internal override void Initialize(TerminatingErrorContext errorContext, PSPropertyExpressionFactory expressionFactory,
                                          PSObject so, TypeInfoDataBase db,
                                          FormattingCommandLineParameters parameters)
        {
            base.Initialize(errorContext, expressionFactory, so, db, parameters);

            if ((this.dataBaseInfo != null) && (this.dataBaseInfo.view != null))
            {
                _tableBody = (TableControlBody)this.dataBaseInfo.view.mainControl;
            }

            List <MshParameter> rawMshParameterList = null;

            if (parameters != null)
            {
                rawMshParameterList = parameters.mshParameterList;
            }

            // check if we received properties from the command line
            if (rawMshParameterList != null && rawMshParameterList.Count > 0)
            {
                this.activeAssociationList = AssociationManager.ExpandTableParameters(rawMshParameterList, so);
                return;
            }

            // we did not get any properties:
            // try to get properties from the default property set of the object
            this.activeAssociationList = AssociationManager.ExpandDefaultPropertySet(so, this.expressionFactory);
            if (this.activeAssociationList.Count > 0)
            {
                // we got a valid set of properties from the default property set..add computername for
                // remoteobjects (if available)
                if (PSObjectHelper.ShouldShowComputerNameProperty(so))
                {
                    activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null,
                                                                                            new PSPropertyExpression(RemotingConstants.ComputerNameNoteProperty)));
                }

                return;
            }

            // we failed to get anything from the default property set
            this.activeAssociationList = AssociationManager.ExpandAll(so);
            if (this.activeAssociationList.Count > 0)
            {
                // Remove PSComputerName and PSShowComputerName from the display as needed.
                AssociationManager.HandleComputerNameProperties(so, activeAssociationList);
                FilterActiveAssociationList();
                return;
            }

            // we were unable to retrieve any properties, so we leave an empty list
            this.activeAssociationList = new List <MshResolvedExpressionParameterAssociation>();
        }
Beispiel #2
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.tableBody = (TableControlBody)base.dataBaseInfo.view.mainControl;
            }
            List <MshParameter> mshParameterList = null;

            if (parameters != null)
            {
                mshParameterList = parameters.mshParameterList;
            }
            if ((mshParameterList != null) && (mshParameterList.Count > 0))
            {
                base.activeAssociationList = AssociationManager.ExpandTableParameters(mshParameterList, so);
            }
            else
            {
                base.activeAssociationList = AssociationManager.ExpandDefaultPropertySet(so, base.expressionFactory);
                if (base.activeAssociationList.Count > 0)
                {
                    if (PSObjectHelper.ShouldShowComputerNameProperty(so))
                    {
                        base.activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null, new MshExpression(RemotingConstants.ComputerNameNoteProperty)));
                    }
                }
                else
                {
                    base.activeAssociationList = AssociationManager.ExpandAll(so);
                    if (base.activeAssociationList.Count > 0)
                    {
                        AssociationManager.HandleComputerNameProperties(so, base.activeAssociationList);
                        this.FilterActiveAssociationList();
                    }
                    else
                    {
                        base.activeAssociationList = new List <MshResolvedExpressionParameterAssociation>();
                    }
                }
            }
        }