NamespaceSystemLibrary.Common.Episerver.Extensions
String extensions
StringExtensions
public static class StringExtensions
Inheritance
System.Object
StringExtensions
String extensions
Convert the 'text', which is a string (json string) that comes from a 'public virtual' property marked with JsonEdit attribute
Read that json data as a List of T, or a simple T
Convert the stored value from a JsonEdit attribute, which is stored as a string, to a List of T
class Car {
public string Name { get; set; }
}
[JsonEdit(Type = typeof(Car))]
public virtual string Cars { get; set; }
public class Controller
{
ActionResult Index(Block currentBlock) //or page
{
var cars = currentBlock.Cars.JsonEditAsObject<List<Car>>();
// cars is now a list of cars or empty
}
}
Name | Description |
---|---|
T |
Type | Name | Description |
---|---|---|
System.String | text |
Type | Description |
---|---|
T | Returns a simple object T or a List of T, based on the json string that comes from a 'public virtual' property marked with JsonEdit attribute |
Returns a friendly url version of the passed in url, usually a episerver content link or similar
Type | Name | Description |
---|---|---|
System.String | url | |
System.Nullable<System.Boolean> | convertToAbsolute | Pass null, which is default, to not convert, if input is absolute it returns absolute, else relative. Set to 'false' to force a relative return value, set to 'true' to force a absolute path based on CMS PrimaryDomain value |
Type | Description |
---|---|
System.String | Returns friendly url, never null, minimum "" |
}