WriteArray() public method

public WriteArray ( string prefix, System localName, System namespaceUri, System array, int offset, int count ) : void
prefix string
localName System
namespaceUri System
array System
offset int
count int
return void
 public void WriteValue(XmlDictionaryWriter writer, object value)
 {
     if (_isArray)
     {
         switch (_typeCode)
         {
             case TypeCode.Byte:
                 {
                     byte[] arrayValue = (byte[])value;
                     writer.WriteBase64(arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.Boolean:
                 {
                     bool[] arrayValue = (bool[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.DateTime:
                 {
                     DateTime[] arrayValue = (DateTime[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.Decimal:
                 {
                     decimal[] arrayValue = (decimal[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.Int32:
                 {
                     Int32[] arrayValue = (Int32[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.Int64:
                 {
                     Int64[] arrayValue = (Int64[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.Single:
                 {
                     float[] arrayValue = (float[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             case TypeCode.Double:
                 {
                     double[] arrayValue = (double[])value;
                     writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
                 }
                 break;
             default:
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter));
         }
     }
     else
     {
         switch (_typeCode)
         {
             case TypeCode.Boolean:
                 writer.WriteValue((bool)value);
                 break;
             case TypeCode.DateTime:
                 writer.WriteValue((DateTime)value);
                 break;
             case TypeCode.Decimal:
                 writer.WriteValue((Decimal)value);
                 break;
             case TypeCode.Double:
                 writer.WriteValue((double)value);
                 break;
             case TypeCode.Int32:
                 writer.WriteValue((int)value);
                 break;
             case TypeCode.Int64:
                 writer.WriteValue((long)value);
                 break;
             case TypeCode.Single:
                 writer.WriteValue((float)value);
                 break;
             case TypeCode.String:
                 writer.WriteString((string)value);
                 break;
             default:
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter));
         }
     }
 }
Esempio n. 2
0
 protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count)
 {
     writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
 }
            public void WriteValue(XmlDictionaryWriter writer, object value)
            {
                if (!this.isArray)
                {
                    switch (this.typeCode)
                    {
                        case TypeCode.Int32:
                            writer.WriteValue((int) value);
                            return;

                        case TypeCode.Int64:
                            writer.WriteValue((long) value);
                            return;

                        case TypeCode.Single:
                            writer.WriteValue((float) value);
                            return;

                        case TypeCode.Double:
                            writer.WriteValue((double) value);
                            return;

                        case TypeCode.Decimal:
                            writer.WriteValue((decimal) value);
                            return;

                        case TypeCode.DateTime:
                            writer.WriteValue((DateTime) value);
                            return;

                        case TypeCode.String:
                            writer.WriteString((string) value);
                            return;

                        case TypeCode.Boolean:
                            writer.WriteValue((bool) value);
                            return;
                    }
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter")));
                }
                switch (this.typeCode)
                {
                    case TypeCode.Boolean:
                    {
                        bool[] array = (bool[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, array, 0, array.Length);
                        return;
                    }
                    case TypeCode.Byte:
                    {
                        byte[] buffer = (byte[]) value;
                        writer.WriteBase64(buffer, 0, buffer.Length);
                        return;
                    }
                    case TypeCode.Int32:
                    {
                        int[] numArray2 = (int[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, numArray2, 0, numArray2.Length);
                        return;
                    }
                    case TypeCode.Int64:
                    {
                        long[] numArray3 = (long[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, numArray3, 0, numArray3.Length);
                        return;
                    }
                    case TypeCode.Single:
                    {
                        float[] numArray4 = (float[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, numArray4, 0, numArray4.Length);
                        return;
                    }
                    case TypeCode.Double:
                    {
                        double[] numArray5 = (double[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, numArray5, 0, numArray5.Length);
                        return;
                    }
                    case TypeCode.Decimal:
                    {
                        decimal[] numArray = (decimal[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, numArray, 0, numArray.Length);
                        return;
                    }
                    case TypeCode.DateTime:
                    {
                        DateTime[] timeArray = (DateTime[]) value;
                        writer.WriteArray(null, this.itemName, this.itemNamespace, timeArray, 0, timeArray.Length);
                        return;
                    }
                }
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter")));
            }