.Net System.Object 对象实现代码

 

  1 None.gif //  Decompiled by Salamander version 1.0.6
  2 None.gif //  Copyright 2002 Remotesoft Inc. All rights reserved.
  3 None.gif //   http://www.remotesoft.com/salamander
  4 None.gif
  5 None.gif using  System.Reflection;
  6 None.gif using  System.Runtime;
  7 None.gif using  System.Runtime.Remoting;
  8 None.gif using  System.Runtime.Remoting.Messaging;
  9 None.gif
 10 None.gif namespace  System
 11 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 12InBlock.gif  [ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
 13InBlock.gif  [SerializableAttribute()]
 14InBlock.gif  public class Object
 15ExpandedSubBlockStart.gifContractedSubBlock.gif  dot.gif{
 16InBlock.gif
 17InBlock.gif    public Object()
 18ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 19ExpandedSubBlockEnd.gif    }

 20InBlock.gif
 21InBlock.gif    // internalcall
 22InBlock.gif    private Type InternalGetType();
 23InBlock.gif
 24InBlock.gif    // internalcall
 25InBlock.gif    private Type FastGetExistingType();
 26InBlock.gif
 27InBlock.gif    public virtual string ToString()
 28ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 29InBlock.gif      return GetType().FullName;
 30ExpandedSubBlockEnd.gif    }

 31InBlock.gif
 32InBlock.gif    // internalcall
 33InBlock.gif    public virtual bool Equals(object obj);
 34InBlock.gif
 35InBlock.gif    public static bool Equals(object objA, object objB)
 36ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 37InBlock.gif      if (objA == objB)
 38ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
 39InBlock.gif        return true;
 40ExpandedSubBlockEnd.gif      }

 41InBlock.gif      if (objA == null || objB == null)
 42ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
 43InBlock.gif        return false;
 44ExpandedSubBlockEnd.gif      }

 45InBlock.gif      else
 46ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
 47InBlock.gif        return objA.Equals(objB);
 48ExpandedSubBlockEnd.gif      }

 49ExpandedSubBlockEnd.gif    }

 50InBlock.gif
 51InBlock.gif    public static bool ReferenceEquals(object objA, object objB)
 52ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 53InBlock.gif      return objA == objB;
 54ExpandedSubBlockEnd.gif    }

 55InBlock.gif
 56InBlock.gif    // internalcall
 57InBlock.gif    public virtual int GetHashCode();
 58InBlock.gif
 59InBlock.gif    public Type GetType()
 60ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 61InBlock.gif      Type type = FastGetExistingType();
 62InBlock.gif      if (type == null)
 63ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
 64InBlock.gif        type = InternalGetType();
 65ExpandedSubBlockEnd.gif      }

 66InBlock.gif      return type;
 67ExpandedSubBlockEnd.gif    }

 68InBlock.gif
 69InBlock.gif    ~Object()
 70ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 71ExpandedSubBlockEnd.gif    }

 72InBlock.gif
 73InBlock.gif    // internalcall
 74InBlock.gif    protected object MemberwiseClone();
 75InBlock.gif
 76InBlock.gif    private void FieldSetter(string typeName, string fieldName, object val)
 77ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 78InBlock.gif      FieldInfo fieldInfo = GetFieldInfo(typeName, fieldName);
 79InBlock.gif      if (fieldInfo.IsInitOnly)
 80ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
 81InBlock.gif        throw new FieldAccessException(Environment.GetResourceString("FieldAccess_InitOnly"));
 82ExpandedSubBlockEnd.gif      }

 83InBlock.gif      Message.CoerceArg(val, fieldInfo.FieldType);
 84InBlock.gif      fieldInfo.SetValue(this, val);
 85ExpandedSubBlockEnd.gif    }

 86InBlock.gif
 87InBlock.gif    private void FieldGetter(string typeName, string fieldName, ref object val)
 88ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 89InBlock.gif      FieldInfo fieldInfo = GetFieldInfo(typeName, fieldName);
 90InBlock.gif      val = fieldInfo.GetValue(this);
 91ExpandedSubBlockEnd.gif    }

 92InBlock.gif
 93InBlock.gif    private FieldInfo GetFieldInfo(string typeName, string fieldName)
 94ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 95InBlock.gif      Type type;
 96InBlock.gif
 97InBlock.gif      for (type = GetType(); type != null && !type.FullName.Equals(typeName); type = type.BaseType)
 98ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
 99ExpandedSubBlockEnd.gif      }

100InBlock.gif      if (type == null)
101ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
102InBlock.gif        throw new RemotingException(String.Format(Environment.GetResourceString("Remoting_BadType"), typeName));
103ExpandedSubBlockEnd.gif      }

104InBlock.gif      FieldInfo fieldInfo = type.GetField(fieldName, 21);
105InBlock.gif      if (fieldInfo == null)
106ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
107InBlock.gif        throw new RemotingException(String.Format(Environment.GetResourceString("Remoting_BadField"), fieldName, typeName));
108ExpandedSubBlockEnd.gif      }

109InBlock.gif      else
110ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
111InBlock.gif        return fieldInfo;
112ExpandedSubBlockEnd.gif      }

113ExpandedSubBlockEnd.gif    }

114ExpandedSubBlockEnd.gif  }

115InBlock.gif
116ExpandedBlockEnd.gif}

117 None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值