Consider the following
I have an Html Template object
class HtmlTemplateModel
{
public HTML Html {get;set;}
//..etc
}
and an Html Editor
class HtmlEditorViewModel
{
private HtmlTemplateModel htmlTemplateModel;
public HtmlEditor(HtmlTemplateModel htmlTemplateModel)
{
this.htmlTemplateModel = htmlTemplateModel;
}
}
This way the TemplateEditor instance applies the changes to the original template since its a reference type, but i dont want to modify its value so i made a new constructor that takes an HtmlTemplateModel
and creates a new HtmlTemplateModel
.
- is this the best way to clone reference type in .NET?
- and is there a shortcut so that i don't have to create another constructor to clone the object?