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); } } }
/// <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 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); }
/// <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); }
protected override void Serialize(IntermediateWriter output, SharedResourceList <T> value, ContentSerializerAttribute format) { foreach (T item in value) { output.WriteSharedResource(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); }
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); }
protected override void Serialize(IntermediateWriter output, FloatColour value, ContentSerializerAttribute format) { if (output == null) { throw new ArgumentNullException("output"); } WritePart(output, value.R); WritePart(output, value.G); WriteLast(output, value.B); }
protected override void Serialize(IntermediateWriter output, Color[] value, ContentSerializerAttribute format) { if (value != null) { for (int i = 0; i < value.Length; i++) { output.Xml.WriteString(value[i].ToString() + " "); } } }
protected override void Serialize(IntermediateWriter output, Interval <T> value, ContentSerializerAttribute format) { if (value.Low.Equals(value.High)) { output.Xml.WriteValue(string.Format(CultureInfo.InvariantCulture, "{0}", value.Low)); } else { output.Xml.WriteValue(string.Format(CultureInfo.InvariantCulture, "{0} to {1}", value.Low, value.High)); } }
protected override void Serialize(IntermediateWriter output, AttributeModifier <TAttribute> value, ContentSerializerAttribute format) { switch (value.ComputationType) { case AttributeComputationType.Additive: output.Xml.WriteValue(string.Format(CultureInfo.InvariantCulture, "{0}", value.Value) + " " + Enum.GetName(typeof(TAttribute), value.Type)); break; case AttributeComputationType.Multiplicative: output.Xml.WriteValue(string.Format(CultureInfo.InvariantCulture, "{0}", ((value.Value - 1) * 100)) + "% " + Enum.GetName(typeof(TAttribute), value.Type)); break; } }
protected override void Serialize(IntermediateWriter output, Vector4[] value, ContentSerializerAttribute format) { StringBuilder sb = new StringBuilder(); if (value != null) { foreach (var v in value) { sb.AppendFormat(CultureInfo.InvariantCulture, "{0:0.#####} {1:0.#####} {2:0.#####} {3:0.#####} ", v.x, v.y, v.z, v.w); } } output.Xml.WriteString(sb.ToString()); }
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 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 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()); }
/// <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"); }
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()); }
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" }); } } }
/// <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, RotationModifier value, ContentSerializerAttribute format) { output.WriteObject("RotationRate", value.RotationRate); }
/// <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, $safeitemname$ value, ContentSerializerAttribute format) { // TODO serialize $safeitemname$ fields & properties... }
/// <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 abstract void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format);
protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format) { Debug.Assert(value.GetType() == TargetType, "Got invalid value type!"); output.Xml.WriteString(value.ToString()); }
protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format) { // First serialize the base type. if (_baseSerializer != null) _baseSerializer.Serialize(output, value, format); // Now serialize our own elements. foreach (var info in _elements) { var elementValue = info.Getter(value); if (info.Attribute.SharedResource) output.WriteSharedResource(elementValue, info.Attribute); else output.WriteObjectInternal(elementValue, info.Attribute, info.Serializer, info.Serializer.TargetType); } }
/// <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, TimedReleaseQuantityController value, ContentSerializerAttribute format) { }
/// <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, PointEmitter value, ContentSerializerAttribute format) { // PointEmitter has no additional fields from AbstractEmitter... return; }
protected override void Serialize(IntermediateWriter output, Vector2[] value, ContentSerializerAttribute format) { throw new NotImplementedException(); }
/// <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); }
protected override void Serialize(IntermediateWriter output, Vector2 value, ContentSerializerAttribute format) { output.Xml.WriteString(value.x + " " + value.y); }
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, Range value, ContentSerializerAttribute format) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; output.Xml.WriteString(String.Format(invariantCulture, "{0:G}", value)); }
/// <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); }
protected internal override void Serialize (IntermediateWriter output, object value, ContentSerializerAttribute format) { throw new System.NotImplementedException(); }
protected override void Serialize(IntermediateWriter output, BoneWeight w, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format) { output.Xml.WriteString(String.Format("{0} {1} {2} {3} {4} {5} {6} {7}", w.weights.x, w.weights.y, w.weights.z, w.weights.w, w.boneIndex0, w.boneIndex1, w.boneIndex2, w.boneIndex3)); }
/// <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 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, RotationRange value, ContentSerializerAttribute format) { output.WriteObject("Pitch", value.Pitch); output.WriteObject("Yaw", value.Yaw); output.WriteObject("Roll", value.Roll); }
protected override void Serialize(IntermediateWriter output, Rect value, Microsoft.Xna.Framework.Content.ContentSerializerAttribute format) { throw new NotImplementedException(); }