示例#1
0
        private static object LoadSetting(GlobalSettingsPropertyDefinition propDef)
        {
            object obj = propDef.Getter(propDef);
            PropertyConstraintViolationError propertyConstraintViolationError = propDef.Validate(obj);

            if (propertyConstraintViolationError != null)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueOutOfRange, new string[]
                {
                    propDef.Name,
                    propDef.ReadConstraint.ToString(),
                    obj.ToString(),
                    propDef.DefaultValue.ToString()
                });
                return(propDef.DefaultValue);
            }
            return(obj);
        }
        internal object DefaultGetter(GlobalSettingsPropertyDefinition propDef)
        {
            string appSetting = GlobalSettingsSchema.GetAppSetting(propDef);

            if (appSetting == null)
            {
                if (propDef.LogMissingEntries)
                {
                    AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueHasBeenDefaulted, new string[]
                    {
                        propDef.Name,
                        propDef.DefaultValue.ToString()
                    });
                }
                return(propDef.DefaultValue);
            }
            return(GlobalSettingsPropertyDefinition.ConvertValueFromString(propDef, appSetting));
        }
示例#3
0
        private static T LoadSetting <T>(GlobalSettingsPropertyDefinition propDef)
        {
            if (propDef.Type != typeof(T))
            {
                throw new ArgumentException(string.Format("Property {0} is not of the correct type {1}, but is a {2} property", propDef.Name, typeof(T).Name, propDef.Type.Name));
            }
            object obj = propDef.Getter(propDef);
            PropertyConstraintViolationError propertyConstraintViolationError = propDef.Validate(obj);

            if (propertyConstraintViolationError != null)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueOutOfRange, new string[]
                {
                    propDef.Name,
                    propDef.ReadConstraint.ToString(),
                    obj.ToString(),
                    propDef.DefaultValue.ToString()
                });
                return((T)((object)propDef.DefaultValue));
            }
            return((T)((object)obj));
        }
 public static object ConvertValueFromString(GlobalSettingsPropertyDefinition propDef, string valueToConvert)
 {
     return(GlobalSettingsPropertyDefinition.ConvertValueFromString(valueToConvert, propDef.Type, propDef.Name, propDef.DefaultValue));
 }
        public override bool Equals(object obj)
        {
            GlobalSettingsPropertyDefinition globalSettingsPropertyDefinition = obj as GlobalSettingsPropertyDefinition;

            return(globalSettingsPropertyDefinition != null && globalSettingsPropertyDefinition.Name == base.Name && globalSettingsPropertyDefinition.Type == base.Type);
        }
示例#6
0
        public static bool Clear(GlobalSettingsPropertyDefinition propDef)
        {
            object obj;

            return(GlobalSettings.settings.TryRemove(propDef, out obj));
        }
示例#7
0
 internal static object GetSetting(GlobalSettingsPropertyDefinition propDef)
 {
     return(GlobalSettings.settings.GetOrAdd(propDef, (GlobalSettingsPropertyDefinition propDef2) => GlobalSettings.LoadSetting(propDef2)));
 }
示例#8
0
 internal static T GetSetting <T>(GlobalSettingsPropertyDefinition propDef)
 {
     return((T)((object)GlobalSettings.settings.GetOrAdd(propDef, (GlobalSettingsPropertyDefinition propDef2) => GlobalSettings.LoadSetting <T>(propDef2))));
 }