Esempio n. 1
0
 protected override void ProcessRecord()
 {
     string[] path = this.Path;
     for (int i = 0; i < (int)path.Length; i++)
     {
         string str = path[i];
         try
         {
             base.InvokeProvider.Property.Get(str, SessionStateUtilities.ConvertArrayToCollection <string>(this.property), this.CmdletProviderContext);
         }
         catch (PSNotSupportedException pSNotSupportedException1)
         {
             PSNotSupportedException pSNotSupportedException = pSNotSupportedException1;
             base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException));
         }
         catch (DriveNotFoundException driveNotFoundException1)
         {
             DriveNotFoundException driveNotFoundException = driveNotFoundException1;
             base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException));
         }
         catch (ProviderNotFoundException providerNotFoundException1)
         {
             ProviderNotFoundException providerNotFoundException = providerNotFoundException1;
             base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException));
         }
         catch (ItemNotFoundException itemNotFoundException1)
         {
             ItemNotFoundException itemNotFoundException = itemNotFoundException1;
             base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException));
         }
     }
 }
Esempio n. 2
0
        private void AccumulateMatchingCommands()
        {
            Collection <string> commandNames = SessionStateUtilities.ConvertArrayToCollection <string>(this.Name);

            if (commandNames.Count == 0)
            {
                commandNames.Add("*");
            }
            this.AccumulateMatchingCommands(commandNames);
        }
Esempio n. 3
0
        } // Property

        /// <summary>
        /// A virtual method for retrieving the dynamic parameters for a cmdlet. Derived cmdlets
        /// that require dynamic parameters should override this method and return the
        /// dynamic parameter object.
        /// </summary>
        /// <param name="context">
        /// The context under which the command is running.
        /// </param>
        /// <returns>
        /// An object representing the dynamic parameters for the cmdlet or null if there
        /// are none.
        /// </returns>
        internal override object GetDynamicParameters(CmdletProviderContext context)
        {
            if (Path != null && Path.Length > 0)
            {
                return(InvokeProvider.Property.GetPropertyDynamicParameters(
                           Path[0],
                           SessionStateUtilities.ConvertArrayToCollection <string>(_property), context));
            }
            return(InvokeProvider.Property.GetPropertyDynamicParameters(
                       ".",
                       SessionStateUtilities.ConvertArrayToCollection <string>(_property), context));
        } // GetDynamicParameters
Esempio n. 4
0
 /// <summary>
 /// Gets the properties of an item at the specified path
 /// </summary>
 protected override void ProcessRecord()
 {
     foreach (string path in Path)
     {
         try
         {
             InvokeProvider.Property.Get(
                 path,
                 SessionStateUtilities.ConvertArrayToCollection <string>(_property),
                 CmdletProviderContext);
         }
         catch (PSNotSupportedException notSupported)
         {
             WriteError(
                 new ErrorRecord(
                     notSupported.ErrorRecord,
                     notSupported));
             continue;
         }
         catch (DriveNotFoundException driveNotFound)
         {
             WriteError(
                 new ErrorRecord(
                     driveNotFound.ErrorRecord,
                     driveNotFound));
             continue;
         }
         catch (ProviderNotFoundException providerNotFound)
         {
             WriteError(
                 new ErrorRecord(
                     providerNotFound.ErrorRecord,
                     providerNotFound));
             continue;
         }
         catch (ItemNotFoundException pathNotFound)
         {
             WriteError(
                 new ErrorRecord(
                     pathNotFound.ErrorRecord,
                     pathNotFound));
             continue;
         }
     }
 } // ProcessRecord
Esempio n. 5
0
        /// <summary>
        /// Gets the values of the properties of an item at the specified path.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (Path == null || Path.Length == 0)
            {
                paths = new string[] { "." };
            }
            foreach (string path in Path)
            {
                try
                {
                    Collection <PSObject> itemProperties = InvokeProvider.Property.Get(
                        new string[] { path },
                        SessionStateUtilities.ConvertArrayToCollection <string>(_property),
                        base.SuppressWildcardExpansion);

                    if (itemProperties != null)
                    {
                        foreach (PSObject currentItem in itemProperties)
                        {
                            if (this.Name != null)
                            {
                                foreach (string currentPropertyName in this.Name)
                                {
                                    if (currentItem.Properties != null &&
                                        currentItem.Properties[currentPropertyName] != null &&
                                        currentItem.Properties[currentPropertyName].Value != null)
                                    {
                                        CmdletProviderContext.WriteObject(currentItem.Properties[currentPropertyName].Value);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (PSNotSupportedException notSupported)
                {
                    WriteError(
                        new ErrorRecord(
                            notSupported.ErrorRecord,
                            notSupported));
                    continue;
                }
                catch (DriveNotFoundException driveNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            driveNotFound.ErrorRecord,
                            driveNotFound));
                    continue;
                }
                catch (ProviderNotFoundException providerNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            providerNotFound.ErrorRecord,
                            providerNotFound));
                    continue;
                }
                catch (ItemNotFoundException pathNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            pathNotFound.ErrorRecord,
                            pathNotFound));
                    continue;
                }
            }
        }
Esempio n. 6
0
 internal override object GetDynamicParameters(CmdletProviderContext context)
 {
     if (this.Path == null || (int)this.Path.Length <= 0)
     {
         return(base.InvokeProvider.Property.GetPropertyDynamicParameters(".", SessionStateUtilities.ConvertArrayToCollection <string>(this.property), context));
     }
     else
     {
         return(base.InvokeProvider.Property.GetPropertyDynamicParameters(this.Path[0], SessionStateUtilities.ConvertArrayToCollection <string>(this.property), context));
     }
 }