Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 :
11 : namespace Cqrs.Repositories.Queries
12 : {
13 : /// <summary>
14 : /// Information about a parameter pass to a function in a <see cref="IQueryStrategy"/>.
15 : /// </summary>
16 : public class QueryParameter : IComparable<QueryParameter>
17 1 : {
18 : /// <summary>
19 : /// Instantiates a new instance of <see cref="QueryParameter"/>
20 : /// </summary>
21 1 : public QueryParameter() { }
22 :
23 : /// <summary>
24 : /// Instantiates a new instance of <see cref="QueryParameter"/>
25 : /// </summary>
26 1 : public QueryParameter(string parameterName, object parameterValue)
27 : {
28 : ParameterName = parameterName;
29 : ParameterValue = parameterValue;
30 : }
31 :
32 : /// <summary>
33 : /// The name of the parameter.
34 : /// </summary>
35 : public string ParameterName { get; set; }
36 :
37 : /// <summary>
38 : /// The value of the parameter.
39 : /// </summary>
40 : public object ParameterValue { get; set; }
41 :
42 : /// <summary>
43 : /// Returns <see cref="ParameterValue"/> cast to <typeparamref name="T"/>.
44 : /// </summary>
45 1 : public T GetParameterValue<T>()
46 : {
47 : return (T) ParameterValue;
48 : }
49 :
50 : #region Implementation of IComparable
51 :
52 : /// <summary>
53 : /// 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.
54 : /// </summary>
55 : /// <returns>
56 : /// 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"/>.
57 : /// </returns>
58 : /// <param name="obj">An object to compare with this instance. </param>
59 : /// <exception cref="T:System.ArgumentException"><paramref name="obj"/> is not the same type as this instance. </exception>
60 1 : public int CompareTo(object obj)
61 : {
62 : var other = obj as QueryParameter;
63 : if (other != null)
64 : return CompareTo(other);
65 : return -1;
66 : }
67 :
68 : #endregion
69 :
70 : #region Implementation of IComparable<in QueryParameter>
71 :
72 : /// <summary>
73 : /// Compares the current object with another object of the same type.
74 : /// </summary>
75 : /// <returns>
76 : /// 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"/>.
77 : /// </returns>
78 : /// <param name="other">An object to compare with this object.</param>
79 1 : public int CompareTo(QueryParameter other)
80 : {
81 : return string.Compare(ParameterName, other.ParameterName, StringComparison.Ordinal);
82 : }
83 :
84 : #endregion
85 : }
86 : }
|