/// <summary> /// Generates xml element containing the settings. /// </summary> /// <param name="rootElemName">Name to be used as a name of the root element.</param> /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param> /// <returns>XElement containing the settings</returns> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName); if (!suppressDefaults || !IsDefaultDensity) { rootElem.Add(new XAttribute("density", Density.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultAvgDistance) { rootElem.Add(new XAttribute("avgDistance", IsDefaultAvgDistance ? DefaultAvgDistanceCode : AvgDistance.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultAllowSelfConnection) { rootElem.Add(new XAttribute("allowSelfConnection", AllowSelfConnection.ToString(CultureInfo.InvariantCulture).ToLowerInvariant())); } if (!suppressDefaults || !IsDefaultConstantNumOfConnections) { rootElem.Add(new XAttribute("constantNumOfConnections", ConstantNumOfConnections.ToString(CultureInfo.InvariantCulture).ToLowerInvariant())); } if (!suppressDefaults || !IsDefaultReplaceExistingConnections) { rootElem.Add(new XAttribute("replaceExistingConnections", ReplaceExistingConnections.ToString(CultureInfo.InvariantCulture).ToLowerInvariant())); } if (!suppressDefaults || !IsDefaultRepetitions) { rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture))); } Validate(rootElem, XsdTypeName); return(rootElem); }
/// <summary> /// Generates xml element containing the settings. /// </summary> /// <param name="rootElemName">Name to be used as a name of the root element.</param> /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param> /// <returns>XElement containing the settings</returns> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName, new XAttribute("targetPool", TargetPoolName), new XAttribute("targetConnDensity", TargetConnectionDensity.ToString(CultureInfo.InvariantCulture)), new XAttribute("sourcePool", SourcePoolName), new XAttribute("sourceConnDensity", SourceConnectionDensity.ToString(CultureInfo.InvariantCulture)) ); if (!suppressDefaults || !IsDefaultConstantNumOfConnections) { rootElem.Add(new XAttribute("constantNumOfConnections", ConstantNumOfConnections.ToString(CultureInfo.InvariantCulture).ToLowerInvariant())); } Validate(rootElem, XsdTypeName); return(rootElem); }