Skip to content

Commit

Permalink
Removed the non-working lambda validation attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkendk committed Jul 25, 2020
1 parent 9e97882 commit 5bef982
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions Ceen.Database/ValidationSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,35 +130,36 @@ public abstract class ValidationBaseAttribute : Attribute
public abstract void Validate(object value);
}

/// <summary>
/// Rule checking with a function
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
public class FunctionRuleAttribute : ValidationBaseAttribute
{
/// <summary>
/// The method to invoke
/// </summary>
private readonly Action<object> m_method;
// This is not possible because the constructor cannot take a the Action<object> argument (CS0181)
// /// <summary>
// /// Rule checking with a function
// /// </summary>
// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
// public class FunctionRuleAttribute : ValidationBaseAttribute
// {
// /// <summary>
// /// The method to invoke
// /// </summary>
// private readonly Action<object> m_method;

/// <summary>
/// Constructs a new function based rule
/// </summary>
/// <param name="method">The function used to validate the parameter</param>
public FunctionRuleAttribute(Action<object> method)
{
m_method = method ?? throw new ArgumentNullException(nameof(method));
}
// /// <summary>
// /// Constructs a new function based rule
// /// </summary>
// /// <param name="method">The function used to validate the parameter</param>
// public FunctionRuleAttribute(Action<object> method)
// {
// m_method = method ?? throw new ArgumentNullException(nameof(method));
// }

/// <summary>
/// Validates a value by invoking the function
/// </summary>
/// <param name="value">The value to validate</param>
public override void Validate(object value)
{
m_method(value);
}
}
// /// <summary>
// /// Validates a value by invoking the function
// /// </summary>
// /// <param name="value">The value to validate</param>
// public override void Validate(object value)
// {
// m_method(value);
// }
// }


/// <summary>
Expand Down

0 comments on commit 5bef982

Please sign in to comment.