-
Notifications
You must be signed in to change notification settings - Fork 0
Read Only Property Support
Cy Scott edited this page Aug 22, 2021
·
3 revisions
If the interface has a get only property then it will be considered a read only property and a special constructor will be generated for initializing that read only property alone with all the other read only properties. Here is a simple example of how it works:
[Generate]
public interface IHaveAReadOnlyProperty
{
Guid Id { get; }
}
The generated code will look like:
public class HaveAReadOnlyPropertyModel : IHaveAReadOnlyProperty
{
public System.Guid Id
{
get
{
return _Id;
}
}
private readonly System.Guid _Id;
public HaveAReadOnlyPropertyModel(System.Guid Id)
{
_Id = Id;
}
}