本文整理汇总了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;
}
示例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);
}
示例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();
}