diff --git a/src/Skybrud.Umbraco.GridData/GridArea.cs b/src/Skybrud.Umbraco.GridData/GridArea.cs
index 9e3dbd4..c167fb7 100644
--- a/src/Skybrud.Umbraco.GridData/GridArea.cs
+++ b/src/Skybrud.Umbraco.GridData/GridArea.cs
@@ -15,7 +15,7 @@ public class GridArea : GridJsonObject {
#region Properties
///
- /// Gets a reference to the parent GridRow
.
+ /// Gets a reference to the parent .
///
[JsonIgnore]
public GridRow Row { get; private set; }
@@ -31,7 +31,7 @@ public class GridArea : GridJsonObject {
public bool AllowAll { get; private set; }
///
- /// Gets an array of all editors allowed for this area. If AllowAll
is TRUE
, this
+ /// Gets an array of all editors allowed for this area. If is true
, this
/// array may be empty.
///
public string[] Allowed { get; private set; }
@@ -47,7 +47,7 @@ public class GridArea : GridJsonObject {
public GridDictionary Styles { get; private set; }
///
- /// Gets a dictionary representing the configuration (called Settings in the backoffice) of the area.
+ /// Gets a dictionary representing the configuration (called Settings in the backoffice) of the area.
///
public GridDictionary Config { get; private set; }
@@ -70,7 +70,7 @@ public bool HasControls {
///
/// Gets the first control of the area. If the area doesn't contain
- /// any controls, this property will return NULL
.
+ /// any controls, this property will return null
.
///
public GridControl FirstControl {
get { return Controls.FirstOrDefault(); }
@@ -78,7 +78,7 @@ public GridControl FirstControl {
///
/// Gets the last control of the area. If the area doesn't contain
- /// any controls, this property will return NULL
.
+ /// any controls, this property will return null
.
///
public GridControl LastControl {
get { return Controls.LastOrDefault(); }
@@ -88,10 +88,26 @@ public GridControl LastControl {
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified .
+ ///
+ /// An instance of representing the area.
protected GridArea(JObject obj) : base(obj) { }
#endregion
+ #region Member methods
+
+ ///
+ /// Gets a textual representation of the area - eg. to be used in Examine.
+ ///
+ /// Returns an instance of representing the value of the area.
+ public virtual string GetSearchableText() {
+ return Controls.Aggregate("", (current, control) => current + control.GetSearchableText());
+ }
+
+ #endregion
+
#region Static methods
///
diff --git a/src/Skybrud.Umbraco.GridData/GridContext.cs b/src/Skybrud.Umbraco.GridData/GridContext.cs
index 8501531..b697353 100644
--- a/src/Skybrud.Umbraco.GridData/GridContext.cs
+++ b/src/Skybrud.Umbraco.GridData/GridContext.cs
@@ -20,7 +20,7 @@ public class GridContext {
#region Properties
///
- /// Gets the singleton instance of the GridContext
class.
+ /// Gets the singleton instance of the class.
///
public static readonly GridContext Current = new GridContext();
@@ -42,7 +42,7 @@ private GridContext() { }
#region Member methods
///
- /// Gets an instance of GridControlWrapper
based on the specified control
.
+ /// Gets an instance of based on the specified control
.
///
/// The control to wrap.
public GridControlWrapper GetControlWrapper(GridControl control) {
diff --git a/src/Skybrud.Umbraco.GridData/GridControl.cs b/src/Skybrud.Umbraco.GridData/GridControl.cs
index 13b49f6..c74fd60 100644
--- a/src/Skybrud.Umbraco.GridData/GridControl.cs
+++ b/src/Skybrud.Umbraco.GridData/GridControl.cs
@@ -17,7 +17,7 @@ public class GridControl : GridJsonObject {
#region Properties
///
- /// Gets a reference to the parent GridArea
.
+ /// Gets a reference to the parent .
///
[JsonIgnore]
public GridArea Area { get; private set; }
@@ -70,6 +70,18 @@ public T GetValue() where T : IGridControlValue {
return (T) Value;
}
+ #region Member methods
+
+ ///
+ /// Gets the value of the control as a searchable text - eg. to be used in Examine.
+ ///
+ /// Returns an instance of with the value as a searchable text.
+ public virtual string GetSearchableText() {
+ return IsValid ? Value.GetSearchableText() : "";
+ }
+
+ #endregion
+
#endregion
#region Static methods
@@ -78,7 +90,7 @@ public T GetValue() where T : IGridControlValue {
/// Parses a control from the specified obj
.
///
/// The parent area of the control.
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridControl Parse(GridArea area, JObject obj) {
// Set basic properties
diff --git a/src/Skybrud.Umbraco.GridData/GridDataModel.cs b/src/Skybrud.Umbraco.GridData/GridDataModel.cs
index 3966d9b..33697a4 100644
--- a/src/Skybrud.Umbraco.GridData/GridDataModel.cs
+++ b/src/Skybrud.Umbraco.GridData/GridDataModel.cs
@@ -15,11 +15,14 @@ namespace Skybrud.Umbraco.GridData {
public class GridDataModel : GridJsonObject {
#region Properties
-
+
///
- /// Gets whether the model is valid.
+ /// Gets whether the model is valid. The model is considered valid if it has been parsed from a JSON value and
+ /// has at least one valid control.
///
- public bool IsValid { get; private set; }
+ public bool IsValid {
+ get { return JObject != null && GetAllControls().All(x => x.IsValid); }
+ }
///
/// Gets the raw JSON value this model was parsed from.
@@ -78,7 +81,6 @@ public dynamic sections {
private GridDataModel(JObject obj) : base(obj) {
Sections = new GridSection[0];
- IsValid = false;
}
#endregion
@@ -138,6 +140,14 @@ public HtmlString GetHtml(HtmlHelper helper, string framework) {
return helper.GetTypedGridHtml(this, framework);
}
+ ///
+ /// Gets a textual representation of the grid model - eg. to be used in Examine.
+ ///
+ /// Returns an instance of representing the value of the grid model.
+ public virtual string GetSearchableText() {
+ return Sections.Aggregate("", (current, section) => current + section.GetSearchableText());
+ }
+
#endregion
#region Static methods
@@ -188,7 +198,6 @@ public static GridDataModel Deserialize(string json, string propertyTypeAlias) {
GridDataModel model = new GridDataModel(obj) {
Raw = json,
Name = obj.GetString("name"),
- IsValid = true,
PropertyAlias = propertyTypeAlias
};
@@ -201,9 +210,9 @@ public static GridDataModel Deserialize(string json, string propertyTypeAlias) {
}
///
- /// Parses the specified JObject
into an instance of GridDataModel
.
+ /// Parses the specified into an instance of .
///
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
[Obsolete("Use Deserialize method instead")]
public static GridDataModel Parse(JObject obj) {
if (obj == null) return null;
diff --git a/src/Skybrud.Umbraco.GridData/GridDictionary.cs b/src/Skybrud.Umbraco.GridData/GridDictionary.cs
index 48ccb30..c4e1d3d 100644
--- a/src/Skybrud.Umbraco.GridData/GridDictionary.cs
+++ b/src/Skybrud.Umbraco.GridData/GridDictionary.cs
@@ -71,7 +71,7 @@ public bool ContainsKey(string key) {
///
/// Parses a dictionary from the specified obj
.
///
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridDictionary Parse(JObject obj) {
// Initialize an empty dictionary
diff --git a/src/Skybrud.Umbraco.GridData/GridEditor.cs b/src/Skybrud.Umbraco.GridData/GridEditor.cs
index 40d9ae1..26e4efe 100644
--- a/src/Skybrud.Umbraco.GridData/GridEditor.cs
+++ b/src/Skybrud.Umbraco.GridData/GridEditor.cs
@@ -16,7 +16,7 @@ public class GridEditor : GridJsonObject {
#region Properties
///
- /// Gets a reference to the parent GridControl
.
+ /// Gets a reference to the parent .
///
[JsonIgnore]
public GridControl Control { get; private set; }
@@ -53,8 +53,8 @@ public class GridEditor : GridJsonObject {
public string Icon { get; private set; }
///
- /// Gets the configuration object for the editor. This property will return NULL
if the
- /// corresponding property in the underlying JSON is also NULL
.
+ /// Gets the configuration object for the editor. This property will return null
if the
+ /// corresponding property in the underlying JSON is also null
.
///
[JsonProperty("config", NullValueHandling = NullValueHandling.Ignore)]
public IGridEditorConfig Config { get; set; }
@@ -85,7 +85,7 @@ public T GetConfig() where T : IGridEditorConfig {
/// Parses an editor from the specified obj
.
///
/// The parent control of the editor.
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridEditor Parse(GridControl control, JObject obj) {
// Parse basic properties
diff --git a/src/Skybrud.Umbraco.GridData/GridHelpers.cs b/src/Skybrud.Umbraco.GridData/GridHelpers.cs
index 9fb7363..010cc78 100644
--- a/src/Skybrud.Umbraco.GridData/GridHelpers.cs
+++ b/src/Skybrud.Umbraco.GridData/GridHelpers.cs
@@ -11,7 +11,7 @@ public static class GridHelpers {
///
/// Parses the specified obj
into a dictionary.
///
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
///
public static Dictionary ParseDictionary(JObject obj) {
Dictionary settings = new Dictionary();
diff --git a/src/Skybrud.Umbraco.GridData/GridRow.cs b/src/Skybrud.Umbraco.GridData/GridRow.cs
index 8613bce..1f2ad47 100644
--- a/src/Skybrud.Umbraco.GridData/GridRow.cs
+++ b/src/Skybrud.Umbraco.GridData/GridRow.cs
@@ -14,7 +14,7 @@ public class GridRow : GridJsonObject {
#region Properties
///
- /// Gets a reference to the parent GridSection
.
+ /// Gets a reference to the parent .
///
public GridSection Section { get; private set; }
@@ -67,16 +67,16 @@ public bool HasAreas {
}
///
- /// Gets the first area of the row. If the row doesn't contain
- /// any areas, this property will return NULL
.
+ /// Gets the first area of the row. If the row doesn't contain any areas, this property will return
+ /// null
.
///
public GridArea FirstRow {
get { return Areas.FirstOrDefault(); }
}
///
- /// Gets the last area of the row. If the row doesn't contain
- /// any areas, this property will return NULL
.
+ /// Gets the last area of the row. If the row doesn't contain any areas, this property will return
+ /// null
.
///
public GridArea LastRow {
get { return Areas.LastOrDefault(); }
@@ -86,6 +86,10 @@ public GridArea LastRow {
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified .
+ ///
+ /// An instance of representing the row.
protected GridRow(JObject obj) : base(obj) { }
#endregion
@@ -124,6 +128,14 @@ select control
).ToArray();
}
+ ///
+ /// Gets a textual representation of the row - eg. to be used in Examine.
+ ///
+ /// Returns an instance of representing the value of the row.
+ public virtual string GetSearchableText() {
+ return Areas.Aggregate("", (current, area) => current + area.GetSearchableText());
+ }
+
#endregion
#region Static methods
@@ -132,7 +144,7 @@ select control
/// Parses a row from the specified obj
.
///
/// The parent section of the row.
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridRow Parse(GridSection section, JObject obj) {
// Some input validation
diff --git a/src/Skybrud.Umbraco.GridData/GridSection.cs b/src/Skybrud.Umbraco.GridData/GridSection.cs
index fdd8382..fc5346e 100644
--- a/src/Skybrud.Umbraco.GridData/GridSection.cs
+++ b/src/Skybrud.Umbraco.GridData/GridSection.cs
@@ -14,7 +14,7 @@ public class GridSection : GridJsonObject {
#region Properties
///
- /// Gets a reference to the parent GridDataModel
.
+ /// Gets a reference to the parent .
///
public GridDataModel Model { get; private set; }
@@ -36,15 +36,16 @@ public bool HasRows {
}
///
- /// Gets the first row of the section. If the section doesn't contain
- /// any rows, this property will return NULL
.
+ /// Gets the first row of the section. If the section doesn't contain any rows, this property will return
+ /// null
.
///
public GridRow FirstRow {
get { return Rows.FirstOrDefault(); }
}
///
- /// Gets the last row of the section. If the section doesn't contain any rows, this property will return NULL
.
+ /// Gets the last row of the section. If the section doesn't contain any rows, this property will return
+ /// null
.
///
public GridRow LastRow {
get { return Rows.LastOrDefault(); }
@@ -54,17 +55,33 @@ public GridRow LastRow {
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified .
+ ///
+ /// An instance of representing the section.
protected GridSection(JObject obj) : base(obj) { }
#endregion
+ #region Member methods
+
+ ///
+ /// Gets a textual representation of the section - eg. to be used in Examine.
+ ///
+ /// Returns an instance of representing the value of the section.
+ public virtual string GetSearchableText() {
+ return Rows.Aggregate("", (current, row) => current + row.GetSearchableText());
+ }
+
+ #endregion
+
#region Static methods
///
/// Parses a section from the specified obj
.
///
/// The parent model of the section.
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridSection Parse(GridDataModel model, JObject obj) {
// Some input validation
diff --git a/src/Skybrud.Umbraco.GridData/GridUtils.cs b/src/Skybrud.Umbraco.GridData/GridUtils.cs
index 2c84926..d48c141 100644
--- a/src/Skybrud.Umbraco.GridData/GridUtils.cs
+++ b/src/Skybrud.Umbraco.GridData/GridUtils.cs
@@ -24,7 +24,7 @@ public static string GetVersion() {
///
public static string GetFileVersion() {
Assembly assembly = typeof(GridUtils).Assembly;
- return FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
+ return assembly.Location == null ? null : FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
}
///
diff --git a/src/Skybrud.Umbraco.GridData/Interfaces/IGridControlValue.cs b/src/Skybrud.Umbraco.GridData/Interfaces/IGridControlValue.cs
index b55041a..a50e88d 100644
--- a/src/Skybrud.Umbraco.GridData/Interfaces/IGridControlValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Interfaces/IGridControlValue.cs
@@ -18,7 +18,13 @@ public interface IGridControlValue {
///
[JsonIgnore]
bool IsValid { get; }
-
+
+ ///
+ /// Gets the value of the control as a searchable text - eg. to be used in Examine.
+ ///
+ /// Returns an instance of with the value as a searchable text.
+ string GetSearchableText();
+
}
}
\ No newline at end of file
diff --git a/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfo.json b/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfo.json
index 483eff5..85eabf8 100644
--- a/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfo.json
+++ b/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfo.json
@@ -6,5 +6,5 @@
"copyright": "Copyright © 2016",
"version": "1.5.2.0",
"informationalVersion": "1.5.2",
- "fileVersion": "0.0.730.1"
+ "fileVersion": "0.0.803.7"
}
\ No newline at end of file
diff --git a/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfoGenerated.cs b/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfoGenerated.cs
index 7e54e6a..ce6074d 100644
--- a/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfoGenerated.cs
+++ b/src/Skybrud.Umbraco.GridData/Properties/AssemblyInfoGenerated.cs
@@ -1,4 +1,4 @@
using System.Reflection;
-[assembly: AssemblyFileVersion("0.0.730.1")]
+[assembly: AssemblyFileVersion("0.0.803.7")]
diff --git a/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj b/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj
index 6f80c2a..4a7008f 100644
--- a/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj
+++ b/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj
@@ -310,6 +310,7 @@
+
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlEmbedValue.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlEmbedValue.cs
index b6e756f..fa0480c 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlEmbedValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlEmbedValue.cs
@@ -12,6 +12,11 @@ public class GridControlEmbedValue : GridControlHtmlValue {
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
protected GridControlEmbedValue(GridControl control, JToken token) : base(control, token) { }
#endregion
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlHtmlValue.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlHtmlValue.cs
index 49bb7a0..e726849 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlHtmlValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlHtmlValue.cs
@@ -1,4 +1,6 @@
-using System.Web;
+using System;
+using System.Text.RegularExpressions;
+using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Skybrud.Umbraco.GridData.Json.Converters;
@@ -14,28 +16,51 @@ public class GridControlHtmlValue : GridControlTextValue {
#region Properties
///
- /// Gets an instance of HtmlString
representing the text value.
+ /// Gets an instance of representing the text value.
///
[JsonIgnore]
public HtmlString HtmlValue { get; private set; }
+ ///
+ /// Gets whether the value is valid. For an instance of , this means
+ /// checking whether the specified text is not an empty string (using
+ /// against the value returned by the method).
+ ///
+ [JsonIgnore]
+ public override bool IsValid {
+ get { return !String.IsNullOrWhiteSpace(GetSearchableText()); }
+ }
+
#endregion
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
protected GridControlHtmlValue(GridControl control, JToken token) : base(control, token) {
HtmlValue = new HtmlString(Value);
}
#endregion
+ #region Member methods
+
+ public override string GetSearchableText() {
+ return Regex.Replace(Value, "<.*?>", "");
+ }
+
+ #endregion
+
#region Static methods
///
- /// Gets a text value from the specified JToken
.
+ /// Gets a text value from the specified .
///
/// The parent control.
- /// The instance of JToken
to be parsed.
+ /// The instance of to be parsed.
public new static GridControlTextValue Parse(GridControl control, JToken token) {
return token == null ? null : new GridControlHtmlValue(control, token);
}
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlMacroValue.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlMacroValue.cs
index c7e9759..2feeb2c 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlMacroValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlMacroValue.cs
@@ -3,20 +3,13 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Skybrud.Umbraco.GridData.Extensions.Json;
-using Skybrud.Umbraco.GridData.Interfaces;
-using Skybrud.Umbraco.GridData.Json;
namespace Skybrud.Umbraco.GridData.Values {
///
/// Class representing the macro value of a control.
///
- public class GridControlMacroValue : GridJsonObject, IGridControlValue {
-
- ///
- /// Gets a reference to the parent control.
- ///
- public GridControl Control { get; private set; }
+ public class GridControlMacroValue : GridControlValueBase {
///
/// Gets the syntax of the macro.
@@ -41,14 +34,21 @@ public class GridControlMacroValue : GridJsonObject, IGridControlValue {
/// checking whether a macro alias has been specified.
///
[JsonIgnore]
- public virtual bool IsValid {
+ public override bool IsValid {
get { return !String.IsNullOrWhiteSpace(MacroAlias); }
}
#region Constructors
- protected GridControlMacroValue(GridControl control, JObject obj) : base(obj) {
- Control = control;
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
+ protected GridControlMacroValue(GridControl control, JObject obj) : base(control, obj) {
+ Syntax = obj.GetString("syntax");
+ MacroAlias = obj.GetString("macroAlias");
+ Parameters = obj.GetObject("macroParamsDictionary").ToObject>();
}
#endregion
@@ -56,17 +56,12 @@ protected GridControlMacroValue(GridControl control, JObject obj) : base(obj) {
#region Static methods
///
- /// Gets a macro value from the specified JsonObject
.
+ /// Gets a macro value from the specified .
///
/// The parent control.
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridControlMacroValue Parse(GridControl control, JObject obj) {
- if (obj == null) return null;
- return new GridControlMacroValue(control, obj) {
- Syntax = obj.GetString("syntax"),
- MacroAlias = obj.GetString("macroAlias"),
- Parameters = obj.GetObject("macroParamsDictionary").ToObject>()
- };
+ return obj == null ? null : new GridControlMacroValue(control, obj);
}
#endregion
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlMediaFocalPoint.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlMediaFocalPoint.cs
index d3e0693..ba1a237 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlMediaFocalPoint.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlMediaFocalPoint.cs
@@ -28,22 +28,25 @@ public class GridControlMediaFocalPoint : GridJsonObject {
#region Constructors
- protected GridControlMediaFocalPoint(JObject obj) : base(obj) { }
+ ///
+ /// Initializes a new instance based on the specified .
+ ///
+ /// An instance of representing the the focal point.
+ protected GridControlMediaFocalPoint(JObject obj) : base(obj) {
+ Left = obj.GetFloat("left");
+ Top = obj.GetFloat("top");
+ }
#endregion
#region Static methods
///
- /// Gets a focal point from the specified JsonObject
.
+ /// Gets a focal point from the specified .
///
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridControlMediaFocalPoint Parse(JObject obj) {
- if (obj == null) return null;
- return new GridControlMediaFocalPoint(obj) {
- Left = obj.GetFloat("left"),
- Top = obj.GetFloat("top")
- };
+ return obj == null ? null : new GridControlMediaFocalPoint(obj);
}
#endregion
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlMediaValue.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlMediaValue.cs
index 7877819..5a1221d 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlMediaValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlMediaValue.cs
@@ -1,23 +1,16 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Skybrud.Umbraco.GridData.Extensions.Json;
-using Skybrud.Umbraco.GridData.Interfaces;
-using Skybrud.Umbraco.GridData.Json;
namespace Skybrud.Umbraco.GridData.Values {
///
/// Class representing the media value of a control.
///
- public class GridControlMediaValue : GridJsonObject, IGridControlValue {
+ public class GridControlMediaValue : GridControlValueBase {
#region Properties
- ///
- /// Gets a reference to the parent control.
- ///
- public GridControl Control { get; private set; }
-
///
/// Gets the focal point with information on how the iamge should be cropped.
///
@@ -48,7 +41,7 @@ public class GridControlMediaValue : GridJsonObject, IGridControlValue {
/// media cache.
///
[JsonIgnore]
- public virtual bool IsValid {
+ public override bool IsValid {
get { return Id > 0; }
}
@@ -56,26 +49,29 @@ public virtual bool IsValid {
#region Constructors
- protected GridControlMediaValue(JObject obj) : base(obj) { }
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
+ protected GridControlMediaValue(GridControl control, JObject obj) : base(control, obj) {
+ FocalPoint = obj.GetObject("focalPoint", GridControlMediaFocalPoint.Parse);
+ Id = obj.GetInt32("id");
+ Image = obj.GetString("image");
+ Caption = obj.GetString("caption");
+ }
#endregion
#region Static methods
///
- /// Gets a media value from the specified JsonObject
.
+ /// Gets a media value from the specified .
///
/// The parent control.
- /// The instance of JObject
to be parsed.
+ /// The instance of to be parsed.
public static GridControlMediaValue Parse(GridControl control, JObject obj) {
- if (obj == null) return null;
- return new GridControlMediaValue(obj) {
- Control = control,
- FocalPoint = obj.GetObject("focalPoint", GridControlMediaFocalPoint.Parse),
- Id = obj.GetInt32("id"),
- Image = obj.GetString("image"),
- Caption = obj.GetString("caption")
- };
+ return obj == null ? null : new GridControlMediaValue(control, obj);
}
#endregion
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlRichTextValue.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlRichTextValue.cs
index f23e2ed..9c7acc3 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlRichTextValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlRichTextValue.cs
@@ -12,6 +12,11 @@ public class GridControlRichTextValue : GridControlHtmlValue {
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
protected GridControlRichTextValue(GridControl control, JToken token) : base(control, token) { }
#endregion
@@ -19,10 +24,10 @@ protected GridControlRichTextValue(GridControl control, JToken token) : base(con
#region Static methods
///
- /// Gets a rich text value from the specified JToken
.
+ /// Gets a rich text value from the specified .
///
/// The parent control.
- /// The instance of JToken
to be parsed.
+ /// The instance of to be parsed.
public new static GridControlRichTextValue Parse(GridControl control, JToken token) {
return token == null ? null : new GridControlRichTextValue(control, token);
}
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlTextValue.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlTextValue.cs
index 082c56d..0d5b625 100644
--- a/src/Skybrud.Umbraco.GridData/Values/GridControlTextValue.cs
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlTextValue.cs
@@ -37,17 +37,30 @@ public class GridControlTextValue : IGridControlValue {
///
[JsonIgnore]
public virtual bool IsValid {
- get { return String.IsNullOrWhiteSpace(Value); }
+ get { return !String.IsNullOrWhiteSpace(Value); }
}
#endregion
#region Constructors
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
protected GridControlTextValue(GridControl control, JToken token) {
Control = control;
JToken = token;
- Value = token.Value();
+ Value = token.Value() + "";
+ }
+
+ #endregion
+
+ #region Member methods
+
+ public virtual string GetSearchableText() {
+ return Value;
}
#endregion
@@ -55,13 +68,12 @@ protected GridControlTextValue(GridControl control, JToken token) {
#region Static methods
///
- /// Gets a text value from the specified JToken
.
+ /// Gets a text value from the specified .
///
/// The parent control.
- /// The instance of JToken
to be parsed.
+ /// The instance of to be parsed.
public static GridControlTextValue Parse(GridControl control, JToken token) {
- if (token == null) return null;
- return new GridControlTextValue(control, token);
+ return token == null ? null : new GridControlTextValue(control, token);
}
#endregion
diff --git a/src/Skybrud.Umbraco.GridData/Values/GridControlValueBase.cs b/src/Skybrud.Umbraco.GridData/Values/GridControlValueBase.cs
new file mode 100644
index 0000000..5d2d21f
--- /dev/null
+++ b/src/Skybrud.Umbraco.GridData/Values/GridControlValueBase.cs
@@ -0,0 +1,48 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Skybrud.Umbraco.GridData.Interfaces;
+using Skybrud.Umbraco.GridData.Json;
+
+namespace Skybrud.Umbraco.GridData.Values {
+
+ ///
+ /// Abstract class with a basic implementation of the interface.
+ ///
+ public abstract class GridControlValueBase : GridJsonObject, IGridControlValue {
+
+ #region Properties
+
+ [JsonIgnore]
+ public GridControl Control { get; private set; }
+
+ [JsonIgnore]
+ public virtual bool IsValid {
+ get { return true; }
+ }
+
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Initializes a new instance based on the specified and .
+ ///
+ /// An instance of representing the control.
+ /// An instance of representing the value of the control.
+ protected GridControlValueBase(GridControl control, JObject obj) : base(obj) {
+ Control = control;
+ }
+
+ #endregion
+
+ #region Member methods
+
+ public virtual string GetSearchableText() {
+ return "";
+ }
+
+ #endregion
+
+ }
+
+}
\ No newline at end of file