/// <summary> /// Initializes a new instance of the <see cref="Future{T}"/> class that /// will, upon running, execute the given <see cref="CallableDelegate{T}"/>. /// </summary> /// <param name="callable"> /// The callable task. /// </param> /// <param name="state"> /// An object representing data to be used by the future. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="callable"/> is null /// </exception> public Future(CallableDelegate <T> callable, object state) : this(state) { if (callable == null) { throw new ArgumentNullException("callable"); } callable_ = callable; }
/// <summary> /// Creates a <see cref="IFuture{T}"/> which has its value set to the /// value returned by the specified <paramref name="callable"/> immediately /// upon construction. /// </summary> /// <param name="callable"> /// The callable task which returning value should be assigned to the /// returned future. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="callable"/> is null /// </exception> /// <remarks> /// </remarks> public static IFuture <T> ImmediateCallableFuture <T>( CallableDelegate <T> callable) { Future <T> future = new Future <T>(callable); future.Run(true); return(future); }
/// <summary> /// Initializes a new instance of the <see cref="Future{T}"/> class that /// will, upon running, execute the given <see cref="RunnableDelegate"/>, /// and arrange that <see cref="AbstractFuture{T}.Get()"/> will return the /// given result on successful completion. /// </summary> /// <param name="runnable"> /// The runnable task /// </param> /// <param name="state"> /// An object representing data to be used by the future. /// </param> /// <param name="result"> /// The result to return on successful completion. If you don't need a /// particular result, consider using constructions of the form: /// <para> /// <code> /// Future{T} f = new Future(runnable, null). /// </code> /// </para> /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="runnable"/> is null. /// </exception> public Future(RunnableDelegate runnable, T result, object state) : this() { if (runnable == null) { throw new ArgumentNullException("runnable"); } callable_ = () => { runnable(); return(result); }; }
internal DataReaderMapper() { loader_ = NewT; }
internal DataReaderMapper() { loader_ = NewT; links_ = Enumerable.Empty <Action <IDataReader, T> >().ToList(); }
/// <summary> /// Defines the factory that shoud be used to create an instance of the /// <typeparamref name="T"/> class. /// </summary> /// <param name="factory"> /// A <see cref="CallableDelegate{T}"/> that should be used to create an /// instance of the <typeparamref name="T"/> class. /// </param> /// <remarks> /// If the class <typeparamref name="T"/> does not has a constructor that /// receives no parameters, the <see cref="SetFactory"/> method should be /// called to define the factory that should be used to create an instance /// of the <typeparamref name="T"/> class, falling to define this will /// causes the <see cref="Build"/> method to throw an exception. /// </remarks> public DataReaderMapperBuilder <T> SetFactory(CallableDelegate <T> factory) { factory_ = factory; return(this); }
/// <summary> /// Initialzes a new instance of the /// <see cref="CallableConfigurationBuilder{T}"/> object that runs the /// given <paramref name="callable"/> when <see cref="Build"/> is /// called. /// </summary> /// <param name="callable"> /// A <see cref="RunnableDelegate"/> to execute when <see cref="Build"/> /// method is called. /// </param> public CallableConfigurationBuilder(CallableDelegate <T> callable) { callable_ = callable; }