本文整理汇总了C#中Microsoft.OData.Core.ODataProperty.SetMaterializedValue方法的典型用法代码示例。如果您正苦于以下问题:C# ODataProperty.SetMaterializedValue方法的具体用法?C# ODataProperty.SetMaterializedValue怎么用?C# ODataProperty.SetMaterializedValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Core.ODataProperty
的用法示例。
在下文中一共展示了ODataProperty.SetMaterializedValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MaterializeEnumTypeProperty
/// <summary>
/// Materializes the enum data value.
/// </summary>
/// <param name="valueType">Type of the collection item.</param>
/// <param name="property">The ODataProperty.</param>
/// <returns>Materialized enum data CLR value.</returns>
public object MaterializeEnumTypeProperty(Type valueType, ODataProperty property)
{
object materializedValue = null;
ODataEnumValue value = property.Value as ODataEnumValue;
this.MaterializeODataEnumValue(valueType, value.TypeName, value.Value, () => "TODO: Is this reachable?", out materializedValue);
if (!property.HasMaterializedValue())
{
property.SetMaterializedValue(materializedValue);
}
return materializedValue;
}
示例2: ApplyCollectionDataValues
/// <summary>
/// Applies collectionValue item to the provided <paramref name="collectionInstance"/>.
/// </summary>
/// <param name="collectionProperty">Atom property containing materialized Collection items.</param>
/// <param name="collectionInstance">Collection instance. Must implement ICollection<T> where T is either primitive or complex type (not an entity).</param>
/// <param name="collectionItemType">Type of items in the Collection. Note: this could be calculated from collectionInstance but we already have it in upstream methods.</param>
/// <param name="addValueToBackingICollectionInstance">Action called actually add a Collection item to <paramref name="collectionInstance" /></param>
/// <param name="isElementNullable">If element type is nullable.</param>
internal void ApplyCollectionDataValues(
ODataProperty collectionProperty,
object collectionInstance,
Type collectionItemType,
Action<object, object> addValueToBackingICollectionInstance,
bool isElementNullable)
{
Debug.Assert(collectionProperty != null, "property != null");
Debug.Assert(collectionProperty.Value != null, "Collection should have already been checked for nullness");
Debug.Assert(collectionInstance != null, "collectionInstance != null");
Debug.Assert(WebUtil.IsCLRTypeCollection(collectionInstance.GetType(), this.materializerContext.Model), "collectionInstance must be a CollectionValue");
Debug.Assert(collectionItemType.IsAssignableFrom(
ClientTypeUtil.GetImplementationType(collectionInstance.GetType(), typeof(ICollection<>)).GetGenericArguments()[0]),
"collectionItemType has to match the collectionInstance generic type.");
Debug.Assert(!ClientTypeUtil.TypeIsEntity(collectionItemType, this.materializerContext.Model), "CollectionValues cannot contain entities");
Debug.Assert(addValueToBackingICollectionInstance != null, "AddValueToBackingICollectionInstance != null");
ODataCollectionValue collectionValue = collectionProperty.Value as ODataCollectionValue;
this.ApplyCollectionDataValues(
collectionValue.Items,
collectionValue.TypeName,
collectionInstance,
collectionItemType,
addValueToBackingICollectionInstance,
isElementNullable);
collectionProperty.SetMaterializedValue(collectionInstance);
}
示例3: MaterializePrimitiveDataValue
/// <summary>Materializes a primitive value. No op for non-primitive values.</summary>
/// <param name="type">Type of value to set.</param>
/// <param name="property">Property holding value.</param>
internal void MaterializePrimitiveDataValue(Type type, ODataProperty property)
{
Debug.Assert(type != null, "type != null");
Debug.Assert(property != null, "atomProperty != null");
if (!property.HasMaterializedValue())
{
object value = property.Value;
object materializedValue = this.PrimitivePropertyConverter.ConvertPrimitiveValue(value, type);
property.SetMaterializedValue(materializedValue);
}
}