public void All_setting_attrib_ctors_should_work_as_expected()
        {
            /* Arrange / Act */
            var a1 = new ConfigSettingAttribute();
            var a2 = new ConfigSettingAttribute(true);
            var a3 = new ConfigSettingAttribute("New Name");
            var a4 = new ConfigSettingAttribute("New Name", true);

            var a5 = new ConfigSettingAttribute
            {
                Description = "Some Description"
            };

            /* Assert */
            a1.Description.Should().BeNull();
            a1.Encrypt.Should().BeFalse();
            a1.SettingName.Should().BeNull();

            a2.Description.Should().BeNull();
            a2.Encrypt.Should().BeTrue();
            a2.SettingName.Should().BeNull();

            a3.Description.Should().BeNull();
            a3.Encrypt.Should().BeFalse();
            a3.SettingName.Should().Be("New Name");

            a4.Description.Should().BeNull();
            a4.Encrypt.Should().BeTrue();
            a4.SettingName.Should().Be("New Name");

            a5.Description.Should().Be("Some Description");
        }
 private void DiscoverMoreSysvars()
 {
     foreach (var ms in LockInfo.CopyOf(Plugins).Values)
     {
         ConfigSettingAttribute.AddSingletonClass(ms.GetType());
     }
 }
Exemple #3
0
 private object ConvertType00(object o, Type type)
 {
     if (type == typeof(TimeSpan))
     {
         double seconds;
         if (double.TryParse("" + o, out seconds))
         {
             return(TimeSpan.FromSeconds(seconds));
         }
     }
     if (FilterSpecAttribute.IsAssignableFrom(typeof(SimObject), type))
     {
         return(AsSimObject(o));
     }
     if (FilterSpecAttribute.IsAssignableFrom(typeof(Primitive), type))
     {
         return(AsSimObject(o).Prim);
     }
     if (FilterSpecAttribute.IsAssignableFrom(typeof(UUID), type))
     {
         SimObject nullCheck = AsSimObject(o);
         if (nullCheck == null)
         {
             return(null);
         }
         return(nullCheck.ID);
     }
     if (o is IConvertible)
     {
         if (typeof(IConvertible).IsAssignableFrom(type))
         {
             try
             {
                 return(Convert.ChangeType(o, type));
             }
             catch
             {
             }
         }
     }
     return(ConfigSettingAttribute.FindValueOfType(o, type, 2));
 }
 public static void LoadSysVars(Type t)
 {
     lock (SysVars0)
     {
         ConfigSettingAttribute pca = ConfigSettingAttribute.FindConfigSetting(t, false);
         bool allMembers            = pca != null;
         foreach (
             var s in
             t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                          BindingFlags.Static))
         {
             ConfigSettingAttribute cs0;
             if (!s.IsDefined(typeof(ConfigSettingAttribute), true))
             {
                 if (!ConfigSettingAttribute.IsGoodForConfig(s, true, allMembers, true, allMembers))
                 {
                     continue;
                 }
                 cs0 = ConfigSettingAttribute.FindConfigSetting(s, true);
             }
             else
             {
                 cs0 = ConfigSettingAttribute.FindConfigSetting(s, true);
             }
             if (!cs0.IsNonValue && !SysVars0.Contains(cs0))
             {
                 SysVars0.Add(cs0);
             }
             //  WriteLine("Setting: " + cs0.Description);
         }
         var st = t.BaseType;
         if (st != null && st != typeof(object))
         {
             LoadSysVars(st);
         }
     }
 }