Ejemplo n.º 1
0
 protected BindBoxBase(IConfigurationChangeNotifyable changeNotifyable, BindSettings bindSettings, ConfigBindMode mode)
 {
     ChangeNotifyable = changeNotifyable ?? throw new ArgumentNullException(nameof(changeNotifyable));
     BindSettings     = bindSettings ?? throw new ArgumentNullException(nameof(bindSettings));
     Mode             = mode;
     once             = new ConcurrentOnce();
 }
Ejemplo n.º 2
0
 public ObservableBindBox(IConfigurationChangeNotifyable changeNotifyable,
                          BindSettings bindSettings,
                          ConfigBindMode mode,
                          Action <Action> updater)
     : this(changeNotifyable, changeNotifyable, bindSettings, mode, updater)
 {
 }
Ejemplo n.º 3
0
 public BindBox(IConfigurationChangeNotifyable changeNotifyable, BindSettings bindSettings, ConfigBindMode mode, Action <Action> updater)
 {
     ChangeNotifyable = changeNotifyable ?? throw new ArgumentNullException(nameof(changeNotifyable));
     BindSettings     = bindSettings ?? throw new ArgumentNullException(nameof(bindSettings));
     Mode             = mode;
     Updater          = updater ?? throw new ArgumentNullException(nameof(updater));
     once             = new ConcurrentOnce();
 }
Ejemplo n.º 4
0
        public static BindBox Bind(this IConfigurationChangeNotifyable notifyable, BindSettings bindSettings, ConfigBindMode configBindMode)
        {
            var updater = bindSettings.Updater;

            if (updater is null)
            {
                updater = a => a();
            }
            var box = new BindBox(notifyable, bindSettings, configBindMode, updater);

            box.Bind();
            return(box);
        }
Ejemplo n.º 5
0
        public ObservableBindBox(IConfigurationChangeNotifyable changeNotifyable,
                                 IConfiguration configuration,
                                 BindSettings bindSettings,
                                 ConfigBindMode mode,
                                 Action <Action> updater)
            : base(changeNotifyable, bindSettings, mode, updater)
        {
            Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            NotifyObject  = bindSettings.Value as INotifyPropertyChanged;
            if (NotifyObject is null)
            {
                throw new InvalidCastException($"Can't case {changeNotifyable.GetType().FullName} to {typeof(INotifyPropertyChanged).FullName}");
            }
            notifyPropertyMap = NotifyObject.GetType().GetProperties()
                                .ToDictionary(x => x.Name, x => new PropertyBindBox(x));

            propertyConfigMap = new Dictionary <string, PropertyBindBox>();
            propertyVisitor   = CompilePropertyVisitor.Instance;
        }
Ejemplo n.º 6
0
        public static ObservableBindBox BindNotifyTwoWay(this IConfigurationChangeNotifyable notifyable, INotifyPropertyChanged value, params IChangeTransferCondition[] changeTransferConditions)
        {
            if (notifyable is null)
            {
                throw new ArgumentNullException(nameof(notifyable));
            }

            if (value is null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (changeTransferConditions is null)
            {
                throw new ArgumentNullException(nameof(changeTransferConditions));
            }

            var setting = new BindSettings(value, BindSettings.DefaultDelayTime, changeTransferConditions);

            return(BindNotifyNotify(notifyable, setting, ConfigBindMode.TwoWay));
        }
Ejemplo n.º 7
0
        public static BindBox Bind(this IConfigurationChangeNotifyable notifyable, BindSettings bindSettings, ConfigBindMode configBindMode)
        {
            if (notifyable is null)
            {
                throw new ArgumentNullException(nameof(notifyable));
            }

            if (bindSettings is null)
            {
                throw new ArgumentNullException(nameof(bindSettings));
            }

            var updater = bindSettings.Updater;

            if (updater is null)
            {
                updater = a => a();
            }
            var box = new BindBox(notifyable, bindSettings, configBindMode, updater);

            box.Bind();
            return(box);
        }
Ejemplo n.º 8
0
        public static BindBox BindTwoWay(this IConfigurationChangeNotifyable notifyable, object value, params IChangeTransferCondition[] changeTransferConditions)
        {
            var setting = new BindSettings(value, BindSettings.DefaultDelayTime, changeTransferConditions);

            return(Bind(notifyable, setting, ConfigBindMode.TwoWay));
        }
Ejemplo n.º 9
0
 public BindBox(IConfigurationChangeNotifyable changeNotifyable, BindSettings bindSettings, ConfigBindMode mode, Action <Action> updater)
     : base(changeNotifyable, bindSettings, mode)
 {
     Updater = updater ?? throw new ArgumentNullException(nameof(updater));
 }