CodeOwls.TxF.TxFNodeFactory.NewItem C# (CSharp) Метод

NewItem() публичный Метод

public NewItem ( IContext context, string path, string itemTypeName, object newItemValue ) : IPathNode
context IContext
path string
itemTypeName string
newItemValue object
Результат IPathNode
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var dirInfo = _node.Item as DirectoryInfo;
            if (null == dirInfo)
            {
                throw new NotSupportedException();
            }

            FileSystemInfo newItem = null;
            var newItemPath = Path.Combine(dirInfo.FullName, path);
            switch (itemTypeName.ToLowerInvariant())
            {
                case ("file"):
                    {
                        using (
                            var fs = Microsoft.KtmIntegration.TransactedFile.Open(newItemPath, FileMode.Create,
                                                                                  FileAccess.ReadWrite,
                                                                                  FileShare.ReadWrite))
                        {
                            newItem = new FileInfo(newItemPath);
                        }
                        if (null != newItemValue)
                        {
                            using (var writer = GetContentWriter(context, newItem.FullName))
                            {
                                var list = new string[] {newItemValue.ToString()}.ToList();
                                writer.Write(list);
                            }
                        }
                        break;

                    }
                case ("folder"):
                case("directory"):
                    {
                        if (Microsoft.KtmIntegration.TransactedDirectory.CreateDirectory(newItemPath))
                        {
                            newItem = new DirectoryInfo(newItemPath);
                        }
                        break;
                    }
            }

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

            return new TxFPathNode( newItem );
        }