本文整理汇总了C#中Microsoft.EnsureProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.EnsureProperty方法的具体用法?C# Microsoft.EnsureProperty怎么用?C# Microsoft.EnsureProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.EnsureProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFiles
private IEnumerable<Microsoft.SharePoint.Client.File> GetFiles(Microsoft.SharePoint.Client.Folder folder)
{
var files = new List<Microsoft.SharePoint.Client.File>();
folder.EnsureProperty(f => f.Folders);
if (folder.Folders.Any())
{
foreach (var subfolder in folder.Folders)
{
files.AddRange(GetFiles(subfolder));
}
}
var folderFiles = folder.EnsureProperty(f => f.Files);
files.AddRange(folderFiles);
return files;
}
示例2: RetrieveFieldValues
internal Model.File RetrieveFieldValues(Web web, Microsoft.SharePoint.Client.File file, Model.File modelFile)
{
ListItem listItem = null;
try
{
listItem = file.EnsureProperty(f => f.ListItemAllFields);
}
catch { }
if (listItem != null)
{
var list = listItem.ParentList;
var fields = list.Fields;
web.Context.Load(fields, fs => fs.IncludeWithDefaultProperties(f => f.TypeAsString, f => f.InternalName, f => f.Title));
web.Context.ExecuteQueryRetry();
var fieldValues = listItem.FieldValues;
var fieldValuesAsText = listItem.EnsureProperty(li => li.FieldValuesAsText).FieldValues;
var fieldstoExclude = new[] {
"ID",
"GUID",
"Author",
"Editor",
"FileLeafRef",
"FileRef",
"File_x0020_Type",
"Modified_x0020_By",
"Created_x0020_By",
"Created",
"Modified",
"FileDirRef",
"Last_x0020_Modified",
"Created_x0020_Date",
"File_x0020_Size",
"FSObjType",
"IsCheckedoutToLocal",
"ScopeId",
"UniqueId",
"VirusStatus",
"_Level",
"_IsCurrentVersion",
"ItemChildCount",
"FolderChildCount",
"SMLastModifiedDate",
"owshiddenversion",
"_UIVersion",
"_UIVersionString",
"Order",
"WorkflowVersion",
"DocConcurrencyNumber",
"ParentUniqueId",
"CheckedOutUserId",
"SyncClientId",
"CheckedOutTitle",
"SMTotalSize",
"SMTotalFileStreamSize",
"SMTotalFileCount",
"ParentVersionString",
"ParentLeafName",
"SortBehavior",
"StreamHash",
"TaxCatchAll",
"TaxCatchAllLabel",
"_ModerationStatus",
//"HtmlDesignAssociated",
//"HtmlDesignStatusAndPreview",
//"MetaInfo",
};
foreach (var fieldValue in fieldValues.Where(f => !fieldstoExclude.Contains(f.Key)))
{
if (fieldValue.Value != null && !string.IsNullOrEmpty(fieldValue.Value.ToString()))
{
var field = fields.FirstOrDefault(fs => fs.InternalName == fieldValue.Key);
string value = string.Empty;
switch (field.TypeAsString)
{
case "URL":
value = Tokenize(fieldValuesAsText[fieldValue.Key], web.Url);
break;
case "User":
var fieldUserValue = fieldValue.Value as Microsoft.SharePoint.Client.FieldUserValue;
if (fieldUserValue != null)
{
#if !CLIENTSDKV15
value = fieldUserValue.Email;
#else
value = fieldUserValue.LookupValue;
#endif
}
break;
case "LookupMulti":
case "TaxonomyFieldType":
case "TaxonomyFieldTypeMulti":
var internalFieldValue = fieldValue.Value as Microsoft.SharePoint.Client.FieldLookupValue[];
//.........这里部分代码省略.........
示例3: UpdateContentType
private static void UpdateContentType(Web web, Microsoft.SharePoint.Client.ContentType existingContentType, ContentType templateContentType, TokenParser parser, PnPMonitoredScope scope)
{
var isDirty = false;
if (existingContentType.Hidden != templateContentType.Hidden)
{
scope.LogPropertyUpdate("Hidden");
existingContentType.Hidden = templateContentType.Hidden;
isDirty = true;
}
if (existingContentType.ReadOnly != templateContentType.ReadOnly)
{
scope.LogPropertyUpdate("ReadOnly");
existingContentType.ReadOnly = templateContentType.ReadOnly;
isDirty = true;
}
if (existingContentType.Sealed != templateContentType.Sealed)
{
scope.LogPropertyUpdate("Sealed");
existingContentType.Sealed = templateContentType.Sealed;
isDirty = true;
}
if (templateContentType.Description != null && existingContentType.Description != parser.ParseString(templateContentType.Description))
{
scope.LogPropertyUpdate("Description");
existingContentType.Description = parser.ParseString(templateContentType.Description);
isDirty = true;
}
if (templateContentType.DocumentTemplate != null && existingContentType.DocumentTemplate != parser.ParseString(templateContentType.DocumentTemplate))
{
scope.LogPropertyUpdate("DocumentTemplate");
existingContentType.DocumentTemplate = parser.ParseString(templateContentType.DocumentTemplate);
isDirty = true;
}
if (existingContentType.Name != parser.ParseString(templateContentType.Name))
{
scope.LogPropertyUpdate("Name");
existingContentType.Name = parser.ParseString(templateContentType.Name);
isDirty = true;
// CT is being renamed, add an extra token to the tokenparser
parser.AddToken(new ContentTypeIdToken(web, existingContentType.Name, existingContentType.StringId));
}
if (templateContentType.Group != null && existingContentType.Group != parser.ParseString(templateContentType.Group))
{
scope.LogPropertyUpdate("Group");
existingContentType.Group = parser.ParseString(templateContentType.Group);
isDirty = true;
}
if (templateContentType.DisplayFormUrl != null && existingContentType.DisplayFormUrl != parser.ParseString(templateContentType.DisplayFormUrl))
{
scope.LogPropertyUpdate("DisplayFormUrl");
existingContentType.DisplayFormUrl = parser.ParseString(templateContentType.DisplayFormUrl);
isDirty = true;
}
if (templateContentType.EditFormUrl != null && existingContentType.EditFormUrl != parser.ParseString(templateContentType.EditFormUrl))
{
scope.LogPropertyUpdate("EditFormUrl");
existingContentType.EditFormUrl = parser.ParseString(templateContentType.EditFormUrl);
isDirty = true;
}
if (templateContentType.NewFormUrl != null && existingContentType.NewFormUrl != parser.ParseString(templateContentType.NewFormUrl))
{
scope.LogPropertyUpdate("NewFormUrl");
existingContentType.NewFormUrl = parser.ParseString(templateContentType.NewFormUrl);
isDirty = true;
}
#if !CLIENTSDKV15
if (templateContentType.Name.ContainsResourceToken())
{
existingContentType.NameResource.SetUserResourceValue(templateContentType.Name, parser);
isDirty = true;
}
if (templateContentType.Description.ContainsResourceToken())
{
existingContentType.DescriptionResource.SetUserResourceValue(templateContentType.Description, parser);
isDirty = true;
}
#endif
if (isDirty)
{
existingContentType.Update(true);
web.Context.ExecuteQueryRetry();
}
// Delta handling
existingContentType.EnsureProperty(c => c.FieldLinks);
List<Guid> targetIds = existingContentType.FieldLinks.AsEnumerable().Select(c1 => c1.Id).ToList();
List<Guid> sourceIds = templateContentType.FieldRefs.Select(c1 => c1.Id).ToList();
var fieldsNotPresentInTarget = sourceIds.Except(targetIds).ToArray();
if (fieldsNotPresentInTarget.Any())
{
foreach (var fieldId in fieldsNotPresentInTarget)
{
var fieldRef = templateContentType.FieldRefs.Find(fr => fr.Id == fieldId);
var field = web.Fields.GetById(fieldId);
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Adding_field__0__to_content_type, fieldId);
web.AddFieldToContentType(existingContentType, field, fieldRef.Required, fieldRef.Hidden);
}
}
//.........这里部分代码省略.........