//------------------------------------------------------------------------------ // // This code was generated by a tool. // Tango Observables Generator // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. Do not modify! // //------------------------------------------------------------------------------ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Xml.Serialization; using Newtonsoft.Json; using System.Linq; using Tango.DAL.Remote.DB; using Tango.Core; using System.ComponentModel; using Tango.Core.CustomAttributes; namespace Tango.BL.Entities { @if (Model.Description != null) {
/// /// @(Model.Description) ///
} [Table("@(Model.TableName)")] public abstract class @(Model.Name) : ObservableEntity<@(Model.Name.Replace("Base",""))> { @foreach (var prop in Model.Fields) { if (!prop.Name.EndsWith("Guid")) {
public event EventHandler<@(prop.Type)> @(prop.Name)Changed;
} } @foreach (var prop in Model.Fields) {
protected @(prop.Type) _@(prop.Name.ToLower()); @if (prop.DbDescription != null) {
/// @(prop.DbDescription) ///
} else {
/// /// Gets or sets the @(Model.Name.ToLower()) @(prop.Description). ///
} @(!prop.Construct && !prop.Complex ? "[Column(\"" + prop.FieldName + "\")]" : "") @(prop.IsForeignKey ? "[ForeignKey(\"" + prop.ForeignKeyName + "\")]" : "") @(prop.XmlIgnore ? "[XmlIgnore]" : "") @(prop.XmlIgnore ? "[JsonIgnore]" : "") @if (prop.PropertyExtension != null) { if (prop.PropertyExtension.HasDescription) {
[Description("@(prop.PropertyExtension.Description)")]
} if (prop.PropertyExtension.HasRange) {
[Range(@(prop.PropertyExtension.Min),@(prop.PropertyExtension.Max))]
} if (prop.PropertyExtension.HasStringFormat) {
[StringFormat("@(prop.PropertyExtension.StringFormat)")]
} if (prop.PropertyExtension.HasIndex) {
[PropertyIndex(@(prop.PropertyExtension.Index))]
} } public @(prop.Construct || prop.Complex ? "virtual" : "") @(prop.Type) @(prop.Name) { get { return _@(prop.Name.ToLower()); } set { if (_@(prop.Name.ToLower()) != value) { _@(prop.Name.ToLower()) = value; @if (prop.Complex) {
if (@(prop.Name) != null) { @(prop.Name)Guid = @(prop.Name).Guid; }
} @if (!prop.Name.EndsWith("Guid")) {
On@(prop.Name)Changed(value);
} } } }
} @foreach (var prop in Model.Fields) { if (!prop.Name.EndsWith("Guid")) {
/// /// Called when the @(prop.Name) has changed. /// protected virtual void On@(prop.Name)Changed(@(prop.Type) @(prop.Name.ToLower())) { @(prop.Name)Changed?.Invoke(this, @(prop.Name.ToLower())); RaisePropertyChanged(nameof(@(prop.Name))); }
} } /// /// Initializes a new instance of the class. /// public @(Model.Name)() : base() { @foreach (var prop in Model.Fields) { if (prop.Construct) {
@(prop.Name) = new @(prop.Type)();
} } } } }