Beispiel #1
0
        protected virtual int ShouldSerializeSignature(DAEParameter parameter)
        {
            PropertyDescriptorCollection propertyDescriptors = TypeDescriptor.GetProperties(parameter);
            int serializeSignature = 0;

            if (propertyDescriptors["ParameterName"].ShouldSerializeValue(parameter))
            {
                serializeSignature |= 1;
            }

            if (propertyDescriptors["DAEDbType"].ShouldSerializeValue(parameter))
            {
                serializeSignature |= 2;
            }

            if (propertyDescriptors["SourceColumn"].ShouldSerializeValue(parameter))
            {
                serializeSignature |= 4;
            }

            if
            (
                propertyDescriptors["Size"].ShouldSerializeValue(parameter) ||
                propertyDescriptors["Direction"].ShouldSerializeValue(parameter) ||
                propertyDescriptors["IsNullable"].ShouldSerializeValue(parameter) ||
                propertyDescriptors["Precision"].ShouldSerializeValue(parameter) ||
                propertyDescriptors["Scale"].ShouldSerializeValue(parameter) ||
                propertyDescriptors["SourceVersion"].ShouldSerializeValue(parameter)
            )
            {
                serializeSignature |= 8;
            }

            return(serializeSignature);
        }
Beispiel #2
0
        public override int Add(object value)
        {
            DAEParameter localValue = (DAEParameter)value;

            _items.Add(localValue);
            return(IndexOf(localValue));
        }
Beispiel #3
0
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            DAEParameter parameter = value as DAEParameter;

            if
            (
                (destinationType == typeof(InstanceDescriptor)) &&
                (parameter != null)
            )
            {
                return(GetInstanceDescriptor(parameter));
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Beispiel #4
0
        protected virtual InstanceDescriptor GetInstanceDescriptor(DAEParameter parameter)
        {
            ConstructorInfo info;
            Type            type = parameter.GetType();

            switch (ShouldSerializeSignature(parameter))
            {
            case 0:
            case 1:
            case 2:
            case 3:
                info = type.GetConstructor
                       (
                    new Type[]
                {
                    typeof(string),
                    typeof(DAEDbType)
                }
                       );
                return(new InstanceDescriptor
                       (
                           info,
                           new object[]
                {
                    parameter.ParameterName,
                    parameter.DAEDbType
                }
                       ));

            case 4:
            case 5:
            case 6:
            case 7:
                info = type.GetConstructor
                       (
                    new Type[]
                {
                    typeof(string),
                    typeof(DAEDbType),
                    typeof(string)
                }
                       );
                return(new InstanceDescriptor
                       (
                           info,
                           new object[]
                {
                    parameter.ParameterName,
                    parameter.DAEDbType,
                    parameter.SourceColumn
                }
                       ));

            default:
                info = type.GetConstructor
                       (
                    new Type[]
                {
                    typeof(string),
                    typeof(DAEDbType),
                    typeof(int),
                    typeof(ParameterDirection),
                    typeof(bool),
                    typeof(byte),
                    typeof(byte),
                    typeof(string),
                    typeof(DataRowVersion),
                    typeof(object)
                }
                       );
                return(new InstanceDescriptor
                       (
                           info,
                           new object[]
                {
                    parameter.ParameterName,
                    parameter.DAEDbType,
                    parameter.Size,
                    parameter.Direction,
                    parameter.IsNullable,
                    parameter.Precision,
                    parameter.Scale,
                    parameter.SourceColumn,
                    parameter.SourceVersion,
                    parameter.Value
                }
                       ));
            }
        }