diff --git a/app/Umbraco/Archetype.Courier/DataResolvers/ArchetypeDataResolver.cs b/app/Umbraco/Archetype.Courier/DataResolvers/ArchetypeDataResolver.cs index bacdd26..c970492 100644 --- a/app/Umbraco/Archetype.Courier/DataResolvers/ArchetypeDataResolver.cs +++ b/app/Umbraco/Archetype.Courier/DataResolvers/ArchetypeDataResolver.cs @@ -13,6 +13,9 @@ using Umbraco.Courier.ItemProviders; namespace Archetype.Courier.DataResolvers { + /// + /// Lee Kelleher's implementation of Courier's PropertyDataResolverProvider for Archetype. + /// public class ArchetypeDataResolver : PropertyDataResolverProvider { private enum Direction @@ -21,6 +24,12 @@ namespace Archetype.Courier.DataResolvers Packaging } + /// + /// Gets the editor alias. + /// + /// + /// The editor alias. + /// public override string EditorAlias { get @@ -29,26 +38,48 @@ namespace Archetype.Courier.DataResolvers } } + /// + /// Extractings the type of the data. + /// + /// The item. public override void ExtractingDataType(DataType item) { // No longer need to extract the DataType (int) Ids as Archetype now references the Guid [LK] } + /// + /// Extractings the property. + /// + /// The item. + /// The property data. public override void ExtractingProperty(Item item, ContentProperty propertyData) { ReplacePropertyDataIds(item, propertyData, Direction.Extracting); } + /// + /// Packagings the type of the data. + /// + /// The item. public override void PackagingDataType(DataType item) { AddDataTypeDependencies(item); } + /// + /// Packages the property. + /// + /// The item. + /// The property data. public override void PackagingProperty(Item item, ContentProperty propertyData) { ReplacePropertyDataIds(item, propertyData, Direction.Packaging); } + /// + /// Adds the datatype dependencies. + /// + /// The item. private void AddDataTypeDependencies(DataType item) { if (item.Prevalues != null && item.Prevalues.Count > 0) @@ -71,6 +102,12 @@ namespace Archetype.Courier.DataResolvers } } + /// + /// Replaces the property data Ids. + /// + /// The item. + /// The property data. + /// The direction. private void ReplacePropertyDataIds(Item item, ContentProperty propertyData, Direction direction) { if (propertyData != null && propertyData.Value != null) @@ -168,6 +205,10 @@ namespace Archetype.Courier.DataResolvers } } + /// + /// Retrieves the additional properties. + /// + /// The pre value. private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue) { if (preValue == null) @@ -189,6 +230,11 @@ namespace Archetype.Courier.DataResolvers } } + /// + /// Retrieves the additional properties. + /// + /// The archetype. + /// The pre value. private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue) { foreach (var fieldset in preValue.Fieldsets) diff --git a/app/Umbraco/Archetype.Tests/Models/FieldsetTests.cs b/app/Umbraco/Archetype.Tests/Models/FieldsetTests.cs index 797b72f..832231c 100644 --- a/app/Umbraco/Archetype.Tests/Models/FieldsetTests.cs +++ b/app/Umbraco/Archetype.Tests/Models/FieldsetTests.cs @@ -5,13 +5,17 @@ using NUnit.Framework; namespace Archetype.Tests.Models { - + /// + /// Tests designed for the fieldsets. + /// [TestFixture] public class FieldsetTests { - private string _sampleJson; + /// + /// Sets up the test to use sample JSON data. + /// [SetUp] public void SetUp() { diff --git a/app/Umbraco/Archetype.Tests/PropertyValueConverter/PropertyValueConverterTests.cs b/app/Umbraco/Archetype.Tests/PropertyValueConverter/PropertyValueConverterTests.cs index 63f595c..0fa8c31 100644 --- a/app/Umbraco/Archetype.Tests/PropertyValueConverter/PropertyValueConverterTests.cs +++ b/app/Umbraco/Archetype.Tests/PropertyValueConverter/PropertyValueConverterTests.cs @@ -1,22 +1,21 @@ -using System; -using System.Collections.Generic; -using System.IO; +using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Archetype.PropertyConverters; -using Moq; using NUnit.Framework; -using Umbraco.Core.Models.PublishedContent; namespace Archetype.Tests.PropertyValueConverter { + /// + /// Tests designed to test the PVC. + /// [TestFixture] public class PropertyValueConverterTests { - private string _sampleJson; + /// + /// Sets up the test to use JSON data. + /// [SetUp] public void SetUp() { diff --git a/app/Umbraco/DatabaseSizer/Application.cs b/app/Umbraco/DatabaseSizer/Application.cs index 0824ba5..5261a0f 100644 --- a/app/Umbraco/DatabaseSizer/Application.cs +++ b/app/Umbraco/DatabaseSizer/Application.cs @@ -4,6 +4,10 @@ using Umbraco.Core.Logging; namespace DatabaseSizer { + /// + /// A now obsolete project that handled an Umbraco core limitation. + /// + [Obsolete("This project is now obsolete with 7.2.2+")] public class Application : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) diff --git a/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs b/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs index ba2816a..af0c4ce 100644 --- a/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs +++ b/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs @@ -14,10 +14,12 @@ using Archetype.Extensions; namespace Archetype.Api { + /// + /// Controller that handles datatype related interactions. + /// [PluginController("ArchetypeApi")] public class ArchetypeDataTypeController : UmbracoAuthorizedJsonController { - public IEnumerable GetAllPropertyEditors() { return @@ -25,12 +27,22 @@ namespace Archetype.Api .Select(x => new {defaultPreValues = x.DefaultPreValuesForArchetype(), alias = x.Alias, view = x.ValueEditor.View}); } + /// + /// Gets all datatypes. + /// + /// public object GetAll() { var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions(); return dataTypes.Select(t => new { guid = t.Key, name = t.Name }); } + /// + /// Gets the datatype by GUID. + /// + /// The unique identifier. + /// + /// public object GetByGuid(Guid guid) { var dataType = Services.DataTypeService.GetDataTypeDefinitionById(guid); @@ -43,6 +55,16 @@ namespace Archetype.Api return new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues }; } + /// + /// Gets the datatype by GUID. + /// + /// The unique identifier. + /// The content type alias. + /// The property type alias. + /// The archetype alias. + /// The node identifier. + /// + /// public object GetByGuid(Guid guid, string contentTypeAlias, string propertyTypeAlias, string archetypeAlias, int nodeId) { var dataType = Services.DataTypeService.GetDataTypeDefinitionById(guid); @@ -54,11 +76,19 @@ namespace Archetype.Api return new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues, contentTypeAlias = contentTypeAlias, propertyTypeAlias = propertyTypeAlias, archetypeAlias = archetypeAlias, nodeId = nodeId }; } + /// + /// Returns the DLL version from the file. + /// + /// public object GetDllVersion() { return new {dllVersion = _version()}; } + /// + /// Gets the DLL version from the file. + /// + /// private string _version() { var asm = Assembly.GetExecutingAssembly(); diff --git a/app/Umbraco/Umbraco.Archetype/Constants.cs b/app/Umbraco/Umbraco.Archetype/Constants.cs index f8e6b50..d2a9db8 100644 --- a/app/Umbraco/Umbraco.Archetype/Constants.cs +++ b/app/Umbraco/Umbraco.Archetype/Constants.cs @@ -1,5 +1,8 @@ namespace Archetype { + /// + /// Archetype constants. + /// public static class Constants { public const string PropertyEditorAlias = "Imulus.Archetype"; diff --git a/app/Umbraco/Umbraco.Archetype/Events/ExpireCache.cs b/app/Umbraco/Umbraco.Archetype/Events/ExpireCache.cs index 792165b..c57e9e7 100644 --- a/app/Umbraco/Umbraco.Archetype/Events/ExpireCache.cs +++ b/app/Umbraco/Umbraco.Archetype/Events/ExpireCache.cs @@ -1,18 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Umbraco.Core; +using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; -using Umbraco.Web; namespace Archetype.Events { public class ExpireCache : ApplicationEventHandler { - + /// + /// Registers our ExpirePreValueCache handler on app starting. + /// + /// + /// protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { base.ApplicationStarting(umbracoApplication, applicationContext); @@ -20,6 +18,11 @@ namespace Archetype.Events DataTypeService.Saved += ExpirePreValueCache; } + /// + /// Expires the pre value cache when a datatype is saved. + /// + /// The sender. + /// The instance containing the event data. void ExpirePreValueCache(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs e) { foreach (var dataType in e.SavedEntities) diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypeHelper.cs b/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypeHelper.cs index fde1255..3f80cba 100644 --- a/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypeHelper.cs +++ b/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypeHelper.cs @@ -9,6 +9,9 @@ using Umbraco.Core.Models.PublishedContent; namespace Archetype.Extensions { + /// + /// Helper class that handles several Archetype related interactions. + /// public class ArchetypeHelper { protected JsonSerializerSettings _jsonSettings; @@ -18,6 +21,9 @@ namespace Archetype.Extensions internal static ArchetypeHelper Instance { get { return _instance; } } + /// + /// Initializes a new instance of the class. + /// internal ArchetypeHelper() { var dcr = new Newtonsoft.Json.Serialization.DefaultContractResolver(); @@ -27,8 +33,20 @@ namespace Archetype.Extensions _app = ApplicationContext.Current; } + /// + /// Gets the json serializer settings. + /// + /// + /// The json serializer settings. + /// internal JsonSerializerSettings JsonSerializerSettings { get { return _jsonSettings; } } + /// + /// Deserializes the JSON to archetype. + /// + /// The source JSON. + /// The data type pre values. + /// internal ArchetypeModel DeserializeJsonToArchetype(string sourceJson, PreValueCollection dataTypePreValues) { try @@ -54,6 +72,13 @@ namespace Archetype.Extensions } } + /// + /// Deserializes the JSON to archetype. + /// + /// The source JSON. + /// The data type identifier. + /// Type of the host content. + /// internal ArchetypeModel DeserializeJsonToArchetype(string sourceJson, int dataTypeId, PublishedContentType hostContentType = null) { try @@ -79,6 +104,11 @@ namespace Archetype.Extensions } } + /// + /// Determines whether datatypeId has had it's PVC overridden. + /// + /// The data type identifier. + /// internal bool IsPropertyValueConverterOverridden(int dataTypeId) { var prevalues = GetArchetypePreValueFromDataTypeId(dataTypeId); @@ -88,6 +118,11 @@ namespace Archetype.Extensions return prevalues.OverrideDefaultPropertyValueConverter; } + /// + /// Gets the archetype pre value from data type identifier. + /// + /// The data type identifier. + /// private ArchetypePreValue GetArchetypePreValueFromDataTypeId(int dataTypeId) { return _app.ApplicationCache.RuntimeCache.GetCacheItem( @@ -108,6 +143,11 @@ namespace Archetype.Extensions }) as ArchetypePreValue; } + /// + /// Gets the archetype pre value from pre values collection. + /// + /// The data type pre values. + /// private ArchetypePreValue GetArchetypePreValueFromPreValuesCollection(PreValueCollection dataTypePreValues) { var preValueAsString = dataTypePreValues.PreValuesAsDictionary.First().Value.Value; @@ -115,6 +155,11 @@ namespace Archetype.Extensions return preValue; } + /// + /// Gets the data type by unique identifier. + /// + /// The unique identifier. + /// internal IDataTypeDefinition GetDataTypeByGuid(Guid guid) { return (IDataTypeDefinition)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem( diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypePropertyModelExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypePropertyModelExtensions.cs index c14ee73..2e8532b 100644 --- a/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypePropertyModelExtensions.cs +++ b/app/Umbraco/Umbraco.Archetype/Extensions/ArchetypePropertyModelExtensions.cs @@ -5,13 +5,26 @@ using Umbraco.Core.Models.PublishedContent; namespace Archetype.Extensions { + /// + /// ArchetypePropertyModel extensions. + /// public static class ArchetypePropertyModelExtensions { + /// + /// Determines whether this instance is an archetype. + /// + /// The property. + /// public static bool IsArchetype(this ArchetypePropertyModel prop) { return prop.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditorAlias); } + /// + /// Creates dummy property type. + /// + /// The property. + /// internal static PublishedPropertyType CreateDummyPropertyType(this ArchetypePropertyModel prop) { return new PublishedPropertyType(prop.HostContentType, new PropertyType(new DataTypeDefinition(-1, prop.PropertyEditorAlias) { Id = prop.DataTypeId })); diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs index 5144b02..7606b6a 100644 --- a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs +++ b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs @@ -7,28 +7,67 @@ using Umbraco.Core.Logging; namespace Archetype.Extensions { + /// + /// HtmlHelper extenions used for rendering an Archetype. + /// public static class HtmlHelperExtensions { + /// + /// Renders the archetype partials. + /// + /// The HTML helper. + /// The archetype model. + /// public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel) { return RenderPartials(htmlHelper, archetypeModel, null, null); } + /// + /// Renders the archetype partials. + /// + /// The HTML helper. + /// The archetype model. + /// The partial path. + /// public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath) { return RenderPartials(htmlHelper, archetypeModel, partialPath, null); } + /// + /// Renders the archetype partials. + /// + /// The HTML helper. + /// The archetype model. + /// The view data dictionary. + /// public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, ViewDataDictionary viewDataDictionary) { return RenderPartials(htmlHelper, archetypeModel, null, viewDataDictionary); } + /// + /// Renders the archetype partials. + /// + /// The HTML helper. + /// The archetype model. + /// The partial path. + /// The view data dictionary. + /// public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { return htmlHelper.RenderPartials(archetypeModel, partialPath, viewDataDictionary); } + /// + /// Renders the partials based on the model, partial path and given viewdata dictionary. + /// + /// The HTML helper. + /// The archetype model. + /// The partial path. + /// The view data dictionary. + /// private static IHtmlString RenderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { var context = HttpContext.Current; diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/PropertyEditorExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/PropertyEditorExtensions.cs index 6ec2946..ef2481c 100644 --- a/app/Umbraco/Umbraco.Archetype/Extensions/PropertyEditorExtensions.cs +++ b/app/Umbraco/Umbraco.Archetype/Extensions/PropertyEditorExtensions.cs @@ -5,6 +5,9 @@ using Umbraco.Core.PropertyEditors; namespace Archetype.Extensions { + /// + /// PropertyEditor extensions. + /// public static class PropertyEditorExtensions { /// diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/StringExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/StringExtensions.cs index 47636cb..8dc9783 100644 --- a/app/Umbraco/Umbraco.Archetype/Extensions/StringExtensions.cs +++ b/app/Umbraco/Umbraco.Archetype/Extensions/StringExtensions.cs @@ -1,8 +1,15 @@ namespace Archetype.Extensions { + /// + /// String extensions. + /// public static class StringExtensions { - //lifted from the core as it is marked 'internal' + /// + /// Detects if the input string is JSON. + /// + /// The input. + /// public static bool DetectIsJson(this string input) { input = input.Trim(); diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypeFieldsetModel.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypeFieldsetModel.cs index d89d1e3..215cd78 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypeFieldsetModel.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypeFieldsetModel.cs @@ -6,6 +6,9 @@ using System; namespace Archetype.Models { + /// + /// Model that represents a fieldset stored as content JSON. + /// public class ArchetypeFieldsetModel { [JsonProperty("alias")] @@ -20,6 +23,9 @@ namespace Archetype.Models [JsonProperty("id")] public Guid Id { get; set; } + /// + /// Initializes a new instance of the class. + /// public ArchetypeFieldsetModel() { Properties = new List(); @@ -27,11 +33,22 @@ namespace Archetype.Models #region Helper Methods + /// + /// Gets the value and returns as string. + /// + /// The property alias. + /// public string GetValue(string propertyAlias) { return GetValue(propertyAlias); } + /// + /// Gets the value based on the type passed in as a generic. + /// + /// + /// The property alias. + /// public T GetValue(string propertyAlias) { var property = GetProperty(propertyAlias); @@ -49,6 +66,13 @@ namespace Archetype.Models // however, this would require GetValue(string propertyAlias) to call the common implementation // with a default(T) value, which could in theory result in a performance hit, if T for some reason // is costly to instantiate. + /// + /// Gets the value. + /// + /// + /// The property alias. + /// The default value. + /// public T GetValue(string propertyAlias, T defaultValue) { var property = GetProperty(propertyAlias); @@ -61,16 +85,31 @@ namespace Archetype.Models return property.GetValue(); } + /// + /// Determines whether the property is empty. + /// + /// The property. + /// private bool IsEmptyProperty(ArchetypePropertyModel property) { return (property == null || property.Value == null || string.IsNullOrEmpty(property.Value.ToString())); } + /// + /// Determines whether the specified property alias has property. + /// + /// The property alias. + /// public bool HasProperty(string propertyAlias) { return GetProperty(propertyAlias) != null; } + /// + /// Determines whether the specified property alias has value. + /// + /// The property alias. + /// public bool HasValue(string propertyAlias) { var property = GetProperty(propertyAlias); @@ -80,12 +119,16 @@ namespace Archetype.Models return !string.IsNullOrEmpty(property.Value.ToString()); } + /// + /// Gets the property. + /// + /// The property alias. + /// private ArchetypePropertyModel GetProperty(string propertyAlias) { return Properties.FirstOrDefault(p => p.Alias.InvariantEquals(propertyAlias)); } #endregion - } } diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypeModel.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypeModel.cs index 9e3c512..11a13a1 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypeModel.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypeModel.cs @@ -7,27 +7,44 @@ using Newtonsoft.Json.Linq; namespace Archetype.Models { + /// + /// Model that represents an entire Archetype. + /// [JsonObject] public class ArchetypeModel : IEnumerable { [JsonProperty("fieldsets")] public IEnumerable Fieldsets { get; set; } + /// + /// Initializes a new instance of the class. + /// public ArchetypeModel() { Fieldsets = new List(); } + /// + /// Returns an enumerator that iterates through the collection of fieldsets. + /// + /// + /// An enumerator that can be used to iterate through the collection. + /// public IEnumerator GetEnumerator() { return this.Fieldsets.Where(f => f.Disabled == false).GetEnumerator(); } + //possibly obsolete? IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } + /// + /// Serializes for persistence. This should be used for serialization as it cleans up the JSON before saving. + /// + /// public string SerializeForPersistence() { var json = JObject.Parse(JsonConvert.SerializeObject(this, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs index 3d49e8e..49982d8 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs @@ -4,6 +4,9 @@ using Newtonsoft.Json; namespace Archetype.Models { + /// + /// Model that represents the configured Archetype options. + /// public class ArchetypePreValue { [JsonProperty("showAdvancedOptions")] diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldset.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldset.cs index 0bfd3c8..e97206b 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldset.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldset.cs @@ -3,6 +3,9 @@ using Newtonsoft.Json; namespace Archetype.Models { + /// + /// Model that represents configured Archetype fieldsets. + /// public class ArchetypePreValueFieldset { [JsonProperty("alias")] diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldsetGroup.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldsetGroup.cs index e62e69c..a1c80a4 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldsetGroup.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueFieldsetGroup.cs @@ -2,6 +2,9 @@ using Newtonsoft.Json; namespace Archetype.Models { + /// + /// Model that represents configured groupings of Archetype fieldsets. + /// public class ArchetypePreValueFieldsetGroup { [JsonProperty("name")] diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueProperty.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueProperty.cs index 09cf236..aacad7d 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueProperty.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValueProperty.cs @@ -3,6 +3,9 @@ using Newtonsoft.Json; namespace Archetype.Models { + /// + /// Model that represents a configured property on an Archetype fieldset. + /// public class ArchetypePreValueProperty { [JsonProperty("alias")] diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePropertyModel.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePropertyModel.cs index 52a1e6b..8c1d76f 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePropertyModel.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePropertyModel.cs @@ -9,6 +9,9 @@ using Umbraco.Web; namespace Archetype.Models { + /// + /// Model that represents a stored property in Archetype. + /// public class ArchetypePropertyModel { [JsonProperty("alias")] @@ -33,6 +36,11 @@ namespace Archetype.Models [JsonProperty("hostContentType")] internal PublishedContentType HostContentType { get; set; } + /// + /// Gets the value based on the type given. + /// + /// + /// public T GetValue() { // Try Umbraco's PropertyValueConverters @@ -56,6 +64,13 @@ namespace Archetype.Models return default(T); } + /// + /// Tries to convert the value with property value converters. + /// + /// + /// The value. + /// The converters. + /// private Attempt TryConvertWithPropertyValueConverters(object value, IEnumerable converters) { var properyType = this.CreateDummyPropertyType(); @@ -92,6 +107,9 @@ namespace Archetype.Models return Attempt.Fail(); } + /// + /// Model that represents the current UmbracoEditorState + /// internal class UmbracoEditorState { // container for the names of any files selected for a property in the Umbraco backend diff --git a/app/Umbraco/Umbraco.Archetype/PropertyConverters/ArchetypeValueConverter.cs b/app/Umbraco/Umbraco.Archetype/PropertyConverters/ArchetypeValueConverter.cs index 99e18e1..ddefcce 100644 --- a/app/Umbraco/Umbraco.Archetype/PropertyConverters/ArchetypeValueConverter.cs +++ b/app/Umbraco/Umbraco.Archetype/PropertyConverters/ArchetypeValueConverter.cs @@ -8,15 +8,29 @@ using Umbraco.Core.Services; namespace Archetype.PropertyConverters { + /// + /// Default property value converter that models the JSON to a C# object. + /// [PropertyValueType(typeof(Models.ArchetypeModel))] [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] public class ArchetypeValueConverter : PropertyValueConverterBase { + /// + /// Gets the services. + /// + /// + /// The services. + /// public ServiceContext Services { get { return ApplicationContext.Current.Services; } } + /// + /// Determines whether the specified property type is converter for Archetype. + /// + /// Type of the property. + /// public override bool IsConverter(PublishedPropertyType propertyType) { var isArcheTypePropertyEditor = !String.IsNullOrEmpty(propertyType.PropertyEditorAlias) @@ -27,6 +41,13 @@ namespace Archetype.PropertyConverters return !ArchetypeHelper.Instance.IsPropertyValueConverterOverridden(propertyType.DataTypeId); } + /// + /// Converts the data to source. + /// + /// Type of the property. + /// The source. + /// if set to true [preview]. + /// public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) { var defaultValue = new ArchetypeModel(); diff --git a/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs b/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs index 728d855..7ae82e6 100644 --- a/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs +++ b/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs @@ -15,17 +15,27 @@ using Umbraco.Web.Models.ContentEditing; namespace Archetype.PropertyEditors { + /// + /// C# representation of the property editor. This is often done with package manifest instead. + /// [PropertyEditorAsset(ClientDependencyType.Javascript, "../App_Plugins/Archetype/js/archetype.js")] [PropertyEditor(Constants.PropertyEditorAlias, "Archetype", "../App_Plugins/Archetype/views/archetype.html", ValueType = "JSON")] public class ArchetypePropertyEditor : PropertyEditor { #region Pre Value Editor + /// + /// Creates a pre value editor instance + /// + /// protected override PreValueEditor CreatePreValueEditor() { return new ArchetypePreValueEditor(); } + /// + /// Class that represents the prevalue editor. This is often done with a package manifest instead. + /// internal class ArchetypePreValueEditor : PreValueEditor { [PreValueField("archetypeConfig", "Config", "../App_Plugins/Archetype/views/archetype.config.html", @@ -41,11 +51,18 @@ namespace Archetype.PropertyEditors #region Value Editor + /// + /// Creates a value editor instance + /// + /// protected override PropertyValueEditor CreateValueEditor() { return new ArchetypePropertyValueEditor(base.CreateValueEditor()); } + /// + /// Class that represents the actual data editor. This is often done with a package manifest instead. + /// internal class ArchetypePropertyValueEditor : PropertyValueEditorWrapper { protected JsonSerializerSettings _jsonSettings; @@ -55,6 +72,13 @@ namespace Archetype.PropertyEditors { } + /// + /// Converts the property value for use in the front-end cache + /// + /// + /// + /// + /// public override string ConvertDbToString(Property property, PropertyType propertyType, IDataTypeService dataTypeService) { if(property.Value == null || property.Value.ToString() == "") @@ -85,6 +109,17 @@ namespace Archetype.PropertyEditors return archetype.SerializeForPersistence(); } + /// + /// A method used to format the database value to a value that can be used by the editor + /// + /// + /// + /// + /// + /// + /// The object returned will automatically be serialized into json notation. For most property editors + /// the value returned is probably just a string but in some cases a json structure will be returned. + /// public override object ConvertDbToEditor(Property property, PropertyType propertyType, IDataTypeService dataTypeService) { if(property.Value == null || property.Value.ToString() == "") @@ -114,6 +149,19 @@ namespace Archetype.PropertyEditors return archetype; } + /// + /// A method to deserialize the string value that has been saved in the content editor + /// to an object to be stored in the database. + /// + /// + /// The current value that has been persisted to the database for this editor. This value may be usesful for + /// how the value then get's deserialized again to be re-persisted. In most cases it will probably not be used. + /// + /// + /// By default this will attempt to automatically convert the string value to the value type supplied by ValueType. + /// If overridden then the object returned must match the type supplied in the ValueType, otherwise persisting the + /// value to the DB will fail when it tries to validate the value type. + /// public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) { if(editorValue.Value == null || editorValue.Value.ToString() == "") @@ -175,6 +223,11 @@ namespace Archetype.PropertyEditors return archetype.SerializeForPersistence(); } + /// + /// Gets the property editor. + /// + /// The DTD. + /// internal virtual PropertyEditor GetPropertyEditor(IDataTypeDefinition dtd) { if(dtd.Id != 0)