public SinglePropertyBehaviorBuilder(VMDescriptorConfiguration configuration, BehaviorChainConfiguration propertyConfiguration, TDescriptor descriptor)
     : base(configuration)
 {
     Check.NotNull(propertyConfiguration, nameof(propertyConfiguration));
     _propertyConfiguration = propertyConfiguration;
     _descriptor            = descriptor;
 }
        /// <summary>
        ///   Creates a new <see cref="BehaviorChainConfiguration"/> from this
        ///   template.
        /// </summary>
        // TODO: Comment.
        internal BehaviorChainConfiguration CreateConfiguration(
            IBehaviorFactoryConfiguration factoryConfiguration
            )
        {
            Check.NotNull(factoryConfiguration, nameof(factoryConfiguration));

            var config = new BehaviorChainConfiguration();
            IBehaviorFactory factory = factoryConfiguration.GetFactory(_factoryProvider);

            foreach (BehaviorChainItemTemplate itemTemplate in _itemTemplates)
            {
                BehaviorKey key = itemTemplate.Key;

                if (itemTemplate.State == DefaultBehaviorState.DisabledWithoutFactory)
                {
                    config.Append(key);
                }
                else
                {
                    IBehavior instance = factory.Create(key);
                    config.Append(key, instance);

                    if (itemTemplate.State == DefaultBehaviorState.Enabled)
                    {
                        config.Enable(key);
                    }
                }
            }

            return(config);
        }
Exemple #3
0
 public void ReplaceConfiguration(BehaviorChainTemplateKey templateKey)
 {
     _configuration.ViewModelConfiguration = BehaviorChainConfiguration.GetConfiguration(
         templateKey,
         BehaviorFactoryConfigurations.ForViewModel <TVM>()
         );
 }
        public IVMPropertyDescriptor <TValue> CustomProperty <TValue>(BehaviorChainConfiguration behaviorChain)
        {
            var property = new VMPropertyDescriptor <TValue>();

            Configuration
            .PropertyConfigurations
            .RegisterProperty(property, behaviorChain);

            return(property);
        }
Exemple #5
0
        /// <summary>
        ///   Registers a <see cref="BehaviorChainConfiguration"/> for a certain
        ///   <paramref name="property"/>.
        /// </summary>
        public void RegisterProperty <TValue>(
            IVMPropertyDescriptor <TValue> property,
            BehaviorChainConfiguration configuration
            )
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(configuration, nameof(configuration));

            _propertyConfigurations.Add(property, configuration);
        }
        public IVMPropertyDescriptor <TValue> CustomProperty <TValue>(
            BehaviorChainTemplateKey templateKey,
            IBehaviorFactoryConfiguration factoryConfiguration,
            Action <BehaviorChainConfiguration> chainConfigurationAction
            )
        {
            var config = BehaviorChainConfiguration.GetConfiguration(templateKey, factoryConfiguration);

            chainConfigurationAction(config);
            return(CustomProperty <TValue>(config));
        }
Exemple #7
0
        /// <summary>
        ///   Creates concrete <see cref="BehaviorChain"/> objects for each registered
        ///   <see cref="BehaviorChainConfiguration"/> and assigns it to the <see
        ///   cref="IVMPropertyDescriptor.Behaviors"/> property of the <see cref="IVMPropertyDescriptor"/>
        ///   object for which the <see cref="BehaviorChainConfiguration"/> was
        ///   registered.
        /// </summary>
        internal void ApplyToProperties(IVMDescriptor parentDescriptor)
        {
            foreach (var pair in _propertyConfigurations)
            {
                IVMPropertyDescriptor      property = pair.Key;
                BehaviorChainConfiguration config   = pair.Value;

                var chain = config.CreateChain();
                chain.Initialize(parentDescriptor, property);
                property.Behaviors = chain;
            }
        }
Exemple #8
0
 public VMDependencyBuilder(BehaviorChainConfiguration viewModelConfiguration)
 {
     _viewModelConfiguration = viewModelConfiguration;
 }
Exemple #9
0
 public DependencyBuilderOperation(BehaviorChainConfiguration viewModelConfiguration)
 {
     _viewModelConfiguration = viewModelConfiguration;
     TargetProperties        = new QualifiedProperties();
 }