Ejemplo n.º 1
0
 public WindowPropertyData(
     IWindowControlHandler <TControl> controlHandler,
     string name,
     Type propertyType,
     Func <IWindow, Func <object, bool>, bool> action,
     Action <IWindow, object> setAction)
     : base(controlHandler, name, propertyType)
 {
     this.action   = action;
     this.IsWindow = true;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the properties.
        /// </summary>
        private void GetProperties()
        {
            const BindingFlags Flags = BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly;

            var windowType = this.WindowType;

            var control = this.GetWindowControl();

            this.properties.Add(control.Name, control);

            var locatorControl = this.GetNativeWindow <IControlProvider>();

            if (locatorControl != null)
            {
                foreach (var property in locatorControl.GetControls())
                {
                    var propertyData = new ControlPropertyData <TControl>(
                        this, property.PropertyName, property.PropertyType, AddValueProperty(property));

                    this.properties.Add(propertyData.Name, propertyData);
                }

                return;
            }

            foreach (var propertyInfo in windowType.GetProperties(Flags).Where(
                         p => p.CanRead && (this.SupportedPropertyType(p.PropertyType)) && this.TypeIsNotBaseClass(p)))
            {
                IPropertyData propertyData;

                if (typeof(TWindow).IsAssignableFrom(propertyInfo.PropertyType))
                {
                    IWindowControlHandler <TWindow> controlHandler = CreateNativeWindow(
                        this.window,
                        propertyInfo.PropertyType,
                        false);

                    var expressions = AddWindowProperty(windowType, propertyInfo);

                    propertyData = new WindowPropertyData <TWindow>(
                        controlHandler,
                        propertyInfo.Name,
                        propertyInfo.PropertyType,
                        expressions.Item1,
                        expressions.Item2);
                }
                else if (typeof(TControl).IsAssignableFrom(propertyInfo.PropertyType))
                {
                    var controlHandler = AddControlProperty(windowType, propertyInfo);
                    propertyData = new ControlPropertyData <TControl>(
                        this,
                        propertyInfo.Name,
                        propertyInfo.PropertyType,
                        controlHandler);
                }
                else
                {
                    throw new NotSupportedException($"Property: {propertyInfo}");
                }

                this.properties.Add(propertyData.Name, propertyData);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyDataBase{TControl}" /> class.
 /// </summary>
 /// <param name="controlHandler">The control handler.</param>
 /// <param name="name">The name of the property.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="controlAction">The control action.</param>
 public ControlPropertyData(IWindowControlHandler <TControl> controlHandler, string name, Type propertyType, Func <IWindow, Func <TControl, bool>, bool> controlAction)
     : base(controlHandler, name, propertyType)
 {
     this.controlAction = controlAction;
     this.IsControl     = true;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyDataBase{TControl}" /> class.
 /// </summary>
 /// <param name="controlHandler">The control handler.</param>
 /// <param name="name">The name of the property.</param>
 /// <param name="propertyType">Type of the property.</param>
 protected PropertyDataBase(IWindowControlHandler <TControl> controlHandler, string name, Type propertyType)
 {
     this.controlHandler = controlHandler;
     this.Name           = name;
     this.PropertyType   = propertyType;
 }