CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Person.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="Person.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using Csla;
13
15{
17 public partial class Person : BusinessBase<Person>
18 {
19 static Person() { }
20
21 public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(
22 typeof(Person),
23 new PropertyInfo<string>("Name"));
24
25 public static readonly PropertyInfo<DateTime> BirthdateProperty = RegisterProperty<DateTime>(
26 typeof(Person),
27 new PropertyInfo<DateTime>("Birthdate"));
28
29 public static readonly PropertyInfo<AddressList> AddressesProperty = RegisterProperty<AddressList>(
30 typeof(Person),
31 new PropertyInfo<AddressList>("Addresses"));
32
33 public static readonly PropertyInfo<Address> PrimaryAddressProperty = RegisterProperty<Address>(
34 typeof(Person),
35 new PropertyInfo<Address>("PrimaryAddress"));
36
37 public string Name
38 {
39 get { return GetProperty<string>(NameProperty); }
40 set { SetProperty<string>(NameProperty, value); }
41 }
42
43 public DateTime Birthdate
44 {
45 get { return GetProperty<DateTime>(BirthdateProperty); }
46 set { SetProperty<DateTime>(BirthdateProperty, value); }
47 }
48
49 public int Age
50 {
51 get { return (DateTime.Now - Birthdate).Days / 365; }
52 set { Birthdate = DateTime.Now - new TimeSpan(value * 365, 0, 0, 0); }
53 }
54
55 [NonSerialized]
56 private string mUnserialized = "";
57 public string Unserialized
58 {
59 get { return mUnserialized; }
60 set { mUnserialized = value; }
61 }
62
64 {
65 get { return GetProperty<AddressList>(AddressesProperty); }
66 set { SetProperty<AddressList>(AddressesProperty, value); }
67 }
68
69 public DateTime GetBDate()
70 {
71 return GetProperty<DateTime>(BirthdateProperty);
72 }
73
74 private static PropertyInfo<DateTimeOffset> DtoDateProperty = RegisterProperty<DateTimeOffset>(c => c.DtoDate, "DateTimeOffset date");
75 public DateTimeOffset DtoDate
76 {
77 get { return GetProperty(DtoDateProperty); }
78 set { SetProperty(DtoDateProperty, value); }
79 }
80
82 {
83 get { return GetProperty<Address>(PrimaryAddressProperty); }
84 set { SetProperty<Address>(PrimaryAddressProperty, value); }
85 }
86 }
87}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
static readonly PropertyInfo< AddressList > AddressesProperty
Definition: Person.cs:29
static readonly PropertyInfo< DateTime > BirthdateProperty
Definition: Person.cs:25
static readonly PropertyInfo< Address > PrimaryAddressProperty
Definition: Person.cs:33
static readonly PropertyInfo< string > NameProperty
Definition: Person.cs:21
@ Serializable
Prevents updating or inserting until the transaction is complete.