Пример #1
0
 /// <summary>
 /// 使用类型及属性对 <paramref name="settings"/> 进行绑定。
 /// </summary>
 /// <param name="modelType">模型类型。</param>
 /// <param name="propertyName">属性名称。</param>
 /// <param name="settings"></param>
 public static void Bind(Type modelType, string propertyName, ISettingsBindable settings)
 {
     foreach (var binder in binders.Where(s => s.Value.CanBind(settings)))
     {
         binder.Value.Bind(modelType, propertyName, settings);
     }
 }
Пример #2
0
        public void Bind(Type modelType, string propertyName, ISettingsBindable settings)
        {
            //模型类型必须实现自 IEntity
            if (!typeof(IEntity).IsAssignableFrom(modelType))
            {
                return;
            }

            //获取对应的依赖属性
            var property = PropertyUnity.GetProperty(modelType, propertyName);

            if (property == null)
            {
                return;
            }

            var vsettings = settings as ValidateBoxSettings;
            //获取依赖属性所指定的验证特性
            var validTypes = new List <string>();

            foreach (var validation in ValidationUnity.GetValidations(property))
            {
                ParseValidation(vsettings, validation, validTypes);
            }

            vsettings.ValidType = validTypes.ToArray();
        }
Пример #3
0
        public void Bind(Type modelType, string propertyName, ISettingsBindable settings)
        {
            var nsettings = settings as NumberBoxSettings;

            if (!typeof(IEntity).IsAssignableFrom(modelType))
            {
                return;
            }

            //获取对应的依赖属性
            var property = PropertyUnity.GetProperty(modelType, propertyName);

            if (property == null)
            {
                return;
            }

            nsettings.Precision = property.Info.Scale;

            //找 RangeAttribute 特性
            var range = ValidationUnity.GetValidations(property).Where(s => s is RangeAttribute).Cast <RangeAttribute>().FirstOrDefault();

            if (range != null)
            {
                nsettings.Min = range.Minimum.To <decimal?>();
                nsettings.Max = range.Maximum.To <decimal?>();
            }
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel(ISettingsBindable settings)
 {
     this.Settings = settings;
     ////if (IsInDesignMode)
     ////{
     ////    // Code runs in Blend --> create design time data.
     ////}
     ////else
     ////{
     ////    // Code runs "for real"
     ////}
 }
Пример #5
0
        public Feeder(vJoy joy, ISimpleLogger logger, ISettingsBindable settings, Interop interop)
        {
            this._joy      = joy;
            this._logger   = logger;
            this._settings = settings;
            this._interop  = interop;

            this._timer.Interval = settings.TimerInterval;

            this._timer.Elapsed            += this.OnTimerTick;
            this._settings.PropertyChanged += this.OnSettingsPropertyChanged;

            this._joy.ResetVJD(this._settings.DeviceID);
        }
        public ControlsViewModel(ISimpleLogger logger, ISettingsManager settingsManager, ISettingsBindable settings, Feeder feeder)
        {
            this._logger = logger;
            this._feeder = feeder;

            this._settingsManager = settingsManager;
            this.Settings         = settings;

            this.StartStopCommand = new RelayCommand(this.StartStop);
            this.LoadCommand      = new RelayCommand(this._settingsManager.LoadFromFile);
            this.SaveCommand      = new RelayCommand(this._settingsManager.SaveToFile);
        }
        public SettingsManager(ISimpleLogger logger, JsonFileManager jsonFileManager, ISettingsBindable settings)
        {
            this._logger          = logger;
            this._jsonFileManager = jsonFileManager;
            this._settings        = settings;

            LoadDefault();
        }
Пример #8
0
 public bool CanBind(ISettingsBindable settings)
 {
     return(typeof(ValidateBoxSettings).IsAssignableFrom(settings.GetType()));
 }