コード例 #1
0
        public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || this.GetType() != obj.GetType())
            {
                return(false);
            }

            DifferentProperties dp = (DifferentProperties)obj;

            return((this.objPropertyName == dp.objPropertyName) &&
                   (this.objUrn1 == dp.objUrn1) &&
                   (this.objUrn2 == dp.objUrn2) &&
                   (this.objValue1 == dp.objValue1) &&
                   (this.objValue2 == dp.objValue2));
        }
コード例 #2
0
ファイル: SmoCompare.cs プロジェクト: rcdosado/SMO
        private bool CompareValueTypes(PropertyInfo propInfo1, PropertyInfo propInfo2, SqlSmoObject object1, SqlSmoObject object2)
        {
            object obj1 = propInfo1.GetValue(object1, null);
            object obj2 = propInfo2.GetValue(object2, null);
            bool ReturnValueLoc = obj1.Equals(obj2);
            if (!ReturnValueLoc)
            {
                DifferentProperties temp = new DifferentProperties();
                temp.Urn1 = object1.Urn;
                temp.Urn2 = object2.Urn;
                temp.PropertyName = propInfo1.Name;
                temp.ObjectValue1
                    = propInfo1.GetValue(object1, null).ToString();
                temp.ObjectValue2
                    = propInfo2.GetValue(object2, null).ToString();
                DiffProps.Add(temp);
            }

            return ReturnValueLoc;
        }
コード例 #3
0
ファイル: SmoCompare.cs プロジェクト: rcdosado/SMO
        private bool CompareStringTypes(PropertyInfo propInfo1, PropertyInfo propInfo2, SqlSmoObject object1, SqlSmoObject object2)
        {
            bool ReturnValueLoc = false;

            if (propInfo1.Name == "TextBody")
            {
                ReturnValueLoc = (((string)propInfo1.GetValue(object1, null)))
                    .TrimEnd() == (((string)propInfo2.GetValue(object2, null)))
                    .TrimEnd() ? true : false;
            }
            else
            {
                ReturnValueLoc = ((string)propInfo1.GetValue(object1, null))
                    == ((string)propInfo2.GetValue(object2, null))
                    ? true : false;
            }

            if (!ReturnValueLoc)
            {
                DifferentProperties temp = new DifferentProperties();
                temp.Urn1 = object1.Urn;
                temp.Urn2 = object2.Urn;
                temp.PropertyName = propInfo1.Name;
                temp.ObjectValue1
                    = propInfo1.GetValue(object1, null).ToString();
                temp.ObjectValue2
                    = propInfo2.GetValue(object2, null).ToString();
                DiffProps.Add(temp);
            }

            return ReturnValueLoc;
        }
コード例 #4
0
ファイル: SmoCompare.cs プロジェクト: rcdosado/SMO
        private bool CompareEnumTypes(PropertyInfo propInfo1, PropertyInfo propInfo2, SqlSmoObject object1, SqlSmoObject object2)
        {
            Enum s1 = (Enum)propInfo1.GetValue(object1, null);
            Enum s2 = (Enum)propInfo2.GetValue(object2, null);
            bool ReturnValueLoc = s1.CompareTo(s2) == 0 ? true : false;

            if (!ReturnValueLoc)
            {
                DifferentProperties temp = new DifferentProperties();
                temp.Urn1 = object1.Urn;
                temp.Urn2 = object2.Urn;
                temp.PropertyName = propInfo1.Name;
                temp.ObjectValue1
                    = propInfo1.GetValue(object1, null).ToString();
                temp.ObjectValue2
                    = propInfo2.GetValue(object2, null).ToString();
                DiffProps.Add(temp);
            }

            return ReturnValueLoc;
        }
コード例 #5
0
ファイル: SmoCompare.cs プロジェクト: rcdosado/SMO
        private bool CompareAnyTypes(PropertyInfo propInfo1, PropertyInfo propInfo2, SqlSmoObject object1, SqlSmoObject object2)
        {
            bool ReturnValueLoc = true;
            object objTemp1 = propInfo1.GetValue(object1, null);
            object objTemp2 = propInfo2.GetValue(object2, null);

            if (objTemp1 == null && objTemp2 == null)
            {
                // (i.e. DefaultConstraint)
                if (!CanBeNull(propInfo1.Name, object1.GetType().Name))
                {
                    throw new ApplicationException(string.Format(
                        System.Globalization.CultureInfo.InvariantCulture,
                        Properties.Resources.NullReferenceException,
                        object1.Urn, object2.Urn, propInfo1.Name,
                        propInfo2.Name));
                }

                // On else branch we do nothing; both props are null and they 
                // are accepted with null values
                return true;
            }

            if (objTemp1.GetType().IsSubclassOf(typeof(SqlSmoObject))
                && objTemp2.GetType().IsSubclassOf(typeof(SqlSmoObject)))
            {
                ReturnValueLoc &= Compare((SqlSmoObject)objTemp1, (SqlSmoObject)objTemp2);

                return ReturnValueLoc;
            }

            if (objTemp1.GetType().FullName
                == "Microsoft.SqlServer.Management.Smo.DataType"
                && objTemp2.GetType().FullName
                == "Microsoft.SqlServer.Management.Smo.DataType")
            {
                DataType dt1 = objTemp1 as DataType;
                DataType dt2 = objTemp2 as DataType;

                ReturnValueLoc &= dt1.SqlDataType == dt2.SqlDataType ? true : false;
                if (!ReturnValueLoc)
                {
                    DifferentProperties temp = new DifferentProperties();
                    temp.Urn1 = object1.Urn;
                    temp.Urn2 = object2.Urn;
                    temp.PropertyName = propInfo1.Name;

                    // Here we store all the prop and values for DataType
                    string objectValue1 = string.Format(
                        System.Globalization.CultureInfo.InvariantCulture,
                        Properties.Resources.ObjectValue,
                        dt1.MaximumLength, dt1.Name, dt1.NumericPrecision,
                        dt1.NumericScale, dt1.Schema, dt1.SqlDataType);

                    string objectValue2 = string.Format(
                        System.Globalization.CultureInfo.InvariantCulture,
                        Properties.Resources.ObjectValue,
                        dt2.MaximumLength, dt2.Name, dt2.NumericPrecision,
                        dt2.NumericScale, dt2.Schema, dt2.SqlDataType);

                    temp.ObjectValue1 = objectValue1;
                    temp.ObjectValue2 = objectValue2;

                    DiffProps.Add(temp);
                }

                return ReturnValueLoc;
            }

            ReturnValueLoc &= objTemp1.Equals(objTemp2);

            return ReturnValueLoc;
        }