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


C# IEdmModel.FindBoundOperations方法代码示例

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


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

示例1: TryBindAsOperation

        internal static bool TryBindAsOperation(PathSegmentToken pathToken, IEdmModel model, IEdmStructuredType entityType, out ODataPathSegment segment)
        {
            Debug.Assert(pathToken != null, "pathToken != null");
            Debug.Assert(entityType != null, "bindingType != null");

            List<IEdmOperation> possibleFunctions = new List<IEdmOperation>();

            // Catch all catchable exceptions as FindDeclaredBoundOperations is implemented by anyone.
            // If an exception occurs it will be supressed and the possible functions will be empty and return false.
            try
            {
                int wildCardPos = pathToken.Identifier.IndexOf("*", StringComparison.Ordinal);
                if (wildCardPos > -1)
                {
                    string namespaceName = pathToken.Identifier.Substring(0, wildCardPos - 1);
                    possibleFunctions = model.FindBoundOperations(entityType).Where(o => o.Namespace == namespaceName).ToList();
                }
                else
                {
                    NonSystemToken nonSystemToken = pathToken as NonSystemToken;
                    IList<string> parameterNames = new List<string>();
                    if (nonSystemToken != null && nonSystemToken.NamedValues != null)
                    {
                        parameterNames = nonSystemToken.NamedValues.Select(s => s.Name).ToList();
                    }

                    if (parameterNames.Count > 0)
                    {
                        // Always force to use fully qualified name when select operation
                        possibleFunctions = model.FindBoundOperations(entityType).FilterByName(true, pathToken.Identifier).FilterOperationsByParameterNames(parameterNames, false).ToList();
                    }
                    else
                    {
                        possibleFunctions = model.FindBoundOperations(entityType).FilterByName(true, pathToken.Identifier).ToList();
                    }
                }
            }
            catch (Exception exc)
            {
                if (!ExceptionUtils.IsCatchableExceptionType(exc))
                {
                    throw;
                }
            }

            possibleFunctions = possibleFunctions.EnsureOperationsBoundWithBindingParameter().ToList();

            // Only filter if there is more than one and its needed.
            if (possibleFunctions.Count > 1)
            {
                possibleFunctions = possibleFunctions.FilterBoundOperationsWithSameTypeHierarchyToTypeClosestToBindingType(entityType).ToList();
            }

            if (possibleFunctions.Count <= 0)
            {
                segment = null;
                return false;
            }

            segment = new OperationSegment(possibleFunctions, null /*entitySet*/);
            return true;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:62,代码来源:SelectPathSegmentTokenBinder.cs

示例2: ResolveBoundOperations

        /// <summary>
        /// Resolve bound operations based on name.
        /// </summary>
        /// <param name="model">The model to be used.</param>
        /// <param name="identifier">The operation name.</param>
        /// <param name="bindingType">The type operation was binding to.</param>
        /// <returns>Resolved operation list.</returns>
        public virtual IEnumerable<IEdmOperation> ResolveBoundOperations(IEdmModel model, string identifier, IEdmType bindingType)
        {
            if (EnableCaseInsensitive)
            {
                return model.SchemaElements.OfType<IEdmOperation>()
                    .Where(operation => string.Equals(
                            identifier,
                            operation.FullName(),
                            StringComparison.OrdinalIgnoreCase)
                    && operation.IsBound && operation.Parameters.Any()
                    && operation.HasEquivalentBindingType(bindingType));
            }

            return model.FindBoundOperations(identifier, bindingType);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:22,代码来源:ODataUriResolver.cs

示例3: CalculateBindableOperationsForType

        internal static IEdmOperation[] CalculateBindableOperationsForType(IEdmType bindingType, IEdmModel model, EdmTypeResolver edmTypeResolver)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(edmTypeResolver != null, "edmTypeResolver != null");

            List<IEdmOperation> operations = null;
            try
            {
                operations = model.FindBoundOperations(bindingType).ToList();
            }
            catch (Exception exc)
            {
                if (!ExceptionUtils.IsCatchableExceptionType(exc))
                {
                    throw;
                }

                throw new ODataException(Strings.MetadataUtils_CalculateBindableOperationsForType(bindingType.FullTypeName()), exc);
            }

            List<IEdmOperation> operationsFound = new List<IEdmOperation>();
            foreach (IEdmOperation operation in operations.EnsureOperationsBoundWithBindingParameter())
            {
                IEdmOperationParameter bindingParameter = operation.Parameters.FirstOrDefault();
                IEdmType resolvedBindingType = edmTypeResolver.GetParameterType(bindingParameter).Definition;
                if (resolvedBindingType.IsAssignableFrom(bindingType))
                {
                    operationsFound.Add(operation);
                }
            }

            return operationsFound.ToArray();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:33,代码来源:MetadataUtils.cs


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