Example #1
0
        private WideViewEntry GenerateWideViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            WideControlBody            mainControl = (WideControlBody)base.dataBaseInfo.view.mainControl;
            WideControlEntryDefinition activeWideControlEntryDefinition = this.GetActiveWideControlEntryDefinition(mainControl, so);

            return(new WideViewEntry {
                formatPropertyField = base.GenerateFormatPropertyField(activeWideControlEntryDefinition.formatTokenList, so, enumerationLimit)
            });
        }
        private WideControlEntryDefinition LoadWideControlEntry(XmlNode wideControlEntryNode, int index)
        {
            using (this.StackFrame(wideControlEntryNode, index))
            {
                bool appliesToNodeFound     = false; // cardinality 0..1
                bool propertyEntryNodeFound = false; // cardinality 1

                WideControlEntryDefinition wved = new WideControlEntryDefinition();

                foreach (XmlNode n in wideControlEntryNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.EntrySelectedByNode))
                    {
                        if (appliesToNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return(null); // fatal
                        }

                        appliesToNodeFound = true;
                        wved.appliesTo     = LoadAppliesToSection(n, true);
                    }
                    else if (MatchNodeName(n, XmlTags.WideItemNode))
                    {
                        if (propertyEntryNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return(null); // fatal
                        }

                        propertyEntryNodeFound = true;
                        wved.formatTokenList   = LoadPropertyEntry(n);
                        if (wved.formatTokenList == null)
                        {
                            // Error at XPath {0} in file {1}: Invalid {2}.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, ComputeCurrentXPath(), FilePath, XmlTags.WideItemNode));
                            return(null); // fatal
                        }
                    }
                    else
                    {
                        ProcessUnknownNode(n);
                    }
                }

                if (wved.formatTokenList.Count == 0)
                {
                    // Error at XPath {0} in file {1}: Missing WideItem.
                    this.ReportMissingNode(XmlTags.WideItemNode);
                    return(null); // fatal error
                }

                return(wved);
            }
        }
        private void LoadWideControlEntries(XmlNode wideControlEntriesNode, WideControlBody wideBody)
        {
            using (this.StackFrame(wideControlEntriesNode))
            {
                int entryIndex = 0;

                foreach (XmlNode n in wideControlEntriesNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.WideEntryNode))
                    {
                        WideControlEntryDefinition wved = LoadWideControlEntry(n, entryIndex++);
                        if (wved == null)
                        {
                            // Error at XPath {0} in file {1}: Invalid {2}.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, ComputeCurrentXPath(), FilePath, XmlTags.WideEntryNode));
                            return;
                        }
                        // determine if we have a default entry and if it's already set
                        if (wved.appliesTo == null)
                        {
                            if (wideBody.defaultEntryDefinition == null)
                            {
                                wideBody.defaultEntryDefinition = wved;
                            }
                            else
                            {
                                // Error at XPath {0} in file {1}: There cannot be more than one default {2}.
                                this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.WideEntryNode));
                                wideBody.defaultEntryDefinition = null;
                                return; // fatal error
                            }
                        }
                        else
                        {
                            wideBody.optionalEntryList.Add(wved);
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (wideBody.defaultEntryDefinition == null)
                {
                    // Error at XPath {0} in file {1}: There must be at least one default {2}.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.WideEntryNode));
                }
            }
        }
        private WideViewEntry GenerateWideViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            WideControlBody wideBody = (WideControlBody)this.dataBaseInfo.view.mainControl;

            WideControlEntryDefinition activeWideControlEntryDefinition =
                GetActiveWideControlEntryDefinition(wideBody, so);

            WideViewEntry wve = new WideViewEntry();

            wve.formatPropertyField = GenerateFormatPropertyField(activeWideControlEntryDefinition.formatTokenList, so, enumerationLimit);

            //wve.alignment = activeWideViewEntryDefinition.alignment;

            return(wve);
        }
Example #5
0
 internal WideControlEntryItem(WideControlEntryDefinition definition)
 {
     this._selectedBy = new List<string>();
     FieldPropertyToken token = definition.formatTokenList[0] as FieldPropertyToken;
     if (token != null)
     {
         if (token.expression.isScriptBlock)
         {
             this._entry = new System.Management.Automation.DisplayEntry(token.expression.expressionValue, DisplayEntryValueType.ScriptBlock);
         }
         else
         {
             this._entry = new System.Management.Automation.DisplayEntry(token.expression.expressionValue, DisplayEntryValueType.Property);
         }
     }
     if (definition.appliesTo != null)
     {
         foreach (TypeOrGroupReference reference in definition.appliesTo.referenceList)
         {
             this._selectedBy.Add(reference.name);
         }
     }
 }
Example #6
0
 private WideControlEntryDefinition LoadWideControlEntryFromObjectModel(WideControlEntryItem wideItem, int viewIndex, string typeName)
 {
     WideControlEntryDefinition definition = new WideControlEntryDefinition();
     if (wideItem.SelectedBy.Count > 0)
     {
         definition.appliesTo = this.LoadAppliesToSectionFromObjectModel(wideItem.SelectedBy);
     }
     ExpressionToken token = this.LoadExpressionFromObjectModel(wideItem.DisplayEntry, viewIndex, typeName);
     if (token == null)
     {
         return null;
     }
     FieldPropertyToken item = new FieldPropertyToken {
         expression = token
     };
     definition.formatTokenList.Add(item);
     return definition;
 }
Example #7
0
 private WideControlEntryDefinition LoadWideControlEntry(System.Xml.XmlNode wideControlEntryNode, int index)
 {
     using (base.StackFrame(wideControlEntryNode, index))
     {
         bool flag = false;
         bool flag2 = false;
         WideControlEntryDefinition definition = new WideControlEntryDefinition();
         foreach (System.Xml.XmlNode node in wideControlEntryNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "EntrySelectedBy"))
             {
                 if (flag)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag = true;
                 definition.appliesTo = this.LoadAppliesToSection(node, true);
             }
             else if (base.MatchNodeName(node, "WideItem"))
             {
                 if (flag2)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag2 = true;
                 definition.formatTokenList = this.LoadPropertyEntry(node);
                 if (definition.formatTokenList == null)
                 {
                     base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, new object[] { base.ComputeCurrentXPath(), base.FilePath, "WideItem" }));
                     return null;
                 }
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         if (definition.formatTokenList.Count == 0)
         {
             base.ReportMissingNode("WideItem");
             return null;
         }
         return definition;
     }
 }
Example #8
0
        /// <summary>
        /// Load WideEntry into WieControlEntryDefinition
        /// </summary>
        /// <param name="wideItem"></param>
        /// <param name="viewIndex"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        private WideControlEntryDefinition LoadWideControlEntryFromObjectModel(WideControlEntryItem wideItem, int viewIndex, string typeName)
        {
            WideControlEntryDefinition wved = new WideControlEntryDefinition();

            // Contains:
            //   SelectedBy   --- EntrySelectedBy (TypeName)  cardinality 0..1
            //   DisplayEntry --- WideItem (Expression)       cardinality 1
            // process selectedBy property
            if (wideItem.EntrySelectedBy != null)
            {
                wved.appliesTo = LoadAppliesToSectionFromObjectModel(wideItem.EntrySelectedBy.TypeNames, wideItem.EntrySelectedBy.SelectionCondition);
            }

            // process displayEntry property
            ExpressionToken expression = LoadExpressionFromObjectModel(wideItem.DisplayEntry, viewIndex, typeName);
            if (expression == null)
            {
                return null; // fatal
            }
            FieldPropertyToken fpt = new FieldPropertyToken();
            fpt.expression = expression;
            fpt.fieldFormattingDirective.formatString = wideItem.FormatString;
            wved.formatTokenList.Add(fpt);

            return wved;
        }
Example #9
0
        private WideControlEntryDefinition LoadWideControlEntry(XmlNode wideControlEntryNode, int index)
        {
            using (this.StackFrame(wideControlEntryNode, index))
            {
                bool appliesToNodeFound = false;     // cardinality 0..1
                bool propertyEntryNodeFound = false; // cardinality 1

                WideControlEntryDefinition wved = new WideControlEntryDefinition();

                foreach (XmlNode n in wideControlEntryNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.EntrySelectedByNode))
                    {
                        if (appliesToNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; //fatal
                        }

                        appliesToNodeFound = true;
                        wved.appliesTo = LoadAppliesToSection(n, true);
                    }
                    else if (MatchNodeName(n, XmlTags.WideItemNode))
                    {
                        if (propertyEntryNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; //fatal
                        }

                        propertyEntryNodeFound = true;
                        wved.formatTokenList = LoadPropertyEntry(n);
                        if (wved.formatTokenList == null)
                        {
                            //Error at XPath {0} in file {1}: Invalid {2}.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, ComputeCurrentXPath(), FilePath, XmlTags.WideItemNode));
                            return null; //fatal
                        }
                    }
                    else
                    {
                        ProcessUnknownNode(n);
                    }
                }

                if (wved.formatTokenList.Count == 0)
                {
                    //Error at XPath {0} in file {1}: Missing WideItem.
                    this.ReportMissingNode(XmlTags.WideItemNode);
                    return null; //fatal error
                }
                return wved;
            }
        }
        internal WideControlEntryItem(WideControlEntryDefinition definition) : this()
        {
            FieldPropertyToken fpt = definition.formatTokenList[0] as FieldPropertyToken;
            if (fpt != null)
            {
                DisplayEntry = new DisplayEntry(fpt.expression);
                FormatString = fpt.fieldFormattingDirective.formatString;
            }

            if (definition.appliesTo != null)
            {
                EntrySelectedBy = EntrySelectedBy.Get(definition.appliesTo.referenceList);
            }
        }