Пример #1
0
        /// <summary>
        /// Used for XML serialization.
        /// Write an XML content of the object without a root element
        /// </summary>
        /// <param name="writer">Xml writer</param>
        public override void WriteXml(XmlWriter writer)
        {
            TagsXmlFactory             tagsXmlFactory             = new TagsXmlFactory();
            ConfigsXmlFactory          configsXmlFactory          = new ConfigsXmlFactory();
            BootstrapActionsXmlFactory bootstrapActionsXmlFactory = new BootstrapActionsXmlFactory();
            StepsXmlFactory            stepsXmlFactory            = new StepsXmlFactory();

            writer.WriteElementString("name", this.Name);
            writer.WriteElementString("logUri", this.LogUri);
            writer.WriteElementString("ec2KeyName", this.Ec2KeyName);
            writer.WriteElementString("jobFlowRole", this.JobFlowRole);
            writer.WriteElementString("amiVersion", this.AmiVersion);
            writer.WriteElementString("hadoopVersion", this.HadoopVersion);
            writer.WriteElementString("masterInstanceType", this.MasterInstanceType);
            writer.WriteElementString("slaveInstanceType", this.SlaveInstanceType);
            writer.WriteElementString("instanceCount", this.InstanceCount.ToString());
            writer.WriteElementString("keepJobflowAliveWhenNoSteps", this.KeepJobFlowAliveWhenNoSteps.ToString().ToLower());
            writer.WriteElementString("terminationProtected", this.TerminationProtected.ToString().ToLower());
            writer.WriteElementString("additionalInfo", this.AdditionalInfo);

            tagsXmlFactory.WriteItems(writer, this.Tags);
            configsXmlFactory.WriteItems(writer, this.Configs);
            bootstrapActionsXmlFactory.WriteItems(writer, this.BootstrapActions);
            stepsXmlFactory.WriteItems(writer, this.Steps);
        }
Пример #2
0
        /// <summary>
        /// Used for XML deserialization.
        /// Populate object nested items from the nested xml-branch
        /// </summary>
        /// <param name="reader">Xml reader</param>
        protected override bool ReadXmlBranch(XmlReader reader)
        {
            switch (reader.Name)
            {
            case TagsXmlFactory.RootXmlElement:
                TagsXmlFactory tagsXmlFactory = new TagsXmlFactory();
                this.Tags = tagsXmlFactory.ReadItems(reader);
                return(true);

            case ConfigsXmlFactory.RootXmlElement:
                ConfigsXmlFactory configsXmlFactory = new ConfigsXmlFactory();
                this.Configs = configsXmlFactory.ReadItems(reader);
                return(true);

            case BootstrapActionsXmlFactory.RootXmlElement:
                BootstrapActionsXmlFactory bootstrapActionsXmlFactory = new BootstrapActionsXmlFactory();
                this.BootstrapActions = bootstrapActionsXmlFactory.ReadItems(reader);
                return(true);

            case StepsXmlFactory.RootXmlElement:
                StepsXmlFactory stepsXmlFactory = new StepsXmlFactory();
                this.Steps = stepsXmlFactory.ReadItems(reader);
                return(true);
            }

            return(false);
        }
Пример #3
0
        public void TestDeserialization()
        {
            //Expectation
            IList <StepBase> stepsExpected = this.GetTestStepsList();

            //Action
            XmlDocument stepsXml = new XmlDocument();

            stepsXml.Load("TestData/Steps.xml");
            StepsXmlFactory  stepsXmlFactory = new StepsXmlFactory();
            IList <StepBase> stepsActual     = stepsXmlFactory.ReadXml(stepsXml.OuterXml);

            //Verify
            Assert.IsTrue(stepsExpected.SequenceEqual(stepsActual), "Unexpected steps deserialization result");
        }
Пример #4
0
        public void TestSerialization()
        {
            //Expectation
            XmlDocument stepsExpectedXml = new XmlDocument();

            stepsExpectedXml.Load("TestData/Steps.xml");

            //Action
            StepsXmlFactory stepsXmlFactory = new StepsXmlFactory();
            string          xml             = stepsXmlFactory.WriteXml(this.GetTestStepsList());

            XmlDocument stepsActualXml = new XmlDocument();

            stepsActualXml.LoadXml(xml); //load to the XmlDocument to make the same formatting

            //Verify
            Assert.AreEqual(stepsExpectedXml.OuterXml, stepsActualXml.OuterXml, "Unexpected steps serialization result");
        }