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


C# ResourceType.TryResolveNamedStream方法代码示例

本文整理汇总了C#中System.Data.Services.Providers.ResourceType.TryResolveNamedStream方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceType.TryResolveNamedStream方法的具体用法?C# ResourceType.TryResolveNamedStream怎么用?C# ResourceType.TryResolveNamedStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.Services.Providers.ResourceType的用法示例。


在下文中一共展示了ResourceType.TryResolveNamedStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPropertyType

        /// <summary>
        /// Returns a resource type of the property on the specified resource type.
        /// </summary>
        /// <param name="resourceType">The resource type to look for the property on.</param>
        /// <param name="propertyName">The name of the property to look for.</param>
        /// <param name="isMultiValueProperty">return true if the property was a MultiValue property.</param>
        /// <returns>The type of the property specified. Note that for MultiValue properties this returns the type of the item of the MultiValue property.</returns>
        private static ResourceType GetPropertyType(ResourceType resourceType, string propertyName, out bool isMultiValueProperty)
        {
            Debug.Assert(propertyName != null, "propertyName != null");

            isMultiValueProperty = false;
            ResourceProperty resourceProperty = resourceType != null ? resourceType.TryResolvePropertyName(propertyName) : null;

            if (resourceProperty != null)
            {
                if (resourceProperty.IsOfKind(ResourcePropertyKind.MultiValue))
                {
                    isMultiValueProperty = true;
                    Debug.Assert(resourceProperty.ResourceType is MultiValueResourceType, "MultiValue property must be of the MultiValueResourceType.");
                    MultiValueResourceType multiValueResourceType = (MultiValueResourceType)resourceProperty.ResourceType;
                    return multiValueResourceType.ItemType;
                }
                else
                {
                    return resourceProperty.ResourceType;
                }
            }
            else
            {
                if (resourceType != null && !resourceType.IsOpenType)
                {
                    // could be a named stream
                    resourceProperty = resourceType.TryResolveNamedStream(propertyName);
                    if (resourceProperty != null)
                    {
                        throw new ODataException(Strings.EpmSourceTree_NamedStreamCannotBeMapped(propertyName, resourceType.FullName));
                    }
                    else
                    {
                        throw new ODataException(Strings.EpmSourceTree_MissingPropertyOnType(propertyName, resourceType.FullName));
                    }
                }

                return null;
            }
        }
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:47,代码来源:EpmSourceTree.cs


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