Example #1
0
        public static async Task<bool> Query(this IEnumerable<Item> items, bool all = false)
        {
            try
            {
                if (!all)
                    items = items?.Where(i => i.PriceSell == null);
                if (items.IsNullOrEmpty())
                    return true;
                var ids = string.Join("&", items.Select(i => "typeid=" + i.TypeId));
                var url = string.Format(Settings.Default.Marketstat, ids);
                var str = await Utils.HttpGetStringAsync(url);

                var doc = XDocument.Parse(str);

                foreach (var nodes in doc.Descendants("type"))
                {
                    var id = int.Parse(nodes.Attribute("id").Value);
                    var item = items.Single(i => i.TypeId == id);
                    item.PriceSell = nodes.Element("sell").Element("min").Value.AsDecimal();
                    item.PriceBuy = nodes.Element("buy").Element("max").Value.AsDecimal();
                    item.LastUpdate = DateTime.Now;
                }
                await EveContext.Context.SaveChangesAsync();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        /// <summary>
        /// Given a <see cref="IEnumerable{IMethodSymbol}"/>, this method returns the method symbol which 
        /// matches the expectedParameterTypesInOrder parameter requirement
        /// </summary>
        /// <param name="members"></param>
        /// <param name="expectedParameterTypesInOrder"></param>
        /// <returns></returns>
        public static IMethodSymbol GetSingleOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol> members, params ParameterInfo[] expectedParameterTypesInOrder)
        {
            var expectedParameterCount = expectedParameterTypesInOrder.Count();
            return members?.Where(member =>
            {
                if (member.Parameters.Count() != expectedParameterCount)
                {
                    return false;
                }

                for (int i = 0; i < expectedParameterCount; i++)
                {
                    // check IsParams only on the last parameter
                    if (i == expectedParameterCount - 1 &&
                        member.Parameters[i].IsParams != expectedParameterTypesInOrder[i].IsParams)
                    {
                        return false;
                    }

                    var parameterType = member.Parameters[i].Type;
                    if (expectedParameterTypesInOrder[i].IsArray)
                    {
                        var arrayParameterSymbol = parameterType as IArrayTypeSymbol;
                        if (arrayParameterSymbol?.Rank != expectedParameterTypesInOrder[i].ArrayRank)
                        {
                            return false;
                        }

                        parameterType = arrayParameterSymbol.ElementType;
                    }

                    if (!expectedParameterTypesInOrder[i].ParameterType.Equals(parameterType))
                    {
                        return false;
                    }
                }

                return true;
            }).SingleOrDefault();
        }
Example #3
0
		static public IEnumerable<MemoryStruct.ITreeViewEntry> SetTreeEntrySuitingSelectedPath(
			this IEnumerable<MemoryStruct.ITreeViewEntry> SetTreeEntryRoot,
			IEnumerable<string> SelectedPathListNodeLabel)
		{
			if (null == SetTreeEntryRoot || null == SelectedPathListNodeLabel)
			{
				return null;
			}

			var PathListNodeLabelLessFormatting =
				SelectedPathListNodeLabel?.Select(Label => Label?.RemoveXmlTag()?.Trim())?.ToArray();

			var PathListNodeLabelNext =
				PathListNodeLabelLessFormatting?.FirstOrDefault();

			if (null == PathListNodeLabelNext)
			{
				return null;
			}

			var SetTreeEntryRootSuitingPathNodeNext =
				SetTreeEntryRoot
				?.Where(TreeEntry => (TreeEntry?.Text?.RemoveXmlTag()?.Trim()).EqualsIgnoreCase(PathListNodeLabelNext))
				?.ToArray();

			if (null == SetTreeEntryRootSuitingPathNodeNext)
			{
				return null;
			}

			if (PathListNodeLabelLessFormatting.Length < 2)
			{
				return SetTreeEntryRootSuitingPathNodeNext;
			}

			return
				SetTreeEntryRootSuitingPathNodeNext
				.Select((LinxTreeEntryPasend) =>
					SetTreeEntrySuitingSelectedPath(
						LinxTreeEntryPasend.Child,
						SelectedPathListNodeLabel.Skip(1)))
				?.Where((Kandidaat) => null != Kandidaat)
				?.ConcatNullable();
		}