Ejemplo n.º 1
0
            private System.ComponentModel.Design.Serialization.InstanceDescriptor ConvertToInstanceDescriptor(OleDbParameter p)
            {
                int flags = 0;

                if (p.ShouldSerializeOleDbType())
                {
                    flags |= 1;
                }
                if (p.ShouldSerializeSize())
                {
                    flags |= 2;
                }
                if (!ADP.IsEmpty(p.SourceColumn))
                {
                    flags |= 4;
                }
                if (null != p.Value)
                {
                    flags |= 8;
                }
                if ((ParameterDirection.Input != p.Direction) || p.IsNullable ||
                    p.ShouldSerializePrecision() || p.ShouldSerializeScale() ||
                    (DataRowVersion.Current != p.SourceVersion))
                {
                    flags |= 16; // V1.0 everything
                }
                if (p.SourceColumnNullMapping)
                {
                    flags |= 32; // v2.0 everything
                }

                Type[]   ctorParams;
                object[] ctorValues;
                switch (flags)
                {
                case  0: // ParameterName
                case  1: // OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType };
                    break;

                case  2: // Size
                case  3: // Size, OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType), typeof(int) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType, p.Size };
                    break;

                case  4: // SourceColumn
                case  5: // SourceColumn, OleDbType
                case  6: // SourceColumn, Size
                case  7: // SourceColumn, Size, OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(string) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType, p.Size, p.SourceColumn };
                    break;

                case  8: // Value
                    ctorParams = new Type[] { typeof(string), typeof(object) };
                    ctorValues = new object[] { p.ParameterName, p.Value };
                    break;

                default:                   // everything else
                    if (0 == (32 & flags)) // V1.0 everything
                    {
                        ctorParams = new Type[] {
                            typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection),
                            typeof(bool), typeof(byte), typeof(byte), typeof(string),
                            typeof(DataRowVersion), typeof(object)
                        };
                        ctorValues = new object[] {
                            p.ParameterName, p.OleDbType, p.Size, p.Direction,
                            p.IsNullable, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn,
                            p.SourceVersion, p.Value
                        };
                    }
                    else   // v2.0 everything - round trip all browsable properties + precision/scale
                    {
                        ctorParams = new Type[] {
                            typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection),
                            typeof(byte), typeof(byte),
                            typeof(string), typeof(DataRowVersion), typeof(bool),
                            typeof(object)
                        };
                        ctorValues = new object[] {
                            p.ParameterName, p.OleDbType, p.Size, p.Direction,
                            p.PrecisionInternal, p.ScaleInternal,
                            p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping,
                            p.Value
                        };
                    }
                    break;
                }
                System.Reflection.ConstructorInfo ctor = typeof(OleDbParameter).GetConstructor(ctorParams);
                return(new System.ComponentModel.Design.Serialization.InstanceDescriptor(ctor, ctorValues));
            }
Ejemplo n.º 2
0
            private System.ComponentModel.Design.Serialization.InstanceDescriptor ConvertToInstanceDescriptor(OleDbParameter p) {
                int flags = 0;

                if (p.ShouldSerializeOleDbType()) {
                    flags |= 1;
                }
                if (p.ShouldSerializeSize()) {
                    flags |= 2;
                }
                if (!ADP.IsEmpty(p.SourceColumn)) {
                    flags |= 4;
                }
                if (null != p.Value) {
                    flags |= 8;
                }
                if ((ParameterDirection.Input != p.Direction) || p.IsNullable
                    || p.ShouldSerializePrecision() || p.ShouldSerializeScale()
                    || (DataRowVersion.Current != p.SourceVersion)) {
                    flags |= 16; // V1.0 everything
                }
                if (p.SourceColumnNullMapping) {
                    flags |= 32; // v2.0 everything
                }

                Type[] ctorParams;
                object[] ctorValues;
                switch(flags) {
                case  0: // ParameterName
                case  1: // OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType };
                    break;
                case  2: // Size
                case  3: // Size, OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType), typeof(int) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType, p.Size };
                    break;
                case  4: // SourceColumn
                case  5: // SourceColumn, OleDbType
                case  6: // SourceColumn, Size
                case  7: // SourceColumn, Size, OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(string) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType, p.Size, p.SourceColumn };
                    break;
                case  8: // Value
                    ctorParams = new Type[] { typeof(string), typeof(object) };
                    ctorValues = new object[] { p.ParameterName, p.Value };
                    break;
                default: // everything else
                    if (0 == (32 & flags)) { // V1.0 everything
                        ctorParams = new Type[] {
                            typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection),
                            typeof(bool), typeof(byte), typeof(byte), typeof(string),
                            typeof(DataRowVersion), typeof(object) };
                        ctorValues = new object[] {
                            p.ParameterName, p.OleDbType,  p.Size, p.Direction,
                            p.IsNullable, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn,
                            p.SourceVersion, p.Value };
                    }
                    else { // v2.0 everything - round trip all browsable properties + precision/scale
                        ctorParams = new Type[] {
                            typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection),
                            typeof(byte), typeof(byte),
                            typeof(string), typeof(DataRowVersion), typeof(bool),
                            typeof(object) };
                        ctorValues = new object[] {
                            p.ParameterName, p.OleDbType,  p.Size, p.Direction,
                            p.PrecisionInternal, p.ScaleInternal,
                            p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping,
                            p.Value };
                    }
                    break;
                }
                System.Reflection.ConstructorInfo ctor = typeof(OleDbParameter).GetConstructor(ctorParams);
                return new System.ComponentModel.Design.Serialization.InstanceDescriptor(ctor, ctorValues);
            }
            private InstanceDescriptor ConvertToInstanceDescriptor(OleDbParameter p)
            {
                object[] objArray3;
                Type[] typeArray3;
                int num = 0;
                if (p.ShouldSerializeOleDbType())
                {
                    num |= 1;
                }
                if (p.ShouldSerializeSize())
                {
                    num |= 2;
                }
                if (!ADP.IsEmpty(p.SourceColumn))
                {
                    num |= 4;
                }
                if (p.Value != null)
                {
                    num |= 8;
                }
                if (((ParameterDirection.Input != p.Direction) || p.IsNullable) || ((p.ShouldSerializePrecision() || p.ShouldSerializeScale()) || (DataRowVersion.Current != p.SourceVersion)))
                {
                    num |= 0x10;
                }
                if (p.SourceColumnNullMapping)
                {
                    num |= 0x20;
                }
                switch (num)
                {
                    case 0:
                    case 1:
                        typeArray3 = new Type[] { typeof(string), typeof(OleDbType) };
                        objArray3 = new object[] { p.ParameterName, p.OleDbType };
                        break;

                    case 2:
                    case 3:
                        typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int) };
                        objArray3 = new object[] { p.ParameterName, p.OleDbType, p.Size };
                        break;

                    case 4:
                    case 5:
                    case 6:
                    case 7:
                        typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(string) };
                        objArray3 = new object[] { p.ParameterName, p.OleDbType, p.Size, p.SourceColumn };
                        break;

                    case 8:
                        typeArray3 = new Type[] { typeof(string), typeof(object) };
                        objArray3 = new object[] { p.ParameterName, p.Value };
                        break;

                    default:
                        if ((0x20 & num) == 0)
                        {
                            typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection), typeof(bool), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion), typeof(object) };
                            objArray3 = new object[] { p.ParameterName, p.OleDbType, p.Size, p.Direction, p.IsNullable, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn, p.SourceVersion, p.Value };
                        }
                        else
                        {
                            typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion), typeof(bool), typeof(object) };
                            objArray3 = new object[] { p.ParameterName, p.OleDbType, p.Size, p.Direction, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping, p.Value };
                        }
                        break;
                }
                return new InstanceDescriptor(typeof(OleDbParameter).GetConstructor(typeArray3), objArray3);
            }
            private InstanceDescriptor ConvertToInstanceDescriptor(OleDbParameter p)
            {
                object[] objArray3;
                Type[]   typeArray3;
                int      num = 0;

                if (p.ShouldSerializeOleDbType())
                {
                    num |= 1;
                }
                if (p.ShouldSerializeSize())
                {
                    num |= 2;
                }
                if (!ADP.IsEmpty(p.SourceColumn))
                {
                    num |= 4;
                }
                if (p.Value != null)
                {
                    num |= 8;
                }
                if (((ParameterDirection.Input != p.Direction) || p.IsNullable) || ((p.ShouldSerializePrecision() || p.ShouldSerializeScale()) || (DataRowVersion.Current != p.SourceVersion)))
                {
                    num |= 0x10;
                }
                if (p.SourceColumnNullMapping)
                {
                    num |= 0x20;
                }
                switch (num)
                {
                case 0:
                case 1:
                    typeArray3 = new Type[] { typeof(string), typeof(OleDbType) };
                    objArray3  = new object[] { p.ParameterName, p.OleDbType };
                    break;

                case 2:
                case 3:
                    typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int) };
                    objArray3  = new object[] { p.ParameterName, p.OleDbType, p.Size };
                    break;

                case 4:
                case 5:
                case 6:
                case 7:
                    typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(string) };
                    objArray3  = new object[] { p.ParameterName, p.OleDbType, p.Size, p.SourceColumn };
                    break;

                case 8:
                    typeArray3 = new Type[] { typeof(string), typeof(object) };
                    objArray3  = new object[] { p.ParameterName, p.Value };
                    break;

                default:
                    if ((0x20 & num) == 0)
                    {
                        typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection), typeof(bool), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion), typeof(object) };
                        objArray3  = new object[] { p.ParameterName, p.OleDbType, p.Size, p.Direction, p.IsNullable, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn, p.SourceVersion, p.Value };
                    }
                    else
                    {
                        typeArray3 = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion), typeof(bool), typeof(object) };
                        objArray3  = new object[] { p.ParameterName, p.OleDbType, p.Size, p.Direction, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping, p.Value };
                    }
                    break;
                }
                return(new InstanceDescriptor(typeof(OleDbParameter).GetConstructor(typeArray3), objArray3));
            }