コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: Info.cs プロジェクト: prantlf/SharePosh
 public ListInfo AddList(ListCreationParameters parameters)
 {
     return Connector.GetModifying().AddList(this, parameters);
 }
コード例 #4
0
ファイル: Info.cs プロジェクト: prantlf/SharePosh
 public ListInfo AddList(ListCreationParameters parameters)
 {
     throw new InvalidOperationException("Lists can be added to a web only.");
 }
コード例 #5
0
ファイル: CacheConnector.cs プロジェクト: prantlf/SharePosh
 protected abstract ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters);
コード例 #6
0
ファイル: CacheConnector.cs プロジェクト: prantlf/SharePosh
 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;
 }
コード例 #7
0
 public ListInfo AddList(ListCreationParameters parameters)
 {
     return(Connector.GetModifying().AddList(this, parameters));
 }
コード例 #8
0
 public ListInfo AddList(ListCreationParameters parameters)
 {
     throw new InvalidOperationException("Lists can be added to a web only.");
 }
コード例 #9
0
ファイル: DriveProvider.cs プロジェクト: prantlf/SharePosh
        // 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);
            }
        }
コード例 #10
0
ファイル: XmlConnector.cs プロジェクト: prantlf/SharePosh
 protected abstract XmlElement RawAddList(WebInfo web, ListCreationParameters parameters);
コード例 #11
0
ファイル: XmlConnector.cs プロジェクト: prantlf/SharePosh
 protected override ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters)
 {
     return(CreateListInfo(web, RawAddList(web, parameters)));
 }
コード例 #12
0
ファイル: TestConnector.cs プロジェクト: prantlf/SharePosh
 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;
 }
コード例 #13
0
ファイル: XmlConnector.cs プロジェクト: prantlf/SharePosh
 protected override ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters)
 {
     return CreateListInfo(web, RawAddList(web, parameters));
 }
コード例 #14
0
ファイル: XmlConnector.cs プロジェクト: prantlf/SharePosh
 protected abstract XmlElement RawAddList(WebInfo web, ListCreationParameters parameters);
コード例 #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));
 }
コード例 #16
0
 protected abstract ListInfo AddListDirectly(WebInfo web,
                                             ListCreationParameters parameters);