本文整理汇总了C#中IEdmEntityType.FullTypeName方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityType.FullTypeName方法的具体用法?C# IEdmEntityType.FullTypeName怎么用?C# IEdmEntityType.FullTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmEntityType
的用法示例。
在下文中一共展示了IEdmEntityType.FullTypeName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateEntry
/// <summary>
/// Validates the type of an entry in a top-level feed.
/// </summary>
/// <param name="entityType">The type of the entry.</param>
internal void ValidateEntry(IEdmEntityType entityType)
{
Debug.Assert(entityType != null, "entityType != null");
// If we don't have a type, store the type of the first item.
if (this.itemType == null)
{
this.itemType = entityType;
}
// Validate the expected and actual types.
if (this.itemType.IsEquivalentTo(entityType))
{
return;
}
// If the types are not equivalent, make sure they have a common base type.
IEdmType commonBaseType = EdmLibraryExtensions.GetCommonBaseType(this.itemType, entityType);
if (commonBaseType == null)
{
throw new ODataException(Strings.FeedWithoutExpectedTypeValidator_IncompatibleTypes(entityType.FullTypeName(), this.itemType.FullTypeName()));
}
this.itemType = (IEdmEntityType)commonBaseType;
}
示例2: ValidateEntryInExpandedLink
/// <summary>
/// Validates an entry in an expanded link to make sure the entity types match.
/// </summary>
/// <param name="entryEntityType">The <see cref="IEdmEntityType"/> of the entry.</param>
/// <param name="parentNavigationPropertyType">The type of the parent navigation property.</param>
internal static void ValidateEntryInExpandedLink(IEdmEntityType entryEntityType, IEdmEntityType parentNavigationPropertyType)
{
if (parentNavigationPropertyType == null)
{
return;
}
Debug.Assert(entryEntityType != null, "If we have a parent navigation property type we should also have an entry type.");
// Make sure the entity types are compatible
if (!parentNavigationPropertyType.IsAssignableFrom(entryEntityType))
{
throw new ODataException(Strings.WriterValidationUtils_EntryTypeInExpandedLinkNotCompatibleWithNavigationPropertyType(entryEntityType.FullTypeName(), parentNavigationPropertyType.FullTypeName()));
}
}
示例3: ValidateNavigationPropertyDefined
/// <summary>
/// Validates that a navigation property with the specified name exists on a given entity type.
/// The entity type can be null if no metadata is available.
/// </summary>
/// <param name="propertyName">The name of the property to validate.</param>
/// <param name="owningEntityType">The owning entity type or null if no metadata is available.</param>
/// <returns>The <see cref="IEdmProperty"/> instance representing the navigation property with name <paramref name="propertyName"/>
/// or null if no metadata is available.</returns>
internal static IEdmNavigationProperty ValidateNavigationPropertyDefined(string propertyName, IEdmEntityType owningEntityType)
{
Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");
if (owningEntityType == null)
{
return null;
}
IEdmProperty property = ValidatePropertyDefined(propertyName, owningEntityType);
if (property == null)
{
// We don't support open navigation properties
Debug.Assert(owningEntityType.IsOpen, "We should have already failed on non-existing property on a closed type.");
throw new ODataException(Strings.ValidationUtils_OpenNavigationProperty(propertyName, owningEntityType.FullTypeName()));
}
if (property.PropertyKind != EdmPropertyKind.Navigation)
{
// The property must be a navigation property
throw new ODataException(Strings.ValidationUtils_NavigationPropertyExpected(propertyName, owningEntityType.FullTypeName(), property.PropertyKind.ToString()));
}
return (IEdmNavigationProperty)property;
}
示例4: TryBindKeyPropertyValue
/// <summary>
/// Binds a key property value.
/// </summary>
/// <param name="namedValue">The named value to bind.</param>
/// <param name="collectionItemEntityType">The type of a single item in a collection to apply the key value to.</param>
/// <param name="keys">Dictionary of alias to keys.</param>
/// <param name="keyPropertyValue">The bound key property value node.</param>
/// <returns>The bound key property value node.</returns>
private bool TryBindKeyPropertyValue(NamedValue namedValue, IEdmEntityType collectionItemEntityType, IDictionary<string, IEdmProperty> keys, out KeyPropertyValue keyPropertyValue)
{
// These are exception checks because the data comes directly from the potentially user specified tree.
ExceptionUtils.CheckArgumentNotNull(namedValue, "namedValue");
ExceptionUtils.CheckArgumentNotNull(namedValue.Value, "namedValue.Value");
Debug.Assert(collectionItemEntityType != null, "collectionItemType != null");
IEdmProperty keyProperty = null;
if (namedValue.Name == null)
{
foreach (IEdmProperty p in keys.Values)
{
if (keyProperty == null)
{
keyProperty = p;
}
else
{
throw new ODataException(ODataErrorStrings.MetadataBinder_UnnamedKeyValueOnTypeWithMultipleKeyProperties(collectionItemEntityType.FullTypeName()));
}
}
}
else
{
keyProperty = keys.SingleOrDefault(k => string.CompareOrdinal(k.Key, namedValue.Name) == 0).Value;
if (keyProperty == null)
{
keyPropertyValue = null;
return false;
}
}
IEdmTypeReference keyPropertyType = keyProperty.Type;
SingleValueNode value = (SingleValueNode)this.keyValueBindMethod(namedValue.Value);
// TODO: Check that the value is of primitive type
Debug.Assert(keyPropertyType.IsODataPrimitiveTypeKind(), "The key's type must be primitive.");
value = MetadataBindingUtils.ConvertToTypeIfNeeded(value, keyPropertyType);
Debug.Assert(keyProperty != null, "keyProperty != null");
keyPropertyValue = new KeyPropertyValue()
{
KeyProperty = keyProperty,
KeyValue = value
};
return true;
}
示例5: ValidateNavigationPropertyDefined
/// <summary>
/// Validates that a navigation property with the specified name exists on a given entity type.
/// The entity type can be null if no metadata is available.
/// </summary>
/// <param name="propertyName">The name of the property to validate.</param>
/// <param name="owningEntityType">The owning entity type or null if no metadata is available.</param>
/// <param name="messageReaderSettings">The message reader settings being used.</param>
/// <returns>The <see cref="IEdmNavigationProperty"/> instance representing the navigation property with name <paramref name="propertyName"/>
/// or null if no metadata is available.</returns>
internal static IEdmNavigationProperty ValidateNavigationPropertyDefined(
string propertyName,
IEdmEntityType owningEntityType,
ODataMessageReaderSettings messageReaderSettings)
{
Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");
Debug.Assert(messageReaderSettings != null, "messageReaderSettings != null");
if (owningEntityType == null)
{
return null;
}
IEdmProperty property = ValidateLinkPropertyDefined(propertyName, owningEntityType, messageReaderSettings);
if (property == null)
{
if (owningEntityType.IsOpen && !messageReaderSettings.ReportUndeclaredLinkProperties)
{
// We don't support open navigation properties
throw new ODataException(Strings.ValidationUtils_OpenNavigationProperty(propertyName, owningEntityType.FullTypeName()));
}
}
else if (property.PropertyKind != EdmPropertyKind.Navigation)
{
// The property must be a navigation property
throw new ODataException(Strings.ValidationUtils_NavigationPropertyExpected(propertyName, owningEntityType.FullTypeName(), property.PropertyKind.ToString()));
}
return (IEdmNavigationProperty)property;
}
示例6: WriteFeed
/// <summary>
/// Writes an OData feed.
/// </summary>
/// <param name="writer">The ODataWriter that will write the feed.</param>
/// <param name="entityType">The type of the entity in the feed.</param>
/// <param name="entries">The items from the data store to write to the feed.</param>
/// <param name="entitySet">The entity set in the model that the feed belongs to.</param>
/// <param name="targetVersion">The OData version this segment is targeting.</param>
/// <param name="selectExpandClause">The SelectExpandClause.</param>
public static void WriteFeed(ODataWriter writer, IEdmEntityType entityType, IEnumerable entries, IEdmEntitySetBase entitySet, ODataVersion targetVersion, SelectExpandClause selectExpandClause, long? count, Uri deltaLink, Uri nextPageLink, Dictionary<string, string> incomingHeaders = null)
{
var feed = new ODataFeed
{
Id = entitySet == null ? null : new Uri(ServiceConstants.ServiceBaseUri, entitySet.Name),
DeltaLink = deltaLink,
NextPageLink = nextPageLink
};
if (entitySet == null)
{
feed.SetSerializationInfo(new ODataFeedAndEntrySerializationInfo()
{
NavigationSourceEntityTypeName = entityType.FullTypeName(),
NavigationSourceName = null,
NavigationSourceKind = EdmNavigationSourceKind.UnknownEntitySet,
IsFromCollection = true
});
}
if (count.HasValue)
{
feed.Count = count;
}
writer.WriteStart(feed);
foreach (var element in entries)
{
WriteEntry(writer, element, entitySet, targetVersion, selectExpandClause, incomingHeaders);
}
writer.WriteEnd();
}
示例7: ValidateEntryMetadataResource
/// <summary>
/// Validates that the specified <paramref name="entry"/> is a valid entry as per the specified type.
/// </summary>
/// <param name="entry">The entry to validate.</param>
/// <param name="entityType">Optional entity type to validate the entry against.</param>
/// <param name="model">Model containing the entity type.</param>
/// <param name="validateMediaResource">true if the validation of the default MediaResource should be done; false otherwise.</param>
/// <remarks>If the <paramref name="entityType"/> is available only entry-level tests are performed, properties and such are not validated.</remarks>
internal static void ValidateEntryMetadataResource(ODataEntry entry, IEdmEntityType entityType, IEdmModel model, bool validateMediaResource)
{
Debug.Assert(entry != null, "entry != null");
if (entityType != null)
{
Debug.Assert(model != null, "model != null");
Debug.Assert(model.IsUserModel(), "model.IsUserModel()");
if (validateMediaResource)
{
if (entry.MediaResource == null)
{
if (entityType.HasStream)
{
throw new ODataException(Strings.ValidationUtils_EntryWithoutMediaResourceAndMLEType(entityType.FullTypeName()));
}
}
else
{
if (!entityType.HasStream)
{
throw new ODataException(Strings.ValidationUtils_EntryWithMediaResourceAndNonMLEType(entityType.FullTypeName()));
}
}
}
}
}