本文整理汇总了C#中IEdmEntityTypeReference.FullName方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityTypeReference.FullName方法的具体用法?C# IEdmEntityTypeReference.FullName怎么用?C# IEdmEntityTypeReference.FullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmEntityTypeReference
的用法示例。
在下文中一共展示了IEdmEntityTypeReference.FullName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFeed
/// <summary>
/// Deserializes the given <paramref name="feed"/> under the given <paramref name="readContext"/>.
/// </summary>
/// <param name="feed">The feed to deserialize.</param>
/// <param name="readContext">The deserializer context.</param>
/// <param name="elementType">The element type of the feed being read.</param>
/// <returns>The deserialized feed object.</returns>
public virtual IEnumerable ReadFeed(ODataFeedWithEntries feed, IEdmEntityTypeReference elementType, ODataDeserializerContext readContext)
{
ODataEdmTypeDeserializer deserializer = DeserializerProvider.GetEdmTypeDeserializer(elementType);
if (deserializer == null)
{
throw new SerializationException(
Error.Format(SRResources.TypeCannotBeDeserialized, elementType.FullName(), typeof(ODataMediaTypeFormatter).Name));
}
foreach (ODataEntryWithNavigationLinks entry in feed.Entries)
{
yield return deserializer.ReadInline(entry, elementType, readContext);
}
}
示例2: ApplyNavigationProperty
/// <summary>
/// Deserializes the navigation property from <paramref name="navigationLinkWrapper"/> into <paramref name="entityResource"/>.
/// </summary>
/// <param name="entityResource">The object into which the navigation property should be read.</param>
/// <param name="navigationLinkWrapper">The navigation link.</param>
/// <param name="entityType">The entity type of the entity resource.</param>
/// <param name="readContext">The deserializer context.</param>
public virtual void ApplyNavigationProperty(object entityResource, ODataNavigationLinkWithItems navigationLinkWrapper,
IEdmEntityTypeReference entityType, ODataDeserializerContext readContext)
{
if (navigationLinkWrapper == null)
{
throw Error.ArgumentNull("navigationLinkWrapper");
}
if (entityResource == null)
{
throw Error.ArgumentNull("entityResource");
}
IEdmNavigationProperty navigationProperty = entityType.FindProperty(navigationLinkWrapper.NavigationLink.Name) as IEdmNavigationProperty;
if (navigationProperty == null)
{
throw new ODataException(
Error.Format(SRResources.NavigationPropertyNotfound, navigationLinkWrapper.NavigationLink.Name, entityType.FullName()));
}
foreach (ODataItemBase childItem in navigationLinkWrapper.NestedItems)
{
ODataEntityReferenceLinkBase entityReferenceLink = childItem as ODataEntityReferenceLinkBase;
if (entityReferenceLink != null)
{
// ignore links.
continue;
}
ODataFeedWithEntries feed = childItem as ODataFeedWithEntries;
if (feed != null)
{
ApplyFeedInNavigationProperty(navigationProperty, entityResource, feed, readContext);
continue;
}
// It must be entry by now.
ODataEntryWithNavigationLinks entry = (ODataEntryWithNavigationLinks)childItem;
if (entry != null)
{
ApplyEntryInNavigationProperty(navigationProperty, entityResource, entry, readContext);
}
}
}
示例3: CreateEntityResource
/// <summary>
/// Creates a new instance of the backing CLR object for the given entity type.
/// </summary>
/// <param name="entityType">The EDM type of the entity to create.</param>
/// <param name="readContext">The deserializer context.</param>
/// <returns>The created CLR object.</returns>
public virtual object CreateEntityResource(IEdmEntityTypeReference entityType, ODataDeserializerContext readContext)
{
if (readContext == null)
{
throw Error.ArgumentNull("readContext");
}
if (entityType == null)
{
throw Error.ArgumentNull("entityType");
}
IEdmModel model = readContext.Model;
if (model == null)
{
throw Error.Argument("readContext", SRResources.ModelMissingFromReadContext);
}
if (readContext.IsUntyped)
{
return new EdmEntityObject(entityType);
}
else
{
Type clrType = EdmLibHelpers.GetClrType(entityType, model);
if (clrType == null)
{
throw new ODataException(
Error.Format(SRResources.MappingDoesNotContainEntityType, entityType.FullName()));
}
if (readContext.IsDeltaOfT)
{
IEnumerable<string> structuralProperties = entityType.StructuralProperties()
.Select(edmProperty => EdmLibHelpers.GetClrPropertyName(edmProperty, model));
return Activator.CreateInstance(readContext.ResourceType, clrType, structuralProperties);
}
else
{
return Activator.CreateInstance(clrType);
}
}
}
示例4: ReadEntry
/// <summary>
/// Deserializes the given <paramref name="entryWrapper"/> under the given <paramref name="readContext"/>.
/// </summary>
/// <param name="entryWrapper">The OData entry to deserialize.</param>
/// <param name="entityType">The entity type of the entry to deserialize.</param>
/// <param name="readContext">The deserializer context.</param>
/// <returns>The deserialized entity.</returns>
public virtual object ReadEntry(ODataEntryWithNavigationLinks entryWrapper, IEdmEntityTypeReference entityType,
ODataDeserializerContext readContext)
{
if (entryWrapper == null)
{
throw Error.ArgumentNull("entryWrapper");
}
if (readContext == null)
{
throw Error.ArgumentNull("readContext");
}
if (!String.IsNullOrEmpty(entryWrapper.Entry.TypeName) && entityType.FullName() != entryWrapper.Entry.TypeName)
{
// received a derived type in a base type deserializer. delegate it to the appropriate derived type deserializer.
IEdmModel model = readContext.Model;
if (model == null)
{
throw Error.Argument("readContext", SRResources.ModelMissingFromReadContext);
}
IEdmEntityType actualType = model.FindType(entryWrapper.Entry.TypeName) as IEdmEntityType;
if (actualType == null)
{
throw new ODataException(Error.Format(SRResources.EntityTypeNotInModel, entryWrapper.Entry.TypeName));
}
if (actualType.IsAbstract)
{
string message = Error.Format(SRResources.CannotInstantiateAbstractEntityType, entryWrapper.Entry.TypeName);
throw new ODataException(message);
}
IEdmTypeReference actualEntityType = new EdmEntityTypeReference(actualType, isNullable: false);
ODataEdmTypeDeserializer deserializer = DeserializerProvider.GetEdmTypeDeserializer(actualEntityType);
if (deserializer == null)
{
throw new SerializationException(
Error.Format(SRResources.TypeCannotBeDeserialized, actualEntityType.FullName(), typeof(ODataMediaTypeFormatter).Name));
}
object resource = deserializer.ReadInline(entryWrapper, actualEntityType, readContext);
EdmStructuredObject structuredObject = resource as EdmStructuredObject;
if (structuredObject != null)
{
structuredObject.ExpectedEdmType = entityType.EntityDefinition();
}
return resource;
}
else
{
object resource = CreateEntityResource(entityType, readContext);
ApplyEntityProperties(resource, entryWrapper, entityType, readContext);
return resource;
}
}
示例5: ValidateEntityTypeIsAssignable
/// <summary>
/// Validates that the <paramref name="payloadEntityTypeReference"/> is assignable to the <paramref name="expectedEntityTypeReference"/>
/// and fails if it's not.
/// </summary>
/// <param name="expectedEntityTypeReference">The expected entity type reference, the base type of the entities expected.</param>
/// <param name="payloadEntityTypeReference">The payload entity type reference to validate.</param>
internal static void ValidateEntityTypeIsAssignable(IEdmEntityTypeReference expectedEntityTypeReference, IEdmEntityTypeReference payloadEntityTypeReference)
{
Debug.Assert(expectedEntityTypeReference != null, "expectedEntityTypeReference != null");
Debug.Assert(payloadEntityTypeReference != null, "payloadEntityTypeReference != null");
// Entity types must be assignable
if (!EdmLibraryExtensions.IsAssignableFrom(expectedEntityTypeReference.EntityDefinition(), payloadEntityTypeReference.EntityDefinition()))
{
throw new ODataException(Strings.ValidationUtils_EntryTypeNotAssignableToExpectedType(payloadEntityTypeReference.FullName(), expectedEntityTypeReference.FullName()));
}
}