CodeOwls.PowerShell.Provider.Provider.NewItem C# (CSharp) Метод

NewItem() приватный Метод

private NewItem ( string path, bool isParentPathNodeFactory, INodeFactory factory, string itemTypeName, object newItemValue ) : void
path string
isParentPathNodeFactory bool
factory INodeFactory
itemTypeName string
newItemValue object
Результат void
        void NewItem( string path, bool isParentPathNodeFactory, INodeFactory factory, string itemTypeName, object newItemValue )
        {
            var @new = factory as INewItem;
            if (null == factory || null == @new)
            {
                WriteCmdletNotSupportedAtNodeError(path, ProviderCmdlet.NewItem, NewItemNotSupportedErrorID);
                return;
            }

            var fullPath = path;
            var parentPath = fullPath;
            var child = isParentPathNodeFactory ? GetChildName(path) : null;
            if( null != child )
            {
                parentPath = GetParentPath(fullPath, GetRootPath());
            }

            if (!ShouldProcess(fullPath, ProviderCmdlet.NewItem))
            {
                return;
            }

            try
            {
                var item = @new.NewItem(CreateContext(fullPath), child, itemTypeName, newItemValue);
                PathNode node = item as PathNode;

                WritePathNode(parentPath, node);
            }
            catch (Exception e)
            {
                WriteGeneralCmdletError(e, NewItemInvokeErrorID, fullPath);
            }
        }

Same methods

Provider::NewItem ( string path, string itemTypeName, object newItemValue ) : void