Esempio n. 1
1
 public void Apply(IList<IElement> elements, DecompilationContext context)
 {
     var results = new List<IElement>();
     this.ProcessRange(elements, 0, results, new Dictionary<IElement, IElement>());
     elements.Clear();
     elements.AddRange(results);
 }
Esempio n. 2
1
        public SpecPath(string fullPath)
            : base(fullPath)
        {
            _parts = new List<string>();

            var path = new AssetPath(fullPath);
            if (path.Package != null) _parts.Add(path.Package);
            _parts.AddRange(path.Name.Split('/'));
        }
Esempio n. 3
1
        public SpecPath(string packageName, string assetName)
            : base(packageName + "/" + assetName)
        {
            _parts = new List<string>{
                packageName
            };

            _parts.AddRange(assetName.Split('/'));
        }
Esempio n. 4
1
        /// <summary>
        /// Adds additional assemblies to the ones already collected.
        /// </summary>
        /// <param name="assemblies">The collected assemblies.</param>
        /// <param name="assemblyFilter">A filter for the assemblies.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// A Task.
        /// </returns>
        protected override Task AddAdditionalAssembliesAsync(IList<Assembly> assemblies, Func<AssemblyName, bool> assemblyFilter, CancellationToken cancellationToken)
        {
            // load all the assemblies found in the application directory which are not already loaded.
            var directory = this.GetAppLocation();
            var loadedAssemblyFiles = assemblies.Select(this.GetFileName).Select(f => f.ToLowerInvariant());
            var assemblyFiles = Directory.EnumerateFiles(directory, "*.dll", SearchOption.TopDirectoryOnly).Select(Path.GetFileName);
            var assemblyFilesToLoad = assemblyFiles.Where(f => !loadedAssemblyFiles.Contains(f.ToLowerInvariant()));
            assemblies.AddRange(assemblyFilesToLoad.Select(f => Assembly.LoadFile(Path.Combine(directory, f))).Where(a => assemblyFilter(a.GetName())));

            return Task.FromResult((IEnumerable<Assembly>)assemblies);
        }
 private static void ReplaceAnonymousType(
     IList<SymbolDisplayPart> list,
     INamedTypeSymbol anonymousType,
     IEnumerable<SymbolDisplayPart> parts)
 {
     var index = list.IndexOf(p => anonymousType.Equals(p.Symbol));
     if (index >= 0)
     {
         var result = list.Take(index).Concat(parts).Concat(list.Skip(index + 1)).ToList();
         list.Clear();
         list.AddRange(result);
     }
 }
        private void DisplayAssemblyList(IList<string> assemblyList)
        {
            assemblyExplorerManager.ResetVisibleAssemblies();

            if (assemblyList.Count == 0)
                assemblyList.AddRange(GetVisibleAssemblyList());
            else
            {
                ClearVisibleAssemblies();

                var paths = from path in assemblyList
                            select new FileSystemPath(path);

                assemblyExplorerManager.AddUserVisibleAssembly(paths.ToArray());
            }
        }
Esempio n. 7
1
            public MethodCallObjects(Type concreteType, MethodInfo method)
            {
                ParameterExpression objectParameter = Expression.Parameter(concreteType, "x");

                Parameters = method.GetParameters().Select(x => toInput(x)).ToList();
                MethodCall = Expression.Call(objectParameter, method, Parameters.ToArray());

                Parameters.Insert(0, objectParameter);

                _parameterTypes = new List<Type>();
                _parameterTypes.Add(concreteType);
                _parameterTypes.AddRange(method.GetParameters().Select(x => x.ParameterType));

                _parameterTypes.Add(method.ReturnType);

                _parameterTypes.Remove(typeof (void));
            }
Esempio n. 8
1
        private void ProcessRange(IList<IElement> elements, int startIndex, IList<IElement> results, IDictionary<IElement, IElement> original)
        {
            for (var i = startIndex; i < elements.Count; i++) {
                var element = elements[i];
                if (!BranchProcessing.Matches(element, opCodes.Contains)) {
                    results.Add(element);
                    original[element] = element;
                    continue;
                }

                var targetIndexOrNull = BranchProcessing.FindTargetIndexOrNull(element, elements);
                if (targetIndexOrNull == null)
                    BranchProcessing.ThrowTargetNotFound(element);

                var targetIndex = targetIndexOrNull.Value;
                BranchProcessing.EnsureNotBackward(i, targetIndex);

                var targetRange = new List<IElement>();
                this.ProcessRange(elements, targetIndex, targetRange, original);

                var followingRange = new List<IElement>();
                this.ProcessRange(elements, i + 1, followingRange, original);

                var convergingRange = new List<IElement>();
                while (targetRange.Count > 0 && followingRange.Count > 0) {
                    var lastTarget = targetRange.Last();
                    var lastFollowing = followingRange.Last();
                    if (original[lastTarget] != original[lastFollowing])
                        break;

                    convergingRange.Add(lastFollowing);
                    targetRange.RemoveAt(targetRange.Count - 1);
                    followingRange.RemoveAt(followingRange.Count - 1);
                }
                convergingRange.Reverse();

                if (targetRange.Count > 0 || followingRange.Count > 0) {
                    var branching = new BranchingElement(((InstructionElement)element).OpCode, targetRange, followingRange);
                    original[branching] = element;
                    results.Add(branching);
                }

                results.AddRange(convergingRange);
                break;
            }
        }
Esempio n. 9
1
        public bool Build(IList<string> warnings, IList<string> errors)
        {
            var builder = _applicationHostContext.CreateInstance<ProjectBuilder>();

            var result = builder.Build(_project.Name, _outputPath);

            if (result.Errors != null)
            {
                errors.AddRange(result.Errors);
            }

            if (result.Warnings != null)
            {
                warnings.AddRange(result.Warnings);
            }

            return result.Success && errors.Count == 0;
        }
		public void WriteMagicalBonuses(IList<string> output, InventoryItem item, GameClient client, bool shortInfo)
		{
			int oldCount = output.Count;

			WriteBonusLine(output, client, item.Bonus1Type, item.Bonus1);
            WriteBonusLine(output, client, item.Bonus2Type, item.Bonus2);
            WriteBonusLine(output, client, item.Bonus3Type, item.Bonus3);
            WriteBonusLine(output, client, item.Bonus4Type, item.Bonus4);
            WriteBonusLine(output, client, item.Bonus5Type, item.Bonus5);
            WriteBonusLine(output, client, item.Bonus6Type, item.Bonus6);
            WriteBonusLine(output, client, item.Bonus7Type, item.Bonus7);
            WriteBonusLine(output, client, item.Bonus8Type, item.Bonus8);
            WriteBonusLine(output, client, item.Bonus9Type, item.Bonus9);
            WriteBonusLine(output, client, item.Bonus10Type, item.Bonus10);
            WriteBonusLine(output, client, item.ExtraBonusType, item.ExtraBonus);

			if (output.Count > oldCount)
			{
				output.Add(" ");
				output.Insert(oldCount, LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MagicBonus"));
				output.Insert(oldCount, " ");
			}

			oldCount = output.Count;

			WriteFocusLine(output, item.Bonus1Type, item.Bonus1);
			WriteFocusLine(output, item.Bonus2Type, item.Bonus2);
			WriteFocusLine(output, item.Bonus3Type, item.Bonus3);
			WriteFocusLine(output, item.Bonus4Type, item.Bonus4);
			WriteFocusLine(output, item.Bonus5Type, item.Bonus5);
			WriteFocusLine(output, item.Bonus6Type, item.Bonus6);
			WriteFocusLine(output, item.Bonus7Type, item.Bonus7);
			WriteFocusLine(output, item.Bonus8Type, item.Bonus8);
			WriteFocusLine(output, item.Bonus9Type, item.Bonus9);
			WriteFocusLine(output, item.Bonus10Type, item.Bonus10);
			WriteFocusLine(output, item.ExtraBonusType, item.ExtraBonus);

			if (output.Count > oldCount)
			{
				output.Add(" ");
				output.Insert(oldCount, LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.FocusBonus"));
				output.Insert(oldCount, " ");
			}

			if (!shortInfo)
			{
				if (item.ProcSpellID != 0 || item.ProcSpellID1 != 0 || item.SpellID != 0 || item.SpellID1 != 0)
				{
					int requiredLevel = item.LevelRequirement > 0 ? item.LevelRequirement : Math.Min(50, item.Level);
					output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.LevelRequired2", requiredLevel));
					output.Add(" ");
				}

				if (item.Object_Type == (int)eObjectType.Magical && item.Item_Type == (int)eInventorySlot.FirstBackpack) // potion
				{
					// let WritePotion handle the rest of the display
					return;
				}


				#region Proc1
				if (item.ProcSpellID != 0)
				{
					string spellNote = "";
					output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MagicAbility"));
					if (GlobalConstants.IsWeapon(item.Object_Type))
					{
						spellNote = LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.StrikeEnemy");
					}
					else if (GlobalConstants.IsArmor(item.Object_Type))
					{
						spellNote = LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.StrikeArmor");
					}

					SpellLine line = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);
					if (line != null)
					{
						Spell procSpell = SkillBase.FindSpell(item.ProcSpellID, line);

						if (procSpell != null)
						{
							ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, procSpell, line);
							if (spellHandler != null)
							{
								output.AddRange(spellHandler.DelveInfo);
								output.Add(" ");
							}
							else
							{
								output.Add("-" + procSpell.Name + " (Spell Handler Not Implemented)");
							}

							output.Add(spellNote);
						}
						else
						{
							output.Add("- Spell Not Found: " + item.ProcSpellID);
						}
					}
					else
					{
						output.Add("- Item_Effects Spell Line Missing");
					}

					output.Add(" ");
				}
				#endregion
				#region Proc2
				if (item.ProcSpellID1 != 0)
				{
					string spellNote = "";
					output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MagicAbility"));
					if (GlobalConstants.IsWeapon(item.Object_Type))
					{
						spellNote = LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.StrikeEnemy");
					}
					else if (GlobalConstants.IsArmor(item.Object_Type))
					{
						spellNote = LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.StrikeArmor");
					}

					SpellLine line = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);
					if (line != null)
					{
						Spell procSpell = SkillBase.FindSpell(item.ProcSpellID1, line);

						if (procSpell != null)
						{
							ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, procSpell, line);
							if (spellHandler != null)
							{
								output.AddRange(spellHandler.DelveInfo);
								output.Add(" ");
							}
							else
							{
								output.Add("-" + procSpell.Name + " (Spell Handler Not Implemented)");
							}

							output.Add(spellNote);
						}
						else
						{
							output.Add("- Spell Not Found: " + item.ProcSpellID1);
						}
					}
					else
					{
						output.Add("- Item_Effects Spell Line Missing");
					}

					output.Add(" ");
				}
				#endregion
				#region Charge1
				if (item.SpellID != 0)
				{
					SpellLine chargeEffectsLine = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);
					if (chargeEffectsLine != null)
					{
						Spell spell = SkillBase.FindSpell(item.SpellID, chargeEffectsLine);
						if (spell != null)
						{
							ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, spell, chargeEffectsLine);

							if (spellHandler != null)
							{
								if (item.MaxCharges > 0)
								{
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.ChargedMagic"));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.Charges", item.Charges));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MaxCharges", item.MaxCharges));
									output.Add(" ");
								}

								output.AddRange(spellHandler.DelveInfo);
								output.Add(" ");
								output.Add("- This spell is cast when the item is used.");
							}
							else
							{
								output.Add("- Item_Effects Spell Line Missing");
							}
						}
						else
						{
							output.Add("- Spell Not Found: " + item.SpellID);
						}
					}

					output.Add(" ");
				}
				#endregion
				#region Charge2
				if (item.SpellID1 != 0)
				{
					SpellLine chargeEffectsLine = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);
					if (chargeEffectsLine != null)
					{
						Spell spell = SkillBase.FindSpell(item.SpellID1, chargeEffectsLine);
						if (spell != null)
						{
							ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, spell, chargeEffectsLine);

							if (spellHandler != null)
							{
								if (item.MaxCharges > 0)
								{
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.ChargedMagic"));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.Charges", item.Charges));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MaxCharges", item.MaxCharges));
									output.Add(" ");
								}

								output.AddRange(spellHandler.DelveInfo);
								output.Add(" ");
								output.Add("- This spell is cast when the item is used.");
							}
							else
							{
								output.Add("- Item_Effects Spell Line Missing");
							}
						}
						else
						{
							output.Add("- Spell Not Found: " + item.SpellID1);
						}
					}

					output.Add(" ");
				}
				#endregion
				#region Poison
				if (item.PoisonSpellID != 0)
				{
					if (GlobalConstants.IsWeapon(item.Object_Type))// Poisoned Weapon
					{
						SpellLine poisonLine = SkillBase.GetSpellLine(GlobalSpellsLines.Mundane_Poisons);
						if (poisonLine != null)
						{
							List<Spell> spells = SkillBase.GetSpellList(poisonLine.KeyName);
							foreach (Spell spl in spells)
							{
								if (spl.ID == item.PoisonSpellID)
								{
									output.Add(" ");
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.LevelRequired"));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.Level", spl.Level));
									output.Add(" ");
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.ChargedMagic"));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.Charges", item.PoisonCharges));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MaxCharges", item.PoisonMaxCharges));
									output.Add(" ");

									ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, spl, poisonLine);
									if (spellHandler != null)
									{
										output.AddRange(spellHandler.DelveInfo);
										output.Add(" ");
									}
									else
									{
										output.Add("-" + spl.Name + "(Not implemented yet)");
									}
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.StrikeEnemy"));
									return;
								}
							}
						}
					}

					SpellLine chargeEffectsLine = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);
					if (chargeEffectsLine != null)
					{
						List<Spell> spells = SkillBase.GetSpellList(chargeEffectsLine.KeyName);
						foreach (Spell spl in spells)
						{
							if (spl.ID == item.SpellID)
							{
								output.Add(" ");
								output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.LevelRequired"));
								output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.Level", spl.Level));
								output.Add(" ");
								if (item.MaxCharges > 0)
								{
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.ChargedMagic"));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.Charges", item.Charges));
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MaxCharges", item.MaxCharges));
								}
								else
								{
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.MagicAbility"));
								}
								output.Add(" ");

								ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, spl, chargeEffectsLine);
								if (spellHandler != null)
								{
									output.AddRange(spellHandler.DelveInfo);
									output.Add(" ");
								}
								else
								{
									output.Add("-" + spl.Name + "(Not implemented yet)");
								}
								output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.UsedItem"));
								output.Add(" ");
								if (spl.RecastDelay > 0)
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.UseItem1", Util.FormatTime(spl.RecastDelay / 1000)));
								else
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.UseItem2"));
								long lastChargedItemUseTick = client.Player.TempProperties.getProperty<long>(GamePlayer.LAST_CHARGED_ITEM_USE_TICK);
								long changeTime = client.Player.CurrentRegion.Time - lastChargedItemUseTick;
								long recastDelay = (spl.RecastDelay > 0) ? spl.RecastDelay : 60000 * 3;
								if (changeTime < recastDelay) //3 minutes reuse timer
									output.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WriteMagicalBonuses.UseItem3", Util.FormatTime((recastDelay - changeTime) / 1000)));
								return;
							}
						}
					}
				}
				#endregion
			}
		}
        /// <summary>
        /// Add an item set to the IList, but only if those items don't already exist. If the IList is longer than max, cull out the first values to make the list length equal to max.
        /// </summary>
        /// <param name="items">Item set being added.</param>
        /// <param name="max">List maximum length.</param>
        public static void AddRangeOnceClamp <I>(this IList <I> target, IEnumerable <I> items, int max)
        {
            int      delete = 0;
            List <I> toAdd  = new List <I>();

            foreach (I i in items)
            {
                if (!target.Contains(i))
                {
                    delete++;
                    toAdd.Add(i);
                }
            }

            if (target.Count >= max)
            {
                int difference = target.Count - max + delete;
                target.RemoveRange(0, difference);
            }

            target.AddRange(toAdd);
        }
Esempio n. 12
0
        private bool HandleForStatement(JsForStatement stmt, StackEntry location, ImmutableStack <StackEntry> stack, ImmutableStack <Tuple <string, State> > breakStack, ImmutableStack <Tuple <string, State> > continueStack, State currentState, State returnState, IList <JsStatement> currentBlock, bool isFirstStatement)
        {
            if (!(isFirstStatement && (stmt.InitStatement is JsEmptyStatement || location.AfterForInitializer)))
            {
                // We have to create a new block for the statement.
                var topOfLoopState = CreateNewStateValue(currentState.FinallyStack);
                Enqueue(stack.Push(new StackEntry(location.Block, location.Index, true)), breakStack, continueStack, topOfLoopState, returnState);
                if (!(stmt.InitStatement is JsEmptyStatement))
                {
                    currentBlock.Add(stmt.InitStatement);
                }
                currentBlock.Add(new JsGotoStateStatement(topOfLoopState, currentState));
                return(false);
            }
            else
            {
                var iteratorState  = (stmt.IteratorExpression != null ? CreateNewStateValue(currentState.FinallyStack) : currentState);
                var afterLoopState = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);

                if (stmt.ConditionExpression != null)
                {
                    currentBlock.Add(new JsIfStatement(JsExpression.LogicalNot(stmt.ConditionExpression), new JsGotoStateStatement(afterLoopState.Item1, currentState), null));
                }
                string currentName = GetLabelForState(currentState);
                currentBlock.AddRange(Handle(ImmutableStack <StackEntry> .Empty.Push(new StackEntry(stmt.Body, 0)), breakStack.Push(Tuple.Create(currentName, afterLoopState.Item1)), continueStack.Push(Tuple.Create(currentName, iteratorState)), currentState, iteratorState, false, false));

                if (stmt.IteratorExpression != null)
                {
                    Enqueue(ImmutableStack <StackEntry> .Empty.Push(new StackEntry(JsBlockStatement.MakeBlock(new JsExpressionStatement(stmt.IteratorExpression)), 0)), breakStack, continueStack, iteratorState, currentState);
                }

                if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1)
                {
                    Enqueue(PushFollowing(stack, location), breakStack, continueStack, afterLoopState.Item1, returnState);
                }

                return(false);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Find the stem(s) of the provided word
        /// </summary>
        /// <param name="word"> Word to find the stems for </param>
        /// <param name="length"> length </param>
        /// <returns> <see cref="IList{CharsRef}"/> of stems for the word </returns>
        public IList <CharsRef> Stem(char[] word, int length)
        {
            if (dictionary.needsInputCleaning)
            {
                scratchSegment.Length = 0;
                scratchSegment.Append(word, 0, length);
                string cleaned = dictionary.CleanInput(scratchSegment.ToString(), segment);
                scratchBuffer = ArrayUtil.Grow(scratchBuffer, cleaned.Length);
                length        = segment.Length;
                segment.CopyTo(0, scratchBuffer, 0, length);
                word = scratchBuffer;
            }

            int caseType = CaseOf(word, length);

            if (caseType == UPPER_CASE)
            {
                // upper: union exact, title, lower
                CaseFoldTitle(word, length);
                CaseFoldLower(titleBuffer, length);
                IList <CharsRef> list = DoStem(word, length, false);
                list.AddRange(DoStem(titleBuffer, length, true));
                list.AddRange(DoStem(lowerBuffer, length, true));
                return(list);
            }
            else if (caseType == TITLE_CASE)
            {
                // title: union exact, lower
                CaseFoldLower(word, length);
                IList <CharsRef> list = DoStem(word, length, false);
                list.AddRange(DoStem(lowerBuffer, length, true));
                return(list);
            }
            else
            {
                // exact match only
                return(DoStem(word, length, false));
            }
        }
Esempio n. 14
0
        /// <summary>
        /// The entry method into the bottles environment
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="runActivators"></param>
        public static void LoadPackages(Action <IPackageFacility> configuration, bool runActivators = true)
        //consider renaming to InitializeEnvironment
        //have it return an environment object.
        {
            _packages.Clear();

            Diagnostics = new PackagingDiagnostics();
            var record = new PackageLoadingRecord();

            Diagnostics.LogExecution(record, () =>
            {
                var facility       = new PackageFacility();
                var assemblyLoader = new AssemblyLoader(Diagnostics);
                var graph          = new PackagingRuntimeGraph(Diagnostics, assemblyLoader, _packages);

                var codeLocation = findCallToLoadPackages();
                graph.InProvenance(codeLocation, g =>
                {
                    //collect user configuration
                    configuration(facility);

                    //applies collected configurations
                    facility.Configure(g);
                });


                graph.DiscoverAndLoadPackages(() =>
                {
                    //clearing assemblies why? - my guess is testing.
                    // this should only really be called once.
                    _assemblies.Clear();

                    _assemblies.AddRange(assemblyLoader.Assemblies);
                    //the above assemblies are used when we need to resolve bottle assemblies
                }, runActivators);
            });

            record.Finished = DateTime.Now;
        }
Esempio n. 15
0
        public virtual bool ValidateBundleItems(IEnumerable <ProductBundleItem> bundleItems, IList <string> warnings)
        {
            Guard.NotNull(bundleItems, nameof(bundleItems));
            Guard.NotNull(warnings, nameof(warnings));

            var currentWarnings = new List <string>();

            foreach (var bundleItem in bundleItems)
            {
                var name = bundleItem.GetLocalizedName();

                if (!bundleItem.Published)
                {
                    currentWarnings.Add(T("ShoppingCart.Bundle.BundleItemUnpublished", name));
                }

                if (bundleItem.ProductId == 0 ||
                    bundleItem.Product == null ||
                    bundleItem.BundleProductId == 0 ||
                    bundleItem.BundleProduct == null)
                {
                    currentWarnings.Add(T("ShoppingCart.Bundle.MissingProduct", name));
                }

                if (bundleItem.Quantity <= 0)
                {
                    currentWarnings.Add(T("ShoppingCart.Bundle.Quantity", name));
                }

                if (bundleItem.Product.IsDownload || bundleItem.Product.IsRecurring)
                {
                    currentWarnings.Add(T("ShoppingCart.Bundle.ProductResrictions", name));
                }
            }

            warnings.AddRange(currentWarnings);
            return(!currentWarnings.Any());
        }
Esempio n. 16
0
        public async Task Run()
        {
            var nickName = configuration["NickName"];
            var userName = configuration["UserName"];
            var realName = configuration["RealName"];
            var channels = configuration["Channels"].Split(',').Select(x => x.Trim()).ToList();

            ircLayer = new IrcLayer(configuration);

            var server = configuration["Server"];

            if (string.IsNullOrWhiteSpace(server))
            {
                throw new Exception("No server given");
            }

            var hasPort = int.TryParse(configuration["Port"], out var port);

            bool.TryParse(configuration["UseSsl"], out var useSsl);

            if (!hasPort)
            {
                port = useSsl ? 6697 : 6667;
            }

            nexmo = new NexmoClient(configuration);
            noticeActions.AddRange(NoticeAction.GetAll(ircLayer, nexmo, configuration));
            channelActions.AddRange(ChannelAction.GetAll(ircLayer, nexmo, configuration));
            channelCommands.AddRange(Command.GetAll(ircLayer, nexmo, configuration));

            ircLayer.OnMessageReceived += IrcLayerOnOnMessageReceived;
            ircLayer.OnNoticeReceived  += IrcLayerOnOnNoticeReceived;
            ircLayer.OnQueryReceived   += IrcLayerOnOnQueryReceived;
            ircLayer.Disconnected      += IrcLayerDisconnected;
            await ircLayer.Connect(server, port, useSsl, nickName, userName, realName, channels);

            IsConnected = true;
        }
        void PopulateMediaTypeFormatters(
            HttpActionDescriptor actionDescriptor,
            IReadOnlyList <ApiParameterDescription> parameterDescriptions,
            IHttpRoute route,
            Type responseType,
            IList <MediaTypeFormatter> requestFormatters,
            IList <MediaTypeFormatter> responseFormatters)
        {
            Contract.Requires(actionDescriptor != null);
            Contract.Requires(parameterDescriptions != null);
            Contract.Requires(route != null);
            Contract.Requires(requestFormatters != null);
            Contract.Requires(responseFormatters != null);

            if (route is ODataRoute)
            {
                foreach (var formatter in actionDescriptor.Configuration.Formatters.OfType <ODataMediaTypeFormatter>())
                {
                    requestFormatters.Add(formatter);
                    responseFormatters.Add(formatter);
                }

                return;
            }

            var bodyParameter = parameterDescriptions.FirstOrDefault(p => p.Source == FromBody);

            if (bodyParameter != null)
            {
                var paramType = bodyParameter.ParameterDescriptor.ParameterType;
                requestFormatters.AddRange(GetInnerFormatters(actionDescriptor.Configuration.Formatters.Where(f => f.CanReadType(paramType))));
            }

            if (responseType != null)
            {
                responseFormatters.AddRange(GetInnerFormatters(actionDescriptor.Configuration.Formatters.Where(f => f.CanWriteType(responseType))));
            }
        }
Esempio n. 18
0
        /// <summary>
        ///     Updates the current <see cref="IGridViewModel{T}.ItemsSource" />.
        /// </summary>
        /// <param name="value">The new items source value.</param>
        protected virtual void UpdateItemsSourceInternal(IEnumerable <T> value)
        {
            value        = OnItemsSourceChanging(value);
            SelectedItem = null;

            if (value == null)
            {
                _originalData.Clear();
            }
            else
            {
                using (FilterableItemsSource.SuspendNotifications())
                {
                    _originalData.Clear();
                    _originalData.AddRange(value);
                }
            }
            UpdateFilter();
            OnItemsSourceChanged(value);
            RaiseItemsSourceChanged(value);
            OnPropertyChanged("ItemsSource");
            OnPropertyChanged("OriginalItemsSource");
        }
Esempio n. 19
0
        /// <summary>
        /// 使用指定的比较器将 <see cref="IList{T}"/> 中的元素按指定键进行排序。
        /// </summary>
        /// <typeparam name="T"><see cref="IList{T}"/> 中的元素的类型。</typeparam>
        /// <typeparam name="TKey">作为排序基准的属性的类型。</typeparam>
        /// <param name="list">要进行排序的 <see cref="IList{T}"/> 对象。</param>
        /// <param name="keySelector">用于从元素中提取键的函数。</param>
        /// <param name="comparer">用于比较排序的 <see cref="IComparer{T}"/> 对象。</param>
        /// <exception cref="ArgumentNullException">
        /// 存在为 <see langword="null"/> 的参数。</exception>
        public static void Sort <T, TKey>(this IList <T> list,
                                          Converter <T, TKey> keySelector, IComparer <TKey>?comparer = null)
        {
            if (list is null)
            {
                throw new ArgumentNullException(nameof(list));
            }
            if (keySelector is null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            comparer ??= Comparer <TKey> .Default;

            var items = new T[list.Count];

            list.CopyTo(items, 0);
            var keys = Array.ConvertAll(items, keySelector);

            Array.Sort(keys, items, comparer);
            list.Clear();
            list.AddRange(items);
        }
Esempio n. 20
0
        public static void LoadPackages(Action <IPackageFacility> configuration)
        {
            _packages.Clear();

            var facility = new PackageFacility();

            Diagnostics = new PackagingDiagnostics();
            var assemblyLoader = new AssemblyLoader(Diagnostics);
            var graph          = new PackagingRuntimeGraph(Diagnostics, assemblyLoader, _packages);

            var codeLocation = findCallToLoadPackages();

            graph.PushProvenance(codeLocation);
            configuration(facility);
            facility.As <IPackagingRuntimeGraphConfigurer>().Configure(graph);

            graph.PopProvenance();
            graph.DiscoverAndLoadPackages(() =>
            {
                _assemblies.Clear();
                _assemblies.AddRange(assemblyLoader.Assemblies);
            });
        }
 public override void PersistNewObjects()
 {
     lock (_lock)
     {
         _nations.AddRange(_newNations);
         _branches.AddRange(_newBranches);
         _vehicles.AddRange(_newVehicles);
         _vehicleSubclasses.AddRange(_newVehicleSubclasses);
         _aircraftTags.AddRange(_newAircraftTags);
         _groundVehicleTags.AddRange(_newGroundVehicleTags);
         _vehicleResearchTreeData.AddRange(_newVehicleResearchTreeData);
         _vehicleEconomyData.AddRange(_newVehicleEconomyData);
         _vehiclePerformanceData.AddRange(_newVehiclePerformanceData);
         _vehicleCrewData.AddRange(_newVehicleCrewData);
         _vehicleWeaponsData.AddRange(_newVehicleWeaponsData);
         _vehicleModificationsData.AddRange(_newVehicleModificationsData);
         _vehicleGraphicsData.AddRange(_newVehicleGraphicsData);
         _vehicleGameModeParameterSets.AddRange(_newVehicleGameModeParameterSets);
         _localizationRecords.AddRange(_newLocalizationRecords);
         _vehicleImages.AddRange(_newVehicleImages);
     }
     ClearNewObjects();
 }
Esempio n. 22
0
        public static T[] UpdateOrAdd <T>(this IList <T> list, IEnumerable <T> items, bool reverse = false,
                                          string[] extraExclusions = null)
            where T : class, IComparePK <T>
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            T[] existingItems;
            T[] newItems;
            var itemsArray = items.ToArray();

            lock (list) {
                var array = list.ToArray();
                existingItems = itemsArray.Select(x => array.FirstOrDefault(x.ComparePK))
                                .Where(x => x != null)
                                .ToArray();

                newItems = itemsArray.Where(x => existingItems.None(x.ComparePK))
                           .ToArray();

                list.AddRange(newItems, reverse);
            }

            foreach (var i in existingItems)
            {
                var item = itemsArray.First(y => y.ComparePK(i));
                item.CopyProperties(i, extraExclusions);
            }

            return(newItems);
        }
Esempio n. 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="statementsDest"></param>
        /// <param name="statementsSource"></param>
        /// <param name="containers">Outermost container is first.  The bodies of the containers are ignored.</param>
        internal static void AddStatementWithContainers(IList <IStatement> statementsDest, IList <IStatement> statementsSource, ICollection <IStatement> containers)
        {
            if (statementsSource.Count == 0)
            {
                return;
            }
            if (containers.Count == 0)
            {
                statementsDest.AddRange(statementsSource);
                return;
            }
            IStatement        outermostContainer = null;
            IStatement        parent             = null;
            List <IStatement> loopBreakers       = new List <IStatement>();

            foreach (IStatement container in containers)
            {
                IStatement child = CreateContainer(container);
                if (parent != null)
                {
                    AddToContainer(parent, child);
                }
                else
                {
                    outermostContainer = child;
                }
                parent = child;
                if (child is IBrokenForStatement)
                {
                    IBrokenForStatement ifs = (IBrokenForStatement)child;
                    loopBreakers.Add(Recognizer.LoopBreakStatement(ifs));
                }
            }
            AddToContainer(parent, statementsSource);
            AddToContainer(parent, loopBreakers);
            statementsDest.Add(outermostContainer);
        }
Esempio n. 24
0
        protected override void Source_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Target == null || Creator == null)
            {
                return;
            }

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                var ToInsert = e.NewItems.OfType <S>().Select(x => Creator(x));
                if (e.NewStartingIndex >= 0)
                {
                    Target.InsertRange(e.NewStartingIndex, ToInsert);
                }
                else
                {
                    Target.AddRange(ToInsert);
                }
                break;

            case NotifyCollectionChangedAction.Move:
            case NotifyCollectionChangedAction.Replace:
                Source_CollectionChanged(sender, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, e.OldItems));
                Source_CollectionChanged(sender, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, e.NewItems, e.NewStartingIndex));
                break;

            case NotifyCollectionChangedAction.Remove:
                var ToRemove = Target.OfType <U>().Where(u => e.OldItems.Contains(Query(u)));
                Target.RemoveRange(ToRemove);
                break;

            case NotifyCollectionChangedAction.Reset:
                Target.Clear();
                break;
            }
        }
Esempio n. 25
0
        public static void SyncCollectionOfType <T, T2>(this IEnumerable <T> source, IList <T2> destination,
                                                        Func <T, bool> filter = null) where T : T2
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            var src = source;

            if (filter != null)
            {
                src = src.Where(filter);
            }

            var srcAr = src.Cast <T2>().ToArray();

            destination.RemoveAll(destination.Where(x => x is T).Except(srcAr).ToArray());
            destination.AddRange(srcAr.Except(destination).ToArray());
        }
Esempio n. 26
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="icaos"></param>
        /// <param name="fetchedAircraft"></param>
        /// <param name="missingIcaos"></param>
        /// <returns></returns>
        public bool DoLookup(string[] icaos, IList <AircraftOnlineLookupDetail> fetchedAircraft, IList <string> missingIcaos)
        {
            FetchSettings();

            var formContent = String.Format("icaos={0}", HttpUtility.UrlEncode(String.Join("-", icaos)));
            var formBytes   = Encoding.UTF8.GetBytes(formContent);

            var request = (HttpWebRequest)HttpWebRequest.Create(_ServerSettings.LookupByIcaoUrl);

            request.Method = "POST";
            request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
            request.ContentType            = "application/x-www-form-urlencoded";
            request.ContentLength          = formBytes.Length;
            using (var bodyStream = request.GetRequestStream()) {
                bodyStream.Write(formBytes, 0, formBytes.Length);
            }

            string jsonText = null;

            using (var response = request.GetResponse()) {
                using (var streamReader = new StreamReader(response.GetResponseStream())) {
                    jsonText = streamReader.ReadToEnd();
                }
            }

            var result = !String.IsNullOrEmpty(jsonText);

            if (result)
            {
                var aircraftDetails = JsonConvert.DeserializeObject <AircraftOnlineLookupDetail[]>(jsonText);
                fetchedAircraft.AddRange(aircraftDetails);
                missingIcaos.AddRange(icaos.Select(r => r.ToUpper()).Except(aircraftDetails.Select(r => r.Icao.ToUpper())));
            }

            return(result);
        }
Esempio n. 27
0
        private static void GetChildPrivateFields(
            IList <MemberInfo> initialFields,
            Type targetType,
            BindingFlags bindingAttr
            )
        {
            // fix weirdness with private FieldInfos only being returned for the current Type
            // find base type fields and add them to result
            if ((bindingAttr & BindingFlags.NonPublic) != 0)
            {
                // modify flags to not search for public fields
                BindingFlags nonPublicBindingAttr = bindingAttr.RemoveFlag(BindingFlags.Public);

                while ((targetType = targetType.BaseType()) != null)
                {
                    // filter out protected fields
                    IEnumerable <FieldInfo> childPrivateFields = targetType
                                                                 .GetFields(nonPublicBindingAttr)
                                                                 .Where(f => f.IsPrivate);

                    initialFields.AddRange(childPrivateFields);
                }
            }
        }
Esempio n. 28
0
        public void Populate(FrameworkName frameworkName, IList <LibraryDescription> libraries)
        {
            var sw = Stopwatch.StartNew();

            foreach (var groupByResolver in _usedItems.GroupBy(x => x.Value.Resolver))
            {
                var resolver = groupByResolver.Key;

                var resolverLibraries = new List <LibraryDescription>();
                foreach (var entry in groupByResolver)
                {
                    var library = entry.Value.Description;
                    library.Dependencies = library.Dependencies.SelectMany(CorrectDependencyVersion).ToList();
                    library.Framework    = library.Framework ?? frameworkName;
                    resolverLibraries.Add(library);
                }

                resolver.Initialize(resolverLibraries, frameworkName, runtimeIdentifier: null);
                libraries.AddRange(resolverLibraries);
            }

            sw.Stop();
            Logger.TraceInformation("[{0}]: Populate took {1}ms", GetType().Name, sw.ElapsedMilliseconds);
        }
Esempio n. 29
0
        public static IList <ProjectListViewModel> MapFrom(this IList <ProjectListViewModel> model, IList <Project> entity)
        {
            if (entity == null || model == null)
            {
                return(model);
            }
            model.AddRange(
                entity.Select(o => new { o, dmp = o.DataManagementPlan ?? new DataManagementPlan(), dd = o.DataDeposit ?? new DataDeposit() }).
                Select(@t => new ProjectListViewModel
            {
                ProjectId          = t.o.Id,
                ProjectTitle       = t.o.Title,
                ProjectType        = t.o.SourceProjectType,
                ProjectStatus      = t.o.Status.GetDescription(),
                DmpCreationDate    = t.dmp.Id > 0 ? t.dmp.CreationDate.ToShortDateString() : "",
                ProvisioningStatus = t.o.ProvisioningStatus,
                SiteUrl            = t.o.SiteUrl,
                DmpId              = t.dmp.Id,
                DataDepositId      = t.dd.Id,
                HasFirstCollection = t.o.DataCollections != null && t.o.DataCollections.SingleOrDefault(z => z.IsFirstCollection) != null
            }));

            return(model);
        }
Esempio n. 30
0
        /// <summary>
        /// Add Contentful system properties to document metadata.
        /// </summary>
        private static void AddSystemProperties(object item, IEnumerable <PropertyInfo> props, IList <KeyValuePair <string, object> > metadata)
        {
            var sysProp = props.FirstOrDefault(prop => typeof(SystemProperties).IsAssignableFrom(prop.PropertyType))?.GetValue(item);

            if (sysProp is SystemProperties systemProp)
            {
                metadata.AddRange(new[]
                {
                    new KeyValuePair <string, object>(ContentfulKeys.System.Environment, systemProp.Environment),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Status, systemProp.Status),
                    new KeyValuePair <string, object>(ContentfulKeys.System.ArchivedBy, systemProp.ArchivedBy),
                    new KeyValuePair <string, object>(ContentfulKeys.System.ArchivedVersion, systemProp.ArchivedVersion),
                    new KeyValuePair <string, object>(ContentfulKeys.System.ArchivedAt, systemProp.ArchivedAt),
                    new KeyValuePair <string, object>(ContentfulKeys.System.FirstPublishedAt, systemProp.FirstPublishedAt),
                    new KeyValuePair <string, object>(ContentfulKeys.System.PublishCounter, systemProp.PublishCounter),
                    new KeyValuePair <string, object>(ContentfulKeys.System.PublishedBy, systemProp.PublishedBy),
                    new KeyValuePair <string, object>(ContentfulKeys.System.PublishedVersion, systemProp.PublishedVersion),
                    new KeyValuePair <string, object>(ContentfulKeys.System.PublishedCounter, systemProp.PublishedCounter),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Space, systemProp.Space),
                    new KeyValuePair <string, object>(ContentfulKeys.System.ContentType, systemProp.ContentType),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Locale, systemProp.Locale),
                    new KeyValuePair <string, object>(ContentfulKeys.System.DeletedAt, systemProp.DeletedAt),
                    new KeyValuePair <string, object>(ContentfulKeys.System.UpdatedBy, systemProp.UpdatedBy),
                    new KeyValuePair <string, object>(ContentfulKeys.System.UpdatedAt, systemProp.UpdatedAt),
                    new KeyValuePair <string, object>(ContentfulKeys.System.CreatedBy, systemProp.CreatedBy),
                    new KeyValuePair <string, object>(ContentfulKeys.System.CreatedAt, systemProp.CreatedAt),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Version, systemProp.Version),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Revision, systemProp.Revision),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Type, systemProp.Type),
                    new KeyValuePair <string, object>(ContentfulKeys.System.LinkType, systemProp.LinkType),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Id, systemProp.Id),
                    new KeyValuePair <string, object>(ContentfulKeys.System.Organization, systemProp.Organization),
                    new KeyValuePair <string, object>(ContentfulKeys.System.UsagePeriod, systemProp.UsagePeriod),
                });
            }
        }
Esempio n. 31
0
        private static IList <NavBE> FilterDisallowedNavRecords(IList <NavBE> navPages, PageBE page)
        {
            Dictionary <ulong, NavBE> navLookup = new Dictionary <ulong, NavBE>();

            // NOTE (steveb): we collect the given page and its parent pages into a separate collection since these
            //                will need to be shown regardless in the nav pane.

            List <NavBE> parents = new List <NavBE>();

            foreach (NavBE nav in navPages)
            {
                navLookup.Add(nav.Id, nav);
            }
            ulong homepageId = DekiContext.Current.Instance.HomePageId;
            NavBE current;
            ulong id = page.ID;

            do
            {
                if (!navLookup.TryGetValue(id, out current))
                {
                    break;
                }
                parents.Add(current);
                navLookup.Remove(id);
                id = ((current.ParentId == 0) && current.Id != homepageId) ? homepageId : current.ParentId;
            } while(current.Id != homepageId);


            // filter non-parent pages from nav pane
            IList <NavBE> allowed = FilterDisallowedNavRecords(new List <NavBE>(navLookup.Values));

            // add parent page back
            allowed.AddRange(parents);
            return(allowed);
        }
Esempio n. 32
0
        public void Populate(FrameworkName frameworkName, IList <LibraryDescription> libraries)
        {
            foreach (var groupByResolver in _usedItems.GroupBy(x => x.Value.Resolver))
            {
                var resolver    = groupByResolver.Key;
                var packageKeys = groupByResolver.Select(x => x.Value.Key).ToList();

                Trace.TraceInformation("[{0}]: " + String.Join(", ", packageKeys), resolver.GetType().Name);

                var descriptions = groupByResolver.Select(entry =>
                {
                    return(new LibraryDescription
                    {
                        Identity = entry.Value.Key,
                        Dependencies = entry.Value.Dependencies.Where(p => _usedItems.ContainsKey(p.Name))
                                       .Select(p => _usedItems[p.Name].Key)
                                       .ToList()
                    });
                }).ToList();

                resolver.Initialize(descriptions, frameworkName);
                libraries.AddRange(descriptions);
            }
        }
Esempio n. 33
0
        // initialize the per-field DocValuesProducer
        private void InitDocValuesProducers(Codec codec)
        {
            Directory       dir      = core.cfsReader != null ? core.cfsReader : si.Info.Dir;
            DocValuesFormat dvFormat = codec.DocValuesFormat;
            IDictionary <long?, IList <FieldInfo> > genInfos = GetGenInfos();

            //      System.out.println("[" + Thread.currentThread().getName() + "] SR.initDocValuesProducers: segInfo=" + si + "; gens=" + genInfos.keySet());

            // TODO: can we avoid iterating over fieldinfos several times and creating maps of all this stuff if dv updates do not exist?

            foreach (KeyValuePair <long?, IList <FieldInfo> > e in genInfos)
            {
                long?gen = e.Key;
                IList <FieldInfo> infos = e.Value;
                DocValuesProducer dvp   = segDocValues.GetDocValuesProducer(gen, si, IOContext.READ, dir, dvFormat, infos, TermInfosIndexDivisor);
                foreach (FieldInfo fi in infos)
                {
                    dvProducersByField[fi.Name] = dvp;
                    dvProducers.Add(dvp);
                }
            }

            dvGens.AddRange(genInfos.Keys);
        }
		private bool HandleTryStatement(JsTryStatement stmt, StackEntry location, ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State currentState, State returnState, IList<JsStatement> currentBlock, bool isFirstStatement) {
			if (_isIteratorBlock && (FindInterestingConstructsVisitor.Analyze(stmt.GuardedStatement, InterestingConstruct.YieldReturn) || (stmt.Finally != null && stmt.Catch == null && !currentState.FinallyStack.IsEmpty))) {
				if (stmt.Catch != null)
					throw new InvalidOperationException("Cannot yield return from try with catch");
				string handlerName = _allocateFinallyHandler();
				JsBlockStatement handler;
				if (FindInterestingConstructsVisitor.Analyze(stmt.Finally, InterestingConstruct.Label)) {
					var inner = ProcessInner(stmt.Finally, breakStack, continueStack, currentState.FinallyStack, currentState.StateValue);
					handler = JsStatement.Block(new[]  { new JsSetNextStateStatement(inner.Item2) }.Concat(inner.Item1));
					handler = new FinalizerRewriter(_stateVariableName, _labelStates).Process(handler);
				}
				else {
					handler = stmt.Finally;
				}

				_finallyHandlers.Add(Tuple.Create(handlerName, handler));
				var stateAfter = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);
				var innerState = CreateNewStateValue(currentState.FinallyStack, handlerName);
				var stateBeforeFinally = CreateNewStateValue(innerState.FinallyStack);
				currentBlock.Add(new JsSetNextStateStatement(innerState.StateValue));
				currentBlock.AddRange(Handle(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(stmt.GuardedStatement, 0)), breakStack, continueStack, new State(currentState.LoopLabelName, currentState.StateValue, innerState.FinallyStack), stateBeforeFinally, false, false));

				Enqueue(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(JsStatement.Block(JsStatement.BlockMerged(new JsStatement[0])), 0)), breakStack, continueStack, stateBeforeFinally, stateAfter.Item1);
				if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1) {
					Enqueue(PushFollowing(stack, location), breakStack, continueStack, stateAfter.Item1, returnState);
				}
				return false;
			}
			else if (_isIteratorBlock && stmt.Finally != null && !currentState.FinallyStack.IsEmpty) {
				// This is necessary to special-case in order to ensure that the inner finally block is executed before all outer ones.
				return HandleTryStatement(JsStatement.Try(JsStatement.Try(stmt.GuardedStatement, stmt.Catch, null), null, stmt.Finally), location, stack, breakStack, continueStack, currentState, returnState, currentBlock, isFirstStatement);
			}
			else {
				var rewriter = new NestedStatementFixer(breakStack, continueStack, currentState, _exitState.Value, _makeSetResult);
				JsBlockStatement guarded;
				var guardedConstructs = FindInterestingConstructsVisitor.Analyze(stmt.GuardedStatement);
				if ((guardedConstructs & (InterestingConstruct.Label | InterestingConstruct.Await)) != InterestingConstruct.None) {
					if (!isFirstStatement) {
						var sv = CreateNewStateValue(currentState.FinallyStack);
						Enqueue(stack.Push(location), breakStack, continueStack, sv, returnState);
						currentBlock.Add(new JsGotoStateStatement(sv, currentState));
						return false;
					}

					var inner  = ProcessInner(stmt.GuardedStatement, breakStack, continueStack, currentState.FinallyStack, currentState.StateValue);
					guarded    = JsStatement.Block(inner.Item1);
					currentBlock.Add(new JsSetNextStateStatement(inner.Item2));
				}
				else {
					guarded = rewriter.Process(stmt.GuardedStatement);
				}

				JsCatchClause @catch;
				if (stmt.Catch != null) {
					if (FindInterestingConstructsVisitor.Analyze(stmt.Catch.Body, InterestingConstruct.Label)) {
						var inner = ProcessInner(stmt.Catch.Body, breakStack, continueStack, currentState.FinallyStack, null);
						@catch = JsStatement.Catch(stmt.Catch.Identifier, JsStatement.Block(new[] { new JsSetNextStateStatement(inner.Item2) }.Concat(inner.Item1)));
					}
					else {
						var body = rewriter.Process(stmt.Catch.Body);
						@catch = ReferenceEquals(body, stmt.Catch.Body) ? stmt.Catch : JsStatement.Catch(stmt.Catch.Identifier, body);
					}
				}
				else
					@catch = null;

				JsBlockStatement @finally;
				if (stmt.Finally != null) {
					if (FindInterestingConstructsVisitor.Analyze(stmt.Finally, InterestingConstruct.Label)) {
						var inner = ProcessInner(stmt.Finally, breakStack, continueStack, currentState.FinallyStack, null);
						@finally = JsStatement.Block(new[] { new JsSetNextStateStatement(inner.Item2) }.Concat(inner.Item1));
					}
					else
						@finally = rewriter.Process(stmt.Finally);

					if ((guardedConstructs & InterestingConstruct.Await) != InterestingConstruct.None) {
						// Wrap the finally block inside an 'if (doFinallyBlocks) {}'
						@finally = JsStatement.Block(JsStatement.If(JsExpression.Identifier(_doFinallyBlocksVariableName), @finally, null));
					}
				}
				else
					@finally = null;

				if (currentBlock.Count > 0 && _childStates.ContainsKey(currentState.StateValue)) {
					var newBlock = JsStatement.If(JsExpression.Same(JsExpression.Identifier(_stateVariableName), JsExpression.Number(currentState.StateValue)), JsStatement.Block(currentBlock), null);
					currentBlock.Clear();
					currentBlock.Add(newBlock);
				}

				currentBlock.Add(JsStatement.Try(guarded, @catch, @finally));
				return true;
			}
		}
Esempio n. 35
0
		/// <summary>
		/// Replaces the list of available parsers.
		/// Please use this for unit tests only!
		/// </summary>
		public static void RegisterAvailableParsers(params ParserDescriptor[] descriptors)
		{
			lock (syncLock) {
				parserDescriptors = new List<ParserDescriptor>();
				parserDescriptors.AddRange(descriptors);
			}
		}
Esempio n. 36
0
 public static IServiceCollection RegisterAllCommandFromAssembly(this IServiceCollection services, Assembly assembly)
 {
     _commands.AddRange(LoadAllCommandsFromAssembly(assembly));
     return(services);
 }
Esempio n. 37
0
 public CompositeContinuation(params IContinuation[] continuations)
 {
     _continuations.AddRange(continuations);
 }
Esempio n. 38
0
 public void AddGroups(IEnumerable <GroupContainer> groups)
 {
     _groups.Clear();
     _groups.AddRange(groups);
 }
		private void MapResults(ITwitterSearchQuery search, IList<NewsItem> results)
		{
			var r = search.Request()
						  .AsSearchResult();

			results.AddRange(r.Statuses.ConvertAll(t => new NewsItem
															{
																Author = t.FromUserScreenName,
																AuthorPhotoUrl = t.ProfileImageUrl,
																AuthorUrl = "http://twitter.com/{0}".FormatWith(t.FromUserScreenName),
																PublishedTime = t.CreatedDate,
																Headline = t.Text,
																Url = t.Source
															}));
		}
 // Call backs from our ISignatureHelpSourceProvider.  Used to actually populate the vs
 // session.
 internal void AugmentSignatureHelpSession(IList<ISignature> signatures)
 {
     signatures.Clear();
     signatures.AddRange(_signatureHelpItems.Select(_signatureMap.GetValueOrDefault));
 }
		/// <summary>
		/// Write a formatted description of a spell
		/// </summary>
		/// <param name="output"></param>
		/// <param name="spell"></param>
		/// <param name="spellLine"></param>
		/// <param name="client"></param>
		public void WriteSpellInfo(IList<string> output, Spell spell, SpellLine spellLine, GameClient client)
		{
			if (client == null || client.Player == null)
				return;

			// check to see if player class handles delve
			if (client.Player.DelveSpell(output, spell, spellLine))
				return;

			ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, spell, spellLine);
			if (spellHandler == null)
			{
				output.Add(" ");
				output.Add("Spell type (" + spell.SpellType + ") is not implemented.");
			}
			else
			{
				output.AddRange(spellHandler.DelveInfo);
				//Subspells
				if (spell.SubSpellID > 0)
				{
					Spell s = SkillBase.GetSpellByID(spell.SubSpellID);
					output.Add(" ");

					ISpellHandler sh = ScriptMgr.CreateSpellHandler(client.Player, s, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
					output.AddRange(sh.DelveInfo);
				}
			}
			if (client.Account.PrivLevel > 1)
			{
				output.Add(" ");
				output.Add("--- Spell Technical Information ---");
				output.Add(" ");
				output.Add("Line: " + (spellHandler == null ? spellLine.KeyName : spellHandler.SpellLine.Name));
				output.Add("Type: " + spell.SpellType);
				output.Add(" ");
				output.Add("SpellID: " + spell.ID);
				output.Add("Icon: " + spell.Icon);
				output.Add("Type: " + spell.SpellType);
				output.Add("ClientEffect: " + spell.ClientEffect);
				output.Add("Target: " + spell.Target);
				output.Add("MoveCast: " + spell.MoveCast);
				output.Add("Uninterruptible: " + spell.Uninterruptible);
				output.Add("Value: " + spell.Value);
				output.Add("LifeDrainReturn: " + spell.LifeDrainReturn);
				if (spellHandler != null)
					output.Add("HasPositiveEffect: " + spellHandler.HasPositiveEffect);
				output.Add("SharedTimerGroup: " + spell.SharedTimerGroup);
				output.Add("EffectGroup: " + spell.EffectGroup);
				output.Add("SpellGroup (for hybrid grouping): " + spell.Group);
				output.Add("Spell AllowCoexisting: " + spell.AllowCoexisting);
			}
		}
Esempio n. 42
0
        void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
        {
            completionWindow = new CompletionWindow(editor.TextArea);

            data = completionWindow.CompletionList.CompletionData;
            data.Clear();

            if (e.Text == "." && e.Text == ";")
            {
                return;
            }
            else if (e.Text == "(")
            {
                insightWindow = new OverloadInsightWindow(editor.TextArea);
                insightWindow.Provider = new OverloadProvider();

                insightWindow.Show();
                insightWindow.Closed += (o, args) => insightWindow = null;
            }

            else
            {
                foreach (var func in Functions)
                {
                    data.Add(new MyCompletionData(func.Name, Properties.Resources.Method_636));
                }
                data.AddRange("function|delete|break|continue");

                foreach (var obj in objects)
                {
                    if(obj is Delegate)
                    {
                        data.Add(new MyCompletionData(obj.Key, Properties.Resources.Method_636));
                    }
                    else
                    {
                        data.Add(new MyCompletionData(obj.Key, Properties.Resources.Object_554));
                    }
                }
            }

            if (data.Any())
            {
                completionWindow.Show();
            }

            completionWindow.Closed += delegate
            {
                completionWindow = null;
            };
        }
        protected override IList<IQueryNode> SetChildrenOrder(IList<IQueryNode> children)
        {
            try
            {
                foreach (IQueryNode child in children)
                {
                    if (!child.IsLeaf)
                    {
                        IList<IQueryNode> grandChildren = child.GetChildren();

                        if (grandChildren != null && grandChildren.Count > 0)
                        {
                            this.childrenBuffer.Add(child);
                        }
                    }
                    else
                    {
                        this.childrenBuffer.Add(child);
                    }
                }

                children.Clear();
                children.AddRange(this.childrenBuffer);
            }
            finally
            {
                this.childrenBuffer.Clear();
            }

            return children;
        }
        private bool HandleDoWhileStatement(JsDoWhileStatement stmt, StackEntry location, ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State currentState, State returnState, IList<JsStatement> currentBlock)
        {
            if (currentBlock.Count > 0) {
                // We have to create a new block for the statement.
                var topOfLoopState = CreateNewStateValue(currentState.FinallyStack);
                Enqueue(stack.Push(location), breakStack, continueStack, topOfLoopState, returnState);
                currentBlock.Add(new JsGotoStateStatement(topOfLoopState, currentState));
                return false;
            }
            else {
                var beforeConditionState = CreateNewStateValue(currentState.FinallyStack);
                Tuple<State, bool> afterLoopState;
                string currentName = GetLabelForState(currentState);
                if (new ContainsBreakVisitor().Analyze(stmt.Body, currentName)) {
                    afterLoopState = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);
                    breakStack = breakStack.Push(Tuple.Create(currentName, afterLoopState.Item1));
                }
                else {
                    afterLoopState = Tuple.Create(returnState, false);
                }

                currentBlock.AddRange(Handle(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(stmt.Body, 0)), breakStack, continueStack.Push(Tuple.Create(GetLabelForState(currentState), beforeConditionState)), currentState, beforeConditionState));

                if (afterLoopState.Item2) {
                    Enqueue(PushFollowing(stack, location), breakStack, continueStack, afterLoopState.Item1, returnState);
                    Enqueue(stack.Push(new StackEntry(new JsBlockStatement(new JsIfStatement(stmt.Condition, new JsGotoStateStatement(currentState, currentState), null)), 0)), breakStack, continueStack, beforeConditionState, afterLoopState.Item1);
                }
                else {
                    Enqueue(PushFollowing(stack, location).Push(new StackEntry(new JsBlockStatement(new JsIfStatement(stmt.Condition, new JsGotoStateStatement(currentState, currentState), null)), 0)), breakStack, continueStack, beforeConditionState, returnState);
                }

                return false;
            }
        }
        private bool HandleTryStatement(JsTryStatement stmt, StackEntry location, ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State currentState, State returnState, IList<JsStatement> currentBlock)
        {
            if (FindInterestingConstructsVisitor.Analyze(stmt.GuardedStatement, InterestingConstruct.YieldReturn) || (stmt.Finally != null && stmt.Catch == null && !currentState.FinallyStack.IsEmpty)) {
                if (stmt.Catch != null)
                    throw new InvalidOperationException("Cannot yield return from try with catch");
                string handlerName = _allocateFinallyHandler();
                _finallyHandlers.Add(Tuple.Create(handlerName, FindInterestingConstructsVisitor.Analyze(stmt.Finally, InterestingConstruct.Label) ? new FinalizerRewriter(_stateVariableName, _labelStates).Process(new JsBlockStatement(ProcessInner(stmt.Finally, breakStack, continueStack, currentState.FinallyStack))) : stmt.Finally));
                var stateAfter = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);
                var innerState = CreateNewStateValue(currentState.FinallyStack, handlerName);
                var stateBeforeFinally = CreateNewStateValue(innerState.FinallyStack);
                currentBlock.Add(new JsSetNextStateStatement(innerState.StateValue));
                currentBlock.AddRange(Handle(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(stmt.GuardedStatement, 0)), breakStack, continueStack, innerState, stateBeforeFinally));

                Enqueue(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(new JsBlockStatement(new JsBlockStatement(new JsStatement[0], true)), 0)), breakStack, continueStack, stateBeforeFinally, stateAfter.Item1);
                if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1) {
                    Enqueue(PushFollowing(stack, location), breakStack, continueStack, stateAfter.Item1, returnState);
                }
                return false;
            }
            else if (stmt.Finally != null && !currentState.FinallyStack.IsEmpty) {
                // This is necessary to special-case in order to ensure that the inner finally block is executed before all outer ones.
                return HandleTryStatement(new JsTryStatement(new JsTryStatement(stmt.GuardedStatement, stmt.Catch, null), null, stmt.Finally), location, stack, breakStack, continueStack, currentState, returnState, currentBlock);
            }
            else {
                var rewriter = new NestedJumpStatementRewriter(breakStack, continueStack, currentState, _exitState.Value);
                var guarded = FindInterestingConstructsVisitor.Analyze(stmt.GuardedStatement, InterestingConstruct.Label)
                              ? new JsBlockStatement(ProcessInner(stmt.GuardedStatement, breakStack, continueStack, currentState.FinallyStack))
                              : rewriter.Process(stmt.GuardedStatement);

                JsCatchClause @catch;
                if (stmt.Catch != null) {
                    if (FindInterestingConstructsVisitor.Analyze(stmt.Catch.Body, InterestingConstruct.Label)) {
                        @catch = new JsCatchClause(stmt.Catch.Identifier, new JsBlockStatement(ProcessInner(stmt.Catch.Body, breakStack, continueStack, currentState.FinallyStack)));
                    }
                    else {
                        var body = rewriter.Process(stmt.Catch.Body);
                        @catch = ReferenceEquals(body, stmt.Catch.Body) ? stmt.Catch : new JsCatchClause(stmt.Catch.Identifier, body);
                    }
                }
                else
                    @catch = null;

                JsBlockStatement @finally;
                if (stmt.Finally != null) {
                    if (FindInterestingConstructsVisitor.Analyze(stmt.Finally, InterestingConstruct.Label))
                        @finally = new JsBlockStatement(ProcessInner(stmt.Finally, breakStack, continueStack, currentState.FinallyStack));
                    else
                        @finally = rewriter.Process(stmt.Finally);
                }
                else
                    @finally = null;

                currentBlock.Add(new JsTryStatement(guarded, @catch, @finally));
                return true;
            }
        }
		public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) {
			applicableToSpan = null;

			if (session == null || quickInfoContent == null || quickInfoContent.IsReadOnly)
				return;
			
			IDocumentMarkup documentMarkup = TryGetDocumentMarkup();
			if (documentMarkup == null)
				return;

			// If this fail, it means the extension is disabled and none of the components are available.
			var tooltipFontProvider = Shell.Instance.TryGetComponent<TooltipFormattingProvider>();
			if (tooltipFontProvider == null)
				return;

			ITextSnapshot textSnapshot = _textBuffer.CurrentSnapshot;
			TextRange textRange = GetCurrentTextRange(session, textSnapshot);
			IShellLocks shellLocks = documentMarkup.Context.Locks;
			Span? finalSpan = null;

			Action getEnhancedTooltips = () => {
				using (shellLocks.UsingReadLock()) {
					
					var presenter = new MultipleTooltipContentPresenter(tooltipFontProvider.GetTooltipFormatting());
					IContextBoundSettingsStore settings = documentMarkup.Document.GetSettings();
					ISolution solution = TryGetCurrentSolution();

					bool hasIdentifierTooltipContent = false;
					if (solution != null) {
						DocumentRange documentRange = textRange.CreateDocumentRange(documentMarkup.Document);
						IdentifierTooltipContent[] contents = GetIdentifierTooltipContents(documentRange, solution, settings);
						foreach (IdentifierTooltipContent content in contents) {
							if (presenter.TryAddContent(content)) {
								finalSpan = content.TrackingRange.ToSpan();
								hasIdentifierTooltipContent = true;
							}
						}
					}

					List<Vs10Highlighter> highlighters = documentMarkup.GetHighlightersOver(textRange).OfType<Vs10Highlighter>().ToList();
					foreach (Vs10Highlighter highlighter in highlighters) {
						ITooltipContent[] contents = GetTooltipContents(highlighter, highlighter.Range, documentMarkup, solution, hasIdentifierTooltipContent);
						foreach (ITooltipContent content in contents) {
							if (presenter.TryAddContent(content))
								finalSpan = content.TrackingRange.ToSpan().Union(finalSpan);
						}
					}

					var nonReSharperContents = new List<object>();
					bool ignoredFirstTextBuffer = false;
					foreach (object content in quickInfoContent) {

						// ignore existing R# elements
						if (content is RichTextPresenter)
							continue;
						
						// ignore the first VS text is we provided an identifier tooltip
						if (content is ITextBuffer && hasIdentifierTooltipContent && !ignoredFirstTextBuffer) {
							ignoredFirstTextBuffer = true;
							continue;
						}

						nonReSharperContents.Add(content);
					}

					quickInfoContent.Clear();
					quickInfoContent.AddRange(presenter.PresentContents());
					quickInfoContent.AddRange(nonReSharperContents);

				}
			};

			if (shellLocks.ReentrancyGuard.TryExecute("GetEnhancedTooltips", getEnhancedTooltips) && finalSpan != null)
				applicableToSpan = textSnapshot.CreateTrackingSpan(finalSpan.Value, SpanTrackingMode.EdgeInclusive);
		}
        private bool HandleWhileStatement(JsWhileStatement stmt, StackEntry location, ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State currentState, State returnState, IList<JsStatement> currentBlock)
        {
            if (currentBlock.Count > 0) {
                // We have to create a new block for the statement.
                var topOfLoopState = CreateNewStateValue(currentState.FinallyStack);
                Enqueue(stack.Push(location), breakStack, continueStack, topOfLoopState, returnState);
                currentBlock.Add(new JsGotoStateStatement(topOfLoopState, currentState));
                return false;
            }
            else {
                var afterLoopState = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);

                currentBlock.Add(new JsIfStatement(JsExpression.LogicalNot(stmt.Condition), new JsGotoStateStatement(afterLoopState.Item1, currentState), null));
                var currentName = GetLabelForState(currentState);
                currentBlock.AddRange(Handle(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(stmt.Body, 0)), breakStack.Push(Tuple.Create(currentName, afterLoopState.Item1)), continueStack.Push(Tuple.Create(currentName, currentState)), currentState, currentState));

                if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1) {
                    Enqueue(PushFollowing(stack, location), breakStack, continueStack, afterLoopState.Item1, returnState);
                }

                return false;
            }
        }
Esempio n. 48
0
        private string AnalyzeType(IClass @class, out string @namespace, IList<string> validMediaTypes = null)
        {
            if (validMediaTypes != null)
            {
                validMediaTypes.AddRange(@class.MediaTypes);
            }

            var name = CreateName(@class);
            @namespace = CreateNamespace(@class);
            return name;
        }
Esempio n. 49
0
 public WorkspaceFilter(IEnumerable <WorkspaceFilter> workspaceFilters) : this()
 {
     _filters.AddRange(workspaceFilters.SelectMany(x => x.Filters));
 }
Esempio n. 50
0
        public static IList/*!*/ SplatAppend(IList/*!*/ array, object splattee) {
            IEnumerable<object> objList;
            IEnumerable iList;

            if ((objList = splattee as IEnumerable<object>) != null) {
                array.AddRange(objList);
            } else if ((iList = splattee as IEnumerable) != null) {
                array.AddRange(iList);
            } else {
                array.Add(splattee);
            }
            return array;
        }
Esempio n. 51
0
        public override void SetUp()
        {
            base.SetUp();

            AllSortFields = new List<SortField>(Arrays.AsList(new SortField[] { new SortField("byte", SortField.Type_e.BYTE, false), new SortField("short", SortField.Type_e.SHORT, false), new SortField("int", SortField.Type_e.INT, false), new SortField("long", SortField.Type_e.LONG, false), new SortField("float", SortField.Type_e.FLOAT, false), new SortField("double", SortField.Type_e.DOUBLE, false), new SortField("bytes", SortField.Type_e.STRING, false), new SortField("bytesval", SortField.Type_e.STRING_VAL, false), new SortField("byte", SortField.Type_e.BYTE, true), new SortField("short", SortField.Type_e.SHORT, true), new SortField("int", SortField.Type_e.INT, true), new SortField("long", SortField.Type_e.LONG, true), new SortField("float", SortField.Type_e.FLOAT, true), new SortField("double", SortField.Type_e.DOUBLE, true), new SortField("bytes", SortField.Type_e.STRING, true), new SortField("bytesval", SortField.Type_e.STRING_VAL, true), SortField.FIELD_SCORE, SortField.FIELD_DOC }));

            if (SupportsDocValues)
            {
                AllSortFields.AddRange(Arrays.AsList(new SortField[] { new SortField("intdocvalues", SortField.Type_e.INT, false), new SortField("floatdocvalues", SortField.Type_e.FLOAT, false), new SortField("sortedbytesdocvalues", SortField.Type_e.STRING, false), new SortField("sortedbytesdocvaluesval", SortField.Type_e.STRING_VAL, false), new SortField("straightbytesdocvalues", SortField.Type_e.STRING_VAL, false), new SortField("intdocvalues", SortField.Type_e.INT, true), new SortField("floatdocvalues", SortField.Type_e.FLOAT, true), new SortField("sortedbytesdocvalues", SortField.Type_e.STRING, true), new SortField("sortedbytesdocvaluesval", SortField.Type_e.STRING_VAL, true), new SortField("straightbytesdocvalues", SortField.Type_e.STRING_VAL, true) }));
            }

            // Also test missing first / last for the "string" sorts:
            foreach (string field in new string[] { "bytes", "sortedbytesdocvalues" })
            {
                for (int rev = 0; rev < 2; rev++)
                {
                    bool reversed = rev == 0;
                    SortField sf = new SortField(field, SortField.Type_e.STRING, reversed);
                    sf.MissingValue = SortField.STRING_FIRST;
                    AllSortFields.Add(sf);

                    sf = new SortField(field, SortField.Type_e.STRING, reversed);
                    sf.MissingValue = SortField.STRING_LAST;
                    AllSortFields.Add(sf);
                }
            }

            int limit = AllSortFields.Count;
            for (int i = 0; i < limit; i++)
            {
                SortField sf = AllSortFields[i];
                if (sf.Type == SortField.Type_e.INT)
                {
                    SortField sf2 = new SortField(sf.Field, SortField.Type_e.INT, sf.Reverse);
                    sf2.MissingValue = Random().Next();
                    AllSortFields.Add(sf2);
                }
                else if (sf.Type == SortField.Type_e.LONG)
                {
                    SortField sf2 = new SortField(sf.Field, SortField.Type_e.LONG, sf.Reverse);
                    sf2.MissingValue = Random().NextLong();
                    AllSortFields.Add(sf2);
                }
                else if (sf.Type == SortField.Type_e.FLOAT)
                {
                    SortField sf2 = new SortField(sf.Field, SortField.Type_e.FLOAT, sf.Reverse);
                    sf2.MissingValue = (float)Random().NextDouble();
                    AllSortFields.Add(sf2);
                }
                else if (sf.Type == SortField.Type_e.DOUBLE)
                {
                    SortField sf2 = new SortField(sf.Field, SortField.Type_e.DOUBLE, sf.Reverse);
                    sf2.MissingValue = Random().NextDouble();
                    AllSortFields.Add(sf2);
                }
            }

            Dir = NewDirectory();
            RandomIndexWriter iw = new RandomIndexWriter(Random(), Dir);
            int numDocs = AtLeast(200);
            for (int i = 0; i < numDocs; i++)
            {
                IList<Field> fields = new List<Field>();
                fields.Add(NewTextField("english", English.IntToEnglish(i), Field.Store.NO));
                fields.Add(NewTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
                fields.Add(NewStringField("byte", "" + ((sbyte)Random().Next()), Field.Store.NO));
                fields.Add(NewStringField("short", "" + ((short)Random().Next()), Field.Store.NO));
                fields.Add(new IntField("int", Random().Next(), Field.Store.NO));
                fields.Add(new LongField("long", Random().NextLong(), Field.Store.NO));

                fields.Add(new FloatField("float", (float)Random().NextDouble(), Field.Store.NO));
                fields.Add(new DoubleField("double", Random().NextDouble(), Field.Store.NO));
                fields.Add(NewStringField("bytes", TestUtil.RandomRealisticUnicodeString(Random()), Field.Store.NO));
                fields.Add(NewStringField("bytesval", TestUtil.RandomRealisticUnicodeString(Random()), Field.Store.NO));
                fields.Add(new DoubleField("double", Random().NextDouble(), Field.Store.NO));

                if (SupportsDocValues)
                {
                    fields.Add(new NumericDocValuesField("intdocvalues", Random().Next()));
                    fields.Add(new FloatDocValuesField("floatdocvalues", (float)Random().NextDouble()));
                    fields.Add(new SortedDocValuesField("sortedbytesdocvalues", new BytesRef(TestUtil.RandomRealisticUnicodeString(Random()))));
                    fields.Add(new SortedDocValuesField("sortedbytesdocvaluesval", new BytesRef(TestUtil.RandomRealisticUnicodeString(Random()))));
                    fields.Add(new BinaryDocValuesField("straightbytesdocvalues", new BytesRef(TestUtil.RandomRealisticUnicodeString(Random()))));
                }
                Document document = new Document();
                document.Add(new StoredField("id", "" + i));
                if (VERBOSE)
                {
                    Console.WriteLine("  add doc id=" + i);
                }
                foreach (Field field in fields)
                {
                    // So we are sometimes missing that field:
                    if (Random().Next(5) != 4)
                    {
                        document.Add(field);
                        if (VERBOSE)
                        {
                            Console.WriteLine("    " + field);
                        }
                    }
                }

                iw.AddDocument(document);

                if (Random().Next(50) == 17)
                {
                    iw.Commit();
                }
            }
            Reader = iw.Reader;
            iw.Dispose();
            Searcher = NewSearcher(Reader);
            if (VERBOSE)
            {
                Console.WriteLine("  searcher=" + Searcher);
            }
        }
		protected void WritePoisonInfo(IList<string> list, InventoryItem item, GameClient client)
		{
			if (item.PoisonSpellID != 0)
			{
				SpellLine poisonLine = SkillBase.GetSpellLine(GlobalSpellsLines.Mundane_Poisons);
				if (poisonLine != null)
				{
					List<Spell> spells = SkillBase.GetSpellList(poisonLine.KeyName);

					foreach (Spell spl in spells)
					{
						if (spl.ID == item.PoisonSpellID)
						{
							list.Add(" ");
							list.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WritePoisonInfo.LevelRequired"));
							list.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WritePoisonInfo.Level", spl.Level));
							list.Add(" ");
							list.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WritePoisonInfo.ProcAbility"));
							list.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WritePoisonInfo.Charges", item.PoisonCharges));
							list.Add(LanguageMgr.GetTranslation(client.Account.Language, "DetailDisplayHandler.WritePoisonInfo.MaxCharges", item.PoisonMaxCharges));
							list.Add(" ");

							ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(client.Player, spl, poisonLine);
							if (spellHandler != null)
							{
								list.AddRange(spellHandler.DelveInfo);
							}
							else
							{
								list.Add("-" + spl.Name + " (Not implemented yet)");
							}
							break;
						}
					}
				}
			}
		}
 public Task PublishEventsAsync(CustomerIntelligenceEvent[] ciEvents)
 {
     events.AddRange(ciEvents);
     return(Task.CompletedTask);
 }
		private bool HandleForStatement(JsForStatement stmt, StackEntry location, ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State currentState, State returnState, IList<JsStatement> currentBlock, bool isFirstStatement) {
			if (!(isFirstStatement && (stmt.InitStatement is JsEmptyStatement || location.AfterForInitializer))) {
				// We have to create a new block for the statement.
				var topOfLoopState = CreateNewStateValue(currentState.FinallyStack);
				Enqueue(stack.Push(new StackEntry(location.Block, location.Index, true)), breakStack, continueStack, topOfLoopState, returnState);
				if (!(stmt.InitStatement is JsEmptyStatement))
					currentBlock.Add(stmt.InitStatement);
				currentBlock.Add(new JsGotoStateStatement(topOfLoopState, currentState));
				return false;
			}
			else {
				var iteratorState = (stmt.IteratorExpression != null ? CreateNewStateValue(currentState.FinallyStack) : currentState);
				var afterLoopState = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);

				if (stmt.ConditionExpression != null)
					currentBlock.Add(JsStatement.If(JsExpression.LogicalNot(stmt.ConditionExpression), new JsGotoStateStatement(afterLoopState.Item1, currentState), null));
				string currentName = GetLabelForState(currentState);
				currentBlock.AddRange(Handle(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(stmt.Body, 0)), breakStack.Push(Tuple.Create(currentName, afterLoopState.Item1)), continueStack.Push(Tuple.Create(currentName, iteratorState)), currentState, iteratorState, false, false));

				if (stmt.IteratorExpression != null) {
					Enqueue(ImmutableStack<StackEntry>.Empty.Push(new StackEntry(JsStatement.Block(stmt.IteratorExpression), 0)), breakStack, continueStack, iteratorState, currentState);
				}

				if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1) {
					Enqueue(PushFollowing(stack, location), breakStack, continueStack, afterLoopState.Item1, returnState);
				}

				return false;
			}
		}
		static IEnumerable<ICompletionItem> FilterAndAddTemplates(ITextEditor editor, IList<ICompletionItem> items)
		{
			List<ISnippetCompletionItem> snippets = editor.GetSnippets().ToList();
			snippets.RemoveAll(item => !FitsInContext(item, items));
			items.RemoveAll(item => ClassBrowserIconService.Keyword.Equals(item.Image) && snippets.Exists(i => i.Text == item.Text));
			items.AddRange(snippets);
			return items;
		}
 static void AddFilesFromViewContent(IList<string> files, IViewContent vc)
 {
     files.AddRange(vc.Files
                    .Select(f => f.FileName.ToString())
                    .Where(name => name != null && IsPossibleFile(name))
                   );
 }
Esempio n. 57
0
		/// <summary>
		/// Delve a Style handled by this processor
		/// </summary>
		/// <param name="delveInfo"></param>
		/// <param name="style"></param>
		/// <param name="player"></param>
		public static void DelveWeaponStyle(IList<string> delveInfo, Style style, GamePlayer player)
		{
			delveInfo.Add(LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.WeaponType", style.GetRequiredWeaponName()));
			string temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Opening") + " ";
			if (Style.eOpening.Offensive == style.OpeningRequirementType)
			{
				//attacker action result is opening
				switch (style.AttackResultRequirement)
				{
					case Style.eAttackResult.Hit:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.YouHit");
						break;
					case Style.eAttackResult.Miss:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.YouMiss");
						break;
					case Style.eAttackResult.Parry:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetParrys");
						break;
					case Style.eAttackResult.Block:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetBlocks");
						break;
					case Style.eAttackResult.Evade:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetEvades");
						break;
					case Style.eAttackResult.Fumble:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.YouFumble");
						break;
					case Style.eAttackResult.Style:
						Style reqStyle = SkillBase.GetStyleByID(style.OpeningRequirementValue, player.CharacterClass.ID);
						if (reqStyle == null)
						{
							reqStyle = SkillBase.GetStyleByID(style.OpeningRequirementValue, 0);
						}
						temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.OpeningStyle") + " ";
						if (reqStyle == null)
						{
							temp += "(style not found " + style.OpeningRequirementValue + ")";
						}
						else
						{
							temp += reqStyle.Name;
						}
						break;
					default:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Any");
						break;
				}
			}
			else if (Style.eOpening.Defensive == style.OpeningRequirementType)
			{
				//defender action result is opening
				switch (style.AttackResultRequirement)
				{
					case Style.eAttackResult.Miss:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetMisses");
						break;
					case Style.eAttackResult.Hit:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetHits");
						break;
					case Style.eAttackResult.Parry:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.YouParry");
						break;
					case Style.eAttackResult.Block:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.YouBlock");
						break;
					case Style.eAttackResult.Evade:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.YouEvade");
						break;
					case Style.eAttackResult.Fumble:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetFumbles");
						break;
					case Style.eAttackResult.Style:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetStyle");
						break;
					default:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Any");
						break;
				}
			}
			else if (Style.eOpening.Positional == style.OpeningRequirementType)
			{
				//attacker position to target is opening
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Positional");
				switch (style.OpeningRequirementValue)
				{
					case (int)Style.eOpeningPosition.Front:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Front");
						break;
					case (int)Style.eOpeningPosition.Back:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Back");
						break;
					case (int)Style.eOpeningPosition.Side:
						temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Side");
						break;

				}
			}

			delveInfo.Add(temp);

			if (style.OpeningRequirementValue != 0 && style.AttackResultRequirement == 0 && style.OpeningRequirementType == 0)
			{
				delveInfo.Add(string.Format("- Error: Opening Requirement '{0}' but requirement type is Any!", style.OpeningRequirementValue));
			}

			temp = "";

			foreach (Style st in SkillBase.GetStyleList(style.Spec, player.CharacterClass.ID))
			{
				if (st.AttackResultRequirement == Style.eAttackResult.Style && st.OpeningRequirementValue == style.ID)
				{
					temp = (temp == "" ? st.Name : temp + LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Or", st.Name));
				}
			}

			if (temp == "")
			{
				foreach (Style st in player.GetChampionStyleList())
				{
					if (st.AttackResultRequirement == Style.eAttackResult.Style && st.OpeningRequirementValue == style.ID)
					{
						temp = (temp == "" ? st.Name : temp + LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Or", st.Name));
					}
				}
			}

			if (temp != "")
			{
				delveInfo.Add(LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.FollowupStyle", temp));
			}

			temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.FatigueCost") + " ";

			if (style.EnduranceCost < 5)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryLow");
			else if (style.EnduranceCost < 10)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Low");
			else if (style.EnduranceCost < 15)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Medium");
			else if (style.EnduranceCost < 20)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.High");
			else
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryHigh");

			delveInfo.Add(temp);

			temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Damage") + " ";


			if (style.GrowthRate == 0)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.NoBonus");
			else if (style.GrowthRate < .1)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryLow");
			else if (style.GrowthRate < .25)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Low");
			else if (style.GrowthRate < .5)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Medium");
			else if (style.GrowthRate < 1.0)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.High");
			else
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryHigh");

			temp += " (" + style.GrowthRate + ")";

			delveInfo.Add(temp);

			temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.ToHit") + " ";

			if (style.BonusToHit <= -20)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryHighPenalty");
			else if (style.BonusToHit <= -15)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.HighPenalty");
			else if (style.BonusToHit <= -10)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.MediumPenalty");
			else if (style.BonusToHit <= -5)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.LowPenalty");
			else if (style.BonusToHit < 0)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryLowPenalty");
			else if (style.BonusToHit == 0)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.NoBonus");
			else if (style.BonusToHit < 5)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryLowBonus");
			else if (style.BonusToHit < 10)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.LowBonus");
			else if (style.BonusToHit < 15)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.MediumBonus");
			else if (style.BonusToHit < 20)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.HighBonus");
			else
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryHighBonus");

			delveInfo.Add(temp);

			temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.Defense") + " ";

			if (style.BonusToDefense <= -20)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryHighPenalty");
			else if (style.BonusToDefense <= -15)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.HighPenalty");
			else if (style.BonusToDefense <= -10)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.MediumPenalty");
			else if (style.BonusToDefense <= -5)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.LowPenalty");
			else if (style.BonusToDefense < 0)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryLowPenalty");
			else if (style.BonusToDefense == 0)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.NoBonus");
			else if (style.BonusToDefense < 5)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryLowBonus");
			else if (style.BonusToDefense < 10)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.LowBonus");
			else if (style.BonusToDefense < 15)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.MediumBonus");
			else if (style.BonusToDefense < 20)
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.HighBonus");
			else
				temp += LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.VeryHighBonus");

			delveInfo.Add(temp);

			if (style.Procs.Count > 0)
			{
				temp = LanguageMgr.GetTranslation(player.Client, "DetailDisplayHandler.HandlePacket.TargetEffect") + " ";

				SpellLine styleLine = SkillBase.GetSpellLine(GlobalSpellsLines.Combat_Styles_Effect);
				if (styleLine != null)
				{
					foreach (DBStyleXSpell proc in style.Procs)
					{
						// RR4: we added all the procs to the style, now it's time to check for class ID
						if (proc.ClassID != 0 && proc.ClassID != player.CharacterClass.ID) continue;

						Spell spell = SkillBase.GetSpellByID(proc.SpellID);
						if (spell != null)
						{
							ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(player.Client.Player, spell, styleLine);
							if (spellHandler == null)
							{
								temp += spell.Name + " (Not implemented yet)";
								delveInfo.Add(temp);
							}
							else
							{
								temp += spell.Name;
								delveInfo.Add(temp);
								delveInfo.Add(" ");//empty line
								delveInfo.AddRange(spellHandler.DelveInfo);
							}
						}
					}
				}
			}

			if (player.Client.Account.PrivLevel > 1)
			{
				delveInfo.Add(" ");
				delveInfo.Add("--- Style Technical Information ---");
				delveInfo.Add(" ");
				delveInfo.Add(string.Format("ID: {0}", style.ID));
				delveInfo.Add(string.Format("ClassID: {0}", style.ClassID));
				delveInfo.Add(string.Format("Icon: {0}", style.Icon));
				delveInfo.Add(string.Format("TwoHandAnimation: {0}", style.TwoHandAnimation));
				delveInfo.Add(string.Format("Spec: {0}", style.Spec));
				delveInfo.Add(string.Format("SpecLevelRequirement: {0}", style.SpecLevelRequirement));
				delveInfo.Add(string.Format("Level: {0}", style.Level));
				delveInfo.Add(string.Format("GrowthRate: {0}", style.GrowthRate));
				delveInfo.Add(string.Format("Endurance: {0}", style.EnduranceCost));
				delveInfo.Add(string.Format("StealthRequirement: {0}", style.StealthRequirement));
				delveInfo.Add(string.Format("WeaponTypeRequirement: {0}", style.WeaponTypeRequirement));
				string indicator = "";
				if (style.OpeningRequirementValue != 0 && style.AttackResultRequirement == 0 && style.OpeningRequirementType == 0)
				{
					indicator = "!!";
				}
				delveInfo.Add(string.Format("AttackResultRequirement: {0}({1}) {2}", style.AttackResultRequirement, (int)style.AttackResultRequirement, indicator));
				delveInfo.Add(string.Format("OpeningRequirementType: {0}({1}) {2}", style.OpeningRequirementType, (int)style.OpeningRequirementType, indicator));
				delveInfo.Add(string.Format("OpeningRequirementValue: {0}", style.OpeningRequirementValue));
				delveInfo.Add(string.Format("ArmorHitLocation: {0}({1})", style.ArmorHitLocation, (int)style.ArmorHitLocation));
				delveInfo.Add(string.Format("BonusToDefense: {0}", style.BonusToDefense));
				delveInfo.Add(string.Format("BonusToHit: {0}", style.BonusToHit));

				if (style.Procs != null && style.Procs.Count > 0)
				{
					delveInfo.Add(" ");

					string procs = "";
					foreach (DBStyleXSpell spell in style.Procs)
					{
						if (procs != "")
							procs += ", ";

						procs += spell.SpellID;
					}

					delveInfo.Add(string.Format("Procs: {0}", procs));
					delveInfo.Add(string.Format("RandomProc: {0}", style.RandomProc));
				}
			}

		}
Esempio n. 58
0
 public static void AddTo <T>(this IEnumerable <T> item, IList <T> list)
 {
     list.AddRange(item);
 }
Esempio n. 59
0
 public static IServiceCollection RegisterAllEventsFromAssembly(this IServiceCollection services, Assembly assembly)
 {
     _events.AddRange(LoadAllEventsFromAssembly(assembly));
     return(services);
 }
Esempio n. 60
0
        public virtual void ReadFigureList(IList<IFigure> figureList, XElement element, Drawing drawing)
        {
            if (element.Name == "Drawing")
            {
                element = element.Element("Figures");
            }

            var figures = ReadFigures(element, drawing);
            figureList.AddRange(figures);
        }