code-templates

Code template implementation with C#

大城市里の小女人 提交于 2019-12-07 14:19:50
问题 When I need code template, I can use Python as follows. templateString = """ %s %s %s """ print templateString % ("a","b","c") How do I implement the equivalent with C#? I tried using System; class DoFile { static void Main(string[] args) { string templateString = " {0} {1} {2} "; Console.WriteLine(templateString, "a", "b", "c"); } } But I got dogen.cs(86,0): error CS1010: Newline in constant dogen.cs(87,0): error CS1010: Newline in constant dogen.cs(88,0): error CS1010: Newline in constant

Code template implementation with C#

狂风中的少年 提交于 2019-12-05 19:57:40
When I need code template, I can use Python as follows. templateString = """ %s %s %s """ print templateString % ("a","b","c") How do I implement the equivalent with C#? I tried using System; class DoFile { static void Main(string[] args) { string templateString = " {0} {1} {2} "; Console.WriteLine(templateString, "a", "b", "c"); } } But I got dogen.cs(86,0): error CS1010: Newline in constant dogen.cs(87,0): error CS1010: Newline in constant dogen.cs(88,0): error CS1010: Newline in constant Of course templateString = "{0}\n{1}\n{2}\n"; works, but I need to use multiple line template as the

NEW T4 Controller Template in MVC3

我与影子孤独终老i 提交于 2019-12-03 15:23:56
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 Template? Or if I try wrong way, what is your suggestion to use Template to generate controllers? It

Useful Delphi code templates

本秂侑毒 提交于 2019-12-03 13:18:58
问题 I've been programming in Delphi for a little over two years now, and I've only got maybe 5 custom templates, I feel as though I should have more. If anyone has any particularly useful ones it would be great to have a nice repository of them here on stackoverflow. I don't care whether you use the Delphi 2009 syntax or Delphi 7, but if the code you'd be generating only works on a particular version, please mention that. 回答1: There are a handful of useful ones here, including a few based on

Creating new live-templates with import statements in IntelliJ IDEA

纵然是瞬间 提交于 2019-12-03 06:28:56
问题 Here is the Eclipse template that I want to port: ${:import(org.apache.log4j.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class); My current version in IDEA is as follows: private static final Logger LOG = Logger.getLogger($CLASS_NAME$.class);$END$ where $CLASS_NAME$ is configured to use className() as its expression. Unfortunately, I don't find any documentation on adding the import statement. Is there somehing equivalent to Eclipse ${:import(...)} ? 回答1:

Useful Delphi code templates

落爺英雄遲暮 提交于 2019-12-03 03:21:37
I've been programming in Delphi for a little over two years now, and I've only got maybe 5 custom templates, I feel as though I should have more. If anyone has any particularly useful ones it would be great to have a nice repository of them here on stackoverflow. I don't care whether you use the Delphi 2009 syntax or Delphi 7, but if the code you'd be generating only works on a particular version, please mention that. There are a handful of useful ones here, including a few based on CodeRush. These are the live templates, so they work in Delphi 2006 and up. http://delphi.wikia.com/wiki/Delphi

Creating new live-templates with import statements in IntelliJ IDEA

只愿长相守 提交于 2019-12-02 19:59:20
Here is the Eclipse template that I want to port: ${:import(org.apache.log4j.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class); My current version in IDEA is as follows: private static final Logger LOG = Logger.getLogger($CLASS_NAME$.class);$END$ where $CLASS_NAME$ is configured to use className() as its expression. Unfortunately, I don't find any documentation on adding the import statement. Is there somehing equivalent to Eclipse ${:import(...)} ? According to this post , it seems to be intended to use only full-qualified expressions. I tried it out and

IntelliJ Live Template: modified setters template

▼魔方 西西 提交于 2019-12-01 21:41:52
问题 Is anyone know how to set up a live template in intellij for doing specialized setters - i'm using v5, but I accept with pleasure knowledge for a more recent release) - My first need is a firePropertyChange setter: public final static String $PROPERTY$ = "$property$" public void set$Property$($TYPE$ $property$) { Object oldValue = this.$property$; this.$property$ = $property$; firePropertyChange($PROPERTY$, oldValue, $property$); } I have a semi-working version that generate the

Fast implement wrapping (delegate methods) in Eclipse?

丶灬走出姿态 提交于 2019-11-28 11:55:16
Is there some template or something to implement iterface methods with accessing to wrapped member? For example, suppose I have public class MyClass implements List<Something> { private final List<Something> core; ... } and now I want to implement List<Something> by passing calls to wrapped like @Override public int size() { return core.size(); } and so on. There is. Use Source menu->Generate Delegate Methods... I'll say a bit more about how the "Generate Delegate Methods" refactoring works to create a forwarding class like you describe. You make a new class which optionally implements the

How to set the Eclipse date variable format?

有些话、适合烂在心里 提交于 2019-11-28 05:44:50
How can I set the format for the ${date} variable which can be used in Eclipse templates? VonC Update February 2016: bug 75981 is officially fixed! See Jmini 's answer below Update July 2015, 6 years later: The bug mentioned below seems fixed in Eclipse 4.x. Eric Wang comments below : @date ${id:date('YYYY-MMM-dd')} ${time} this give me English datetime format in eclipse 4. Original Answer 2009 Eclipse 3.x Argh! There is a long standing bug just for that: bug 75981 The ${date} variable could be enhanced to accept an argument (similar to other parameterizations added in 3.3M1), e.g. ${d:date