/// <summary> /// Writes the object to an XElement instance using the specified root element name. /// </summary> /// <param name="rootElement">Root element name</param> /// <returns>XElement representation of the object</returns> public override XElement WriteToXml(XName rootElement) { // ReSharper disable AssignNullToNotNullAttribute return(new XElement( rootElement, new XAttribute(NAME, Name), ProcessorType == null ? null : new XAttribute(PROCESSOR_TYPE, ProcessorType), TaskType == null ? null : new XAttribute(TASK_TYPE, TaskType.AssemblyQualifiedName), ArgumentType == null ? null : new XAttribute(ARGUMENT_TYPE, ArgumentType.AssemblyQualifiedName), ResultType == null ? null : new XAttribute(RESULT_TYPE, ResultType.AssemblyQualifiedName), PeekPolicyType == null ? null : new XAttribute(PEEK_POLICY, PeekPolicyType.AssemblyQualifiedName), new XAttribute(INSTANCE_COUNT, InstanceCount), Context == null ? null : Context.WriteToXml(EXECUTION_CONTEXT), _propertysSettings.Count == 0 ? null : _propertysSettings.WriteToXml(PROPERTIES))); }
public void ConstructorWorksWithXElement2() { // --- Act var collection1 = new PropertySettingsCollection( new List <PropertySettings> { new PropertySettings(new PropertySettings("Prop1", "2").WriteToXml("temp")), new PropertySettings(new PropertySettings("Prop2", "Hello").WriteToXml("temp")), }); var element1 = collection1.WriteToXml("Test"); var collection2 = new PropertySettingsCollection(element1); // --- Assert element1.Elements("Property").ShouldHaveCountOf(2); collection2.ShouldHaveCountOf(2); }
public void ConstructorWorksWithXElement2() { // --- Act var collection1 = new PropertySettingsCollection( new List<PropertySettings> { new PropertySettings(new PropertySettings("Prop1", "2").WriteToXml("temp")), new PropertySettings(new PropertySettings("Prop2", "Hello").WriteToXml("temp")), }); var element1 = collection1.WriteToXml("Test"); var collection2 = new PropertySettingsCollection(element1); // --- Assert element1.Elements("Property").ShouldHaveCountOf(2); collection2.ShouldHaveCountOf(2); }
public void ConstructorWorksWithNullRootName() { // --- Act var collection1 = new PropertySettingsCollection( new List<PropertySettings> { new PropertySettings("Prop1", "2"), new PropertySettings("Prop2", "hello") }); var element1 = collection1.WriteToXml("Test"); var collection2 = new PropertySettingsCollection(); collection2.ReadFromXml(element1); // --- Assert element1.Elements("Property").ShouldHaveCountOf(2); collection2.ShouldHaveCountOf(2); }
public void ConstructorWorksWithNullRootName() { // --- Act var collection1 = new PropertySettingsCollection( new List <PropertySettings> { new PropertySettings("Prop1", "2"), new PropertySettings("Prop2", "hello") }); var element1 = collection1.WriteToXml("Test"); var collection2 = new PropertySettingsCollection(); collection2.ReadFromXml(element1); // --- Assert element1.Elements("Property").ShouldHaveCountOf(2); collection2.ShouldHaveCountOf(2); }