Exemplo n.º 1
0
        private ListControlEntryDefinition GetActiveListControlEntryDefinition(ListControlBody listBody, PSObject so)
        {
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            TypeMatch          match             = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames);

            foreach (ListControlEntryDefinition definition in listBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo, so)))
                {
                    return(definition);
                }
            }
            if (match.BestMatch != null)
            {
                return(match.BestMatch as ListControlEntryDefinition);
            }
            Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);

            if (typeNames != null)
            {
                match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames);
                foreach (ListControlEntryDefinition definition2 in listBody.optionalEntryList)
                {
                    if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
                    {
                        return(definition2);
                    }
                }
                if (match.BestMatch != null)
                {
                    return(match.BestMatch as ListControlEntryDefinition);
                }
            }
            return(listBody.defaultEntryDefinition);
        }
Exemplo n.º 2
0
 internal override void Initialize(TerminatingErrorContext terminatingErrorContext, PSPropertyExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters)
 {
     base.Initialize(terminatingErrorContext, mshExpressionFactory, db, view, formatParameters);
     if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view))
     {
         _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl;
     }
 }
Exemplo n.º 3
0
 internal override void Initialize(TerminatingErrorContext terminatingErrorContext, MshExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters)
 {
     base.Initialize(terminatingErrorContext, mshExpressionFactory, db, view, formatParameters);
     if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view))
     {
         _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl;
     }
 }
Exemplo n.º 4
0
 internal ListControl(ListControlBody listcontrolbody)
 {
     this._entries = new List<ListControlEntry>();
     this._entries.Add(new ListControlEntry(listcontrolbody.defaultEntryDefinition));
     foreach (ListControlEntryDefinition definition in listcontrolbody.optionalEntryList)
     {
         this._entries.Add(new ListControlEntry(definition));
     }
 }
Exemplo n.º 5
0
 internal override void Initialize(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, PSObject so, TypeInfoDataBase db, FormattingCommandLineParameters parameters)
 {
     base.Initialize(errorContext, expressionFactory, so, db, parameters);
     if ((base.dataBaseInfo != null) && (base.dataBaseInfo.view != null))
     {
         this.listBody = (ListControlBody)base.dataBaseInfo.view.mainControl;
     }
     base.inputParameters = parameters;
     this.SetUpActiveProperties(so);
 }
Exemplo n.º 6
0
        internal override void Initialize(TerminatingErrorContext errorContext, PSPropertyExpressionFactory expressionFactory,
                                          PSObject so, TypeInfoDataBase db, FormattingCommandLineParameters parameters)
        {
            base.Initialize(errorContext, expressionFactory, so, db, parameters);
            if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view))
            {
                _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl;
            }

            this.inputParameters = parameters;
            SetUpActiveProperties(so);
        }
Exemplo n.º 7
0
        internal override void Initialize(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory,
                                    PSObject so, TypeInfoDataBase db, FormattingCommandLineParameters parameters)
        {
            base.Initialize(errorContext, expressionFactory, so, db, parameters);
            if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view))
            {
                _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl;
            }

            this.inputParameters = parameters;
            SetUpActiveProperties(so);
        }
Exemplo n.º 8
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));
                }
            }
        }
Exemplo n.º 9
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));
                }
            }
        }
Exemplo n.º 10
0
        internal override ControlBase Copy()
        {
            ListControlBody listControlBody = new ListControlBody();

            listControlBody.autosize = this.autosize;
            if (this.defaultEntryDefinition != null)
            {
                listControlBody.defaultEntryDefinition = this.defaultEntryDefinition.Copy();
            }
            foreach (ListControlEntryDefinition optionalEntry in this.optionalEntryList)
            {
                listControlBody.optionalEntryList.Add(optionalEntry);
            }
            return((ControlBase)listControlBody);
        }
Exemplo n.º 11
0
 internal override ControlBase Copy()
 {
     ListControlBody body = new ListControlBody {
         autosize = base.autosize
     };
     if (this.defaultEntryDefinition != null)
     {
         body.defaultEntryDefinition = this.defaultEntryDefinition.Copy();
     }
     foreach (ListControlEntryDefinition definition in this.optionalEntryList)
     {
         body.optionalEntryList.Add(definition);
     }
     return body;
 }
Exemplo n.º 12
0
        internal override ControlBase Copy()
        {
            ListControlBody body = new ListControlBody {
                autosize = base.autosize
            };

            if (this.defaultEntryDefinition != null)
            {
                body.defaultEntryDefinition = this.defaultEntryDefinition.Copy();
            }
            foreach (ListControlEntryDefinition definition in this.optionalEntryList)
            {
                body.optionalEntryList.Add(definition);
            }
            return(body);
        }
Exemplo n.º 13
0
        internal override ControlBase Copy()
        {
            ListControlBody result = new ListControlBody();
            result.autosize = this.autosize;
            if (null != defaultEntryDefinition)
            {
                result.defaultEntryDefinition = this.defaultEntryDefinition.Copy();
            }

            foreach (ListControlEntryDefinition lced in this.optionalEntryList)
            {
                result.optionalEntryList.Add(lced);
            }

            return result;
        }
Exemplo n.º 14
0
        internal override ControlBase Copy()
        {
            ListControlBody result = new ListControlBody();

            result.autosize = this.autosize;
            if (defaultEntryDefinition != null)
            {
                result.defaultEntryDefinition = this.defaultEntryDefinition.Copy();
            }

            foreach (ListControlEntryDefinition lced in this.optionalEntryList)
            {
                result.optionalEntryList.Add(lced);
            }

            return(result);
        }
Exemplo n.º 15
0
        internal override void PrepareForRemoteObjects(PSObject so)
        {
            PSPropertyInfo local1 = so.Properties[RemotingConstants.ComputerNameNoteProperty];

            if (((base.dataBaseInfo != null) && (base.dataBaseInfo.view != null)) && (base.dataBaseInfo.view.mainControl != null))
            {
                this.listBody = (ListControlBody)base.dataBaseInfo.view.mainControl.Copy();
                ListControlItemDefinition item = new ListControlItemDefinition {
                    label = new TextToken()
                };
                item.label.text = RemotingConstants.ComputerNameNoteProperty;
                FieldPropertyToken token = new FieldPropertyToken {
                    expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false)
                };
                item.formatTokenList.Add(token);
                this.listBody.defaultEntryDefinition.itemDefinitionList.Add(item);
            }
        }
Exemplo n.º 16
0
        private ListControlBody LoadListControl(XmlNode controlNode)
        {
            using (this.StackFrame(controlNode))
            {
                ListControlBody listBody = new ListControlBody();

                bool listViewEntriesFound = false;

                foreach (XmlNode n in controlNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.ListEntriesNode))
                    {
                        if (listViewEntriesFound)
                        {
                            this.ProcessDuplicateNode(n);
                            continue;
                        }

                        listViewEntriesFound = true;

                        // now read the columns section
                        LoadListControlEntries(n, listBody);
                        if (listBody.defaultEntryDefinition == null)
                        {
                            return(null); // fatal error
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (!listViewEntriesFound)
                {
                    this.ReportMissingNode(XmlTags.ListEntriesNode);
                    return(null); // fatal error
                }

                return(listBody);
            }
        }
Exemplo n.º 17
0
        private ListControlEntryDefinition GetActiveListControlEntryDefinition(ListControlBody listBody, PSObject so)
        {
            // see if we have an override that matches
            var       typeNames = so.InternalTypeNames;
            TypeMatch match     = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);

            foreach (ListControlEntryDefinition x in listBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo, so)))
                {
                    return(x);
                }
            }

            if (match.BestMatch != null)
            {
                return(match.BestMatch as ListControlEntryDefinition);
            }
            else
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);
                    foreach (ListControlEntryDefinition x in listBody.optionalEntryList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            return(x);
                        }
                    }

                    if (match.BestMatch != null)
                    {
                        return(match.BestMatch as ListControlEntryDefinition);
                    }
                }

                // we do not have any override, use default
                return(listBody.defaultEntryDefinition);
            }
        }
Exemplo n.º 18
0
        private ListControlBody LoadListControl(XmlNode controlNode)
        {
            using (this.StackFrame(controlNode))
            {
                ListControlBody listBody = new ListControlBody();

                bool listViewEntriesFound = false;

                foreach (XmlNode n in controlNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.ListEntriesNode))
                    {
                        if (listViewEntriesFound)
                        {
                            this.ProcessDuplicateNode(n);
                            continue;
                        }

                        listViewEntriesFound = true;

                        // now read the columns section
                        LoadListControlEntries(n, listBody);
                        if (listBody.defaultEntryDefinition == null)
                        {
                            return null; // fatal error
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (!listViewEntriesFound)
                {
                    this.ReportMissingNode(XmlTags.ListEntriesNode);
                    return null; // fatal error
                }
                return listBody;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Let the view prepare itself for RemoteObjects. This will add "ComputerName" to the
        /// table columns.
        /// </summary>
        /// <param name="so"></param>
        internal override void PrepareForRemoteObjects(PSObject so)
        {
            Diagnostics.Assert(null != so, "so cannot be null");

            // make sure computername property exists.
            Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty],
                               "PrepareForRemoteObjects cannot be called when the object does not contain ComputerName property.");

            if ((dataBaseInfo != null) && (dataBaseInfo.view != null) && (dataBaseInfo.view.mainControl != null))
            {
                _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl.Copy();
                // build up the definition for computer name.
                ListControlItemDefinition cnListItemDefinition = new ListControlItemDefinition();
                cnListItemDefinition.label      = new TextToken();
                cnListItemDefinition.label.text = RemotingConstants.ComputerNameNoteProperty;
                FieldPropertyToken fpt = new FieldPropertyToken();
                fpt.expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false);
                cnListItemDefinition.formatTokenList.Add(fpt);

                _listBody.defaultEntryDefinition.itemDefinitionList.Add(cnListItemDefinition);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Let the view prepare itself for RemoteObjects. This will add "ComputerName" to the 
        /// table columns.
        /// </summary>
        /// <param name="so"></param>
        internal override void PrepareForRemoteObjects(PSObject so)
        {
            Diagnostics.Assert(null != so, "so cannot be null");

            // make sure computername property exists.
            Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty],
                "PrepareForRemoteObjects cannot be called when the object does not contain ComputerName property.");

            if ((dataBaseInfo != null) && (dataBaseInfo.view != null) && (dataBaseInfo.view.mainControl != null))
            {
                _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl.Copy();
                // build up the definition for computer name.
                ListControlItemDefinition cnListItemDefinition = new ListControlItemDefinition();
                cnListItemDefinition.label = new TextToken();
                cnListItemDefinition.label.text = RemotingConstants.ComputerNameNoteProperty;
                FieldPropertyToken fpt = new FieldPropertyToken();
                fpt.expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false);
                cnListItemDefinition.formatTokenList.Add(fpt);


                _listBody.defaultEntryDefinition.itemDefinitionList.Add(cnListItemDefinition);
            }
        }
Exemplo n.º 21
0
 private void LoadListControlEntriesFromObjectModel(ListControlBody listBody, List<ListControlEntry> entries, int viewIndex, string typeName)
 {
     // Contains:
     //   Entries --- ListEntries  cardinality 1
     foreach (ListControlEntry listEntry in entries)
     {
         ListControlEntryDefinition lved = LoadListControlEntryDefinitionFromObjectModel(listEntry, viewIndex, typeName);
         if (lved == null)
         {
             this.ReportErrorForLoadingFromObjectModel(
                 StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailedInFormattingData, typeName, viewIndex, XmlTags.ListEntryNode), typeName);
             listBody.defaultEntryDefinition = null;
             return;
         }
         // 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.ReportErrorForLoadingFromObjectModel(
                     StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntryInFormattingData, typeName, viewIndex, XmlTags.ListEntryNode), typeName);
                 listBody.defaultEntryDefinition = null;
                 return; // fatal error
             }
         }
         else
         {
             listBody.optionalEntryList.Add(lved);
         }
     }
     // list entries is empty
     if (listBody.defaultEntryDefinition == null)
     {
         // Error: there must be at least one default
         this.ReportErrorForLoadingFromObjectModel(
             StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntryInFormattingData, typeName, viewIndex, XmlTags.ListEntryNode), typeName);
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Load LoisControl into the ListControlBody
        /// </summary>
        /// <param name="list"></param>
        /// <param name="viewIndex"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        private ListControlBody LoadListControlFromObjectModel(ListControl list, int viewIndex, string typeName)
        {
            ListControlBody listBody = new ListControlBody();

            // load the list entries section
            LoadListControlEntriesFromObjectModel(listBody, list.Entries, viewIndex, typeName);
            if (listBody.defaultEntryDefinition == null)
            {
                return null; // fatal error
            }
            return listBody;
        }
Exemplo n.º 23
0
 internal override void PrepareForRemoteObjects(PSObject so)
 {
     PSPropertyInfo local1 = so.Properties[RemotingConstants.ComputerNameNoteProperty];
     if (((base.dataBaseInfo != null) && (base.dataBaseInfo.view != null)) && (base.dataBaseInfo.view.mainControl != null))
     {
         this.listBody = (ListControlBody) base.dataBaseInfo.view.mainControl.Copy();
         ListControlItemDefinition item = new ListControlItemDefinition {
             label = new TextToken()
         };
         item.label.text = RemotingConstants.ComputerNameNoteProperty;
         FieldPropertyToken token = new FieldPropertyToken {
             expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false)
         };
         item.formatTokenList.Add(token);
         this.listBody.defaultEntryDefinition.itemDefinitionList.Add(item);
     }
 }
Exemplo n.º 24
0
 private ListControlEntryDefinition GetActiveListControlEntryDefinition(ListControlBody listBody, PSObject so)
 {
     ConsolidatedString internalTypeNames = so.InternalTypeNames;
     TypeMatch match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames);
     foreach (ListControlEntryDefinition definition in listBody.optionalEntryList)
     {
         if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo, so)))
         {
             return definition;
         }
     }
     if (match.BestMatch != null)
     {
         return (match.BestMatch as ListControlEntryDefinition);
     }
     Collection<string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);
     if (typeNames != null)
     {
         match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames);
         foreach (ListControlEntryDefinition definition2 in listBody.optionalEntryList)
         {
             if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
             {
                 return definition2;
             }
         }
         if (match.BestMatch != null)
         {
             return (match.BestMatch as ListControlEntryDefinition);
         }
     }
     return listBody.defaultEntryDefinition;
 }
Exemplo n.º 25
0
 private void LoadListControlEntriesFromObjectModel(ListControlBody listBody, List<ListControlEntry> entries, int viewIndex, string typeName)
 {
     foreach (ListControlEntry entry in entries)
     {
         ListControlEntryDefinition item = this.LoadListControlEntryDefinitionFromObjectModel(entry, viewIndex, typeName);
         if (item == null)
         {
             base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailedInFormattingData, new object[] { typeName, viewIndex, "ListEntry" }), typeName);
             listBody.defaultEntryDefinition = null;
             return;
         }
         if (item.appliesTo == null)
         {
             if (listBody.defaultEntryDefinition == null)
             {
                 listBody.defaultEntryDefinition = item;
                 continue;
             }
             base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntryInFormattingData, new object[] { typeName, viewIndex, "ListEntry" }), typeName);
             listBody.defaultEntryDefinition = null;
             return;
         }
         listBody.optionalEntryList.Add(item);
     }
     if (listBody.defaultEntryDefinition == null)
     {
         base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntryInFormattingData, new object[] { typeName, viewIndex, "ListEntry" }), typeName);
     }
 }
Exemplo n.º 26
0
 private ListControlBody LoadListControl(System.Xml.XmlNode controlNode)
 {
     using (base.StackFrame(controlNode))
     {
         ListControlBody listBody = new ListControlBody();
         bool flag = false;
         foreach (System.Xml.XmlNode node in controlNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "ListEntries"))
             {
                 if (!flag)
                 {
                     flag = true;
                     this.LoadListControlEntries(node, listBody);
                     if (listBody.defaultEntryDefinition == null)
                     {
                         return null;
                     }
                 }
                 else
                 {
                     base.ProcessDuplicateNode(node);
                 }
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         if (!flag)
         {
             base.ReportMissingNode("ListEntries");
             return null;
         }
         return listBody;
     }
 }
Exemplo n.º 27
0
 private void LoadListControlEntries(System.Xml.XmlNode listViewEntriesNode, ListControlBody listBody)
 {
     using (base.StackFrame(listViewEntriesNode))
     {
         int num = 0;
         foreach (System.Xml.XmlNode node in listViewEntriesNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "ListEntry"))
             {
                 ListControlEntryDefinition item = this.LoadListControlEntryDefinition(node, num++);
                 if (item == null)
                 {
                     base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailed, new object[] { base.ComputeCurrentXPath(), base.FilePath, "ListEntry" }));
                     listBody.defaultEntryDefinition = null;
                     return;
                 }
                 if (item.appliesTo == null)
                 {
                     if (listBody.defaultEntryDefinition == null)
                     {
                         listBody.defaultEntryDefinition = item;
                         continue;
                     }
                     base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, new object[] { base.ComputeCurrentXPath(), base.FilePath, "ListEntry" }));
                     listBody.defaultEntryDefinition = null;
                     return;
                 }
                 listBody.optionalEntryList.Add(item);
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         if (listBody.optionalEntryList == null)
         {
             base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, new object[] { base.ComputeCurrentXPath(), base.FilePath, "ListEntry" }));
         }
     }
 }
Exemplo n.º 28
0
        private ListControlEntryDefinition GetActiveListControlEntryDefinition(ListControlBody listBody, PSObject so)
        {
            // see if we have an override that matches
            var typeNames = so.InternalTypeNames;
            TypeMatch match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);
            foreach (ListControlEntryDefinition x in listBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo, so)))
                {
                    return x;
                }
            }
            if (match.BestMatch != null)
            {
                return match.BestMatch as ListControlEntryDefinition;
            }
            else
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);
                    foreach (ListControlEntryDefinition x in listBody.optionalEntryList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            return x;
                        }
                    }
                    if (match.BestMatch != null)
                    {
                        return match.BestMatch as ListControlEntryDefinition;
                    }
                }

                // we do not have any override, use default
                return listBody.defaultEntryDefinition;
            }
        }
Exemplo n.º 29
0
 private ListControlBody LoadListControlFromObjectModel(ListControl list, int viewIndex, string typeName)
 {
     ListControlBody listBody = new ListControlBody();
     this.LoadListControlEntriesFromObjectModel(listBody, list.Entries, viewIndex, typeName);
     if (listBody.defaultEntryDefinition == null)
     {
         return null;
     }
     return listBody;
 }
Exemplo n.º 30
0
        /// <summary>To go from internal representation to external - for Get-FormatData</summary>
        internal ListControl(ListControlBody listcontrolbody, ViewDefinition viewDefinition)
            : this()
        {
            this.GroupBy = PSControlGroupBy.Get(viewDefinition.groupBy);
            this.OutOfBand = viewDefinition.outOfBand;

            Entries.Add(new ListControlEntry(listcontrolbody.defaultEntryDefinition));

            foreach (ListControlEntryDefinition lced in listcontrolbody.optionalEntryList)
            {
                Entries.Add(new ListControlEntry(lced));
            }
        }