コード例 #1
0
ファイル: BaseValue.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the BaseValue class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        protected BaseValue(IEveRepository repository, TEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");

            this.id = this.ConvertEntityId(entity.Id);
        }
コード例 #2
0
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the ReadOnlyRepositoryItemCollection class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> associated with the items in the
        /// collection.
        /// </param>
        /// <param name="capacity">
        /// The capacity of the collection.
        /// </param>
        public ReadOnlyRepositoryItemCollection(IEveRepository repository, int capacity) : base(capacity)
        {
            Contract.Requires(repository != null, "The repository associated with the collection cannot be null.");
            Contract.Requires(capacity >= 0, "The capacity cannot be less than zero.");

            this.repository = repository;
        }
コード例 #3
0
ファイル: RegionEntity.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <inheritdoc />
        public Region ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsRegion);
            return(new Region(repository, this.ItemInfo));
        }
コード例 #4
0
ファイル: StargateEntity.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <inheritdoc />
        public Stargate ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsStargate);
            return(new Stargate(repository, this.ItemInfo));
        }
コード例 #5
0
        /* Methods */

        /// <inheritdoc />
        public SolarSystem ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsSolarSystem);
            return(new SolarSystem(repository, this.ItemInfo));
        }
コード例 #6
0
ファイル: SolarSystem.cs プロジェクト: jhtodd/Eve
 /// <summary>
 /// Initializes a new instance of the SolarSystem class.
 /// </summary>
 /// <param name="repository">
 /// The <see cref="IEveRepository" /> which contains the entity adapter.
 /// </param>
 /// <param name="entity">
 /// The data entity that forms the basis of the adapter.
 /// </param>
 internal SolarSystem(IEveRepository repository, ItemEntity entity)
     : base(repository, entity)
 {
     Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
       Contract.Requires(entity != null, "The entity cannot be null.");
       Contract.Requires(entity.IsSolarSystem, "The entity must be a solar system.");
 }
コード例 #7
0
        /* Methods */

        /// <inheritdoc />
        public Agent ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsAgent);
            return(new Agent(repository, this.ItemInfo));
        }
コード例 #8
0
ファイル: UniverseEntity.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <inheritdoc />
        public Universe ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsUniverse);
            return(new Universe(repository, this.ItemInfo));
        }
コード例 #9
0
        /* Methods */

        /// <inheritdoc />
        public NpcCorporation ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsCorporation);
            return(new NpcCorporation(repository, this.ItemInfo));
        }
コード例 #10
0
ファイル: Celestial.cs プロジェクト: jhtodd/Eve
 /* Constructors */
 /// <summary>
 /// Initializes a new instance of the Celestial class.
 /// </summary>
 /// <param name="repository">
 /// The <see cref="IEveRepository" /> which contains the entity adapter.
 /// </param>
 /// <param name="entity">
 /// The data entity that forms the basis of the adapter.
 /// </param>
 internal Celestial(IEveRepository repository, ItemEntity entity)
     : base(repository, entity)
 {
     Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
       Contract.Requires(entity != null, "The entity cannot be null.");
       Contract.Requires(entity.IsCelestial, "The entity must be a celestial object.");
 }
コード例 #11
0
ファイル: Item.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the Item class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        protected Item(IEveRepository repository, ItemEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");

            this.id = entity.Id;
        }
コード例 #12
0
ファイル: Item.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <summary>
        /// Creates an appropriate item for the specified entity.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity.
        /// </param>
        /// <returns>
        /// An <see cref="Item" /> of the appropriate derived type, based on the
        /// contents of <paramref name="entity" />.
        /// </returns>
        public static Item Create(IEveRepository repository, ItemEntity entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
            Contract.Ensures(Contract.Result <Item>() != null);

            if (entity.IsAgent)
            {
                return(new Agent(repository, entity));
            }

            if (entity.IsCelestial)
            {
                return(new Celestial(repository, entity));
            }

            if (entity.IsConstellation)
            {
                return(new Constellation(repository, entity));
            }

            if (entity.IsCorporation)
            {
                return(new NpcCorporation(repository, entity));
            }

            if (entity.IsFaction)
            {
                return(new Character.Faction(repository, entity));
            }

            if (entity.IsRegion)
            {
                return(new Region(repository, entity));
            }

            if (entity.IsSolarSystem)
            {
                return(new SolarSystem(repository, entity));
            }

            if (entity.IsStargate)
            {
                return(new Stargate(repository, entity));
            }

            if (entity.IsStation)
            {
                return(new Station(repository, entity));
            }

            if (entity.IsUniverse)
            {
                return(new Universe.Universe(repository, entity));
            }

            // If we've failed to identify the specific item type, fall back on a
            // generic item.
            return(new GenericItem(repository, entity));
        }
コード例 #13
0
ファイル: CelestialEntity.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <inheritdoc />
        public Celestial ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null);
            Contract.Assume(this.ItemInfo != null);
            Contract.Assume(this.ItemInfo.IsCelestial);
            return(new Celestial(repository, this.ItemInfo));
        }
コード例 #14
0
ファイル: Station.cs プロジェクト: jhtodd/Eve
 /* Constructors */
 /// <summary>
 /// Initializes a new instance of the Station class.
 /// </summary>
 /// <param name="repository">
 /// The <see cref="IEveRepository" /> which contains the entity adapter.
 /// </param>
 /// <param name="entity">
 /// The data entity that forms the basis of the adapter.
 /// </param>
 internal Station(IEveRepository repository, ItemEntity entity)
     : base(repository, entity)
 {
     Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
       Contract.Requires(entity != null, "The entity cannot be null.");
       Contract.Requires(entity.IsStation, "The entity must be a station.");
 }
コード例 #15
0
ファイル: EveEntityAdapter.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the EveEntityAdapter class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        protected EveEntityAdapter(IEveRepository repository, TEntity entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");

            this.entity     = entity;
            this.repository = repository;
        }
コード例 #16
0
ファイル: NpcCorporationInvestor.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the <see cref="NpcCorporationInvestor" /> class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="investorId">
        /// The ID of the investing corporation.
        /// </param>
        /// <param name="shares">
        /// The percentage of shares owned by the investing corporation.
        /// </param>
        internal NpcCorporationInvestor(IEveRepository repository, NpcCorporationId investorId, byte shares)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");

            this.repository = repository;
            this.investorId = investorId;
            this.shares     = shares;
        }
コード例 #17
0
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the SkillLevel class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="skillId">
        /// The ID of the skill.
        /// </param>
        /// <param name="level">
        /// The level of the skill.
        /// </param>
        public SkillLevel(IEveRepository repository, SkillId skillId, byte level)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(level <= SkillType.MaxSkillLevel, Resources.Messages.ISkill_LevelMustBeValid);

            this.repository = repository;
            this.level      = level;
            this.skillId    = skillId;
        }
コード例 #18
0
ファイル: ReadOnlyItemCollection.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <summary>
        /// Creates a new instance of the ReadOnlyItemCollection class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> associated with the items in the
        /// collection.
        /// </param>
        /// <param name="contents">
        /// The contents of the collection.
        /// </param>
        /// <returns>
        /// A newly created collection containing the specified items.
        /// </returns>
        public static ReadOnlyItemCollection Create(IEveRepository repository, IEnumerable <Item> contents)
        {
            Contract.Requires(repository != null, "The provided repository cannot be null.");

            var result = new ReadOnlyItemCollection(repository, contents == null ? 0 : contents.Count());

            if (contents != null)
            {
                foreach (var item in contents)
                {
                    result.Items.AddWithoutCallback(item);
                }
            }

            return(result);
        }
コード例 #19
0
ファイル: EveType.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <summary>
        /// Creates an appropriate type for the specified entity.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity.
        /// </param>
        /// <returns>
        /// An <see cref="EveType" /> of the appropriate derived type, based on the
        /// contents of <paramref name="entity" />.
        /// </returns>
        public static EveType Create(IEveRepository repository, EveTypeEntity entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
            Contract.Ensures(Contract.Result <EveType>() != null);

            // First, check for derived entity types.  These are entities that
            // have additional fields in ancillary tables.

            // BlueprintTypeEntities always map to StationType
            BlueprintTypeEntity blueprintTypeEntity = entity as BlueprintTypeEntity;

            if (blueprintTypeEntity != null)
            {
                return(new BlueprintType(repository, blueprintTypeEntity));
            }

            // StationTypeEntities always map to StationType
            StationTypeEntity stationTypeEntity = entity as StationTypeEntity;

            if (stationTypeEntity != null)
            {
                return(new StationType(repository, stationTypeEntity));
            }

            // For the remainder, the actual entity is the same type, and we need to
            // determine the EVE type based on its property values.

            // Use the item's group and category to determine the correct derived type
            Group group = repository.GetGroupById(entity.GroupId);

            switch (group.CategoryId)
            {
            // All items under category Skill map to SkillType
            case CategoryId.Skill:
                return(new SkillType(repository, entity));
            }

            // If we don't have a specific derived type for the provided entity,
            // fall back on a GenericType wrapper.
            return(new GenericType(repository, entity));
        }
コード例 #20
0
ファイル: AttributeValue.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the AttributeValue class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        public AttributeValue(IEveRepository repository, AttributeValueEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #21
0
ファイル: Station.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the Station class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal Station(IEveRepository repository, ItemEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
            Contract.Requires(entity.IsStation, "The entity must be a station.");
        }
コード例 #22
0
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the CertificateRelationship class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal CertificateRelationship(IEveRepository repository, CertificateRelationshipEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #23
0
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the GenericItem class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal GenericItem(IEveRepository repository, ItemEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #24
0
ファイル: TypeMaterial.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the TypeMaterial class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal TypeMaterial(IEveRepository repository, TypeMaterialEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #25
0
ファイル: MarketGroup.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the MarketGroup class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal MarketGroup(IEveRepository repository, MarketGroupEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #26
0
ファイル: ReadOnlyItemCollection.cs プロジェクト: jhtodd/Eve
        /// <summary>
        /// Creates a new instance of the ReadOnlyItemCollection class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> associated with the items in the
        /// collection.
        /// </param>
        /// <param name="entities">
        /// A sequence of entities from which to create the contents of the collection.
        /// </param>
        /// <returns>
        /// A newly created collection containing the specified items.
        /// </returns>
        public static ReadOnlyItemCollection Create(IEveRepository repository, IEnumerable <ItemEntity> entities)
        {
            Contract.Requires(repository != null, "The provided repository cannot be null.");

            return(Create(repository, entities == null ? null : entities.Select(x => x.ToAdapter(repository)).OrderBy(x => x)));
        }
コード例 #27
0
ファイル: ReadOnlyItemCollection.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the ReadOnlyItemCollection class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> associated with the items in the
        /// collection.
        /// </param>
        /// <param name="capacity">
        /// The capacity of the collection.
        /// </param>
        internal ReadOnlyItemCollection(IEveRepository repository, int capacity) : base(repository, capacity)
        {
            Contract.Requires(repository != null, "The provided repository cannot be null.");
            Contract.Requires(capacity >= 0, "The capacity cannot be less than zero.");
        }
コード例 #28
0
        /// <summary>
        /// Creates a new instance of the ReadOnlyEveTypeCollection class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> associated with the items in the
        /// collection.
        /// </param>
        /// <param name="entities">
        /// A sequence of entities from which to create the contents of the collection.
        /// </param>
        /// <returns>
        /// A newly created collection containing the specified items.
        /// </returns>
        public static ReadOnlyEveTypeCollection <TEveType> Create(IEveRepository repository, IEnumerable <EveTypeEntity> entities)
        {
            Contract.Requires(repository != null, "The provided repository cannot be null.");

            return(Create(repository, entities == null ? null : entities.Select(x => x.ToAdapter(repository)).Cast <TEveType>()));
        }
コード例 #29
0
 /// <inheritdoc />
 public override AssemblyLineTypeGroupDetail ToAdapter(IEveRepository repository)
 {
     Contract.Assume(repository != null); // TODO: Should not be necessary due to base class requires -- check in future version of static checker
     return(new AssemblyLineTypeGroupDetail(repository, this));
 }
コード例 #30
0
ファイル: EveType.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the EveType class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        protected EveType(IEveRepository repository, EveTypeEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #31
0
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the SolarSystemJump class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal SolarSystemJump(IEveRepository repository, SolarSystemJumpEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #32
0
ファイル: AssemblyLineStation.cs プロジェクト: jhtodd/Eve
        /* Constructors */

        /// <summary>
        /// Initializes a new instance of the AssemblyLineStation class.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity that forms the basis of the adapter.
        /// </param>
        internal AssemblyLineStation(IEveRepository repository, AssemblyLineStationEntity entity) : base(repository, entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
        }
コード例 #33
0
ファイル: CertificateEntity.cs プロジェクト: jhtodd/Eve
        /* Methods */

        /// <inheritdoc />
        public override Certificate ToAdapter(IEveRepository repository)
        {
            Contract.Assume(repository != null); // TODO: Should not be necessary due to base class requires -- check in future version of static checker
            return(new Certificate(repository, this));
        }
コード例 #34
0
ファイル: GenericType.cs プロジェクト: jhtodd/Eve
 /* Constructors */
 /// <summary>
 /// Initializes a new instance of the GenericType class.
 /// </summary>
 /// <param name="repository">
 /// The <see cref="IEveRepository" /> which contains the entity adapter.
 /// </param>
 /// <param name="entity">
 /// The data entity that forms the basis of the adapter.
 /// </param>
 internal GenericType(IEveRepository repository, EveTypeEntity entity)
     : base(repository, entity)
 {
     Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
       Contract.Requires(entity != null, "The entity cannot be null.");
 }