The generic IReadOnly<T> inherits IReadOnly meaning you should have two implementations of CreateWritableClone, one typed and one returning object. This can be done with an explicit interface implementatation. An example could be like below which implements IReadOnly<PropertyData>:
object IReadOnly.CreateWritableClone()
{
//Call via generic interface
return this.CreateWritableClone();
}
public virtual PropertyData CreateWritableClone()
{
PropertyData prop = (PropertyData)this.MemberwiseClone();
prop.Parent = null;
prop._isReadOnly = false;
return prop;
}
No, it is not new for CMS7. But since the implementation of the nongeneric is in Base class PropertyData a custom property implementation typically does not have to bother about the non-generic variant (returning object) they just override the variant returning PropertyData.
I can also see that you do not inherit PropertyData (or some other subclass to it), that is a requirement for a custom property.
I have another class which inherits PropertyData and holds a BannerList object as the value (as in the tutorial).
Now when looking more in history I see that the method CreateWritableClone actually was added to IReadOnly in CMS7. Prior to that the non-generic interface was quite odd and difficult to work with since it lacked that method...
Hi.
I am currently creating a custom property which will hold a list of banners. The banners are an imagevault media instance and a link which corresponds. I am following the tutorial made by Joel Abrahamsson, http://joelabrahamsson.com/creating-a-custom-episerver-property-with-a-custom-class-as-value/ even though it is a bit old I think I have managed to get everything right. The problem I am facing is when implementing IReadOnly's (EPiServer.Data.Entity) method CreateWritableClone(). The error message says that the return type should be of 'object' and when I change to object it says the return type should be 'BannerList'. I have supplied my custom class BannerList.cs below.
And the error message reads as following:
Error 1 'EPiServer.Templates.InGellivare.BIT.BannerList' does not implement interface member 'EPiServer.Data.Entity.IReadOnly.CreateWritableClone()'. 'EPiServer.Templates.InGellivare.BIT.BannerList.CreateWritableClone()' cannot implement 'EPiServer.Data.Entity.IReadOnly.CreateWritableClone()' because it does not have the matching return type of 'object'. C:\EPiServer\Sites\GVE\Templates\InGellivare\BIT\BannerList.cs 10 19 nyaGellivare
Thanks in advance,
David Rutqvist