本文整理汇总了C#中IEdmOperation.IsFunction方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmOperation.IsFunction方法的具体用法?C# IEdmOperation.IsFunction怎么用?C# IEdmOperation.IsFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmOperation
的用法示例。
在下文中一共展示了IEdmOperation.IsFunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: WriteMethod
private void WriteMethod(OdcmClass odcmClass, IEdmOperation operation, IEdmOperationImport operationImport = null)
{
var parameters = operation.IsBound
? (from parameter in operation.Parameters
where parameter != operation.Parameters.First()
select parameter)
: (operation.Parameters);
var isBoundToCollection = operation.IsBound && operation.Parameters.First().Type.IsCollection();
var odcmMethod = new OdcmMethod(operation.Name, odcmClass.Namespace)
{
IsComposable = operation.IsFunction() && ((IEdmFunction)operation).IsComposable,
IsBoundToCollection = isBoundToCollection,
Verbs = operation.IsAction() ? OdcmAllowedVerbs.Post : OdcmAllowedVerbs.Any,
Class = odcmClass
};
AddVocabularyAnnotations(odcmMethod, operation);
if (operationImport != null)
{
AddVocabularyAnnotations(odcmMethod, operationImport);
}
odcmClass.Methods.Add(odcmMethod);
if (operation.ReturnType != null)
{
odcmMethod.ReturnType = ResolveType(operation.ReturnType);
odcmMethod.IsCollection = operation.ReturnType.IsCollection();
}
var callingConvention =
operation.IsAction()
? OdcmCallingConvention.InHttpMessageBody
: OdcmCallingConvention.InHttpRequestUri;
foreach (var parameter in parameters)
{
var odcmParameter = new OdcmParameter(parameter.Name)
{
CallingConvention = callingConvention,
Type = ResolveType(parameter.Type),
IsCollection = parameter.Type.IsCollection(),
IsNullable = parameter.Type.IsNullable
};
AddVocabularyAnnotations(odcmParameter, parameter);
odcmMethod.Parameters.Add(odcmParameter);
}
}
示例3: 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;
}