示例#1
0
 public void Deserialize_NullStream()
 {
     try
     {
         FeatureModelCollection.Deserialize(null);
         Assert.Fail("An ArgumentNullException was expected.");
     }
     catch (System.ArgumentNullException) { }
 }
示例#2
0
        /// <summary>
        ///     Creates an instance of <see href="IFeatureSwitch"/>.
        ///
        ///     The sole parameter is a stream that represents the
        ///     feature configuration file.
        /// </summary>
        public static IFeatureSwitch Create(System.IO.Stream stream)
        {
            if (stream == null)
            {
                throw new System.ArgumentNullException("stream");
            }

            FeatureSwitch result = new FeatureSwitch();

            result.ParseFeatureSwitches(FeatureModelCollection.Deserialize(stream));
            return(result);
        }
示例#3
0
        internal void ParseFeatureSwitches(FeatureModelCollection collection)
        {
            if(collection == null)
                throw new System.ArgumentNullException("collection");

            foreach(FeatureModel model in collection.Items)
            {
                if(Features.ContainsKey(model.Key))
                    Features[model.Key] = model.Enabled;
                else
                    Features.Add(model.Key, model.Enabled);
            }
        }
示例#4
0
        internal void ParseFeatureSwitches(FeatureModelCollection collection)
        {
            if (collection == null)
            {
                throw new System.ArgumentNullException("collection");
            }

            foreach (FeatureModel model in collection.Items)
            {
                if (Features.ContainsKey(model.Key))
                {
                    Features[model.Key] = model.Enabled;
                }
                else
                {
                    Features.Add(model.Key, model.Enabled);
                }
            }
        }
示例#5
0
        public void Deserialize()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<Features xmlns=""https://www.kcl-data.com"">
    <Feature Key=""TestKey"" Enabled=""false""/>
</Features>";

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            StreamWriter           writer = new StreamWriter(stream);

            writer.Write(xml);
            writer.Flush();

            stream.Position = 0;

            FeatureModelCollection collection = FeatureModelCollection.Deserialize(stream);

            Assert.IsNotNull(collection);
            Assert.AreEqual(1, collection.Items.Count);
            Assert.AreEqual("TestKey", collection.Items[0].Key);
            Assert.IsFalse(collection.Items[0].Enabled);
        }