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


C# SPList.RequireNotNull方法代码示例

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


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

示例1: CreateLookup

 public SPFieldLookup CreateLookup(SPFieldCollection siteColumns, string fieldName, SPList lookupList, SPWeb web, bool required)
 {
     siteColumns.RequireNotNull("siteColumns");
     fieldName.RequireNotNullOrEmpty("fieldName");
     lookupList.RequireNotNull("lookupList");
     string internalFieldName;
     SPField looupField = TryGetField(siteColumns,fieldName);
     if (null == looupField)
     {
         if (null != web)
         {
             internalFieldName = siteColumns.AddLookup(fieldName, lookupList.ID, web.ID, required);
         }
         else
         {
             internalFieldName = siteColumns.AddLookup(fieldName, lookupList.ID, required);
         }
         looupField = siteColumns.GetFieldByInternalName(internalFieldName);
     }
     return looupField as SPFieldLookup;
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:21,代码来源:FieldOperations.cs

示例2: AddListToPage

        public XsltListViewWebPart AddListToPage(SPList list, string title, string zone, SPLimitedWebPartManager webPartManager, int index)
        {
            // validation
            list.RequireNotNull("list");
            title.RequireNotNullOrEmpty("title");
            zone.RequireNotNullOrEmpty("zone");
            webPartManager.RequireNotNull("webPartManager");
            index.Require(index >= 0, "index");

            XsltListViewWebPart wp = new XsltListViewWebPart();
            wp.ListName = list.ID.ToString("B").ToUpper();
            wp.Title = title;
            wp.ZoneID = zone;
            ModifyViewClass viewOperations = new ModifyViewClass();
            SPView defaultView = viewOperations.GetDefaultView(list);
            SPView modifiedView = viewOperations.CopyView(defaultView, list);
            viewOperations.SetToolbarType(modifiedView, "Standard");
            modifiedView.Update();
            wp.ViewGuid = modifiedView.ID.ToString("B").ToUpper();
            webPartManager.AddWebPart(wp, zone, index);
            list.Update();
            webPartManager.SaveChanges(wp);
            return wp;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:24,代码来源:WebPartOperations.cs

示例3: GetDefaultView

        public static SPView GetDefaultView(SPList list)
        {
            list.RequireNotNull("list");

            SPView listView = (from SPView v in list.Views
                               where v.DefaultView == true
                               select v).First();

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

示例4: 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

示例5: CreatePage

 public static SPFile CreatePage(SPList list, string fileName, SPTemplateFileType fileType)
 {
     list.RequireNotNull("list");
     fileName.RequireNotNullOrEmpty("fileName");
     return list.RootFolder.Files.Add(string.Format("{0}/{1}", list.RootFolder.ServerRelativeUrl, fileName), fileType);
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:6,代码来源:SharePointUtilities.cs

示例6: 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

示例7: ChangeTitleDisplayName

        public static void ChangeTitleDisplayName(SPList list, string newTitle)
        {
            list.RequireNotNull("list");
            newTitle.RequireNotNullOrEmpty("newTitle");

            SPField titleField = list.Fields.TryGetFieldByStaticName("Title");
            if (null != titleField)
            {
                titleField.Title = newTitle;
                titleField.Update();
            }
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:12,代码来源:SharePointUtilities.cs

示例8: AddWorkflow

        /// <summary>
        /// AddWorkflow with 
        /// </summary>
        /// <param name="web"></param>
        /// <param name="contentType"></param>
        /// <param name="tasks"></param>
        /// <param name="workflowHistory"></param>
        /// <param name="workflowTemplateName"></param>
        /// <param name="workflowName"></param>
        /// <param name="associationData"></param>
        public static void AddWorkflow(SPWeb web, SPContentType contentType, SPList tasks, SPList workflowHistory, string workflowTemplateName, string workflowName, object associationData)
        {
            // Validation
            web.RequireNotNull("web");
            contentType.RequireNotNull("list");
            tasks.RequireNotNull("tasks");
            workflowHistory.RequireNotNull("workflowHistory");
            workflowTemplateName.RequireNotNullOrEmpty("workflowTemplateName");
            workflowName.RequireNotNull("workflowName");
            associationData.RequireNotNull("associationData");

            SPWorkflowTemplate workflowtemplate = SharePointUtilities.GetWorkflowByName(web, workflowTemplateName);
            SPWorkflowAssociation association = SPWorkflowAssociation.CreateWebContentTypeAssociation(workflowtemplate, workflowName, tasks.Title, workflowHistory.Title);
            association.AutoStartCreate = true;
            association.AutoStartChange = true;
            association.AllowManual = true;
            XmlSerializer serializer = new XmlSerializer(associationData.GetType());
            using (MemoryStream stream = new MemoryStream())
            {
                serializer.Serialize(stream, associationData);
                stream.Position = 0;
                byte[] bytes = new byte[stream.Length];
                stream.Read(bytes, 0, bytes.Length);
                association.AssociationData = Encoding.UTF8.GetString(bytes);
            }
            if (null == contentType.WorkflowAssociations.GetAssociationByName(association.Name, web.UICulture))
            {
                contentType.WorkflowAssociations.Add(association);
            }

            contentType.UpdateWorkflowAssociationsOnChildren(true,  // Do not generate full change list
                                                                 true,   // Push down to derived content types
                                                                 true,   // Push down to list content types
                                                                 false); // Do not throw exception if sealed or readonly
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:45,代码来源:SharePointUtilities.cs

示例9: WriteMessage

 /// <summary>
 /// Writes messages of 255 characters or less
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="list">The list.</param>
 private void WriteMessage(string message, SPList list)
 {
     message.RequireNotNullOrEmpty("message");
     list.RequireNotNull("list");
     message.Require(message.Length <= 255, "message");
     SPListItem item = list.AddItem();
     item["Title"] = message;
     item.Update();
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:14,代码来源:ListLogger.cs

示例10: AddListToPage

        public static void AddListToPage(SPList list, string title, string zone, SPLimitedWebPartManager webPartManager, int index, string viewName)
        {
            // validation
            list.RequireNotNull("list");
            title.RequireNotNullOrEmpty("title");
            webPartManager.RequireNotNull("webPartManager");
            viewName.RequireNotNullOrEmpty("viewName");

            ListViewWebPart wp = new ListViewWebPart();
            wp.ListName = list.ID.ToString("B").ToUpper();
            wp.ViewGuid = list.Views[viewName].ID.ToString("B").ToUpper();
            wp.Title = title;
            wp.ZoneID = zone;
            webPartManager.AddWebPart(wp, zone, index);
            list.Update();
            webPartManager.SaveChanges(wp);
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:17,代码来源:SharePointUtilities.cs

示例11: AddFieldToList

        public static void AddFieldToList(SPList list, IEnumerable<SPField> fields)
        {
            list.RequireNotNull("list");
            fields.RequireNotNull("field");

            foreach (SPField field in fields)
            {
                if (null != field && !list.Fields.Contains(field.Id))
                {
                    list.Fields.Add(field);
                }
            }

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

示例12: MakeDefaultContentType

        public static void MakeDefaultContentType(SPList list, SPContentType contentType)
        {
            //Validation
            list.RequireNotNull("list");
            contentType.RequireNotNull("contentType");

            SPContentType existingContentType = list.ContentTypes[contentType.Name];
            if (null == existingContentType)
            {
                list.ContentTypes.Add(contentType);
                list.Update();
            }

            List<SPContentType> cts = new List<SPContentType>();

            foreach (SPContentType item in list.ContentTypes)
            {
                if (item.Name.Equals(contentType.Name))
                {
                    cts.Add(item);
                }
            }
            list.RootFolder.UniqueContentTypeOrder = cts;
            list.RootFolder.Update();
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:25,代码来源:SharePointUtilities.cs

示例13: ModifyView

        public static void ModifyView(SPList list, IEnumerable<string> ViewFields, string query)
        {
            // Validation
            list.RequireNotNull("list");

            ViewFields.RequireNotNull("ViewFields");

            if (ViewFields.Count() == 0)
            {
                throw new ArgumentException("ViewFields");
            }

            query.RequireNotNullOrEmpty("query");

            SPView listView = (from SPView v in list.Views
                               where v.DefaultView == true
                               select v).First();
            listView.Query = query;

            listView.ViewFields.DeleteAll();
            foreach (string fieldName in ViewFields)
            {
                listView.ViewFields.Add(fieldName);
            }
            listView.Update();
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:26,代码来源:SharePointUtilities.cs

示例14: WriteLongMessage

        /// <summary>
        /// Writes messages longer than 255 characters
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="list">The list.</param>
        private void WriteLongMessage(string message, SPList list)
        {
            message.RequireNotNullOrEmpty("message");
            list.RequireNotNull("list");
            if (message.Length <= 255)
            {
                WriteMessage(message, list);
            }

            else
            {
                for (int i = 0; i < message.Length; i += 255)
                {
                    int length = Math.Min(message.Length - i, 255);
                    WriteMessage(message.Substring(i, length), list);
                }
            }
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:23,代码来源:ListLogger.cs


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