本文整理汇总了C#中IEdmOperation.FindParameter方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmOperation.FindParameter方法的具体用法?C# IEdmOperation.FindParameter怎么用?C# IEdmOperation.FindParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmOperation
的用法示例。
在下文中一共展示了IEdmOperation.FindParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveOperationParameters
public override IDictionary<IEdmOperationParameter, SingleValueNode> ResolveOperationParameters(IEdmOperation operation, IDictionary<string, SingleValueNode> input)
{
Dictionary<IEdmOperationParameter, SingleValueNode> result = new Dictionary<IEdmOperationParameter, SingleValueNode>(EqualityComparer<IEdmOperationParameter>.Default);
foreach (var item in input)
{
IEdmOperationParameter functionParameter = null;
if (EnableCaseInsensitive)
{
functionParameter = ODataUriResolver.ResolveOpearationParameterNameCaseInsensitive(operation, item.Key);
}
else
{
functionParameter = operation.FindParameter(item.Key);
}
// ensure parameter name existis
if (functionParameter == null)
{
throw new ODataException(Strings.ODataParameterWriterCore_ParameterNameNotFoundInOperation(item.Key, operation.Name));
}
SingleValueNode newVal = item.Value;
if (functionParameter.Type.IsEnum()
&& newVal is ConstantNode
&& newVal.TypeReference != null
&& newVal.TypeReference.IsString())
{
string text = ((ConstantNode)item.Value).Value as string;
ODataEnumValue val;
IEdmTypeReference typeRef = functionParameter.Type;
if (TryParseEnum(typeRef.Definition as IEdmEnumType, text, out val))
{
newVal = new ConstantNode(val, text, typeRef);
}
}
result.Add(functionParameter, newVal);
}
return result;
}
示例2: ResolveOperationParameters
/// <summary>
/// Resolve operation's parameters.
/// </summary>
/// <param name="operation">Current operation for parameters.</param>
/// <param name="input">A dictionary the parameter list.</param>
/// <returns>A dictionary containing resolved parameters.</returns>
public virtual IDictionary<IEdmOperationParameter, SingleValueNode> ResolveOperationParameters(IEdmOperation operation, IDictionary<string, SingleValueNode> input)
{
Dictionary<IEdmOperationParameter, SingleValueNode> result = new Dictionary<IEdmOperationParameter, SingleValueNode>(EqualityComparer<IEdmOperationParameter>.Default);
foreach (var item in input)
{
IEdmOperationParameter functionParameter = null;
if (EnableCaseInsensitive)
{
functionParameter = ResolveOpearationParameterNameCaseInsensitive(operation, item.Key);
}
else
{
functionParameter = operation.FindParameter(item.Key);
}
// ensure parameter name existis
if (functionParameter == null)
{
throw new ODataException(Strings.ODataParameterWriterCore_ParameterNameNotFoundInOperation(item.Key, operation.Name));
}
result.Add(functionParameter, item.Value);
}
return result;
}
示例3: HandleComplexOrCollectionParameterValueIfExists
private static ICollection<FunctionParameterToken> HandleComplexOrCollectionParameterValueIfExists(IEdmModel model, IEdmOperation operation, ICollection<FunctionParameterToken> parameterTokens, bool enableCaseInsensitive, bool enableUriTemplateParsing = false)
{
ICollection<FunctionParameterToken> partiallyParsedParametersWithComplexOrCollection = new Collection<FunctionParameterToken>();
foreach (FunctionParameterToken paraToken in parameterTokens)
{
FunctionParameterToken funcParaToken;
IEdmOperationParameter functionParameter = operation.FindParameter(paraToken.ParameterName);
if (enableCaseInsensitive && functionParameter == null)
{
functionParameter = ODataUriResolver.ResolveOpearationParameterNameCaseInsensitive(operation, paraToken.ParameterName);
// The functionParameter can not be null here, else this method won't be called.
funcParaToken = new FunctionParameterToken(functionParameter.Name, paraToken.ValueToken);
}
else
{
funcParaToken = paraToken;
}
FunctionParameterAliasToken aliasToken = funcParaToken.ValueToken as FunctionParameterAliasToken;
if (aliasToken != null)
{
aliasToken.ExpectedParameterType = functionParameter.Type;
}
LiteralToken valueToken = funcParaToken.ValueToken as LiteralToken;
string valueStr = null;
if (valueToken != null && (valueStr = valueToken.Value as string) != null && !string.IsNullOrEmpty(valueToken.OriginalText))
{
var lexer = new ExpressionLexer(valueToken.OriginalText, true /*moveToFirstToken*/, false /*useSemicolonDelimiter*/, true /*parsingFunctionParameters*/);
if (lexer.CurrentToken.Kind == ExpressionTokenKind.BracketedExpression)
{
object result;
UriTemplateExpression expression;
if (enableUriTemplateParsing && UriTemplateParser.TryParseLiteral(lexer.CurrentToken.Text, functionParameter.Type, out expression))
{
result = expression;
}
else
{
// ExpressionTokenKind.BracketedExpression means text like [{\"Street\":\"NE 24th St.\",\"City\":\"Redmond\"},{\"Street\":\"Pine St.\",\"City\":\"Seattle\"}]
// so now try convert it into complex or collection type value:
result = ODataUriUtils.ConvertFromUriLiteral(valueStr, ODataVersion.V4, model, functionParameter.Type);
}
LiteralToken newValueToken = new LiteralToken(result, valueToken.OriginalText);
FunctionParameterToken newFuncParaToken = new FunctionParameterToken(funcParaToken.ParameterName, newValueToken);
partiallyParsedParametersWithComplexOrCollection.Add(newFuncParaToken);
continue;
}
}
partiallyParsedParametersWithComplexOrCollection.Add(funcParaToken);
}
return partiallyParsedParametersWithComplexOrCollection;
}