ScrewTurn.Wiki.UsersStorageProvider.AddUserGroup C# (CSharp) Method

AddUserGroup() public method

Adds a new user group.
If name or description are null. If name is empty.
public AddUserGroup ( string name, string description ) : UserGroup
name string The name of the group.
description string The description of the group.
return UserGroup
        public UserGroup AddUserGroup(string name, string description)
        {
            if(name == null) throw new ArgumentNullException("name");
            if(name.Length == 0) throw new ArgumentException("Name cannot be empty", "name");
            if(description == null) throw new ArgumentNullException("description");

            lock(this) {
                if(FindGroup(name) != null) return null;

                BackupGroupsFile();

                groupsCache = null;

                // Structure - description can be empty
                // Name|Description|User1|User2|...

                File.AppendAllText(GetFullPath(GroupsFile),
                    name + "|" + description + "\r\n");

                return new UserGroup(name, description, this);
            }
        }