Line data Source code
1 : using System;
2 :
3 : namespace Cqrs.Repositories.Queries
4 : {
5 : public class QueryParameter : IComparable<QueryParameter>
6 0 : {
7 0 : public QueryParameter() { }
8 :
9 0 : public QueryParameter(string parameterName, object parameterValue)
10 : {
11 : ParameterName = parameterName;
12 : ParameterValue = parameterValue;
13 : }
14 :
15 : public string ParameterName { get; set; }
16 :
17 : public object ParameterValue { get; set; }
18 :
19 0 : public T GetParameterValue<T>()
20 : {
21 : return (T) ParameterValue;
22 : }
23 :
24 : #region Implementation of IComparable
25 :
26 : /// <summary>
27 : /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
28 : /// </summary>
29 : /// <returns>
30 : /// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than <paramref name="obj"/>. Zero This instance is equal to <paramref name="obj"/>. Greater than zero This instance is greater than <paramref name="obj"/>.
31 : /// </returns>
32 : /// <param name="obj">An object to compare with this instance. </param>
33 : /// <exception cref="T:System.ArgumentException"><paramref name="obj"/> is not the same type as this instance. </exception>
34 1 : public int CompareTo(object obj)
35 : {
36 : var other = obj as QueryParameter;
37 : if (other != null)
38 : return CompareTo(other);
39 : return -1;
40 : }
41 :
42 : #endregion
43 :
44 : #region Implementation of IComparable<in QueryParameter>
45 :
46 : /// <summary>
47 : /// Compares the current object with another object of the same type.
48 : /// </summary>
49 : /// <returns>
50 : /// A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
51 : /// </returns>
52 : /// <param name="other">An object to compare with this object.</param>
53 1 : public int CompareTo(QueryParameter other)
54 : {
55 : return System.String.Compare(ParameterName, other.ParameterName, StringComparison.Ordinal);
56 : }
57 :
58 : #endregion
59 : }
60 : }
|