本文整理汇总了C#中IReadOnlyDictionary.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyDictionary.ToDictionary方法的具体用法?C# IReadOnlyDictionary.ToDictionary怎么用?C# IReadOnlyDictionary.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyDictionary
的用法示例。
在下文中一共展示了IReadOnlyDictionary.ToDictionary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlSagaStore
/// <summary>
/// Initializes a new instance of <see cref="SqlSagaStore"/>.
/// </summary>
/// <param name="dialect">The database dialect associated with this <see cref="SqlSagaStore"/>.</param>
/// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
/// <param name="typeLocator">The type locator use to retrieve all known <see cref="Saga"/> types.</param>
public SqlSagaStore(ISagaStoreDialect dialect, ISerializeObjects serializer, ILocateTypes typeLocator)
{
Verify.NotNull(typeLocator, nameof(typeLocator));
Verify.NotNull(serializer, nameof(serializer));
Verify.NotNull(dialect, nameof(dialect));
this.dialect = dialect;
this.serializer = serializer;
this.typeToGuidMap = GetKnownSagas(typeLocator);
this.guidToTypeMap = typeToGuidMap.ToDictionary(item => item.Value, item => item.Key);
Initialize();
}
示例2: PointData
public PointData(
string measurement,
IReadOnlyDictionary<string, object> fields,
IReadOnlyDictionary<string, string> tags = null,
DateTime? utcTimestamp = null)
{
if (measurement == null) throw new ArgumentNullException("measurement");
if (fields == null) throw new ArgumentNullException("fields");
Measurement = measurement;
Fields = fields.ToDictionary(kv => kv.Key, kv => kv.Value);
if (tags != null)
Tags = tags.ToDictionary(kv => kv.Key, kv => kv.Value);
UtcTimestamp = utcTimestamp;
}
示例3: SecurityExchangeHours
/// <summary>
/// Initializes a new instance of the <see cref="SecurityExchangeHours"/> class
/// </summary>
/// <param name="timeZone">The time zone the dates and hours are represented in</param>
/// <param name="holidayDates">The dates this exchange is closed for holiday</param>
/// <param name="marketHoursForEachDayOfWeek">The exchange's schedule for each day of the week</param>
public SecurityExchangeHours(DateTimeZone timeZone, IEnumerable<DateTime> holidayDates, IReadOnlyDictionary<DayOfWeek, LocalMarketHours> marketHoursForEachDayOfWeek)
{
_timeZone = timeZone;
_holidays = holidayDates.Select(x => x.Date.Ticks).ToHashSet();
// make a copy of the dictionary for internal use
_openHoursByDay = new Dictionary<DayOfWeek, LocalMarketHours>(marketHoursForEachDayOfWeek.ToDictionary());
SetMarketHoursForDay(DayOfWeek.Sunday, out _sunday);
SetMarketHoursForDay(DayOfWeek.Monday, out _monday);
SetMarketHoursForDay(DayOfWeek.Tuesday, out _tuesday);
SetMarketHoursForDay(DayOfWeek.Wednesday, out _wednesday);
SetMarketHoursForDay(DayOfWeek.Thursday, out _thursday);
SetMarketHoursForDay(DayOfWeek.Friday, out _friday);
SetMarketHoursForDay(DayOfWeek.Saturday, out _saturday);
}
示例4: BenchmarkContext
public BenchmarkContext(IReadOnlyDictionary<CounterMetricName, Counter> counters, IBenchmarkTrace trace)
{
Trace = trace;
_counters = counters.ToDictionary(k => k.Key.CounterName, v => v.Value);
}
示例5: AddChildCommand
public AddChildCommand(OperatorDefinition definition,
IReadOnlyDictionary<string, PropertyTreeMetaObject> arguments)
{
this.definition = definition;
this.arguments = arguments.ToDictionary(t => t.Key, t => t.Value.Component);
}
示例6: SymbolPropertiesDatabase
private SymbolPropertiesDatabase(IReadOnlyDictionary<SecurityDatabaseKey, SymbolProperties> entries)
{
_entries = entries.ToDictionary();
}
示例7: DummyPackagesConfigNuGetProject
public DummyPackagesConfigNuGetProject(IReadOnlyDictionary<string, object> metadata) : base(Directory.GetCurrentDirectory(), metadata.ToDictionary(x => x.Key, x => x.Value))
{
}
示例8: InsertRow
private async Task<IRow> InsertRow(string key, IReadOnlyDictionary<string, string> columns)
{
logger.Info("inserting row to file: " + columns.ToString());
if (string.IsNullOrWhiteSpace(key))
{
throw new ArgumentNullException(CommaDelimitedFileAdapter.ArgumentNameRow);
}
if (null == columns)
{
throw new ArgumentNullException(CommaDelimitedFileAdapter.ArgumentNameColumns);
}
IDictionary<string, string> valuesByNormalizedNames =
columns
.ToDictionary(
(KeyValuePair<string, string> item) =>
new Value(item.Key).ToString().ToUpperInvariant(),
(KeyValuePair<string, string> item) =>
item.Value);
IList<string> values = new List<string>(this.headers.Count);
string keyNormalized = new Value(key).ToString();
values.Add(keyNormalized);
IEnumerable<string> normalizedHeaders = this.headersNormalized.Skip(1);
foreach (string normalizedHeader in normalizedHeaders)
{
string value = null;
if (!valuesByNormalizedNames.TryGetValue(normalizedHeader, out value))
{
values.Add(string.Empty);
continue;
}
string normalizedValue = new Value(value).ToString();
values.Add(normalizedValue);
}
string row =
string.Join(CommaDelimitedFileAdapter.Comma, values);
AsyncSemaphore.Releaser? releaser = null;
try
{
releaser = await this.semaphore.EnterAsync();
StreamWriter writer = null;
try
{
writer = File.AppendText(this.FilePath);
logger.Info("inserting row: " + row);
await writer.WriteLineAsync(row);
}
finally
{
if (writer != null)
{
writer.Close();
writer = null;
}
}
}
finally
{
if (releaser.HasValue)
{
releaser.Value.Dispose();
releaser = null;
}
}
IRow result = new Row(keyNormalized, columns);
return result;
}
示例9: CommandlineParameters
public CommandlineParameters(IReadOnlyDictionary<string, string> dictionary)
{
_dictionary = dictionary.ToDictionary(x => x.Key.ToLower(), x => x.Value.ToLower());
}
示例10: MessageFilterComponent
static MessageFilterComponent()
{
_criteriaPropertyNames = new Dictionary<CriteriaPropertyType, string>()
{
{ CriteriaPropertyType.From, "from" },
{ CriteriaPropertyType.To, "to" },
{ CriteriaPropertyType.Subject, "subject" },
{ CriteriaPropertyType.HasTheWords, "hasTheWord" },
{ CriteriaPropertyType.DoesntHave, "doesNotHaveTheWord" },
{ CriteriaPropertyType.HasAttachment, "hasAttachment" },
{ CriteriaPropertyType.ExcludeChats, "excludeChats" },
{ CriteriaPropertyType.Size, "size" },
{ CriteriaPropertyType.SizeOperator, "sizeOperator" },
{ CriteriaPropertyType.SizeUnit, "sizeUnit" }
}.AsReadOnly();
_criteriaPropertyTypes = _criteriaPropertyNames.ToDictionary(o => o.Value, o => o.Key).AsReadOnly();
_actionPropertyNames = new Dictionary<ActionPropertyType, string>()
{
{ ActionPropertyType.ArchiveIt, "shouldArchive" },
{ ActionPropertyType.MarkAsRead, "shouldMarkAsRead" },
{ ActionPropertyType.StarIt, "shouldStar" },
{ ActionPropertyType.ApplyLabel, "label" },
{ ActionPropertyType.ForwardIt, "forwardTo" },
{ ActionPropertyType.DeleteIt, "shouldTrash" },
{ ActionPropertyType.NeverSendToSpam, "shouldNeverSpam" },
{ ActionPropertyType.AlwaysImportant, "shouldAlwaysMarkAsImportant" },
{ ActionPropertyType.NeverImportant, "shouldNeverMarkAsImportant" },
{ ActionPropertyType.SmartLabel, "smartLabelToApply" }
}.AsReadOnly();
_actionPropertyTypes = _actionPropertyNames.ToDictionary(o => o.Value, o => o.Key).AsReadOnly();
_smartLabelNames = new Dictionary<SmartLabelType, string>()
{
{ SmartLabelType.Personal, "^smartlabel_personal" },
{ SmartLabelType.Social, "^smartlabel_social" },
{ SmartLabelType.Promotions, "^smartlabel_promo" },
{ SmartLabelType.Notification, "^smartlabel_notification" },
{ SmartLabelType.Group, "^smartlabel_group" }
}.AsReadOnly();
_smartLabelTypes = _smartLabelNames.ToDictionary(o => o.Value, o => o.Key).AsReadOnly();
_sizeOperatorNames = new Dictionary<SizeOperatorType, string>()
{
{ SizeOperatorType.GreaterThan, "s_sl" },
{ SizeOperatorType.LessThan, "s_ss" }
}.AsReadOnly();
_sizeOperatorTypes = _sizeOperatorNames.ToDictionary(o => o.Value, o => o.Key).AsReadOnly();
_sizeUnitNames = new Dictionary<SizeUnitType, string>()
{
{ SizeUnitType.MB, "s_smb" },
{ SizeUnitType.KB, "s_skb" },
{ SizeUnitType.Byte, "s_sb" }
}.AsReadOnly();
_sizeUnitTypes = _sizeUnitNames.ToDictionary(o => o.Value, o => o.Key).AsReadOnly();
}
示例11: MarketHoursDatabase
/// <summary>
/// Initializes a new instance of the <see cref="MarketHoursDatabase"/> class
/// </summary>
/// <param name="exchangeHours">The full listing of exchange hours by key</param>
public MarketHoursDatabase(IReadOnlyDictionary<SecurityDatabaseKey, Entry> exchangeHours)
{
_entries = exchangeHours.ToDictionary();
}
示例12: PropertiesDeploymentMatcher
public PropertiesDeploymentMatcher(IReadOnlyDictionary<string, string> matchProperties)
{
_matchProperties = matchProperties.ToDictionary(pair => pair.Key, pair => pair.Value);
}
示例13: AppInstallConfig
public AppInstallConfig(AppIdentity appIdentity, IReadOnlyDictionary<string, string> properties) : this(appIdentity)
{
Properties = properties.ToDictionary(pair => pair.Key, pair => pair.Value);
}
示例14: WriteDictionary
/// <summary>
/// Escape the name of the Property before calling ElasticSearch
/// </summary>
protected override void WriteDictionary(IReadOnlyDictionary<ScalarValue, LogEventPropertyValue> elements, TextWriter output)
{
var escaped = elements.ToDictionary(e => DotEscapeFieldName(e.Key), e => e.Value);
base.WriteDictionary(escaped, output);
}
示例15: AsAttributes
private static Dictionary<string, AttributeValue> AsAttributes(IReadOnlyDictionary<string, object> item)
{
return item.ToDictionary(i => i.Key, i => AsAttribute(i.Value));
}