csharp: Add some docs to MVVM infrastructure

Reviewers: SanghyeonLee, felipealmeida, cedric, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10301
This commit is contained in:
Lauro Moura 2019-10-08 10:04:57 +02:00 committed by Xavi Artigas
parent 4457a93ae5
commit 4867c4bdaf
4 changed files with 36 additions and 11 deletions

View File

@ -9,10 +9,17 @@ using Eina;
namespace Efl { namespace Efl {
/// <summary>Generic <see cref="Efl.IModel" /> implementation for MVVM models based on <see cref="Efl.UserModel&lt;T&gt;" /> /// <summary>
/// Generic <see cref="Efl.IModel" /> helper class to ease manual implementation of C# models.
/// ///
/// Since EFL 1.23. /// <para>It provides an expanded API like async helpers to get children.</para>
///
/// <para>For MVVM-based models, <see cref="Efl.UserModel&lt;T&gt;" /> provides a simpler API.</para>
///
/// <para>Since EFL 1.24.</para>
/// </summary> /// </summary>
/// <typeparam name="T">The type of the child model. It is the type used when adding/removing/getting items to this
/// model.</typeparam>
public class GenericModel<T> : Efl.Object, Efl.IModel, IDisposable public class GenericModel<T> : Efl.Object, Efl.IModel, IDisposable
{ {
private Efl.IModel model; private Efl.IModel model;
@ -78,7 +85,7 @@ public class GenericModel<T> : Efl.Object, Efl.IModel, IDisposable
ModelHelper.SetProperties(o, child); ModelHelper.SetProperties(o, child);
} }
/// <summary>Adds a new childs to the model and returns it.</summary> /// <summary>Adds a new child to the model and returns it.</summary>
public Efl.Object AddChild() public Efl.Object AddChild()
{ {
return model.AddChild(); return model.AddChild();

View File

@ -49,8 +49,8 @@ internal class ModelHelper
/// <summary>Helper class to simplify the creation of MVVM Models based on <see cref="Efl.IModel" />. /// <summary>Helper class to simplify the creation of MVVM Models based on <see cref="Efl.IModel" />.
/// ///
/// <para>This class works together with <see cref="Efl.GenericModel&lt;T&gt;" /> to wrap user defined classes as MVVM models. /// <para>This class enables usage of simple model classes to define the data to be stored in the native model
/// Example:</para> /// and presented in a friendly manner to the C# developer. Example:</para>
/// ///
/// <code> /// <code>
/// public class PersonModel /// public class PersonModel
@ -65,12 +65,18 @@ internal class ModelHelper
/// PersonModel p = await model.GetAtAsync(0); /// PersonModel p = await model.GetAtAsync(0);
/// </code> /// </code>
/// ///
/// Since EFL 1.23. /// <para>Since EFL 1.24.</para>
/// </summary> /// </summary>
/// <typeparam name="T">The enclosed C# model class with the properties to be added to the native model.</typeparam>
[Efl.Eo.BindingEntity] [Efl.Eo.BindingEntity]
public class UserModel<T> : Efl.MonoModelInternal, IDisposable public class UserModel<T> : Efl.MonoModelInternal, IDisposable
{ {
/// <summary>Creates a new model.</summary> /// <summary>
/// Creates a new root model.
///
/// <para>The properties of <code>T</code> will be added to the underlying native model as properties the user can get/set on children
/// of this model.</para>
/// </summary>
/// <param name="parent">The parent of the model.</param> /// <param name="parent">The parent of the model.</param>
public UserModel (Efl.Object parent = null) : base(Efl.MonoModelInternal.efl_mono_model_internal_class_get(), parent) public UserModel (Efl.Object parent = null) : base(Efl.MonoModelInternal.efl_mono_model_internal_class_get(), parent)
{ {
@ -87,9 +93,9 @@ public class UserModel<T> : Efl.MonoModelInternal, IDisposable
Dispose(false); Dispose(false);
} }
/// <summary>Adds a new child to the model wrapping the properites of <c>o</c> /// <summary>Adds a new child to the model wrapping the properties of <c>o</c>
/// ///
/// <para>Reflection is used to instantiate a new <see cref="Efl.IModel" /> for this child and /// <para>Reflection is used to instantiate a new <see cref="Efl.IModel" />-based class for this child and
/// set the mirroring properties correctly.</para> /// set the mirroring properties correctly.</para>
/// </summary> /// </summary>
/// ///

View File

@ -1,10 +1,18 @@
class @beta Efl.Mono_Model_Internal extends Efl.Loop_Consumer implements Efl.Model class @beta Efl.Mono_Model_Internal extends Efl.Loop_Consumer implements Efl.Model
{ {
[[Internal @Efl.Model implementation for the root models in C# MVVM infrastructure.
This represents the root model, containing @Efl.Mono_Model_Internal_Child elements. It is inherited from classes
like the C#-only Efl.UserModel<T>, which the end user will actually instantiate.
]]
methods { methods {
add_property { add_property {
[[Adds a new property to the wrapped children models.
When adding new children models, these children will have the properties that were added from this method.]]
params { params {
@in name: string; @in name: string; [[Name of the property being added.]]
@in type: ptr(const(Eina.Value_Type)); @in type: ptr(const(Eina.Value_Type)); [[Type of the property being added, as an @Eina.Value_Type.]]
} }
} }
} }

View File

@ -1,5 +1,9 @@
class @beta Efl.Mono_Model_Internal_Child extends Efl.Loop_Consumer implements Efl.Model class @beta Efl.Mono_Model_Internal_Child extends Efl.Loop_Consumer implements Efl.Model
{ {
[[Internal @Efl.Model implementation for the actual model data contained in a root @Efl.Mono_Model_Internal.
This model's properties are added through C# reflection on the user-provided model through Efl.GenericModel<T>.
]]
implements { implements {
Efl.Object.constructor; Efl.Object.constructor;
Efl.Object.destructor; Efl.Object.destructor;