本文整理汇总了C#中IDictionary.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.ToDictionary方法的具体用法?C# IDictionary.ToDictionary怎么用?C# IDictionary.ToDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.ToDictionary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
IMockNetworkWithReturn IMockNetworkWithExpectation.Returning(HttpStatusCode statusCode, string responseContent, IDictionary<string, string> responseHeaders)
{
_statusCode = statusCode;
_responseContent = responseContent;
_responseHeaders = responseHeaders.ToDictionary(kvp => kvp.Key.ToLowerInvariant(), kvp => kvp.Value);
return this;
}
示例2: EnsureClientDimensionsExist
public static async Task<IDictionary<string, int>> EnsureClientDimensionsExist(SqlConnection connection, IDictionary<string, Tuple<int, ClientDimension>> recognizedUserAgents)
{
var results = new Dictionary<string, int>();
var command = connection.CreateCommand();
command.CommandText = "[dbo].[EnsureClientDimensionsExist]";
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = _defaultCommandTimeout;
var parameterValue = ClientDimensionTableType.CreateDataTable(recognizedUserAgents.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Item2));
var parameter = command.Parameters.AddWithValue("clients", parameterValue);
parameter.SqlDbType = SqlDbType.Structured;
parameter.TypeName = "[dbo].[ClientDimensionTableType]";
using (var dataReader = await command.ExecuteReaderAsync())
{
while (await dataReader.ReadAsync())
{
var clientDimensionId = dataReader.GetInt32(0);
var userAgent = dataReader.GetString(1);
results.Add(userAgent, clientDimensionId);
}
}
return results;
}
示例3: GetParameters
public IDictionary<string,Parameter> GetParameters(IDictionary<string, object> dictionary)
{
if (dynamicRaml == null)
return new Dictionary<string, Parameter>();
return dictionary.ToDictionary(kv => kv.Key, kv => (new ParameterBuilder()).Build((IDictionary<string, object>)kv.Value));
}
示例4: BinaryDecisionTreeParentNode
public BinaryDecisionTreeParentNode(
bool isLeaf,
string decisionFeatureName,
IDictionary<IDecisionTreeLink, IDecisionTreeNode> linksToChildren,
object decisionValue,
bool isSplitValueNumeric)
: base(isLeaf, decisionFeatureName, linksToChildren)
{
IsValueNumeric = isSplitValueNumeric;
DecisionValue = decisionValue;
TestResultsWithChildren = linksToChildren.ToDictionary(
kvp => kvp.Key as IBinaryDecisionTreeLink,
kvp => kvp.Value);
foreach (var link in linksToChildren)
{
var binaryTreeLink = link.Key as IBinaryDecisionTreeLink;
if (binaryTreeLink != null)
{
if (!binaryTreeLink.LogicalTestResult)
{
LeftChild = link.Value;
LeftChildLink = binaryTreeLink;
}
else
{
RightChild = link.Value;
RightChildLink = binaryTreeLink;
}
}
}
}
示例5: OverrideValueProvider
public OverrideValueProvider(IValueProvider originalValueProvider, IDictionary<string, string> values)
{
OriginalValueProvider = originalValueProvider;
HardcodedValues = values.ToDictionary(
x => x.Key,
x => new ValueProviderResult(x.Value, x.Value, System.Globalization.CultureInfo.InvariantCulture));
}
示例6: Request
public Request(string url, string verb, string body, IDictionary<string, string> headers)
{
_url = url;
_headers = headers.ToDictionary(kv => kv.Key.ToLower(), kv => kv.Value.ToLower());
_verb = verb.ToLower();
_body = body==null ? "" : body.Trim();
}
示例7: TangerineConfiguration
/// <summary>
/// Initializes a new instance of the <see cref="Craswell.WebRepositories.Tangerine.TangerineConfiguration"/> class.
/// </summary>
/// <param name="webSiteAddress">Web site address.</param>
/// <param name="acn">The account client number.</param>
/// <param name="pin">The client pin.</param>
/// <param name="securityQuestions">The client security questions.</param>
public TangerineConfiguration(
Uri webSiteAddress,
string acn,
string pin,
IDictionary<string, string> securityQuestions)
{
if (string.IsNullOrEmpty(acn))
{
throw new ArgumentNullException("acn");
}
if (string.IsNullOrEmpty(pin))
{
throw new ArgumentNullException("pin");
}
if (webSiteAddress == null)
{
throw new ArgumentNullException("webSiteAddress");
}
if (securityQuestions == null)
{
throw new ArgumentNullException("securityQuestions");
}
this.acn = acn;
this.pin = pin;
this.webSiteAddress = webSiteAddress;
this.securityQuestions = securityQuestions
.ToDictionary(d => d.Key, d => d.Value);
}
示例8: BuildOptionDictionary
static IDictionary<string, IOptionApplier> BuildOptionDictionary(
IDictionary<string, IDictionary<string, JToken>> jsonOptions, IReadOnlyList<IOption> supportedOptions)
{
return jsonOptions.ToDictionary(
o => o.Key,
o => (IOptionApplier)new JsonOptionApplier(o.Key, o.Value, supportedOptions));
}
示例9: BuildTextureMap
private short[,] BuildTextureMap(IDictionary<TextureGroup, byte> textureGroupIds,
IDictionary<Tuple<byte, byte>, TextureGroupTransition> textureTansitionLookup,
byte[,] textureGroupMap)
{
var idsToTextureGroups = textureGroupIds.ToDictionary(item => item.Value, item => item.Key);
return null;
}
示例10: ObjectSubclassingController
public ObjectSubclassingController(IDictionary<Type, Action> actions) {
mutex = new ReaderWriterLockSlim();
registeredSubclasses = new Dictionary<String, ObjectSubclassInfo>();
registerActions = actions.ToDictionary(p => GetClassName(p.Key), p => p.Value);
// Register the ParseObject subclass, so we get access to the ACL,
// objectId, and other ParseFieldName properties.
RegisterSubclass(typeof(ParseObject));
}
示例11: RedisExtensions
static RedisExtensions()
{
getCommand = new Dictionary<string,Type>{
{"AddCustomerCommand", typeof(AddCustomerCommand)},
{"AddOrderCommand" , typeof(AddOrderCommand)},
{"AddProductCommand" , typeof(AddProductCommand)},
{"AddProductToOrder" , typeof(AddProductToOrder)},
};
getName = getCommand.ToDictionary(kv => kv.Value, kv => kv.Key);
}
示例12: InvokeMethod
public IEnumerable<string> InvokeMethod(Models.Method method, IDictionary<string, object> form)
{
using (var build = Build())
{
return build
.Controller(method.ClassName)
.Action(method.Name)
.Parameters(form.ToDictionary(p => p.Key, p => p.Value != null ? p.Value.ToString() : (string)null))
.Invoke();
}
}
示例13: SaveTempData
/// <summary>
/// Save temp data dictionary to the specified <see cref="HttpContext" /> object.
/// </summary>
/// <param name="context">The <see cref="HttpContext" /> object.</param>
/// <param name="values">The temp data dictionary to be saving.</param>
public override void SaveTempData(HttpContext context, IDictionary<string, object> values)
{
if (values == null)
{
base.SaveTempData(context, null);
return;
}
var newDic = values.ToDictionary(item => item.Key, item => ObjectSerializer.Serialize(item.Value));
base.SaveTempData(context, newDic);
}
示例14: ODataQueryPartTypeExtensions
static ODataQueryPartTypeExtensions()
{
var fields = Enum.GetNames(typeof (ODataQueryPartType))
.Select(typeof (ODataQueryPartType).GetField)
.ToList();
TypeToParameterNames = fields
.Where(x => x.GetCustomAttributes<UrlParameterAttribute>().Any())
.ToDictionary(key => (ODataQueryPartType)key.GetValue(null), value => value.GetCustomAttributes<UrlParameterAttribute>().Single().Name);
ParameterNameToType = TypeToParameterNames.ToDictionary(key => key.Value, value => value.Key);
}
示例15: ToDynamicODataEntry
private static IDictionary<string, object> ToDynamicODataEntry(IDictionary<string, object> entry)
{
return entry == null
? null
: entry.ToDictionary(
x => x.Key,
y => y.Value is IDictionary<string, object>
? new DynamicODataEntry(y.Value as IDictionary<string, object>)
: y.Value is IEnumerable<object>
? ToDynamicODataEntry(y.Value as IEnumerable<object>)
: y.Value);
}