Exemplo n.º 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);
        }
Exemplo n.º 2
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));
        }