Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / TypeRefElement.cs / 1305376 / TypeRefElement.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using Som = System.Data.EntityModel.SchemaObjectModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.Xml;
using System.Xml.Schema;
using System.Data;
using System.IO;
using System.Data.Metadata.Edm;
using System.Data.Entity;
using System.Text;
namespace System.Data.EntityModel.SchemaObjectModel
{
class TypeRefElement : ModelFunctionTypeElement
{
#region constructor
///
///
///
///
internal TypeRefElement(SchemaElement parentElement)
: base(parentElement)
{
}
#endregion
protected override bool HandleAttribute(XmlReader reader)
{
if (base.HandleAttribute(reader))
{
return true;
}
else if (CanHandleAttribute(reader, XmlConstants.TypeElement))
{
HandleTypeAttribute(reader);
return true;
}
return false;
}
protected void HandleTypeAttribute(XmlReader reader)
{
Debug.Assert(reader != null);
string type;
if (!Utils.GetString(Schema, reader, out type))
return;
if (!Utils.ValidateDottedName(Schema, reader, type))
return;
_unresolvedType = type;
}
internal override bool ResolveNameAndSetTypeUsage(Converter.ConversionCache convertedItemCache, Dictionary newGlobalItems)
{
if (_type is ScalarType) //Create and store type usage for scalar type
{
_typeUsageBuilder.ValidateAndSetTypeUsage(_type as ScalarType, false);
_typeUsage = _typeUsageBuilder.TypeUsage;
return true;
}
else //Try to resolve edm type. If not now, it will resolve in the second pass
{
EdmType edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
if (edmType != null)
{
_typeUsageBuilder.ValidateAndSetTypeUsage(edmType, false); //use typeusagebuilder so dont lose facet information
_typeUsage = _typeUsageBuilder.TypeUsage;
}
return _typeUsage != null;
}
}
internal override void WriteIdentity(StringBuilder builder)
{
Debug.Assert(UnresolvedType != null && !UnresolvedType.Trim().Equals(String.Empty));
builder.Append(UnresolvedType);
}
internal override TypeUsage GetTypeUsage()
{
Debug.Assert(_typeUsage != null);
return _typeUsage;
}
internal override void Validate()
{
base.Validate();
if (_type != null && _type is ScalarType == false && _typeUsageBuilder.HasUserDefinedFacets)
{
//Non-scalar return type should not have Facets
AddError(ErrorCode.ModelFuncionFacetOnNonScalarType, EdmSchemaErrorSeverity.Error, Strings.FacetsOnNonScalarType(_type.FQName));
}
if (_type == null && _typeUsageBuilder.HasUserDefinedFacets)
{
//Type attribute not specified but facets exist
AddError(ErrorCode.ModelFunctionIncorrectlyPlacedFacet, EdmSchemaErrorSeverity.Error, Strings.FacetDeclarationRequiresTypeAttribute);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using Som = System.Data.EntityModel.SchemaObjectModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.Xml;
using System.Xml.Schema;
using System.Data;
using System.IO;
using System.Data.Metadata.Edm;
using System.Data.Entity;
using System.Text;
namespace System.Data.EntityModel.SchemaObjectModel
{
class TypeRefElement : ModelFunctionTypeElement
{
#region constructor
///
///
///
///
internal TypeRefElement(SchemaElement parentElement)
: base(parentElement)
{
}
#endregion
protected override bool HandleAttribute(XmlReader reader)
{
if (base.HandleAttribute(reader))
{
return true;
}
else if (CanHandleAttribute(reader, XmlConstants.TypeElement))
{
HandleTypeAttribute(reader);
return true;
}
return false;
}
protected void HandleTypeAttribute(XmlReader reader)
{
Debug.Assert(reader != null);
string type;
if (!Utils.GetString(Schema, reader, out type))
return;
if (!Utils.ValidateDottedName(Schema, reader, type))
return;
_unresolvedType = type;
}
internal override bool ResolveNameAndSetTypeUsage(Converter.ConversionCache convertedItemCache, Dictionary newGlobalItems)
{
if (_type is ScalarType) //Create and store type usage for scalar type
{
_typeUsageBuilder.ValidateAndSetTypeUsage(_type as ScalarType, false);
_typeUsage = _typeUsageBuilder.TypeUsage;
return true;
}
else //Try to resolve edm type. If not now, it will resolve in the second pass
{
EdmType edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
if (edmType != null)
{
_typeUsageBuilder.ValidateAndSetTypeUsage(edmType, false); //use typeusagebuilder so dont lose facet information
_typeUsage = _typeUsageBuilder.TypeUsage;
}
return _typeUsage != null;
}
}
internal override void WriteIdentity(StringBuilder builder)
{
Debug.Assert(UnresolvedType != null && !UnresolvedType.Trim().Equals(String.Empty));
builder.Append(UnresolvedType);
}
internal override TypeUsage GetTypeUsage()
{
Debug.Assert(_typeUsage != null);
return _typeUsage;
}
internal override void Validate()
{
base.Validate();
if (_type != null && _type is ScalarType == false && _typeUsageBuilder.HasUserDefinedFacets)
{
//Non-scalar return type should not have Facets
AddError(ErrorCode.ModelFuncionFacetOnNonScalarType, EdmSchemaErrorSeverity.Error, Strings.FacetsOnNonScalarType(_type.FQName));
}
if (_type == null && _typeUsageBuilder.HasUserDefinedFacets)
{
//Type attribute not specified but facets exist
AddError(ErrorCode.ModelFunctionIncorrectlyPlacedFacet, EdmSchemaErrorSeverity.Error, Strings.FacetDeclarationRequiresTypeAttribute);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RadioButton.cs
- PropertyRecord.cs
- WebPartTransformerCollection.cs
- IBuiltInEvidence.cs
- Image.cs
- FastPropertyAccessor.cs
- RemoteX509Token.cs
- ClientSession.cs
- TreeBuilder.cs
- SecUtil.cs
- ListViewInsertEventArgs.cs
- IList.cs
- HttpChannelBindingToken.cs
- AutomationElement.cs
- EntityDataSourceStatementEditorForm.cs
- HttpListenerResponse.cs
- SqlDataSourceView.cs
- PropertyBuilder.cs
- LayoutUtils.cs
- ProviderSettingsCollection.cs
- _AutoWebProxyScriptEngine.cs
- WebPartManagerInternals.cs
- TokenBasedSet.cs
- SoapAttributes.cs
- SqlConnection.cs
- UserPreferenceChangingEventArgs.cs
- FrameworkElementFactory.cs
- ButtonPopupAdapter.cs
- WorkflowDefinitionDispenser.cs
- FixedSOMTableCell.cs
- ConfigXmlWhitespace.cs
- ProtocolsSection.cs
- recordstatescratchpad.cs
- PeerName.cs
- PkcsMisc.cs
- ParseElementCollection.cs
- ThicknessAnimationBase.cs
- addressfiltermode.cs
- XPathException.cs
- DefaultExpression.cs
- WebPartMovingEventArgs.cs
- MLangCodePageEncoding.cs
- FlowLayoutSettings.cs
- InfoCardBinaryReader.cs
- Privilege.cs
- ping.cs
- BitmapCacheBrush.cs
- CalendarDesigner.cs
- HotSpotCollection.cs
- wgx_render.cs
- EndPoint.cs
- UIPermission.cs
- ChtmlTextBoxAdapter.cs
- AsyncDataRequest.cs
- TextViewBase.cs
- XmlHierarchyData.cs
- ResourceProperty.cs
- InsufficientMemoryException.cs
- MetaTableHelper.cs
- StringAnimationUsingKeyFrames.cs
- ThousandthOfEmRealDoubles.cs
- FSWPathEditor.cs
- Semaphore.cs
- ZipFileInfoCollection.cs
- FormatConvertedBitmap.cs
- brushes.cs
- SoapSchemaImporter.cs
- InternalsVisibleToAttribute.cs
- SessionStateModule.cs
- NameTable.cs
- EventSinkHelperWriter.cs
- FileDetails.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ZipIOExtraFieldPaddingElement.cs
- ProtocolViolationException.cs
- TextSelection.cs
- SubtreeProcessor.cs
- AQNBuilder.cs
- StyleBamlRecordReader.cs
- WebPartDesigner.cs
- EncodingStreamWrapper.cs
- ScriptBehaviorDescriptor.cs
- NameValueConfigurationElement.cs
- FlowLayoutSettings.cs
- ProfessionalColors.cs
- CodeNamespaceCollection.cs
- CodeDelegateInvokeExpression.cs
- SystemIPGlobalProperties.cs
- SimpleHandlerFactory.cs
- PrintingPermissionAttribute.cs
- HandlerWithFactory.cs
- AnimationLayer.cs
- TextBox.cs
- XmlCustomFormatter.cs
- XmlLoader.cs
- DefaultParameterValueAttribute.cs
- ScrollBar.cs
- Column.cs
- DataSourceProvider.cs
- CancellationHandler.cs