Example #1
0
        private ComplexViewEntry GenerateComplexViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            // execute on the format directive
            ComplexViewEntry cve = new ComplexViewEntry();

            // NOTE: we set a max depth to protect ourselves from infinite loops
            const int maxTreeDepth = 50;
            ComplexControlGenerator controlGenerator =
                new ComplexControlGenerator(this.dataBaseInfo.db,
                                            this.dataBaseInfo.view.loadingInfo,
                                            this.expressionFactory,
                                            this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList,
                                            this.ErrorManager,
                                            enumerationLimit,
                                            this.errorContext);

            controlGenerator.GenerateFormatEntries(maxTreeDepth,
                                                   this.dataBaseInfo.view.mainControl, so, cve.formatValueList);
            return(cve);
        }
        private ComplexViewEntry GenerateComplexViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            // execute on the format directive
            ComplexViewEntry cve = new ComplexViewEntry();

            // NOTE: we set a max depth to protect ourselves from infinite loops
            const int maxTreeDepth = 50;
            ComplexControlGenerator controlGenerator =
                            new ComplexControlGenerator(this.dataBaseInfo.db,
                                    this.dataBaseInfo.view.loadingInfo,
                                    this.expressionFactory,
                                    this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList,
                                    this.ErrorManager,
                                    enumerationLimit,
                                    this.errorContext);

            controlGenerator.GenerateFormatEntries(maxTreeDepth,
                this.dataBaseInfo.view.mainControl, so, cve.formatValueList);
            return cve;
        }
        internal GroupStartData GenerateGroupStartData(PSObject firstObjectInGroup, int enumerationLimit)
        {
            GroupStartData startGroup = new GroupStartData();

            if (_groupingManager is null)
            {
                return(startGroup);
            }

            object currentGroupingValue = _groupingManager.CurrentGroupingKeyPropertyValue;

            if (currentGroupingValue == AutomationNull.Value)
            {
                return(startGroup);
            }

            PSObject so = PSObjectHelper.AsPSObject(currentGroupingValue);

            // we need to determine how to display the group header
            ControlBase control        = null;
            TextToken   labelTextToken = null;

            if (this.dataBaseInfo.view != null && this.dataBaseInfo.view.groupBy != null)
            {
                if (this.dataBaseInfo.view.groupBy.startGroup != null)
                {
                    // NOTE: from the database constraints, only one of the
                    // two will be non null
                    control        = this.dataBaseInfo.view.groupBy.startGroup.control;
                    labelTextToken = this.dataBaseInfo.view.groupBy.startGroup.labelTextToken;
                }
            }

            startGroup.groupingEntry = new GroupingEntry();

            if (control is null)
            {
                // we do not have a control, we auto generate a
                // snippet of complex display using a label

                StringFormatError formatErrorObject = null;
                if (_errorManager.DisplayFormatErrorString)
                {
                    // we send a format error object down to the formatting calls
                    // only if we want to show the formatting error strings
                    formatErrorObject = new StringFormatError();
                }

                string currentGroupingValueDisplay = PSObjectHelper.SmartToString(so, this.expressionFactory, enumerationLimit, formatErrorObject);

                if (formatErrorObject != null && formatErrorObject.exception != null)
                {
                    // if we did no thave any errors in the expression evaluation
                    // we might have errors in the formatting, if present
                    _errorManager.LogStringFormatError(formatErrorObject);
                    if (_errorManager.DisplayFormatErrorString)
                    {
                        currentGroupingValueDisplay = _errorManager.FormatErrorString;
                    }
                }

                FormatEntry fe = new FormatEntry();
                startGroup.groupingEntry.formatValueList.Add(fe);

                FormatTextField ftf = new FormatTextField();

                // determine what the label should be. If we have a label from the
                // database, let's use it, else fall back to the string provided
                // by the grouping manager
                string label;
                if (labelTextToken != null)
                {
                    label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(labelTextToken);
                }
                else
                {
                    label = _groupingManager.GroupingKeyDisplayName;
                }

                ftf.text = StringUtil.Format(FormatAndOut_format_xxx.GroupStartDataIndentedAutoGeneratedLabel, label);

                fe.formatValueList.Add(ftf);

                FormatPropertyField fpf = new FormatPropertyField();

                fpf.propertyValue = currentGroupingValueDisplay;
                fe.formatValueList.Add(fpf);
            }
            else
            {
                // NOTE: we set a max depth to protect ourselves from infinite loops
                const int maxTreeDepth = 50;
                ComplexControlGenerator controlGenerator =
                    new ComplexControlGenerator(this.dataBaseInfo.db,
                                                this.dataBaseInfo.view.loadingInfo,
                                                this.expressionFactory,
                                                this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList,
                                                this.ErrorManager,
                                                enumerationLimit,
                                                this.errorContext);

                controlGenerator.GenerateFormatEntries(maxTreeDepth,
                                                       control, firstObjectInGroup, startGroup.groupingEntry.formatValueList);
            }

            return(startGroup);
        }
Example #4
0
        internal GroupStartData GenerateGroupStartData(PSObject firstObjectInGroup, int enumerationLimit)
        {
            GroupStartData startGroup = new GroupStartData();
            if (_groupingManager == null)
                return startGroup;

            object currentGroupingValue = _groupingManager.CurrentGroupingKeyPropertyValue;

            if (currentGroupingValue == AutomationNull.Value)
                return startGroup;

            PSObject so = PSObjectHelper.AsPSObject(currentGroupingValue);

            // we need to determine how to display the group header
            ControlBase control = null;
            TextToken labelTextToken = null;
            if (this.dataBaseInfo.view != null && this.dataBaseInfo.view.groupBy != null)
            {
                if (this.dataBaseInfo.view.groupBy.startGroup != null)
                {
                    // NOTE: from the database constraints, only one of the
                    // two will be non null
                    control = this.dataBaseInfo.view.groupBy.startGroup.control;
                    labelTextToken = this.dataBaseInfo.view.groupBy.startGroup.labelTextToken;
                }
            }

            startGroup.groupingEntry = new GroupingEntry();

            if (control == null)
            {
                // we do not have a control, we auto generate a
                // snippet of complex display using a label

                StringFormatError formatErrorObject = null;
                if (_errorManager.DisplayFormatErrorString)
                {
                    // we send a format error object down to the formatting calls
                    // only if we want to show the formatting error strings
                    formatErrorObject = new StringFormatError();
                }

                string currentGroupingValueDisplay = PSObjectHelper.SmartToString(so, this.expressionFactory, enumerationLimit, formatErrorObject);

                if (formatErrorObject != null && formatErrorObject.exception != null)
                {
                    // if we did no thave any errors in the expression evaluation
                    // we might have errors in the formatting, if present
                    _errorManager.LogStringFormatError(formatErrorObject);
                    if (_errorManager.DisplayFormatErrorString)
                    {
                        currentGroupingValueDisplay = _errorManager.FormatErrorString;
                    }
                }


                FormatEntry fe = new FormatEntry();
                startGroup.groupingEntry.formatValueList.Add(fe);

                FormatTextField ftf = new FormatTextField();

                // determine what the label should be. If we have a label from the
                // database, let's use it, else fall back to the string provided
                // by the grouping manager
                string label;
                if (labelTextToken != null)
                    label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(labelTextToken);
                else
                    label = _groupingManager.GroupingKeyDisplayName;

                ftf.text = StringUtil.Format(FormatAndOut_format_xxx.GroupStartDataIndentedAutoGeneratedLabel, label);

                fe.formatValueList.Add(ftf);

                FormatPropertyField fpf = new FormatPropertyField();

                fpf.propertyValue = currentGroupingValueDisplay;
                fe.formatValueList.Add(fpf);
            }
            else
            {
                // NOTE: we set a max depth to protect ourselves from infinite loops
                const int maxTreeDepth = 50;
                ComplexControlGenerator controlGenerator =
                                new ComplexControlGenerator(this.dataBaseInfo.db,
                                        this.dataBaseInfo.view.loadingInfo,
                                        this.expressionFactory,
                                        this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList,
                                        this.ErrorManager,
                                        enumerationLimit,
                                        this.errorContext);

                controlGenerator.GenerateFormatEntries(maxTreeDepth,
                    control, firstObjectInGroup, startGroup.groupingEntry.formatValueList);
            }
            return startGroup;
        }