public static bool Equals(ICreateAttributeSetInstance state1, IAttributeSetInstanceStateProperties state2)
 {
     if (!SafeEquals <string>(state1.AttributeSetId, state2.AttributeSetId) ||
         !SafeEquals <string>(state1.OrganizationId, state2.OrganizationId) ||
         !SafeEquals <string>(state1.ReferenceId, state2.ReferenceId) ||
         !SafeEquals <string>(state1.SerialNumber, state2.SerialNumber) ||
         !SafeEquals <string>(state1.LotId, state2.LotId) ||
         !SafeEquals <string>(state1.Description, state2.Description) ||
         !SafeEquals <bool>(state1.Active, state2.Active) ||
         !SafeEquals <decimal>(state1.WidthInch, state2.WidthInch) ||
         !SafeEquals <decimal>(state1.DiameterInch, state2.DiameterInch) ||
         !SafeEquals <decimal>(state1.WeightLbs, state2.WeightLbs) ||
         !SafeEquals <decimal>(state1.WeightKg, state2.WeightKg) ||
         !SafeEquals <decimal>(state1.AirDryWeightLbs, state2.AirDryWeightLbs) ||
         !SafeEquals <decimal>(state1.AirDryWeightKg, state2.AirDryWeightKg) ||
         !SafeEquals <decimal>(state1.AirDryMetricTon, state2.AirDryMetricTon) ||
         !SafeEquals <int>(state1.PackageCount, state2.PackageCount) ||
         !SafeEquals <decimal>(state1.AirDryPct, state2.AirDryPct) ||
         !SafeEquals <bool>(state1._F_B_0_, state2._F_B_0_) ||
         !SafeEquals <int>(state1._F_I_0_, state2._F_I_0_) ||
         !SafeEquals <long>(state1._F_L_0_, state2._F_L_0_) ||
         !SafeEquals <DateTime>(state1._F_DT_0_, state2._F_DT_0_) ||
         !SafeEquals <decimal>(state1._F_N_0_, state2._F_N_0_) ||
         !SafeEquals <string>(state1._F_C5_0_, state2._F_C5_0_) ||
         !SafeEquals <string>(state1._F_C10_0_, state2._F_C10_0_) ||
         !SafeEquals <string>(state1._F_C20_0_, state2._F_C20_0_) ||
         !SafeEquals <string>(state1._F_C50_0_, state2._F_C50_0_) ||
         !SafeEquals <string>(state1._F_C100_0_, state2._F_C100_0_) ||
         !SafeEquals <string>(state1._F_C200_0_, state2._F_C200_0_) ||
         !SafeEquals <string>(state1._F_C500_0_, state2._F_C500_0_) ||
         !SafeEquals <string>(state1._F_C1000_0_, state2._F_C1000_0_) ||
         !SafeEquals <bool>(state1._F_B_1_, state2._F_B_1_) ||
         !SafeEquals <int>(state1._F_I_1_, state2._F_I_1_) ||
         !SafeEquals <long>(state1._F_L_1_, state2._F_L_1_) ||
         !SafeEquals <DateTime>(state1._F_DT_1_, state2._F_DT_1_) ||
         !SafeEquals <decimal>(state1._F_N_1_, state2._F_N_1_) ||
         !SafeEquals <string>(state1._F_C5_1_, state2._F_C5_1_) ||
         !SafeEquals <string>(state1._F_C10_1_, state2._F_C10_1_) ||
         !SafeEquals <string>(state1._F_C20_1_, state2._F_C20_1_) ||
         !SafeEquals <string>(state1._F_C50_1_, state2._F_C50_1_) ||
         !SafeEquals <string>(state1._F_C100_1_, state2._F_C100_1_) ||
         !SafeEquals <string>(state1._F_C200_1_, state2._F_C200_1_) ||
         !SafeEquals <bool>(state1._F_B_2_, state2._F_B_2_) ||
         !SafeEquals <int>(state1._F_I_2_, state2._F_I_2_) ||
         !SafeEquals <long>(state1._F_L_2_, state2._F_L_2_) ||
         !SafeEquals <DateTime>(state1._F_DT_2_, state2._F_DT_2_) ||
         !SafeEquals <decimal>(state1._F_N_2_, state2._F_N_2_) ||
         !SafeEquals <string>(state1._F_C5_2_, state2._F_C5_2_) ||
         !SafeEquals <string>(state1._F_C10_2_, state2._F_C10_2_) ||
         !SafeEquals <string>(state1._F_C20_2_, state2._F_C20_2_) ||
         !SafeEquals <string>(state1._F_C50_2_, state2._F_C50_2_) ||
         !SafeEquals <bool>(state1._F_B_3_, state2._F_B_3_) ||
         !SafeEquals <int>(state1._F_I_3_, state2._F_I_3_) ||
         !SafeEquals <long>(state1._F_L_3_, state2._F_L_3_) ||
         !SafeEquals <DateTime>(state1._F_DT_3_, state2._F_DT_3_) ||
         !SafeEquals <decimal>(state1._F_N_3_, state2._F_N_3_) ||
         !SafeEquals <string>(state1._F_C5_3_, state2._F_C5_3_) ||
         !SafeEquals <string>(state1._F_C10_3_, state2._F_C10_3_) ||
         !SafeEquals <string>(state1._F_C20_3_, state2._F_C20_3_) ||
         !SafeEquals <string>(state1._F_C50_3_, state2._F_C50_3_) ||
         !SafeEquals <bool>(state1._F_B_4_, state2._F_B_4_) ||
         !SafeEquals <int>(state1._F_I_4_, state2._F_I_4_) ||
         !SafeEquals <long>(state1._F_L_4_, state2._F_L_4_) ||
         !SafeEquals <DateTime>(state1._F_DT_4_, state2._F_DT_4_) ||
         !SafeEquals <decimal>(state1._F_N_4_, state2._F_N_4_) ||
         !SafeEquals <string>(state1._F_C5_4_, state2._F_C5_4_) ||
         !SafeEquals <string>(state1._F_C10_4_, state2._F_C10_4_) ||
         !SafeEquals <string>(state1._F_C20_4_, state2._F_C20_4_) ||
         !SafeEquals <string>(state1._F_C50_4_, state2._F_C50_4_)
         )
     {
         return(false);
     }
     return(true);
 }
        public static string GetHash(IAttributeSetInstanceStateProperties state)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("AttributeSetId").Append("=").Append(GetSafeStringValue(state.AttributeSetId)).Append("|");
            sb.Append("OrganizationId").Append("=").Append(GetSafeStringValue(state.OrganizationId)).Append("|");
            sb.Append("ReferenceId").Append("=").Append(GetSafeStringValue(state.ReferenceId)).Append("|");
            sb.Append("SerialNumber").Append("=").Append(GetSafeStringValue(state.SerialNumber)).Append("|");
            sb.Append("LotId").Append("=").Append(GetSafeStringValue(state.LotId)).Append("|");
            sb.Append("Description").Append("=").Append(GetSafeStringValue(state.Description)).Append("|");
            sb.Append("Active").Append("=").Append(state.Active).Append("|");
            sb.Append("WidthInch").Append("=").Append(state.WidthInch).Append("|");
            sb.Append("DiameterInch").Append("=").Append(state.DiameterInch).Append("|");
            sb.Append("WeightLbs").Append("=").Append(state.WeightLbs).Append("|");
            sb.Append("WeightKg").Append("=").Append(state.WeightKg).Append("|");
            sb.Append("AirDryWeightLbs").Append("=").Append(state.AirDryWeightLbs).Append("|");
            sb.Append("AirDryWeightKg").Append("=").Append(state.AirDryWeightKg).Append("|");
            sb.Append("AirDryMetricTon").Append("=").Append(state.AirDryMetricTon).Append("|");
            sb.Append("PackageCount").Append("=").Append(state.PackageCount).Append("|");
            sb.Append("AirDryPct").Append("=").Append(state.AirDryPct).Append("|");
            sb.Append("_F_B_0_").Append("=").Append(state._F_B_0_).Append("|");
            sb.Append("_F_I_0_").Append("=").Append(state._F_I_0_).Append("|");
            sb.Append("_F_L_0_").Append("=").Append(state._F_L_0_).Append("|");
            sb.Append("_F_DT_0_").Append("=").Append(state._F_DT_0_).Append("|");
            sb.Append("_F_N_0_").Append("=").Append(state._F_N_0_).Append("|");
            sb.Append("_F_C5_0_").Append("=").Append(GetSafeStringValue(state._F_C5_0_)).Append("|");
            sb.Append("_F_C10_0_").Append("=").Append(GetSafeStringValue(state._F_C10_0_)).Append("|");
            sb.Append("_F_C20_0_").Append("=").Append(GetSafeStringValue(state._F_C20_0_)).Append("|");
            sb.Append("_F_C50_0_").Append("=").Append(GetSafeStringValue(state._F_C50_0_)).Append("|");
            sb.Append("_F_C100_0_").Append("=").Append(GetSafeStringValue(state._F_C100_0_)).Append("|");
            sb.Append("_F_C200_0_").Append("=").Append(GetSafeStringValue(state._F_C200_0_)).Append("|");
            sb.Append("_F_C500_0_").Append("=").Append(GetSafeStringValue(state._F_C500_0_)).Append("|");
            sb.Append("_F_C1000_0_").Append("=").Append(GetSafeStringValue(state._F_C1000_0_)).Append("|");
            sb.Append("_F_B_1_").Append("=").Append(state._F_B_1_).Append("|");
            sb.Append("_F_I_1_").Append("=").Append(state._F_I_1_).Append("|");
            sb.Append("_F_L_1_").Append("=").Append(state._F_L_1_).Append("|");
            sb.Append("_F_DT_1_").Append("=").Append(state._F_DT_1_).Append("|");
            sb.Append("_F_N_1_").Append("=").Append(state._F_N_1_).Append("|");
            sb.Append("_F_C5_1_").Append("=").Append(GetSafeStringValue(state._F_C5_1_)).Append("|");
            sb.Append("_F_C10_1_").Append("=").Append(GetSafeStringValue(state._F_C10_1_)).Append("|");
            sb.Append("_F_C20_1_").Append("=").Append(GetSafeStringValue(state._F_C20_1_)).Append("|");
            sb.Append("_F_C50_1_").Append("=").Append(GetSafeStringValue(state._F_C50_1_)).Append("|");
            sb.Append("_F_C100_1_").Append("=").Append(GetSafeStringValue(state._F_C100_1_)).Append("|");
            sb.Append("_F_C200_1_").Append("=").Append(GetSafeStringValue(state._F_C200_1_)).Append("|");
            sb.Append("_F_B_2_").Append("=").Append(state._F_B_2_).Append("|");
            sb.Append("_F_I_2_").Append("=").Append(state._F_I_2_).Append("|");
            sb.Append("_F_L_2_").Append("=").Append(state._F_L_2_).Append("|");
            sb.Append("_F_DT_2_").Append("=").Append(state._F_DT_2_).Append("|");
            sb.Append("_F_N_2_").Append("=").Append(state._F_N_2_).Append("|");
            sb.Append("_F_C5_2_").Append("=").Append(GetSafeStringValue(state._F_C5_2_)).Append("|");
            sb.Append("_F_C10_2_").Append("=").Append(GetSafeStringValue(state._F_C10_2_)).Append("|");
            sb.Append("_F_C20_2_").Append("=").Append(GetSafeStringValue(state._F_C20_2_)).Append("|");
            sb.Append("_F_C50_2_").Append("=").Append(GetSafeStringValue(state._F_C50_2_)).Append("|");
            sb.Append("_F_B_3_").Append("=").Append(state._F_B_3_).Append("|");
            sb.Append("_F_I_3_").Append("=").Append(state._F_I_3_).Append("|");
            sb.Append("_F_L_3_").Append("=").Append(state._F_L_3_).Append("|");
            sb.Append("_F_DT_3_").Append("=").Append(state._F_DT_3_).Append("|");
            sb.Append("_F_N_3_").Append("=").Append(state._F_N_3_).Append("|");
            sb.Append("_F_C5_3_").Append("=").Append(GetSafeStringValue(state._F_C5_3_)).Append("|");
            sb.Append("_F_C10_3_").Append("=").Append(GetSafeStringValue(state._F_C10_3_)).Append("|");
            sb.Append("_F_C20_3_").Append("=").Append(GetSafeStringValue(state._F_C20_3_)).Append("|");
            sb.Append("_F_C50_3_").Append("=").Append(GetSafeStringValue(state._F_C50_3_)).Append("|");
            sb.Append("_F_B_4_").Append("=").Append(state._F_B_4_).Append("|");
            sb.Append("_F_I_4_").Append("=").Append(state._F_I_4_).Append("|");
            sb.Append("_F_L_4_").Append("=").Append(state._F_L_4_).Append("|");
            sb.Append("_F_DT_4_").Append("=").Append(state._F_DT_4_).Append("|");
            sb.Append("_F_N_4_").Append("=").Append(state._F_N_4_).Append("|");
            sb.Append("_F_C5_4_").Append("=").Append(GetSafeStringValue(state._F_C5_4_)).Append("|");
            sb.Append("_F_C10_4_").Append("=").Append(GetSafeStringValue(state._F_C10_4_)).Append("|");
            sb.Append("_F_C20_4_").Append("=").Append(GetSafeStringValue(state._F_C20_4_)).Append("|");
            sb.Append("_F_C50_4_").Append("=").Append(GetSafeStringValue(state._F_C50_4_)).Append("|");

            using (MD5 md5Hash = MD5.Create())
            {
                string hash = GetMD5HashString(md5Hash, sb.ToString());
                return(hash);
            }
        }