コード例 #1
0
        internal static List <MshResolvedExpressionParameterAssociation> SetupActiveProperties(List <MshParameter> rawMshParameterList,
                                                                                               PSObject target, MshExpressionFactory expressionFactory)
        {
            // check if we received properties from the command line
            if (rawMshParameterList != null && rawMshParameterList.Count > 0)
            {
                return(AssociationManager.ExpandParameters(rawMshParameterList, target));
            }

            // we did not get any properties:
            //try to get properties from the default property set of the object
            List <MshResolvedExpressionParameterAssociation> activeAssociationList = AssociationManager.ExpandDefaultPropertySet(target, 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(target))
                {
                    activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null,
                                                                                            new MshExpression(RemotingConstants.ComputerNameNoteProperty)));
                }

                return(activeAssociationList);
            }

            // we failed to get anything from the default property set
            // just get all the properties
            activeAssociationList = AssociationManager.ExpandAll(target);
            // Remove PSComputerName and PSShowComputerName from the display as needed.
            AssociationManager.HandleComputerNameProperties(target, activeAssociationList);

            return(activeAssociationList);
        }
コード例 #2
0
        private void SetUpActiveProperty(PSObject so)
        {
            List <MshParameter> parameters = null;

            if (base.inputParameters != null)
            {
                parameters = base.inputParameters.mshParameterList;
            }
            if ((parameters != null) && (parameters.Count > 0))
            {
                base.activeAssociationList = AssociationManager.ExpandParameters(parameters, so);
            }
            else
            {
                MshExpression displayNameExpression = PSObjectHelper.GetDisplayNameExpression(so, base.expressionFactory);
                if (displayNameExpression != null)
                {
                    base.activeAssociationList = new List <MshResolvedExpressionParameterAssociation>();
                    base.activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null, displayNameExpression));
                }
                else
                {
                    base.activeAssociationList = AssociationManager.ExpandDefaultPropertySet(so, base.expressionFactory);
                    if (base.activeAssociationList.Count <= 0)
                    {
                        base.activeAssociationList = AssociationManager.ExpandAll(so);
                    }
                }
            }
        }
コード例 #3
0
        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>();
        }
コード例 #4
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>();
                    }
                }
            }
        }
コード例 #5
0
        private void SetUpActiveProperty(PSObject so)
        {
            List <MshParameter> rawMshParameterList = null;

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

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

            // we did not get any properties:
            //try to get the display property of the object
            MshExpression displayNameExpression = PSObjectHelper.GetDisplayNameExpression(so, this.expressionFactory);

            if (displayNameExpression != null)
            {
                this.activeAssociationList = new List <MshResolvedExpressionParameterAssociation>();
                this.activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null, displayNameExpression));
                return;
            }

            // try to get the default property set (we will use the first property)
            this.activeAssociationList = AssociationManager.ExpandDefaultPropertySet(so, this.expressionFactory);
            if (this.activeAssociationList.Count > 0)
            {
                // we got a valid set of properties from the default property set
                return;
            }

            // we failed to get anything from the default property set
            // just get all the properties
            this.activeAssociationList = AssociationManager.ExpandAll(so);
        }