예제 #1
0
        /// <summary>
        /// Constructor from the API.
        /// </summary>
        /// <param name="ccpCharacter">The CCP character.</param>
        /// <param name="src">The source.</param>
        /// <exception cref="System.ArgumentNullException">src</exception>
        internal Contract(CCPCharacter ccpCharacter, SerializableContractListItem src)
        {
            src.ThrowIfNull(nameof(src));

            Character = ccpCharacter;
            PopulateContractInfo(src);
            m_state = GetState(src);
        }
예제 #2
0
        /// <summary>
        /// Populates the serialization object contract with the info from the API.
        /// </summary>
        /// <param name="src">The source.</param>
        /// <exception cref="System.ArgumentNullException">src</exception>
        private void PopulateContractInfo(SerializableContractListItem src)
        {
            src.ThrowIfNull(nameof(src));

            m_method = src.APIMethod;

            ID = src.ContractID;
            IssuerID = src.IssuerID;
            AssigneeID = src.AssigneeID;
            Description = String.IsNullOrWhiteSpace(src.Title) ? "(None)" : src.Title;
            IssuedFor = src.ForCorp ? IssuedFor.Corporation : IssuedFor.Character;
            Issued = src.DateIssued;
            Expiration = src.DateExpired;
            Duration = Convert.ToInt32(src.DateExpired.Subtract(src.DateIssued).TotalDays);
            DaysToComplete = src.NumDays;
            Price = src.Price;
            Reward = src.Reward;
            Collateral = src.Collateral;
            Buyout = src.Buyout;
            Volume = src.Volume;
            m_startStationID = src.StartStationID;
            m_endStationID = src.EndStationID;
            UpdateStation();
            UpdateContractInfo(src);

            Availability = Enum.IsDefined(typeof(ContractAvailability), src.Availability)
                ? (ContractAvailability)Enum.Parse(typeof(ContractAvailability), src.Availability)
                : ContractAvailability.None;

            ContractType = Enum.IsDefined(typeof(ContractType), src.Type)
                ? (ContractType)Enum.Parse(typeof(ContractType), src.Type)
                : ContractType.None;

            m_issuer = src.ForCorp
                ? Character.Corporation.Name
                : src.IssuerID == Character.CharacterID
                    ? Character.Name
                    : EveIDToName.GetIDToName(src.IssuerID);


            m_assignee = src.AssigneeID == Character.CharacterID
                ? Character.Name
                : src.AssigneeID == Character.CorporationID
                    ? Character.Corporation.Name
                    : EveIDToName.GetIDToName(src.AssigneeID);


            if (ContractType != ContractType.Courier)
                GetContractItems();
        }