-
Notifications
You must be signed in to change notification settings - Fork 13
Customize generated models in client side
Signalgo visual studio extenstion allows to customize generated models client side. Let's consider, for example, we have server side a LanguaGeInfo class with "Id" and "Name" properties. How can I add client side a new property "IsEdited"? If we change something server side we loose everything client side because the VS extension re-creates all services references from zero this tutorial you will change generated models without lost anythings.
Create ModelsMap Folder in your client project that has your signalgo generated services.
Add a class in ModelsMap folder that you want customize your model, for example if your model name is LanguageInfo, add LanguageInfoMap.cs in ModelsMap folder.
Use ModelMapp attribute over your LanguageInfoMap class and inheritance LanguageInfo for LanguageInfoMap class.
Source example:
[ModelMapp(typeof(LanguageInfo))]
public class LanguageInfoMap : LanguageInfo
{
private bool _IsEdited;
public bool IsEdited
{
get
{
return _IsEdited;
}
set
{
if (_IsEdited != value)
{
_IsEdited = value;
OnPropertyChanged(nameof(IsEdited));
}
}
}
}Update your signalgo service generated,for update right click on your added service in "Connected Services" folder and select "Update Signalgo Service".
And after update you will see your LanguageInfo class has IsEdited property in client side but server model has not IsEdited property.