t4

NEW T4 Controller Template in MVC3

无人久伴 提交于 2019-12-21 05:09:14
问题 As you know to create new t4 templates in MVC, need to add CodeTemplates folder to project. There are two main subfolders 1- AddController , 2- AddView I always use AddView folder to add new templates to generate custom views, know I need new template to generate controllers, but when I add new tt file to AddController folder, there is no any new option in templates of new controller, there is always 3 options: So how can I add new option to Add Controller window to use my custom Controller

How to create a method that encapsulates the T4 template text section?

狂风中的少年 提交于 2019-12-21 02:19:07
问题 Instead of this .tt: <#@ template debug="false" hostspecific="true" language="C#" #> <#@ import namespace="System.IO" #> <#@ output extension=".txt" #> <#@ assembly name="System"#> <# message = "hello world" ; #> blah blah blah etc. very complex example with embedded expression like <#=message#> I'd like to have an output function that would return the output blah blah etc.: <#@ template debug="false" hostspecific="true" language="C#" #> <#@ import namespace="System.IO" #> <#@ output

VS2010 - Assign html code formatting to T4 (.tt) file

▼魔方 西西 提交于 2019-12-20 05:15:13
问题 I am having a T4 text template (.tt) in VS2010 - mainly used to generate HTML code (basically some includes and JavaScript). Is it possible to assign the HTML code formatting (colors, etc) to that tt file. Is situation (the T4): Want have: -- Update as of answer Marcio Barcellos -- Formatting with proposed AddOn: 回答1: You can add an extension to visual studio and get the result you want http://visualstudiogallery.msdn.microsoft.com/40a887aa-f3be-40ec-a85d-37044b239591 来源: https:/

Prevent EF6 from generate navigation properties

▼魔方 西西 提交于 2019-12-20 05:01:07
问题 I've recently started to use EF6 and i'm building a couple of T4 templates to generate some code automatically (on VS2012). I'm generating my model from the database and this process creates all the associations automatically based on the DB ForeignKeys. And generates too a "Navigation Property" for that field in Associations/FK. I want to get a "Flat Version" of my entities without navigation properties. Just a class with properties corresponding to table columns. Is there any way to

Is there any way to change the Navigation Property name convention when an edmx is generated in Visual Studio 2010 to use the foreign key column name?

六月ゝ 毕业季﹏ 提交于 2019-12-20 02:58:19
问题 I am currently generating some code from an edmx file with a t4 template by going through all of the properties. By default the edmx file has navigation properties that are named after the object type essentially but I would like to change it to work off of the foreign key id column instead. For example there is a Region table which is referred to by a single table twice - it has both a Supervisory Region and a Geographic Region. The default edmx navigation property name is Region and Region1

T4 Text Template - Is it possible to get compilation symbols from host?

别等时光非礼了梦想. 提交于 2019-12-19 18:29:52
问题 Background: I have an open source game library written in C# which is highly tuned for performance, using unsafe code, pointer arithmetic etc. I've recently ported the library to Windows Phone. Unfortunately Windows Phone does not support unsafe code at all, so I have had to litter my source code with preprocessor directives such as this: #if WINDOWS || XBOX public unsafe struct Foo #elif WINDOWS_PHONE public struct Foo #endif Due to the amount of these directives the codebase has become

Use class inside a T4 template

微笑、不失礼 提交于 2019-12-19 15:13:07
问题 I need to be able to use a class inside a T4 template, both of which reside in my solution. I have a class named Container in Container.cs . In my text template I want to be able to Access Container class. Any ideas on how can i do this. Basically something like this: <#@ template language="C#" #> <# var container = new Container() #> 回答1: In general, if you need to actually use the Container class's functionality in your template, you'll want to load the assembly that your project is

run automatically t4 templates

风格不统一 提交于 2019-12-19 15:05:15
问题 I would like to know if is possible to run a T4 template when saving a other file, example run my .tt file after/on saving a xml file I forgot to mention that my IDE is VS2010 回答1: Yes, it is possible. Here is how. 来源: https://stackoverflow.com/questions/3948248/run-automatically-t4-templates

Aspect Oriented Logging with Unity\T4\anything else

时光怂恿深爱的人放手 提交于 2019-12-19 07:00:11
问题 In my application we have a trace logger. We have log statements added at the beginning and end of most of the important methods tracing the method name and the parameter values. Now these trace statements are bloating the code and it is a bit of a pain to read through them. I am considering how can I separate this aspect of the code from my business logic. Today I was reading about Unity's interception framework. I had a passing thought if it is possible to intercept my method calls with a

Design-time T4 templates in ASP.NET 5 (VS 2015)

家住魔仙堡 提交于 2019-12-19 03:46:12
问题 I can't seem to find a way to make T4 templates in VS 2015 RTM, in an ASP.NET 5 (vNext) project. I even installed the T4 toolbox for Visual Studio 2015 extension, but the tt templates are not transformed. The property Custom Tool doesn't appear in the tt file properties, neither can't I find the ' Run Custom Tool ' command. Update The reason I want the T4 templates, is the introduction of the config.json file, and the pluggable configuration system, which is an awesome thing, but with the