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

Modify PropertyTemplate?

1 Answer 46 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.
Manfred
Top achievements
Rank 2
Manfred asked on 30 Jul 2012, 06:54 AM
Hi there,

is it possible, to change the template which was called if I selected 'JustCode - Create Get/Set Property' in the context menu?
I use my own ViewModelBase and I want to use it like this:
/// <summary>
/// Gets or sets the country.
/// </summary>
/// <value>The country.</value>
public string Country
{
    get
    {
        return this.country;
    }
    set
    {
        this.country = value;
        OnChange("Country");
    }
}
I only want to add one line to the setter.
Is it possible to change that template?

Best Regards
Manfred

1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 02 Aug 2012, 08:11 AM
Hello,

Thank you for your feedback. JustCode "Create Property" command does not support the scenario you described. However, you can write an extension for JustCode which does this. I created a working extension following your description and I am attaching the solution.
You can modify it further if you want - for example change/remove the shortcut, the text that will be shown and the identifier. This command can be executed on a field and will create a property which have "OnChange" in its setter.
You can go even further and make it to check whether the new value is different than the old one and call OnChange only then.
In order to get this extension working you have to build the solution, then copy the dll and pdb file, go to (Program Files)/Telerik/JustCode/Libraries and create "UserExtensions" folder. Finally, paste the dll and the pdb in this folder and start a new instance of Visual Studio.
If you want to debug the extension just start debugging in the solution I am sending you.
If you have any questions regarding JustCode and its API, please do not hesitate to contact us again!

Greetings,
Ivan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Code Templates
Asked by
Manfred
Top achievements
Rank 2
Answers by
Ivan
Telerik team
Share this question
or