本文整理汇总了C#中System.Arguments.GetArgument方法的典型用法代码示例。如果您正苦于以下问题:C# Arguments.GetArgument方法的具体用法?C# Arguments.GetArgument怎么用?C# Arguments.GetArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Arguments
的用法示例。
在下文中一共展示了Arguments.GetArgument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCacheKey
private string GetCacheKey(object instance, Arguments arguments)
{
// If we have no argument, return just the method name so we don't uselessly allocate memory.
if (instance == null && arguments.Count == 0)
return this._methodName;
// Add all arguments to the cache key. Note that generic arguments are not part of the cache
// key, so method calls that differ only by generic arguments will have conflicting cache keys.
StringBuilder stringBuilder = new StringBuilder(this._methodName);
stringBuilder.Append('(');
if (instance != null)
{
stringBuilder.Append(instance);
stringBuilder.Append("; ");
}
for (int i = 0; i < arguments.Count; i++)
{
stringBuilder.Append(arguments.GetArgument(i) ?? "null");
stringBuilder.Append(", ");
}
return stringBuilder.ToString();
}
示例2: BuildCacheKey
public string BuildCacheKey(object instance, Arguments arguments)
{
StringBuilder cacheKeyBuilder = new StringBuilder();
// start building a key based on the method name if a group name not set
if (string.IsNullOrWhiteSpace(GroupName))
{
cacheKeyBuilder.Append(MethodName);
}
else
{
cacheKeyBuilder.Append(GroupName);
}
if (instance != null)
{
cacheKeyBuilder.Append(instance);
cacheKeyBuilder.Append(";");
}
int argIndex;
switch (Settings)
{
case CacheSettings.IgnoreParameters:
return cacheKeyBuilder.ToString();
case CacheSettings.UseId:
argIndex = GetArgumentIndexByName("Id");
cacheKeyBuilder.Append(arguments.GetArgument(argIndex) ?? "Null");
break;
case CacheSettings.UseProperty:
argIndex = GetArgumentIndexByName(ParameterProperty);
cacheKeyBuilder.Append(arguments.GetArgument(argIndex) ?? "Null");
break;
case CacheSettings.Default:
for (var i = 0; i < arguments.Count; i++)
{
BuildDefaultKey(arguments.GetArgument(i), cacheKeyBuilder);
}
break;
}
return cacheKeyBuilder.ToString();
}