本文整理汇总了C#中SPMeta2.CSOM.ModelHosts.ListItemModelHost类的典型用法代码示例。如果您正苦于以下问题:C# ListItemModelHost类的具体用法?C# ListItemModelHost怎么用?C# ListItemModelHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListItemModelHost类属于SPMeta2.CSOM.ModelHosts命名空间,在下文中一共展示了ListItemModelHost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var definition = webPartModel.WithAssertAndCast<PageViewerWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions
.LoadWebpartXmlDocument(BuiltInWebPartTemplates.PageViewerWebPart);
if (!string.IsNullOrEmpty(definition.ContentLink))
{
var contentLinkValue = definition.ContentLink ?? string.Empty;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Original contentLinkValue: [{0}]", contentLinkValue);
contentLinkValue = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
{
Value = contentLinkValue,
Context = listItemModelHost
}).Value;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced contentLinkValue: [{0}]", contentLinkValue);
wpXml.SetOrUpdatePageViewerWebPartProperty("ContentLink", contentLinkValue);
}
if (!string.IsNullOrEmpty(definition.SourceType))
{
wpXml.SetOrUpdatePageViewerWebPartProperty("SourceType", definition.SourceType);
}
return wpXml.ToString();
}
示例2: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var typedModel = webPartModel.WithAssertAndCast<ContentEditorWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions.LoadWebpartXmlDocument(BuiltInWebPartTemplates.ContentEditorWebPart);
if (!string.IsNullOrEmpty(typedModel.Content))
wpXml.SetOrUpdateContentEditorWebPartProperty("Content", typedModel.Content, true);
if (!string.IsNullOrEmpty(typedModel.ContentLink))
{
var urlValue = typedModel.ContentLink ?? string.Empty;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Original value: [{0}]", urlValue);
urlValue = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
{
Value = urlValue,
Context = listItemModelHost.HostClientContext
}).Value;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced value: [{0}]", urlValue);
wpXml.SetOrUpdateContentEditorWebPartProperty("ContentLink", urlValue);
}
return wpXml.ToString();
}
示例3: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(
ListItemModelHost listItemModelHost,
WebPartDefinitionBase webPartModel)
{
var typedDefinition = webPartModel.WithAssertAndCast<SilverlightWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions.LoadWebpartXmlDocument(this.ProcessCommonWebpartProperties(BuiltInWebPartTemplates.SilverlightWebPart, webPartModel));
if (!string.IsNullOrEmpty(typedDefinition.Url))
{
var linkValue = typedDefinition.Url;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Original Url: [{0}]", linkValue);
linkValue = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
{
Value = linkValue,
Context = listItemModelHost.HostClientContext
}).Value;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced Url: [{0}]", linkValue);
wpXml.SetOrUpdateProperty("Url", linkValue);
}
if (!string.IsNullOrEmpty(typedDefinition.CustomInitParameters))
{
wpXml.SetOrUpdateProperty("CustomInitParameters", typedDefinition.CustomInitParameters);
}
return wpXml.ToString();
}
示例4: GetCurrentPageFile
protected File GetCurrentPageFile(ListItemModelHost listItemModelHost)
{
if (listItemModelHost.HostFile != null)
return listItemModelHost.HostFile;
return listItemModelHost.HostListItem.File;
}
示例5: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
if (!listItemModelHost.HostWeb.IsObjectPropertyInstantiated("Id"))
{
var webContext = listItemModelHost.HostWeb.Context;
webContext.Load(listItemModelHost.HostWeb, w => w.Id);
webContext.ExecuteQueryWithTrace();
}
var webId = listItemModelHost.HostWeb.Id.ToString();
var wpModel = webPartModel.WithAssertAndCast<ClientWebPartDefinition>("model", value => value.RequireNotNull());
// Enhance 'ClientWebPart' provision - ProductWebId should be current web by default #623
// https://github.com/SubPointSolutions/spmeta2/issues/623
var productId = wpModel.ProductId;
if (!productId.HasGuidValue())
productId = listItemModelHost.HostWeb.Id;
var wpXml = WebpartXmlExtensions
.LoadWebpartXmlDocument(BuiltInWebPartTemplates.ClientWebPart)
.SetOrUpdateProperty("FeatureId", wpModel.FeatureId.ToString())
.SetOrUpdateProperty("ProductId", productId.ToString())
.SetOrUpdateProperty("WebPartName", wpModel.WebPartName)
.SetOrUpdateProperty("ProductWebId", webId)
.ToString();
return wpXml;
}
示例6: OnBeforeDeploy
protected override void OnBeforeDeploy(ListItemModelHost host, WebPartDefinitionBase webpart)
{
base.OnBeforeDeploy(host, webpart);
// pre-load web id
if (!host.HostWeb.IsPropertyAvailable("Id"))
{
host.HostWeb.Context.Load(host.HostWeb, w => w.Id);
host.HostWeb.Context.ExecuteQueryWithTrace();
}
var context = host.HostClientContext;
var wpModel = webpart.WithAssertAndCast<ListViewWebPartDefinition>("model", value => value.RequireNotNull());
// save the old default view ID, then restore in OnAfterDeploy
_currentListBindContext = XsltListViewWebPartModelHandler.LookupBindContext(host,
wpModel.WebUrl, wpModel.WebId,
wpModel.ListUrl, wpModel.ListTitle, wpModel.ListId,
wpModel.ViewName, wpModel.ViewId,
wpModel.TitleUrl);
if (_currentListBindContext.TargetView != null)
{
_currentListBindContext.TargetView.DefaultView = true;
_currentListBindContext.TargetView.Update();
context.ExecuteQueryWithTrace();
}
}
示例7: LookupList
private List LookupList(ListItemModelHost listItemModelHost, ListViewWebPartDefinition wpModel)
{
var web = listItemModelHost.HostWeb;
var context = listItemModelHost.HostWeb.Context;
List list = null;
if (!string.IsNullOrEmpty(wpModel.ListUrl))
{
list = web.QueryAndGetListByUrl(wpModel.ListUrl);
}
else if (!string.IsNullOrEmpty(wpModel.ListTitle))
{
list = web.Lists.GetByTitle(wpModel.ListTitle);
}
else if (wpModel.ListId != default(Guid))
{
list = web.Lists.GetById(wpModel.ListId.Value);
}
else
{
throw new SPMeta2Exception("ListUrl, ListTitle or ListId should be defined.");
}
return list;
}
示例8: LookupBindContext
internal static ListBindContext LookupBindContext(ListItemModelHost listItemModelHost,
XsltListViewWebPartDefinition wpModel)
{
return LookupBindContext(listItemModelHost,
wpModel.WebUrl, wpModel.WebId,
wpModel.ListUrl, wpModel.ListTitle, wpModel.ListId,
wpModel.ViewName, wpModel.ViewId,
wpModel.TitleUrl);
}
示例9: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var wpModel = webPartModel.WithAssertAndCast<SiteFeedWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions
.LoadWebpartXmlDocument(BuiltInWebPartTemplates.SiteFeedWebPart)
.ToString();
return wpXml;
}
示例10: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var typedModel = webPartModel.WithAssertAndCast<PictureLibrarySlideshowWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions.LoadWebpartXmlDocument(BuiltInWebPartTemplates.PictureLibrarySlideshowWebPart);
// TODO, specific XML processing
return wpXml.ToString();
}
示例11: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var wpModel = webPartModel.WithAssertAndCast<MyMembershipWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions
.LoadWebpartXmlDocument(BuiltInWebPartTemplates.MyMembershipWebPart);
// TODO, process XML
return wpXml.ToString();
}
示例12: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var wpModel = webPartModel.WithAssertAndCast<ScriptEditorWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions
.LoadWebpartXmlDocument(BuiltInWebPartTemplates.ScriptEditorWebPart)
//.SetOrUpdateProperty("Content", HttpUtility.HtmlEncode(wpModel.Content))
.SetOrUpdateProperty("Content", wpModel.Content, true)
.ToString();
return wpXml;
}
示例13: LookupBindContext
private ListBindContext LookupBindContext(ListItemModelHost listItemModelHost, XsltListViewWebPartDefinition wpModel)
{
var result = new ListBindContext
{
};
var web = listItemModelHost.HostWeb;
var context = listItemModelHost.HostWeb.Context;
var list = LookupList(listItemModelHost, wpModel);
View view = null;
if (wpModel.ViewId.HasValue && wpModel.ViewId != default(Guid))
view = list.Views.GetById(wpModel.ViewId.Value);
else if (!string.IsNullOrEmpty(wpModel.ViewName))
view = list.Views.GetByTitle(wpModel.ViewName);
context.Load(list, l => l.Id);
context.Load(list, l => l.DefaultViewUrl);
context.Load(list, l => l.Title);
context.Load(list, l => l.DefaultView);
if (view != null)
{
context.Load(view);
context.ExecuteQueryWithTrace();
result.OriginalView = list.DefaultView;
result.OriginalViewId = list.DefaultView.Id;
result.TargetView = view;
result.TargetViewId = view.Id;
result.TitleUrl = view.ServerRelativeUrl;
}
else
{
context.ExecuteQueryWithTrace();
}
result.ListId = list.Id;
if (wpModel.TitleUrl == null)
{
if (string.IsNullOrEmpty(result.TitleUrl))
result.TitleUrl = list.DefaultViewUrl;
}
return result;
}
示例14: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
var definition = webPartModel.WithAssertAndCast<RefinementScriptWebPartDefinition>("model", value => value.RequireNotNull());
var xml = WebpartXmlExtensions.LoadWebpartXmlDocument(ProcessCommonWebpartProperties(BuiltInWebPartTemplates.RefinementScriptWebPart, webPartModel));
if (!string.IsNullOrEmpty(definition.SelectedRefinementControlsJson))
xml.SetOrUpdateProperty("SelectedRefinementControlsJson", definition.SelectedRefinementControlsJson);
if (!string.IsNullOrEmpty(definition.EmptyMessage))
xml.SetOrUpdateProperty("EmptyMessage", definition.EmptyMessage);
return xml.ToString();
}
示例15: GetWebpartXmlDefinition
protected override string GetWebpartXmlDefinition(ListItemModelHost listItemModelHost, WebPartDefinitionBase webPartModel)
{
throw new SPMeta2NotSupportedException("UserCode web part provision is not supported by CSOM (SP API limitations) - https://officespdev.uservoice.com/forums/224641-general/suggestions/7300326-add-support-for-spusercodewebpart-import-via-limit");
var wpModel = webPartModel.WithAssertAndCast<UserCodeWebPartDefinition>("model", value => value.RequireNotNull());
var wpXml = WebpartXmlExtensions
.LoadWebpartXmlDocument(BuiltInWebPartTemplates.UserCodeWebPart)
.SetOrUpdateMetadataPropertyAttribute("type", "name", wpModel.AssemblyFullName)
.SetOrUpdateMetadataPropertyAttribute("Solution", "SolutionId", wpModel.SolutionId.ToString("D"))
//.SetOrUpdateMetadataPropertyAttribute("Solution", "xmlns", "http://schemas.microsoft.com/sharepoint/")
.ToString();
return wpXml;
}