當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。