本文整理汇总了C#中Web.GetCurrentComposedLook方法的典型用法代码示例。如果您正苦于以下问题:C# Web.GetCurrentComposedLook方法的具体用法?C# Web.GetCurrentComposedLook怎么用?C# Web.GetCurrentComposedLook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web.GetCurrentComposedLook方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractObjects
public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
// Load object if not there
#if !CLIENTSDKV15
web.EnsureProperties(w => w.Url, w => w.MasterUrl, w => w.AlternateCssUrl, w => w.SiteLogoUrl);
#else
web.EnsureProperties(w => w.Url, w => w.MasterUrl);
#endif
// Information coming from the site
template.ComposedLook.MasterPage = Tokenize(web.MasterUrl, web.Url);
#if !CLIENTSDKV15
template.ComposedLook.AlternateCSS = Tokenize(web.AlternateCssUrl, web.Url);
template.ComposedLook.SiteLogo = Tokenize(web.SiteLogoUrl, web.Url);
#else
template.ComposedLook.AlternateCSS = null;
template.ComposedLook.SiteLogo = null;
#endif
scope.LogInfo(CoreResources.Provisioning_ObjectHandlers_ComposedLooks_ExtractObjects_Retrieving_current_composed_look);
var theme = web.GetCurrentComposedLook();
if (theme != null)
{
if (creationInfo != null)
{
// Don't exclude the DesignPreviewThemedCssFolderUrl property bag, if any
creationInfo.PropertyBagPropertiesToPreserve.Add("DesignPreviewThemedCssFolderUrl");
}
template.ComposedLook.Name = theme.Name;
if (theme.IsCustomComposedLook)
{
if (creationInfo != null && creationInfo.PersistComposedLookFiles && creationInfo.FileConnector != null)
{
Site site = (web.Context as ClientContext).Site;
if (!site.IsObjectPropertyInstantiated("Url"))
{
web.Context.Load(site);
web.Context.ExecuteQueryRetry();
}
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ComposedLooks_ExtractObjects_Creating_SharePointConnector);
// Let's create a SharePoint connector since our files anyhow are in SharePoint at this moment
SharePointConnector spConnector = new SharePointConnector(web.Context, web.Url, "dummy");
// to get files from theme catalog we need a connector linked to the root site
SharePointConnector spConnectorRoot;
if (!site.Url.Equals(web.Url, StringComparison.InvariantCultureIgnoreCase))
{
spConnectorRoot = new SharePointConnector(web.Context.Clone(site.Url), site.Url, "dummy");
}
else
{
spConnectorRoot = spConnector;
}
// Download the theme/branding specific files
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.AlternateCssUrl, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.SiteLogoUrl, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.BackgroundImage, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Theme, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Font, scope);
}
template.ComposedLook.BackgroundFile = FixFileUrl(Tokenize(theme.BackgroundImage, web.Url));
template.ComposedLook.ColorFile = FixFileUrl(Tokenize(theme.Theme, web.Url));
template.ComposedLook.FontFile = FixFileUrl(Tokenize(theme.Font, web.Url));
// Create file entries for the custom theme files
if (!string.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.BackgroundFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.ColorFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.ColorFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.FontFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.FontFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.SiteLogo))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.SiteLogo));
}
// If a base template is specified then use that one to "cleanup" the generated template model
if (creationInfo != null && creationInfo.BaseTemplate != null)
{
template = CleanupEntities(template, creationInfo.BaseTemplate);
}
}
else
{
template.ComposedLook.BackgroundFile = "";
template.ComposedLook.ColorFile = "";
//.........这里部分代码省略.........
示例2: DetectComposedLook
private ProvisioningTemplate DetectComposedLook(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo, PnPMonitoredScope scope, SharePointConnector spConnector, SharePointConnector spConnectorRoot)
{
var theme = web.GetCurrentComposedLook();
if (theme != null)
{
if (creationInfo != null)
{
// Don't exclude the DesignPreviewThemedCssFolderUrl property bag, if any
creationInfo.PropertyBagPropertiesToPreserve.Add("DesignPreviewThemedCssFolderUrl");
}
template.ComposedLook.Name = theme.Name;
if (theme.IsCustomComposedLook)
{
if (creationInfo != null && creationInfo.PersistComposedLookFiles && creationInfo.FileConnector != null)
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ComposedLooks_ExtractObjects_Creating_SharePointConnector);
// Let's create a SharePoint connector since our files anyhow are in SharePoint at this moment
// Download the theme/branding specific files
#if !CLIENTSDKV15
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.AlternateCssUrl, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.SiteLogoUrl, scope);
#endif
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.BackgroundImage, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Theme, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Font, scope);
}
template.ComposedLook.BackgroundFile = FixFileUrl(Tokenize(theme.BackgroundImage, web.Url));
template.ComposedLook.ColorFile = FixFileUrl(Tokenize(theme.Theme, web.Url));
template.ComposedLook.FontFile = FixFileUrl(Tokenize(theme.Font, web.Url));
// Create file entries for the custom theme files
if (!string.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.BackgroundFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.ColorFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.ColorFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.FontFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.FontFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.SiteLogo))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.SiteLogo));
}
// If a base template is specified then use that one to "cleanup" the generated template model
if (creationInfo != null && creationInfo.BaseTemplate != null)
{
template = CleanupEntities(template, creationInfo.BaseTemplate);
}
}
else
{
template.ComposedLook.BackgroundFile = "";
template.ComposedLook.ColorFile = "";
template.ComposedLook.FontFile = "";
}
}
else
{
template.ComposedLook = null;
}
return template;
}
示例3: CreateEntities
public override ProvisioningTemplate CreateEntities(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
// Load object if not there
bool executeQueryNeeded = false;
if (!web.IsObjectPropertyInstantiated("AlternateCssUrl"))
{
web.Context.Load(web);
executeQueryNeeded = true;
}
if (!web.IsObjectPropertyInstantiated("Url"))
{
web.Context.Load(web);
executeQueryNeeded = true;
}
if (executeQueryNeeded)
{
web.Context.ExecuteQuery();
}
// Information coming from the site
template.ComposedLook.AlternateCSS = Tokenize(web.AlternateCssUrl, web.Url);
template.ComposedLook.MasterPage = Tokenize(web.MasterUrl, web.Url);
template.ComposedLook.SiteLogo = Tokenize(web.SiteLogoUrl, web.Url);
var theme = web.GetCurrentComposedLook();
if (theme != null)
{
template.ComposedLook.Name = theme.Name;
if (theme.IsCustomComposedLook)
{
if (creationInfo.PersistComposedLookFiles && creationInfo.FileConnector != null)
{
Site site = (web.Context as ClientContext).Site;
if (!site.IsObjectPropertyInstantiated("Url"))
{
web.Context.Load(site);
web.Context.ExecuteQueryRetry();
}
// Let's create a SharePoint connector since our files anyhow are in SharePoint at this moment
SharePointConnector spConnector = new SharePointConnector(web.Context, web.Url, "dummy");
// to get files from theme catalog we need a connector linked to the root site
SharePointConnector spConnectorRoot;
if (!site.Url.Equals(web.Url, StringComparison.InvariantCultureIgnoreCase))
{
spConnectorRoot = new SharePointConnector(web.Context.Clone(site.Url), site.Url, "dummy");
}
else
{
spConnectorRoot = spConnector;
}
// Download the theme/branding specific files
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.AlternateCssUrl);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.SiteLogoUrl);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.BackgroundImage);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Theme);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Font);
}
template.ComposedLook.BackgroundFile = Tokenize(theme.BackgroundImage, web.Url);
template.ComposedLook.ColorFile = Tokenize(theme.Theme, web.Url);
template.ComposedLook.FontFile = Tokenize(theme.Font, web.Url);
// Create file entries for the custom theme files
if (!string.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.BackgroundFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.ColorFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.ColorFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.FontFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.FontFile));
}
if (!string.IsNullOrEmpty(template.ComposedLook.SiteLogo))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.SiteLogo));
}
// If a base template is specified then use that one to "cleanup" the generated template model
if (creationInfo.BaseTemplate != null)
{
template = CleanupEntities(template, creationInfo.BaseTemplate);
}
}
else
{
template.ComposedLook.BackgroundFile = "";
template.ComposedLook.ColorFile = "";
template.ComposedLook.FontFile = "";
}
}
else
//.........这里部分代码省略.........
示例4: DetectComposedLook
private ProvisioningTemplate DetectComposedLook(Web web, ProvisioningTemplate template, TokenParser parser,
ProvisioningTemplateCreationInformation creationInfo,
PnPMonitoredScope scope, SharePointConnector spConnector,
SharePointConnector spConnectorRoot)
{
var theme = web.GetCurrentComposedLook();
if (theme != null)
{
if (creationInfo != null)
{
// Don't exclude the DesignPreviewThemedCssFolderUrl property bag, if any
creationInfo.PropertyBagPropertiesToPreserve.Add("DesignPreviewThemedCssFolderUrl");
}
template.ComposedLook.Name = theme.Name;
if (theme.IsCustomComposedLook)
{
// Set the URL pointers to files
template.ComposedLook.BackgroundFile = FixFileUrl(TokenizeUrl(theme.BackgroundImage, parser));
template.ComposedLook.ColorFile = FixFileUrl(TokenizeUrl(theme.Theme, parser));
template.ComposedLook.FontFile = FixFileUrl(TokenizeUrl(theme.Font, parser));
// Download files if this is root site, since theme files are only stored there
if (!web.IsSubSite() && creationInfo != null &&
creationInfo.PersistBrandingFiles && creationInfo.FileConnector != null)
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ComposedLooks_ExtractObjects_Creating_SharePointConnector);
// Let's create a SharePoint connector since our files anyhow are in SharePoint at this moment
// Download the theme/branding specific files
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web, theme.BackgroundImage, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web, theme.Theme, scope);
DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web, theme.Font, scope);
}
// Create file entries for the custom theme files, but only if it's a root site
// If it's root site we do not extract or set theme files, since those are in the root of the site collection
if (!web.IsSubSite())
{
if (!string.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.BackgroundFile, template.Connector));
}
if (!string.IsNullOrEmpty(template.ComposedLook.ColorFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.ColorFile, template.Connector));
}
if (!string.IsNullOrEmpty(template.ComposedLook.FontFile))
{
template.Files.Add(GetComposedLookFile(template.ComposedLook.FontFile, template.Connector));
}
}
// If a base template is specified then use that one to "cleanup" the generated template model
if (creationInfo != null && creationInfo.BaseTemplate != null)
{
template = CleanupEntities(template, creationInfo.BaseTemplate);
}
}
else
{
template.ComposedLook.BackgroundFile = "";
template.ComposedLook.ColorFile = "";
template.ComposedLook.FontFile = "";
}
}
else
{
template.ComposedLook = null;
}
return template;
}