Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CachedTypeData"/> class for caching reflected meta-data for a given Type.
 /// </summary>
 /// <param name="type">The Type provided will have its reflected PropertyInfo and Attributes cached.</param>
 internal CachedTypeData(Type type)
 {
     ExceptionFactory.ThrowIf <ArgumentNullException>(type == null, "Type is required.");
     this.Type                  = type;
     this.propertiesBag         = new ConcurrentBag <PropertyInfo>();
     this.propertyAttributesBag = new ConcurrentDictionary <PropertyInfo, IEnumerable <Attribute> >();
     this.typeAttributes        = new ConcurrentBag <Attribute>();
 }
Пример #2
0
        /// <summary>
        /// Invokes the given action and returns a Task when completed.
        /// </summary>
        /// <param name="actionToReturnTask">The action to return task.</param>
        /// <returns></returns>
        public static Task Invoke(Action actionToReturnTask)
        {
            ExceptionFactory.ThrowIf(
                actionToReturnTask == null,
                () => new ArgumentNullException(nameof(actionToReturnTask), "Action must not be null."));

            actionToReturnTask();
            return(Task.FromResult(true));
        }
Пример #3
0
        /// <summary>
        /// Callback on the results of an ExceptionFactory invocation
        /// </summary>
        /// <param name="callback">The callback.</param>
        /// <returns>Returns an instance of ExceptionFactoryResult</returns>
        public ExceptionFactoryResult <TException> ElseDo(Action callback)
        {
            ExceptionFactory.ThrowIf <ArgumentNullException>(
                callback == null,
                "callback can not be null",
                component);
            callback();

            return(this);
        }
Пример #4
0
 /// <summary>
 /// Permits piggybacking on the result of an ExceptionFactory.ThrowIf invocation with an
 /// additional condition check that results in an exception being thrown if true.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="predicate">The predicate.</param>
 /// <param name="message">The message.</param>
 /// <returns>Returns an instance of ExceptionFactoryResult</returns>
 public ExceptionFactoryResult <TAlternateException> Or <TAlternateException>(bool condition, string message = null) where TAlternateException : Exception, new()
 {
     return(ExceptionFactory.ThrowIf <TAlternateException>(condition, message, component));
 }
Пример #5
0
 /// <summary>
 /// Permits piggybacking on the result of an ExceptionFactory.ThrowIf invocation with an
 /// additional condition check that results in an exception being thrown if true.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="predicate">The predicate.</param>
 /// <param name="message">The message.</param>
 /// <returns>Returns an instance of ExceptionFactoryResult</returns>
 public ExceptionFactoryResult <TException> Or(bool condition, string message = null)
 {
     return(ExceptionFactory.ThrowIf <TException>(condition, message, component));
 }
Пример #6
0
 /// <summary>
 /// Permits piggybacking on the result of an ExceptionFactory.ThrowIf invocation with an
 /// additional predicate check that results in an exception being thrown if true.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="predicate">The predicate.</param>
 /// <param name="message">The message.</param>
 /// <returns>Returns an instance of ExceptionFactoryResult</returns>
 public ExceptionFactoryResult <TAlternateException> Or <TAlternateException>(Func <bool> predicate, Func <TAlternateException> exceptionFactory) where TAlternateException : Exception, new()
 {
     return(ExceptionFactory.ThrowIf(predicate, exceptionFactory, component));
 }
Пример #7
0
 /// <summary>
 /// Permits piggybacking on the result of an ExceptionFactory.ThrowIf invocation with an
 /// additional predicate check that results in an exception being thrown if true.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="predicate">The predicate.</param>
 /// <param name="message">The message.</param>
 /// <returns>Returns an instance of ExceptionFactoryResult</returns>
 public ExceptionFactoryResult <TAlternateException> Or <TAlternateException>(Func <bool> predicate, string message = null) where TAlternateException : Exception, new()
 {
     return(ExceptionFactory.ThrowIf <TAlternateException>(predicate, message, component));
 }
Пример #8
0
 /// <summary>
 /// Permits piggybacking on the result of an ExceptionFactory.ThrowIf invocation with an
 /// additional predicate check that results in an exception being thrown if true.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="predicate">The predicate.</param>
 /// <param name="message">The message.</param>
 /// <returns>Returns an instance of ExceptionFactoryResult</returns>
 public ExceptionFactoryResult <TException> Or(Func <bool> predicate, string message = null)
 {
     // TODO: Need to just mirror the ThrowIf signatures so Or invocations can provide data.
     return(ExceptionFactory.ThrowIf <TException>(predicate, message, component));
 }
Пример #9
0
 /// <summary>
 /// Permits piggybacking on the result of an ExceptionFactory.ThrowIf invocation with an
 /// additional condition check that results in an exception being thrown if true.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="predicate">The predicate.</param>
 /// <param name="message">The message.</param>
 /// <returns>Returns an instance of ExceptionFactoryResult</returns>
 public ExceptionFactoryResult <TAlternateException> Or <TAlternateException>(bool condition, Func <TAlternateException> exceptionFactory) where TAlternateException : Exception, new()
 {
     return(ExceptionFactory.ThrowIf(condition, exceptionFactory, component));
 }