Placing Backing Field on top of class using Live Template

267 views Asked by At

I've created a Live Template to generate a full property that includes a notifypropertychange and a comment on top. It works great except I was wondering if it was possible for the backing field to automatically placed at the top of my class in my #Members Region. If so how could I go about doing this? I know in resharper i can convert an auto property to a full backing field property and resharper is smart enough to place the field below any existing fields i have in the class at the top. Any help is greatly appreciated.

 private $TYPE$ $nAME$; 


 /// <summary>
 /// Gets and sets the value for $NAME$
 /// </summary>
 public $TYPE$ $NAME$
 {
    get 
    {
       return $nAME$;
    }
    set
    {
       $nAME$ = value;
       NotifyPropertyChanged(x => x.$NAME$); 
    }
 }
1

There are 1 answers

0
citizenmatt On BEST ANSWER

Live Templates can't do that - they're for generating a single block of code, rather than inserting multiple blocks into an existing file (how would you specify where you wanted a particular block to go?) The best you can do is manually reformat the code after using the template.