当前位置: 首页>>代码示例>>C#>>正文


C# Template.OnNew方法代码示例

本文整理汇总了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;
        }
开发者ID:jracabado,项目名称:justEdit-,代码行数:25,代码来源:Template.cs

示例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;
        }
开发者ID:rickliveshere,项目名称:Umbraco-CMS,代码行数:47,代码来源:Template.cs


注:本文中的umbraco.cms.businesslogic.template.Template.OnNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。