Exemple #1
0
        protected override XmlElement RawAddList(WebInfo web, ListCreationParameters parameters)
        {
            var target = GetWebXml(web);

            if (HasWebXml(target, parameters.Name))
            {
                throw new ApplicationException("Web with the same name found.");
            }
            if (HasWebFolderXml(target, parameters.Name))
            {
                throw new ApplicationException("WebFolder with the same name found.");
            }
            if (HasListXml(target, parameters.Name))
            {
                throw new ApplicationException("List with the same name found.");
            }
            var source = target.OwnerDocument.CreateElement("List");

            source.SetAttribute("ID", Guid.NewGuid().ToString("D"));
            source.SetAttribute("Name", parameters.Name);
            if (string.IsNullOrEmpty(parameters.Description))
            {
                source.SetAttribute("Description", parameters.Description);
            }
            source.SetAttribute("Template", parameters.Template.ToStringI());
            source.SetAttribute("Created", DateForNow);
            target.AppendChild(source);
            SaveSite(target);
            return(source);
        }
Exemple #2
0
        public ListInfo AddList(WebInfo web, ListCreationParameters parameters)
        {
            if (web == null)
            {
                throw new ArgumentNullException("web");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            parameters.Check();
            var list = AddListDirectly(web, parameters);

            if (web.Lists != null)
            {
                web.Lists = web.Lists.Concat(new[] { list }).ToList();
            }
            return(list);
        }
Exemple #3
0
 public ListInfo AddList(ListCreationParameters parameters)
 {
     return Connector.GetModifying().AddList(this, parameters);
 }
Exemple #4
0
 public ListInfo AddList(ListCreationParameters parameters)
 {
     throw new InvalidOperationException("Lists can be added to a web only.");
 }
Exemple #5
0
 protected abstract ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters);
Exemple #6
0
 public ListInfo AddList(WebInfo web, ListCreationParameters parameters)
 {
     if (web == null)
         throw new ArgumentNullException("web");
     if (parameters == null)
         throw new ArgumentNullException("parameters");
     parameters.Check();
     var list = AddListDirectly(web, parameters);
     if (web.Lists != null)
         web.Lists = web.Lists.Concat(new[] { list }).ToList();
     return list;
 }
Exemple #7
0
 public ListInfo AddList(ListCreationParameters parameters)
 {
     return(Connector.GetModifying().AddList(this, parameters));
 }
Exemple #8
0
 public ListInfo AddList(ListCreationParameters parameters)
 {
     throw new InvalidOperationException("Lists can be added to a web only.");
 }
Exemple #9
0
        // Item creation

        protected override void NewItem(string path, string itemTypeName, object newItemValue)
        {
            EnsureLog();
            path = PathUtility.NormalizePath(path);
            if (ShouldProcess(path, "New Item"))
            {
                string name;
                var    parent = PathUtility.GetParentPath(path, out name);
                var    target = GetObject(parent);
                // The type of the parameters object returned by the NewItemDynamicParameters
                // method decides the type of the object that is going to be created.
                Info added;
                var  webParameters = DynamicParameters as NewWebParameters;
                if (webParameters != null)
                {
                    var web = target as WebInfo;
                    if (web == null)
                    {
                        throw new ApplicationException("Parent cannot contain a web.");
                    }
                    added = web.AddWeb(WebCreationParameters.Create(name, webParameters));
                }
                else
                {
                    var listParameters = DynamicParameters as NewListParameters;
                    if (listParameters != null)
                    {
                        var listContainer = target as ListContainerInfo;
                        if (listContainer == null)
                        {
                            throw new ApplicationException("Parent cannot contain a list.");
                        }
                        added = listContainer.AddList(
                            ListCreationParameters.Create(name, listParameters));
                    }
                    else
                    {
                        var itemContainer = target as ItemContainerInfo;
                        if (itemContainer == null)
                        {
                            throw new ApplicationException("Parent cannot contain an item.");
                        }
                        var folderParameters = DynamicParameters as NewFolderParameters;
                        if (folderParameters != null)
                        {
                            added = itemContainer.AddFolder(name);
                        }
                        else
                        {
                            var fileParameters = DynamicParameters as NewFileParameters;
                            if (fileParameters != null)
                            {
                                var contentContainer = target as ContentContainerInfo;
                                if (contentContainer == null)
                                {
                                    throw new ApplicationException(
                                              "Parent cannot contain a file.");
                                }
                                newItemValue = newItemValue.GetBaseObject();
                                using (var content = GetContent(newItemValue, fileParameters))
                                    added = contentContainer.AddFile(name, content);
                            }
                            else
                            {
                                var itemParameters = (NewItemParameters)DynamicParameters;
                                added = itemContainer.AddItem(name);
                            }
                        }
                    }
                }
                WriteItemObject(added);
            }
        }
Exemple #10
0
 protected abstract XmlElement RawAddList(WebInfo web, ListCreationParameters parameters);
Exemple #11
0
 protected override ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters)
 {
     return(CreateListInfo(web, RawAddList(web, parameters)));
 }
Exemple #12
0
 protected override XmlElement RawAddList(WebInfo web, ListCreationParameters parameters)
 {
     var target = GetWebXml(web);
     if (HasWebXml(target, parameters.Name))
         throw new ApplicationException("Web with the same name found.");
     if (HasWebFolderXml(target, parameters.Name))
         throw new ApplicationException("WebFolder with the same name found.");
     if (HasListXml(target, parameters.Name))
         throw new ApplicationException("List with the same name found.");
     var source = target.OwnerDocument.CreateElement("List");
     source.SetAttribute("ID", Guid.NewGuid().ToString("D"));
     source.SetAttribute("Name", parameters.Name);
     if (string.IsNullOrEmpty(parameters.Description))
         source.SetAttribute("Description", parameters.Description);
     source.SetAttribute("Template", parameters.Template.ToStringI());
     source.SetAttribute("Created", DateForNow);
     target.AppendChild(source);
     SaveSite(target);
     return source;
 }
Exemple #13
0
 protected override ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters)
 {
     return CreateListInfo(web, RawAddList(web, parameters));
 }
Exemple #14
0
 protected abstract XmlElement RawAddList(WebInfo web, ListCreationParameters parameters);
Exemple #15
0
 protected override XmlElement RawAddList(WebInfo web, ListCreationParameters parameters)
 {
     Log.Verbose("Adding the list {0} to /{1}.", parameters.Name, web.Path);
     return((XmlElement)GetService <Lists>(web.Path).AddList(
                parameters.Name, parameters.Description, parameters.Template));
 }
Exemple #16
0
 protected abstract ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters);