本文整理汇总了C#中umbraco.cms.businesslogic.template.Template.OnNew方法的典型用法代码示例。如果您正苦于以下问题:C# Template.OnNew方法的具体用法?C# Template.OnNew怎么用?C# Template.OnNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.template.Template
的用法示例。
在下文中一共展示了Template.OnNew方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeNew
public static Template MakeNew(string Name, BusinessLogic.User u)
{
//ensure unique alias
if (GetByAlias(Name) != null)
Name = EnsureUniqueAlias(Name, 1);
// CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
CMSNode n = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Name, Guid.NewGuid());
Name = Name.Replace("/", ".").Replace("\\", "");
if (Name.Length > 100)
Name = Name.Substring(0, 95) + "...";
SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
SqlHelper.CreateParameter("@nodeId", n.Id),
SqlHelper.CreateParameter("@alias", Name),
SqlHelper.CreateParameter("@design", ' '),
SqlHelper.CreateParameter("@master", DBNull.Value));
Template t = new Template(n.Id);
NewEventArgs e = new NewEventArgs();
t.OnNew(e);
return t;
}
示例2: MakeNew
private static Template MakeNew(string name, BusinessLogic.User u, Template master, string design)
{
// CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
CMSNode n = CMSNode.MakeNew(-1, _objectType, u.Id, 1, name, Guid.NewGuid());
//ensure unique alias
name = helpers.Casing.SafeAlias(name);
if (GetByAlias(name) != null)
name = EnsureUniqueAlias(name, 1);
name = name.Replace("/", ".").Replace("\\", "");
if (name.Length > 100)
name = name.Substring(0, 95) + "...";
SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
SqlHelper.CreateParameter("@nodeId", n.Id),
SqlHelper.CreateParameter("@alias", name),
SqlHelper.CreateParameter("@design", ' '),
SqlHelper.CreateParameter("@master", DBNull.Value));
Template t = new Template(n.Id);
NewEventArgs e = new NewEventArgs();
t.OnNew(e);
if (master != null)
t.MasterTemplate = master.Id;
switch (DetermineRenderingEngine(t, design))
{
case RenderingEngine.Mvc:
ViewHelper.CreateViewFile(t);
break;
case RenderingEngine.WebForms:
MasterPageHelper.CreateMasterPage(t);
break;
}
//if a design is supplied ensure it is updated.
if (!design.IsNullOrWhiteSpace())
{
t.ImportDesign(design);
}
return t;
}