Пример #1
0
        /// <summary>
        /// Creates the HTML object for each property that is part of the parent.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="attribute">The attribute.</param>
        /// <param name="nativeAttributes">The native attributes.</param>
        /// <returns>The expressions needed to create the list</returns>
        private IEnumerable <Expression> CreateWinControlObject(ControlBuilderContext context, ControlLocatorAttribute attribute, IEnumerable nativeAttributes)
        {
            var buildElement = context.CurrentControl ?? context.Window;
            var objectType   = this.GetPropertyProxyType(buildElement.Type);

            var propConstructor = this.GetConstructor(objectType, context);

            if (propConstructor == null)
            {
                throw this.CreateConstructorException(buildElement.Name, objectType);
            }

            var itemVariable = buildElement.Expression;

            return(new[]
            {
                (Expression)Expression.Assign(itemVariable, Expression.New(propConstructor.Item1, propConstructor.Item2)),
                Expression.Call(
                    Expression.Constant(this),
                    this.assignMethodInfo,
                    Expression.Convert(itemVariable, typeof(TControl)),
                    Expression.Constant(attribute, typeof(ControlLocatorAttribute)),
                    Expression.Constant(nativeAttributes, typeof(object[])))
            });
        }