initial commit
[CPE_learningsite] / CPE / CPE.App / CPE.App.Notify / Models / Partials / PartialClass.cs
1 /*
2 Developer: Tyler Allen
3 Date Created: 08/24/2016
4 ---------------------------------------------------
5 */
6
7 using System.Linq;
8 using System.Text;
9
10 namespace CPE.App.Notify.Models.Partials {
11     /// <summary>
12     ///     This base class is used to override the ToString() method.
13     ///     ToString() will output all properties and their values.
14     /// </summary>
15     public class PartialBaseClass {
16         public override string ToString() {
17             var output = new StringBuilder();
18
19             var currentType = GetType();
20             var properties = currentType.GetProperties()
21                                         .Where(x => !x.PropertyType.IsClass)
22                                         .OrderBy(x => x.Name);
23             foreach (var property in properties) {
24                 output.AppendFormat("{0}={1}, ", property.Name, property.GetValue(this, null));
25             }
26
27             return output.ToString();
28         }
29     }
30 }