AOP C#在行动(续2)
2004-07-06 23:48
323 查看
今天开始写Paser了,不过是从SharpDevelop借过来而已(不想重新发明轮子,^_^)。但是,还是对原先的代码作了一些修改,即使到了RC2了,SharpDevelop的代码中还是存在问题。今天看代码是就发现了两处。比如下面的代码:
static public int Compare(IList a, IList b, IComparer comparer)
{
if (a == null || b == null) {
return 1;
}
if (a.Count != b.Count) {
return Math.Sign(a.Count - b.Count);
}
int limit = (a.Count < b.Count) ? a.Count : b.Count;
for(int i=0; i < limit; i++) {
if (a[i] is IComparable && b[i] is IComparable) {
int cmp = comparer.Compare(a[i], b[i]);
if (cmp != 0) {
return cmp;
}
}
}
return a.Count - b.Count;
}
第二个if块让我迷惑了好一阵。看mono中已经纠正了,怀疑那段语句是不是在喝酒只有写的。
static public int Compare(IList a, IList b, IComparer comparer)
{
if (a == null || b == null) {
return 1;
}
if (a.Count != b.Count) {
return Math.Sign(a.Count - b.Count);
}
int limit = (a.Count < b.Count) ? a.Count : b.Count;
for(int i=0; i < limit; i++) {
if (a[i] is IComparable && b[i] is IComparable) {
int cmp = comparer.Compare(a[i], b[i]);
if (cmp != 0) {
return cmp;
}
}
}
return a.Count - b.Count;
}
第二个if块让我迷惑了好一阵。看mono中已经纠正了,怀疑那段语句是不是在喝酒只有写的。
相关文章推荐
- AOP C#在行动(续1)
- AOP C#在行动
- AOP C#在行动(续1)
- C# Attribute 实现简单的 AOP 处理的例子(转)
- C# 实现AOP 的几种常见方式
- 【C# / Pattern】C#中利用Attribute实现AOP(面向切面编程)
- 轻量级AOP框架-移植python的装饰器(Decorator)到C#(思考篇)
- C# 用delegate实现AOP事务[C# | AOP | delegate]
- C#实现AOP框架
- C# 的AOP实现
- C# 实现 Aop [Emit动态生成代理类方式]
- 颠覆C#王权的“魔比斯环” — 实现AOP框架的终极利器
- C# 用Attribute实现AOP事务 [C# | AOP | Attribute | ContextAttribute | IContributeObjectSink | IMessageSink
- C#.NET利用ContextBoundObject和Attribute实现AOP技术--AOP事务实现例子
- C# AOP手动实现
- C# 使用KingAOP面向切面编程
- C# Aop简单扫盲及ORM实体类属性拦截示例
- C# 实现 Aop [继承ContextBoundObject方式]
- 利用Attribute给C#实现AOP?
- c# AOP 文章地址