Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.ComponentModel;
  6.  
  7. /// <summary>
  8. /// Summary description for BusinessObjectBase
  9. /// </summary>
  10. public class BusinessObjectBase : IDataErrorInfo
  11. {
  12.     private Dictionary<string, string> _validationErrors;
  13.  
  14.     protected Dictionary<string, string> ValidationErrors
  15.     {
  16.         get
  17.         {
  18.             return this._validationErrors ?? (this._validationErrors = new Dictionary<string, string>());
  19.         }
  20.     }
  21.  
  22.    
  23.     public BusinessObjectBase()
  24.     {
  25.         //
  26.         // TODO: Add constructor logic here
  27.         //
  28.     }
  29.  
  30.     public bool IsValid
  31.     {
  32.         get { return this.ValidationErrors.Count == 0; }
  33.     }
  34.  
  35.     public string Error
  36.     {
  37.         get
  38.         {
  39.             return !this.IsValid ? "Objektets tillstånd är ogiltigt." : null;
  40.         }
  41.     }
  42.  
  43.  
  44.     public string this[string propertyName]
  45.     {
  46.         get
  47.         {
  48.  
  49.             string error;
  50.             if (this.ValidationErrors.TryGetValue(propertyName, out error))
  51.             {
  52.  
  53.                 return error;
  54.             }
  55.  
  56.             return null;
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement