internal CmdletProvider Add(ProviderInfo providerInfo, ExecutionContext executionContext)
        {
            CmdletProvider provider = providerInfo.CreateInstance();

            var runtime = new ProviderRuntime(executionContext.SessionState);
            providerInfo = provider.Start(providerInfo, runtime);
            provider.SetProviderInfo(providerInfo);

            // Cache the Provider's Info and instance
            if (!_providers.ContainsKey(providerInfo.Name))
            {
                _providers.Add(providerInfo.Name, new List<ProviderInfo>());
            }
            _providers[providerInfo.Name].Add(providerInfo);
            _providerInstances[providerInfo] = provider;

            // provider is added, default drives can be added
            AddDefaultDrives(provider, runtime);

            return provider;
        }
        internal CmdletProvider Add(ProviderInfo providerInfo, ExecutionContext executionContext)
        {
            CmdletProvider provider = providerInfo.CreateInstance();

            var runtime = new ProviderRuntime(executionContext.SessionState);

            providerInfo = provider.Start(providerInfo, runtime);
            provider.SetProviderInfo(providerInfo);

            // Cache the Provider's Info and instance
            if (!_providers.ContainsKey(providerInfo.Name))
            {
                _providers.Add(providerInfo.Name, new List <ProviderInfo>());
            }
            _providers[providerInfo.Name].Add(providerInfo);
            _providerInstances[providerInfo] = provider;

            // provider is added, default drives can be added
            AddDefaultDrives(provider, runtime);

            return(provider);
        }
        /// <summary>
        /// Get provider specific help info.
        /// </summary>
        internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)
        {
            if (InternalTestHooks.BypassOnlineHelpRetrieval)
            {
                // By returning null, we force get-help to return generic help
                // which includes a helpUri that points to the fwlink defined in the cmdlet code.
                return(null);
            }

            // Get the provider.
            ProviderInfo          providerInfo          = null;
            PSDriveInfo           driveInfo             = null;
            string                resolvedProviderPath  = null;
            CmdletProviderContext cmdletProviderContext = new CmdletProviderContext(_executionContext);

            try
            {
                string psPath = _requestedPath;
                if (string.IsNullOrEmpty(_requestedPath))
                {
                    psPath = _pathIntrinsics.CurrentLocation.Path;
                }

                resolvedProviderPath = _executionContext.LocationGlobber.GetProviderPath(
                    psPath,
                    cmdletProviderContext,
                    out providerInfo,
                    out driveInfo);
            }
            // ignore exceptions caused by provider resolution
            catch (ArgumentNullException)
            {
            }
            catch (ProviderNotFoundException)
            {
            }
            catch (DriveNotFoundException)
            {
            }
            catch (ProviderInvocationException)
            {
            }
            catch (NotSupportedException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            catch (ItemNotFoundException)
            {
            }

            if (providerInfo == null)
            {
                return(null);
            }

            // Does the provider know how to generate MAML.
            CmdletProvider cmdletProvider        = providerInfo.CreateInstance();
            ICmdletProviderSupportsHelp provider = cmdletProvider as ICmdletProviderSupportsHelp;

            // Under JEA sessions the resolvedProviderPath will be null, we should allow get-help to continue.
            if (provider == null)
            {
                return(null);
            }

            bool isJEASession = false;

            if (this._executionContext.InitialSessionState != null && this._executionContext.InitialSessionState.Providers != null && providerInfo != null)
            {
                foreach (
                    Runspaces.SessionStateProviderEntry sessionStateProvider in
                    this._executionContext.InitialSessionState.Providers[providerInfo.Name])
                {
                    if (sessionStateProvider.Visibility == SessionStateEntryVisibility.Private)
                    {
                        isJEASession = true;
                        break;
                    }
                }
            }

            if (resolvedProviderPath == null)
            {
                if (isJEASession)
                {
                    return(null);
                }
                else
                {
                    throw new ItemNotFoundException(_requestedPath, "PathNotFound", SessionStateStrings.PathNotFound);
                }
            }

            // ok we have path and valid provider that supplys content..initialize the provider
            // and get the help content for the path.
            cmdletProvider.Start(providerInfo, cmdletProviderContext);
            // There should be exactly one resolved path.
            string providerPath = resolvedProviderPath;
            // Get the MAML help info. Don't catch exceptions thrown by provider.
            string mamlXmlString = provider.GetHelpMaml(helpItemName, providerPath);

            if (string.IsNullOrEmpty(mamlXmlString))
            {
                return(null);
            }
            // process the MAML content only if it is non-empty.
            XmlDocument mamlDoc = InternalDeserializer.LoadUnsafeXmlDocument(
                mamlXmlString,
                false, /* ignore whitespace, comments, etc. */
                null); /* default maxCharactersInDocument */
            MamlCommandHelpInfo providerSpecificHelpInfo = MamlCommandHelpInfo.Load(mamlDoc.DocumentElement, HelpCategory.Provider);

            return(providerSpecificHelpInfo);
        }
Esempio n. 4
0
        private CmdletProvider AddProvider(ProviderInfo providerInfo)
        {
            CmdletProvider provider = providerInfo.CreateInstance();

            provider.Start(providerInfo, new ProviderRuntime(_executionContext));
            provider.SetProviderInfo(providerInfo);

            // Cache the Provider's Info
            if (!_providers.ContainsKey(providerInfo.Name))
            {
                _providers.Add(providerInfo.Name, new List<ProviderInfo>());
            }
            _providers[providerInfo.Name].Add(providerInfo);

            return provider;
        }
Esempio n. 5
0
        internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)
        {
            ProviderInfo          info    = null;
            PSDriveInfo           drive   = null;
            string                str     = null;
            CmdletProviderContext context = new CmdletProviderContext(this._executionContext);

            try
            {
                string str2 = this._requestedPath;
                if (string.IsNullOrEmpty(this._requestedPath))
                {
                    str2 = this._pathIntrinsics.CurrentLocation.Path;
                }
                str = this._executionContext.LocationGlobber.GetProviderPath(str2, context, out info, out drive);
            }
            catch (ArgumentNullException)
            {
            }
            catch (ProviderNotFoundException)
            {
            }
            catch (DriveNotFoundException)
            {
            }
            catch (ProviderInvocationException)
            {
            }
            catch (NotSupportedException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            catch (ItemNotFoundException)
            {
            }
            if (info == null)
            {
                return(null);
            }
            CmdletProvider provider          = info.CreateInstance();
            ICmdletProviderSupportsHelp help = provider as ICmdletProviderSupportsHelp;

            if (help == null)
            {
                return(null);
            }
            if (str == null)
            {
                throw new ItemNotFoundException(this._requestedPath, "PathNotFound", SessionStateStrings.PathNotFound);
            }
            provider.Start(info, context);
            string path     = str;
            string helpMaml = help.GetHelpMaml(helpItemName, path);

            if (string.IsNullOrEmpty(helpMaml))
            {
                return(null);
            }
            return(MamlCommandHelpInfo.Load(InternalDeserializer.LoadUnsafeXmlDocument(helpMaml, false, null).DocumentElement, HelpCategory.Provider));
        }
        /// <summary>
        /// Get provider specific help info.
        /// </summary>
        internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)
        {
            // Get the provider.
            ProviderInfo          providerInfo          = null;
            PSDriveInfo           driveInfo             = null;
            string                resolvedProviderPath  = null;
            CmdletProviderContext cmdletProviderContext = new CmdletProviderContext(_executionContext);

            try
            {
                string psPath = _requestedPath;
                if (string.IsNullOrEmpty(_requestedPath))
                {
                    psPath = _pathIntrinsics.CurrentLocation.Path;
                }

                resolvedProviderPath = _executionContext.LocationGlobber.GetProviderPath(
                    psPath,
                    cmdletProviderContext,
                    out providerInfo,
                    out driveInfo);
            }
            // ignore exceptions caused by provider resolution
            catch (ArgumentNullException)
            {
            }
            catch (ProviderNotFoundException)
            {
            }
            catch (DriveNotFoundException)
            {
            }
            catch (ProviderInvocationException)
            {
            }
            catch (NotSupportedException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            catch (ItemNotFoundException)
            {
            }

            if (providerInfo == null)
            {
                return(null);
            }

            // Does the provider know how to generate MAML.
            CmdletProvider cmdletProvider        = providerInfo.CreateInstance();
            ICmdletProviderSupportsHelp provider = cmdletProvider as ICmdletProviderSupportsHelp;

            if (provider == null)
            {
                return(null);
            }

            if (resolvedProviderPath == null)
            {
                throw new ItemNotFoundException(_requestedPath, "PathNotFound", SessionStateStrings.PathNotFound);
            }

            // ok we have path and valid provider that supplys content..initialize the provider
            // and get the help content for the path.
            cmdletProvider.Start(providerInfo, cmdletProviderContext);
            // There should be exactly one resolved path.
            string providerPath = resolvedProviderPath;
            // Get the MAML help info. Don't catch exceptions thrown by provider.
            string mamlXmlString = provider.GetHelpMaml(helpItemName, providerPath);

            if (string.IsNullOrEmpty(mamlXmlString))
            {
                return(null);
            }
            // process the MAML content only if it is non-empty.
            XmlDocument mamlDoc = InternalDeserializer.LoadUnsafeXmlDocument(
                mamlXmlString,
                false, /* ignore whitespace, comments, etc. */
                null); /* default maxCharactersInDocument */
            MamlCommandHelpInfo providerSpecificHelpInfo = MamlCommandHelpInfo.Load(mamlDoc.DocumentElement, HelpCategory.Provider);

            return(providerSpecificHelpInfo);
        }
Esempio n. 7
0
        } // GetProviderInstance

        /// <summary>
        /// Gets an instance of a provider given the provider information.
        /// </summary>
        /// 
        /// <param name="provider">
        /// The provider to return an instance of.
        /// </param>
        /// 
        /// <returns>
        /// An instance of the specified provider.
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="provider"/> is null.
        /// </exception>
        /// 
        internal Provider.CmdletProvider GetProviderInstance(ProviderInfo provider)
        {
            if (provider == null)
            {
                throw PSTraceSource.NewArgumentNullException("provider");
            }

            return provider.CreateInstance();
        } // GetProviderInstance
Esempio n. 8
0
        } // InitializeProvider



        /// <summary>
        /// Creates and adds a provider to the provider container 
        /// </summary>
        /// 
        /// <param name="provider">
        /// The provider to add.
        /// </param>
        /// 
        /// <returns>
        /// The provider that was added or null if the provider failed to be added.
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="provider"/> is null.
        /// </exception>
        /// 
        /// <exception cref="SessionStateException">
        /// If the provider already exists.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If there was a failure to load the provider or the provider
        /// threw an exception.
        /// </exception>
        /// 
        internal ProviderInfo NewProvider(ProviderInfo provider)
        {
            if (provider == null)
            {
                throw PSTraceSource.NewArgumentNullException("provider");
            }

            // Check to see if the provider already exists.
            // We do the check instead of allowing the hashtable to 
            // throw the exception so that we give a better error
            // message.
            ProviderInfo existingProvider = ProviderExists(provider);
            if (existingProvider != null)
            {
                // If it's an already loaded provider, don't return an error...
                if (existingProvider.ImplementingType == provider.ImplementingType)
                    return existingProvider;

                SessionStateException sessionStateException =
                    new SessionStateException(
                        provider.Name,
                        SessionStateCategory.CmdletProvider,
                        "CmdletProviderAlreadyExists",
                        SessionStateStrings.CmdletProviderAlreadyExists,
                        ErrorCategory.ResourceExists);

                throw sessionStateException;
            }


            // Make sure we are able to create an instance of the provider.
            // Note, this will also set the friendly name if the user didn't
            // specify one.

            Provider.CmdletProvider providerInstance = provider.CreateInstance();

            // Now call start to let the provider initialize itself
            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);
            ProviderInfo newProviderInfo = null;

            try
            {
                newProviderInfo = providerInstance.Start(provider, context);

                // Set the new provider info in the instance in case the provider
                // derived a new one

                providerInstance.SetProviderInformation(newProviderInfo);
            }
            catch (LoopFlowException)
            {
                throw;
            }
            catch (PipelineStoppedException)
            {
                throw;
            }
            catch (ActionPreferenceStopException)
            {
                throw;
            }
            catch (InvalidOperationException)
            {
                throw;
            }
            catch (Exception e) // Catch-call OK, 3rd party callout
            {
                CommandProcessorBase.CheckForSevereException(e);
                throw
                    NewProviderInvocationException(
                        "ProviderStartException",
                        SessionStateStrings.ProviderStartException,
                        provider,
                        null,
                        e);
            }

            context.ThrowFirstErrorOrDoNothing(true);

            if (newProviderInfo == null)
            {
                throw
                    PSTraceSource.NewInvalidOperationException(
                        SessionStateStrings.InvalidProviderInfoNull);
            }

            if (newProviderInfo != provider)
            {
                // Since the references are not the same, ensure that the provider
                // name is the same.

                if (!string.Equals(newProviderInfo.Name, provider.Name, StringComparison.OrdinalIgnoreCase))
                {
                    throw
                        PSTraceSource.NewInvalidOperationException(
                            SessionStateStrings.InvalidProviderInfo);
                }

                // Use the new provider info instead
                provider = newProviderInfo;
            }

            // Add the newly create provider to the providers container

            try
            {
                NewProviderEntry(provider);
            }
            catch (ArgumentException)
            {
                SessionStateException sessionStateException =
                    new SessionStateException(
                        provider.Name,
                        SessionStateCategory.CmdletProvider,
                        "CmdletProviderAlreadyExists",
                        SessionStateStrings.CmdletProviderAlreadyExists,
                        ErrorCategory.ResourceExists);

                throw sessionStateException;
            }

            // Add the provider to the provider current working 
            // drive hashtable so that we can associate a current working
            // drive with it.

            ProvidersCurrentWorkingDrive.Add(provider, null);

            bool initializeProviderError = false;
            try
            {
                // Initialize the provider and give it a chance to 
                // mount some drives.

                InitializeProvider(providerInstance, provider, context);
                context.ThrowFirstErrorOrDoNothing(true);
            }
            catch (LoopFlowException)
            {
                throw;
            }
            catch (PipelineStoppedException)
            {
                initializeProviderError = true;
                throw;
            }
            catch (ActionPreferenceStopException)
            {
                initializeProviderError = true;
                throw;
            }
            catch (NotSupportedException)
            {
                // We can safely ignore NotSupportedExceptions because
                // it just means that the provider doesn't support
                // drives.

                initializeProviderError = false;
            }
            catch (SessionStateException)
            {
                initializeProviderError = true;
                throw;
            }
            finally
            {
                if (initializeProviderError)
                {
                    // An exception during initialization should remove the provider from 
                    // session state.

                    Providers.Remove(provider.Name.ToString());
                    ProvidersCurrentWorkingDrive.Remove(provider);
                    provider = null;
                }
            }

#if RELATIONSHIP_SUPPORTED
    // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release

            // Make sure the delay-load relationships get updated for the new provider

            relationships.ProcessDelayLoadRelationships (provider.Name);
#endif

            // Now write out the result

            return provider;
        } // NewProvider
Esempio n. 9
0
        internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)
        {
            ProviderInfo          provider = (ProviderInfo)null;
            PSDriveInfo           drive    = (PSDriveInfo)null;
            string                str      = (string)null;
            CmdletProviderContext cmdletProviderContext = new CmdletProviderContext(this._executionContext);

            try
            {
                string path = this._requestedPath;
                if (string.IsNullOrEmpty(this._requestedPath))
                {
                    path = this._pathIntrinsics.CurrentLocation.Path;
                }
                str = this._executionContext.LocationGlobber.GetProviderPath(path, cmdletProviderContext, out provider, out drive);
            }
            catch (ArgumentNullException ex)
            {
            }
            catch (ProviderNotFoundException ex)
            {
            }
            catch (DriveNotFoundException ex)
            {
            }
            catch (ProviderInvocationException ex)
            {
            }
            catch (NotSupportedException ex)
            {
            }
            catch (InvalidOperationException ex)
            {
            }
            catch (ItemNotFoundException ex)
            {
            }
            if (provider == null)
            {
                return((MamlCommandHelpInfo)null);
            }
            CmdletProvider instance = provider.CreateInstance();

            if (!(instance is ICmdletProviderSupportsHelp providerSupportsHelp))
            {
                return((MamlCommandHelpInfo)null);
            }
            if (str == null)
            {
                throw new ItemNotFoundException(this._requestedPath, "PathNotFound");
            }
            instance.Start(provider, cmdletProviderContext);
            string path1    = str;
            string helpMaml = providerSupportsHelp.GetHelpMaml(helpItemName, path1);

            if (string.IsNullOrEmpty(helpMaml))
            {
                return((MamlCommandHelpInfo)null);
            }
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(helpMaml);
            return(MamlCommandHelpInfo.Load((XmlNode)xmlDocument.DocumentElement, HelpCategory.Provider));
        }
Esempio n. 10
0
 internal ProviderInfo NewProvider(ProviderInfo provider)
 {
     if (provider == null)
     {
         throw PSTraceSource.NewArgumentNullException("provider");
     }
     ProviderInfo info = this.ProviderExists(provider);
     if (info != null)
     {
         if (info.ImplementingType == provider.ImplementingType)
         {
             return info;
         }
         SessionStateException exception = new SessionStateException(provider.Name, SessionStateCategory.CmdletProvider, "CmdletProviderAlreadyExists", SessionStateStrings.CmdletProviderAlreadyExists, ErrorCategory.ResourceExists, new object[0]);
         throw exception;
     }
     CmdletProvider providerInstance = provider.CreateInstance();
     CmdletProviderContext cmdletProviderContext = new CmdletProviderContext(this.ExecutionContext);
     ProviderInfo providerInfoToSet = null;
     try
     {
         providerInfoToSet = providerInstance.Start(provider, cmdletProviderContext);
         providerInstance.SetProviderInformation(providerInfoToSet);
     }
     catch (LoopFlowException)
     {
         throw;
     }
     catch (PipelineStoppedException)
     {
         throw;
     }
     catch (ActionPreferenceStopException)
     {
         throw;
     }
     catch (InvalidOperationException)
     {
         throw;
     }
     catch (Exception exception2)
     {
         CommandProcessorBase.CheckForSevereException(exception2);
         throw this.NewProviderInvocationException("ProviderStartException", SessionStateStrings.ProviderStartException, provider, null, exception2);
     }
     cmdletProviderContext.ThrowFirstErrorOrDoNothing(true);
     if (providerInfoToSet == null)
     {
         throw PSTraceSource.NewInvalidOperationException("SessionStateStrings", "InvalidProviderInfoNull", new object[0]);
     }
     if (providerInfoToSet != provider)
     {
         if (!string.Equals(providerInfoToSet.Name, provider.Name, StringComparison.OrdinalIgnoreCase))
         {
             throw PSTraceSource.NewInvalidOperationException("SessionStateStrings", "InvalidProviderInfo", new object[0]);
         }
         provider = providerInfoToSet;
     }
     try
     {
         this.NewProviderEntry(provider);
     }
     catch (ArgumentException)
     {
         SessionStateException exception3 = new SessionStateException(provider.Name, SessionStateCategory.CmdletProvider, "CmdletProviderAlreadyExists", SessionStateStrings.CmdletProviderAlreadyExists, ErrorCategory.ResourceExists, new object[0]);
         throw exception3;
     }
     this.ProvidersCurrentWorkingDrive.Add(provider, null);
     bool flag = false;
     try
     {
         this.InitializeProvider(providerInstance, provider, cmdletProviderContext);
         cmdletProviderContext.ThrowFirstErrorOrDoNothing(true);
     }
     catch (LoopFlowException)
     {
         throw;
     }
     catch (PipelineStoppedException)
     {
         flag = true;
         throw;
     }
     catch (ActionPreferenceStopException)
     {
         flag = true;
         throw;
     }
     catch (NotSupportedException)
     {
         flag = false;
     }
     catch (SessionStateException)
     {
         flag = true;
         throw;
     }
     finally
     {
         if (flag)
         {
             this.Providers.Remove(provider.Name.ToString());
             this.ProvidersCurrentWorkingDrive.Remove(provider);
             provider = null;
         }
     }
     return provider;
 }
Esempio n. 11
0
 internal string MakePath(ProviderInfo provider, string parent, string child, CmdletProviderContext context)
 {
     CmdletProvider providerInstance = provider.CreateInstance();
     return this.MakePath(providerInstance, parent, child, context);
 }
Esempio n. 12
0
 private string GetChildName(ProviderInfo provider, string path, CmdletProviderContext context)
 {
     CmdletProvider providerInstance = provider.CreateInstance();
     return this.GetChildName(providerInstance, path, context, true);
 }
Esempio n. 13
0
 string GetProviderPathFromDriveQualifiedPath(string path, ProviderRuntime runtime, out ProviderInfo providerInfo, out PSDriveInfo drive)
 {
     var idx = path.IndexOf(":");
     var driveName = path.Substring(0, idx);
     // TODO: validate drive name?
     drive = _sessionState.Drive.Get(driveName);
     providerInfo = drive.Provider;
     path = path.Substring(idx + 1).TrimStart(PathIntrinsics.CorrectSlash, PathIntrinsics.WrongSlash);
     return Path.Combine(providerInfo.CreateInstance(), drive.Root, path, runtime);
 }
Esempio n. 14
0
        } // GetChildName

        /// <summary>
        /// Gets the leaf element of the specified path.
        /// </summary>
        /// 
        /// <param name="provider">
        /// The provider to use.
        /// </param>
        /// 
        /// <param name="path">
        /// The path to the item if it was specified on the command line.
        /// </param>
        /// 
        /// <param name="context">
        /// The context which the core command is running.
        /// </param>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the <paramref name="providerInstance"/> does not support this operation.
        /// </exception>
        /// 
        /// <exception cref="PipelineStoppedException">
        /// If the pipeline is being stopped while executing the command.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        private string GetChildName(
            ProviderInfo provider,
            string path,
            CmdletProviderContext context)
        {
            // All parameters should have been validated by caller
            Dbg.Diagnostics.Assert(
                provider != null,
                "Caller should validate provider before calling this method");

            Dbg.Diagnostics.Assert(
                path != null,
                "Caller should validate path before callin g this method");

            Dbg.Diagnostics.Assert(
                context != null,
                "Caller should validate context before calling this method");


            CmdletProvider providerInstance = provider.CreateInstance();

            return GetChildName(providerInstance, path, context, true);
        }
Esempio n. 15
0
        } // MakePath

        /// <summary>
        /// Uses the specified provider to put the two parts of a path together
        /// </summary>
        /// 
        /// <param name="provider">
        /// The provider to use.
        /// </param>
        /// 
        /// <param name="parent">
        /// The parent part of the path to join with the child.
        /// </param>
        /// 
        /// <param name="child">
        /// The child part of the path to join with the parent.
        /// </param>
        /// 
        /// <param name="context">
        /// The context under which the command is running.
        /// </param>
        /// 
        /// <returns>
        /// The combined path.
        /// </returns>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the <paramref name="providerId"/> does not support this operation.
        /// </exception>
        /// 
        /// <exception cref="PipelineStoppedException">
        /// If the pipeline is being stopped while executing the command.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        internal string MakePath(
            ProviderInfo provider,
            string parent,
            string child,
            CmdletProviderContext context)
        {
            // All parameters should have been validated by caller
            Dbg.Diagnostics.Assert(
                provider != null,
                "Caller should validate provider before calling this method");

            Dbg.Diagnostics.Assert(
                context != null,
                "Caller should validate context before calling this method");

            // Get an instance of the provider


            Provider.CmdletProvider providerInstance = provider.CreateInstance();

            return MakePath(providerInstance, parent, child, context);
        }