protected virtual void InsertToCollection(int minPro, int maxPro, string[] paths) { List <DirectoryInfo> dirs = new List <DirectoryInfo>(); List <FileInfo> files = new List <FileInfo>(); foreach (string path in paths) { if (Directory.Exists(path)) { dirs.Add(new DirectoryInfo(path)); } else if (SIF.Exists(path)) { files.Add(new FileInfo(path)); } } if (dirs.Any()) { Each each = new Each(); each.SetProgress(minPro, maxPro); each.FileHandleEvent += Each_FileHandleEvent; each.ProgressEvent += this.OnProgress; each.DirsEach(dirs.ToArray()); each.FileHandleEvent -= Each_FileHandleEvent; each.ProgressEvent -= this.OnProgress; } if (files.Any()) { FileEach(files); } }
private static void Obj_AI_Hero_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (sender.IsEnemy && sender.Type == GameObjectType.obj_AI_Minion) { if (GetBool("FW") && W.IsReady() && GetActive("FarmActive") && args.Target.Name == Player.Name && Player.Mana / Player.MaxMana * 100 >= GetSlider("MP")) { if (GrabAlly() == null) { W.Cast(sender, GetBool("UsePacket")); } else { W.CastIfHitchanceEquals(GrabAlly(), HitC, GetBool("UsePacket")); } } } if (GetBool("AutoW") && W.IsReady() && sender.IsEnemy && (sender.Type == GameObjectType.obj_AI_Hero || sender.Type == GameObjectType.obj_AI_Turret)) { if (SpellData.SpellName.Any(Each => Each.Contains(args.SData.Name)) || (args.Target == Player && Player.Distance(sender) <= 450) || args.Target == Player && Utility.UnderTurret(Player, true)) { { if (GrabAlly() == null) { W.Cast(sender, GetBool("UsePacket")); } else { W.CastIfHitchanceEquals(GrabAlly(), HitC, GetBool("UsePacket")); } } } } }
private static void Obj_AI_Hero_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (sender.IsMe) { if (args.SData.Name.ToLower() == "overload") { LastCast = "Q"; } else if (args.SData.Name.ToLower() == "runeprison") { LastCast = "W"; } else if (args.SData.Name.ToLower() == "spellflux") { LastCast = "E"; } else if (args.SData.Name.ToLower() == "desperatepower") { LastCast = "R"; } else if (args.SData.Name.ToLower() == "summonerflash") { LastFlashTime = Environment.TickCount; } } if (sender.IsEnemy && (sender.Type == GameObjectType.obj_AI_Hero || sender.Type == GameObjectType.obj_AI_Turret)) { if (SpellData.SpellName.Any(Each => Each.Contains(args.SData.Name)) || (args.Target == myHero && myHero.Distance(sender) <= 700)) { UseShield = true; } } }
void when_checking_namespaces() { var projectRoot = TestExtensions.GetProjectRoot(); var sourceFiles = TestExtensions.GetSourceFiles(projectRoot); it["processes roughly the correct number of files"] = () => { sourceFiles.Count.should_be_greater_than(80); sourceFiles.Count.should_be_less_than(150); }; const string namespacePattern = @"(?:^namespace)\s.*\b"; string expectedNamespacePattern = string.Format(@"[^\{0}]*", Path.DirectorySeparatorChar); var entitasSourceDir = dir("Entitas", "Entitas"); var entitasUnitySourceDir = dir("Entitas.Unity", "Assets", "Entitas", "Unity"); var each = new Each <string, string, string>(); foreach (var file in sourceFiles) { string expectedNamespace; var fileName = file.Key .Replace(dir(projectRoot), string.Empty) .Replace(entitasSourceDir + "CodeGenerator", "Entitas.CodeGenerator") .Replace(entitasSourceDir + dir("Serialization", "Blueprints"), "Entitas.Serialization.Blueprints/") .Replace(entitasSourceDir + dir("Serialization", "Configuration"), "Entitas.Serialization.Configuration/") .Replace(entitasSourceDir + "Serialization", "Entitas.Serialization") .Replace(entitasUnitySourceDir + "CodeGenerator", "Entitas.Unity.CodeGenerator") .Replace(entitasUnitySourceDir + "VisualDebugging", "Entitas.Unity.VisualDebugging") .Replace(entitasUnitySourceDir + dir("Serialization", "Blueprints"), "Entitas.Unity.Serialization.Blueprints/") .Replace(entitasUnitySourceDir + "Migration", "Entitas.Unity.Migration"); if (file.Key.Contains(typeof(Entitas.Feature).Name) || file.Key.Contains("BlueprintEntityExtension")) { expectedNamespace = "Entitas"; } else { expectedNamespace = Regex.Match(fileName, expectedNamespacePattern) .ToString() .Replace("namespace ", string.Empty) .Trim(); } var foundNamespace = Regex.Match(file.Value, namespacePattern, RegexOptions.Multiline) .ToString() .Replace("namespace ", string.Empty) .Trim(); each.Add(new NSpecTuple <string, string, string>(fileName, foundNamespace, expectedNamespace)); } each.Do((fileName, given, expected) => it["{0} namespace should be {2}".With(fileName, given, expected)] = () => given.should_be(expected) ); }
void when_checking_namespaces() { var projectRoot = TestExtensions.GetProjectRoot(); var sourceFiles = TestExtensions.GetSourceFiles(projectRoot); it["processes roughly the correct number of files"] = () => { sourceFiles.Count.should_be_greater_than(80); sourceFiles.Count.should_be_less_than(150); }; const string namespacePattern = @"(?:^namespace)\s.*\b"; string expectedNamespacePattern = string.Format(@"[^\{0}]*", Path.DirectorySeparatorChar); var entitasSourceDir = dir("Entitas", "Entitas"); var entitasUnitySourceDir = dir("Entitas.Unity", "Assets", "Entitas", "Unity"); var each = new Each<string, string, string>(); foreach(var file in sourceFiles) { string expectedNamespace; var fileName = file.Key .Replace(dir(projectRoot), string.Empty) .Replace(entitasSourceDir + "CodeGenerator", "Entitas.CodeGenerator") .Replace(entitasSourceDir + dir("Serialization", "Blueprints"), "Entitas.Serialization.Blueprints/") .Replace(entitasSourceDir + dir("Serialization", "Configuration"), "Entitas.Serialization.Configuration/") .Replace(entitasSourceDir + "Serialization", "Entitas.Serialization") .Replace(entitasUnitySourceDir + "CodeGenerator", "Entitas.Unity.CodeGenerator") .Replace(entitasUnitySourceDir + "VisualDebugging", "Entitas.Unity.VisualDebugging") .Replace(entitasUnitySourceDir + dir("Serialization", "Blueprints"), "Entitas.Unity.Serialization.Blueprints/") .Replace(entitasUnitySourceDir + "Migration", "Entitas.Unity.Migration"); if(file.Key.Contains(typeof(Entitas.Feature).Name) || file.Key.Contains("BlueprintEntityExtension")) { expectedNamespace = "Entitas"; } else { expectedNamespace = Regex.Match(fileName, expectedNamespacePattern) .ToString() .Replace("namespace ", string.Empty) .Trim(); } var foundNamespace = Regex.Match(file.Value, namespacePattern, RegexOptions.Multiline) .ToString() .Replace("namespace ", string.Empty) .Trim(); each.Add(new NSpecTuple<string, string, string>(fileName, foundNamespace, expectedNamespace)); } each.Do((fileName, given, expected) => it["{0} namespace should be {2}".With(fileName, given, expected)] = () => given.should_be(expected) ); }
void when_checking_namespaces() { var projectRoot = TestExtensions.GetProjectRoot(); var sourceFiles = TestExtensions.GetSourceFiles(projectRoot); it["processes roughly the correct number of files"] = () => { sourceFiles.Count.should_be_greater_than(80); sourceFiles.Count.should_be_less_than(200); }; System.Console.WriteLine("sourceFiles: " + sourceFiles.Count); const string namespacePattern = @"(?:^namespace)\s.*\b"; string expectedNamespacePattern = string.Format(@"[^\{0}]*", Path.DirectorySeparatorChar); var addonsDir = dir("Addons"); var each = new Each <string, string, string>(); foreach (var file in sourceFiles) { var fileName = file.Key .Replace(dir(projectRoot), string.Empty) .Replace(addonsDir, string.Empty); string expectedNamespace; if (file.Key.Contains(typeof(Entitas.Feature).Name)) { expectedNamespace = "Entitas"; } else if (file.Key.Contains("EntityLink.cs")) { expectedNamespace = "Entitas.Unity"; } else { expectedNamespace = Regex.Match(fileName, expectedNamespacePattern) .ToString() .Replace("namespace ", string.Empty) .Trim(); } var foundNamespace = Regex.Match(file.Value, namespacePattern, RegexOptions.Multiline) .ToString() .Replace("namespace ", string.Empty) .Trim(); each.Add(new NSpecTuple <string, string, string>(fileName, foundNamespace, expectedNamespace)); } each.Do((fileName, given, expected) => it["{0} namespace should be {2}".With(fileName, given, expected)] = () => given.should_be(expected) ); }
private string GetRankData() { string RankData = ""; foreach (RankInfo Each in List_RankInfo) { RankData += Each.GetRankData(); } return(RankData); }
static void Main() { List<string> InputList = GetInputList(); string A = InputList[0]; long Answer = 1 + Derive_nC2(A.Length); foreach (var Each in A.ToCharArray().GroupBy(X => X)) { if (Each.Count() <= 1) continue; Answer -= Derive_nC2(Each.Count()); } Console.WriteLine(Answer); }
public void ForEach(Each action) { values .Select(r => r.Value.Select(v => new { origin = v, destiny = r.Key }) ) .SelectMany(r => r) .ToList() .ForEach(r => action(r.origin, r.destiny)); }
/// <summary> /// each block /// </summary> /// <returns></returns> private Each ParseEach() { var tok = Expect("each"); var node = new Each(tok.Code, tok.Value, tok.Key) { Line = Line, Block = Block() }; if (Peek().Type == "code" && (string)Peek().Value == "else") { Advance(); node.Alternative = Block(); } return(node); }
public void Each() { var c = new Dictionary <string, object>(); c["items"] = new int[] { 1, 5, 10, 15 }; var processedItems = new List <int>(); var itemSt = ConvertManager.ChangeType <IStatement>((Action <IDictionary <string, object> >)((cntx) => { processedItems.Add((int)cntx["itm"]); })); var eachSt = new Each((cntx) => { return(cntx["items"] as IEnumerable); }, itemSt, "itm"); eachSt.Execute(c); Assert.AreEqual(0, ValueComparer.Instance.Compare(c["items"], processedItems)); }
void when_checking_namespaces() { var entitasDir = getEntitasProjectDir(); const string entitasUnity = "Entitas.Unity"; var entitasUnityDir = entitasUnity + _dirChar + "Assets"; var sourceFiles = getSourceFiles(entitasDir); sourceFiles.Count.should_be_greater_than(80); sourceFiles.Count.should_be_less_than(150); const string namespacePattern = @"(?:^namespace)\s.*\b"; string expectedNamespacePattern = string.Format(@"[^\{0}]*", _dirChar); var each = new Each <string, string, string>(); foreach (var file in sourceFiles) { var fileName = file.Key .Replace(entitasDir + _dirChar, string.Empty) .Replace(entitasUnityDir + _dirChar, string.Empty) .Replace("Entitas" + _dirChar + "Entitas" + _dirChar + "CodeGenerator", "Entitas.CodeGenerator") .Replace("Entitas" + _dirChar + "Entitas" + _dirChar + "Serialization", "Entitas.Serialization") .Replace("Entitas.Unity" + _dirChar + "CodeGenerator", "Entitas.Unity.CodeGenerator") .Replace("Entitas.Unity" + _dirChar + "VisualDebugging", "Entitas.Unity.VisualDebugging") .Replace("Entitas.Unity" + _dirChar + "Migration", "Entitas.Unity.Migration") .Replace("Entitas.Unity" + _dirChar + "Blueprints", "Entitas.Unity.Blueprints"); var expectedNamespace = Regex.Match(fileName, expectedNamespacePattern) .ToString() .Replace("namespace ", string.Empty) .Trim(); var foundNamespace = Regex.Match(file.Value, namespacePattern, RegexOptions.Multiline) .ToString() .Replace("namespace ", string.Empty) .Trim(); each.Add(new NSpecTuple <string, string, string>(fileName, foundNamespace, expectedNamespace)); } each.Do((fileName, given, expected) => it["{0} namespace should be {2}".With(fileName, given, expected)] = () => given.should_be(expected) ); }
void when_checking_namespaces() { var entitasDir = getEntitasProjectDir(); const string entitasUnity = "Entitas.Unity"; var entitasUnityDir = entitasUnity + _dirChar + "Assets"; var sourceFiles = getSourceFiles(entitasDir); sourceFiles.Count.should_be_greater_than(80); sourceFiles.Count.should_be_less_than(150); const string namespacePattern = @"(?:^namespace)\s.*\b"; string expectedNamespacePattern = string.Format(@"[^\{0}]*", _dirChar); var each = new Each<string, string, string>(); foreach (var file in sourceFiles) { var fileName = file.Key .Replace(entitasDir + _dirChar, string.Empty) .Replace(entitasUnityDir + _dirChar, string.Empty) .Replace("Entitas" + _dirChar + "Entitas" + _dirChar + "CodeGenerator", "Entitas.CodeGenerator") .Replace("Entitas" + _dirChar + "Entitas" + _dirChar + "Serialization", "Entitas.Serialization") .Replace("Entitas.Unity" + _dirChar + "CodeGenerator", "Entitas.Unity.CodeGenerator") .Replace("Entitas.Unity" + _dirChar + "VisualDebugging", "Entitas.Unity.VisualDebugging") .Replace("Entitas.Unity" + _dirChar + "Migration", "Entitas.Unity.Migration") .Replace("Entitas.Unity" + _dirChar + "Blueprints", "Entitas.Unity.Blueprints"); var expectedNamespace = Regex.Match(fileName, expectedNamespacePattern) .ToString() .Replace("namespace ", string.Empty) .Trim(); var foundNamespace = Regex.Match(file.Value, namespacePattern, RegexOptions.Multiline) .ToString() .Replace("namespace ", string.Empty) .Trim(); each.Add(new NSpecTuple<string, string, string>(fileName, foundNamespace, expectedNamespace)); } each.Do((fileName, given, expected) => it["{0} namespace should be {2}".With(fileName, given, expected)] = () => given.should_be(expected) ); }
public void EachTest() { var each = new Each <string>(); var itemsMoq = new Mock <IProvider <string, IEnumerable> >(); var arr = new[] { "a", "b", "c" }; itemsMoq.Setup(fn => fn.Provide("aa")).Returns(arr); var opMoq = new Mock <IOperation <EachContext <string> > >(); var idx = 0; opMoq.Setup(fn => fn.Execute(It.Is <EachContext <string> >(i => i.Item.ToString() == arr[idx]))) .Callback(() => idx++); each.ItemsProvider = itemsMoq.Object; each.ItemOperation = opMoq.Object; each.Execute("aa"); }
private Node parseEach() { Token token = expect(typeof(Each)) ; Each eachToken = (Each)token; EachNode node = new EachNode(); node.setValue(eachToken.getValue()); node.setKey(eachToken.getKey()); node.setCode(eachToken.getCode()); node.setLineNumber(eachToken.getLineNumber()); node.setFileName(filename); node.setBlock(block()); if (peek() is Else) { nextToken(); node.setElseNode(block()); } return(node); }
private void SaveDataToFile() { string Data = ""; // append country data foreach (var Each in Helper.List_Country) { Data += Each.ToString(); } Data += "\n\n\n"; // append category data foreach (var Each in Helper.List_Category) { Data += Each.ToString(); } Data += "\n\n\n"; // append brand data foreach (var Each in Helper.List_Brand) { Data += Each.ToString(); } Data += "\n\n\n"; for (int i = 0; i < CommodityContent.Rows.Count - 1; ++i) { for (int j = 0; j < CommodityContent.Columns.Count; ++j) { Data += CommodityContent.Rows[i].Cells[j].Value.ToString() + ","; } Data = Data.Remove(Data.Length - 1, 1) + "\n"; } File.WriteAllText(Config.CsvFilePath, Data); }
private static void Obj_AI_Hero_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { var UseW = Config.Item("AutoW").GetValue <bool>(); var UsePacket = Config.Item("UsePacket").GetValue <bool>(); var ComboActive = Config.Item("ComboActive").GetValue <KeyBind>().Active; var FarmActive = Config.Item("FarmActive").GetValue <KeyBind>().Active; var FW = Config.Item("FW").GetValue <bool>(); var MP = Config.Item("FMP").GetValue <Slider>().Value; if (sender.IsEnemy && sender.Type == GameObjectType.obj_AI_Minion) { if (FW && W.IsReady() && FarmActive && args.Target.Name == myHero.Name && myHero.Mana / myHero.MaxMana * 100 >= MP) { if (Ally == null) { W.Cast(sender, UsePacket); } else { W.CastIfHitchanceEquals(Ally, HitC, UsePacket); } } } if (UseW && W.IsReady() && sender.IsEnemy && (sender.Type == GameObjectType.obj_AI_Hero || sender.Type == GameObjectType.obj_AI_Turret)) { if (SpellData.SpellName.Any(Each => Each.Contains(args.SData.Name)) || (args.Target == myHero && myHero.Distance(sender) <= 550)) { if (Ally == null) { W.Cast(sender, UsePacket); } else { W.CastIfHitchanceEquals(Ally, HitC, UsePacket); } } } }
public static IStatement ComposeCombinedStatement() { var set1 = new SetSt("sum", 0); var if1 = new If((cntx) => { return(!cntx.ContainsKey("sum")); }, set1); var set2 = new SetSt("items", new double[] { 1, 1, 2, 3, 5, 8, 13 }); var sumSt = new DelegateInvoke( (Func <double, double, double>)((sum, a) => { return(sum + a); }), new Func <IDictionary <string, object>, object>[] { (cntx) => { return(cntx["sum"]); }, (cntx) => { return(cntx["itm"]); } }, "sum" ); var each1 = new Each((cntx) => { return(cntx["items"] as IEnumerable); }, sumSt, "itm"); var sq1 = new Sequence(new IStatement[] { if1, set2, each1 }); return(sq1); }
// Update is called once per frame void Update() { shop = GameObject.FindGameObjectWithTag("shop").GetComponent <Shop>(); // Gör så man kan komma åt Shop scriptet points = GameObject.FindGameObjectWithTag("score").GetComponent <Points>().score; // Kommer åt Points scriptet if (points >= 1 && PlayerPrefs.GetInt("achievement1gotten") == 0) //Om man når kraven för achievementen så får man det. Gäller alla nedan ner till if(startanim... { Dedication?.Invoke(); } if (points >= 10 && PlayerPrefs.GetInt("achievement2gotten") == 0) { Slurper?.Invoke(); } if (shop.Clicker >= 1 && PlayerPrefs.GetInt("achievement3gotten") == 0) { Auto?.Invoke(); } if (shop.Clicker >= 1 || shop.CentupleClicker >= 1 || shop.DecupleClicker >= 1 || shop.TenXClicker >= 1 || shop.doubleClicker >= 1 || shop.HundredXClicker >= 1) { if (PlayerPrefs.GetInt("achievement4gotten") == 0) { Buy?.Invoke(); } } if (shop.Clicker >= 1 && shop.CentupleClicker >= 1 && shop.DecupleClicker >= 1 && shop.TenXClicker >= 1 && shop.doubleClicker >= 1 && shop.HundredXClicker >= 1 && PlayerPrefs.GetInt("achievement5gotten") == 0) { Each.Invoke(); } if (points >= 50000000 && PlayerPrefs.GetInt("achievement6gotten") == 0) { Half.Invoke(); } if (startanimation1 == true) // om man animationen startat så sätter den achievementgotten till 1 och spelar upp animationen. { animator1.SetBool("start", true); StartCoroutine(AnimatorWait()); PlayerPrefs.SetInt("achievement1gotten", 1); } if (startanimation2 == true) { animator2.SetBool("start", true); StartCoroutine(AnimatorWait2()); PlayerPrefs.SetInt("achievement2gotten", 1); } if (startanimation3 == true) { animator3.SetBool("start", true); StartCoroutine(AnimatorWait3()); PlayerPrefs.SetInt("achievement3gotten", 1); } if (startanimation4 == true) { animator4.SetBool("start", true); StartCoroutine(AnimatorWait4()); PlayerPrefs.SetInt("achievement4gotten", 1); } if (startanimation5 == true) { animator5.SetBool("start", true); StartCoroutine(AnimatorWait5()); PlayerPrefs.SetInt("achievement5gotten", 1); } if (startanimation6 == true) { animator6.SetBool("start", true); StartCoroutine(AnimatorWait6()); PlayerPrefs.SetInt("achievement6gotten", 1); } }