/// <summary> /// Writes this task to an XML writer, using the given parameters object. /// </summary> /// <param name="Writer">Writer for the XML schema</param> /// <param name="Parameters">Parameters object that this task is constructed with</param> protected void Write(XmlWriter Writer, object Parameters) { TaskElementAttribute Element = GetType().GetCustomAttribute <TaskElementAttribute>(); Writer.WriteStartElement(Element.Name); foreach (FieldInfo Field in Parameters.GetType().GetFields()) { if (Field.MemberType == MemberTypes.Field) { TaskParameterAttribute ParameterAttribute = Field.GetCustomAttribute <TaskParameterAttribute>(); if (ParameterAttribute != null) { object Value = Field.GetValue(Parameters); if (Value != null && Field.FieldType == typeof(bool) && (bool)Value == false) { Value = null; } if (Value != null) { Writer.WriteAttributeString(Field.Name, Value.ToString()); } } } } Writer.WriteEndElement(); }
/// <summary> /// Gets the name of this task for tracing /// </summary> /// <returns>The trace name</returns> public virtual string GetTraceName() { TaskElementAttribute TaskElement = GetType().GetCustomAttribute <TaskElementAttribute>(); return((TaskElement != null)? TaskElement.Name : "unknown"); }