Skip to content

Commit

Permalink
Improved XML documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Apr 12, 2017
1 parent 3645799 commit 6fac3a4
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public void RemoveAt(int index) {
_converters.RemoveAt(index);
}

/// <summary>
/// Returns an enumerator that iterates through the <see cref="List{IGridConverter}"/>.
/// </summary>
/// <returns>A <see cref="List{T}.Enumerator"/> for the <see cref="List{IGridConverter}"/>.</returns>
public IEnumerator<IGridConverter> GetEnumerator() {
return _converters.GetEnumerator();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Web;
using System.Web.Mvc;
using System.Text.RegularExpressions;

namespace Skybrud.Umbraco.GridData.Extensions {

Expand Down Expand Up @@ -33,7 +32,7 @@ public static HtmlString RenderGridRow(this HtmlHelper helper, GridRow row, stri
}

/// <summary>
/// Gets the HTML of the specified <paramref name="row" /> or falls back to <see cref="fallbackPartial"/> if no row view is found.
/// Gets the HTML of the specified <paramref name="row" /> or falls back to <paramref name="fallbackPartial"/> if no row view is found.
/// </summary>
/// <param name="helper">The instance of <see cref="T:System.Web.Mvc.HtmlHelper" /> used for rendering the row.</param>
/// <param name="row">The row to be rendered.</param>
Expand All @@ -45,7 +44,7 @@ public static HtmlString RenderGridRowOrFallback(this HtmlHelper helper, GridRow
}

/// <summary>
/// Gets the HTML of the specified <paramref name="row" /> or falls back to <see cref="fallbackPartial"/> if <paramref name="partial"/> isn't found.
/// Gets the HTML of the specified <paramref name="row" /> or falls back to <paramref name="fallbackPartial"/> if <paramref name="partial"/> isn't found.
/// </summary>
/// <param name="helper">The instance of <see cref="T:System.Web.Mvc.HtmlHelper" /> used for rendering the row.</param>
/// <param name="row">The row to be rendered.</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.RegularExpressions;
using System.Web;
using System.Web;
using System.Web.Mvc;

namespace Skybrud.Umbraco.GridData.Extensions {
Expand Down Expand Up @@ -33,7 +32,7 @@ public static HtmlString RenderGridSection(this HtmlHelper helper, GridSection s
}

/// <summary>
/// Gets the HTML of the specified <paramref name="section" /> or falls back to <see cref="fallbackPartial"/> if no section view is found.
/// Gets the HTML of the specified <paramref name="section" /> or falls back to <paramref name="fallbackPartial"/> if no section view is found.
/// </summary>
/// <param name="helper">The instance of <see cref="T:System.Web.Mvc.HtmlHelper" /> used for rendering the section.</param>
/// <param name="section">The section to be rendered.</param>
Expand All @@ -45,7 +44,7 @@ public static HtmlString RenderGridSectionOrFallback(this HtmlHelper helper, Gri
}

/// <summary>
/// Gets the HTML of the specified <paramref name="section" /> or falls back to <see cref="fallbackPartial"/> if <paramref name="partial"/> isn't found.
/// Gets the HTML of the specified <paramref name="section" /> or falls back to <paramref name="fallbackPartial"/> if <paramref name="partial"/> isn't found.
/// </summary>
/// <param name="helper">The instance of <see cref="T:System.Web.Mvc.HtmlHelper" /> used for rendering the section.</param>
/// <param name="section">The section to be rendered.</param>
Expand Down
4 changes: 4 additions & 0 deletions src/Skybrud.Umbraco.GridData/GridDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public bool TryGetValue(string key, out string value) {
return _dictionary.TryGetValue(key, out value);
}

/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns>An enumerator that can be used to iterate through the collection.</returns>
public IEnumerator<GridDictionaryItem> GetEnumerator() {
return _dictionary.Select(x => new GridDictionaryItem(x.Key, x.Value)).GetEnumerator();
}
Expand Down
37 changes: 37 additions & 0 deletions src/Skybrud.Umbraco.GridData/GridPropertyValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,33 @@ namespace Skybrud.Umbraco.GridData {
/// </summary>
public class GridPropertyValueConverter : IPropertyValueConverterMeta {

/// <summary>
/// Gets a value indicating whether the converter supports a property type.
/// </summary>
/// <param name="propertyType">The property type.</param>
/// <returns>A value indicating whether the converter supports a property type.</returns>
public bool IsConverter(PublishedPropertyType propertyType) {
return propertyType.PropertyEditorAlias == "Umbraco.Grid";
}

/// <summary>
/// Converts a property Data value to a Source value.
/// </summary>
/// <param name="propertyType">The property type.</param>
/// <param name="source">The data value.</param>
/// <param name="preview">A value indicating whether conversion should take place in preview mode.</param>
/// <returns>The result of the conversion.</returns>
public object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) {
return source;
}

/// <summary>
/// Converts a property Source value to an Object value.
/// </summary>
/// <param name="propertyType">The property type.</param>
/// <param name="source">The source value.</param>
/// <param name="preview">A value indicating whether conversion should take place in preview mode.</param>
/// <returns>The result of the conversion.</returns>
public object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview) {

// Get the value as a string
Expand All @@ -27,10 +46,23 @@ public object ConvertSourceToObject(PublishedPropertyType propertyType, object s

}

/// <summary>
/// Converts a property Source value to an XPath value.
/// </summary>
/// <param name="propertyType">The property type.</param>
/// <param name="source">The source value.</param>
/// <param name="preview">A value indicating whether conversion should take place in preview mode.</param>
/// <returns>The result of the conversion.</returns>
public object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) {
return null;
}

/// <summary>
/// Gets the property cache level of a specified value.
/// </summary>
/// <param name="propertyType">The property type.</param>
/// <param name="cacheValue">The property value.</param>
/// <returns>The property cache level of the specified value.</returns>
public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType, PropertyCacheValue cacheValue) {
PropertyCacheLevel propertyCacheLevel;
switch (cacheValue) {
Expand All @@ -50,6 +82,11 @@ public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyTy
return propertyCacheLevel;
}

/// <summary>
/// Gets the type of values returned by the converter.
/// </summary>
/// <param name="propertyType">The property type.</param>
/// <returns>The CLR type of values returned by the converter.</returns>
public virtual Type GetPropertyValueType(PublishedPropertyType propertyType) {
return typeof(GridDataModel);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Skybrud.Umbraco.GridData/GridRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public static GridRow Parse(GridSection section, JObject obj) {

// Some input validation
if (obj == null) throw new ArgumentNullException("obj");

#pragma warning disable 618

// Parse basic properties
GridRow row = new GridRow(obj) {
Expand All @@ -202,6 +204,8 @@ public static GridRow Parse(GridSection section, JObject obj) {
Name = obj.GetString("name")
};

#pragma warning restore 618

// Parse the areas
row.Areas = obj.GetArray("areas", x => GridArea.Parse(row, x)) ?? new GridArea[0];

Expand Down
4 changes: 2 additions & 2 deletions src/Skybrud.Umbraco.GridData/Interfaces/IGridControlValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Skybrud.Umbraco.GridData.Interfaces {
public interface IGridControlValue {

/// <summary>
/// Gets a reference to the parent control.
/// Gets a reference to the parent <see cref="GridControl"/>.
/// </summary>
[JsonIgnore]
GridControl Control { get; }
Expand All @@ -22,7 +22,7 @@ public interface IGridControlValue {
/// <summary>
/// Gets the value of the control as a searchable text - eg. to be used in Examine.
/// </summary>
/// <returns>Returns an instance of <see cref="System.String"/> with the value as a searchable text.</returns>
/// <returns>An instance of <see cref="System.String"/> with the value as a searchable text.</returns>
string GetSearchableText();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ namespace Skybrud.Umbraco.GridData.Json.Converters {
/// </summary>
public class GridControlValueStringConverter : JsonConverter {

/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The calling serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
GridControlTextValue text = value as GridControlTextValue;
if (text != null) {
Expand All @@ -18,14 +24,30 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
serializer.Serialize(writer, value);
}

/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value of object being read.</param>
/// <param name="serializer">The calling serializer.</param>
/// <returns>The object value.</returns>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
throw new NotImplementedException("Unnecessary because CanRead is false. The type will skip the converter.");
}

/// <summary>
/// Gets a value indicating whether this Newtonsoft.Json.JsonConverter can read JSON.
/// </summary>
public override bool CanRead {
get { return false; }
}

/// <summary>
/// Determines whether this instance can convert the specified object type.
/// </summary>
/// <param name="type">Type of the object.</param>
/// <returns><code>true</code> if this instance can convert the specified object type; otherwise <code>false</code>.</returns>
public override bool CanConvert(Type type) {
return false;
}
Expand Down
22 changes: 22 additions & 0 deletions src/Skybrud.Umbraco.GridData/Json/Converters/GridJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ namespace Skybrud.Umbraco.GridData.Json.Converters {
/// </summary>
public class GridJsonConverter : JsonConverter {

/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The calling serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {

GridJsonObject obj = value as GridJsonObject;
Expand All @@ -20,14 +26,30 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s

}

/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value of object being read.</param>
/// <param name="serializer">The calling serializer.</param>
/// <returns>The object value.</returns>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
throw new NotImplementedException("Unnecessary because CanRead is false. The type will skip the converter.");
}

/// <summary>
/// Gets a value indicating whether this Newtonsoft.Json.JsonConverter can read JSON.
/// </summary>
public override bool CanRead {
get { return false; }
}

/// <summary>
/// Determines whether this instance can convert the specified object type.
/// </summary>
/// <param name="type">Type of the object.</param>
/// <returns><code>true</code> if this instance can convert the specified object type; otherwise <code>false</code>.</returns>
public override bool CanConvert(Type type) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Skybrud.Umbraco.GridData/Values/GridControlEmbedValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class GridControlEmbedValue : GridControlHtmlValue {

#region Properties

/// <summary>
/// Gets whether the value of the control is valid.
/// </summary>
public override bool IsValid {
get { return !String.IsNullOrWhiteSpace(Value); }
}
Expand Down
8 changes: 8 additions & 0 deletions src/Skybrud.Umbraco.GridData/Values/GridControlHtmlValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ protected GridControlHtmlValue(GridControl control, JToken token) : base(control

#region Member methods

/// <summary>
/// Gets the value of the control as a searchable text - eg. to be used in Examine.
/// </summary>
/// <returns>An instance of <see cref="System.String"/> with the value as a searchable text.</returns>
public override string GetSearchableText() {
return Regex.Replace(Value, "<.*?>", "");
}

/// <summary>
/// Gets a string representing the raw value of the control.
/// </summary>
/// <returns>An instance of <see cref="System.String"/>.</returns>
public string ToHtmlString() {
return Value;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Skybrud.Umbraco.GridData/Values/GridControlTextValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,18 @@ protected GridControlTextValue(GridControl control, JToken token) {

#region Member methods

/// <summary>
/// Gets the value of the control as a searchable text - eg. to be used in Examine.
/// </summary>
/// <returns>An instance of <see cref="System.String"/> with the value as a searchable text.</returns>
public virtual string GetSearchableText() {
return Value;
}

/// <summary>
/// Gets a string representing the raw value of the control.
/// </summary>
/// <returns>An instance of <see cref="System.String"/>.</returns>
public override string ToString() {
return Value;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Skybrud.Umbraco.GridData/Values/GridControlValueBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public abstract class GridControlValueBase : GridJsonObject, IGridControlValue {

#region Properties

/// <summary>
/// Gets a reference to the parent <see cref="GridControl"/>.
/// </summary>
[JsonIgnore]
public GridControl Control { get; private set; }

/// <summary>
/// Gets whether the control is valid (eg. whether it has a value).
/// </summary>
[JsonIgnore]
public virtual bool IsValid {
get { return true; }
Expand All @@ -37,6 +43,10 @@ protected GridControlValueBase(GridControl control, JObject obj) : base(obj) {

#region Member methods

/// <summary>
/// Gets the value of the control as a searchable text - eg. to be used in Examine.
/// </summary>
/// <returns>An instance of <see cref="System.String"/> with the value as a searchable text.</returns>
public virtual string GetSearchableText() {
return "";
}
Expand Down

0 comments on commit 6fac3a4

Please sign in to comment.