Ejemplo n.º 1
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (ContractId != null)
                {
                    hashCode = hashCode * 59 + ContractId.GetHashCode();
                }

                hashCode = hashCode * 59 + Agency.GetHashCode();
                if (Person != null)
                {
                    hashCode = hashCode * 59 + Person.GetHashCode();
                }
                if (Grade != null)
                {
                    hashCode = hashCode * 59 + Grade.GetHashCode();
                }
                if (Rates != null)
                {
                    hashCode = hashCode * 59 + Rates.GetHashCode();
                }
                return(hashCode);
            }
        }
Ejemplo n.º 2
0
        private void ConvertThroughProto(ContractId source)
        {
            Com.DigitalAsset.Ledger.Api.V1.Value protoValue = source.ToProto();
            var maybe = Value.FromProto(protoValue).AsContractId();

            Assert.AreEqual(typeof(Some <ContractId>), maybe.GetType());
            Assert.IsTrue(source == (Some <ContractId>)maybe);
        }
Ejemplo n.º 3
0
        private void ConvertThroughProto(ContractId source)
        {
            Com.Daml.Ledger.Api.V1.Value protoValue = source.ToProto();
            var maybe = Value.FromProto(protoValue).AsContractId();

            maybe.Should().BeOfType <Some <ContractId> >();
            Assert.True(source == (Some <ContractId>)maybe);
        }
Ejemplo n.º 4
0
        public void HashCodeHasValueSemantics()
        {
            var contract1 = new ContractId(_commonId);
            var contract2 = new ContractId(_commonId);
            var contract3 = new ContractId(Guid.NewGuid().ToString());

            Assert.IsTrue(contract1.GetHashCode() == contract2.GetHashCode());
            Assert.IsTrue(contract1.GetHashCode() != contract3.GetHashCode());
        }
Ejemplo n.º 5
0
        public void EqualityHasValueSemantics()
        {
            var contract1 = new ContractId(_commonId);
            var contract2 = new ContractId(_commonId);
            var contract3 = new ContractId(Guid.NewGuid().ToString());

            Assert.IsTrue(contract1.Equals(contract1));
            Assert.IsTrue(contract1 == contract1);

            Assert.IsTrue(contract1.Equals(contract2));
            Assert.IsTrue(contract1 == contract2);

            Assert.IsFalse(contract1.Equals(contract3));
            Assert.IsTrue(contract1 != contract3);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomTokenSerializer">A delegate to serialize custom token JSON objects.</param>
        /// <param name="CustomEnergyContractSerializer">A delegate to serialize custom energy contract JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <Token> CustomTokenSerializer = null,
                              CustomJObjectSerializerDelegate <EnergyContract> CustomEnergyContractSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("country_code", CountryCode.ToString()),
                new JProperty("party_id", PartyId.ToString()),
                new JProperty("uid", Id.ToString()),
                new JProperty("type", Type.ToString()),
                new JProperty("contract_id", ContractId.ToString()),

                VisualNumber.IsNotNullOrEmpty()
                               ? new JProperty("visual_number", VisualNumber)
                               : null,

                new JProperty("issuer", Issuer),

                GroupId.HasValue
                               ? new JProperty("group_id", GroupId.ToString())
                               : null,

                new JProperty("valid", IsValid),
                new JProperty("whitelist", WhitelistType.ToString()),

                UILanguage.HasValue
                               ? new JProperty("language", UILanguage.ToString())
                               : null,

                DefaultProfile.HasValue
                               ? new JProperty("default_profile_type", DefaultProfile.ToString())
                               : null,

                EnergyContract.HasValue
                               ? new JProperty("energy_contract", EnergyContract.Value.ToJSON(CustomEnergyContractSerializer))
                               : null,

                new JProperty("last_updated", LastUpdated.ToIso8601())

                );

            return(CustomTokenSerializer != null
                       ? CustomTokenSerializer(this, JSON)
                       : JSON);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns true if BookingInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of BookingInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BookingInfo other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ContractId == other.ContractId ||
                     ContractId != null &&
                     ContractId.Equals(other.ContractId)
                     ) &&
                 (
                     Agency == other.Agency ||

                     Agency.Equals(other.Agency)
                 ) &&
                 (
                     Person == other.Person ||
                     Person != null &&
                     Person.Equals(other.Person)
                 ) &&
                 (
                     Grade == other.Grade ||
                     Grade != null &&
                     Grade.Equals(other.Grade)
                 ) &&
                 (
                     Rates == other.Rates ||
                     Rates != null &&
                     other.Rates != null &&
                     Rates.SequenceEqual(other.Rates)
                 ));
        }
Ejemplo n.º 8
0
 public override int GetHashCode()
 {
     return(AppId.GetHashCode() ^ PackageId.GetHashCode() ^ ContractId.GetHashCode() ^ Description.GetHashCode()
            ^ DisplayName.GetHashCode() ^ Icon.GetHashCode() ^ Vendor.GetHashCode() ^ COMUtilities.GetHashCodeDictionary(CustomProperties)
            ^ Source.GetHashCode());
 }
Ejemplo n.º 9
0
 public AddContract(ContractId contract) : base(EmoteType.AddContract)
 {
     Stat = (int)contract;
 }
Ejemplo n.º 10
0
        public RemoveContract(ContractId contract)

            : base(EmoteType.RemoveContract)
        {
            Stat = (int)contract;
        }
Ejemplo n.º 11
0
 public override string ToString()
 {
     return($"{ContractId.PadRight(20)}\t{MobileNumber.PadRight(20)}\t{TarifPackage.PadRight(40)}");;
 }