Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / ReferenceTypeElement.cs / 1305376 / ReferenceTypeElement.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 ReferenceTypeElement : ModelFunctionTypeElement
{
#region constructor
///
///
///
///
internal ReferenceTypeElement(SchemaElement parentElement)
: base(parentElement)
{
}
#endregion
protected override bool HandleAttribute(XmlReader reader)
{
if (base.HandleAttribute(reader))
{
return true;
}
else if (CanHandleAttribute(reader, XmlConstants.TypeElement))
{
HandleTypeElementAttribute(reader);
return true;
}
return false;
}
protected void HandleTypeElementAttribute(XmlReader reader)
{
Debug.Assert(reader != null);
string type;
if (!Utils.GetString(Schema, reader, out type))
return;
_unresolvedType = type;
}
internal override void WriteIdentity(StringBuilder builder)
{
Debug.Assert(UnresolvedType != null && !UnresolvedType.Trim().Equals(String.Empty));
builder.Append("Ref(" + UnresolvedType + ")");
}
internal override TypeUsage GetTypeUsage()
{
return _typeUsage;
}
internal override bool ResolveNameAndSetTypeUsage(Converter.ConversionCache convertedItemCache, Dictionary newGlobalItems)
{
if (_typeUsage == null)
{
Debug.Assert(!(_type is ScalarType));
EdmType edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
EntityType entityType = edmType as EntityType;
Debug.Assert(entityType != null);
RefType refType = new RefType(entityType);
refType.AddMetadataProperties(this.OtherContent);
_typeUsage = TypeUsage.Create(refType);
}
return true;
}
internal override void Validate()
{
base.Validate();
if (_type != null && !(_type is SchemaEntityType))
{
//Ref type refers to non entity type
AddError(ErrorCode.ReferenceToNonEntityType, EdmSchemaErrorSeverity.Error, Strings.ReferenceToNonEntityType(_type.FQName));
}
}
}
}
// 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 ReferenceTypeElement : ModelFunctionTypeElement
{
#region constructor
///
///
///
///
internal ReferenceTypeElement(SchemaElement parentElement)
: base(parentElement)
{
}
#endregion
protected override bool HandleAttribute(XmlReader reader)
{
if (base.HandleAttribute(reader))
{
return true;
}
else if (CanHandleAttribute(reader, XmlConstants.TypeElement))
{
HandleTypeElementAttribute(reader);
return true;
}
return false;
}
protected void HandleTypeElementAttribute(XmlReader reader)
{
Debug.Assert(reader != null);
string type;
if (!Utils.GetString(Schema, reader, out type))
return;
_unresolvedType = type;
}
internal override void WriteIdentity(StringBuilder builder)
{
Debug.Assert(UnresolvedType != null && !UnresolvedType.Trim().Equals(String.Empty));
builder.Append("Ref(" + UnresolvedType + ")");
}
internal override TypeUsage GetTypeUsage()
{
return _typeUsage;
}
internal override bool ResolveNameAndSetTypeUsage(Converter.ConversionCache convertedItemCache, Dictionary newGlobalItems)
{
if (_typeUsage == null)
{
Debug.Assert(!(_type is ScalarType));
EdmType edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
EntityType entityType = edmType as EntityType;
Debug.Assert(entityType != null);
RefType refType = new RefType(entityType);
refType.AddMetadataProperties(this.OtherContent);
_typeUsage = TypeUsage.Create(refType);
}
return true;
}
internal override void Validate()
{
base.Validate();
if (_type != null && !(_type is SchemaEntityType))
{
//Ref type refers to non entity type
AddError(ErrorCode.ReferenceToNonEntityType, EdmSchemaErrorSeverity.Error, Strings.ReferenceToNonEntityType(_type.FQName));
}
}
}
}
// 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
- LoginCancelEventArgs.cs
- DataMemberFieldConverter.cs
- ClaimSet.cs
- PackageController.cs
- GeneralTransform2DTo3D.cs
- HebrewNumber.cs
- WarningException.cs
- FacetDescription.cs
- QueryConverter.cs
- PropertyGridCommands.cs
- WindowsIdentity.cs
- OleAutBinder.cs
- UIElementCollection.cs
- BuildProvidersCompiler.cs
- ServiceContractViewControl.cs
- RequestQueue.cs
- ObjectNavigationPropertyMapping.cs
- EntityDataSourceColumn.cs
- ItemCollection.cs
- JavaScriptString.cs
- DodSequenceMerge.cs
- XomlCompilerError.cs
- HttpListenerElement.cs
- Int16Converter.cs
- DataTableMappingCollection.cs
- ParentQuery.cs
- Component.cs
- SerializationStore.cs
- NoResizeHandleGlyph.cs
- MetadataArtifactLoaderResource.cs
- FontStyles.cs
- PenCursorManager.cs
- ReflectionPermission.cs
- WorkflowValidationFailedException.cs
- DashStyle.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- ThemeDirectoryCompiler.cs
- Baml2006ReaderSettings.cs
- PrePrepareMethodAttribute.cs
- BaseResourcesBuildProvider.cs
- FragmentQueryProcessor.cs
- DecimalStorage.cs
- BitSet.cs
- ImplicitInputBrush.cs
- ServiceConfigurationTraceRecord.cs
- StorageFunctionMapping.cs
- SingleAnimationBase.cs
- Lazy.cs
- ThemeableAttribute.cs
- ByteStreamMessageEncoder.cs
- WebSysDescriptionAttribute.cs
- AttributeConverter.cs
- ContextMarshalException.cs
- SecurityHelper.cs
- ReflectionPermission.cs
- SyntaxCheck.cs
- TextTreeTextNode.cs
- SafeRightsManagementHandle.cs
- SelectionChangedEventArgs.cs
- KerberosReceiverSecurityToken.cs
- FileDialog.cs
- ParsedRoute.cs
- ZipArchive.cs
- ThumbButtonInfoCollection.cs
- SortedSet.cs
- DuplexSecurityProtocolFactory.cs
- ApplyImportsAction.cs
- AdapterDictionary.cs
- GridViewCellAutomationPeer.cs
- SafeRegistryHandle.cs
- ToolStripRenderEventArgs.cs
- XmlElementList.cs
- DockAndAnchorLayout.cs
- DispatcherHookEventArgs.cs
- GlobalizationSection.cs
- OracleRowUpdatedEventArgs.cs
- HtmlProps.cs
- PersistenceProvider.cs
- SystemResourceHost.cs
- XamlBrushSerializer.cs
- SortKey.cs
- ReadOnlyHierarchicalDataSourceView.cs
- DelegateArgument.cs
- QueryActivatableWorkflowsCommand.cs
- ObjectItemCollection.cs
- StatusBarPanel.cs
- OrderedEnumerableRowCollection.cs
- BinaryWriter.cs
- ObjectListDesigner.cs
- IndentedTextWriter.cs
- Message.cs
- ContentElement.cs
- Package.cs
- PerspectiveCamera.cs
- FrameworkReadOnlyPropertyMetadata.cs
- CustomPopupPlacement.cs
- XmlChildNodes.cs
- DynamicRenderer.cs
- PropertyEntry.cs
- ObjectDataSourceStatusEventArgs.cs