- UID
 - 658062
 
- 积分
 - 2147
 
- 精华
 
- 贡献
 -  
 
- 威望
 -  
 
- 活跃度
 -  
 
- D豆
 -  
 
- 在线时间
 -  小时
 
- 注册时间
 - 2008-10-22
 
- 最后登录
 - 1970-1-1
 
 
 
 
 
  
 | 
 
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
 
 
 
 
×
 
 本帖最后由 csharp 于 2014-5-9 07:13 编辑  
 
http://www.theswamp.org/index.php?topic=20097.0
  - namespace LispBase
 
 - {
 
 -   public static class ResultBufferExtension
 
 -   {
 
 -     //add
 
 -     public static void Add(this ResultBuffer m_this, int typecode)
 
 -     {
 
 -       m_this.Add(new TypedValue(typecode));
 
 -     }
 
 -     public static void Add(this ResultBuffer m_this, int typecode, object value)
 
 -     {
 
 -       m_this.Add(new TypedValue(typecode, value));
 
 -     }
 
 -     public static void Add(this ResultBuffer m_this, LispDataType type)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)type));
 
 -     }
 
 -     public static void Add(this ResultBuffer m_this, LispDataType type, object value)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)type, value));
 
 -     }
 
 -     public static void Add(this ResultBuffer m_this, DxfCode type)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)type));
 
 -     }
 
 -     public static void Add(this ResultBuffer m_this, DxfCode type, object value)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)type, value));
 
 -     }
 
  
-     //AddRange
 
 -     public static void AddRange(this ResultBuffer m_this, ResultBuffer src)
 
 -     {
 
 -       if (src == null)
 
 -         throw new ArgumentNullException();
 
  
-       foreach (TypedValue e in src)
 
 -         m_this.Add(e);
 
  
-     }
 
 -     public static void AddRange(this ResultBuffer m_this, TypedValue[] src)
 
 -     {
 
 -       if (src == null)
 
 -         throw new ArgumentNullException();
 
  
-       foreach (TypedValue e in src)
 
 -         m_this.Add(e);
 
  
-     }
 
 -     public static void AddRange(this ResultBuffer m_this, IEnumerable<TypedValue> src)
 
 -     {
 
 -       if (src == null)
 
 -         throw new ArgumentNullException();
 
  
-       foreach (TypedValue e in src)
 
 -         m_this.Add(e);
 
  
-     }
 
  
-     //Some Lisp stuff .. add what you need
 
 -     public static void AddLispT(this ResultBuffer m_this)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)LispDataType.T_atom));
 
 -     }
 
 -     public static void AddLispNil(this ResultBuffer m_this)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)LispDataType.Nil));
 
 -     }
 
 -     public static void AddLispString(this ResultBuffer m_this, string str)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)LispDataType.Text, str));
 
 -     }
 
 -     public static void AddLispDouble(this ResultBuffer m_this, double num)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)LispDataType.Double, num));
 
 -     }
 
 -     public static void AddLispInt(this ResultBuffer m_this, int num)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)LispDataType.Int32, num));
 
 -     }
 
 -     public static void AddLispErr(this ResultBuffer m_this, string message)
 
 -     {
 
 -       m_this.Add(new TypedValue((int)LispDataType.Nil));
 
 -       m_this.Add(new TypedValue((int)LispDataType.DottedPair));
 
 -       m_this.Add(new TypedValue((int)LispDataType.Text, "Error: " + message));
 
 -     }
 
  
-     //
 
 -     public static void ForEach(this ResultBuffer m_this, Action<TypedValue> action)
 
 -     {
 
 -       if (action == null)
 
 -         throw new ArgumentNullException();
 
  
-       foreach (TypedValue e in m_this)
 
 -         action(e);
 
 -     }
 
  
-     //
 
 -     public static TypedValue GetAt(this ResultBuffer m_this, int index)
 
 -     {
 
 -       return m_this.AsArray()[index];
 
 -     }
 
  
-     //
 
 -     public static int GetCount(this ResultBuffer m_this)
 
 -     {
 
 -       int cnt = 0;
 
  
-       foreach (TypedValue e in m_this)
 
 -         cnt += 1;
 
  
-       return cnt;
 
 -     }
 
  
-     //
 
 -     public static List<TypedValue> ToList(this ResultBuffer m_this)
 
 -     {
 
 -       return new List<TypedValue>(m_this.AsArray());
 
 -     }
 
  
-     //add some LinQ
 
 -     public static IEnumerable<TypedValue> Where
 
 -       (this ResultBuffer m_this, Func<TypedValue, bool> predicate)
 
 -     {
 
 -       foreach (TypedValue element in m_this)
 
 -       {
 
 -         if (predicate(element) == true)
 
 -           yield return element;
 
 -       }
 
 -     }
 
  
-     public static IEnumerable<TypedValue> Select
 
 -       (this ResultBuffer m_this, Func<TypedValue, TypedValue> selector)
 
 -     {
 
 -       foreach (TypedValue element in m_this)
 
 -       {
 
 -         yield return selector(element);
 
 -       }
 
 -     }
 
 -   }
 
 - }
 
  
  |   
 
 
 
 |