Exemplo 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 (InputAddress != null)
         {
             hashCode = hashCode * 59 + InputAddress.GetHashCode();
         }
         if (InputCoinType != null)
         {
             hashCode = hashCode * 59 + InputCoinType.GetHashCode();
         }
         if (OutputAddressNickname != null)
         {
             hashCode = hashCode * 59 + OutputAddressNickname.GetHashCode();
         }
         if (OutputCoinType != null)
         {
             hashCode = hashCode * 59 + OutputCoinType.GetHashCode();
         }
         if (RefundAddressNickname != null)
         {
             hashCode = hashCode * 59 + RefundAddressNickname.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 2
0
            public DatumAddress CreateAddress(int numericValue)
            {
                if (!IsValid(numericValue))
                {
                    throw new ArgumentOutOfRangeException();
                }

                var raw = ComputeAddress(numericValue);

                switch (Kind)
                {
                case DatumAddressKind.Coil:
                    return(CoilAddress.FromRawValue(raw));

                case DatumAddressKind.Input:
                    return(InputAddress.FromRawValue(raw));

                case DatumAddressKind.HoldingRegister:
                    return(HoldingRegisterAddress.FromRawValue(raw));

                case DatumAddressKind.InputRegister:
                    return(InputRegisterAddress.FromRawValue(raw));

                default:
                    throw new ApplicationException();
                }
            }
Exemplo n.º 3
0
        /// <summary>
        /// Returns true if SimpleFixedPriceTradeInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of SimpleFixedPriceTradeInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SimpleFixedPriceTradeInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     InputAddress == other.InputAddress ||
                     InputAddress != null &&
                     InputAddress.Equals(other.InputAddress)
                     ) &&
                 (
                     InputCoinType == other.InputCoinType ||
                     InputCoinType != null &&
                     InputCoinType.Equals(other.InputCoinType)
                 ) &&
                 (
                     InputAmount == other.InputAmount ||
                     InputAmount != null &&
                     InputAmount.Equals(other.InputAmount)
                 ) &&
                 (
                     OutputAddress == other.OutputAddress ||
                     OutputAddress != null &&
                     OutputAddress.Equals(other.OutputAddress)
                 ) &&
                 (
                     OutputCoinType == other.OutputCoinType ||
                     OutputCoinType != null &&
                     OutputCoinType.Equals(other.OutputCoinType)
                 ) &&
                 (
                     OutputAmount == other.OutputAmount ||
                     OutputAmount != null &&
                     OutputAmount.Equals(other.OutputAmount)
                 ) &&
                 (
                     RefundAddress == other.RefundAddress ||
                     RefundAddress != null &&
                     RefundAddress.Equals(other.RefundAddress)
                 ) &&
                 (
                     ExpirationTime == other.ExpirationTime ||
                     ExpirationTime != null &&
                     ExpirationTime.Equals(other.ExpirationTime)
                 ) &&
                 (
                     FlatTransactionFeeInInputCoinType == other.FlatTransactionFeeInInputCoinType ||
                     FlatTransactionFeeInInputCoinType != null &&
                     FlatTransactionFeeInInputCoinType.Equals(other.FlatTransactionFeeInInputCoinType)
                 ));
        }
Exemplo n.º 4
0
            public IDictionary <string, string> ToDictionary()
            {
                var dictionary = new Dictionary <string, string>
                {
                    { "InputAddress", InputAddress.ToString() },
                    { "Message", Message },
                };

                if (LastException != null)
                {
                    dictionary.Add("LastExceptionMessage", LastException?.Message);
                }

                return(dictionary);
            }
Exemplo n.º 5
0
        /// <summary>
        /// Returns true if SimpleTradeInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of SimpleTradeInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SimpleTradeInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     InputAddress == other.InputAddress ||
                     InputAddress != null &&
                     InputAddress.Equals(other.InputAddress)
                     ) &&
                 (
                     InputMemo == other.InputMemo ||
                     InputMemo != null &&
                     InputMemo.Equals(other.InputMemo)
                 ) &&
                 (
                     InputCoinType == other.InputCoinType ||
                     InputCoinType != null &&
                     InputCoinType.Equals(other.InputCoinType)
                 ) &&
                 (
                     OutputAddress == other.OutputAddress ||
                     OutputAddress != null &&
                     OutputAddress.Equals(other.OutputAddress)
                 ) &&
                 (
                     OutputCoinType == other.OutputCoinType ||
                     OutputCoinType != null &&
                     OutputCoinType.Equals(other.OutputCoinType)
                 ) &&
                 (
                     RefundAddress == other.RefundAddress ||
                     RefundAddress != null &&
                     RefundAddress.Equals(other.RefundAddress)
                 ) &&
                 (
                     FlatTransactionFeeInInputCoinType == other.FlatTransactionFeeInInputCoinType ||
                     FlatTransactionFeeInInputCoinType != null &&
                     FlatTransactionFeeInInputCoinType.Equals(other.FlatTransactionFeeInInputCoinType)
                 ));
        }
Exemplo n.º 6
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 (InputAddress != null)
         {
             hashCode = hashCode * 59 + InputAddress.GetHashCode();
         }
         if (InputCoinType != null)
         {
             hashCode = hashCode * 59 + InputCoinType.GetHashCode();
         }
         if (InputAmount != null)
         {
             hashCode = hashCode * 59 + InputAmount.GetHashCode();
         }
         if (OutputAddress != null)
         {
             hashCode = hashCode * 59 + OutputAddress.GetHashCode();
         }
         if (OutputCoinType != null)
         {
             hashCode = hashCode * 59 + OutputCoinType.GetHashCode();
         }
         if (OutputAmount != null)
         {
             hashCode = hashCode * 59 + OutputAmount.GetHashCode();
         }
         if (RefundAddress != null)
         {
             hashCode = hashCode * 59 + RefundAddress.GetHashCode();
         }
         if (ExpirationTime != null)
         {
             hashCode = hashCode * 59 + ExpirationTime.GetHashCode();
         }
         if (FlatTransactionFeeInInputCoinType != null)
         {
             hashCode = hashCode * 59 + FlatTransactionFeeInInputCoinType.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Returns true if MappingsModel1 instances are equal
        /// </summary>
        /// <param name="other">Instance of MappingsModel1 to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MappingsModel1 other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     InputAddress == other.InputAddress ||
                     InputAddress != null &&
                     InputAddress.Equals(other.InputAddress)
                     ) &&
                 (
                     InputCoinType == other.InputCoinType ||
                     InputCoinType != null &&
                     InputCoinType.Equals(other.InputCoinType)
                 ) &&
                 (
                     OutputAddressNickname == other.OutputAddressNickname ||
                     OutputAddressNickname != null &&
                     OutputAddressNickname.Equals(other.OutputAddressNickname)
                 ) &&
                 (
                     OutputCoinType == other.OutputCoinType ||
                     OutputCoinType != null &&
                     OutputCoinType.Equals(other.OutputCoinType)
                 ) &&
                 (
                     RefundAddressNickname == other.RefundAddressNickname ||
                     RefundAddressNickname != null &&
                     RefundAddressNickname.Equals(other.RefundAddressNickname)
                 ) &&
                 (
                     SessionToken == other.SessionToken ||
                     SessionToken != null &&
                     SessionToken.Equals(other.SessionToken)
                 ));
        }
Exemplo n.º 8
0
        public IActionResult UpsValidateAddress([FromBody] ODataActionParameters value)
        {
            if (!value.ContainsKey(Constants.Address.AddressLine1))
            {
                return((IActionResult) new BadRequestObjectResult((object)value));
            }
            if (!value.ContainsKey(Constants.Address.City))
            {
                return((IActionResult) new BadRequestObjectResult((object)value));
            }
            if (!value.ContainsKey(Constants.Address.State))
            {
                return((IActionResult) new BadRequestObjectResult((object)value));
            }
            if (!value.ContainsKey(Constants.Address.ZipCode))
            {
                return((IActionResult) new BadRequestObjectResult((object)value));
            }

            var inputAddress = new InputAddress
            {
                AddressLine1  = value[Constants.Address.AddressLine1].ToString(),
                City          = value[Constants.Address.City].ToString(),
                State         = value[Constants.Address.State].ToString(),
                ZipCode       = value[Constants.Address.ZipCode].ToString(),
                CountryCode   = "US", //value[Constants.Address.CountryCode].ToString(),
                AddressLine2  = value.ContainsKey(Constants.Address.AddressLine2) ? value[Constants.Address.AddressLine2].ToString() : string.Empty,
                ConsigneeName =
                    value.ContainsKey(Constants.Address.ConsigneeName) ? value[Constants.Address.ConsigneeName].ToString() : Constants.Address.DefaultConsigneeName,
                BuildingName = value.ContainsKey(Constants.Address.BuildingName) ? value[Constants.Address.BuildingName].ToString() : Constants.Address.DefaultBuildingName
            };

            var command = this.Command <UpsValidateAddressCommand>();
            var result  = command.Process(CurrentContext, inputAddress);

            return(new ObjectResult(result));
        }
Exemplo n.º 9
0
 private static Tuple <DatumAddress, Type, int> CreateInput(int numericValue, int baseValue)
 {
     return(Tuple.Create((DatumAddress)InputAddress.FromInteger(numericValue), typeof(bool), 1));
 }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Kind != 0)
            {
                hash ^= Kind.GetHashCode();
            }
            if (input_ != null)
            {
                hash ^= Input.GetHashCode();
            }
            if (filter_ != null)
            {
                hash ^= Filter.GetHashCode();
            }
            if (output_ != null)
            {
                hash ^= Output.GetHashCode();
            }
            if (convDesc_ != null)
            {
                hash ^= ConvDesc.GetHashCode();
            }
            if (ConvScale != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(ConvScale);
            }
            if (SideValueScale != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(SideValueScale);
            }
            if (Activation != 0)
            {
                hash ^= Activation.GetHashCode();
            }
            if (InputAddress != 0L)
            {
                hash ^= InputAddress.GetHashCode();
            }
            if (FilterAddress != 0L)
            {
                hash ^= FilterAddress.GetHashCode();
            }
            if (OutputAddress != 0L)
            {
                hash ^= OutputAddress.GetHashCode();
            }
            if (BiasAddress != 0L)
            {
                hash ^= BiasAddress.GetHashCode();
            }
            if (SideInputAddress != 0L)
            {
                hash ^= SideInputAddress.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 11
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 (TransactionId != null)
         {
             hashCode = hashCode * 59 + TransactionId.GetHashCode();
         }
         if (TransactionProcessingState != null)
         {
             hashCode = hashCode * 59 + TransactionProcessingState.GetHashCode();
         }
         if (InputFirstSeenTime != null)
         {
             hashCode = hashCode * 59 + InputFirstSeenTime.GetHashCode();
         }
         if (InputFullyConfirmedTime != null)
         {
             hashCode = hashCode * 59 + InputFullyConfirmedTime.GetHashCode();
         }
         if (InputNumberOfConfirmations != null)
         {
             hashCode = hashCode * 59 + InputNumberOfConfirmations.GetHashCode();
         }
         if (InputAmount != null)
         {
             hashCode = hashCode * 59 + InputAmount.GetHashCode();
         }
         if (InputTransactionHash != null)
         {
             hashCode = hashCode * 59 + InputTransactionHash.GetHashCode();
         }
         if (InputCoinType != null)
         {
             hashCode = hashCode * 59 + InputCoinType.GetHashCode();
         }
         if (InputWalletType != null)
         {
             hashCode = hashCode * 59 + InputWalletType.GetHashCode();
         }
         if (InputAddress != null)
         {
             hashCode = hashCode * 59 + InputAddress.GetHashCode();
         }
         if (PrimarySourceAddress != null)
         {
             hashCode = hashCode * 59 + PrimarySourceAddress.GetHashCode();
         }
         if (OutputInitiationTime != null)
         {
             hashCode = hashCode * 59 + OutputInitiationTime.GetHashCode();
         }
         if (OutputAmount != null)
         {
             hashCode = hashCode * 59 + OutputAmount.GetHashCode();
         }
         if (OutputTransactionHash != null)
         {
             hashCode = hashCode * 59 + OutputTransactionHash.GetHashCode();
         }
         if (OutputCoinType != null)
         {
             hashCode = hashCode * 59 + OutputCoinType.GetHashCode();
         }
         if (OutputWalletType != null)
         {
             hashCode = hashCode * 59 + OutputWalletType.GetHashCode();
         }
         if (OutputAddress != null)
         {
             hashCode = hashCode * 59 + OutputAddress.GetHashCode();
         }
         if (OutputMemo != null)
         {
             hashCode = hashCode * 59 + OutputMemo.GetHashCode();
         }
         if (OutputAddressNickname != null)
         {
             hashCode = hashCode * 59 + OutputAddressNickname.GetHashCode();
         }
         if (LastModifiedTime != null)
         {
             hashCode = hashCode * 59 + LastModifiedTime.GetHashCode();
         }
         if (RequiredNumberOfInputConfirmations != null)
         {
             hashCode = hashCode * 59 + RequiredNumberOfInputConfirmations.GetHashCode();
         }
         if (InputUsdEquivalent != null)
         {
             hashCode = hashCode * 59 + InputUsdEquivalent.GetHashCode();
         }
         if (DelegationId != null)
         {
             hashCode = hashCode * 59 + DelegationId.GetHashCode();
         }
         if (VestsDelegated != null)
         {
             hashCode = hashCode * 59 + VestsDelegated.GetHashCode();
         }
         if (SteemPowerDelegated != null)
         {
             hashCode = hashCode * 59 + SteemPowerDelegated.GetHashCode();
         }
         if (SteemPowerDelegatee != null)
         {
             hashCode = hashCode * 59 + SteemPowerDelegatee.GetHashCode();
         }
         if (DelegationExtensionDuration != null)
         {
             hashCode = hashCode * 59 + DelegationExtensionDuration.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Returns true if TransactionInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of TransactionInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TransactionInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     TransactionId == other.TransactionId ||
                     TransactionId != null &&
                     TransactionId.Equals(other.TransactionId)
                     ) &&
                 (
                     TransactionProcessingState == other.TransactionProcessingState ||
                     TransactionProcessingState != null &&
                     TransactionProcessingState.Equals(other.TransactionProcessingState)
                 ) &&
                 (
                     InputFirstSeenTime == other.InputFirstSeenTime ||
                     InputFirstSeenTime != null &&
                     InputFirstSeenTime.Equals(other.InputFirstSeenTime)
                 ) &&
                 (
                     InputFullyConfirmedTime == other.InputFullyConfirmedTime ||
                     InputFullyConfirmedTime != null &&
                     InputFullyConfirmedTime.Equals(other.InputFullyConfirmedTime)
                 ) &&
                 (
                     InputNumberOfConfirmations == other.InputNumberOfConfirmations ||
                     InputNumberOfConfirmations != null &&
                     InputNumberOfConfirmations.Equals(other.InputNumberOfConfirmations)
                 ) &&
                 (
                     InputAmount == other.InputAmount ||
                     InputAmount != null &&
                     InputAmount.Equals(other.InputAmount)
                 ) &&
                 (
                     InputTransactionHash == other.InputTransactionHash ||
                     InputTransactionHash != null &&
                     InputTransactionHash.Equals(other.InputTransactionHash)
                 ) &&
                 (
                     InputCoinType == other.InputCoinType ||
                     InputCoinType != null &&
                     InputCoinType.Equals(other.InputCoinType)
                 ) &&
                 (
                     InputWalletType == other.InputWalletType ||
                     InputWalletType != null &&
                     InputWalletType.Equals(other.InputWalletType)
                 ) &&
                 (
                     InputAddress == other.InputAddress ||
                     InputAddress != null &&
                     InputAddress.Equals(other.InputAddress)
                 ) &&
                 (
                     PrimarySourceAddress == other.PrimarySourceAddress ||
                     PrimarySourceAddress != null &&
                     PrimarySourceAddress.Equals(other.PrimarySourceAddress)
                 ) &&
                 (
                     OutputInitiationTime == other.OutputInitiationTime ||
                     OutputInitiationTime != null &&
                     OutputInitiationTime.Equals(other.OutputInitiationTime)
                 ) &&
                 (
                     OutputAmount == other.OutputAmount ||
                     OutputAmount != null &&
                     OutputAmount.Equals(other.OutputAmount)
                 ) &&
                 (
                     OutputTransactionHash == other.OutputTransactionHash ||
                     OutputTransactionHash != null &&
                     OutputTransactionHash.Equals(other.OutputTransactionHash)
                 ) &&
                 (
                     OutputCoinType == other.OutputCoinType ||
                     OutputCoinType != null &&
                     OutputCoinType.Equals(other.OutputCoinType)
                 ) &&
                 (
                     OutputWalletType == other.OutputWalletType ||
                     OutputWalletType != null &&
                     OutputWalletType.Equals(other.OutputWalletType)
                 ) &&
                 (
                     OutputAddress == other.OutputAddress ||
                     OutputAddress != null &&
                     OutputAddress.Equals(other.OutputAddress)
                 ) &&
                 (
                     OutputMemo == other.OutputMemo ||
                     OutputMemo != null &&
                     OutputMemo.Equals(other.OutputMemo)
                 ) &&
                 (
                     OutputAddressNickname == other.OutputAddressNickname ||
                     OutputAddressNickname != null &&
                     OutputAddressNickname.Equals(other.OutputAddressNickname)
                 ) &&
                 (
                     LastModifiedTime == other.LastModifiedTime ||
                     LastModifiedTime != null &&
                     LastModifiedTime.Equals(other.LastModifiedTime)
                 ) &&
                 (
                     RequiredNumberOfInputConfirmations == other.RequiredNumberOfInputConfirmations ||
                     RequiredNumberOfInputConfirmations != null &&
                     RequiredNumberOfInputConfirmations.Equals(other.RequiredNumberOfInputConfirmations)
                 ) &&
                 (
                     InputUsdEquivalent == other.InputUsdEquivalent ||
                     InputUsdEquivalent != null &&
                     InputUsdEquivalent.Equals(other.InputUsdEquivalent)
                 ) &&
                 (
                     DelegationId == other.DelegationId ||
                     DelegationId != null &&
                     DelegationId.Equals(other.DelegationId)
                 ) &&
                 (
                     VestsDelegated == other.VestsDelegated ||
                     VestsDelegated != null &&
                     VestsDelegated.Equals(other.VestsDelegated)
                 ) &&
                 (
                     SteemPowerDelegated == other.SteemPowerDelegated ||
                     SteemPowerDelegated != null &&
                     SteemPowerDelegated.Equals(other.SteemPowerDelegated)
                 ) &&
                 (
                     SteemPowerDelegatee == other.SteemPowerDelegatee ||
                     SteemPowerDelegatee != null &&
                     SteemPowerDelegatee.Equals(other.SteemPowerDelegatee)
                 ) &&
                 (
                     DelegationExtensionDuration == other.DelegationExtensionDuration ||
                     DelegationExtensionDuration != null &&
                     DelegationExtensionDuration.Equals(other.DelegationExtensionDuration)
                 ));
        }
        public virtual string Process(CommerceContext commerceContext, InputAddress inputAddress)
        {
            var upsClientPolicy = commerceContext.GetPolicy <UpsAddressValidationPolicy>();

            var url = upsClientPolicy.IsLive ? upsClientPolicy.ProdUrl : upsClientPolicy.TestUrl;

            var requestString = $@"{{
	            ""UPSSecurity"": {{
		            ""UsernameToken"": {{
			            ""Username"": ""{upsClientPolicy.UserName}"",
			            ""Password"": ""{upsClientPolicy.Password}""
		            }},
		            ""ServiceAccessToken"": {{
			            ""AccessLicenseNumber"": ""{upsClientPolicy.LicenseKey}""
		            }}
	            }},
	            ""XAVRequest"": {{
		            ""Request"": {{
			            ""RequestOption"": ""1"",
			            ""TransactionReference"": {{
				            ""CustomerContext"": ""Your Customer Context""
			            }}
		            }},
		            ""MaximumListSize"": ""10"",
		            ""AddressKeyFormat"": {{
			            ""ConsigneeName"": ""{inputAddress.ConsigneeName}"",
			            ""BuildingName"": ""{inputAddress.BuildingName}"",
			            ""AddressLine"": ""{inputAddress.AddressLine1}"",
			            ""PoliticalDivision2"": ""{inputAddress.City}"",
			            ""PoliticalDivision1"": ""{inputAddress.State}"",
			            ""PostcodePrimaryLow"": ""{inputAddress.ZipCode}"",
			            ""CountryCode"": ""{inputAddress.CountryCode}""
		            }}
	            }}
            }}";



            var client  = new HttpClient();
            var content = new StringContent(requestString, Encoding.UTF8, Constants.Headers.ContentType);

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(Constants.Headers.ContentType));
            content.Headers.ContentType = new MediaTypeHeaderValue(Constants.Headers.ContentType);
            client.DefaultRequestHeaders.Add(Constants.Headers.AcessControlHeaders, Constants.Headers.AllowHeaders);
            client.DefaultRequestHeaders.Add(Constants.Headers.AcessControlMethods, Constants.Headers.Methods);
            client.DefaultRequestHeaders.Add(Constants.Headers.AcessControlOrigin, Constants.Headers.Origin);

            try
            {
                var output = client.PostAsync(url, content).Result;
                output.EnsureSuccessStatusCode();

                var outputData = output.Content.ReadAsStringAsync().Result;

                return(outputData);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }

            return(string.Empty);
        }