public void should_check_if_sequence_has_more_than_zero_elements() { var sequence = new[] { 1, 2, 3, 4, 5 }; bool sequenceNotEmpty = sequence.Any(); bool modThreeNotEmpty = sequence.Any(item => item % 3 == 0); // please update variable values of the following 2 lines to fix the test. const bool expectedSequenceNotEmpty = false; const bool expectedModThreeNotEmpty = false; Assert.Equal(expectedSequenceNotEmpty, sequenceNotEmpty); Assert.Equal(expectedModThreeNotEmpty, modThreeNotEmpty); }
public void Copy_Razor_files_to_AWS_Bucket() { var fs = new FileSystemVirtualPathProvider(appHost, "~/../RazorRockstars.WebHost".MapHostAbsolutePath()); var skipDirs = new[] { "bin", "obj" }; var matchingFileTypes = new[] { "cshtml", "md", "css", "js", "png", "jpg" }; var replaceHtmlTokens = new Dictionary<string, string> { { "title-bg.png", "title-bg-aws.png" }, //Title Background { "https://gist.github.com/3617557.js", "https://gist.github.com/mythz/396dbf54ce6079cc8b2d.js" }, //AppHost.cs { "https://gist.github.com/3616766.js", "https://gist.github.com/mythz/ca524426715191b8059d.js" }, //S3 RockstarsService.cs { "RazorRockstars.WebHost/RockstarsService.cs", "RazorRockstars.S3/RockstarsService.cs" }, //S3 RockstarsService.cs { "http://github.com/ServiceStackApps/RazorRockstars/", "https://github.com/ServiceStackApps/RazorRockstars/tree/master/src/RazorRockstars.S3" } //Link to GitHub project }; foreach (var file in fs.GetAllFiles()) { if (skipDirs.Any(x => file.VirtualPath.StartsWith(x))) continue; if (!matchingFileTypes.Contains(file.Extension)) continue; if (file.Extension == "cshtml") { var html = file.ReadAllText(); replaceHtmlTokens.Each(x => html = html.Replace(x.Key, x.Value)); s3.WriteFile(file.VirtualPath, html); } else { s3.WriteFile(file); } } }
private IEnumerable<string> GetTestSuiteFiles() { const string dir = @"J:\dev\Projects\Misc\closure-library\closure\goog\"; string[] allFiles = Directory.GetFiles(dir, "*_test.html", SearchOption.AllDirectories); string[] ignore = new [] {"fontsizemonitor_test.html", "icontent_test.html", "abstractdialogplugin_test.html", "linkdialogplugin_test.html", "crossdomainrpc_test.html", "positioning_test.html", "serializer_test.html", "descriptor_test.html", "message_test.html", "proto_test.html", "viewportclientposition_test.html", "spellcheck_test.html", "pubsub_test.html", "collectablestorage_test.html"}; return allFiles.Where(f => !ignore.Any(i => f.IndexOf(i) >= 0)).ToArray(); }
private static bool HasShipNextDoor(IEnumerable<Point> points, Point point) { var list = new[] { new KeyValuePair<char, int>((char)(point.X - 1), point.Y), new KeyValuePair<char, int>((char)(point.X + 1), point.Y), new KeyValuePair<char, int>((char)point.X, (byte)(point.Y - 1)), new KeyValuePair<char, int>((char)point.X, (byte)(point.Y + 1)) }; return points.Where(d => d.HasShip).Any(c => list.Any(d => d.Key == c.X && d.Value == c.Y)); }
/// <summary> /// Ermittelt die ID-Information aus der Informationssammlung /// </summary> /// <param name="information">Informationssammlung</param> /// <returns>ID-Information</returns> public static string GetId(this Dictionary<string, IEnumerable<string>> information) { var id = default(string); var idexpressions = new[] { ".id", "id" }; var ids = information != null ? information?.FirstOrDefault(entry => idexpressions.Any(expression => entry.Key.ToLower().EndsWith(expression))) : default(KeyValuePair<string, IEnumerable<string>>) ; id = ids?.Value?.FirstOrDefault() ?? string.Empty; return id; }
TreeNode CreateTreeNodeCore() { var node = new TreeNode(); using (var stream = item.OpenStream()) { var rawEMsg = PeekUInt(stream); node.Nodes.Add(BuildInfoNode(rawEMsg)); var header = ReadHeader(rawEMsg, stream); node.Nodes.Add(new TreeNodeObjectExplorer("Header", header).TreeNode); var body = ReadBody(rawEMsg, stream, header); var bodyNode = new TreeNodeObjectExplorer("Body", body).TreeNode; node.Nodes.Add(bodyNode); var payload = ReadPayload(stream); if (payload != null && payload.Length > 0) { node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload).TreeNode); } if (Specializations != null) { var objectsToSpecialize = new[] { body }; while (objectsToSpecialize.Any()) { var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o))); if (!specializations.Any()) { break; } bodyNode.Collapse(ignoreChildren: true); var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value).TreeNode).ToArray(); node.Nodes.AddRange(extraNodes); // Let the specializers examine any new message objects. objectsToSpecialize = specializations.Select(x => x.Value).ToArray(); } } } return node; }
protected override bool TriggerCondition() { var theron = CurrentTile.SubItems.FirstOrDefault(x => x is Theron) as Theron; if (theron != null) { var items = new[] { theron.Hand } .Concat(theron.PartyGroup.SelectMany(x => x.Body.Storages.SelectMany(s => s.Storage))) .Concat(CurrentTile.SubItems.OfType<GrabableItem>()); return items.Any(Constrain.IsAcceptable); } else { return false; } }
public IEnumerable<RouteInfo> FindAll(params Assembly[] assemblies) { var routes = new List<RouteInfo>(); foreach (var assembly in assemblies) { var types = assembly.GetTypes(); var allowedMethodNames = new[] { HttpMethods.Any, HttpMethods.Post, HttpMethods.Get, HttpMethods.Put, HttpMethods.Delete }; foreach (var type in types) { foreach (var serviceMethod in type.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(m => m.ReturnType != typeof(void))) { if (allowedMethodNames.Any(m => string.Compare(m, serviceMethod.Name, true) == 0)) { var parameters = serviceMethod.GetParameters(); if (parameters.Length == 1) { var parameterType = parameters[0].ParameterType; var attributes = parameterType.GetCustomAttributes(typeof(RouteAttribute), true) as RouteAttribute[]; foreach (var attribute in attributes) { routes.Add(new RouteInfo(attribute.Route, serviceMethod)); } } } } } } return new ReadOnlyCollection<RouteInfo>(routes); }
internal void LoadConfigSettings() { if(Config.Instance.TrackerWindowTop.HasValue) Top = Config.Instance.TrackerWindowTop.Value; if(Config.Instance.TrackerWindowLeft.HasValue) Left = Config.Instance.TrackerWindowLeft.Value; if(Config.Instance.WindowHeight < 0) Config.Instance.Reset("WindowHeight"); Height = Config.Instance.WindowHeight; if(Config.Instance.WindowWidth < 0) Config.Instance.Reset("WindowWidth"); Width = Config.Instance.WindowWidth; var titleBarCorners = new[] { new Point((int)Left + 5, (int)Top + 5), new Point((int)(Left + Width) - 5, (int)Top + 5), new Point((int)Left + 5, (int)(Top + TitlebarHeight) - 5), new Point((int)(Left + Width) - 5, (int)(Top + TitlebarHeight) - 5) }; if(!Screen.AllScreens.Any(s => titleBarCorners.Any(c => s.WorkingArea.Contains(c)))) { Top = 100; Left = 100; } if(Config.Instance.StartMinimized) { WindowState = WindowState.Minimized; if(Config.Instance.MinimizeToTray) MinimizeToTray(); } Options.Load(Core.Game); Help.TxtblockVersion.Text = "v" + Helper.GetCurrentVersion().ToVersionString(); Core.TrayIcon.SetContextMenuProperty("autoSelectDeck", "Checked", Config.Instance.AutoDeckDetection); // Don't select the 'archived' class on load var selectedClasses = Config.Instance.SelectedDeckPickerClasses.Where(c => c.ToString() != "Archived").ToList(); if(selectedClasses.Count == 0) selectedClasses.Add(HeroClassAll.All); DeckPickerList.SelectClasses(selectedClasses); DeckPickerList.SelectDeckType(Config.Instance.SelectedDeckType, true); DeckPickerList.UpdateAutoSelectToggleButton(); SortFilterDecksFlyout.LoadTags(DeckList.Instance.AllTags); SortFilterDecksFlyout.SetSelectedTags(Config.Instance.SelectedTags); TagControlEdit.LoadTags(DeckList.Instance.AllTags.Where(tag => tag != "All" && tag != "None").ToList()); SortFilterDecksFlyout.OperationSwitch.IsChecked = Config.Instance.TagOperation == TagFilerOperation.And; SortFilterDecksFlyout.ComboboxDeckSorting.SelectedItem = Config.Instance.SelectedDeckSorting; SortFilterDecksFlyout.CheckBoxSortByClass.IsChecked = Config.Instance.SortDecksByClass; SortFilterDecksFlyout.ComboboxDeckSortingArena.SelectedItem = Config.Instance.SelectedDeckSortingArena; SortFilterDecksFlyout.CheckBoxSortByClassArena.IsChecked = Config.Instance.SortDecksByClassArena; if(!Helper.EventKeys.Contains(Config.Instance.KeyPressOnGameStart)) Config.Instance.KeyPressOnGameStart = "None"; if(!Helper.EventKeys.Contains(Config.Instance.KeyPressOnGameEnd)) Config.Instance.KeyPressOnGameEnd = "None"; ManaCurveMyDecks.Visibility = Config.Instance.ManaCurveMyDecks ? Visibility.Visible : Visibility.Collapsed; Core.TrayIcon.SetContextMenuProperty("classCardsFirst", "Checked", Config.Instance.CardSortingClassFirst); Core.TrayIcon.SetContextMenuProperty("useNoDeck", "Checked", DeckList.Instance.ActiveDeck == null); DeckStatsFlyout.LoadConfig(); GameDetailsFlyout.LoadConfig(); Core.Windows.StatsWindow.StatsControl.LoadConfig(); Core.Windows.StatsWindow.GameDetailsFlyout.LoadConfig(); MenuItemCheckBoxSyncOnStart.IsChecked = Config.Instance.HearthStatsSyncOnStart; MenuItemCheckBoxAutoUploadDecks.IsChecked = Config.Instance.HearthStatsAutoUploadNewDecks; MenuItemCheckBoxAutoUploadGames.IsChecked = Config.Instance.HearthStatsAutoUploadNewGames; MenuItemCheckBoxAutoSyncBackground.IsChecked = Config.Instance.HearthStatsAutoSyncInBackground; MenuItemCheckBoxAutoDeleteDecks.IsChecked = Config.Instance.HearthStatsAutoDeleteDecks; MenuItemCheckBoxAutoDeleteGames.IsChecked = Config.Instance.HearthStatsAutoDeleteMatches; }
public static bool Qualifies(Transaction t) { var validTypes = new[] { 600, 646, 636, 650, 700 }; return validTypes.Any(v => v == t.TransactionTypeId); }
private static void Generate35(string srcPath, string destFile, params string[] references) { var database = XDocument.Load(srcPath); foreach (var element in database.Root.Descendants(xmlns + "DefineConstants").ToArray()) { if (element.Value.EndsWith(";") == false) element.Value += ";"; element.Value += "NET35"; } foreach (var element in database.Root.Descendants(xmlns + "ProjectReference").ToArray()) { if (references.Contains(element.Element(xmlns + "Name").Value) == false) continue; element.Attribute("Include").Value = element.Attribute("Include").Value.Replace(".csproj", ".g.3.5.csproj"); { element.Element(xmlns + "Project").Value = "{4C18FC25-0B1E-42E3-A423-3A99F1AC57EE}"; element.Element(xmlns + "Name").Value += "-3.5"; } } foreach (var element in database.Root.Descendants(xmlns + "Reference").ToArray()) { if (element.Attribute("Include").Value == "Microsoft.CSharp") element.Remove(); if (element.Attribute("Include").Value == "AsyncCtpLibrary") element.Remove(); if (element.Attribute("Include").Value == "System.ComponentModel.Composition") element.Remove(); var nugetPakcages = new[] {"Newtonsoft.Json", "NLog"}; if (nugetPakcages.Any(x => element.Attribute("Include").Value.StartsWith(x))) { element.Element(xmlns + "HintPath").Value = element.Element(xmlns + "HintPath").Value.Replace("net40", "net35"); } } foreach (var element in database.Root.Descendants(xmlns + "DocumentationFile").ToArray()) { element.Value = element.Value.Replace(".XML", "-3.5.XML"); } foreach (var element in database.Root.Descendants(xmlns + "TargetFrameworkVersion")) { element.Value = "v3.5"; } foreach (var element in database.Root.Descendants(xmlns + "TargetFrameworkProfile")) { element.Value = "Client"; } foreach (var element in database.Root.Descendants(xmlns + "AssemblyName")) { element.Value += "-3.5"; } using (var xmlWriter = XmlWriter.Create(destFile, new XmlWriterSettings { Indent = true })) { database.WriteTo(xmlWriter); xmlWriter.Flush(); } }
public static bool Qualifies(Transaction t) { var validTypes = new[] { 601, 602, 603 }; return validTypes.Any(v => v == t.TransactionTypeId); }
public bool BeginAndEndAreEqual() { if (HasRange) { var bytes = new[] { "byte[]", "rowversion" }; if (bytes.Any(t => t == Version.SimpleType)) { var beginBytes = (byte[])Begin; var endBytes = (byte[])End; return Common.AreEqual(beginBytes, endBytes); } return Begin.Equals(End); } return false; }
//指定されたファイルのパスを受け取って、指定名のバックアップファイルを作成して挿入 private static void WriteInsetLine(string defaultFileFullName, Encoding encoding) { //挿入するべき最後尾の文字 var delm = new[]{ ";", "{", "}", ")"}; var fileInfo = new FileInfo(defaultFileFullName); const string appendExtension = OccfNames.LineBackUpSuffix; var backUpFileFullName = defaultFileFullName + appendExtension; File.Copy(defaultFileFullName, backUpFileFullName, true); using (var reader = new StreamReader(backUpFileFullName, encoding)) { using (var writer = new StreamWriter(fileInfo.FullName, false, encoding)) { string line; var lineNum = 1; while ((line = reader.ReadLine()) != null) { if (delm.Any(s => line.TrimEnd(' ', '\t').EndsWith(s))) { writer.WriteLine(line); writer.WriteLine("#line " + lineNum); } else { writer.WriteLine(line); } lineNum++; } reader.Close(); writer.Close(); } } Console.WriteLine("wrote:" + fileInfo.FullName); }
private static MiningFilter ComposeFilterColor(string question) { var filter = default(MiningFilter); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Data.Mining.colors.json")) { using (var reader = new StreamReader(stream)) { var colorfilters = Enumerable.Empty<MiningFilter>(); var jsoncolors = JsonConvert.DeserializeObject(reader.ReadToEnd()) as JObject; var jcolors = jsoncolors.SelectTokens("$.colors[?(@.description != '')]"); foreach(var jcolor in jcolors) { var color = jcolor.SelectToken("description").ToString(); var subcolorids = jcolor.SelectToken("subcolors") as JArray; var synonyms = new[] { color, $"{color}e" }; if(synonyms.Any( synonym => question.ToLower().StartsWith(synonym) || Regex.IsMatch(question.ToLower(), $"( |,){synonym}( |,)") )) { colorfilters = colorfilters.Concat(new[] { new MiningFilter { Target = "color", Value = $".*?{color}.*?" } }); // Farbalternativen durch Subfarben if (subcolorids != null && subcolorids.Any()) { subcolorids.AsParallel().ForAll(colorid => { var jsubcolor = jsoncolors.SelectToken($"$.colors[?(@.id == {colorid})]"); var subcolor = jsubcolor?.SelectToken("description").ToString(); colorfilters = colorfilters.Concat(new[] { new MiningFilter { Target = "color", Value = $".*?{subcolor}.*?" } }); }); } } } if(colorfilters.Any()) { filter = new MiningFilter { Or = colorfilters }; } } } return filter; }
public static bool Qualifies(Transaction t) { var validTypes = new[] { 652, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809 }; return validTypes.Any(v => v == t.TransactionTypeId); }
public static async Task SaveArticleContent(ArticleModel model, ISqliteService service, bool skipCleaning = false) { var imageContentGenericRepository = new GenericRepository<ImageContentModel, ImageContentEntity>(service); var textContentGenericRepository = new GenericRepository<TextContentModel, TextContentEntity>(service); var galleryContentGenericRepository = new GenericRepository<GalleryContentModel, GalleryContentEntity>(service); var supportedContents = new[] { (int)ContentType.Text, (int)ContentType.Gallery, (int)ContentType.Image }; List<ContentEntity> oldModels = null; if (!skipCleaning) { var id = model.GetId(); oldModels = (await service.GetByCondition<ContentEntity>(e => e.ParentId == id, null, false, 0, 0)).ToList(); oldModels = oldModels.Where(e => supportedContents.Any(s => s == e.ContentType)).ToList(); } for (int i = 0; i < model.Content.Count; i++) { var baseContentModel = model.Content[i]; ContentEntity entity = null; if (!skipCleaning) { entity = oldModels.FirstOrDefault(m => m.ContentId == baseContentModel.GetId()); oldModels.Remove(entity); } if (entity == null) entity = new ContentEntity(); if (baseContentModel is TextContentModel) { var text = (TextContentModel)baseContentModel; text.ContentJson = JsonConvert.SerializeObject(text.Content); await textContentGenericRepository.SaveAsyc(text); entity.ContentType = (int)ContentType.Text; } else if (baseContentModel is ImageContentModel) { var image = (ImageContentModel)baseContentModel; if (image.Text != null) { await textContentGenericRepository.SaveAsyc(image.Text); image.TextContentId = image.Text.GetId(); } await imageContentGenericRepository.SaveAsyc(image); entity.ContentType = (int)ContentType.Image; } else if (baseContentModel is GalleryContentModel) { var gallery = (GalleryContentModel)baseContentModel; if (gallery.Text != null) { await textContentGenericRepository.SaveAsyc(gallery.Text); gallery.TextContentId = gallery.Text.GetId(); } await galleryContentGenericRepository.SaveAsyc(gallery); for (int index = 0; index < gallery.Images.Count; index++) { gallery.Images[index].GalleryId = gallery.GetId(); gallery.Images[index].GalleryIndex = index; if (gallery.Images[index].Text != null) { await textContentGenericRepository.SaveAsyc(gallery.Images[index].Text); gallery.Images[index].TextContentId = gallery.Images[index].Text.GetId(); } await imageContentGenericRepository.SaveAsyc(gallery.Images[index]); } entity.ContentType = (int)ContentType.Gallery; } else { continue; } entity.ContentId = baseContentModel.GetId(); entity.ParentId = model.GetId(); entity.Index = i; if (entity.Id == 0) await service.Add(entity); else await service.Update(entity); } if (!skipCleaning && oldModels != null) foreach (var contentEntity in oldModels) { await service.DeleteById<ContentEntity>(contentEntity.Id); } }
private bool DoesContainAssertion(MethodCall methodCall) { if (!methodCall.HasMethodDefinition || !methodCall.MethodDefinition.HasBody) return false; var frameworks = new[] {Framework}.Concat(_mockFrameworks); return frameworks.Any(fw => fw.DoesContainAssertion(methodCall.MethodDefinition)); }
private void CreateSolution(IEnumerable<TsPoint> points, TspSolution solution, TsPoint firstPoint) { var notVisited = new List<TsPoint>(points.Where(p => p.Id != firstPoint.Id)); var last = firstPoint; while (notVisited.Any()) { var next = GetClosestPoint(last, notVisited); //check for potential orphans var pointsAbove = notVisited.Where(p => p != next && p.Y > last.Y).ToArray(); var pointsBelow = notVisited.Where(p => p != next && p.Y < last.Y).ToArray(); var pointsRight = notVisited.Where(p => p != next && p.X > last.X).ToArray(); var pointsLeft = notVisited.Where(p => p != next && p.X < last.X).ToArray(); TsPoint theAbove = null; TsPoint theBelow = null; TsPoint theRight = null; TsPoint theLeft = null; if (pointsAbove.Length == 1) { theAbove = pointsAbove.Single(); if (next.DistanceFrom(last) / theAbove.DistanceFrom(last) < _threshold) theAbove = null; } if (pointsBelow.Length == 1) { theBelow = pointsBelow.Single(); if (next.DistanceFrom(last) / theBelow.DistanceFrom(last) < _threshold) theBelow = null; } if (pointsRight.Length == 1) { theRight = pointsRight.Single(); if (next.DistanceFrom(last) / theRight.DistanceFrom(last) < _threshold) theRight = null; } if (pointsLeft.Length == 1) { theLeft = pointsLeft.Single(); if (next.DistanceFrom(last) / theLeft.DistanceFrom(last) < _threshold) theLeft = null; } var nextPoints = new[] { theAbove, theBelow, theRight, theLeft }.Where(p => p != null).ToList(); if (nextPoints.Any()) { var unOrphaned = GetClosestPoint(last, nextPoints); notVisited.Remove(unOrphaned); last = unOrphaned; solution.AddNext(unOrphaned); } else { notVisited.Remove(next); last = next; solution.AddNext(next); } } }