当前位置: 首页>>代码示例>>C#>>正文


C# SPWeb.RequireNotNull方法代码示例

本文整理汇总了C#中SPWeb.RequireNotNull方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.RequireNotNull方法的具体用法?C# SPWeb.RequireNotNull怎么用?C# SPWeb.RequireNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPWeb的用法示例。


在下文中一共展示了SPWeb.RequireNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createListImpl

 private static SPList createListImpl(SPWeb web, string Title, string Description, SPListTemplate template)
 {
     web.RequireNotNull("web");
     Title.RequireNotNullOrEmpty("Title");
     Description.RequireNotNullOrEmpty("Description");
     template.RequireNotNull("template");
     Guid listGuid = web.Lists.Add(Title, Description, template);
     return web.Lists[listGuid];
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:9,代码来源:ListOperations.cs

示例2: CreateList

        public SPList CreateList(SPWeb web, string Title, string Description, SPListTemplate template)
        {
            web.RequireNotNull("web");
            Title.RequireNotNullOrEmpty("Title");
            Description.RequireNotNullOrEmpty("Description");
            template.RequireNotNull("template");
            SPList list = web.Lists.TryGetList(Title);

            return null != list ? list : createListImpl(web, Title, Description, template) ;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:10,代码来源:ListOperations.cs

示例3: AddDocumentLink

        public SPFile AddDocumentLink(SPWeb web, SPFolder targetFolder, string documentPath, string documentName, string documentUrl)
        {
            web.RequireNotNull("web");
            targetFolder.RequireNotNull("targetFolder");
            documentPath.RequireNotNullOrEmpty("documentPath");
            documentName.RequireNotNullOrEmpty("documentName");
            documentUrl.RequireNotNullOrEmpty("documentUrl");
            IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
            IContentTypeOperations contentTypeOps = serviceLocator.GetInstance<IContentTypeOperations>();
            string contentTypeName = "Link to a Document";

            var contentType = web.AvailableContentTypes[contentTypeName];
            SPDocumentLibrary DocLibrary = targetFolder.DocumentLibrary;
            if (null != DocLibrary)
            {
                bool LinkToDocumentApplied = false;
                foreach (SPContentType cType in DocLibrary.ContentTypes)
                {
                    if (cType.Name == contentTypeName)
                    {
                        LinkToDocumentApplied = true;
                        break;
                    }
                }

                if (!LinkToDocumentApplied)
                {
                    contentTypeOps.AddContentTypeToList(contentType, DocLibrary);
                }
            }

            var filePath = targetFolder.ServerRelativeUrl;
            if (!string.IsNullOrEmpty(documentPath))
            {
                filePath += "/" + documentPath;
            }
            var currentFolder = web.GetFolder(filePath);

            var files = currentFolder.Files;
            var urlOfFile = currentFolder.Url + "/" + documentName + ".aspx";

            var builder = new StringBuilder(aspxPageFormat.Length + 400);
            builder.AppendFormat(aspxPageFormat, typeof(SPDocumentLibrary).Assembly.FullName);

            var properties = new Hashtable();
            properties["ContentTypeId"] = contentType.Id.ToString();

            var file = files.Add(urlOfFile, new MemoryStream(new UTF8Encoding().GetBytes(builder.ToString())), properties, false, false);
            var item = file.Item;
            item["URL"] = documentUrl + ", ";
            item.UpdateOverwriteVersion();
            return file;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:53,代码来源:LinkToDocumentCreator.cs

示例4: ActivateFeatureIfNecessary

        public static SPFeature ActivateFeatureIfNecessary(SPWeb web, Guid featureGuid)
        {
            web.RequireNotNull("web");
            featureGuid.Require(Guid.Empty != featureGuid, "featureGuid");

            SPFeature feature = web.Features[featureGuid];
            if (null == feature)
            {
                feature = web.Features.Add(featureGuid);
            }

            return feature;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:13,代码来源:SharePointUtilities.cs

示例5: ClearWikiPage

 public void ClearWikiPage(SPFile wikiFile, SPWeb web)
 {
     wikiFile.RequireNotNull("wikiFile");
     web.RequireNotNull("web");
     ChangeWikiContent(wikiFile, string.Empty);
     using (SPLimitedWebPartManager limitedWebPartManager = wikiFile.GetLimitedWebPartManager(PersonalizationScope.Shared))
     {
         List<Microsoft.SharePoint.WebPartPages.WebPart> webParts =
             new List<Microsoft.SharePoint.WebPartPages.WebPart>(
                 from Microsoft.SharePoint.WebPartPages.WebPart w in limitedWebPartManager.WebParts
                 select w);
         webParts.ForEach(w => limitedWebPartManager.DeleteWebPart(w));
     }
     web.Update();
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:15,代码来源:WikiPagesOperations.cs

示例6: CreateSiteColumn

        public static SPField CreateSiteColumn(SPWeb web, string fieldName, SPFieldType spFieldType, bool required)
        {
            // Validation
            web.RequireNotNull("web");
            fieldName.RequireNotNullOrEmpty("fieldName");

            if (web.AvailableFields.ContainsField(fieldName))
            {
                return web.AvailableFields[fieldName];
            }

            string internalName = web.Fields.Add(fieldName, spFieldType, required);
            return web.Fields.GetFieldByInternalName(internalName);
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:14,代码来源:SharePointUtilities.cs

示例7: CreateMangedMetadataSiteColumn

        public static TaxonomyField CreateMangedMetadataSiteColumn(SPWeb web, string fieldName, TermSet termSet, string GroupName)
        {
            web.RequireNotNull("web");
            fieldName.RequireNotNullOrEmpty("fieldName");
            termSet.RequireNotNull("termSet");

            if (web.Fields.ContainsField(fieldName))
            {
                return web.Fields[fieldName] as TaxonomyField;
            }

            TaxonomyField field = web.Fields.CreateNewField("TaxonomyFieldType", fieldName) as TaxonomyField;
            field.SspId = termSet.TermStore.Id;
            field.TermSetId = termSet.Id;
            field.TargetTemplate = string.Empty;
            ///field.AllowMultipleValues = true;
            // field.CreateValuesInEditForm = true;
            field.Open = true;
            field.AnchorId = Guid.Empty;
            field.Group = !string.IsNullOrEmpty(GroupName) ? GroupName : "Managed Metadata";
            web.Fields.Add(field);
            web.Update();
            return web.Fields[fieldName] as TaxonomyField;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:24,代码来源:SharePointUtilities.cs

示例8: CreateLookupSiteColumn

        public static SPFieldLookup CreateLookupSiteColumn(SPWeb web, SPList list, string title, bool required)
        {
            // Validation
            web.RequireNotNull("web");
            list.RequireNotNull("List");
            title.RequireNotNullOrEmpty("Title");

            if (web.AvailableFields.ContainsField(title))
            {
                return web.AvailableFields[title] as SPFieldLookup;
            }

            string internalName = web.Fields.AddLookup(title, list.ID, required);
            SPFieldLookup lookupField = web.Fields.GetFieldByInternalName(internalName) as SPFieldLookup;
            return lookupField;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:16,代码来源:SharePointUtilities.cs

示例9: Unregister

 public static void Unregister(SPWeb web)
 {
     web.RequireNotNull("web");
     elevatedPrivilegesUnRegisterTypes(web);
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:5,代码来源:ServiceLocationRegistration.cs

示例10: DeleteList

        public static void DeleteList(SPWeb web, string ListTitle)
        {
            web.RequireNotNull("web");
            ListTitle.RequireNotNullOrEmpty("ListTitle");

            SPList list = web.Lists.TryGetList(ListTitle);
            if (null != list)
            {
                web.Lists.Delete(list.ID);
            }
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:11,代码来源:SharePointUtilities.cs

示例11: AddWorkflow

        public static void AddWorkflow(SPWeb web, SPList list, SPList tasks, SPList workflowHistory, string workflowTemplateName, string workflowName)
        {
            // Validation
            web.RequireNotNull("web");
            list.RequireNotNull("list");
            tasks.RequireNotNull("tasks");
            workflowHistory.RequireNotNull("workflowHistory");
            workflowTemplateName.RequireNotNullOrEmpty("builtinWorkflowName");
            workflowName.RequireNotNull("workflowName");

            SPWorkflowTemplate approvalWorkflow = SharePointUtilities.GetWorkflowByName(web, workflowTemplateName);
            SPWorkflowAssociation association = SPWorkflowAssociation.CreateListAssociation(approvalWorkflow, workflowName, tasks, workflowHistory);
            association.AutoStartCreate = true;
            association.AutoStartChange = true;
            association.AllowManual = true;
            list.WorkflowAssociations.Add(association);
            list.Update();
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:18,代码来源:SharePointUtilities.cs

示例12: AddPageToNavigation

        public static void AddPageToNavigation(SPWeb web, SPFile page, string navTitle)
        {
            web.RequireNotNull("web");
            page.RequireNotNull("page");
            navTitle.RequireNotNullOrEmpty("navTitle");

            // update the navigation
            SPNavigationNode node = new SPNavigationNode(navTitle, page.Url);
            // navigation is shared update the root
            if (web.ParentWeb.Navigation.UseShared)
            {
                using (SPSite site = new SPSite(web.Url))
                {
                    SPWeb rootWeb = site.RootWeb;
                    rootWeb.Navigation.TopNavigationBar.AddAsLast(node);
                }
            }

            else
            {
                web.Navigation.TopNavigationBar.AddAsLast(node);
            }
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:23,代码来源:SharePointUtilities.cs

示例13: TryFindContentType

 public static SPContentType TryFindContentType(SPWeb rootWeb, string contentTypeName)
 {
     rootWeb.RequireNotNull("rootWeb");
     contentTypeName.RequireNotNullOrEmpty("contentTypeName");
     SPContentType bestPracticesContentType = (from SPContentType t in rootWeb.ContentTypes
                                               where t.Name.Equals(contentTypeName)
                                               select t).FirstOrDefault();
     return bestPracticesContentType;
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:9,代码来源:SharePointUtilities.cs

示例14: CreateWiki

        public static SPList CreateWiki(SPWeb web, string title, string description)
        {
            web.RequireNotNull("web");
            title.RequireNotNullOrEmpty("title");
            description.RequireNotNullOrEmpty("description");

            SPListTemplate template = web.ListTemplates["Wiki Page Library"];
            Guid listID = new Guid();
            listID = web.Lists.Add(title, description, template);
            SPList list = web.Lists[listID];
            list.OnQuickLaunch = true;
            list.Update();

            return list;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:15,代码来源:SharePointUtilities.cs

示例15: DefaultContentApproval

 public static void DefaultContentApproval(SPWeb web, SPList list, SPList tasks, SPList workflowHistory, string workflowName)
 {
     EnableContentApproval(list);
     const string builtInWorkflowName = "Approval - SharePoint 2010";
     web.RequireNotNull("web");
     list.RequireNotNull("list");
     tasks.RequireNotNull("tasks");
     workflowHistory.RequireNotNull("workflowHistory");
     workflowName.RequireNotNullOrEmpty("workflowName");
     web.AllowUnsafeUpdates = true;
     SPWorkflowTemplate approvalWorkflow = SharePointUtilities.GetWorkflowByName(web, builtInWorkflowName);
     SPWorkflowAssociation association = SPWorkflowAssociation.CreateListAssociation(approvalWorkflow, workflowName, tasks, workflowHistory);
     association.AutoStartCreate = true;
     association.AutoStartChange = true;
     association.AllowManual = true;
     string temp = association.AssociationData;
     XDocument associationData = XDocument.Parse(temp, LoadOptions.None);
     association.AssociationData = SharePointUtilities.GetDefaultAssociationData(web, associationData);
     list.WorkflowAssociations.Add(association);
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:20,代码来源:SharePointUtilities.cs


注:本文中的SPWeb.RequireNotNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。