本文整理汇总了C#中IEdmStructuredType.FullTypeName方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmStructuredType.FullTypeName方法的具体用法?C# IEdmStructuredType.FullTypeName怎么用?C# IEdmStructuredType.FullTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmStructuredType
的用法示例。
在下文中一共展示了IEdmStructuredType.FullTypeName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertNonTypeTokenToSegment
/// <summary>
/// Build a segment from a token.
/// </summary>
/// <param name="tokenIn">the token to bind</param>
/// <param name="model">The model.</param>
/// <param name="edmType">the type of the current scope based on type segments.</param>
/// <param name="resolver">Resolver for uri parser.</param>
/// <returns>The segment created from the token.</returns>
public static ODataPathSegment ConvertNonTypeTokenToSegment(PathSegmentToken tokenIn, IEdmModel model, IEdmStructuredType edmType, ODataUriResolver resolver = null)
{
if (resolver == null)
{
resolver = ODataUriResolver.Default;
}
ODataPathSegment nextSegment;
if (TryBindAsDeclaredProperty(tokenIn, edmType, resolver, out nextSegment))
{
return nextSegment;
}
// Operations must be container-qualified, and because the token type indicates it was not a .-seperated identifier, we should not try to look up operations.
if (tokenIn.IsNamespaceOrContainerQualified())
{
if (TryBindAsOperation(tokenIn, model, edmType, out nextSegment))
{
return nextSegment;
}
// If an action or function is requested in a selectItem using a qualifiedActionName or a qualifiedFunctionName
// and that operation cannot be bound to the entities requested, the service MUST ignore the selectItem.
if (!edmType.IsOpen)
{
return null;
}
}
if (edmType.IsOpen)
{
return new OpenPropertySegment(tokenIn.Identifier);
}
throw new ODataException(ODataErrorStrings.MetadataBinder_PropertyNotDeclared(edmType.FullTypeName(), tokenIn.Identifier));
}
示例2: SetDynamicProperty
internal static void SetDynamicProperty(object resource, string propertyName, object value,
IEdmStructuredType structuredType, ODataDeserializerContext readContext)
{
IDelta delta = resource as IDelta;
if (delta != null)
{
delta.TrySetPropertyValue(propertyName, value);
}
else
{
PropertyInfo propertyInfo = EdmLibHelpers.GetDynamicPropertyDictionary(structuredType,
readContext.Model);
if (propertyInfo == null)
{
return;
}
IDictionary<string, object> dynamicPropertyDictionary;
object dynamicDictionaryObject = propertyInfo.GetValue(resource);
if (dynamicDictionaryObject == null)
{
if (!propertyInfo.CanWrite)
{
throw Error.InvalidOperation(SRResources.CannotSetDynamicPropertyDictionary, propertyName,
resource.GetType().FullName);
}
dynamicPropertyDictionary = new Dictionary<string, object>();
propertyInfo.SetValue(resource, dynamicPropertyDictionary);
}
else
{
dynamicPropertyDictionary = (IDictionary<string, object>)dynamicDictionaryObject;
}
if (dynamicPropertyDictionary.ContainsKey(propertyName))
{
throw Error.InvalidOperation(SRResources.DuplicateDynamicPropertyNameFound,
propertyName, structuredType.FullTypeName());
}
dynamicPropertyDictionary.Add(propertyName, value);
}
}
示例3: ResolveProperty
/// <summary>
/// Resolve property from property name
/// </summary>
/// <param name="type">The declaring type.</param>
/// <param name="propertyName">The property name.</param>
/// <returns>The resolved <see cref="IEdmProperty"/></returns>
public virtual IEdmProperty ResolveProperty(IEdmStructuredType type, string propertyName)
{
if (EnableCaseInsensitive)
{
var result = type.Properties()
.Where(_ => string.Equals(propertyName, _.Name, StringComparison.OrdinalIgnoreCase))
.ToList();
if (result.Count == 1)
{
return result.Single();
}
else if (result.Count > 1)
{
throw new ODataException(Strings.UriParserMetadata_MultipleMatchingPropertiesFound(propertyName, type.FullTypeName()));
}
}
return type.FindProperty(propertyName);
}
示例4: GetSchemaFromModel
private static RecordSchema GetSchemaFromModel(IEdmStructuredType type)
{
if (type.IsOpen)
{
throw new ApplicationException("not supported.");
}
RecordSchema rs = Schema.CreateRecord(type.FullTypeName(), null);
Schema.SetFields(rs, type.Properties().Select(property => Schema.CreateField(property.Name, GetSchemaFromModel(property.Type))));
return rs;
}
示例5: ValidatePropertyDefined
/// <summary>
/// Validates that a property with the specified name exists on a given structured type.
/// The structured type can be null if no metadata is available.
/// </summary>
/// <param name="propertyName">The name of the property to validate.</param>
/// <param name="owningStructuredType">The owning type of the property with name <paramref name="propertyName"/>
/// or null if no metadata is available.</param>
/// <param name="throwOnMissingProperty">Whether throw exception on missing property.</param>
/// <returns>The <see cref="IEdmProperty"/> instance representing the property with name <paramref name="propertyName"/>
/// or null if no metadata is available.</returns>
internal static IEdmProperty ValidatePropertyDefined(
string propertyName,
IEdmStructuredType owningStructuredType,
bool throwOnMissingProperty = true)
{
Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");
if (owningStructuredType == null)
{
return null;
}
IEdmProperty property = owningStructuredType.FindProperty(propertyName);
// verify that the property is declared if the type is not an open type.
if (throwOnMissingProperty && !owningStructuredType.IsOpen && property == null)
{
throw new ODataException(Strings.ValidationUtils_PropertyDoesNotExistOnType(propertyName, owningStructuredType.FullTypeName()));
}
return property;
}
示例6: ValidateLinkPropertyDefined
/// <summary>
/// Validates that a property with the specified name exists on a given structured type.
/// The structured type can be null if no metadata is available.
/// </summary>
/// <param name="propertyName">The name of the property to validate.</param>
/// <param name="owningStructuredType">The owning type of the property with name <paramref name="propertyName"/>
/// or null if no metadata is available.</param>
/// <param name="messageReaderSettings">The message reader settings being used.</param>
/// <returns>The <see cref="IEdmProperty"/> instance representing the property with name <paramref name="propertyName"/>
/// or null if no metadata is available.</returns>
internal static IEdmProperty ValidateLinkPropertyDefined(string propertyName, IEdmStructuredType owningStructuredType, ODataMessageReaderSettings messageReaderSettings)
{
Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");
Debug.Assert(messageReaderSettings != null, "messageReaderSettings != null");
if (owningStructuredType == null)
{
return null;
}
IEdmProperty property = FindDefinedProperty(propertyName, owningStructuredType);
if (property == null && !owningStructuredType.IsOpen)
{
if (!messageReaderSettings.ReportUndeclaredLinkProperties)
{
throw new ODataException(Strings.ValidationUtils_PropertyDoesNotExistOnType(propertyName, owningStructuredType.FullTypeName()));
}
}
return property;
}
示例7: ApplyDynamicProperty
private static bool ApplyDynamicProperty(ODataProperty property, IEdmStructuredType structuredType,
object resource, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
{
PropertyInfo propertyInfo = EdmLibHelpers.GetDynamicPropertyDictionary(structuredType,
readContext.Model);
if (propertyInfo == null)
{
return false;
}
IDictionary<string, object> dynamicPropertyDictionary = propertyInfo.GetValue(resource)
as IDictionary<string, object>;
if (dynamicPropertyDictionary == null)
{
dynamicPropertyDictionary = new Dictionary<string, object>();
propertyInfo.SetValue(resource, dynamicPropertyDictionary);
}
if (dynamicPropertyDictionary.ContainsKey(property.Name))
{
throw Error.InvalidOperation(SRResources.DuplicateDynamicPropertyNameFound,
property.Name, structuredType.FullTypeName());
}
EdmTypeKind propertyKind;
IEdmTypeReference propertyType = null;
object value = ConvertValue(property.Value, ref propertyType, deserializerProvider, readContext, out propertyKind);
if (propertyKind == EdmTypeKind.Collection)
{
throw Error.InvalidOperation(SRResources.CollectionNotAllowedAsDynamicProperty, property.Name);
}
if (propertyKind == EdmTypeKind.Enum)
{
ODataEnumValue enumValue = (ODataEnumValue)value;
IEdmModel model = readContext.Model;
IEdmType edmType = model.FindType(enumValue.TypeName);
if (edmType == null)
{
return false;
}
Type enumType = EdmLibHelpers.GetClrType(edmType, model);
value = Enum.Parse(enumType, enumValue.Value);
}
dynamicPropertyDictionary.Add(property.Name, value);
return true;
}