ReadValueAsBase64() public method

public ReadValueAsBase64 ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
return int
Beispiel #1
0
 protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
 {
     Type type = reader.ValueType;
     if (type == typeof(string))
     {
         if (reader.CanReadValueChunk)
         {
             if (chars == null)
             {
                 chars = new char[256];
             }
             int count;
             while ((count = reader.ReadValueChunk(chars, 0, chars.Length)) > 0)
             {
                 this.WriteChars(chars, 0, count);
             }
         }
         else
         {
             WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (type == typeof(byte[]))
     {
         if (reader.CanReadBinaryContent)
         {
             // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text
             if (bytes == null)
             {
                 bytes = new byte[384];
             }
             int count;
             while ((count = reader.ReadValueAsBase64(bytes, 0, bytes.Length)) > 0)
             {
                 this.WriteBase64(bytes, 0, count);
             }
         }
         else
         {
             WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else
     {
         base.WriteTextNode(reader, attribute);
     }
 }
Beispiel #2
0
        protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
        {
            Type valueType = reader.ValueType;

            if (valueType == typeof(string))
            {
                if (reader.CanReadValueChunk)
                {
                    int num;
                    if (this.chars == null)
                    {
                        this.chars = new char[0x100];
                    }
                    while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0)
                    {
                        this.WriteChars(this.chars, 0, num);
                    }
                }
                else
                {
                    this.WriteString(reader.Value);
                }
                if (!attribute)
                {
                    reader.Read();
                }
            }
            else if (valueType == typeof(byte[]))
            {
                if (reader.CanReadBinaryContent)
                {
                    int num2;
                    if (this.bytes == null)
                    {
                        this.bytes = new byte[0x180];
                    }
                    while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0)
                    {
                        this.WriteBase64(this.bytes, 0, num2);
                    }
                }
                else
                {
                    this.WriteString(reader.Value);
                }
                if (!attribute)
                {
                    reader.Read();
                }
            }
            else
            {
                base.WriteTextNode(reader, attribute);
            }
        }
 protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
 {
     Type valueType = reader.ValueType;
     if (valueType == typeof(string))
     {
         if (reader.CanReadValueChunk)
         {
             int num;
             if (this.chars == null)
             {
                 this.chars = new char[0x100];
             }
             while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0)
             {
                 this.WriteChars(this.chars, 0, num);
             }
         }
         else
         {
             this.WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (valueType == typeof(byte[]))
     {
         if (reader.CanReadBinaryContent)
         {
             int num2;
             if (this.bytes == null)
             {
                 this.bytes = new byte[0x180];
             }
             while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0)
             {
                 this.WriteBase64(this.bytes, 0, num2);
             }
         }
         else
         {
             this.WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else
     {
         base.WriteTextNode(reader, attribute);
     }
 }
Beispiel #4
0
        protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
        {
            Type valueType = reader.ValueType;

            if (valueType == typeof(string))
            {
                XmlDictionaryString str;
                if (reader.TryGetValueAsDictionaryString(out str))
                {
                    this.WriteString(str);
                }
                else if (reader.CanReadValueChunk)
                {
                    int num;
                    if (this.chars == null)
                    {
                        this.chars = new char[0x100];
                    }
                    while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0)
                    {
                        this.WriteChars(this.chars, 0, num);
                    }
                }
                else
                {
                    this.WriteString(reader.Value);
                }
                if (!attribute)
                {
                    reader.Read();
                }
            }
            else if (valueType == typeof(byte[]))
            {
                if (reader.CanReadBinaryContent)
                {
                    int num2;
                    if (this.bytes == null)
                    {
                        this.bytes = new byte[0x180];
                    }
                    while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0)
                    {
                        this.WriteBase64(this.bytes, 0, num2);
                    }
                }
                else
                {
                    this.WriteString(reader.Value);
                }
                if (!attribute)
                {
                    reader.Read();
                }
            }
            else if (valueType == typeof(int))
            {
                this.WriteValue(reader.ReadContentAsInt());
            }
            else if (valueType == typeof(long))
            {
                this.WriteValue(reader.ReadContentAsLong());
            }
            else if (valueType == typeof(bool))
            {
                this.WriteValue(reader.ReadContentAsBoolean());
            }
            else if (valueType == typeof(double))
            {
                this.WriteValue(reader.ReadContentAsDouble());
            }
            else if (valueType == typeof(DateTime))
            {
                this.WriteValue(reader.ReadContentAsDateTime());
            }
            else if (valueType == typeof(float))
            {
                this.WriteValue(reader.ReadContentAsFloat());
            }
            else if (valueType == typeof(decimal))
            {
                this.WriteValue(reader.ReadContentAsDecimal());
            }
            else if (valueType == typeof(UniqueId))
            {
                this.WriteValue(reader.ReadContentAsUniqueId());
            }
            else if (valueType == typeof(Guid))
            {
                this.WriteValue(reader.ReadContentAsGuid());
            }
            else if (valueType == typeof(TimeSpan))
            {
                this.WriteValue(reader.ReadContentAsTimeSpan());
            }
            else
            {
                this.WriteValue(reader.ReadContentAsObject());
            }
        }
Beispiel #5
0
 protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
 {
     Type type = reader.ValueType;
     if (type == typeof(string))
     {
         XmlDictionaryString value;
         if (reader.TryGetValueAsDictionaryString(out value))
         {
             WriteString(value);
         }
         else
         {
             if (reader.CanReadValueChunk)
             {
                 if (_chars == null)
                 {
                     _chars = new char[256];
                 }
                 int count;
                 while ((count = reader.ReadValueChunk(_chars, 0, _chars.Length)) > 0)
                 {
                     this.WriteChars(_chars, 0, count);
                 }
             }
             else
             {
                 WriteString(reader.Value);
             }
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (type == typeof(byte[]))
     {
         if (reader.CanReadBinaryContent)
         {
             // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text
             if (_bytes == null)
             {
                 _bytes = new byte[384];
             }
             int count;
             while ((count = reader.ReadValueAsBase64(_bytes, 0, _bytes.Length)) > 0)
             {
                 this.WriteBase64(_bytes, 0, count);
             }
         }
         else
         {
             WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (type == typeof(int))
         WriteValue(reader.ReadContentAsInt());
     else if (type == typeof(long))
         WriteValue(reader.ReadContentAsLong());
     else if (type == typeof(bool))
         WriteValue(reader.ReadContentAsBoolean());
     else if (type == typeof(double))
         WriteValue(reader.ReadContentAsDouble());
     else if (type == typeof(DateTime))
         WriteValue(reader.ReadContentAsDateTimeOffset().DateTime);
     else if (type == typeof(float))
         WriteValue(reader.ReadContentAsFloat());
     else if (type == typeof(decimal))
         WriteValue(reader.ReadContentAsDecimal());
     else if (type == typeof(UniqueId))
         WriteValue(reader.ReadContentAsUniqueId());
     else if (type == typeof(Guid))
         WriteValue(reader.ReadContentAsGuid());
     else if (type == typeof(TimeSpan))
         WriteValue(reader.ReadContentAsTimeSpan());
     else
         WriteValue(reader.ReadContentAsObject());
 }
 protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
 {
     Type valueType = reader.ValueType;
     if (valueType == typeof(string))
     {
         XmlDictionaryString str;
         if (reader.TryGetValueAsDictionaryString(out str))
         {
             this.WriteString(str);
         }
         else if (reader.CanReadValueChunk)
         {
             int num;
             if (this.chars == null)
             {
                 this.chars = new char[0x100];
             }
             while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0)
             {
                 this.WriteChars(this.chars, 0, num);
             }
         }
         else
         {
             this.WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (valueType == typeof(byte[]))
     {
         if (reader.CanReadBinaryContent)
         {
             int num2;
             if (this.bytes == null)
             {
                 this.bytes = new byte[0x180];
             }
             while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0)
             {
                 this.WriteBase64(this.bytes, 0, num2);
             }
         }
         else
         {
             this.WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (valueType == typeof(int))
     {
         this.WriteValue(reader.ReadContentAsInt());
     }
     else if (valueType == typeof(long))
     {
         this.WriteValue(reader.ReadContentAsLong());
     }
     else if (valueType == typeof(bool))
     {
         this.WriteValue(reader.ReadContentAsBoolean());
     }
     else if (valueType == typeof(double))
     {
         this.WriteValue(reader.ReadContentAsDouble());
     }
     else if (valueType == typeof(DateTime))
     {
         this.WriteValue(reader.ReadContentAsDateTime());
     }
     else if (valueType == typeof(float))
     {
         this.WriteValue(reader.ReadContentAsFloat());
     }
     else if (valueType == typeof(decimal))
     {
         this.WriteValue(reader.ReadContentAsDecimal());
     }
     else if (valueType == typeof(UniqueId))
     {
         this.WriteValue(reader.ReadContentAsUniqueId());
     }
     else if (valueType == typeof(Guid))
     {
         this.WriteValue(reader.ReadContentAsGuid());
     }
     else if (valueType == typeof(TimeSpan))
     {
         this.WriteValue(reader.ReadContentAsTimeSpan());
     }
     else
     {
         this.WriteValue(reader.ReadContentAsObject());
     }
 }