CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
DecoratedRuleArgs.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DecoratedRuleArgs.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Provides the DecoratedRuleArgs base class for CSLA 3.x rule engine</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using Csla.Rules;
12
13#if (ANDROID || IOS)
14using Uri = Csla.Utilities;
15#endif
16
17namespace Csla.Validation
18{
24 {
25 private Dictionary<string, object> _decorations;
26
27 #region Base Constructors
28
33 public DecoratedRuleArgs(string propertyName)
34 : base(propertyName)
35 {
36 _decorations = new Dictionary<string, object>();
37 }
38
43 public DecoratedRuleArgs(Core.IPropertyInfo propertyInfo)
44 : base(propertyInfo)
45 {
46 _decorations = new Dictionary<string, object>();
47 }
48
56 public DecoratedRuleArgs(string propertyName, string friendlyName)
57 : base(propertyName, friendlyName)
58 {
59 _decorations = new Dictionary<string, object>();
60 }
61
80 public DecoratedRuleArgs(string propertyName, RuleSeverity severity)
81 : base(propertyName, severity)
82 {
83 _decorations = new Dictionary<string, object>();
84 }
85
104 public DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity)
105 : base(propertyInfo, severity)
106 {
107 _decorations = new Dictionary<string, object>();
108 }
109
131 public DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity)
132 : base(propertyName, friendlyName, severity)
133 {
134 _decorations = new Dictionary<string, object>();
135 }
136
159 public DecoratedRuleArgs(string propertyName, RuleSeverity severity, bool stopProcessing)
160 : base(propertyName, severity, stopProcessing)
161 {
162 _decorations = new Dictionary<string, object>();
163 }
164
187 public DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity, bool stopProcessing)
188 : base(propertyInfo, severity, stopProcessing)
189 {
190 _decorations = new Dictionary<string, object>();
191 }
192
218 public DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity, bool stopProcessing)
219 : base(propertyName, friendlyName, severity, stopProcessing)
220 {
221 _decorations = new Dictionary<string, object>();
222 }
223
224 #endregion
225
232 public DecoratedRuleArgs(string propertyName, Dictionary<string, object> args)
233 : base(propertyName)
234 {
235 _decorations = args;
236 }
237
244 public DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, Dictionary<string, object> args)
245 : base(propertyInfo)
246 {
247 _decorations = args;
248 }
249
259 public DecoratedRuleArgs(string propertyName, string friendlyName, Dictionary<string, object> args)
260 : base(propertyName, friendlyName)
261 {
262 _decorations = args;
263 }
264
285 public DecoratedRuleArgs(string propertyName, RuleSeverity severity, Dictionary<string, object> args)
286 : base(propertyName, severity)
287 {
288 _decorations = args;
289 }
290
311 public DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity, Dictionary<string, object> args)
312 : base(propertyInfo, severity)
313 {
314 _decorations = args;
315 }
316
340 public DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity, Dictionary<string, object> args)
341 : base(propertyName, friendlyName, severity)
342 {
343 _decorations = args;
344 }
345
370 public DecoratedRuleArgs(string propertyName, RuleSeverity severity, bool stopProcessing, Dictionary<string, object> args)
371 : base(propertyName, severity, stopProcessing)
372 {
373 _decorations = args;
374 }
375
400 public DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity, bool stopProcessing, Dictionary<string, object> args)
401 : base(propertyInfo, severity, stopProcessing)
402 {
403 _decorations = args;
404 }
405
433 public DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity, bool stopProcessing, Dictionary<string, object> args)
434 : base(propertyName, friendlyName, severity, stopProcessing)
435 {
436 _decorations = args;
437 }
438
445 public object this[string key]
446 {
447 get
448 {
449 object result = null;
450 if (_decorations.TryGetValue(key, out result))
451 return result;
452 else
453 return null;
454 }
455 set
456 {
457 _decorations[key] = value;
458 }
459 }
460
466 public override string ToString()
467 {
468 StringBuilder sb = new StringBuilder();
469 sb.Append(base.ToString());
470 if (_decorations.Count > 0)
471 {
472 sb.Append("?");
473 bool first = true;
474 foreach (System.Collections.Generic.KeyValuePair<string, object> item in _decorations)
475 {
476 if (first)
477 first = false;
478 else
479 sb.Append("&");
480 if (item.Key != null)
481 {
482 var itemString = Uri.EscapeDataString(item.Key);
483 string valueString;
484 if (item.Value == null)
485 valueString = string.Empty;
486 else
487 valueString = Uri.EscapeDataString(item.Value.ToString());
488 sb.AppendFormat("{0}={1}", itemString, valueString);
489 }
490 }
491 }
492 return sb.ToString();
493 }
494 }
495}
Object providing extra information to methods that implement business rules.
DecoratedRuleArgs(string propertyName)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity, bool stopProcessing, Dictionary< string, object > args)
Creates an instance of RuleArgs.
override string ToString()
Return a string representation of the object using the rule:// URI format.
DecoratedRuleArgs(string propertyName, string friendlyName)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, RuleSeverity severity, bool stopProcessing, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity, bool stopProcessing)
Creates an instance of RuleArgs.
DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, RuleSeverity severity, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, string friendlyName, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, string friendlyName, RuleSeverity severity, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, RuleSeverity severity)
Creates an instance of RuleArgs.
DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity, bool stopProcessing)
Creates an instance of RuleArgs.
DecoratedRuleArgs(Core.IPropertyInfo propertyInfo, RuleSeverity severity, bool stopProcessing, Dictionary< string, object > args)
Creates an instance of RuleArgs.
DecoratedRuleArgs(Core.IPropertyInfo propertyInfo)
Creates an instance of RuleArgs.
DecoratedRuleArgs(string propertyName, RuleSeverity severity, bool stopProcessing)
Creates an instance of RuleArgs.
Object providing extra information to methods that implement business rules.
Definition: RuleArgs.cs:22
RuleSeverity
Values for validation rule severities.
Definition: RuleSeverity.cs:16