当前位置: 首页>>代码示例>>C#>>正文


C# ODataProperty.SetMaterializedValue方法代码示例

本文整理汇总了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;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:18,代码来源:EnumValueMaterializationPolicy.cs

示例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&lt;T&gt; 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);
        }
开发者ID:TomDu,项目名称:odata.net,代码行数:36,代码来源:CollectionValueMaterializationPolicy.cs

示例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);
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:StructuralValueMaterializationPolicy.cs


注:本文中的Microsoft.OData.Core.ODataProperty.SetMaterializedValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。