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")); }
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; } }
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)); } }
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); if (Binary.Target.TargetType == TargetRules.TargetType.Editor) { BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Resources/UE4Editor.icns"), BuildProductType.RequiredResource); BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Resources/UProject.icns"), BuildProductType.RequiredResource); } else { string IconName = Binary.Target.TargetName; if (IconName == "EpicGamesBootstrapLauncher") { IconName = "EpicGamesLauncher"; } BuildProducts.Add(FileReference.Combine(BundleContentsDirectory, "Resources/" + IconName + ".icns"), BuildProductType.RequiredResource); } } }
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); }
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); } }
private void Page_Load(object sender, System.EventArgs e) { ContainerPage.SetPageTitle("Home"); ContainerPage.ContentHasNoTitleAtTop = true; Query q = new Query(); q.Columns = Templates.Articles.LatestNew.Columns; q.TableElement = Templates.Articles.LatestNew.PerformJoins(q.TableElement); q.QueryCondition = new And( Article.EnabledQueryCondition, new Q(Article.Columns.Relevance, Article.RelevanceEnum.Worldwide), new And(new Q(Article.Columns.ShowAboveFoldOnFrontPage, true), new Q(Article.Columns.EnabledDateTime, QueryOperator.GreaterThan, DateTime.Now.AddHours(-48))) ); q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending); ArticleSet ars = new ArticleSet(q); if (ars.Count == 0) { NewArticlesPanel.Visible = false; } else { NewArticlesDataList.DataSource = ars; NewArticlesDataList.ItemTemplate = this.LoadTemplate("/Templates/Articles/LatestNew.ascx"); NewArticlesDataList.DataBind(); } Cambro.Web.Helpers.TieButton(SpotterCode, SpotterCodeButton); if (Vars.IE) { SpotterCodeButton.Style["height"] = "23px"; SpotterCodeButton.Style["font-size"] = "12px"; SpotterCodeButton.Style["margin-left"] = "4px"; } else { SpotterCodeButton.Style["height"] = "24px"; SpotterCodeButton.Style["font-size"] = "14px"; SpotterCodeButton.Style["margin-left"] = "0px"; } bool allowTakeoverAfterAgeCheck = true; if (Common.Settings.TakeoverRequiresDrinkingAgeVerificationStatus == Common.Settings.TakeoverRequiresDrinkingAgeVerificationStatusOption.On) { if (Prefs.Current["Drink"] != 1) { allowTakeoverAfterAgeCheck = false; } } if (allowTakeoverAfterAgeCheck) { FrontPageBannerPh.Controls.Clear(); FrontPageBannerPh.Controls.Add(new LiteralControl(Common.Settings.FrontPageBannerHtmlHtml)); } try { bool rb1 = Common.Settings.FrontPageRoadblock1Status == Common.Settings.FrontPageRoadblock1StatusOption.On; bool rb2 = Common.Settings.FrontPageRoadblock2Status == Common.Settings.FrontPageRoadblock2StatusOption.On; bool rb3 = Common.Settings.FrontPageRoadblock3Status == Common.Settings.FrontPageRoadblock3StatusOption.On; int w1 = Common.Settings.FrontPageRoadblock1Weight; int w2 = Common.Settings.FrontPageRoadblock2Weight; int w3 = Common.Settings.FrontPageRoadblock3Weight; //we have a roadblock to show... List<string> alwaysOn = new List<string>(); Dictionary<string, int> roadblocks = new Dictionary<string, int>(); int totalWeight = 0; if (rb1 && w1 == 0) alwaysOn.Add(Common.Settings.FrontPageRoadblock1Html); else if (rb1) { 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 { } }