Esempio n. 1
0
        public void TestIsRegistered()
        {
            const string key = "IsRegisteredKey";

            Assert.AreEqual(false, FeatureDescriptor.IsRegistered(key));
            FeatureDescriptor.Register(key, typeof(int));
            Assert.AreEqual(true, FeatureDescriptor.IsRegistered(key));
        }
Esempio n. 2
0
        /// <summary>
        /// Overwrite of the <see cref="JsonConverter"/> method
        /// Deserializes the <see cref="FeatureDescriptor"/> json created by the this class
        /// </summary>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            string value = (string)reader.Value;

            if (value.Contains("|"))
            {
                string[]          strings     = value.Split('|');
                string            key         = strings[0].Trim();
                string            featureType = strings[1].Trim();
                Type              currType    = Type.GetType(featureType);
                FeatureDescriptor fd          = FeatureDescriptor.Register(key, currType);
                return(fd);
            }
            else
            {
                FeatureDescriptor fd = FeatureDescriptor.Get(value);
                return(fd);
            }
        }