Rx:3-System.CoreEx.dll

在Rx发布的这个dll里,主要是对System.Core的扩充,其实就是把所需要的组件从4.0里拿出来放在了这里,所以Rx才能有在3.5版本上跑的可能性。

System

1)扩展Action<…>和Func<…>都到支持16个参数(.net 3.5下是最多4个)

2)增加了IObserver<TValue, TResult>接口:

   1: public interface IObserver<TValue, TResult>
   2: {
   3:     // Methods
   4:     TResult OnCompleted();
   5:     TResult OnError(Exception exception);
   6:     TResult OnNext(TValue value);
   7: }

这个接口使得IObserver对象可以再任何状态时都返回消息。如果IObserver的返回都是void,那不可避免的他总是再充当着“司令官”的角色——总在指挥他人干活或一些不重要(不需要返回值)的“小活”(这样的活往往都好治理,现在已经有较多的经验和组件)。

3)这里的Unit这个Struct结构体的实现方法很是奇怪:

   1: [StructLayout(LayoutKind.Sequential, Size=1)]
   2: public struct Unit : IEquatable<Unit>
   3: {
   4:     public bool Equals(Unit other)
   5:     {
   6:         return true;
   7:     }
   8:  
   9:  

System.Collections.GenericSystem.Concurrency

这两个命名空间下就是加东西

System.Diagnostics

这下面扩展了:

   1: public static class ExceptionExtensions
   2: {
   3:     // Fields
   4:     private const string ExceptionPrepForRemotingMethodName = "PrepForRemoting";
   5:     private static readonly MethodInfo prepForRemoting = typeof(Exception).GetMethod("PrepForRemoting", BindingFlags.NonPublic | BindingFlags.Instance);
   6:  
   7:     // Methods
   8:     public static Exception PrepareForRethrow(this Exception exception)
   9:     {
  10:         if (exception == null)
  11:         {
  12:             throw new ArgumentNullException("exception");
  13:         }
  14:         prepForRemoting.Invoke(exception, new object[0]);
  15:         return exception;
  16:     }
  17: }
  18:  

System.Disposables

这个Namespace是个比较实用的。因为每个IObservable<T>都需要实现一个返回IDisposable的Subscribe方法,而不同的场景我们需要使用不同的IDisposable的实现方式(比如在第一篇文章中我使用的实现方式的目的就是希望提供unsubscribe的功能),所以在这个Namespace下提供了一些常用的实现方式。

System.Linq

这个命名空间下提供了两个结构体:TimeInterval<T>和Timestamped<T>,具体用法之后再贴blog

posted @ 2010-06-02 01:41  new 维生素C.net()  阅读(1218)  评论(1编辑  收藏  举报