本文整理汇总了C#中System.Collections.Dictionary.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.ToArray方法的具体用法?C# Dictionary.ToArray怎么用?C# Dictionary.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.ToArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_get_info
public async Task should_get_info()
{
var dummyValuesDict = new Dictionary<string, string>{ { "lsd", "high"} };
var lstKeys = dummyValuesDict.ToArray();
var dummyGrouping = lstKeys.GroupBy(x => x.Key).ToArray();
var muxSubstitute = Substitute.For<IConnectionMultiplexer>();
var muxServer = Substitute.For<IServer>();
muxSubstitute.GetServer(Arg.Any<EndPoint>()).Returns(muxServer);
muxSubstitute.GetEndPoints(Arg.Any<bool>()).Returns(x => new EndPoint[1]);
muxServer.InfoAsync().Returns(dummyGrouping);
RedisInstanceController controller = new RedisInstanceController(muxSubstitute);
var info = await controller.Info();
info.Should().ContainSingle(x => x.ContainsKey("lsd"));
}
示例2: AddItemSourceToSeries
private static void AddItemSourceToSeries(string chartType, object series, Dictionary<object, object> pointList)
{
switch (chartType.ToUpper().Replace(" ", ""))
{
case Statics.Area:
((AreaSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Bar:
((ColumnSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Bubble:
((BubbleSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.RotatedBar:
((BarSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Histogram:
((ColumnSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Line:
((LineSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Pie:
((PieSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Scatter:
((ScatterSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
case Statics.Stacked:
case Statics.TreeMap:
default:
((ColumnSeries)series).ItemsSource = (KeyValuePair<object, object>[])pointList.ToArray();
break;
}
}
示例3: ReadCore
object ReadCore ()
{
SkipSpaces ();
int c = PeekChar ();
if (c < 0)
throw JsonError ("Incomplete JSON input");
switch (c) {
case '[':
ReadChar ();
var list = new List<object> ();
SkipSpaces ();
if (PeekChar () == ']') {
ReadChar ();
return list;
}
while (true) {
list.Add (ReadCore ());
SkipSpaces ();
c = PeekChar ();
if (c != ',')
break;
ReadChar ();
continue;
}
if (ReadChar () != ']')
throw JsonError ("JSON array must end with ']'");
return list.ToArray ();
case '{':
ReadChar ();
var obj = new Dictionary<string,object> ();
SkipSpaces ();
if (PeekChar () == '}') {
ReadChar ();
return obj;
}
while (true) {
SkipSpaces ();
string name = ReadStringLiteral ();
SkipSpaces ();
Expect (':');
SkipSpaces ();
obj [name] = ReadCore (); // it does not reject duplicate names.
SkipSpaces ();
c = ReadChar ();
if (c == ',')
continue;
if (c == '}')
break;
}
return obj.ToArray ();
case 't':
Expect ("true");
return true;
case 'f':
Expect ("false");
return false;
case 'n':
Expect ("null");
// FIXME: what should we return?
return (string) null;
case '"':
return ReadStringLiteral ();
default:
if ('0' <= c && c <= '9' || c == '-')
return ReadNumericLiteral ();
else
throw JsonError (String.Format ("Unexpected character '{0}'", (char) c));
}
}
示例4: ModifyBuildProducts
public override void ModifyBuildProducts(UEBuildBinary Binary, Dictionary<FileReference, BuildProductType> BuildProducts)
{
if (BuildConfiguration.bUsePDBFiles == true)
{
KeyValuePair<FileReference, BuildProductType>[] BuildProductsArray = BuildProducts.ToArray();
foreach (KeyValuePair<FileReference, BuildProductType> BuildProductPair in BuildProductsArray)
{
string DebugExtension = "";
switch (BuildProductPair.Value)
{
case BuildProductType.Executable:
DebugExtension = UEBuildPlatform.GetBuildPlatform(Binary.Target.Platform).GetDebugInfoExtension(UEBuildBinaryType.Executable);
break;
case BuildProductType.DynamicLibrary:
DebugExtension = UEBuildPlatform.GetBuildPlatform(Binary.Target.Platform).GetDebugInfoExtension(UEBuildBinaryType.DynamicLinkLibrary);
break;
}
if (DebugExtension == ".dSYM")
{
string BinaryPath = BuildProductPair.Key.FullName;
if(BinaryPath.Contains(".app"))
{
while(BinaryPath.Contains(".app"))
{
BinaryPath = Path.GetDirectoryName(BinaryPath);
}
BinaryPath = Path.Combine(BinaryPath, BuildProductPair.Key.GetFileName());
BinaryPath = Path.ChangeExtension(BinaryPath, DebugExtension);
FileReference Ref = new FileReference(BinaryPath);
BuildProducts.Add(Ref, BuildProductType.SymbolFile);
}
}
else if(BuildProductPair.Value == BuildProductType.SymbolFile && BuildProductPair.Key.FullName.Contains(".app"))
{
BuildProducts.Remove(BuildProductPair.Key);
}
}
}
if (Binary.Target.GlobalLinkEnvironment.Config.bIsBuildingConsoleApplication)
{
return;
}
if (BundleContentsDirectory == null && Binary.Config.Type == UEBuildBinaryType.Executable)
{
BundleContentsDirectory = Binary.Config.OutputFilePath.Directory.ParentDirectory;
}
// We need to know what third party dylibs would be copied to the bundle
if (Binary.Config.Type != UEBuildBinaryType.StaticLibrary)
{
var Modules = Binary.GetAllDependencyModules(bIncludeDynamicallyLoaded: false, bForceCircular: false);
var BinaryLinkEnvironment = Binary.Target.GlobalLinkEnvironment.DeepCopy();
var BinaryDependencies = new List<UEBuildBinary>();
var LinkEnvironmentVisitedModules = new HashSet<UEBuildModule>();
foreach (var Module in Modules)
{
Module.SetupPrivateLinkEnvironment(Binary, BinaryLinkEnvironment, BinaryDependencies, LinkEnvironmentVisitedModules);
}
foreach (string AdditionalLibrary in BinaryLinkEnvironment.Config.AdditionalLibraries)
{
string LibName = Path.GetFileName(AdditionalLibrary);
if (LibName.StartsWith("lib"))
{
if (Path.GetExtension(AdditionalLibrary) == ".dylib" && BundleContentsDirectory != null)
{
FileReference Entry = FileReference.Combine(BundleContentsDirectory, "MacOS", LibName);
if (!BuildProducts.ContainsKey(Entry))
{
BuildProducts.Add(Entry, BuildProductType.DynamicLibrary);
}
}
}
}
foreach (UEBuildBundleResource Resource in BinaryLinkEnvironment.Config.AdditionalBundleResources)
{
if (Directory.Exists(Resource.ResourcePath))
{
foreach (string ResourceFile in Directory.GetFiles(Resource.ResourcePath, "*", SearchOption.AllDirectories))
{
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, Resource.BundleContentsSubdir, ResourceFile.Substring(Path.GetDirectoryName(Resource.ResourcePath).Length + 1)), BuildProductType.RequiredResource);
}
}
else
{
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, Resource.BundleContentsSubdir, Path.GetFileName(Resource.ResourcePath)), BuildProductType.RequiredResource);
}
}
}
if (Binary.Config.Type == UEBuildBinaryType.Executable)
{
// And we also need all the resources
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Info.plist"), BuildProductType.RequiredResource);
BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "PkgInfo"), BuildProductType.RequiredResource);
//.........这里部分代码省略.........
示例5: GetChartData2
public JsonResult GetChartData2(string chartID)
{
Dictionary<int, int?> pointDict = new Dictionary<int, int?>();
if (chartID.ToLower() != "null")
{
int id = int.Parse(chartID);
BrjostagjofDBDataContext db = new BrjostagjofDBDataContext();
var result = from c in db.Timelines
where c.chartID == id
orderby c.x ascending
select new
{
x = c.x,
y1 = c.y1,
y2 = c.y2
};
foreach (var point in result)
{
pointDict.Add(point.x, point.y2);
}
}
else
{
pointDict.Add(0, 0);
}
return Json(pointDict.ToArray(), JsonRequestBehavior.AllowGet);
}
示例6: InitWtiDataSet
public void InitWtiDataSet(double tv, double commission, double mult, double contSize, double pointvalue, double zim, double ticksize)
{
_parameterProvider.Clear();
_tv = tv;
_commission = commission;
_multiplier = mult;
_contractSize = contSize;
_pointValue = pointvalue;
_tickSize = ticksize;
_zim = _pointValue * _defaultStopLevel;
_wtiParamList = new Dictionary<string,double>
{
{"Time Value",_tv} ,
{"Commission", _commission},
{"Multiplier",_multiplier},
{"Contract Size",_contractSize},
{"Point Value",_pointValue},
{"ZIM",_zim} ,
{"Tick Size",_tickSize}
};
foreach (KeyValuePair<string,double> keys in _wtiParamList.ToArray())
{
DataRow row = _parameterProvider.NewRow();
row[0] = keys.Key ;
row[1] = keys.Value;
_parameterProvider.Rows.Add(row);
}
}
示例7: Page_Load
//.........这里部分代码省略.........
roadblocks.Add(Common.Settings.FrontPageRoadblock1Html, w1);
totalWeight += w1;
}
if (rb2 && w2 == 0)
alwaysOn.Add(Common.Settings.FrontPageRoadblock2Html);
else if (rb2)
{
roadblocks.Add(Common.Settings.FrontPageRoadblock2Html, w2);
totalWeight += w2;
}
if (rb3 && w3 == 0)
alwaysOn.Add(Common.Settings.FrontPageRoadblock3Html);
else if (rb3)
{
roadblocks.Add(Common.Settings.FrontPageRoadblock3Html, w3);
totalWeight += w3;
}
Random r = new Random();
if (alwaysOn.Count > 1)
{
int index = r.Next(alwaysOn.Count);
renderRoadblock(alwaysOn[index]);
}
else if (alwaysOn.Count == 1)
{
renderRoadblock(alwaysOn[0]);
}
else
{
int chosenRnd = r.Next(10 + totalWeight);
if (chosenRnd < 10)
{
Photo p = FrontPagePhotos[chosenRnd];
PhotoAnchor.HRef = p.Url();
PhotoImg.Src = Storage.Path(p.FrontPagePic.Value);
PhotoCaption.InnerHtml = p.PhotoOfWeekCaption;
PhotoCaption.Attributes["class"] = "PhotoOverlay " + p.FrontPageCaptionClass;
PhotoSpotterLink.InnerHtml = p.Usr.NickName;
PhotoSpotterLink.HRef = p.Usr.Url();
string color = p.FrontPageCaptionClass.StartsWith("White") ? "White" : "Black";
string topBottom = p.FrontPageCaptionClass.Contains("Bottom") ? "Bottom" : "Top";
string topBottomOpposite = p.FrontPageCaptionClass.Contains("Bottom") ? "Top" : "Bottom";
string leftRight = p.FrontPageCaptionClass.Contains("Left") ? "Left" : "Right";
string leftRightOpposite = p.FrontPageCaptionClass.Contains("Left") ? "Right" : "Left";
PhotoSoptterHolder.Attributes["class"] = "PhotoOverlay " + color + " " + topBottom + " " + leftRightOpposite;
PhotoLinksHolder.Attributes["class"] = "PhotoOverlay " + color + " " + topBottomOpposite + " Left";
TopPhotoArchiveHolder.Attributes["class"] = "PhotoOverlay " + color + " " + topBottomOpposite + " Right";
}
else
{
chosenRnd = chosenRnd - 10;
for (int i = 0; i < roadblocks.Count; i++)
{
chosenRnd = chosenRnd - roadblocks.ToArray()[i].Value;
if (chosenRnd <= 0)
{
renderRoadblock(roadblocks.ToArray()[i].Key);
break;
}
}
}
}
}
catch { }
try
{
StringBuilder sb = new StringBuilder();
foreach (Photo p in FrontPagePhotos)
{
string s = "";
string s1 = "";
if (Usr.Current != null && Usr.Current.IsAdmin)
{
s = "stt('" + Cambro.Misc.Utility.FriendlyDate(p.PhotoOfWeekDateTime) + "');";
s1 = "onmouseout=\"htm();\"";
}
sb.Append(@"
<div style=""float:left; margin-top:3px; margin-bottom:3px;" + (sb.Length == 0 ? "" : " margin-left:5px;") + @""">
<img src=""" + p.IconPath + @""" width=""30"" height=""30"" class=""Block"" onmouseover=""" + s + @"TopPhotoChangeImage('" + Storage.Path(p.FrontPagePic.Value) + @"', '" + p.Url() + @"', '" + Cambro.Misc.Utility.JsStringEncode(p.PhotoOfWeekCaption) + @"', '" + p.Usr.NickName + @"');return false;"" " + s1 + @" />
</div>
");
}
PhotoLinksPh.Controls.Clear();
PhotoLinksPh.Controls.Add(new LiteralControl(sb.ToString()));
}
catch { }
}