ScrewTurn.Wiki.PagesStorageProvider.AddPage C# (CSharp) Method

AddPage() public method

Adds a Page.
This method should not create the content of the Page.
If is null. If is empty.
public AddPage ( string nspace, string name, System.DateTime creationDateTime ) : System.PageInfo
nspace string The target namespace (null for the root).
name string The Page Name.
creationDateTime System.DateTime The creation Date/Time.
return System.PageInfo
        public PageInfo AddPage(string nspace, string name, DateTime creationDateTime)
        {
            if(name == null) throw new ArgumentNullException("name");
            if(name.Length == 0) throw new ArgumentException("Name cannot be empty", "name");

            lock(this) {
                if(!NamespaceExists(nspace)) return null;
                if(PageExists(new PageInfo(NameTools.GetFullName(nspace, name), this, DateTime.Now))) return null;

                LocalPageInfo result = new LocalPageInfo(NameTools.GetFullName(nspace, name), this, creationDateTime,
                    GetNamespacePartialPathForPageContent(nspace) + name + ".cs");

                BackupPagesFile();

                // Structure
                // Namespace.Page|File|CreationDateTime
                File.AppendAllText(GetFullPath(PagesFile), result.FullName + "|" + result.File + "|" + creationDateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss") + "\r\n");
                //File.Create(GetFullPathForPageContent(result.File)).Close(); // Empty content file might cause problems with backups
                File.WriteAllText(GetFullPathForPageContent(result.File), "--\r\n--|1900/01/01 0:00:00|\r\n##PAGE##\r\n--");
                pagesCache = null;

                return result;
            }
        }
PagesStorageProvider