示例#1
0
        protected override IEnumerable <PageControlBase> CreateItems()
        {
            var containerPageControl = new PageControlContainer(ID, 0, ContainerType.GetValueOrDefault(PageControlContainerType.ContentArea));

            containerPageControl.Properties.CaptionML.Set(CaptionML);
            containerPageControl.Properties.Description = Description;
            containerPageControl.Properties.Name        = Name;
            containerPageControl.AutoCaption(AutoCaption);
            yield return(containerPageControl);

            var variables = new List <PSVariable>()
            {
                new PSVariable("ControlIndentation", 1)
            };
            var subObjects = SubObjects?
                             .InvokeWithContext(null, variables)
                             .Select(o => o.BaseObject)
                             .Cast <PageControlBase>()
                             ?? Enumerable.Empty <PageControlBase>();

            foreach (var childControl in subObjects)
            {
                yield return(childControl);
            }
        }
示例#2
0
        public static IEnumerable <ParameterBase> ToParameters(this PageControlContainer pageControlContainer)
        {
            yield return(new SimpleParameter("ID", pageControlContainer.ID));

            foreach (var parameter in pageControlContainer.AllProperties.WithAValue.SelectMany(p => p.ToParameters()))
            {
                yield return(parameter);
            }

            yield return(new ScriptBlockParameter("SubObjects", pageControlContainer.Children.Select(c => c.ToInvocation())));
        }
        public static void Write(this PageControlContainer containerPageControl, CSideWriter writer, int propertyIndentation)
        {
            var debt               = 0;
            var controlID          = BuildControlPart(containerPageControl.ID.ToString(), 4, ref debt);
            var controlIndentation = BuildControlPart(containerPageControl.IndentationLevel.AsString(), 4, ref debt);
            var controlType        = BuildControlPart("Container", 10, ref debt);
            var declaration        = string.Format("{{ {0};{1};{2};", controlID, controlIndentation, controlType);

            writer.WriteLine(declaration);

            writer.Indent(propertyIndentation);
            containerPageControl.Properties.Write(PropertiesStyle.Field, writer);
            writer.WriteLine("}");
            writer.Unindent();
            writer.InnerWriter.WriteLine();
        }