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


C# Template类代码示例

本文整理汇总了C#中Template的典型用法代码示例。如果您正苦于以下问题:C# Template类的具体用法?C# Template怎么用?C# Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Template类属于命名空间,在下文中一共展示了Template类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefaultServerGridLayoutOptions

 public DefaultServerGridLayoutOptions(
     ContextualizedHelpers helpers,
     IList<RowType> rows,
     IList<KeyValuePair<string, string>> toolbars,
     Template<LayoutTemplateOptions> layoutTemplate,
     IEnumerable<Template<LayoutTemplateOptions>> subTemplates, 
     IHtmlContent mainContent,
     GridType type,
     string id,
     string prefix,
     GridErrorMessages messages,
     string cssClass,
     string caption,
     Type localizerType
     ) : base(rows, toolbars, layoutTemplate, subTemplates, mainContent)
 {
     this.helpers = helpers;
     Type = type;
     Messages = messages;
     Id = id;
     Prefix = prefix;
     CssClass = cssClass;
     Caption = caption;
     var first = rows.FirstOrDefault();
     MustAddButtonColumn = first.MustAddButtonColumn(helpers, Type== GridType.Batch);
     VisibleColumns = first.VisibleColumns(helpers, Type == GridType.Batch);
     LocalizerType = localizerType;
     Localizer = LocalizerType != null ? helpers.LocalizerFactory.Create(LocalizerType) : null;
 }
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:29,代码来源:DefaultServerGridLayoutOptions.cs

示例2: Create

        public ActionResult Create(Template template)
        {
            var templateToCreate = new Template();
            Mapper.Map(template, templateToCreate);
            templateToCreate.Seminar = SiteService.GetLatestSeminar(Site, true);

            ModelState.Clear();
            templateToCreate.TransferValidationMessagesTo(ModelState);
            if (ModelState.IsValid)
            {
                // inactivate all old templates
                foreach (var t in _templateRepository.Queryable.Where(a => a.NotificationType == templateToCreate.NotificationType))
                {
                    t.IsActive = false;
                    _templateRepository.EnsurePersistent(t);
                }

                _templateRepository.EnsurePersistent(templateToCreate);

                Message = "Template Created Successfully";

                return RedirectToAction("Index");
            }

            var viewModel = TemplateViewModel.Create(Repository, templateToCreate);
            return View(viewModel);
        }
开发者ID:ucdavis,项目名称:Agribusiness,代码行数:27,代码来源:TemplateController.cs

示例3: DefaultServerDetailLayoutOptions

 public DefaultServerDetailLayoutOptions(
     ContextualizedHelpers helpers,
     IList<RowType> rows,
     IList<KeyValuePair<string, string>> toolbars,
     Template<LayoutTemplateOptions> layoutTemplate,
     IEnumerable<Template<LayoutTemplateOptions>> subTemplates,
     IHtmlContent mainContent,
     string id,
     string prefix,
     string cssClass,
     Type localizerType,
     bool editMode,
     string formAction,
     string formMethod,
     bool? antiforgery,
     bool noSubmit=false
     ) : base(rows, toolbars, layoutTemplate, subTemplates, mainContent)
 {
     this.helpers = helpers;
     Id = id;
     Prefix = prefix;
     CssClass = cssClass;
     LocalizerType = localizerType;
     Localizer = LocalizerType != null ? helpers.LocalizerFactory.Create(LocalizerType) : null;
     EditMode = editMode;
     Antiforgery = antiforgery;
     FormAction = formAction;
     FormMethod = formMethod;
     NoSubmit = noSubmit;
 }
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:30,代码来源:DefaultServerDetailLayoutOptions.cs

示例4: SetUp

        public void SetUp()
        {
            var source1 = new TestSource
            {
                Name = "-artist-",
                GetAllItemsFunc = c => new[]
                {
                    new DynamicItem("beatles", new [] { new ContextItem("artist-id", "1") }),
                    new DynamicItem("beach-boys", new [] { new ContextItem("artist-id", "2") })
                }
            };

            var source2 = new TestSource
            {
                Name = "-album-",
                GetAllItemsFunc = c =>
                    {
                        return c.Any(i => i.Name == "artist-id" && i.Value == "1")
                        ? new[] { new DynamicItem("revolver") }
                        : new[] { new DynamicItem("pet-sounds") };
                    }
            };

            var dynamicSourceProvider = MockRepository.GenerateMock<IDynamicSourceProvider>();

            dynamicSourceProvider.Stub(p => p.Get("-artist-")).Return(source1);
            dynamicSourceProvider.Stub(p => p.Get("-album-")).Return(source2);
            var pathInstanceBuilder = new PathInstanceBuilder(dynamicSourceProvider);

            var template = new Template(new[] { "static", "-artist-", "-album-" });
            template.BuildInstancePaths(pathInstanceBuilder);

            this.resource = new TemplateResourceBuilder().Build(template) as TemplateResource;
        }
开发者ID:mr-sandy,项目名称:kola,代码行数:34,代码来源:WhenBuildingATemplateResourceForATemplateWithADynamicPath.cs

示例5: CreateSession

        /// <summary>
        /// Creates a new session for assembling documents using the HotDocs Cloud Services Rest API.
        /// </summary>
        /// <param name="template">The template to use with the session.</param>
        /// <param name="billingRef">This parameter lets you specify information that will be included in usage logs for this call. For example, you can use a string to uniquely identify the end user that initiated the request and/or the context in which the call was made. When you review usage logs, you can then see which end users initiated each request. That information could then be used to pass costs on to those end users if desired.</param>
        /// <param name="answers">The answers to use.</param>
        /// <param name="markedVariables">An array of variable names, whose prompts should be "marked" when displayed in an interview.</param>
        /// <param name="interviewFormat">The format to use when displaying an interview.</param>
        /// <param name="outputFormat">The format to use when assembling a document.</param>
        /// <param name="settings">The settings to use with the session.</param>
        /// <param name="theme">The interview theme.</param>
        /// <param name="showDownloadLinks">Indicates whether or not links for downloading the assembled document(s) should appear at the end of the interview.</param>
        /// <returns></returns>
        public string CreateSession(
			Template template,
			string billingRef = null,
			string answers = null,
			string[] markedVariables = null,
			InterviewFormat interviewFormat = InterviewFormat.JavaScript,
			OutputFormat outputFormat = OutputFormat.Native,
			Dictionary<string, string> settings = null,
			string theme = null,
			bool showDownloadLinks = true
		)
        {
            return (string)TryWithoutAndWithPackage(
                (uploadPackage) => CreateSessionImpl(
                    template,
                    billingRef,
                    answers,
                    markedVariables,
                    interviewFormat,
                    outputFormat,
                    settings,
                    theme,
                    showDownloadLinks,
                    uploadPackage)
            );
        }
开发者ID:MMetodiew,项目名称:hotdocs-open-sdk,代码行数:39,代码来源:RestClientSession.cs

示例6: renders_the_template

        public void renders_the_template()
        {
            var theValue = TemplateValue.For("field", "FirstName");
            var theTemplate = new Template(StringToken.FromKeyString("Test", "{field} is required"), theValue);

            theTemplate.Render().ShouldBe("FirstName is required");
        }
开发者ID:RyanHauert,项目名称:fubumvc,代码行数:7,代码来源:TemplateValueTester.cs

示例7: InvokeTemplateSelected

		public static void InvokeTemplateSelected(TemplateProfile profile, Template oldTemplate)
		{
			if (profile != null && !profile.Deleted && OnTemplateSelected != null)
			{
				OnTemplateSelected(profile, oldTemplate);
			}
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:7,代码来源:PvPTemplates_Events.cs

示例8: CreateWaiting

        public static TemplateGenerationStatusEventArgs CreateWaiting(Template template)
        {
            if (template == null)
                throw new ArgumentNullException("template");

            return new TemplateGenerationStatusEventArgs(template, GenerationStatus.Waiting);
        }
开发者ID:QuantumConcepts,项目名称:CodeGenerator,代码行数:7,代码来源:TemplateGenerationStatusEventArgs.cs

示例9: It_can_include_templates_over_three_levels_with_external_includes

        public void It_can_include_templates_over_three_levels_with_external_includes()
        {
            var baseTemplate = new Template("Base");
            baseTemplate.Load(new StringReader("Base{{>BaseContent}}"));

            var masterTemplate = new Template("Master");
            masterTemplate.Load(new StringReader("{{<BaseContent}}Master{{>MasterContent}}{{/BaseContent}}{{>Base}}"));

            var templates = new Dictionary<string, Template>();
            templates.Add("Base", baseTemplate);
            templates.Add("Master", masterTemplate);

            TemplateLocator locateTemplate =
                name =>
                {
                    Template ret;
                    templates.TryGetValue(name, out ret);
                    if (ret == null) throw new KeyNotFoundException(string.Format("The view '{0}' could not be found.", name));
                    return ret;
                };

            var result = Render.StringToString("{{<MasterContent}}Hello{{/MasterContent}}{{>Master}}", null, locateTemplate);

            Assert.AreEqual("BaseMasterHello", result);
        }
开发者ID:gordonmleigh,项目名称:Nustache,代码行数:25,代码来源:Describe_Template_Render.cs

示例10: GetMessageTemplate

        public virtual Template GetMessageTemplate(bool verbose)
        {
            Template messageST = new Template(GetErrorType().msg);
            messageST.impl.Name = errorType.Name;

            messageST.Add("verbose", verbose);
            object[] args = GetArgs();
            for (int i = 0; i < args.Length; i++)
            {
                string attr = "arg";
                if (i > 0)
                    attr += i + 1;
                messageST.Add(attr, args[i]);
            }
            if (args.Length < 2)
                messageST.Add("arg2", null); // some messages ref arg2

            Exception cause = GetCause();
            if (cause != null)
            {
                messageST.Add("exception", cause);
                messageST.Add("stackTrace", cause.StackTrace);
            }
            else
            {
                messageST.Add("exception", null); // avoid ST error msg
                messageST.Add("stackTrace", null);
            }

            return messageST;
        }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:31,代码来源:ANTLRMessage.cs

示例11: Resolve

		public virtual IUimlElement Resolve(Template t, IUimlElement placeholder)
		{
			// add all children of the template's top element to placeholder's children 
			Console.Write("Trying to unite element '{0}' with template '{1}'... ", ((UimlAttributes) placeholder).Identifier, t.Identifier);

			try
			{
				// check if types are compatible
				if (t.Top.GetType().Equals(placeholder.GetType()))
				{
					// TODO: check for children with the same identifier, and resolve name conflicts!
					// add elements from template's top element
					placeholder.Children.AddRange(t.Top.Children);	
					Console.WriteLine("OK!");
				}
				else
					Console.WriteLine("Failed! -> incompatible types, no action taken");
			}
			catch (Exception e)
			{
				Console.WriteLine("Failed!");
			}

			return placeholder; // always return placeholder, whether it's modified or not
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:25,代码来源:UnionTemplateResolver.cs

示例12: TestComplicatedExpression

 public void TestComplicatedExpression()
 {
     var templateContent = "${(8+2)*(5+5) - ((2+8)/2)}";
     var template = new Template(templateContent);
     var render = template.Render();
     Assert.AreEqual("95", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:7,代码来源:TagsTests.cs

示例13: TestUnknownVariablesAreIgnored

 public void TestUnknownVariablesAreIgnored()
 {
     Template template = new Template("Hello, ${name}");
     template.Set("unknown", "Hi");
     template.Set("name", "Tom");
     Assert.AreEqual("Hello, Tom", template.Evaluate());
 }
开发者ID:doriath,项目名称:TddPresentation,代码行数:7,代码来源:TemplateTests.cs

示例14: AddTemplate

        public bool AddTemplate(Template template) {
            Debug.Assert(template.ImportPrecedence == 0);

            template.ImportPrecedence = this.importPrecedence;
            template.OrderNumber      = this.orderNumber++;

            compiler.AllTemplates.Add(template);

            if (template.Name != null) {
                Template old;
                if (!compiler.NamedTemplates.TryGetValue(template.Name, out old)) {
                    compiler.NamedTemplates[template.Name] = template;
                } else {
                    Debug.Assert(template.ImportPrecedence <= old.ImportPrecedence, "Global objects are processed in order of decreasing import precedence");
                    if (old.ImportPrecedence == template.ImportPrecedence) {
                        return false;
                    }
                }
            }

            if (template.Match != null) {
                Templates.Add(template);
            }
            return true;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:25,代码来源:stylesheet.cs

示例15: GenerateMain

        public static void GenerateMain(string entryType, string entryNamespace, bool inputArgs)
        {
            StreamWriter writer = new StreamWriter(FileWritterManager.WorkingPath + "main.cpp");

            string txt;
            Template template;

            string altTools = Environment.GetEnvironmentVariable("ALTERNATIVE_TOOLS_PATH");

            if(altTools == null)
                altTools = Path.Combine(Environment.CurrentDirectory, (@"..\..\..\Tools").Replace('\\','/'));

            StreamReader sr = new StreamReader((altTools + @"\Templates\Code\main.stg").Replace('\\', '/'));
            txt = sr.ReadToEnd();
            template = new Template(txt);

            StreamReader fs = new StreamReader(Path.Combine(altTools, "Text/notice"));
            string notice = fs.ReadToEnd();

            template.Add("NOTICE", notice);
            template.Add("ENTRY_TYPE", entryType);
            template.Add("ENTRY_NAMESPACE_NEEDED", !String.IsNullOrEmpty(entryNamespace));
            template.Add("ENTRY_NAMESPACE", entryNamespace);
            template.Add("INPUT_ARGS", inputArgs);

            string output = template.Render();

            writer.Write(output);
            writer.Flush();
            writer.Close();

            FileWritterManager.AddSourceFile("main.cpp");
        }
开发者ID:KAW0,项目名称:Alter-Native,代码行数:33,代码来源:MainWritter.cs


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