本文整理汇总了C#中Schema.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.Save方法的具体用法?C# Schema.Save怎么用?C# Schema.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema.Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTemplateBuildingBlockSave
private static void OnTemplateBuildingBlockSave(TemplateBuildingBlock subject, SaveEventArgs e, EventPhases phase)
{
if (!subject.IsAssemblyTemplateBuildingBlock())
return;
using (var session = subject.Session)
{
var templatingAssembly = new TemplatingAssembly(subject);
foreach (var embeddedParameterSchema in templatingAssembly.EmbeddedParameterSchemas)
{
if (session.IsExistingObject(String.Concat(subject.OrganizationalItem.WebDavUrl, "/", embeddedParameterSchema.Title, ".xsd")))
continue;
var parameterSchema = new Schema(session, subject.OrganizationalItem.Id)
{
Title = embeddedParameterSchema.Title,
Description = embeddedParameterSchema.Title,
Purpose = SchemaPurpose.TemplateParameters,
RootElementName = "Parameters",
Xsd = embeddedParameterSchema.Xsd
};
parameterSchema.Save(true);
}
foreach (var cSharpTemplateBuildingBlock in templatingAssembly.CSharpTemplateBuildingBlocks)
{
//If a TBB already exists
if (session.IsExistingObject(String.Concat(subject.OrganizationalItem.WebDavUrl, "/", cSharpTemplateBuildingBlock.Title, ".tbbcs")))
continue;
//Create a new C# TBB
var templateBuildingBlock = new TemplateBuildingBlock(session, subject.OrganizationalItem.Id)
{
Title = cSharpTemplateBuildingBlock.Title,
TemplateType = TemplateTypes.CSharpTemplate,
Content = String.Format(CSharpTemplateBuildingBlockContent, templatingAssembly.Id, cSharpTemplateBuildingBlock.ClassName)
};
if (cSharpTemplateBuildingBlock.ParameterSchema != null)
{
if (cSharpTemplateBuildingBlock.ParameterSchema.ToLower().StartsWith("/webdav/") || cSharpTemplateBuildingBlock.ParameterSchema.ToLower().StartsWith("tcm:"))
{
var parameterSchema = (Schema) session.GetObject(cSharpTemplateBuildingBlock.ParameterSchema);
templateBuildingBlock.ParameterSchema = parameterSchema;
}
else if (cSharpTemplateBuildingBlock.ParameterSchema.ToLower().StartsWith("resource:"))
{
var parameterSchemaUrl = String.Concat(subject.OrganizationalItem.WebDavUrl, "/", Regex.Match(cSharpTemplateBuildingBlock.ParameterSchema, @"[\w ]*(?=\.xsd$)").Value, ".xsd");
var parameterSchema = (Schema)session.GetObject(parameterSchemaUrl);
templateBuildingBlock.ParameterSchema = parameterSchema;
}
}
templateBuildingBlock.Save(true);
}
}
}