Example #1
0
        private void InjectProperties(IComponentContext context, IPresentationBusConfiguration bus, UIElement uiElement)
        {
            if (uiElement == null)
                return;

            context.InjectUnsetProperties(uiElement);

            var subscriber = uiElement as IHandlePresentationMessages;
            if (subscriber != null)
            {
                bus.Subscribe(subscriber);
            }

            InjectPropertiesForChildViews(context, bus, uiElement);
        }
        /// <summary>
        /// Override to return a closure that injects properties into a target.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The injector.</returns>
        protected override Func<object, object> GetInjector(IComponentContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            return target =>
                       {
                           var targetType = target.GetType();
                           if (targetType.GetCustomAttributes(typeof(InjectPropertiesAttribute), true).Length > 0)
                           {
                               return context.InjectProperties(target);
                           }
                           else if (targetType.GetCustomAttributes(typeof(InjectUnsetPropertiesAttribute), true).Length > 0)
                           {
                               return context.InjectUnsetProperties(target);
                           }
                           else
                           {
                               return target;
                           }
                       };
        }
Example #3
0
        /// <summary>
        /// Override to return a closure that injects properties into a target.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The injector.</returns>
        protected override Func <object, object> GetInjector(IComponentContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            return(target =>
            {
                var targetType = target.GetType();
                if (targetType.GetCustomAttributes(typeof(InjectPropertiesAttribute), true).Length > 0)
                {
                    return context.InjectProperties(target);
                }
                else if (targetType.GetCustomAttributes(typeof(InjectUnsetPropertiesAttribute), true).Length > 0)
                {
                    return context.InjectUnsetProperties(target);
                }
                else
                {
                    return target;
                }
            });
        }