Exemple #1
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 override void Serialize(IntermediateWriter output, SphereForceModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("Position", value.Position);
     output.WriteObject("Radius", value.Radius);
     output.WriteObject("ForceVector", value.ForceVector);
     output.WriteObject("Strength", value.Strength);
 }
 /// <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 override void Serialize(IntermediateWriter output, OpacityInterpolator3 value, ContentSerializerAttribute format)
 {
     output.WriteObject("InitialOpacity", value.InitialOpacity);
     output.WriteObject("Median", value.Median);
     output.WriteObject("MedianOpacity", value.MedianOpacity);
     output.WriteObject("FinalOpacity", value.FinalOpacity);
 }
 /// <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 override void Serialize(IntermediateWriter output, ParticleEffect value, ContentSerializerAttribute format)
 {
     output.WriteObject("Name", value.Name);
     output.WriteObject("Author", value.Author);
     output.WriteObject("Description", value.Description);
     output.WriteObject("Emitters", value.Emitters, "Item");
 }
Exemple #4
0
 /// <summary>
 /// Serializes the derived fields.
 /// </summary>
 /// <param name="output">The output.</param>
 /// <param name="value">The value.</param>
 /// <param name="format">The format.</param>
 protected override void SerializeDerivedFields(IntermediateWriter output, BoxEmitter value, ContentSerializerAttribute format)
 {
     output.WriteObject("Width", value.Width);
     output.WriteObject("Height", value.Height);
     output.WriteObject("Depth", value.Depth);
     output.WriteObject("Rotation", value.Rotation);
 }
        protected override void Serialize(IntermediateWriter output,
                                          SharedResourceDictionary <TKey, TValue> value,
                                          ContentSerializerAttribute format)
        {
            foreach (TKey key in value.Keys)
            {
                if (default(TKey) is ValueType)
                {
                    output.WriteObject(key, Keyformat);
                }
                else
                {
                    output.WriteSharedResource(key, Keyformat);
                }

                if (default(TValue) is ValueType)
                {
                    output.WriteObject(value[key], Valueformat);
                }
                else
                {
                    output.WriteSharedResource(value[key], Valueformat);
                }
            }
        }
        protected internal override void Serialize(IntermediateWriter output, NamedValueDictionary <T> value, ContentSerializerAttribute format)
        {
            var valueSerializer = output.Serializer.GetTypeSerializer(value.DefaultSerializerType);

            foreach (var kvp in value)
            {
                output.Xml.WriteStartElement(format.CollectionItemName);

                output.WriteObject(kvp.Key, _keyFormat, _keySerializer);
                output.WriteObject(kvp.Value, _valueFormat, valueSerializer);

                output.Xml.WriteEndElement();
            }
        }
        protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
        {
            // Create the item serializer attribute.
            var itemFormat = new ContentSerializerAttribute();
            itemFormat.ElementName = format.CollectionItemName;

            // Read all the items.
            foreach (var item in (IList) value)
                output.WriteObject(item, itemFormat);
        }
 /// <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 override void Serialize(IntermediateWriter output, BoxForceModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("Position", value.Position);
     output.WriteObject("Width", value.Width);
     output.WriteObject("Height", value.Height);
     output.WriteObject("Depth", value.Depth);
     output.WriteObject("Force", value.Force);
     output.WriteObject("Strength", value.Strength);
 }
Exemple #9
0
        protected override void Serialize(IntermediateWriter output, ParticleEffect value, ContentSerializerAttribute format)
        {
            foreach (Emitter emitter in value)
            {
                output.WriteObject(emitter, new ContentSerializerAttribute {
                    ElementName = "Item"
                });
            }

            output.Xml.WriteElementString("Name", value.Name);
            output.Xml.WriteElementString("Author", value.Author);
            output.Xml.WriteElementString("Description", value.Description);

            foreach (Controller controller in value.Controllers)
            {
                // Do not serialize the editor support controller...
                if (controller.GetType().Name != "EditorSupportController")
                {
                    output.WriteObject(controller, new ContentSerializerAttribute {
                        ElementName = "Controller"
                    });
                }
            }
        }
Exemple #10
0
        protected override void Serialize(IntermediateWriter output, MaskEmitter value, ContentSerializerAttribute format)
        {
            base.Serialize(output, value, format);

            output.Xml.WriteElementString("MaskTextureContentPath", value.MaskTextureContentPath);

            if (String.IsNullOrEmpty(value.MaskTextureContentPath))
            {
                output.WriteObject <byte[][]>(value.Mask, new ContentSerializerAttribute {
                    ElementName = "Mask"
                });
            }

            output.Xml.WriteElementString("Threshold", value.Threshold.ToString());
            output.Xml.WriteElementString("Width", value.Width.ToString());
            output.Xml.WriteElementString("Height", value.Height.ToString());
        }
 protected override void Serialize(IntermediateWriter output, T value, ContentSerializerAttribute format)
 {
     output.Xml.WriteElementString("Name", value.Name);
     output.Xml.WriteElementString("Budget", value.Budget.ToString());
     output.Xml.WriteElementString("Term", value.Term.ToString());
     output.Xml.WriteElementString("ReleaseQuantity", value.ReleaseQuantity.ToString());
     output.Xml.WriteElementString("Enabled", value.Enabled.ToString());
     output.WriteObject(value.ReleaseSpeed, new ContentSerializerAttribute {
         ElementName = "ReleaseSpeed"
     });
     output.WriteObject(value.ReleaseColour, new ContentSerializerAttribute {
         ElementName = "ReleaseColour"
     });
     output.WriteObject(value.ReleaseOpacity, new ContentSerializerAttribute {
         ElementName = "ReleaseOpacity"
     });
     output.WriteObject(value.ReleaseScale, new ContentSerializerAttribute {
         ElementName = "ReleaseScale"
     });
     output.WriteObject(value.ReleaseRotation, new ContentSerializerAttribute {
         ElementName = "ReleaseRotation"
     });
     output.WriteObject(value.ReleaseImpulse, new ContentSerializerAttribute {
         ElementName = "ReleaseImpulse"
     });
     output.Xml.WriteElementString("ParticleTextureAssetName", value.ParticleTextureAssetName);
     output.WriteObject(value.Modifiers, new ContentSerializerAttribute {
         ElementName = "Modifiers"
     });
     output.WriteObject(value.BlendMode, new ContentSerializerAttribute {
         ElementName = "BlendMode"
     });
     output.WriteObject(value.TriggerOffset, new ContentSerializerAttribute {
         ElementName = "TriggerOffset"
     });
     output.Xml.WriteElementString("MinimumTriggerPeriod", value.MinimumTriggerPeriod.ToString());
 }
 /// <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 override void Serialize(IntermediateWriter output, RotationModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("RotationRate", value.RotationRate);
 }
Exemple #13
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 override void Serialize(IntermediateWriter output, DampingModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("DampingCoefficient", value.DampingCoefficient);
 }
 /// <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 override void Serialize(IntermediateWriter output, TriggerRandomOffsetController value, ContentSerializerAttribute format)
 {
     output.WriteObject("Size", value.Size);
 }
 /// <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 override void Serialize(IntermediateWriter output, VelocityClampModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("MaximumVelocity", value.MaximumVelocity);
 }
Exemple #16
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 override void Serialize(IntermediateWriter output, HueShiftModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("HueShift", value.HueShift);
 }
        /// <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 override sealed void Serialize(IntermediateWriter output, T value, ContentSerializerAttribute format)
        {
            output.WriteObject("Name", value.Name);
            output.WriteObject("Budget", value.Budget);
            output.WriteObject("Term", value.Term);
            output.WriteObject("ReleaseQuantity", value.ReleaseQuantity);
            output.WriteObject("Enabled", value.Enabled);
            output.WriteObject("ReleaseSpeed", value.ReleaseSpeed);
            output.WriteObject("ReleaseColour", value.ReleaseColour);
            output.WriteObject("ReleaseOpacity", value.ReleaseOpacity);
            output.WriteObject("ReleaseScale", value.ReleaseScale);
            output.WriteObject("ReleaseRotation", value.ReleaseRotation);
            output.WriteObject("ParticleTextureAssetPath", value.ParticleTextureAssetPath);
            output.WriteObject("BlendMode", value.BlendMode);

            this.SerializeDerivedFields(output, value, format);

            output.WriteObject("Modifiers", value.Modifiers, "Modifier");
            output.WriteObject("Controllers", value.Controllers, "Controller");
        }
 /// <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 override void Serialize(IntermediateWriter output, TriggerRotationController value, ContentSerializerAttribute format)
 {
     output.WriteObject("TriggerRotation", value.TriggerRotation);
 }
 /// <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 override void Serialize(IntermediateWriter output, ColourRange value, ContentSerializerAttribute format)
 {
     output.WriteObject("Red", value.Red);
     output.WriteObject("Green", value.Green);
     output.WriteObject("Blue", value.Blue);
 }
 /// <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 override void Serialize(IntermediateWriter output, LinearGravityModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("GravityVector", value.GravityVector);
     output.WriteObject("Strength", value.Strength);
 }
Exemple #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 strongly typed object to be serialized.</param>
 /// <param name="format">Specifies the content format for this object.</param>
 protected override void Serialize(IntermediateWriter output, OpacityFastFadeModifier value, ContentSerializerAttribute format)
 {
     output.WriteObject("InitialOpacity", value.InitialOpacity);
 }
 /// <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 override void Serialize(IntermediateWriter output, CooldownController value, ContentSerializerAttribute format)
 {
     output.WriteObject("CooldownPeriod", value.CooldownPeriod);
 }
 /// <summary>
 /// Writes a single object to the output XML stream.
 /// </summary>
 /// <typeparam name="T">The type of object to write.</typeparam>
 /// <param name="instance">Extension instance.</param>
 /// <param name="elementName">The name of the XML element.</param>
 /// <param name="value">The value to serialize.</param>
 /// <param name="collectionItemName">The name of child elements if <typeparamref name="T"/> is a collection type.</param>
 static public void WriteObject <T>(this IntermediateWriter instance, string elementName, T value, string collectionItemName)
 {
     instance.WriteObject <T>(value, new ContentSerializerAttribute {
         ElementName = elementName, CollectionItemName = collectionItemName
     });
 }
 /// <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 override void Serialize(IntermediateWriter output, ColourInterpolator2 value, ContentSerializerAttribute format)
 {
     output.WriteObject("InitialColour", value.InitialColour);
     output.WriteObject("FinalColour", value.FinalColour);
 }
 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);
     }
 }
 /// <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 override void Serialize(IntermediateWriter output, RotationRange value, ContentSerializerAttribute format)
 {
     output.WriteObject("Pitch", value.Pitch);
     output.WriteObject("Yaw", value.Yaw);
     output.WriteObject("Roll", value.Roll);
 }
 /// <summary>
 /// Serializes only the fields of the derived emitter class 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 override void SerializeDerivedFields(IntermediateWriter output, SphereEmitter value, ContentSerializerAttribute format)
 {
     output.WriteObject("Radius", value.Radius);
     output.WriteObject("Shell", value.Shell);
     output.WriteObject("Radiate", value.Radiate);
 }