A good thing to do when you want to learn more is to open the Episerver .dll files in dotPeek or other decompiling tool.
Decompiling PropertyLongString I think that their code examples are wrong.
There is no Property called "String" on PropertyLongString and PropertyData that the example inherits from. But there is a property called "LongString".
I think it should be
if (!String.IsNullOrEmpty(LongString))
and LongString on other places where the word "String" might be giving errors in their example. Can you try replacing the "String" where Visual Studio gives an error with "LongString"?
I also see that you're linking to document for an older version of Episerver. Versioning of the documentation are a bit confusing.
Here's the latest version where you can see that their using "LongString" instead of "String"
http://world.episerver.com/documentation/developer-guides/CMS/Content/Properties/Custom-properties/
Hi,
I am new to Episerver and learning it from documentation. i picked this topic from below url
http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Content/Properties/Custom-properties/
But unable to understand how it is possible in C#
if (!String.IsNullOrEmpty(String))
if possible kindly let me know the meaning and use of method/properties used in this class. As far as I understand to create a custom property class inheriting from one of the Default Backing Types. One of the example that make sense to me is
https://github.com/episerver/AlloyDemoKit/blob/master/src/AlloyDemoKit/Models/Properties/PropertyStringList.cs
[PropertyDefinitionTypePlugIn]
public class LinkingProperty : PropertyLongString
{
public IEnumerable LinkedReferences
{
get
{
if (!String.IsNullOrEmpty(String))
{
var entries = String.Split(';');
return entries.Select(e => ContentReference.Parse(e));
}
return null;
}
set
{
base.String = String.Join(";", value.Select(r => r.ToString()));
}
}
public override object Value
{
get { return LinkedReferences; }
set {
IEnumerable links = value as IEnumerable;
if (links != null)
{
LinkedReferences = links;
}
else
{
base.Value = value;
}
}
}
public override Type PropertyValueType
{
get { return typeof(IEnumerable); }
}
public override object SaveData(PropertyDataCollection properties)
{ return base.String; }
}