This is a migrated thread and some comments may be shown as answers.

Property Template generation

2 Answers 75 Views
Code Templates
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 11 Nov 2010, 07:44 PM
What's the template syntax to get this generated properly?
private string _property;
public string Property{
    get{
        return _property;
    }
    set{
        _property = value;
    }
}

This is what I did, but it's a bit gimpy (empty line generated after the private definition) and when I get to variable 3 I get a dropdown box for some reason.

Is there any sort of transform I can apply such that Property automatically becomes _property so I dont have to have 3 variables to enter?



**Edit**
Sorry, these dont get blown away if I update to another version or internal release right?

2 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 11 Nov 2010, 07:59 PM
Got it kindof, except for the underscore (if anyone needs it)

private $1$ $2$ = $6=SELECT(null,String.Empty,Guid.Empty,Guid.NewGuid(),true,false)$;
public $1$ $3$
{
get
{
return $2=SELECT_VARIABLE($3$)$;
}
set
{
$2$ = value;
}
}


Although it still plops it out like this (space between them)
private string _property = String.Empty;
 
public string Property{
    get{
        return _property;
    }
    set{
        _property = value;
    }
}

Lets say I want an OPTIONAL V4 which will let me assign a default value to the private member...can that be done?  The only thing I see is SELECT in the documentation
0
Tsviatko Yovtchev
Telerik team
answered on 15 Nov 2010, 02:01 PM
Hi Steve,

 I am not quite sure I fully understand you. Let's go through this one step at a time.

>This is what I did, but it's a bit gimpy (empty line generated after the private definition) and when I get to variable 3 I get a dropdown box for some reason.

What is that you did? The empty line after the private definition is inserted by the JustCode formatting. We format the region of code the template produces. We can think of an exception to that rule but it's gonna be some time before we are able to have this functionality.

>Is there any sort of transform I can apply such that Property automatically becomes _property so I dont have to have 3 variables to enter?

Nope we don't have textual transforms as of yet. This is again something useful that we might add later.

>**Edit** 
Sorry, these dont get blown away if I update to another version or internal release right?

What do you mean by that? I could not quite get it.

>Lets say I want an OPTIONAL V4 which will let me assign a default value to the private member...can that be done?  The only thing I see is SELECT in the documentation

You are already assigning default value to the private member using the SELECT function. What do you mean by OPTIONAL V4?


Sincerely yours,
Tsviatko Yovtchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Code Templates
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Tsviatko Yovtchev
Telerik team
Share this question
or