예제 #1
0
        /// <summary>
        /// Initializes a new instance of the ScryfallClient.
        /// </summary>
        public ScryfallClient() : base("https://api.scryfall.com")
        {
            Sets      = new Sets(this);
            Cards     = new Cards(this);
            Rulings   = new Rulings(this);
            Symbology = new Symbology(this);
            Catalog   = new CatalogOperations(this);

            SerializationSettings = new JsonSerializerSettings {
                Formatting            = Formatting.Indented,
                DateFormatHandling    = DateFormatHandling.IsoDateFormat,
                DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
                NullValueHandling     = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                ContractResolver      = new ReadOnlyJsonContractResolver(),
                Converters            = new List <JsonConverter> {
                    new Iso8601TimeSpanConverter()
                }
            };
            DeserializationSettings = new JsonSerializerSettings {
                DateFormatHandling    = DateFormatHandling.IsoDateFormat,
                DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
                NullValueHandling     = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                ContractResolver      = new ReadOnlyJsonContractResolver(),
                Converters            = new List <JsonConverter> {
                    new Iso8601TimeSpanConverter()
                }
            };
        }
예제 #2
0
        private void ini()
        {
            if (ctxt.Cards.Any())
            {
                return;
            }

            var _colors = SeedColors();

            Color FindColor(string name) => _colors.Where(f => f.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            var _types = SeedTypes();

            Types FindType(string name) => _types.Where(f => f.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();


            var _sets = SeedSets();

            Sets FindSets(string name) => _sets.Where(f => f.SetAbbr.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            var _abilities = SeedAbilities();

            Abilities FindAbility(string ability) => _abilities.Where(a => a.Ability.Equals(ability, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();



            //var Sets = new Sets[]
            //{
            //    new Sets{ SetAbbr="AER", SetFullName="Aether Revolt"},
            //};

            //ctxt.Sets.AddRange(Sets);
            //ctxt.SaveChanges(true);

            //var types = new Types[]
            //{
            //    new Types{ ID=1, Name="Artifact Creature" },
            //    new Types{ ID=2, Name="Construct"}
            //};

            //ctxt.Types.AddRange(types);
            //ctxt.SaveChanges(true);

            //var abilities = new Abilities[]
            //{
            //    new Abilities{ AbilityID =1, Ability="{4}{W}: Return another target creature you control to its owner's hand."}
            //};

            //ctxt.Abilities.AddRange(abilities);
            //ctxt.SaveChanges(true);

            //var colors = new Color[]
            //{
            //    new Color{ Name="Colorless" }
            //};

            //ctxt.Color.AddRange(colors);
            //ctxt.SaveChanges(true);


            var Cards = new Card[]
            {
                new Card {
                    MultiverseID = "423808", Artist = "Kieran Yanner", CardName = "Aegis Automaton", FlavorText = "#_The streets of Ghirapur have become dangerous. It's good to have a dependable companion._#", HighPrice = 0.95, LowPrice = 0.01, MidPrice = 0.1, Power = 0, Toughness = 3, RarityId = "C", Rating = 5
                }
            };

            ctxt.Cards.AddRange(Cards);
            ctxt.SaveChanges(true);

            var CardTypes = new CardTypes[]
            {
                new MagicDbContext.Models.CardTypes {
                    TypeID = FindType("Artifact").ID, CardID = "423808"
                },
                new CardTypes {
                    TypeID = FindType("Creature").ID, CardID = "423808"
                },
                new CardTypes {
                    TypeID = FindType("Construct").ID, CardID = "423808"
                }
            };

            ctxt.CardTypes.AddRange(CardTypes);
            ctxt.SaveChanges(true);

            var Rulings = new Rulings[]
            {
                new Rulings {
                    CardID = "423808", Ruling = ""
                }
            };

            ctxt.Rulings.AddRange(Rulings);
            ctxt.SaveChanges(true);

            var cardAbilities = new CardAbilities[]
            {
                new CardAbilities {
                    AbilityID = FindAbility("{4}{W}: Return another target creature you control to its owner's hand.").AbilityID, CardID = "423808"
                }
            };

            ctxt.CardAbilities.AddRange(cardAbilities);
            ctxt.SaveChanges(true);

            var manaCosts = new ManaCosts[]
            {
                new ManaCosts {
                    Quantity = 2, ColorID = FindColor("Colorless").ID, CardID = "423808"
                }
            };

            ctxt.ManaCosts.AddRange(manaCosts);
            ctxt.SaveChanges(true);

            //ctxt.Cards.Single(s=> s.MultiverseID==423808).SetID=0;

            //ctxt.Cards.AddRange(Cards);
            ctxt.SaveChanges(true);
        }