本文整理汇总了C#中IEdmProperty类的典型用法代码示例。如果您正苦于以下问题:C# IEdmProperty类的具体用法?C# IEdmProperty怎么用?C# IEdmProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEdmProperty类属于命名空间,在下文中一共展示了IEdmProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OrderByProperty
public static IQueryable OrderByProperty(IQueryable query, IEdmModel model, IEdmProperty property, OrderByDirection direction, Type type, bool alreadyOrdered = false)
{
// property aliasing
string propertyName = EdmLibHelpers.GetClrPropertyName(property, model);
LambdaExpression orderByLambda = GetPropertyAccessLambda(type, propertyName);
return OrderBy(query, orderByLambda, direction, type, alreadyOrdered);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:7,代码来源:ExpressionHelpers.cs
示例2: GetPropertyInfo
/// <summary>
/// Gets the property info for the EDM property declared on this type.
/// </summary>
/// <param name="structuredType">The structured type to get the property on.</param>
/// <param name="property">Property instance to get the property info for.</param>
/// <param name="model">The model containing annotations.</param>
/// <returns>Returns the PropertyInfo object for the specified EDM property.</returns>
internal PropertyInfo GetPropertyInfo(IEdmStructuredType structuredType, IEdmProperty property, IEdmModel model)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(structuredType != null, "structuredType != null");
Debug.Assert(property != null, "property != null");
Debug.Assert(model != null, "model != null");
Debug.Assert(property.GetCanReflectOnInstanceTypeProperty(model), "property.CanReflectOnInstanceTypeProperty()");
#if DEBUG
Debug.Assert(structuredType.ContainsProperty(property), "The structuredType does not define the specified property.");
#endif
if (this.propertyInfosDeclaredOnThisType == null)
{
this.propertyInfosDeclaredOnThisType = new Dictionary<IEdmProperty, PropertyInfo>(ReferenceEqualityComparer<IEdmProperty>.Instance);
}
PropertyInfo propertyInfo;
if (!this.propertyInfosDeclaredOnThisType.TryGetValue(property, out propertyInfo))
{
BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;
propertyInfo = structuredType.GetInstanceType(model).GetProperty(property.Name, bindingFlags);
if (propertyInfo == null)
{
throw new ODataException(Strings.PropertyInfoTypeAnnotation_CannotFindProperty(structuredType.ODataFullName(), structuredType.GetInstanceType(model), property.Name));
}
this.propertyInfosDeclaredOnThisType.Add(property, propertyInfo);
}
Debug.Assert(propertyInfo != null, "propertyInfo != null");
return propertyInfo;
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:39,代码来源:PropertyInfoTypeAnnotation.cs
示例3: EdmPropertyValueBinding
public EdmPropertyValueBinding(IEdmProperty boundProperty, IEdmExpression value)
{
EdmUtil.CheckArgumentNull<IEdmProperty>(boundProperty, "boundProperty");
EdmUtil.CheckArgumentNull<IEdmExpression>(value, "value");
this.boundProperty = boundProperty;
[email protected] = value;
}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:EdmPropertyValueBinding.cs
示例4: EdmPropertyReferenceExpression
public EdmPropertyReferenceExpression(IEdmExpression baseExpression, IEdmProperty referencedProperty)
{
EdmUtil.CheckArgumentNull<IEdmExpression>(baseExpression, "baseExpression");
EdmUtil.CheckArgumentNull<IEdmProperty>(referencedProperty, "referencedPropert");
this.baseExpression = baseExpression;
this.referencedProperty = referencedProperty;
}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:EdmPropertyReferenceExpression.cs
示例5: GeneratePropertyAccessQueryNode
/// <summary>
/// Generates a bound query node representing an <see cref="IEdmProperty"/> given an already semantically bound parent node.
/// </summary>
/// <param name="parentNode">The semantically bound source node of this end path token</param>
/// <param name="property">The <see cref="IEdmProperty"/> that will be bound to this node. Must not be primitive collection</param>
/// <returns>QueryNode bound to this property.</returns>
internal static QueryNode GeneratePropertyAccessQueryNode(SingleValueNode parentNode, IEdmProperty property)
{
ExceptionUtils.CheckArgumentNotNull(parentNode, "parent");
ExceptionUtils.CheckArgumentNotNull(property, "property");
// TODO: Remove this check.
// We should verify that the top level of an expression is a bool rather than arbitrarily restrict property types.
// We can get here if there is a query like $filter=MyCollectionProperty eq 'foo' or something.
// If it was $filter=MyCollectionProperty/any(...) then we would have gone down the 'NonRootSegment' code path instead of this one
if (property.Type.IsNonEntityCollectionType())
{
// if this happens to be a top level node (i.e. $filter=MyCollection), then it will fail further up the chain, so
// don't need to worry about checking for that here.
return new CollectionPropertyAccessNode(parentNode, property);
}
if (property.PropertyKind == EdmPropertyKind.Navigation)
{
// These are error cases in practice, but we let ourselves throw later for better context-sensitive error messages
var edmNavigationProperty = (IEdmNavigationProperty)property;
var singleEntityParentNode = (SingleEntityNode)parentNode;
if (edmNavigationProperty.TargetMultiplicity() == EdmMultiplicity.Many)
{
return new CollectionNavigationNode(edmNavigationProperty, singleEntityParentNode);
}
return new SingleNavigationNode(edmNavigationProperty, singleEntityParentNode);
}
return new SingleValuePropertyAccessNode(parentNode, property);
}
开发者ID:TomDu,项目名称:odata.net,代码行数:37,代码来源:EndPathBinder.cs
示例6: SetDeclaredProperty
internal static void SetDeclaredProperty(object resource, EdmTypeKind propertyKind, string propertyName,
object propertyValue, IEdmProperty edmProperty, ODataDeserializerContext readContext)
{
if (propertyKind == EdmTypeKind.Collection)
{
SetCollectionProperty(resource, edmProperty, propertyValue, propertyName);
}
else
{
if (!readContext.IsUntyped)
{
if (propertyKind == EdmTypeKind.Primitive)
{
propertyValue = EdmPrimitiveHelpers.ConvertPrimitiveValue(propertyValue,
GetPropertyType(resource, propertyName));
}
else if (propertyKind == EdmTypeKind.Enum)
{
propertyValue = EnumDeserializationHelpers.ConvertEnumValue(propertyValue,
GetPropertyType(resource, propertyName));
}
}
SetProperty(resource, propertyName, propertyValue);
}
}
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:26,代码来源:DeserializationHelpers.cs
示例7: NullValueReadBehaviorKind
/// <summary>
/// Gets the reader behavior for null property value on the specified property.
/// </summary>
/// <param name="model">The model containing the annotation.</param>
/// <param name="property">The property to check.</param>
/// <returns>The behavior to use when reading null value for this property.</returns>
public static ODataNullValueBehaviorKind NullValueReadBehaviorKind(this IEdmModel model, IEdmProperty property)
{
ExceptionUtils.CheckArgumentNotNull(model, "model");
ExceptionUtils.CheckArgumentNotNull(property, "property");
ODataEdmPropertyAnnotation annotation = model.GetAnnotationValue<ODataEdmPropertyAnnotation>(property);
return annotation == null ? ODataNullValueBehaviorKind.Default : annotation.NullValueReadBehaviorKind;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:14,代码来源:ODataUtils.cs
示例8: PropertyAccessPathSegment
/// <summary>
/// Initializes a new instance of the <see cref="PropertyAccessPathSegment" /> class.
/// </summary>
/// <param name="property">The property being accessed by this segment.</param>
public PropertyAccessPathSegment(IEdmProperty property)
{
if (property == null)
{
throw Error.ArgumentNull("property");
}
Property = property;
PropertyName = property.Name;
}
开发者ID:akrisiun,项目名称:WebApi,代码行数:14,代码来源:PropertyAccessPathSegment.cs
示例9: OrderByPropertyNode
/// <summary>
/// Initializes a new instance of the <see cref="OrderByPropertyNode"/> class.
/// </summary>
/// <param name="property">The <see cref="IEdmProperty"/> for this node.</param>
/// <param name="direction">The <see cref="OrderByDirection"/> for this node.</param>
public OrderByPropertyNode(IEdmProperty property, OrderByDirection direction)
: base(direction)
{
if (property == null)
{
throw Error.ArgumentNull("property");
}
Property = property;
}
开发者ID:joshcomley,项目名称:WebApi,代码行数:15,代码来源:OrderByPropertyNode.cs
示例10: PropertyAccessPathSegment
/// <summary>
/// Initializes a new instance of the <see cref="PropertyAccessPathSegment" /> class.
/// </summary>
/// <param name="previous">The previous segment in the path.</param>
/// <param name="property">The property being accessed by this segment.</param>
public PropertyAccessPathSegment(ODataPathSegment previous, IEdmProperty property)
: base(previous)
{
if (property == null)
{
throw Error.ArgumentNull("property");
}
EdmType = property.Type.Definition;
Property = property;
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:16,代码来源:PropertyAccessPathSegment.cs
示例11: AddProperty
/// <summary>
/// Adds the <paramref name="property"/> to this type.
/// <see cref="IEdmProperty.DeclaringType"/> of the <paramref name="property"/> must be this type.
/// </summary>
/// <param name="property">The property being added.</param>
public void AddProperty(IEdmProperty property)
{
EdmUtil.CheckArgumentNull(property, "property");
if (!Object.ReferenceEquals(this, property.DeclaringType))
{
throw new InvalidOperationException(Edm.Strings.EdmModel_Validator_Semantic_DeclaringTypeMustBeCorrect(property.Name));
}
this.declaredProperties.Add(property);
this.propertiesDictionary.Clear(null);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:17,代码来源:EdmStructuredType.cs
示例12: SetScaleMeasuresAnnotation
public static void SetScaleMeasuresAnnotation(this EdmModel model, IEdmProperty property, byte scale)
{
if (model == null) throw new ArgumentNullException("model");
if (property == null) throw new ArgumentNullException("property");
var target = property;
var term = ScaleTerm;
var expression = new EdmIntegerConstant(scale);
var annotation = new EdmAnnotation(target, term, expression);
annotation.SetSerializationLocation(model, property.ToSerializationLocation());
model.AddVocabularyAnnotation(annotation);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:MeasuresHelpers.cs
示例13: SetISOCurrencyMeasuresAnnotation
public static void SetISOCurrencyMeasuresAnnotation(this EdmModel model, IEdmProperty property, string isoCurrency)
{
if (model == null) throw new ArgumentNullException("model");
if (property == null) throw new ArgumentNullException("property");
var target = property;
var term = ISOCurrencyTerm;
var expression = new EdmStringConstant(isoCurrency);
var annotation = new EdmAnnotation(target, term, expression);
annotation.SetSerializationLocation(model, property.ToSerializationLocation());
model.AddVocabularyAnnotation(annotation);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:MeasuresHelpers.cs
示例14: SetComputedAnnotation
public static void SetComputedAnnotation(EdmModel model, IEdmProperty target)
{
EdmUtil.CheckArgumentNull(model, "model");
EdmUtil.CheckArgumentNull(target, "target");
IEdmBooleanConstantExpression val = new EdmBooleanConstant(true);
IEdmValueTerm term = CoreVocabularyModel.ComputedTerm;
Debug.Assert(term != null, "term!=null");
EdmAnnotation annotation = new EdmAnnotation(target, term, val);
annotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.Inline);
model.SetVocabularyAnnotation(annotation);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:13,代码来源:EdmxWriterTests.cs
示例15: GetPropertyInfo
/// <summary>
/// Gets the property info for the EDM property on the specified type.
/// </summary>
/// <param name="typeReference">The type to get the property on.</param>
/// <param name="property">Property instance to get the property info for.</param>
/// <param name="model">Model containing annotations.</param>
/// <returns>Returns the PropertyInfo object for the specified property.</returns>
/// <remarks>The method searches this type as well as all its base types for the property.</remarks>
internal static PropertyInfo GetPropertyInfo(this IEdmStructuredTypeReference typeReference, IEdmProperty property, IEdmModel model)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(typeReference != null, "typeReference != null");
Debug.Assert(property != null, "property != null");
Debug.Assert(model != null, "model != null");
Debug.Assert(property.GetCanReflectOnInstanceTypeProperty(model), "property.CanReflectOnInstanceTypeProperty()");
#if DEBUG
Debug.Assert(typeReference.ContainsProperty(property), "The typeReference does not define the specified property.");
#endif
IEdmStructuredType structuredType = typeReference.StructuredDefinition();
return PropertyInfoTypeAnnotation.GetPropertyInfoTypeAnnotation(structuredType, model).GetPropertyInfo(structuredType, property, model);
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:22,代码来源:PropertyInfoExtensionMethods.cs
示例16: SetCollectionProperty
internal static void SetCollectionProperty(object resource, IEdmProperty edmProperty, object value)
{
Contract.Assert(edmProperty != null);
if (value != null)
{
string propertyName = edmProperty.Name;
IEnumerable collection = value as IEnumerable;
Contract.Assert(collection != null,
"SetCollectionProperty is always passed the result of ODataFeedDeserializer or ODataCollectionDeserializer");
Type resourceType = resource.GetType();
Type propertyType = GetPropertyType(resource, propertyName);
Type elementType;
if (!propertyType.IsCollection(out elementType))
{
string message = Error.Format(SRResources.PropertyIsNotCollection, propertyType.FullName, propertyName, resourceType.FullName);
throw new SerializationException(message);
}
IEnumerable newCollection;
if (CanSetProperty(resource, propertyName) &&
CollectionDeserializationHelpers.TryCreateInstance(propertyType, edmProperty.Type.AsCollection(), elementType, out newCollection))
{
// settable collections
collection.AddToCollection(newCollection, elementType, resourceType, propertyName, propertyType);
if (propertyType.IsArray)
{
newCollection = CollectionDeserializationHelpers.ToArray(newCollection, elementType);
}
SetProperty(resource, propertyName, newCollection);
}
else
{
// get-only collections.
newCollection = GetProperty(resource, propertyName) as IEnumerable;
if (newCollection == null)
{
string message = Error.Format(SRResources.CannotAddToNullCollection, propertyName, resourceType.FullName);
throw new SerializationException(message);
}
collection.AddToCollection(newCollection, elementType, resourceType, propertyName, propertyType);
}
}
}
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:49,代码来源:DeserializationHelpers.cs
示例17: GetPropertyInfo
private PropertyInfo GetPropertyInfo(IEdmProperty property)
{
ClrPropertyInfoAnnotation clrPropertyAnnotation = _model.GetAnnotationValue<ClrPropertyInfoAnnotation>(property);
if (clrPropertyAnnotation != null)
{
return clrPropertyAnnotation.ClrPropertyInfo;
}
ClrTypeAnnotation clrTypeAnnotation = _model.GetAnnotationValue<ClrTypeAnnotation>(property.DeclaringType);
Contract.Assert(clrTypeAnnotation != null);
PropertyInfo info = clrTypeAnnotation.ClrType.GetProperty(property.Name);
Contract.Assert(info != null);
return info;
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:16,代码来源:SelectExpandWrapperConverter.cs
示例18: ValidateStreamReferenceProperty
/// <summary>
/// Validates a stream reference property.
/// </summary>
/// <param name="streamProperty">The stream property to check.</param>
/// <param name="structuredType">The owning type of the stream property or null if no metadata is available.</param>
/// <param name="streamEdmProperty">The stream property defined by the model.</param>
/// <param name="messageReaderSettings">The message reader settings being used.</param>
internal static void ValidateStreamReferenceProperty(ODataProperty streamProperty, IEdmStructuredType structuredType, IEdmProperty streamEdmProperty, ODataMessageReaderSettings messageReaderSettings)
{
Debug.Assert(streamProperty != null, "streamProperty != null");
ValidationUtils.ValidateStreamReferenceProperty(streamProperty, streamEdmProperty);
if (structuredType != null && structuredType.IsOpen)
{
// If no property match was found in the metadata and an error wasn't raised,
// it is an open property (which is not supported for streams).
if (streamEdmProperty == null && !messageReaderSettings.ReportUndeclaredLinkProperties)
{
// Fails with the correct error message.
ValidationUtils.ValidateOpenPropertyValue(streamProperty.Name, streamProperty.Value);
}
}
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:24,代码来源:ReaderValidationUtils.cs
示例19: ValidateStreamReferenceProperty
/// <summary>
/// Validates a stream reference property.
/// </summary>
/// <param name="streamProperty">The stream property to check.</param>
/// <param name="structuredType">The owning type of the stream property or null if no metadata is available.</param>
/// <param name="streamEdmProperty">The stream property defined by the model.</param>
internal static void ValidateStreamReferenceProperty(ODataProperty streamProperty, IEdmStructuredType structuredType, IEdmProperty streamEdmProperty)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(streamProperty != null, "streamProperty != null");
ValidationUtils.ValidateStreamReferenceProperty(streamProperty, streamEdmProperty);
if (structuredType != null && structuredType.IsOpen)
{
// If no property match was found in the metadata and an error wasn't raised,
// it is an open property (which is not supported for streams).
if (streamEdmProperty == null)
{
// Fails with the correct error message.
ValidationUtils.ValidateOpenPropertyValue(streamProperty.Name, streamProperty.Value);
}
}
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:24,代码来源:ReaderValidationUtils.cs
示例20: SetNullValueReaderBehavior
/// <summary>
/// Adds a transient annotation to indicate how null values for the specified property should be read.
/// </summary>
/// <param name="model">The <see cref="IEdmModel"/> containing the annotations.</param>
/// <param name="property">The <see cref="IEdmProperty"/> to modify.</param>
/// <param name="nullValueReadBehaviorKind">The new behavior for reading null values for this property.</param>
public static void SetNullValueReaderBehavior(this IEdmModel model, IEdmProperty property, ODataNullValueBehaviorKind nullValueReadBehaviorKind)
{
ExceptionUtils.CheckArgumentNotNull(model, "model");
ExceptionUtils.CheckArgumentNotNull(property, "property");
ODataEdmPropertyAnnotation annotation = model.GetAnnotationValue<ODataEdmPropertyAnnotation>(property);
if (annotation == null)
{
if (nullValueReadBehaviorKind != ODataNullValueBehaviorKind.Default)
{
annotation = new ODataEdmPropertyAnnotation
{
NullValueReadBehaviorKind = nullValueReadBehaviorKind
};
model.SetAnnotationValue(property, annotation);
}
}
else
{
annotation.NullValueReadBehaviorKind = nullValueReadBehaviorKind;
}
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:28,代码来源:ODataUtils.cs
注:本文中的IEdmProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论