Exemplo n.º 1
0
        /* 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);
        }
        /* 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;
        }
Exemplo n.º 3
0
        /* 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));
        }
Exemplo n.º 4
0
        /* 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 6
0
 /// <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.");
 }
Exemplo n.º 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));
        }
Exemplo n.º 8
0
        /* 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 10
0
 /* 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.");
 }
Exemplo n.º 11
0
Arquivo: Item.cs Projeto: 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;
        }
Exemplo n.º 12
0
Arquivo: Item.cs Projeto: 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));
        }
Exemplo n.º 13
0
        /* 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));
        }
Exemplo n.º 14
0
 /* 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.");
 }
Exemplo n.º 15
0
        /* 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;
        }
Exemplo n.º 16
0
        /* 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 18
0
        /* 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);
        }
Exemplo n.º 19
0
        /* 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));
        }
Exemplo n.º 20
0
        /* 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.");
        }
Exemplo n.º 21
0
        /* 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 24
0
        /* 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.");
        }
Exemplo n.º 25
0
        /* 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.");
        }
Exemplo n.º 26
0
        /// <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)));
        }
Exemplo n.º 27
0
        /* 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.");
        }
        /// <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>()));
        }
Exemplo n.º 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));
 }
Exemplo n.º 30
0
        /* 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 32
0
        /* 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.");
        }
Exemplo n.º 33
0
        /* 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));
        }
Exemplo n.º 34
0
 /* 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.");
 }