Пример #1
0
        /// <summary>
        /// Queries a collection of resources.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public virtual IEnumerable <TOut> Query <TOut>(Func <T, IEnumerable <ILinkedEntity <TOut> > > objFunc, params string[] parameters)
            where TOut : class, ICrestResource <TOut>
        {
            var items = objFunc.Invoke(this as T);

            return(EveCrest.Load(items, parameters));
        }
Пример #2
0
        /// <summary>
        ///     Queries a collection of resources asynchronously.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public virtual Task <IEnumerable <TOut> > QueryAsync <TOut>(Func <T, IEnumerable <Href <TOut> > > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            IEnumerable <Href <TOut> > items = objFunc.Invoke(this as T);

            return(EveCrest.LoadAsync(items));
        }
Пример #3
0
        /// <summary>
        ///     Queries a collection of resources.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public virtual IEnumerable <TOut> Query <TOut>(Func <T, IEnumerable <ILinkedEntity <TOut> > > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            IEnumerable <ILinkedEntity <TOut> > items = objFunc.Invoke(this as T);

            return(EveCrest.Load(items));
        }
Пример #4
0
 /// <summary>
 ///     Injects the specified instance.
 /// </summary>
 /// <param name="instance">The instance.</param>
 public override void Inject(EveCrest instance)
 {
     base.Inject(instance);
     Contacts.EveCrest  = instance;
     Fittings.EveCrest  = instance;
     Waypoints.EveCrest = instance;
 }
Пример #5
0
        /// <summary>
        /// Queries a collection of resources asynchronously.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public virtual Task <IEnumerable <TOut> > QueryAsync <TOut>(Func <T, IEnumerable <Href <TOut> > > objFunc,
                                                                    params string[] parameters)
            where TOut : class, ICrestResource <TOut>
        {
            var items = objFunc.Invoke(this as T);

            return(EveCrest.LoadAsync(items, parameters));
        }
Пример #6
0
 /// <summary>
 ///     Injects the specified crest instance.
 /// </summary>
 /// <param name="crestInstance">The crest instance.</param>
 public override void Inject(EveCrest crestInstance)
 {
     base.Inject(crestInstance);
     foreach (var item in Items)
     {
         item.EveCrest = EveCrest;
         item.PostUri  = Uri.ToString();
     }
 }
Пример #7
0
 /// <summary>
 ///     Injects the specified instance.
 /// </summary>
 /// <param name="instance">The instance.</param>
 public override void Inject(EveCrest instance)
 {
     base.Inject(instance);
     Contacts.EveCrest             = instance;
     Fittings.EveCrest             = instance;
     UI.SetWaypoints.EveCrest      = instance;
     UI.ShowMarketDetails.EveCrest = instance;
     UI.ShowContact.EveCrest       = instance;
 }
Пример #8
0
 public EveCrest_Singularity_Tests() {
     Crest = new EveCrest(refreshToken, encodedKey);
     Crest.Host = "https://api-sisi.testeveonline.com/";
     Crest.EveAuth.Host = "sisilogin.testeveonline.com";
     Crest.RequestHandler.ThrowOnDeprecated = true;
     Crest.RequestHandler.ThrowOnMissingContentType = true;
     Crest.EnableAutomaticPaging = true;
     Crest.RequestHandler.CacheLevel = CacheLevel.BypassCache;
 }
Пример #9
0
 public EveCrest_Singularity_Tests()
 {
     Crest              = new EveCrest(refreshToken, encodedKey);
     Crest.Host         = "https://api-sisi.testeveonline.com/";
     Crest.EveAuth.Host = "sisilogin.testeveonline.com";
     Crest.RequestHandler.ThrowOnDeprecated         = true;
     Crest.RequestHandler.ThrowOnMissingContentType = true;
     Crest.EnableAutomaticPaging     = true;
     Crest.RequestHandler.CacheLevel = CacheLevel.BypassCache;
 }
Пример #10
0
        /// <summary>
        ///     Queries a collection resource for a single item, async.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public async Task <TOut> QueryAsync <TOut>(Func <IEnumerable <TItem>, Href <TOut> > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            //var collection = this;
            //var list = collection.Items.ToList();
            //if (EveCrest.EnableAutomaticPaging) {
            //    while (collection.Next != null) {
            //        collection = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);
            //        list.AddRange(collection.Items);
            //    }
            //}
            var item = objFunc.Invoke(this);

            return(await EveCrest.LoadAsync(item).ConfigureAwait(false));
        }
Пример #11
0
        protected override void _ExecuteInConsole(IConsole console)
        {
            string retval = "";
            EveCrest crest = new EveCrest();

            var regions = crest.GetRoot().Query(r => r.Regions);
            var list = regions.Items.ToList();
            foreach (var region in list)
            {
                retval += region.Name;
                retval += "\n";
            }

            console.Write(retval);
        }
Пример #12
0
        /// <summary>
        ///     Gets all items in the collection as an asynchronous operation.
        /// </summary>
        /// <returns>Task&lt;IEnumerable&lt;TCollection&gt;&gt;.</returns>
        public async Task <IEnumerable <TItem> > AllItemsAsync()
        {
            var collection = this;
            var list       = collection.Items.ToList();

            while (collection.Next != null)
            {
                if (collection.NextResource == null)
                {
                    collection.NextResource = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);
                }
                collection = collection.NextResource;
                list.AddRange(collection.Items);
            }
            return(list);
        }
Пример #13
0
        protected override void _ExecuteInConsole(IConsole console)
        {
            string   retval = "";
            EveCrest crest  = new EveCrest();

            var regions = crest.GetRoot().Query(r => r.Regions);
            var list    = regions.Items.ToList();

            foreach (var region in list)
            {
                retval += region.Name;
                retval += "\n";
            }

            console.Write(retval);
        }
Пример #14
0
        /// <summary>
        /// Gets all items in the collection as an asynchronous operation.
        /// </summary>
        /// <returns>Task&lt;IEnumerable&lt;TCollection&gt;&gt;.</returns>
        public async Task <IEnumerable <TCollection> > AllItemsAsync()
        {
            CollectionResource <T, TCollection> collection = this;
            List <TCollection> list = collection.Items.ToList();

            if (EveCrest.EnableAutomaticPaging)
            {
                while (collection.Next != null)
                {
                    collection = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);

                    list.AddRange(collection.Items);
                }
            }
            return(list);
        }
Пример #15
0
        /// <summary>
        ///     Queries a collection resource for a single item, async.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public async Task <TOut> QueryAsync <TOut>(Func <IEnumerable <TCollection>, ILinkedEntity <TOut> > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            CollectionResource <T, TCollection> collection = this;
            List <TCollection> list = collection.Items.ToList();

            if (EveCrest.EnableAutomaticPaging)
            {
                while (collection.Next != null)
                {
                    collection = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);

                    list.AddRange(collection.Items);
                }
            }
            ILinkedEntity <TOut> item = objFunc.Invoke(list);

            return(await EveCrest.LoadAsync(item).ConfigureAwait(false));
        }
Пример #16
0
        /// <summary>
        /// Returns an enumerator that iterates through a collection.
        /// </summary>
        /// <returns>An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.</returns>
        IEnumerator IEnumerable.GetEnumerator()
        {
            foreach (var item in Items)
            {
                yield return(item);
            }
            if (Next == null || !EveCrest.EnableAutomaticPaging)
            {
                yield break;
            }
            if (NextResource == null)
            {
                NextResource = EveCrest.Load(Next);
            }
            var iter = NextResource.GetEnumerator();

            while (iter.MoveNext())
            {
                yield return(iter.Current);
            }
        }
Пример #17
0
        public static void Main(string[] args)
        {
            // There are alternate views for things requiring a preamble.
            var crest = new EveCrest();
            var root = crest.GetRoot();

            // Note collections hold only the first 1000 or so items. To get an enumerable
            // over all, one might use the AllItems utility method.

            // The following is an illustration of one way to get the region ID for a given
            // named region.
            var regions = root.Query(r => r.Regions);
            const string regionName = "Deklein";
            var regionId = regions.AllItems().First(r => r.Name == regionName).Id;
            Console.WriteLine("Id for region '{0}' is {1}", regionName, regionId);

            // Now get the market type ID for generic small antimatter.
            var marketTypes = crest.Load(root.MarketTypes);
            const string itemName = "Antimatter Charge S";
            var itemId = marketTypes.AllItems().Select(i => i.Type).First(t => t.Name == itemName).Id;
            Console.WriteLine("Id for market item '{0}' is {1}", itemName, itemId);

            // The following call is deprecated as it is not idiomatic w.r.t. CREST, but it's
            // unclear to me what its replacement actually is.
            var hist = crest.GetMarketHistory(regionId, itemId);
            double monies = 0;
            long items = 0;
            foreach (var item in hist.AllItems())
            {
                monies += item.AvgPrice * item.Volume;
                items += item.Volume;
            }
            // These reports seem to span 13 total months.
            Console.WriteLine("Avg for '{0}' in '{1}' is {2} across {3} total ISK volume", itemName, regionName, monies / items, monies);

            // That's actually rather more than I expected. Who finds it effective to brawl with
            // antimatter charge S in nullsec, against the NPCs we often see here?
        }
Пример #18
0
        private async Task produce(int region, int typeId, EveData.MarketData.MarketHistoryEntry latest)
        {
            CrestMarketHistory result;

            while (true)
            {
                try {
                    result = await EveCrest.GetMarketHistoryAsync(region, typeId).ConfigureAwait(false);

                    break;
                } catch (Exception) {
                    Console.WriteLine("Something went wrong, waiting...");
                    Thread.Sleep(30000);
                }
            }
            var limit   = DateTime.UtcNow.AddMonths(-3);
            var history = result.Entries.Where(e => e.Date > limit).ToList();

            if (latest != null)
            {
                history = history.Where(e => e.Date > latest.Date).ToList();
            }
            Queue.Add(new ConsumerTask(typeId, region, history));
        }
Пример #19
0
 /// <summary>
 ///     Queries the resource asynchronously.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public Task <TOut> QueryAsync <TOut>(Func <T, ILinkedEntity <TOut> > objFunc)
     where TOut : class, ICrestResource <TOut>
 {
     return(EveCrest.LoadAsync(objFunc.Invoke(this as T)));
 }
Пример #20
0
 /// <summary>
 ///     Queries the resource.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public virtual TOut Query <TOut>(Func <T, Href <TOut> > objFunc)
     where TOut : class, ICrestResource <TOut>
 {
     return(EveCrest.Load(objFunc.Invoke(this as T)));
 }
Пример #21
0
 /// <summary>
 /// Queries the asynchronous.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <typeparam name="TParam">The type of the t parameter.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <param name="param">The parameter.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public Task <TOut> QueryAsync <TOut, TParam>(Func <T, Href <TOut> > objFunc, LinkedEntity <TParam> param)
     where TOut : class, ICrestResource <TOut> where TParam : IQueryParameter <TParam>
 {
     return(EveCrest.LoadAsync(objFunc.Invoke(this as T), param));
 }
Пример #22
0
 /// <summary>
 /// Injects the specified crest.
 /// </summary>
 /// <param name="crest">The crest.</param>
 public virtual void Inject(EveCrest crest)
 {
     EveCrest = crest;
 }
Пример #23
0
 public EveService(EveAuth eveAuth, EveCrest eveCrest)
 {
     _eveAuth  = eveAuth;
     _eveCrest = eveCrest;
 }
Пример #24
0
 public EveService(string refreshToken)
 {
     _eveAuth  = new EveAuth();
     _eveCrest = new EveCrest(refreshToken, GenerateEncryptedKey());
 }
Пример #25
0
 /// <summary>
 /// Queries the resource.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public virtual TOut Query <TOut>(Func <T, Href <TOut> > objFunc, params string[] parameters)
     where TOut : class, ICrestResource <TOut>
 {
     return(EveCrest.Load(objFunc.Invoke(this as T), parameters));
 }
Пример #26
0
 /// <summary>
 /// Queries the resource asynchronously.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public Task <TOut> QueryAsync <TOut>(Func <T, Href <TOut> > objFunc, params string[] parameters)
     where TOut : class, ICrestResource <TOut>
 {
     return(EveCrest.LoadAsync(objFunc.Invoke(this as T), parameters));
 }
Пример #27
0
 /// <summary>
 /// Saves this instance.
 /// </summary>
 /// <param name="forcePostRequest">if set to <c>true</c> [force post request].</param>
 /// <returns>Task.</returns>
 public Task <bool> SaveAsync(bool forcePostRequest = false)
 {
     return(EveCrest.SaveEntityAsync(this, forcePostRequest));
 }
Пример #28
0
 /// <summary>
 ///     Deletes this instance.
 /// </summary>
 /// <returns>Task.</returns>
 public Task <bool> DeleteAsync()
 {
     return(EveCrest.DeleteEntityAsync(this));
 }
Пример #29
0
 public MarketHistoryUpdater()
 {
     EveCrest          = new EveCrest();
     StaticDataContext = new EveStaticData();
     Queue             = new BlockingCollection <ConsumerTask>();
 }