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


C# IEdmOperation.FullName方法代码示例

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


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

示例1: CreateODataOperation

        public virtual ODataOperation CreateODataOperation(IEdmOperation operation, FeedContext feedContext, ODataSerializerContext writeContext)
        {
            if (operation == null)
            {
                throw Error.ArgumentNull("operation");
            }

            if (feedContext == null)
            {
                throw Error.ArgumentNull("feedContext");
            }

            if (writeContext == null)
            {
                throw Error.ArgumentNull("writeContext");
            }

            ODataMetadataLevel metadataLevel = writeContext.MetadataLevel;
            IEdmModel model = writeContext.Model;

            if (metadataLevel != ODataMetadataLevel.FullMetadata)
            {
                return null;
            }

            ProcedureLinkBuilder builder;
            IEdmAction action = operation as IEdmAction;
            if (action != null)
            {
                builder = model.GetActionLinkBuilder(action);
            }
            else
            {
                builder = model.GetFunctionLinkBuilder((IEdmFunction)operation);
            }

            if (builder == null)
            {
                return null;
            }

            Uri target = builder.BuildLink(feedContext);
            if (target == null)
            {
                return null;
            }

            Uri baseUri = new Uri(writeContext.Url.CreateODataLink(new MetadataPathSegment()));
            Uri metadata = new Uri(baseUri, "#" + operation.FullName());

            ODataOperation odataOperation;
            if (action != null)
            {
                odataOperation = new ODataAction();
            }
            else
            {
                odataOperation = new ODataFunction();
            }
            odataOperation.Metadata = metadata;

            // Always omit the title in minimal/no metadata modes.
            ODataEntityTypeSerializer.EmitTitle(model, operation, odataOperation);

            // Omit the target in minimal/no metadata modes unless it doesn't follow conventions.
            if (metadataLevel == ODataMetadataLevel.FullMetadata || !builder.FollowsConventions)
            {
                odataOperation.Target = target;
            }

            return odataOperation;
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:72,代码来源:ODataFeedSerializer.cs

示例2: GetPathForOperationOfEntity

        /// <summary>
        /// Get the Uri Swagger path for Edm operation bound to entity.
        /// </summary>
        /// <param name="operation">The Edm operation.</param>
        /// <param name="navigationSource">The Edm navigation source.</param>
        /// <returns>The <see cref="System.String"/> path represents the related Edm operation.</returns>
        public static string GetPathForOperationOfEntity(IEdmOperation operation, IEdmNavigationSource navigationSource)
        {
            IEdmEntitySet entitySet = navigationSource as IEdmEntitySet;
            if (operation == null || entitySet == null)
            {
                return String.Empty;
            }

            string swaggerOperationPath = GetPathForEntity(entitySet) + "/" + operation.FullName() + "(";
            if (operation.IsFunction())
            {
                foreach (var parameter in operation.Parameters.Skip(1))
                {
                    if (parameter.Type.Definition.TypeKind == EdmTypeKind.Primitive &&
                   ((IEdmPrimitiveType)parameter.Type.Definition).PrimitiveKind == EdmPrimitiveTypeKind.String)
                    {
                        swaggerOperationPath += parameter.Name + "=" + "'{" + parameter.Name + "}',";
                    }
                    else
                    {
                        swaggerOperationPath += parameter.Name + "=" + "{" + parameter.Name + "},";
                    }
                }
            }
            if (swaggerOperationPath.EndsWith(",", StringComparison.Ordinal))
            {
                swaggerOperationPath = swaggerOperationPath.Substring(0, swaggerOperationPath.Length - 1);
            }
            swaggerOperationPath += ")";

            return swaggerOperationPath;
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:38,代码来源:ODataSwaggerUtilities.cs

示例3: GetPathForOperationOfEntitySet

        static string GetPathForOperationOfEntitySet(IEdmOperation operation, IEdmEntitySet entitySet)
        {
            string swaggerOperationPath = "/" + entitySet.Name + "/" + operation.FullName() + "(";
            if (operation.IsFunction())
            {
                foreach (var parameter in operation.Parameters.Skip(1))
                {
                    if (parameter.Type.Definition.TypeKind == EdmTypeKind.Primitive &&
                   (parameter.Type.Definition as IEdmPrimitiveType).PrimitiveKind == EdmPrimitiveTypeKind.String)
                    {
                        swaggerOperationPath += parameter.Name + "=" + "'{" + parameter.Name + "}',";
                    }
                    else
                    {
                        swaggerOperationPath += parameter.Name + "=" + "{" + parameter.Name + "},";
                    }
                }
            }
            if (swaggerOperationPath.EndsWith(","))
            {
                swaggerOperationPath = swaggerOperationPath.Substring(0,
                    swaggerOperationPath.Length - 1);
            }
            swaggerOperationPath += ")";

            return swaggerOperationPath;
        }
开发者ID:TomDu,项目名称:lab,代码行数:27,代码来源:Program.cs

示例4: AddOperation

 private void AddOperation(IEdmOperation operation)
 {
     List<IEdmOperation> operationsFound;
     if (this.operations.TryGetValue(operation.FullName(), out operationsFound))
     {
         operationsFound.Add(operation);
     }
     else
     {
         this.operations.Add(operation.FullName(), new List<IEdmOperation>() { operation });
     }
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:ConstructableMetadata.cs

示例5: GenerateFunctionLink

        /// <summary>
        /// Generates an function link following the OData URL conventions for the function <paramref name="function"/> and bound to the entity
        /// represented by <paramref name="entityContext"/>.
        /// </summary>
        /// <param name="entityContext">The <see cref="EntityInstanceContext"/> representing the entity for which the function link needs to be generated.</param>
        /// <param name="function">The function for which the function link needs to be generated.</param>
        /// <returns>The generated function link following OData URL conventions.</returns>
        public static Uri GenerateFunctionLink(this EntityInstanceContext entityContext, IEdmOperation function)
        {
            if (entityContext == null)
            {
                throw Error.ArgumentNull("entityContext");
            }
            if (function == null)
            {
                throw Error.ArgumentNull("function");
            }

            IEdmOperationParameter bindingParameter = function.Parameters.FirstOrDefault();
            if (bindingParameter == null || !bindingParameter.Type.IsEntity())
            {
                throw Error.Argument("function", SRResources.FunctionNotBoundToEntity, function.Name);
            }

            return GenerateFunctionLink(entityContext, bindingParameter.Type.FullName(), function.FullName(), function.Parameters.Select(p => p.Name));
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:26,代码来源:LinkGenerationHelpers.cs

示例6: GetMetadataReferenceName

        internal static string GetMetadataReferenceName(IEdmModel model, IEdmOperation operation)
        {
            Debug.Assert(operation != null, "operation != null");

            string metadataReferenceName = operation.FullName();
            bool hasOverload = model.FindDeclaredOperations(operation.FullName()).Take(2).Count() > 1;
            
            if (hasOverload)
            {
                if (operation is IEdmFunction)
                {
                    metadataReferenceName = operation.FullNameWithNonBindingParameters();
                }
            }

            return metadataReferenceName;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:17,代码来源:ODataJsonLightUtils.cs

示例7: ValidateNotDuplicate

        public bool ValidateNotDuplicate(IEdmOperation operation, bool skipError)
        {
            bool duplicate = false;
            string fullName = operation.FullName();
            var function = operation as IEdmFunction;
            if (function != null)
            {
                var uniqueFunctionParameterName = BuildInternalUniqueParameterNameFunctionString(function);
                if (functionsParameterNameHash.Contains(uniqueFunctionParameterName))
                {
                    duplicate = true;
                    if (!skipError)
                    {
                        this.context.AddError(
                            function.Location(),
                            EdmErrorCode.DuplicateFunctions,
                            function.IsBound ? Strings.EdmModel_Validator_Semantic_ModelDuplicateBoundFunctionParameterNames(fullName) : Strings.EdmModel_Validator_Semantic_ModelDuplicateUnBoundFunctionsParameterNames(fullName));
                    }
                }
                else
                {
                    functionsParameterNameHash.Add(uniqueFunctionParameterName);
                }

                var uniqueFunctionParameterType = BuildInternalUniqueParameterTypeFunctionString(function);
                if (functionsParameterTypeHash.Contains(uniqueFunctionParameterType))
                {
                    duplicate = true;
                    if (!skipError)
                    {
                        this.context.AddError(
                            function.Location(),
                            EdmErrorCode.DuplicateFunctions,
                            function.IsBound ? Strings.EdmModel_Validator_Semantic_ModelDuplicateBoundFunctionParameterTypes(fullName) : Strings.EdmModel_Validator_Semantic_ModelDuplicateUnBoundFunctionsParameterTypes(fullName));
                    }
                }
                else
                {
                    functionsParameterTypeHash.Add(uniqueFunctionParameterType);
                }
            }
            else
            {
                var action = operation as IEdmAction;
                Debug.Assert(action != null, "action should not be null");
                var uniqueActionName = BuildInternalUniqueActionString(action);
                if (actionsNameHash.Contains(uniqueActionName))
                {
                    duplicate = true;
                    if (!skipError)
                    {
                        this.context.AddError(
                            action.Location(),
                            EdmErrorCode.DuplicateActions,
                            action.IsBound ? Strings.EdmModel_Validator_Semantic_ModelDuplicateBoundActions(fullName) : Strings.EdmModel_Validator_Semantic_ModelDuplicateUnBoundActions(fullName));
                    }
                }
                else
                {
                    actionsNameHash.Add(uniqueActionName);
                }
            }

            return duplicate;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:65,代码来源:DuplicateOperationValidator.cs


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