本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
}
示例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
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
}