public static string Print(ApplicationGatewayConfiguration config)
        {
            MemoryStream stream = new MemoryStream();

            var settings = new XmlWriterSettings()
            {
                Indent      = true,
                IndentChars = "    "
            };

            DataContractSerializer serializer = new DataContractSerializer(typeof(ApplicationGatewayConfiguration));

            using (var writer = XmlWriter.Create(stream, settings))
            {
                try
                {
                    serializer.WriteObject(writer, config);
                }
                catch (Exception e)
                {
                    throw new ApplicationGatewayConfigurationException(
                              string.Format("Error Serializing config: {0}", config.ToString()), e);
                }
            }

            stream.Position = 0;
            var sr = new StreamReader(stream);

            return(sr.ReadToEnd());
        }
        public static ApplicationGatewayConfiguration Deserialize(string xmlConfig)
        {
            byte[]       byteArray = Encoding.UTF8.GetBytes(xmlConfig);
            MemoryStream stream    = new MemoryStream(byteArray);

            DataContractSerializer          serializer         = new DataContractSerializer(typeof(ApplicationGatewayConfiguration));
            ApplicationGatewayConfiguration deserializedConfig = null;

            try
            {
                deserializedConfig = (ApplicationGatewayConfiguration)serializer.ReadObject(stream);
            }
            catch (Exception e)
            {
                throw new ApplicationGatewayConfigurationException(
                          string.Format("Error deserializing config: {0}", xmlConfig), e);
            }

            return(deserializedConfig);
        }
 internal ApplicationGatewayConfigurationContext(ApplicationGatewayConfiguration configuration)
     : this()
 {
     this.Configuration = configuration;
 }