コード例 #1
0
 protected internal override void Serialize(IntermediateWriter output, DateTime value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     output.Xml.WriteString(XmlConvert.ToString(value, XmlDateTimeSerializationMode.RoundtripKind));
 }
コード例 #2
0
 protected internal override void Serialize(IntermediateWriter output, Type value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     output.WriteTypeName(value);
 }
コード例 #3
0
 protected internal override void Serialize(IntermediateWriter output, T value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     output.Xml.WriteString(value.PackedValue.ToString("X8", CultureInfo.InvariantCulture));
 }
コード例 #4
0
 protected internal override void Serialize(IntermediateWriter output, sbyte value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     output.Xml.WriteString(XmlConvert.ToString(value));
 }
コード例 #5
0
 protected internal override void Serialize(IntermediateWriter output, BoundingFrustum value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     output.WriteObject <Matrix>(value.Matrix, BoundingFrustumSerializer.matrixFormat);
 }
コード例 #6
0
        protected internal override void Serialize(IntermediateWriter output, Vector2 value, ContentSerializerAttribute format)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            MathTypeSerializer <Vector2> .WritePart(output, value.X);

            MathTypeSerializer <Vector2> .WriteLast(output, value.Y);
        }
コード例 #7
0
        public void Serialize(IntermediateWriter output, ContentSerializerAttribute format, object collection)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }
            this.ValidateCollectionType(collection);
            IEnumerable enumerable = (IEnumerable)collection;

            if (this.contentSerializer is IXmlListItemSerializer)
            {
                ContentSerializerAttribute contentSerializerAttribute = new ContentSerializerAttribute();
                contentSerializerAttribute.FlattenContent = true;
                bool        flag       = true;
                IEnumerator enumerator = enumerable.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        object current = enumerator.Current;
                        if (flag)
                        {
                            flag = false;
                        }
                        else
                        {
                            output.Xml.WriteWhitespace(" ");
                        }
                        output.WriteRawObject <object>(current, contentSerializerAttribute, this.contentSerializer);
                    }
                    return;
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            ContentSerializerAttribute contentSerializerAttribute2 = new ContentSerializerAttribute();

            contentSerializerAttribute2.ElementName = format.CollectionItemName;
            foreach (object current2 in enumerable)
            {
                output.WriteObject <object>(current2, contentSerializerAttribute2, this.contentSerializer);
            }
        }
コード例 #8
0
 protected internal override void Serialize(IntermediateWriter output, Rectangle value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     output.Xml.WriteString(XmlConvert.ToString(value.X));
     output.Xml.WriteWhitespace(" ");
     output.Xml.WriteString(XmlConvert.ToString(value.Y));
     output.Xml.WriteWhitespace(" ");
     output.Xml.WriteString(XmlConvert.ToString(value.Width));
     output.Xml.WriteWhitespace(" ");
     output.Xml.WriteString(XmlConvert.ToString(value.Height));
 }
コード例 #9
0
 protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (format == null)
     {
         throw new ArgumentNullException("format");
     }
     foreach (DictionaryEntry dictionaryEntry in this.CastType(value))
     {
         output.Xml.WriteStartElement(format.CollectionItemName);
         output.WriteObject <object>(dictionaryEntry.Key, this.keyFormat);
         output.WriteObject <object>(dictionaryEntry.Value, this.valueFormat);
         output.Xml.WriteEndElement();
     }
 }
コード例 #10
0
        protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }
            ContentSerializerAttribute contentSerializerAttribute = new ContentSerializerAttribute();

            contentSerializerAttribute.ElementName = format.CollectionItemName;
            foreach (object current in this.CastType(value))
            {
                output.WriteObject <object>(current, contentSerializerAttribute);
            }
        }
コード例 #11
0
 protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (!base.IsTargetType(value))
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.WrongArgumentType, new object[]
         {
             base.TargetType,
             value.GetType()
         }));
     }
     output.Xml.WriteString(value.ToString());
 }
コード例 #12
0
        protected internal override void Serialize(IntermediateWriter output, CurveKey value, ContentSerializerAttribute format)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            MathTypeSerializer <CurveKey> .WritePart(output, value.Position);

            MathTypeSerializer <CurveKey> .WritePart(output, value.Value);

            MathTypeSerializer <CurveKey> .WritePart(output, value.TangentIn);

            MathTypeSerializer <CurveKey> .WritePart(output, value.TangentOut);

            output.Xml.WriteString(value.Continuity.ToString());
        }
コード例 #13
0
 protected internal override void Serialize(IntermediateWriter output, Dictionary <Key, Value> value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (format == null)
     {
         throw new ArgumentNullException("format");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     foreach (KeyValuePair <Key, Value> current in value)
     {
         output.Xml.WriteStartElement(format.CollectionItemName);
         output.WriteObject <Key>(current.Key, this.keyFormat, this.keySerializer);
         output.WriteObject <Value>(current.Value, this.valueFormat, this.valueSerializer);
         output.Xml.WriteEndElement();
     }
 }
コード例 #14
0
        protected internal override void Serialize(IntermediateWriter output, Matrix value, ContentSerializerAttribute format)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            MathTypeSerializer <Matrix> .WritePart(output, value.M11);

            MathTypeSerializer <Matrix> .WritePart(output, value.M12);

            MathTypeSerializer <Matrix> .WritePart(output, value.M13);

            MathTypeSerializer <Matrix> .WritePart(output, value.M14);

            MathTypeSerializer <Matrix> .WritePart(output, value.M21);

            MathTypeSerializer <Matrix> .WritePart(output, value.M22);

            MathTypeSerializer <Matrix> .WritePart(output, value.M23);

            MathTypeSerializer <Matrix> .WritePart(output, value.M24);

            MathTypeSerializer <Matrix> .WritePart(output, value.M31);

            MathTypeSerializer <Matrix> .WritePart(output, value.M32);

            MathTypeSerializer <Matrix> .WritePart(output, value.M33);

            MathTypeSerializer <Matrix> .WritePart(output, value.M34);

            MathTypeSerializer <Matrix> .WritePart(output, value.M41);

            MathTypeSerializer <Matrix> .WritePart(output, value.M42);

            MathTypeSerializer <Matrix> .WritePart(output, value.M43);

            MathTypeSerializer <Matrix> .WriteLast(output, value.M44);
        }
コード例 #15
0
        /// <summary>Serializes an object into an intermediate XML file.</summary>
        /// <param name="output">The output XML stream.</param>
        /// <param name="value">The object to be serialized.</param>
        /// <param name="referenceRelocationPath">Final name of the output file, used to relative encode external reference filenames.</param>
        public static void Serialize <T>(XmlWriter output, T value, string referenceRelocationPath)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            Uri baseUri = IntermediateSerializer.RelocationPathToUri(referenceRelocationPath);
            IntermediateWriter intermediateWriter = new IntermediateWriter(IntermediateSerializer.SingletonInstance, output, baseUri);

            output.WriteStartElement("XnaContent");
            new XmlNamespaces(intermediateWriter).WriteNamespaces(value);
            ContentSerializerAttribute contentSerializerAttribute = new ContentSerializerAttribute();

            contentSerializerAttribute.ElementName = "Asset";
            intermediateWriter.WriteObject <object>(value, contentSerializerAttribute);
            intermediateWriter.WriteSharedResources();
            intermediateWriter.WriteExternalReferences();
            output.WriteEndElement();
        }
コード例 #16
0
 protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (format == null)
     {
         throw new ArgumentNullException("format");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (!base.IsTargetType(value))
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.WrongArgumentType, new object[]
         {
             base.TargetType,
             value.GetType()
         }));
     }
     format = this.ApplyCustomFormatting(format);
     if (this.baseSerializer != null)
     {
         this.baseSerializer.Serialize(output, value, format);
     }
     foreach (ReflectiveSerializerMemberHelper current in this.memberHelpers)
     {
         current.Serialize(output, value);
     }
     if (this.collectionHelper != null)
     {
         this.collectionHelper.Serialize(output, format, value);
     }
 }
コード例 #17
0
 protected internal override void Serialize(IntermediateWriter output, T[] value, ContentSerializerAttribute format)
 {
     this.arrayHelper.Serialize(output, format, value);
 }
コード例 #18
0
 protected internal override void Serialize(IntermediateWriter output, List <T> value, ContentSerializerAttribute format)
 {
     this.collectionHelper.Serialize(output, format, value);
 }
コード例 #19
0
 protected static void WriteLast(IntermediateWriter output, float value)
 {
     output.Xml.WriteString(XmlConvert.ToString(value));
 }
コード例 #20
0
 protected static void WritePart(IntermediateWriter output, float value)
 {
     output.Xml.WriteString(XmlConvert.ToString(value));
     output.Xml.WriteWhitespace(" ");
 }
コード例 #21
0
 /// <summary>Serializes an object to intermediate XML format.</summary>
 /// <param name="output">Specifies the intermediate XML location, and provides various serialization helpers.</param>
 /// <param name="value">The object to be serialized.</param>
 /// <param name="format">Specifies the content format for this object.</param>
 protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
 {
     this.Serialize(output, ContentTypeSerializer <T> .CastType(value), format);
 }
コード例 #22
0
 /// <summary>Serializes an object to intermediate XML format.</summary>
 /// <param name="output">Specifies the intermediate XML location, and provides various serialization helpers.</param>
 /// <param name="value">The strongly typed object to be serialized.</param>
 /// <param name="format">Specifies the content format for this object.</param>
 protected internal abstract void Serialize(IntermediateWriter output, T value, ContentSerializerAttribute format);
コード例 #23
0
 protected internal override void Serialize(IntermediateWriter output, Color value, ContentSerializerAttribute format)
 {
     base.Serialize(output, ColorSerializer.SwapBgra(value), format);
 }
コード例 #24
0
 protected internal override void Serialize(IntermediateWriter output, T?value, ContentSerializerAttribute format)
 {
     output.WriteRawObject <T>(value.Value, this.underlyingFormat, this.underlyingTypeSerializer);
 }
コード例 #25
0
 public XmlNamespaces(IntermediateWriter writer)
 {
     this.writer = writer;
 }