From: Griffin C. <gc...@us...> - 2006-06-06 03:07:29
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6076/DotNetMock/Dynamic/Predicates Modified Files: AbstractPredicate.cs IsIn.cs IsMatch.cs IsTypeOf.cs Predicate.cs Log Message: - Initial conversion to .NET 2.0 and VIsual Studio 2005 Index: IsTypeOf.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsTypeOf.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IsTypeOf.cs 20 Feb 2005 09:26:49 -0000 1.4 --- IsTypeOf.cs 6 Jun 2006 03:06:52 -0000 1.5 *************** *** 1,46 **** #region License // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. #endregion #region Imports using System; #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that evaluates the input value against the expected <see cref="Type"/> ! /// </summary> ! public class IsTypeOf : AbstractPredicate ! { ! private Type _type; ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="type">type to evaluate against</param> ! public IsTypeOf(Type type) ! { ! this._type = type; ! } ! /// <summary> ! /// Evaluates the input value to verify that it is correctly typed. ! /// </summary> ! /// <param name="currentValue">input value</param> ! /// <returns>True if the original type is assignable from the input value, false otherwise.</returns> ! public override bool Eval(object currentValue) ! { ! return currentValue == null ? false : _type.IsAssignableFrom(currentValue.GetType()); ! } ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} is a {1}", ! name, ! _type.FullName ! ); ! } ! } ! } --- 1,54 ---- #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; + #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that evaluates the input value against the expected <see cref="Type"/> ! /// </summary> ! public class IsTypeOf : AbstractPredicate ! { ! private Type _type; ! ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="type">type to evaluate against</param> ! public IsTypeOf(Type type) ! { ! _type = type; ! } ! ! /// <summary> ! /// Evaluates the input value to verify that it is correctly typed. ! /// </summary> ! /// <param name="currentValue">input value</param> ! /// <returns>True if the original type is assignable from the input value, false otherwise.</returns> ! public override bool Eval(object currentValue) ! { ! return currentValue == null ? false : _type.IsAssignableFrom(currentValue.GetType()); ! } ! ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} is a {1}", ! name, ! _type.FullName ! ); ! } ! } ! } \ No newline at end of file Index: IsMatch.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsMatch.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IsMatch.cs 20 Feb 2005 09:26:49 -0000 1.4 --- IsMatch.cs 6 Jun 2006 03:06:52 -0000 1.5 *************** *** 1,58 **** #region License // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. #endregion #region Imports using System; using System.Text.RegularExpressions; #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that compares the input value against an regular expression pattern. ! /// </summary> ! public class IsMatch : AbstractPredicate ! { ! private Regex _regex; ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="regex">Regular expression object to use.</param> ! public IsMatch(Regex regex) ! { ! this._regex = regex; ! } ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="regex">Regular expression pattern to use.</param> ! public IsMatch(String regex) : this(new Regex(regex)) {} ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="regex">Regular expression pattern to use.</param> ! /// <param name="ignoreCase">Flag indicating if the regular expression object should ignore case or not.</param> ! public IsMatch(String regex, bool ignoreCase) : this(new Regex(regex, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None)) {} ! /// <summary> ! /// Evaluates the input value against the provided regular expression ! /// </summary> ! /// <param name="inputValue">input value</param> ! /// <returns>True if the regular expression matches the input value, flase otherwise.</returns> ! public override bool Eval(object inputValue) ! { ! return inputValue == null ? false : _regex.IsMatch(inputValue.ToString()); ! } ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} matches /{1}/", ! name, ! _regex ! ); ! } ! } ! } --- 1,73 ---- #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; using System.Text.RegularExpressions; + #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that compares the input value against an regular expression pattern. ! /// </summary> ! public class IsMatch : AbstractPredicate ! { ! private Regex _regex; ! ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="regex">Regular expression object to use.</param> ! public IsMatch(Regex regex) ! { ! _regex = regex; ! } ! ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="regex">Regular expression pattern to use.</param> ! public IsMatch(String regex) : this(new Regex(regex)) ! { ! } ! ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="regex">Regular expression pattern to use.</param> ! /// <param name="ignoreCase">Flag indicating if the regular expression object should ignore case or not.</param> ! public IsMatch(String regex, bool ignoreCase) ! : this(new Regex(regex, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None)) ! { ! } ! ! /// <summary> ! /// Evaluates the input value against the provided regular expression ! /// </summary> ! /// <param name="inputValue">input value</param> ! /// <returns>True if the regular expression matches the input value, flase otherwise.</returns> ! public override bool Eval(object inputValue) ! { ! return inputValue == null ? false : _regex.IsMatch(inputValue.ToString()); ! } ! ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} matches /{1}/", ! name, ! _regex ! ); ! } ! } ! } \ No newline at end of file Index: IsIn.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/IsIn.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IsIn.cs 20 Feb 2005 09:26:49 -0000 1.4 --- IsIn.cs 6 Jun 2006 03:06:52 -0000 1.5 *************** *** 1,64 **** #region License // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. #endregion #region Imports - using System; using DotNetMock.Util; #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that looks for an input value in an array of values. ! /// </summary> ! public class IsIn : AbstractPredicate ! { ! private object[] _inList; ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="inList">array of values to use for searching</param> ! public IsIn(params object[] inList) ! { ! if (inList.Length == 1 && inList[0].GetType().IsArray) ! { ! Array arr = (Array)inList[0]; ! this._inList = new object[arr.Length]; ! arr.CopyTo(this._inList, 0); ! } ! else ! { ! this._inList = inList; ! } ! } ! /// <summary> ! /// Evaluates the input value by looking within the original array list of values for the input value. ! /// </summary> ! /// <param name="inputValue">input value to look for</param> ! /// <returns>True if the input value is found, false otherwise.</returns> ! public override bool Eval(object inputValue) ! { ! foreach (object o in _inList) ! { ! if (o.Equals(inputValue)) ! { ! return true; ! } ! } ! return false; ! } ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} is in [{1}]", ! name, ! StringUtils.FormatArray(_inList) ! ); ! } ! } ! } --- 1,71 ---- #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. + #endregion + #region Imports + using System; using DotNetMock.Util; + #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that looks for an input value in an array of values. ! /// </summary> ! public class IsIn : AbstractPredicate ! { ! private object[] _inList; ! ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="inList">array of values to use for searching</param> ! public IsIn(params object[] inList) ! { ! if (inList.Length == 1 && inList[0].GetType().IsArray) ! { ! Array arr = (Array) inList[0]; ! _inList = new object[arr.Length]; ! arr.CopyTo(_inList, 0); ! } ! else ! { ! _inList = inList; ! } ! } ! ! /// <summary> ! /// Evaluates the input value by looking within the original array list of values for the input value. ! /// </summary> ! /// <param name="inputValue">input value to look for</param> ! /// <returns>True if the input value is found, false otherwise.</returns> ! public override bool Eval(object inputValue) ! { ! foreach (object o in _inList) ! { ! if (o.Equals(inputValue)) ! { ! return true; ! } ! } ! return false; ! } ! ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! public override string ExpressionAsText(string name) ! { ! return String.Format( ! "{0} is in [{1}]", ! name, ! StringUtils.FormatArray(_inList) ! ); ! } ! } ! } \ No newline at end of file Index: Predicate.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/Predicate.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Predicate.cs 20 Feb 2005 09:26:49 -0000 1.4 --- Predicate.cs 6 Jun 2006 03:06:52 -0000 1.5 *************** *** 1,32 **** namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that accepts a reference to the a delegate instance that performs the evaluation. ! /// </summary> ! public class Predicate : AbstractPredicate ! { ! /// <summary> ! /// Delegate that will perform the evaluation of the input value. ! /// </summary> ! public delegate bool EvaluationMethod(object currentValue); ! ! private EvaluationMethod _evaluationMethod; ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="m">Delegate Reference</param> ! public Predicate(EvaluationMethod m) ! { ! this._evaluationMethod = m; ! } ! /// <summary> ! /// Evaluates the input value using the delegate method supplied. ! /// </summary> ! /// <param name="currentValue">input value</param> ! /// <returns>The results of the delegation methods evaluation</returns> ! public override bool Eval(object currentValue) ! { ! return _evaluationMethod(currentValue); ! } ! } ! } --- 1,34 ---- namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// <see cref="IPredicate"/> that accepts a reference to the a delegate instance that performs the evaluation. ! /// </summary> ! public class Predicate : AbstractPredicate ! { ! /// <summary> ! /// Delegate that will perform the evaluation of the input value. ! /// </summary> ! public delegate bool EvaluationMethod(object currentValue); ! ! private EvaluationMethod _evaluationMethod; ! ! /// <summary> ! /// Default Constructor ! /// </summary> ! /// <param name="m">Delegate Reference</param> ! public Predicate(EvaluationMethod m) ! { ! _evaluationMethod = m; ! } ! ! /// <summary> ! /// Evaluates the input value using the delegate method supplied. ! /// </summary> ! /// <param name="currentValue">input value</param> ! /// <returns>The results of the delegation methods evaluation</returns> ! public override bool Eval(object currentValue) ! { ! return _evaluationMethod(currentValue); ! } ! } ! } \ No newline at end of file Index: AbstractPredicate.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/Predicates/AbstractPredicate.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractPredicate.cs 20 Feb 2005 09:26:49 -0000 1.1 --- AbstractPredicate.cs 6 Jun 2006 03:06:52 -0000 1.2 *************** *** 1,46 **** #region License // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. ! #endregion ! #region Imports ! using System; ! using System.Collections; #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// Abstract base class for all predicates. ! /// </summary> ! public abstract class AbstractPredicate : IPredicate ! { ! /// <summary> ! /// Evaluates whether input value satisfies this predicate. ! /// </summary> ! /// <param name="inputValue">input value</param> ! /// <returns>true if the predicate was satisfied</returns> ! public abstract bool Eval(object inputValue); ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! /// <param name="name"> ! /// name of value/variable to use in the expression text ! /// </param> ! /// <returns>text representation of this predicate</returns> ! public virtual string ExpressionAsText(string name) ! { ! return "(N/A)"; ! } ! /// <summary> ! /// Returns a <see cref="String"/> that represents the ! /// expression evaluated by this <see cref="IPredicate"/>. ! /// </summary> ! /// <returns> ! /// Expression evaluated by this predicate. ! /// </returns> ! public override string ToString() ! { ! return ExpressionAsText("value"); ! } ! } ! } --- 1,46 ---- #region License + // Copyright (c) 2004 Griffin Caprio & Choy Rim. All rights reserved. ! #endregion namespace DotNetMock.Dynamic.Predicates { ! /// <summary> ! /// Abstract base class for all predicates. ! /// </summary> ! public abstract class AbstractPredicate : IPredicate ! { ! /// <summary> ! /// Evaluates whether input value satisfies this predicate. ! /// </summary> ! /// <param name="inputValue">input value</param> ! /// <returns>true if the predicate was satisfied</returns> ! public abstract bool Eval(object inputValue); ! ! /// <summary> ! /// Text representation of what is evaluated by the ! /// <see cref="Eval"/> method. ! /// </summary> ! /// <param name="name"> ! /// name of value/variable to use in the expression text ! /// </param> ! /// <returns>text representation of this predicate</returns> ! public virtual string ExpressionAsText(string name) ! { ! return "(N/A)"; ! } ! ! /// <summary> ! /// Returns a <see cref="string"/> that represents the ! /// expression evaluated by this <see cref="IPredicate"/>. ! /// </summary> ! /// <returns> ! /// Expression evaluated by this predicate. ! /// </returns> ! public override string ToString() ! { ! return ExpressionAsText("value"); ! } ! } ! } \ No newline at end of file |