Exemple #1
0
        /// <summary>
        /// Constructeur
        /// </summary>
        public DecisionCreateViewModel(IDecisionPersister decisionsStorage, IDomaineReference domaineReference)
            : base(decisionsStorage, domaineReference)
        {
            this.DecisionBuilder = new InstanceProperty <DecisionBuilder> {
                Value = new DecisionBuilder()
            };
            this.Register(nameof(this.DecisionBuilder), this.DecisionBuilder);
            this.Register(nameof(this.IsEnabled), this.IsEnabled);

            this.DomaineAdd     += (sender, domaine) => this.DecisionBuilder.Value.Domaines.Add(domaine);
            this.DomaineRemoved += (sender, domaine) => this.DecisionBuilder.Value.Domaines.Remove(domaine);
        }
Exemple #2
0
        private IEnumerable<PSAdaptedProperty> GetProperties(Instance instance)
        {
            yield return new PSAdaptedProperty("PSPath", new InstanceProperty { Type = typeof(string) });

            var properties = instance.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
            foreach (var property in properties)
            {
                var tag = new InstanceProperty { Type = property.PropertyType, Property = property };
                yield return new PSAdaptedProperty(property.Name, tag);
            }

            foreach (var keyValue in instance.AdditionalProperties)
            {
                var tag = new InstanceProperty { Type = keyValue.Value?.GetType() ?? typeof(object) };
                yield return new PSAdaptedProperty(keyValue.Key, tag);
            }
        }
Exemple #3
0
        public void InitProperties(LogicalInstance logicalInstance)
        {
            Type type   = GetType(logicalInstance.Type);
            var  fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);

            foreach (var field in fields.Where(item => item.FieldType == typeof(DependencyProperty)))
            {
                string propertyName = field.Name.Substring(0, field.Name.LastIndexOf("Property"));
                int    count        = logicalInstance.InstanceProperties.Count(property => property.Name == propertyName);
                if (count == 0)
                {
                    InstanceProperty instanceProperty = new InstanceProperty
                    {
                        Name            = propertyName,
                        LogicalInstance = logicalInstance
                    };
                    logicalInstance.InstanceProperties.Add(instanceProperty);
                }
            }
        }
Exemple #4
0
        private static void SetPropertyBindings(LogicalInstance logicalInstance, ObjectType objectType)
        {
            Type type   = objectType.GetType();
            var  fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);

            foreach (var field in fields)
            {
                if (field.FieldType == typeof(DependencyProperty))
                {
                    string           propertyName     = field.Name.Substring(0, field.Name.LastIndexOf("Property"));
                    InstanceProperty instanceProperty = logicalInstance.InstanceProperties.Single(item => item.Name == propertyName);
                    Binding          binding          = new Binding
                    {
                        Path   = new PropertyPath("Value"),
                        Mode   = BindingMode.TwoWay,
                        Source = instanceProperty
                    };
                    DependencyProperty dependencyProperty = field.GetValue(objectType) as DependencyProperty;
                    objectType.SetBinding(dependencyProperty, binding);
                }
            }
        }
Exemple #5
0
 void SetValue(ToolArgNode node, InstanceProperty pe)
 {
     if (node.Value != null)
     {
         if (pe.Property.PropertyType.Implements <IList>())
         {
             if (pe.Value == null)
             {
                 pe.Value = Activator.CreateInstance(pe.Property.PropertyType);
             }
             ((IList)pe.Value).Add(node.Value);
         }
         else
         {
             pe.Value = node.Value;
         }
     }
     else
     {
         pe.Value = true;
     }
 }
Exemple #6
0
 set => SetValue(InstanceProperty, value);