本文整理匯總了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();
}