/// <summary> /// Serialize a <see cref="ParameterValueElement"/> object out to XML. /// This method is aware of and implements the shorthand attributes /// for dependency and value elements. /// </summary> /// <param name="writer">Writer to output XML to.</param> /// <param name="element">The <see cref="ParameterValueElement"/> to serialize.</param> /// <param name="elementsOnly">If true, always output an element. If false, then /// dependency and value elements will be serialized as attributes in the parent tag.</param> public static void SerializeParameterValueElement(XmlWriter writer, ParameterValueElement element, bool elementsOnly) { string tag = GetTagForElement(element); if (!elementsOnly) { var attributeOnlyElement = element as IAttributeOnlyElement; if (attributeOnlyElement != null) { attributeOnlyElement.SerializeContent(writer); } else { writer.WriteElement(tag, element.SerializeContent); } } else { writer.WriteElement(tag, element.SerializeContent); } }
/// <summary> /// Gets a <see cref="ParameterValueElement"/>, or if none is present, /// returns a default <see cref="DependencyElement"/>. /// </summary> /// <param name="currentValue">The <see cref="ParameterValueElement"/>.</param> /// <returns>The given <paramref name="currentValue"/>, unless /// <paramref name="currentValue"/> is null, in which case returns /// a <see cref="DependencyElement"/>.</returns> public static ParameterValueElement GetValue(ParameterValueElement currentValue) { return(currentValue ?? DefaultDependency); }