本文整理汇总了C#中SPMeta2.Definitions.WebPartDefinition类的典型用法代码示例。如果您正苦于以下问题:C# WebPartDefinition类的具体用法?C# WebPartDefinition怎么用?C# WebPartDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebPartDefinition类属于SPMeta2.Definitions命名空间,在下文中一共展示了WebPartDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeployWebPartToPage
public static void DeployWebPartToPage(SPLimitedWebPartManager webPartManager,
WebPartDefinition webpartDefinitions,
Action<WebPart> onUpdating,
Action<WebPart> onUpdated)
{
DeployWebPartToPage(webPartManager, webpartDefinitions, onUpdating, onUpdated, null);
}
示例2: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<PageViewerWebPart>("webpartInstance", value => value.RequireNotNull());
var definition = webpartModel.WithAssertAndCast<PageViewerWebPartDefinition>("webpartModel", value => value.RequireNotNull());
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 = CurrentHost.HostFile.Web
}).Value;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced contentLinkValue: [{0}]", contentLinkValue);
typedWebpart.ContentLink = contentLinkValue;
}
if (!string.IsNullOrEmpty(definition.SourceType))
{
typedWebpart.SourceType = (PathPattern)Enum.Parse(typeof(PathPattern), definition.SourceType);
}
}
示例3: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<SPUserCodeWebPart>("webpartInstance", value => value.RequireNotNull());
var typedModel = webpartModel.WithAssertAndCast<UserCodeWebPartDefinition>("webpartModel", value => value.RequireNotNull());
// TODO
typedWebpart.SolutionId = typedModel.SolutionId;
typedWebpart.AssemblyFullName = typedModel.AssemblyFullName;
typedWebpart.TypeFullName = typedModel.TypeFullName;
foreach (var prop in typedModel.UserCodeProperties)
{
var currentProperty = typedWebpart.Properties
.OfType<SPUserCodeProperty>()
.FirstOrDefault(p => p.Name.ToUpper() == prop.Name.ToUpper());
if (currentProperty == null)
{
currentProperty = new SPUserCodeProperty();
currentProperty.Name = prop.Name;
typedWebpart.Properties.Add(currentProperty);
}
currentProperty.Value = prop.Value;
}
}
示例4: OnBeforeDeployModel
protected override void OnBeforeDeployModel(WebpartPageModelHost host, WebPartDefinition webpartModel)
{
_host = host;
var typedModel = webpartModel.WithAssertAndCast<ClientWebPartDefinition>("webpartModel", value => value.RequireNotNull());
typedModel.WebpartType = typeof(ClientWebPart).AssemblyQualifiedName;
}
示例5: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<SilverlightWebPart>("webpartInstance", value => value.RequireNotNull());
var typedDefinition = webpartModel.WithAssertAndCast<SilverlightWebPartDefinition>("webpartModel", value => value.RequireNotNull());
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 = CurrentHost.HostFile.Web
}).Value;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced Url: [{0}]", linkValue);
typedWebpart.Url = linkValue;
}
if (!string.IsNullOrEmpty(typedDefinition.CustomInitParameters))
{
typedWebpart.CustomInitParameters = typedDefinition.CustomInitParameters;
}
}
示例6: WithExistingWebPart
//protected void WithExistingWebPart(ListItem listItem, WebPartDefinition webPartModel,
// Action<WebPart> action)
//{
// WithExistingWebPart(listItem.File, webPartModel, action);
//}
protected void WithExistingWebPart(File file, WebPartDefinition webPartModel,
Action<WebPart> action)
{
WithExistingWebPart(file, webPartModel, (w, d) =>
{
action(w);
});
}
示例7: WithWithExistingWebPart
protected void WithWithExistingWebPart(ListItem listItem, WebPartDefinition webPartModel,
Action<WebPart> action)
{
WithWithExistingWebPart(listItem, webPartModel, (w, d) =>
{
action(w);
});
}
示例8: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<ContactFieldControl>("webpartInstance", value => value.RequireNotNull());
var typedModel = webpartModel.WithAssertAndCast<ContactFieldControlDefinition>("webpartModel", value => value.RequireNotNull());
}
示例9: WebPartDefinitionTests_WebpartType_NonAssemblyQualifiedName_ShouldFail
public void WebPartDefinitionTests_WebpartType_NonAssemblyQualifiedName_ShouldFail()
{
var type = "Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart, Microsoft.SharePoint.Publishing, Version=16.0.0.0, Culture=neutral";
var def = new WebPartDefinition
{
WebpartType = type
};
}
示例10: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<UserDocsWebPart>("webpartInstance", value => value.RequireNotNull());
var definition = webpartModel.WithAssertAndCast<UserDocsWebPartDefinition>("webpartModel", value => value.RequireNotNull());
// TODO, specific provision
}
示例11: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<ScriptEditorWebPart>("webpartInstance", value => value.RequireNotNull());
var typedModel = webpartModel.WithAssertAndCast<ScriptEditorWebPartDefinition>("webpartModel", value => value.RequireNotNull());
typedWebpart.Content = typedModel.Content ?? string.Empty;
}
示例12: WebPartDefinitionTests_WebpartType_AssemblyQualifiedName_ShouldPass
public void WebPartDefinitionTests_WebpartType_AssemblyQualifiedName_ShouldPass()
{
var type = "Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart, Microsoft.SharePoint.Publishing, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
var def = new WebPartDefinition
{
WebpartType = type
};
Assert.IsTrue(type == def.WebpartType);
}
示例13: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel)
{
base.ProcessWebpartProperties(webpartInstance, webpartModel);
var typedWebpart = webpartInstance.WithAssertAndCast<ClientWebPart>("webpartInstance", value => value.RequireNotNull());
var typedModel = webpartModel.WithAssertAndCast<ClientWebPartDefinition>("webpartModel", value => value.RequireNotNull());
typedWebpart.FeatureId = typedModel.FeatureId;
typedWebpart.ProductId = typedModel.ProductId;
typedWebpart.WebPartName = typedModel.WebPartName;
typedWebpart.ProductWebId = _host.SPLimitedWebPartManager.Web.ID;
}
示例14: ProcessWebpartProperties
protected virtual void ProcessWebpartProperties(WebPart instance, WebPartDefinition definition)
{
if (definition.Width.HasValue)
instance.Width = new Unit(definition.Width.Value);
if (definition.Height.HasValue)
instance.Height = new Unit(definition.Height.Value);
if (!string.IsNullOrEmpty(definition.ChromeState))
instance.ChromeState = (PartChromeState)Enum.Parse(typeof(PartChromeState), definition.ChromeState);
if (!string.IsNullOrEmpty(definition.ChromeType))
{
var chromeType = WebPartChromeTypesConvertService.NormilizeValueToPartChromeTypes(definition.ChromeType);
instance.ChromeType = (PartChromeType)Enum.Parse(typeof(PartChromeType), chromeType);
}
if (!string.IsNullOrEmpty(definition.ImportErrorMessage))
instance.ImportErrorMessage = definition.ImportErrorMessage;
if (!string.IsNullOrEmpty(definition.Description))
instance.Description = definition.Description;
if (!string.IsNullOrEmpty(definition.TitleIconImageUrl))
instance.TitleIconImageUrl = definition.TitleIconImageUrl;
if (!string.IsNullOrEmpty(definition.TitleUrl))
{
var urlValue = definition.TitleUrl ?? string.Empty;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Original value: [{0}]",
urlValue);
urlValue = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
{
Value = urlValue,
Context = CurrentHost.HostFile.Web
}).Value;
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced value: [{0}]", urlValue);
instance.TitleUrl = urlValue;
}
if (!string.IsNullOrEmpty(definition.ExportMode))
instance.ExportMode = (WebPartExportMode)Enum.Parse(typeof(WebPartExportMode), definition.ExportMode);
ProcessWebpartCustomProperties(instance, definition);
ProcessParameterBindings(instance, definition);
}
示例15: ProcessWebpartProperties
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition definition)
{
base.ProcessWebpartProperties(webpartInstance, definition);
var typedWebpart = webpartInstance.WithAssertAndCast<RefinementScriptWebPart>("webpartInstance", value => value.RequireNotNull());
var typedModel = definition.WithAssertAndCast<RefinementScriptWebPartDefinition>("webpartModel", value => value.RequireNotNull());
if (!string.IsNullOrEmpty(typedModel.SelectedRefinementControlsJson))
typedWebpart.SelectedRefinementControlsJson = typedModel.SelectedRefinementControlsJson;
if (!string.IsNullOrEmpty(typedModel.EmptyMessage))
typedWebpart.EmptyMessage = typedModel.EmptyMessage;
}