コード例 #1
0
ファイル: OutWindowProxy.cs プロジェクト: nickchal/pash
 internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
 {
     this.title = title;
     this.outputMode = outPutMode;
     this.parentCmdlet = parentCmdlet;
     this.graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, "Microsoft.Management.UI.Internal.OutGridViewWindow");
 }
コード例 #2
0
ファイル: OutWindowProxy.cs プロジェクト: 40a/PowerShell
        /// <summary>
        /// Initializes a new instance of the OutWindowProxy class.
        /// </summary>
        internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
        {
            _title = title;
            _outputMode = outPutMode;
            _parentCmdlet = parentCmdlet;

            _graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, OutWindowProxy.OutGridViewWindowClassName);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the OutWindowProxy class.
        /// </summary>
        internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
        {
            _title        = title;
            _outputMode   = outPutMode;
            _parentCmdlet = parentCmdlet;

            _graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, OutWindowProxy.OutGridViewWindowClassName);
        }
コード例 #4
0
 internal static GridHeader ConstructGridHeader(PSObject input, OutGridViewCommand parentCmd)
 {
     if (DefaultScalarTypes.IsTypeInList(input.TypeNames) ||
         OutOfBandFormatViewManager.IsPropertyLessObject(input))
     {
         return(new ScalarTypeHeader(parentCmd, input));
     }
     return(new NonscalarTypeHeader(parentCmd, input));
 }
コード例 #5
0
ファイル: TableView.cs プロジェクト: modulexcite/pash-1
        internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parentCmdlet)
        {
            HeaderInfo info = new HeaderInfo();
            List <MshResolvedExpressionParameterAssociation> activeAssociationList = AssociationManager.ExpandDefaultPropertySet(input, this.expressionFactory);

            if (activeAssociationList.Count > 0)
            {
                if (PSObjectHelper.ShouldShowComputerNameProperty(input))
                {
                    activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null, new MshExpression(RemotingConstants.ComputerNameNoteProperty)));
                }
            }
            else
            {
                activeAssociationList = AssociationManager.ExpandAll(input);
                if (activeAssociationList.Count > 0)
                {
                    AssociationManager.HandleComputerNameProperties(input, activeAssociationList);
                    this.FilterActiveAssociationList(activeAssociationList);
                }
                else
                {
                    activeAssociationList = new List <MshResolvedExpressionParameterAssociation>();
                }
            }
            for (int i = 0; i < activeAssociationList.Count; i++)
            {
                string staleObjectPropertyName = null;
                MshResolvedExpressionParameterAssociation association = activeAssociationList[i];
                if (association.OriginatingParameter != null)
                {
                    object entry = association.OriginatingParameter.GetEntry("label");
                    if (entry != AutomationNull.Value)
                    {
                        staleObjectPropertyName = (string)entry;
                    }
                }
                if (staleObjectPropertyName == null)
                {
                    staleObjectPropertyName = association.ResolvedExpression.ToString();
                }
                Microsoft.PowerShell.Commands.ColumnInfo col = new OriginalColumnInfo(staleObjectPropertyName, staleObjectPropertyName, staleObjectPropertyName, parentCmdlet);
                info.AddColumn(col);
            }
            return(info);
        }
コード例 #6
0
ファイル: TableView.cs プロジェクト: nickchal/pash
 internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parentCmdlet)
 {
     HeaderInfo info = new HeaderInfo();
     List<MshResolvedExpressionParameterAssociation> activeAssociationList = AssociationManager.ExpandDefaultPropertySet(input, this.expressionFactory);
     if (activeAssociationList.Count > 0)
     {
         if (PSObjectHelper.ShouldShowComputerNameProperty(input))
         {
             activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null, new MshExpression(RemotingConstants.ComputerNameNoteProperty)));
         }
     }
     else
     {
         activeAssociationList = AssociationManager.ExpandAll(input);
         if (activeAssociationList.Count > 0)
         {
             AssociationManager.HandleComputerNameProperties(input, activeAssociationList);
             this.FilterActiveAssociationList(activeAssociationList);
         }
         else
         {
             activeAssociationList = new List<MshResolvedExpressionParameterAssociation>();
         }
     }
     for (int i = 0; i < activeAssociationList.Count; i++)
     {
         string staleObjectPropertyName = null;
         MshResolvedExpressionParameterAssociation association = activeAssociationList[i];
         if (association.OriginatingParameter != null)
         {
             object entry = association.OriginatingParameter.GetEntry("label");
             if (entry != AutomationNull.Value)
             {
                 staleObjectPropertyName = (string) entry;
             }
         }
         if (staleObjectPropertyName == null)
         {
             staleObjectPropertyName = association.ResolvedExpression.ToString();
         }
         Microsoft.PowerShell.Commands.ColumnInfo col = new OriginalColumnInfo(staleObjectPropertyName, staleObjectPropertyName, staleObjectPropertyName, parentCmdlet);
         info.AddColumn(col);
     }
     return info;
 }
コード例 #7
0
            internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
            {
                // Prepare a table view.
                TableView tableView = new TableView();

                tableView.Initialize(parentCmd._expressionFactory, parentCmd._typeInfoDataBase);

                // Request a view definition from the type database.
                ViewDefinition viewDefinition = DisplayDataQuery.GetViewByShapeAndType(parentCmd._expressionFactory, parentCmd._typeInfoDataBase, FormatShape.Table, input.TypeNames, null);

                if (viewDefinition != null)
                {
                    // Create a header using a view definition provided by the types database.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView, (TableControlBody)viewDefinition.mainControl);

                    // Remember all type names and type groups the current view applies to.
                    _appliesTo = viewDefinition.appliesTo;
                }
                else
                {
                    // Create a header using only the input object's properties.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView);
                    _appliesTo = new AppliesTo();

                    // Add all type names except for Object and MarshalByRefObject types because they are too generic.
                    // Leave the Object type name if it is the only type name.
                    int index = 0;
                    foreach (string typeName in input.TypeNames)
                    {
                        if (index > 0 && (typeName.Equals(typeof(Object).FullName, StringComparison.OrdinalIgnoreCase) ||
                                          typeName.Equals(typeof(MarshalByRefObject).FullName, StringComparison.OrdinalIgnoreCase)))
                        {
                            break;
                        }

                        _appliesTo.AddAppliesToType(typeName);
                        index++;
                    }
                }
            }
コード例 #8
0
ファイル: OutGridViewCommand.cs プロジェクト: 40a/PowerShell
 internal HeteroTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     // Clear all existed columns and add Type and Value columns.
     this.parentCmd._windowProxy.AddHeteroViewColumnsAndItem(input);
 }
コード例 #9
0
ファイル: OutGridViewCommand.cs プロジェクト: 40a/PowerShell
            internal ScalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
            {
                _originalScalarType = input.BaseObject.GetType();

                // On scalar types the type name is used as a column name.
                this.parentCmd._windowProxy.AddColumnsAndItem(input);
            }
コード例 #10
0
ファイル: OutGridViewCommand.cs プロジェクト: 40a/PowerShell
            internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
            {
                // Prepare a table view.
                TableView tableView = new TableView();
                tableView.Initialize(parentCmd._expressionFactory, parentCmd._typeInfoDataBase);

                // Request a view definition from the type database.
                ViewDefinition viewDefinition = DisplayDataQuery.GetViewByShapeAndType(parentCmd._expressionFactory, parentCmd._typeInfoDataBase, FormatShape.Table, input.TypeNames, null);
                if (viewDefinition != null)
                {
                    // Create a header using a view definition provided by the types database.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView, (TableControlBody)viewDefinition.mainControl);

                    // Remember all type names and type groups the current view applies to.
                    _appliesTo = viewDefinition.appliesTo;
                }
                else
                {
                    // Create a header using only the input object's properties.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView);
                    _appliesTo = new AppliesTo();

                    // Add all type names except for Object and MarshalByRefObject types because they are too generic.
                    // Leave the Object type name if it is the only type name.
                    int index = 0;
                    foreach (string typeName in input.TypeNames)
                    {
                        if (index > 0 && (typeName.Equals(typeof(Object).FullName, StringComparison.OrdinalIgnoreCase) ||
                            typeName.Equals(typeof(MarshalByRefObject).FullName, StringComparison.OrdinalIgnoreCase)))
                        {
                            break;
                        }
                        _appliesTo.AddAppliesToType(typeName);
                        index++;
                    }
                }
            }
コード例 #11
0
 internal HeteroTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     // Clear all existed columns and add Type and Value columns.
     this.parentCmd._windowProxy.AddHeteroViewColumnsAndItem(input);
 }
コード例 #12
0
ファイル: TableView.cs プロジェクト: dfinke/powershell
        internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parentCmdlet)
        {
            HeaderInfo headerInfo = new HeaderInfo();
            List<MshResolvedExpressionParameterAssociation> activeAssociationList;

            // Get properties from the default property set of the object
            activeAssociationList = AssociationManager.ExpandDefaultPropertySet(input, _expressionFactory);
            if (activeAssociationList.Count > 0)
            {
                // we got a valid set of properties from the default property set..add computername for
                // remoteobjects (if available)
                if (PSObjectHelper.ShouldShowComputerNameProperty(input))
                {
                    activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null,
                        new MshExpression(RemotingConstants.ComputerNameNoteProperty)));
                }
            }
            else
            {
                // We failed to get anything from the default property set
                activeAssociationList = AssociationManager.ExpandAll(input);
                if (activeAssociationList.Count > 0)
                {
                    // Remove PSComputerName and PSShowComputerName from the display as needed.
                    AssociationManager.HandleComputerNameProperties(input, activeAssociationList);
                    FilterActiveAssociationList(activeAssociationList);
                }
                else
                {
                    // We were unable to retrieve any properties, so we leave an empty list
                    activeAssociationList = new List<MshResolvedExpressionParameterAssociation>();
                }
            }

            for (int k = 0; k < activeAssociationList.Count; k++)
            {
                string propertyName = null;

                MshResolvedExpressionParameterAssociation association = activeAssociationList[k];

                // set the label of the column
                if (association.OriginatingParameter != null)
                {
                    object key = association.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey);
                    if (key != AutomationNull.Value)
                        propertyName = (string)key;
                }
                if (propertyName == null)
                {
                    propertyName = association.ResolvedExpression.ToString();
                }
                ColumnInfo columnInfo = new OriginalColumnInfo(propertyName, propertyName, propertyName, parentCmdlet);

                headerInfo.AddColumn(columnInfo);
            }
            return headerInfo;
        }
コード例 #13
0
        internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parentCmdlet)
        {
            HeaderInfo headerInfo = new HeaderInfo();
            List <MshResolvedExpressionParameterAssociation> activeAssociationList;

            // Get properties from the default property set of the object
            activeAssociationList = AssociationManager.ExpandDefaultPropertySet(input, _expressionFactory);
            if (activeAssociationList.Count > 0)
            {
                // we got a valid set of properties from the default property set..add computername for
                // remoteobjects (if available)
                if (PSObjectHelper.ShouldShowComputerNameProperty(input))
                {
                    activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null,
                                                                                            new PSPropertyExpression(RemotingConstants.ComputerNameNoteProperty)));
                }
            }
            else
            {
                // We failed to get anything from the default property set
                activeAssociationList = AssociationManager.ExpandAll(input);
                if (activeAssociationList.Count > 0)
                {
                    // Remove PSComputerName and PSShowComputerName from the display as needed.
                    AssociationManager.HandleComputerNameProperties(input, activeAssociationList);
                    FilterActiveAssociationList(activeAssociationList);
                }
                else
                {
                    // We were unable to retrieve any properties, so we leave an empty list
                    activeAssociationList = new List <MshResolvedExpressionParameterAssociation>();
                }
            }

            for (int k = 0; k < activeAssociationList.Count; k++)
            {
                string propertyName = null;

                MshResolvedExpressionParameterAssociation association = activeAssociationList[k];

                // set the label of the column
                if (association.OriginatingParameter != null)
                {
                    object key = association.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey);
                    if (key != AutomationNull.Value)
                    {
                        propertyName = (string)key;
                    }
                }

                if (propertyName == null)
                {
                    propertyName = association.ResolvedExpression.ToString();
                }

                ColumnInfo columnInfo = new OriginalColumnInfo(propertyName, propertyName, propertyName, parentCmdlet);

                headerInfo.AddColumn(columnInfo);
            }

            return(headerInfo);
        }
コード例 #14
0
 internal GridHeader(OutGridViewCommand parentCmd)
 {
     this.parentCmd = parentCmd;
 }
コード例 #15
0
ファイル: TableView.cs プロジェクト: dfinke/powershell
        internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBody, OutGridViewCommand parentCmdlet)
        {
            HeaderInfo headerInfo = new HeaderInfo();

            // This verification is needed because the database returns "LastWriteTime" value for file system objects
            // as strings and it is used to detect this situation and use the actual field value.
            bool fileSystemObject = typeof(FileSystemInfo).IsInstanceOfType(input.BaseObject);

            if (tableBody != null) // If the tableBody is null, the TableControlBody info was not put into the database.
            {
                // Generate HeaderInfo from the type information database.
                List<TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(tableBody, input);

                int col = 0;
                foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList)
                {
                    ColumnInfo columnInfo = null;
                    string displayName = null;
                    TableColumnHeaderDefinition colHeader = null;
                    // Retrieve a matching TableColumnHeaderDefinition
                    if (col < tableBody.header.columnHeaderDefinitionList.Count)
                        colHeader = tableBody.header.columnHeaderDefinitionList[col];

                    if (colHeader != null && colHeader.label != null)
                    {
                        displayName = _typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(colHeader.label);
                    }

                    FormatToken token = null;
                    if (rowItem.formatTokenList.Count > 0)
                    {
                        token = rowItem.formatTokenList[0];
                    }

                    if (token != null)
                    {
                        FieldPropertyToken fpt = token as FieldPropertyToken;
                        if (fpt != null)
                        {
                            if (displayName == null)
                            {
                                // Database does not provide a label(DisplayName) for the current property, use the expression value instead.
                                displayName = fpt.expression.expressionValue;
                            }
                            if (fpt.expression.isScriptBlock)
                            {
                                MshExpression ex = _expressionFactory.CreateFromExpressionToken(fpt.expression);
                                // Using the displayName as a propertyName for a stale PSObject.
                                const string LastWriteTimePropertyName = "LastWriteTime";

                                // For FileSystem objects "LastWriteTime" property value should be used although the database indicates that a script should be executed to get the value.
                                if (fileSystemObject && displayName.Equals(LastWriteTimePropertyName, StringComparison.OrdinalIgnoreCase))
                                {
                                    columnInfo = new OriginalColumnInfo(displayName, displayName, LastWriteTimePropertyName, parentCmdlet);
                                }
                                else
                                {
                                    columnInfo = new ExpressionColumnInfo(displayName, displayName, ex);
                                }
                            }
                            else
                            {
                                columnInfo = new OriginalColumnInfo(fpt.expression.expressionValue, displayName, fpt.expression.expressionValue, parentCmdlet);
                            }
                        }
                        else
                        {
                            TextToken tt = token as TextToken;
                            if (tt != null)
                            {
                                displayName = _typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(tt);
                                columnInfo = new OriginalColumnInfo(tt.text, displayName, tt.text, parentCmdlet);
                            }
                        }
                    }
                    if (columnInfo != null)
                    {
                        headerInfo.AddColumn(columnInfo);
                    }
                    col++;
                }
            }

            return headerInfo;
        }
コード例 #16
0
ファイル: OutGridViewCommand.cs プロジェクト: nickchal/pash
 internal HeteroTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     base.parentCmd.windowProxy.AddHeteroViewColumnsAndItem(input);
 }
コード例 #17
0
ファイル: OutGridViewCommand.cs プロジェクト: nickchal/pash
 internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     TableView tableView = new TableView();
     tableView.Initialize(parentCmd.expressionFactory, parentCmd.typeInfoDataBase);
     ViewDefinition definition = DisplayDataQuery.GetViewByShapeAndType(parentCmd.expressionFactory, parentCmd.typeInfoDataBase, FormatShape.Table, input.TypeNames, null);
     if (definition != null)
     {
         parentCmd.windowProxy.AddColumnsAndItem(input, tableView, (TableControlBody) definition.mainControl);
         this.appliesTo = definition.appliesTo;
     }
     else
     {
         parentCmd.windowProxy.AddColumnsAndItem(input, tableView);
         this.appliesTo = new AppliesTo();
         int num = 0;
         foreach (string str in input.TypeNames)
         {
             if ((num > 0) && (str.Equals(typeof(object).FullName, StringComparison.OrdinalIgnoreCase) || str.Equals(typeof(MarshalByRefObject).FullName, StringComparison.OrdinalIgnoreCase)))
             {
                 break;
             }
             this.appliesTo.AddAppliesToType(str);
             num++;
         }
     }
 }
コード例 #18
0
ファイル: OutGridViewCommand.cs プロジェクト: nickchal/pash
 internal ScalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     this.originalScalarType = input.BaseObject.GetType();
     base.parentCmd.windowProxy.AddColumnsAndItem(input);
 }
コード例 #19
0
ファイル: ToStringColumnInfo.cs プロジェクト: nickchal/pash
 internal ToStringColumnInfo(string staleObjectPropertyName, string displayName, OutGridViewCommand parentCmdlet) : base(staleObjectPropertyName, displayName)
 {
     this.parentCmdlet = parentCmdlet;
 }
コード例 #20
0
 internal OriginalColumnInfo(string staleObjectPropertyName, string displayName, string liveObjectPropertyName, OutGridViewCommand parentCmdlet)
     : base(staleObjectPropertyName, displayName)
 {
     _liveObjectPropertyName = liveObjectPropertyName;
     _parentCmdlet           = parentCmdlet;
 }
コード例 #21
0
ファイル: TableView.cs プロジェクト: nickchal/pash
 internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBody, OutGridViewCommand parentCmdlet)
 {
     HeaderInfo info = new HeaderInfo();
     bool flag = typeof(FileSystemInfo).IsInstanceOfType(input.BaseObject);
     if (tableBody != null)
     {
         List<TableRowItemDefinition> activeTableRowDefinition = this.GetActiveTableRowDefinition(tableBody, input);
         int num = 0;
         foreach (TableRowItemDefinition definition in activeTableRowDefinition)
         {
             Microsoft.PowerShell.Commands.ColumnInfo col = null;
             string staleObjectPropertyName = null;
             TableColumnHeaderDefinition definition2 = null;
             if (tableBody.header.columnHeaderDefinitionList.Count >= (num - 1))
             {
                 definition2 = tableBody.header.columnHeaderDefinitionList[num];
             }
             if ((definition2 != null) && (definition2.label != null))
             {
                 staleObjectPropertyName = this.typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(definition2.label);
             }
             FormatToken token = null;
             if (definition.formatTokenList.Count > 0)
             {
                 token = definition.formatTokenList[0];
             }
             if (token != null)
             {
                 FieldPropertyToken token2 = token as FieldPropertyToken;
                 if (token2 != null)
                 {
                     if (staleObjectPropertyName == null)
                     {
                         staleObjectPropertyName = token2.expression.expressionValue;
                     }
                     if (token2.expression.isScriptBlock)
                     {
                         MshExpression expression = this.expressionFactory.CreateFromExpressionToken(token2.expression);
                         if (flag && staleObjectPropertyName.Equals("LastWriteTime", StringComparison.OrdinalIgnoreCase))
                         {
                             col = new OriginalColumnInfo(staleObjectPropertyName, staleObjectPropertyName, "LastWriteTime", parentCmdlet);
                         }
                         else
                         {
                             col = new ExpressionColumnInfo(staleObjectPropertyName, staleObjectPropertyName, expression);
                         }
                     }
                     else
                     {
                         col = new OriginalColumnInfo(token2.expression.expressionValue, staleObjectPropertyName, token2.expression.expressionValue, parentCmdlet);
                     }
                 }
                 else
                 {
                     TextToken tt = token as TextToken;
                     if (tt != null)
                     {
                         staleObjectPropertyName = this.typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(tt);
                         col = new OriginalColumnInfo(tt.text, staleObjectPropertyName, tt.text, parentCmdlet);
                     }
                 }
             }
             if (col != null)
             {
                 info.AddColumn(col);
             }
             num++;
         }
     }
     return info;
 }
コード例 #22
0
ファイル: TableView.cs プロジェクト: modulexcite/pash-1
        internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBody, OutGridViewCommand parentCmdlet)
        {
            HeaderInfo info = new HeaderInfo();
            bool       flag = typeof(FileSystemInfo).IsInstanceOfType(input.BaseObject);

            if (tableBody != null)
            {
                List <TableRowItemDefinition> activeTableRowDefinition = this.GetActiveTableRowDefinition(tableBody, input);
                int num = 0;
                foreach (TableRowItemDefinition definition in activeTableRowDefinition)
                {
                    Microsoft.PowerShell.Commands.ColumnInfo col = null;
                    string staleObjectPropertyName          = null;
                    TableColumnHeaderDefinition definition2 = null;
                    if (tableBody.header.columnHeaderDefinitionList.Count >= (num - 1))
                    {
                        definition2 = tableBody.header.columnHeaderDefinitionList[num];
                    }
                    if ((definition2 != null) && (definition2.label != null))
                    {
                        staleObjectPropertyName = this.typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(definition2.label);
                    }
                    FormatToken token = null;
                    if (definition.formatTokenList.Count > 0)
                    {
                        token = definition.formatTokenList[0];
                    }
                    if (token != null)
                    {
                        FieldPropertyToken token2 = token as FieldPropertyToken;
                        if (token2 != null)
                        {
                            if (staleObjectPropertyName == null)
                            {
                                staleObjectPropertyName = token2.expression.expressionValue;
                            }
                            if (token2.expression.isScriptBlock)
                            {
                                MshExpression expression = this.expressionFactory.CreateFromExpressionToken(token2.expression);
                                if (flag && staleObjectPropertyName.Equals("LastWriteTime", StringComparison.OrdinalIgnoreCase))
                                {
                                    col = new OriginalColumnInfo(staleObjectPropertyName, staleObjectPropertyName, "LastWriteTime", parentCmdlet);
                                }
                                else
                                {
                                    col = new ExpressionColumnInfo(staleObjectPropertyName, staleObjectPropertyName, expression);
                                }
                            }
                            else
                            {
                                col = new OriginalColumnInfo(token2.expression.expressionValue, staleObjectPropertyName, token2.expression.expressionValue, parentCmdlet);
                            }
                        }
                        else
                        {
                            TextToken tt = token as TextToken;
                            if (tt != null)
                            {
                                staleObjectPropertyName = this.typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(tt);
                                col = new OriginalColumnInfo(tt.text, staleObjectPropertyName, tt.text, parentCmdlet);
                            }
                        }
                    }
                    if (col != null)
                    {
                        info.AddColumn(col);
                    }
                    num++;
                }
            }
            return(info);
        }
コード例 #23
0
 internal HeteroTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     base.parentCmd.windowProxy.AddHeteroViewColumnsAndItem(input);
 }
コード例 #24
0
        internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBody, OutGridViewCommand parentCmdlet)
        {
            HeaderInfo headerInfo = new HeaderInfo();

            // This verification is needed because the database returns "LastWriteTime" value for file system objects
            // as strings and it is used to detect this situation and use the actual field value.
            bool fileSystemObject = typeof(FileSystemInfo).IsInstanceOfType(input.BaseObject);

            if (tableBody != null) // If the tableBody is null, the TableControlBody info was not put into the database.
            {
                // Generate HeaderInfo from the type information database.
                List <TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(tableBody, input);

                int col = 0;
                foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList)
                {
                    ColumnInfo columnInfo  = null;
                    string     displayName = null;
                    TableColumnHeaderDefinition colHeader = null;
                    // Retrieve a matching TableColumnHeaderDefinition
                    if (col < tableBody.header.columnHeaderDefinitionList.Count)
                    {
                        colHeader = tableBody.header.columnHeaderDefinitionList[col];
                    }

                    if (colHeader != null && colHeader.label != null)
                    {
                        displayName = _typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(colHeader.label);
                    }

                    FormatToken token = null;
                    if (rowItem.formatTokenList.Count > 0)
                    {
                        token = rowItem.formatTokenList[0];
                    }

                    if (token != null)
                    {
                        FieldPropertyToken fpt = token as FieldPropertyToken;
                        if (fpt != null)
                        {
                            if (displayName == null)
                            {
                                // Database does not provide a label(DisplayName) for the current property, use the expression value instead.
                                displayName = fpt.expression.expressionValue;
                            }

                            if (fpt.expression.isScriptBlock)
                            {
                                PSPropertyExpression ex = _expressionFactory.CreateFromExpressionToken(fpt.expression);
                                // Using the displayName as a propertyName for a stale PSObject.
                                const string LastWriteTimePropertyName = "LastWriteTime";

                                // For FileSystem objects "LastWriteTime" property value should be used although the database indicates that a script should be executed to get the value.
                                if (fileSystemObject && displayName.Equals(LastWriteTimePropertyName, StringComparison.OrdinalIgnoreCase))
                                {
                                    columnInfo = new OriginalColumnInfo(displayName, displayName, LastWriteTimePropertyName, parentCmdlet);
                                }
                                else
                                {
                                    columnInfo = new ExpressionColumnInfo(displayName, displayName, ex);
                                }
                            }
                            else
                            {
                                columnInfo = new OriginalColumnInfo(fpt.expression.expressionValue, displayName, fpt.expression.expressionValue, parentCmdlet);
                            }
                        }
                        else
                        {
                            TextToken tt = token as TextToken;
                            if (tt != null)
                            {
                                displayName = _typeInfoDatabase.displayResourceManagerCache.GetTextTokenString(tt);
                                columnInfo  = new OriginalColumnInfo(tt.text, displayName, tt.text, parentCmdlet);
                            }
                        }
                    }

                    if (columnInfo != null)
                    {
                        headerInfo.AddColumn(columnInfo);
                    }

                    col++;
                }
            }

            return(headerInfo);
        }
コード例 #25
0
 internal ScalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
 {
     this.originalScalarType = input.BaseObject.GetType();
     base.parentCmd.windowProxy.AddColumnsAndItem(input);
 }
コード例 #26
0
ファイル: OutGridViewCommand.cs プロジェクト: 40a/PowerShell
 internal GridHeader(OutGridViewCommand parentCmd)
 {
     this.parentCmd = parentCmd;
 }
コード例 #27
0
ファイル: OutGridViewCommand.cs プロジェクト: 40a/PowerShell
 internal static GridHeader ConstructGridHeader(PSObject input, OutGridViewCommand parentCmd)
 {
     if (DefaultScalarTypes.IsTypeInList(input.TypeNames) ||
         OutOfBandFormatViewManager.IsPropertyLessObject(input))
     {
         return new ScalarTypeHeader(parentCmd, input);
     }
     return new NonscalarTypeHeader(parentCmd, input);
 }
コード例 #28
0
 internal ToStringColumnInfo(string staleObjectPropertyName, string displayName, OutGridViewCommand parentCmdlet)
     : base(staleObjectPropertyName, displayName)
 {
     _parentCmdlet = parentCmdlet;
 }
コード例 #29
0
ファイル: OriginalColumnInfo.cs プロジェクト: nickchal/pash
 internal OriginalColumnInfo(string staleObjectPropertyName, string displayName, string liveObjectPropertyName, OutGridViewCommand parentCmdlet) : base(staleObjectPropertyName, displayName)
 {
     this.liveObjectPropertyName = liveObjectPropertyName;
     this.parentCmdlet = parentCmdlet;
 }