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


C# IDictionary.GetValueOrDefault方法代码示例

本文整理汇总了C#中IDictionary.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.GetValueOrDefault方法的具体用法?C# IDictionary.GetValueOrDefault怎么用?C# IDictionary.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDictionary的用法示例。


在下文中一共展示了IDictionary.GetValueOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTemplateGroupingId

 /// <summary>
 /// Gets a unique key representing a composite value of the four stable metadata token types 
 /// (MetricInstanceSetType, MetricType, RenderingMode and Open) which are used to sub-group 
 /// the metric templates to reduce the amount of iteration required while searching for matches.
 /// </summary>
 /// <param name="tokens">The tokens to be used to create the metric template groupings.</param>
 /// <returns>A metric template grouping key.</returns>
 public static string GetTemplateGroupingId(IDictionary<string, string> tokens)
 {
     return DescriptorHelper.CreateUniqueId(tokens.GetValueOrDefault("MetricInstanceSetType"),
                                     tokens.GetValueOrDefault("MetricType"),
                                     tokens.GetValueOrDefault("RenderingMode"),
                                     tokens.GetValueOrDefault("Open"));
 }
开发者ID:sybrix,项目名称:EdFi-App,代码行数:14,代码来源:MetricTemplateMetadata.cs

示例2: LanguageServiceMetadata

 public LanguageServiceMetadata(IDictionary<string, object> data)
     : base(data)
 {
     this.ServiceType = (string)data.GetValueOrDefault("ServiceType");
     this.Layer = (string)data.GetValueOrDefault("Layer");
     this.Data = (IReadOnlyDictionary<string, object>)data;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:LanguageServiceMetadata.cs

示例3: ParseAccessTokenFromResult

        private static AccessToken ParseAccessTokenFromResult(IDictionary<string, object> resultDictionary)
        {
            string userID = resultDictionary.GetValueOrDefault<string>(LoginResult.UserIdKey);
            string accessToken = resultDictionary.GetValueOrDefault<string>(LoginResult.AccessTokenKey);
            DateTime expiration = LoginResult.ParseExpirationDateFromResult(resultDictionary);
            ICollection<string> permissions = LoginResult.ParsePermissionFromResult(resultDictionary);

            return new AccessToken(
                accessToken,
                userID,
                expiration,
                permissions);
        }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity-samples,代码行数:13,代码来源:LoginResult.cs

示例4: Configure

        private void Configure(IDictionary<string, string> props) {
            if(props == null) {
                if(IsDebugEnabled)
                    log.Debug("캐시의 환경 설정 값을 기본값으로 설정합니다...");

                _expiration = DefaultExpiration;
                _priority = CacheItemPriority.Default;
                _regionPrefix = DefaultRegionPrefix;
            }
            else {
                _priority = props.GetValueOrDefault("priority", "4").AsEnum(CacheItemPriority.Default);
                _expiration = TimeSpan.FromSeconds(Math.Max(60, props.GetValueOrDefault("expiration", "300").AsInt(300)));
                _regionPrefix = props.GetValueOrDefault("regionPrefix", string.Empty).AsText(DefaultRegionPrefix);
            }
        }
开发者ID:debop,项目名称:NFramework,代码行数:15,代码来源:SysCache.cs

示例5: RecursionSafeReflect

        private IAstTypeReference RecursionSafeReflect(Type type, IDictionary<Type, IAstTypeReference> alreadyReflected)
        {
            var reflected = alreadyReflected.GetValueOrDefault(type);
            if (reflected != null)
                return reflected;

            if (type == typeof(object))
                return AstAnyType.Instance;

            if (type.IsGenericParameter) {
                var constraints = type.GetGenericParameterConstraints();
                return new AstGenericPlaceholderType(
                    type.Name,
                    p => {
                        alreadyReflected.Add(type, p);
                        return constraints.Select(c => this.RecursionSafeReflect(c, alreadyReflected));
                    },
                    target: type
                );
            }

            if (IsFunctionType(type))
                return ReflectFunctionType(type, alreadyReflected);

            if (type.IsGenericType && !type.IsGenericTypeDefinition)
                return ReflectGenericType(type, alreadyReflected);

            return new AstReflectedType(type, this);
        }
开发者ID:ashmind,项目名称:light,代码行数:29,代码来源:Reflector.cs

示例6: OrderableMetadata

 public OrderableMetadata(IDictionary<string, object> data)
 {
     var readOnlyData = (IReadOnlyDictionary<string, object>)data;
     this.AfterTyped = readOnlyData.GetEnumerableMetadata<string>("After").WhereNotNull();
     this.BeforeTyped = readOnlyData.GetEnumerableMetadata<string>("Before").WhereNotNull();
     this.Name = (string)data.GetValueOrDefault("Name");
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:OrderableMetadata.cs

示例7: MockDictionarySettingsReader

 private Mock<IVsSettingsReader> MockDictionarySettingsReader(IDictionary<string, string> settings)
 {
     var reader = new Mock<IVsSettingsReader>();
     string _;
     reader.Setup(x => x.ReadSettingString(It.IsAny<string>(), out _))
           .Callback((string key, out string value) => { value = settings.GetValueOrDefault(key); });
     return reader;
 }
开发者ID:chyftom,项目名称:ExceptionBreaker,代码行数:8,代码来源:OptionsPageDataTests.cs

示例8: AddGenericTheory

        private void AddGenericTheory(IDictionary<Type, ISet<Type>> genericTheories, Type genericType, Type actualType)
        {
            var set = genericTheories.GetValueOrDefault(genericType);
            if (set == null) {
                genericTheories.Add(genericType, new HashSet<Type> {actualType});
                return;
            }

            set.Add(actualType);
        }
开发者ID:izobr,项目名称:light,代码行数:10,代码来源:OverloadResolver.cs

示例9: Lexer

 internal Lexer(string str, IDictionary<string, object> options)
 {
     _input = InputRegex.Replace(str, "\n");
     _colons = (bool) options.GetValueOrDefault("colons", false);
     _deferredTokens = new List<Token>();
     _lastIndents = 0;
     LineNumber = 1;
     _stash = new List<Token>();
     _indentStack = new List<int>();
     _indentRe = null;
     Pipeless = false;
 }
开发者ID:moonwa,项目名称:jade.net,代码行数:12,代码来源:Lexer.cs

示例10: Render

        public override void Render(IParrotWriter writer, IRendererFactory rendererFactory, Statement statement, IDictionary<string, object> documentHost, object model)
        {
            var childrenQueue = documentHost.GetValueOrDefault(LayoutRenderer.LayoutChildren) as Queue<StatementList>;
            if (childrenQueue == null)
            {
                //TODO: replace this with a real exception
                throw new Exception("Children elements empty");
            }

            var children = childrenQueue.Dequeue();

            RenderChildren(writer, children, rendererFactory, documentHost, DefaultChildTag, model);
        }
开发者ID:ParrotFx,项目名称:Parrot.AspNet,代码行数:13,代码来源:ContentRenderer.cs

示例11: Compiler

 internal Compiler(Node node, IDictionary<string, object> options = null)
 {
     _options = options ?? new Dictionary<string, object>();
     _node = node;
     _hasCompiledDoctype = false;
     _hasCompiledTag = false;
     _pp = (bool) _options.GetValueOrDefault("pretty", false);
     _debug = _options.ContainsKey("compileDebug") && (bool) _options["compileDebug"];
     _indents = 0;
     _parentIndents = 0;
     if (_options.ContainsKey("doctype")) SetDoctype((string) _options["doctype"]);
         
 }
开发者ID:moonwa,项目名称:jade.net,代码行数:13,代码来源:Compiler.cs

示例12: ParseExpirationDateFromResult

        private static DateTime ParseExpirationDateFromResult(IDictionary<string, object> resultDictionary)
        {
            DateTime expiration;
            if (Constants.IsWeb)
            {
                // For canvas we get back the time as seconds since now instead of in epoch time.
                expiration = DateTime.Now.AddSeconds(resultDictionary.GetValueOrDefault<long>(LoginResult.ExpirationTimestampKey));
            }
            else
            {
                string expirationStr = resultDictionary.GetValueOrDefault<string>(LoginResult.ExpirationTimestampKey);
                int expiredTimeSeconds;
                if (int.TryParse(expirationStr, out expiredTimeSeconds) && expiredTimeSeconds > 0)
                {
                    expiration = LoginResult.FromTimestamp(expiredTimeSeconds);
                }
                else
                {
                    expiration = DateTime.MaxValue;
                }
            }

            return expiration;
        }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity-samples,代码行数:24,代码来源:LoginResult.cs

示例13: ContentTypeMetadata

 public ContentTypeMetadata(IDictionary<string, object> data)
 {
     this.ContentTypes = (IEnumerable<string>)data.GetValueOrDefault("ContentTypes");
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:ContentTypeMetadata.cs

示例14: WorkspaceServiceMetadata

 public WorkspaceServiceMetadata(IDictionary<string, object> data)
 {
     this.ServiceType = (string)data.GetValueOrDefault("ServiceType");
     this.Layer = (string)data.GetValueOrDefault("Layer");
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:5,代码来源:WorkspaceServiceMetadata.cs

示例15: VisualStudioVersionMetadata

 public VisualStudioVersionMetadata(IDictionary<string, object> data)
 {
     Version = (VisualStudioVersion)data.GetValueOrDefault("Version");
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:VisualStudioVersionMetadata.cs


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