Example #1
0
        private ListViewEntry GenerateListViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            ListViewEntry lve = new ListViewEntry();

            ListControlEntryDefinition activeListControlEntryDefinition =
                GetActiveListControlEntryDefinition(_listBody, so);

            foreach (ListControlItemDefinition listItem in activeListControlEntryDefinition.itemDefinitionList)
            {
                if (!EvaluateDisplayCondition(so, listItem.conditionToken))
                {
                    continue;
                }

                ListViewField lvf = new ListViewField();
                PSPropertyExpressionResult result;
                lvf.formatPropertyField = GenerateFormatPropertyField(listItem.formatTokenList, so, enumerationLimit, out result);

                // we need now to provide a label
                if (listItem.label != null)
                {
                    // if the directive provides one, we use it
                    lvf.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(listItem.label);
                }
                else if (result != null)
                {
                    // if we got a valid match from the Mshexpression, use it as a label
                    lvf.label = result.ResolvedExpression.ToString();
                }
                else
                {
                    // we did fail getting a result (i.e. property does not exist on the object)

                    // we try to fall back and see if we have an un-resolved PSPropertyExpression
                    FormatToken        token = listItem.formatTokenList[0];
                    FieldPropertyToken fpt   = token as FieldPropertyToken;
                    if (fpt != null)
                    {
                        PSPropertyExpression ex = this.expressionFactory.CreateFromExpressionToken(fpt.expression, this.dataBaseInfo.view.loadingInfo);

                        // use the un-resolved PSPropertyExpression string as a label
                        lvf.label = ex.ToString();
                    }
                    else
                    {
                        TextToken tt = token as TextToken;
                        if (tt != null)
                        {
                            // we had a text token, use it as a label (last resort...)
                            lvf.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                        }
                    }
                }

                lve.listViewFieldList.Add(lvf);
            }

            return(lve);
        }
Example #2
0
        internal ListControlEntryDefinition Copy()
        {
            ListControlEntryDefinition controlEntryDefinition = new ListControlEntryDefinition();

            controlEntryDefinition.appliesTo = this.appliesTo;
            foreach (ListControlItemDefinition itemDefinition in this.itemDefinitionList)
            {
                controlEntryDefinition.itemDefinitionList.Add(itemDefinition);
            }
            return(controlEntryDefinition);
        }
 internal ListControlEntryDefinition Copy()
 {
     ListControlEntryDefinition definition = new ListControlEntryDefinition {
         appliesTo = this.appliesTo
     };
     foreach (ListControlItemDefinition definition2 in this.itemDefinitionList)
     {
         definition.itemDefinitionList.Add(definition2);
     }
     return definition;
 }
        /// <summary>
        /// Returns a Shallow Copy of the current object.
        /// </summary>
        /// <returns></returns>
        internal ListControlEntryDefinition Copy()
        {
            ListControlEntryDefinition result = new ListControlEntryDefinition();
            result.appliesTo = this.appliesTo;
            foreach (ListControlItemDefinition lcid in this.itemDefinitionList)
            {
                result.itemDefinitionList.Add(lcid);
            }

            return result;
        }
Example #5
0
        /// <summary>
        /// Returns a Shallow Copy of the current object.
        /// </summary>
        /// <returns></returns>
        internal ListControlEntryDefinition Copy()
        {
            ListControlEntryDefinition result = new ListControlEntryDefinition();

            result.appliesTo = this.appliesTo;
            foreach (ListControlItemDefinition lcid in this.itemDefinitionList)
            {
                result.itemDefinitionList.Add(lcid);
            }

            return(result);
        }
Example #6
0
        internal ListControlEntryDefinition Copy()
        {
            ListControlEntryDefinition definition = new ListControlEntryDefinition {
                appliesTo = this.appliesTo
            };

            foreach (ListControlItemDefinition definition2 in this.itemDefinitionList)
            {
                definition.itemDefinitionList.Add(definition2);
            }
            return(definition);
        }
Example #7
0
        private void LoadListControlEntries(XmlNode listViewEntriesNode, ListControlBody listBody)
        {
            using (this.StackFrame(listViewEntriesNode))
            {
                int entryIndex = 0;

                foreach (XmlNode n in listViewEntriesNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.ListEntryNode))
                    {
                        ListControlEntryDefinition lved = LoadListControlEntryDefinition(n, entryIndex++);
                        if (lved == null)
                        {
                            //Error at XPath {0} in file {1}: {2} failed to load.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailed, ComputeCurrentXPath(), FilePath, XmlTags.ListEntryNode));
                            listBody.defaultEntryDefinition = null;
                            return; // fatal error
                        }
                        // determine if we have a default entry and if it's already set
                        if (lved.appliesTo == null)
                        {
                            if (listBody.defaultEntryDefinition == null)
                            {
                                listBody.defaultEntryDefinition = lved;
                            }
                            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.ListEntryNode));
                                listBody.defaultEntryDefinition = null;
                                return; // fatal error
                            }
                        }
                        else
                        {
                            listBody.optionalEntryList.Add(lved);
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (listBody.optionalEntryList == 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.ListEntryNode));
                }
            }
        }
Example #8
0
        private ListControlEntryDefinition LoadListControlEntryDefinition(XmlNode listViewEntryNode, int index)
        {
            using (this.StackFrame(listViewEntryNode, index))
            {
                bool appliesToNodeFound = false;    // cardinality 0..1
                bool bodyNodeFound      = false;    // cardinality 1

                ListControlEntryDefinition lved = new ListControlEntryDefinition();

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

                        appliesToNodeFound = true;

                        // optional section
                        lved.appliesTo = LoadAppliesToSection(n, true);
                    }
                    else if (MatchNodeName(n, XmlTags.ListItemsNode))
                    {
                        if (bodyNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return(null); //fatal
                        }

                        bodyNodeFound = true;
                        LoadListControlItemDefinitions(lved, n);
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (lved.itemDefinitionList == null)
                {
                    //Error at XPath {0} in file {1}: Missing definition list.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefinitionList, ComputeCurrentXPath(), FilePath));
                    return(null);
                }

                return(lved);
            }
        }
Example #9
0
 internal ListControlEntry(ListControlEntryDefinition entrydefn)
 {
     this._items = new List<ListControlEntryItem>();
     this._entrySelectedBy = new List<string>();
     if (entrydefn.appliesTo != null)
     {
         foreach (TypeOrGroupReference reference in entrydefn.appliesTo.referenceList)
         {
             this._entrySelectedBy.Add(reference.name);
         }
     }
     foreach (ListControlItemDefinition definition in entrydefn.itemDefinitionList)
     {
         this._items.Add(new ListControlEntryItem(definition));
     }
 }
Example #10
0
        private void LoadListControlItemDefinitions(ListControlEntryDefinition lved, XmlNode bodyNode)
        {
            using (this.StackFrame(bodyNode))
            {
                int index = 0;

                foreach (XmlNode n in bodyNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.ListItemNode))
                    {
                        index++;
                        ListControlItemDefinition lvid = LoadListControlItemDefinition(n);
                        if (lvid == null)
                        {
                            //Error at XPath {0} in file {1}: Invalid property entry.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidPropertyEntry, ComputeCurrentXPath(), FilePath));
                            lved.itemDefinitionList = null;
                            return; //fatal
                        }

                        lved.itemDefinitionList.Add(lvid);
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                // we must have at least a definition in th elist
                if (lved.itemDefinitionList.Count == 0)
                {
                    //Error at XPath {0} in file {1}: At least one list view item must be specified.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoListViewItem, ComputeCurrentXPath(), FilePath));
                    lved.itemDefinitionList = null;
                    return; //fatal
                }
            }
        }
Example #11
0
 private ListControlEntryDefinition LoadListControlEntryDefinitionFromObjectModel(ListControlEntry listEntry, int viewIndex, string typeName)
 {
     ListControlEntryDefinition lved = new ListControlEntryDefinition();
     if (listEntry.SelectedBy.Count > 0)
     {
         lved.appliesTo = this.LoadAppliesToSectionFromObjectModel(listEntry.SelectedBy);
     }
     this.LoadListControlItemDefinitionsFromObjectModel(lved, listEntry.Items, viewIndex, typeName);
     if (lved.itemDefinitionList == null)
     {
         return null;
     }
     return lved;
 }
Example #12
0
 private ListControlEntryDefinition LoadListControlEntryDefinition(System.Xml.XmlNode listViewEntryNode, int index)
 {
     using (base.StackFrame(listViewEntryNode, index))
     {
         bool flag = false;
         bool flag2 = false;
         ListControlEntryDefinition lved = new ListControlEntryDefinition();
         foreach (System.Xml.XmlNode node in listViewEntryNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "EntrySelectedBy"))
             {
                 if (flag)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag = true;
                 lved.appliesTo = this.LoadAppliesToSection(node, true);
             }
             else if (base.MatchNodeName(node, "ListItems"))
             {
                 if (flag2)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag2 = true;
                 this.LoadListControlItemDefinitions(lved, node);
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         if (lved.itemDefinitionList == null)
         {
             base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefinitionList, base.ComputeCurrentXPath(), base.FilePath));
             return null;
         }
         return lved;
     }
 }
        private ListControlEntryDefinition LoadListControlEntryDefinition(XmlNode listViewEntryNode, int index)
        {
            using (this.StackFrame(listViewEntryNode, index))
            {
                bool appliesToNodeFound = false;    // cardinality 0..1
                bool bodyNodeFound = false;         // cardinality 1

                ListControlEntryDefinition lved = new ListControlEntryDefinition();

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

                        appliesToNodeFound = true;

                        // optional section
                        lved.appliesTo = LoadAppliesToSection(n, true);
                    }
                    else if (MatchNodeName(n, XmlTags.ListItemsNode))
                    {
                        if (bodyNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; //fatal
                        }

                        bodyNodeFound = true;
                        LoadListControlItemDefinitions(lved, n);
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (lved.itemDefinitionList == null)
                {
                    //Error at XPath {0} in file {1}: Missing definition list.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefinitionList, ComputeCurrentXPath(), FilePath));
                    return null;
                }

                return lved;
            }
        }
Example #14
0
        /// <summary>
        /// Load ListItems into ListControlItemDefinition
        /// </summary>
        /// <param name="lved"></param>
        /// <param name="listItems"></param>
        /// <param name="viewIndex"></param>
        /// <param name="typeName"></param>
        private void LoadListControlItemDefinitionsFromObjectModel(ListControlEntryDefinition lved, List<ListControlEntryItem> listItems, int viewIndex, string typeName)
        {
            foreach (ListControlEntryItem listItem in listItems)
            {
                ListControlItemDefinition lvid = new ListControlItemDefinition();

                // Contains:
                //   DisplayEntry --- Expression  cardinality 0..1
                //   Label        --- Label       cardinality 0..1
                if (listItem.DisplayEntry != null)
                {
                    ExpressionToken expression = LoadExpressionFromObjectModel(listItem.DisplayEntry, viewIndex, typeName);
                    if (expression == null)
                    {
                        lved.itemDefinitionList = null;
                        return; // fatal
                    }
                    FieldPropertyToken fpt = new FieldPropertyToken();
                    fpt.expression = expression;
                    fpt.fieldFormattingDirective.formatString = listItem.FormatString;
                    lvid.formatTokenList.Add(fpt);
                }

                if (!String.IsNullOrEmpty(listItem.Label))
                {
                    TextToken tt = new TextToken();
                    tt.text = listItem.Label;
                    lvid.label = tt;
                }

                lved.itemDefinitionList.Add(lvid);
            }

            // we must have at least a definition in th elist
            if (lved.itemDefinitionList.Count == 0)
            {
                //Error: At least one list view item must be specified.
                this.ReportErrorForLoadingFromObjectModel(
                    StringUtil.Format(FormatAndOutXmlLoadingStrings.NoListViewItemInFormattingData, typeName, viewIndex), typeName);
                lved.itemDefinitionList = null;
                return; //fatal
            }
        }
Example #15
0
        /// <summary>
        /// Load ListEntry into ListControlEntryDefinition
        /// </summary>
        /// <param name="listEntry"></param>
        /// <param name="viewIndex"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        private ListControlEntryDefinition LoadListControlEntryDefinitionFromObjectModel(ListControlEntry listEntry, int viewIndex, string typeName)
        {
            ListControlEntryDefinition lved = new ListControlEntryDefinition();

            // Contains:
            //   SelectedBy ---  EntrySelectedBy(TypeName)  cardinality 0..1
            //   Items      ---  ListItems                  cardinality 1
            if (listEntry.EntrySelectedBy != null)
            {
                lved.appliesTo = LoadAppliesToSectionFromObjectModel(listEntry.EntrySelectedBy.TypeNames, listEntry.EntrySelectedBy.SelectionCondition);
            }

            LoadListControlItemDefinitionsFromObjectModel(lved, listEntry.Items, viewIndex, typeName);
            if (lved.itemDefinitionList == null)
            {
                return null;
            }

            return lved;
        }
        private void LoadListControlItemDefinitions(ListControlEntryDefinition lved, XmlNode bodyNode)
        {
            using (this.StackFrame(bodyNode))
            {
                int index = 0;

                foreach (XmlNode n in bodyNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.ListItemNode))
                    {
                        index++;
                        ListControlItemDefinition lvid = LoadListControlItemDefinition(n);
                        if (lvid == null)
                        {
                            //Error at XPath {0} in file {1}: Invalid property entry.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidPropertyEntry, ComputeCurrentXPath(), FilePath));
                            lved.itemDefinitionList = null;
                            return; //fatal
                        }
                        lved.itemDefinitionList.Add(lvid);
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                // we must have at least a definition in th elist
                if (lved.itemDefinitionList.Count == 0)
                {
                    //Error at XPath {0} in file {1}: At least one list view item must be specified.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoListViewItem, ComputeCurrentXPath(), FilePath));
                    lved.itemDefinitionList = null;
                    return; //fatal
                }
            }
        }
Example #17
0
 private void LoadListControlItemDefinitions(ListControlEntryDefinition lved, System.Xml.XmlNode bodyNode)
 {
     using (base.StackFrame(bodyNode))
     {
         int num = 0;
         foreach (System.Xml.XmlNode node in bodyNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "ListItem"))
             {
                 num++;
                 ListControlItemDefinition item = this.LoadListControlItemDefinition(node);
                 if (item == null)
                 {
                     base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidPropertyEntry, base.ComputeCurrentXPath(), base.FilePath));
                     lved.itemDefinitionList = null;
                     return;
                 }
                 lved.itemDefinitionList.Add(item);
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         if (lved.itemDefinitionList.Count == 0)
         {
             base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoListViewItem, base.ComputeCurrentXPath(), base.FilePath));
             lved.itemDefinitionList = null;
         }
     }
 }
Example #18
0
 private void LoadListControlItemDefinitionsFromObjectModel(ListControlEntryDefinition lved, List<ListControlEntryItem> listItems, int viewIndex, string typeName)
 {
     foreach (ListControlEntryItem item in listItems)
     {
         ListControlItemDefinition definition = new ListControlItemDefinition();
         if (item.DisplayEntry != null)
         {
             ExpressionToken token = this.LoadExpressionFromObjectModel(item.DisplayEntry, viewIndex, typeName);
             if (token == null)
             {
                 lved.itemDefinitionList = null;
                 return;
             }
             FieldPropertyToken token2 = new FieldPropertyToken {
                 expression = token
             };
             definition.formatTokenList.Add(token2);
         }
         if (!string.IsNullOrEmpty(item.Label))
         {
             TextToken token3 = new TextToken {
                 text = item.Label
             };
             definition.label = token3;
         }
         lved.itemDefinitionList.Add(definition);
     }
     if (lved.itemDefinitionList.Count == 0)
     {
         base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoListViewItemInFormattingData, typeName, viewIndex), typeName);
         lved.itemDefinitionList = null;
     }
 }
 internal ListControlEntry(ListControlEntryDefinition entrydefn)
     : this()
 {
     if (entrydefn.appliesTo != null)
     {
         EntrySelectedBy = EntrySelectedBy.Get(entrydefn.appliesTo.referenceList);
     }
     foreach (ListControlItemDefinition itemdefn in entrydefn.itemDefinitionList)
     {
         Items.Add(new ListControlEntryItem(itemdefn));
     }
 }