本文整理汇总了C#中IDictionary.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.ToList方法的具体用法?C# IDictionary.ToList怎么用?C# IDictionary.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dump
public static string Dump(string sql, IDictionary<string, object> parameters, ISqlDialect dialect = null)
{
if (parameters == null)
return sql;
var param = parameters.ToList();
for (var i = 0; i < param.Count; i++)
{
var name = param[i].Key;
if (!name.StartsWith("@"))
param[i] = new KeyValuePair<string,object>("@" + name, param[i].Value);
}
param.Sort((x, y) => y.Key.Length.CompareTo(x.Key.Length));
var sb = new StringBuilder(sql);
foreach (var pair in param)
sb.Replace(pair.Key, DumpParameterValue(pair.Value, dialect));
var text = DatabaseCaretReferences.Replace(sb.ToString());
dialect = dialect ?? SqlSettings.DefaultDialect;
var openBracket = dialect.OpenQuote;
if (openBracket != '[')
text = BracketLocator.ReplaceBrackets(text, dialect);
var paramPrefix = dialect.ParameterPrefix;
if (paramPrefix != '@')
text = ParamPrefixReplacer.Replace(text, paramPrefix);
return text;
}
示例2: Can_serialize_content_as_complex_associative_array
public void Can_serialize_content_as_complex_associative_array()
{
var message = new MandrillMessage();
var data = new IDictionary<string, object>[]
{
new Dictionary<string, object>
{
{"sku", "apples"},
{"unit_price", 0.20},
},
new Dictionary<string, object>
{
{"sku", "oranges"},
{"unit_price", 0.40},
}
};
message.GlobalMergeVars.Add(new MandrillMergeVar()
{
Name = "test",
Content = data.ToList()
});
var json = JObject.FromObject(message, MandrillSerializer.Instance);
json["global_merge_vars"].Should().NotBeEmpty();
var result = json["global_merge_vars"].First["content"]
.ToObject<List<Dictionary<string, object>>>(MandrillSerializer.Instance);
result[0]["sku"].Should().Be("apples");
result[0]["unit_price"].Should().Be(0.20);
result[1]["sku"].Should().Be("oranges");
result[1]["unit_price"].Should().Be(0.40);
}
示例3: AmqpConnectionParameters
public AmqpConnectionParameters(IDictionary<string, string> parameters)
{
this.SetDefaultValues();
parameters
.ToList<KeyValuePair<string, string>>()
.ForEach(param => this.Set(param.Key, param.Value));
}
示例4: DispatchDoesNotMutateInputRouteValues
public void DispatchDoesNotMutateInputRouteValues(
DefaultRouteDispatcher sut,
MethodCallExpression method,
IDictionary<string, object> routeValues)
{
var expected = routeValues.ToList();
sut.Dispatch(method, routeValues);
Assert.True(expected.SequenceEqual(routeValues));
}
示例5: ReportRunner
public ReportRunner(
ReportFormat reportFormat,
string reportPath,
IDictionary<string, object> reportParameters)
: this(reportFormat,
reportPath,
reportParameters != null ? reportParameters.ToList() : null)
{
}
示例6: SetOutputArguments
public void SetOutputArguments(IDictionary<string, string> output)
{
RemoveArgument(output, StartArgument.Replace("/", ""));
RemoveArgument(output, EndArgument.Replace("/", ""));
foreach (var kvp in output.ToList())
{
output[kvp.Key] = string.Format("{0}.{1}.{2}.pout", kvp.Value, Start, End);
}
}
示例7: GetInstalledExtensionPaths
/// <summary>
/// Converts the given collection of extension properties and their identifiers to full paths.
/// </summary>
internal static Dictionary<string, string> GetInstalledExtensionPaths(IVsExtensionManager extensionManager, IDictionary<string, string> extensionIds)
{
// Update installed Extensions
var installedExtensionPaths = new Dictionary<string, string>();
extensionIds.ToList().ForEach(ie =>
{
installedExtensionPaths.Add(ie.Key, GetInstalledExtensionPath(extensionManager, ie.Value));
});
return installedExtensionPaths;
}
示例8: BuildCommand
public IDbCommand BuildCommand(IDbConnection connection, string sql, IDictionary<string, object> parameters)
{
var cmd = connection.CreateCommand();
cmd.Connection = connection;
cmd.CommandText = sql;
parameters.ToList()
.ForEach(cmd.AddParameter);
return cmd;
}
示例9: Calculate
/// <summary>
/// Append stats distributed in castle
/// </summary>
/// <param name="castleStatsDictionary">Stats distributed in castle</param>
/// <param name="calculationResult">Current calculation result</param>
public void Calculate(IDictionary<StatTypeEnum, byte> castleStatsDictionary, CalculationResult calculationResult)
{
if (castleStatsDictionary == null)
throw new ArgumentNullException("castleStatsDictionary");
if (calculationResult == null)
throw new ArgumentNullException("calculationResult");
castleStatsDictionary
.ToList()
.ForEach(y => applyStatValue(y.Key, y.Value, calculationResult));
}
示例10: CreateTags
/// <summary>
/// Creates Tag objects from a provided dictionary of string tags along with integer values indicating the weight of each tag.
/// This overload is suitable when you have a list of already weighted tags, i.e. from a database query result.
/// </summary>
/// <param name="weightedTags">A dictionary that takes a string for the tag text (as the dictionary key) and an integer for the tag weight (as the dictionary value).</param>
/// <param name="rules">A TagCloudGenerationRules object to decide how the cloud is generated.</param>
/// <returns>A list of Tag objects that can be used to create the tag cloud.</returns>
public static IEnumerable<Tag> CreateTags(IDictionary<string, int> weightedTags, TagCloudGenerationRules generationRules)
{
#region Parameter validation
if (weightedTags == null) throw new ArgumentNullException("weightedTags");
if (generationRules == null) throw new ArgumentNullException("generationRules");
#endregion
return CreateTags(weightedTags.ToList(), generationRules);
}
示例11: OrderedWordsByValue
private static List<KeyValuePair<string, int>> OrderedWordsByValue(IDictionary<string, int> wordsCount)
{
List<KeyValuePair<string, int>> sorted = wordsCount.ToList();
sorted.Sort((firstPair, nextPair) =>
{
return firstPair.Value.CompareTo(nextPair.Value);
}
);
return sorted;
}
示例12: ReportRunner
public ReportRunner(
ReportFormat reportFormat,
string reportPath,
IDictionary<string, object> reportParameters,
ProcessingMode mode = ProcessingMode.Remote,
IDictionary<string, DataTable> localReportDataSources = null)
: this(reportFormat,
reportPath,
reportParameters != null ? reportParameters.ToList() : null,
mode,
localReportDataSources)
{
}
示例13: InitValues
public void InitValues(IDictionary<string, object> defaultValues) {
valueControls.Clear();
items.Children.Clear();
items.RowDefinitions.Clear();
var defVals = defaultValues.ToList();
for (int i = 0; i < defVals.Count; ++i) {
var p = defVals[i];
items.RowDefinitions.Add(new RowDefinition());
var control = CreateItem(p.Key, p.Value, i, items);
valueControls.Add(p.Key, new Tuple<Control, Type>(control, p.Value.GetType()));
}
}
示例14: UploadString
/// <summary>
/// 上传数据
/// </summary>
/// <param name="url"></param>
/// <param name="service"></param>
/// <param name="queries"></param>
/// <param name="action"></param>
/// <param name="failed"></param>
protected void UploadString(string url
, IDictionary<string, string> queries
, Action<RestResponse, object> action
, Action<Exception> failed
, object userState)
{
bool httpResult = HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
RestClient client = new RestClient();
client.Method = WebMethod.Post;
queries.ToList().ForEach(o => client.AddParameter(o.Key, o.Value));
client.AddHeader("X-Requested-With", "xmlhttp");
client.Authority = url;
RestRequest restRequest = new RestRequest();
CookieContainer cookieContainer = null;
if (IsolatedStorageSettings.ApplicationSettings.Contains("cookie"))
{
cookieContainer = IsolatedStorageSettings.ApplicationSettings["cookieContainer"] as CookieContainer;
Cookie cookie = IsolatedStorageSettings.ApplicationSettings["cookie"] as Cookie;
if (cookieContainer.Count == 0 && cookie != null)
{
cookieContainer.SetCookies(new Uri(Constant.ROOTURL), string.Format("{0}={1}", cookie.Name, cookie.Value));
}
}
else
{
cookieContainer = new CookieContainer();
}
restRequest.CookieContainer = cookieContainer;
client.BeginRequest(restRequest, (request, response, userState1) =>
{
cookieContainer = response.CookieContainer;
CookieCollection cookies = cookieContainer.GetCookies(new Uri(Constant.ROOTURL));
try
{
IsolatedStorageSettings.ApplicationSettings["cookie"] = cookies["cooper"];
IsolatedStorageSettings.ApplicationSettings["cookieContainer"] = cookieContainer;
IsolatedStorageSettings.ApplicationSettings.Save();
}
catch
{
}
if (response != null)
Deployment.Current.Dispatcher.BeginInvoke(action, response, userState1);
else
Deployment.Current.Dispatcher.BeginInvoke(failed, new Exception("response返回为空!"));
}, userState);
}
示例15: LogEvent
static void LogEvent(string eventName, IDictionary<string, object> eventData = null)
{
var dict = GetGenericEventDict();
if (eventData != null)
{
var dataList = eventData.ToList();
dataList.ForEach(pair =>
{
dict.Add(pair);
});
}
Analytics.CustomEvent(eventName, dict);
}