本文整理汇总了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"));
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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"]);
}
示例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;
}
示例13: ContentTypeMetadata
public ContentTypeMetadata(IDictionary<string, object> data)
{
this.ContentTypes = (IEnumerable<string>)data.GetValueOrDefault("ContentTypes");
}
示例14: WorkspaceServiceMetadata
public WorkspaceServiceMetadata(IDictionary<string, object> data)
{
this.ServiceType = (string)data.GetValueOrDefault("ServiceType");
this.Layer = (string)data.GetValueOrDefault("Layer");
}
示例15: VisualStudioVersionMetadata
public VisualStudioVersionMetadata(IDictionary<string, object> data)
{
Version = (VisualStudioVersion)data.GetValueOrDefault("Version");
}