当前位置: 首页>>代码示例>>C#>>正文


C# Arguments.GetArgument方法代码示例

本文整理汇总了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();
        }
开发者ID:mchudinov,项目名称:AspMvc5Advanced,代码行数:24,代码来源:CacheAttribute.cs

示例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();
        }
开发者ID:DarekDan,项目名称:attribute-based-caching,代码行数:44,代码来源:KeyBuilder.cs


注:本文中的System.Arguments.GetArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。