/// <summary> /// Adds a new <see cref="QueryParameter"/> to the collection. /// </summary> /// <param name="parameterName">The <see cref="QueryParameter.Name"/> of the new parameter. Must not be <see langword="null"/>.</param> /// <param name="parameterValue">The <see cref="QueryParameter.Value"/> of the new parameter.</param> /// <param name="parameterType">The <see cref="QueryParameterType"/> of the new parameter.</param> /// <exception cref="System.ArgumentNullException"><paramref name="parameterName"/> is <see langword="null"/>.</exception> /// <exception cref="System.ArgumentException"><paramref name="parameterName"/> is an empty string.</exception> /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="parameterType"/> is not a valid enum value.</exception> public void Add(string parameterName, object parameterValue, QueryParameterType parameterType) { ArgumentUtility.CheckNotNullOrEmpty("parameterName", parameterName); ArgumentUtility.CheckValidEnumValue("parameterType", parameterType); Add(new QueryParameter(parameterName, parameterValue, parameterType)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="value">The enum value that should be the undefined value. Must not be <see langword="null"/>.</param> public UndefinedEnumValueAttribute(object value) { ArgumentUtility.CheckNotNullAndType <Enum> ("value", value); ArgumentUtility.CheckValidEnumValue("value", (Enum)value); _value = value; }
/// <summary> /// Initializes a new instance of the <see cref="RegexAssemblyLoaderFilter"/> class. /// </summary> /// <param name="matchExpression">The expression to match against the assembly name.</param> /// <param name="matchTarget">Specifies whether to match the full names or the simple names of assemblies against the /// <paramref name="matchExpression"/>.</param> public RegexAssemblyLoaderFilter(Regex matchExpression, MatchTargetKind matchTarget) { ArgumentUtility.CheckNotNull("matchExpression", matchExpression); ArgumentUtility.CheckValidEnumValue("matchTarget", matchTarget); _matchExpression = matchExpression; _matchTarget = matchTarget; }
/// <summary> /// Initializes a new instance of the <see cref="QueryParameter"/> class. /// </summary> /// <param name="name">The name of the parameter. Must not be <see langword="null"/>.</param> /// <param name="value">The value of the parameter.</param> /// <param name="parameterType">The <see cref="QueryParameterType"/> of the parameter.</param> /// <exception cref="System.ArgumentNullException"><paramref name="name"/> is <see langword="null"/>.</exception> /// <exception cref="System.ArgumentException"><paramref name="name"/> is an empty string.</exception> /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="parameterType"/> is not a valid enum value.</exception> public QueryParameter(string name, object value, QueryParameterType parameterType) { ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckValidEnumValue("parameterType", parameterType); _name = name; _value = value; _parameterType = parameterType; }
public virtual IDataReader ExecuteReader(IDbCommand command, CommandBehavior behavior) { CheckDisposed(); ArgumentUtility.CheckNotNull("command", command); ArgumentUtility.CheckValidEnumValue("behavior", behavior); try { return(command.ExecuteReader(behavior)); } catch (Exception e) { throw CreateRdbmsProviderException(e, "Error while executing SQL command: " + e.Message); } }
// methods and properties public DataContainerCollection GetByState(StateType state) { ArgumentUtility.CheckValidEnumValue("state", state); DataContainerCollection collection = new DataContainerCollection(); foreach (DataContainer dataContainer in this) { if (dataContainer.State == state) { collection.Add(dataContainer); } } return(collection); }
public VirtualRelationEndPointDefinition( ClassDefinition classDefinition, string propertyName, bool isMandatory, CardinalityType cardinality, string sortExpressionText, IPropertyInformation propertyInfo) { ArgumentUtility.CheckNotNull("classDefinition", classDefinition); ArgumentUtility.CheckNotNullOrEmpty("propertyName", propertyName); ArgumentUtility.CheckValidEnumValue("cardinality", cardinality); ArgumentUtility.CheckNotNull("propertyInfo", propertyInfo); _classDefinition = classDefinition; _cardinality = cardinality; _isMandatory = isMandatory; _propertyName = propertyName; _sortExpressionText = sortExpressionText; _sortExpression = new DoubleCheckedLockingContainer <SortExpressionDefinition> (() => ParseSortExpression(_sortExpressionText)); _propertyInfo = propertyInfo; }
/// <summary> /// Initializes a new instance of the <b>QueryDefinition</b> class. /// </summary> /// <param name="queryID">The <paramref name="queryID"/> to be associated with this <b>QueryDefinition</b>. Must not be <see langword="null"/>.</param> /// <param name="storageProviderDefinition">The <see cref="StorageProviderDefinition"/> used for executing instances of this <b>QueryDefinition</b>. Must not be <see langword="null"/>.</param> /// <param name="statement">The <paramref name="statement"/> of the <b>QueryDefinition</b>. The <see cref="Remotion.Data.DomainObjects.Persistence.StorageProvider"/> specified through <paramref name="storageProviderDefinition"/> must understand the syntax of the <paramref name="statement"/>. Must not be <see langword="null"/>.</param> /// <param name="queryType">One of the <see cref="QueryType"/> enumeration constants.</param> /// <param name="collectionType">If <paramref name="queryType"/> specifies a collection to be returned, <paramref name="collectionType"/> specifies the type of the collection. If <paramref name="queryType"/> is <see langword="null"/>, <see cref="DomainObjectCollection"/> is used.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="queryID"/> is <see langword="null"/>.<br /> -or- <br /> /// <paramref name="storageProviderDefinition"/> is <see langword="null"/>.<br /> -or- <br /> /// <paramref name="statement"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="queryID"/> is an empty string.<br /> -or- <br /> /// <paramref name="statement"/> is an empty string. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="queryType"/> is not a valid enum value.</exception> public QueryDefinition( string queryID, StorageProviderDefinition storageProviderDefinition, string statement, QueryType queryType, Type collectionType) { ArgumentUtility.CheckNotNullOrEmpty("queryID", queryID); ArgumentUtility.CheckNotNull("storageProviderDefinition", storageProviderDefinition); ArgumentUtility.CheckNotNullOrEmpty("statement", statement); ArgumentUtility.CheckValidEnumValue("queryType", queryType); if (queryType == QueryType.Scalar && collectionType != null) { throw new ArgumentException(string.Format("The scalar query '{0}' must not specify a collectionType.", queryID), "collectionType"); } if (queryType == QueryType.Collection && collectionType == null) { collectionType = typeof(DomainObjectCollection); } if (collectionType != null && !collectionType.Equals(typeof(DomainObjectCollection)) && !collectionType.IsSubclassOf(typeof(DomainObjectCollection))) { throw new ArgumentException(string.Format( "The collectionType of query '{0}' must be 'Remotion.Data.DomainObjects.DomainObjectCollection' or derived from it.", queryID), "collectionType"); } _id = queryID; _storageProviderDefinition = storageProviderDefinition; _statement = statement; _queryType = queryType; _collectionType = collectionType; }
public StorageClassAttribute(StorageClass storageClass) { ArgumentUtility.CheckValidEnumValue("storageClass", storageClass); _storageClass = storageClass; }
public void Succeed_Flags() { Enum result = ArgumentUtility.CheckValidEnumValue("arg", TestFlags.Flag1 | TestFlags.Flag2); Assert.That(result, Is.EqualTo(TestFlags.Flag1 | TestFlags.Flag2)); }
public void Succeed_SingleValue() { Enum result = ArgumentUtility.CheckValidEnumValue("arg", TestEnum.Value1); Assert.That(result, Is.EqualTo(TestEnum.Value1)); }
public void Fail_PartiallyUndefinedFlags() { ArgumentUtility.CheckValidEnumValue("arg", (TestFlags)(1 | 8)); }
public void Fail_UndefinedValue() { ArgumentUtility.CheckValidEnumValue("arg", (TestEnum)4); }