System.Xml.Schema.TypedObject.SetDecimal C# (CSharp) Method

SetDecimal() public method

public SetDecimal ( ) : void
return void
        public void SetDecimal () {

            if (this.dstruct != null) {
                return; 
            }
        
            // Debug.Assert(!this.IsDecimal);
            switch(xsdtype.TypeCode) {
                case XmlTypeCode.Byte:
                case XmlTypeCode.UnsignedByte:
                case XmlTypeCode.Short:
                case XmlTypeCode.UnsignedShort:
                case XmlTypeCode.Int:
                case XmlTypeCode.UnsignedInt:
                case XmlTypeCode.Long:
                case XmlTypeCode.UnsignedLong:
                case XmlTypeCode.Decimal:
                case XmlTypeCode.Integer:
                case XmlTypeCode.PositiveInteger:
                case XmlTypeCode.NonNegativeInteger:
                case XmlTypeCode.NegativeInteger:
                case XmlTypeCode.NonPositiveInteger:

                    if (this.isList) {
                        this.dstruct = new DecimalStruct(this.dim);
                        for (int i = 0; i < this.dim; i ++) {
                            this.dstruct.Dvalue[i] = Convert.ToDecimal (((Array) this.ovalue).GetValue(i),NumberFormatInfo.InvariantInfo);
                        }
                    }
                    else { //not list
                        this.dstruct = new DecimalStruct();
                        //possibility of list of length 1.
                        this.dstruct.Dvalue[0] = Convert.ToDecimal (this.ovalue, NumberFormatInfo.InvariantInfo);
                    }
                    this.dstruct.IsDecimal = true;
                    break;

                default:
                    if (this.isList) {
                        this.dstruct = new DecimalStruct(this.dim);
                    }
                    else {
                        this.dstruct = new DecimalStruct();
                    }
                    break;

            }
        }

Usage Example

        public bool Equals(TypedObject other)
        {
            if (this.Dim != other.Dim)
            {
                return(false);
            }
            if (this.Type != other.Type)
            {
                if (!this.Type.IsComparable(other.Type))
                {
                    return(false);
                }
                other.SetDecimal();
                this.SetDecimal();
                if (this.IsDecimal && other.IsDecimal)
                {
                    return(this.ListDValueEquals(other));
                }
            }
            if (this.IsList)
            {
                if (other.IsList)
                {
                    return(this.Type.Compare(this.Value, other.Value) == 0);
                }
                Array            array      = this.Value as Array;
                XmlAtomicValue[] valueArray = array as XmlAtomicValue[];
                if (valueArray != null)
                {
                    return((valueArray.Length == 1) && valueArray.GetValue(0).Equals(other.Value));
                }
                return((array.Length == 1) && array.GetValue(0).Equals(other.Value));
            }
            if (!other.IsList)
            {
                return(this.Value.Equals(other.Value));
            }
            Array array2 = other.Value as Array;

            XmlAtomicValue[] valueArray2 = array2 as XmlAtomicValue[];
            if (valueArray2 != null)
            {
                return((valueArray2.Length == 1) && valueArray2.GetValue(0).Equals(this.Value));
            }
            return((array2.Length == 1) && array2.GetValue(0).Equals(this.Value));
        }
All Usage Examples Of System.Xml.Schema.TypedObject::SetDecimal