The Labs \ Source Viewer \ SSCLI \ System.Runtime.Serialization \ MemberHolder

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class: MemberHolder
  18. **
  19. **
  20. ** Purpose: This is a lightweight class designed to hold the members
  21. **          and StreamingContext for a particular class.
  22. **
  23. **
  24. ============================================================*/
  25. namespace System.Runtime.Serialization
  26. {
  27.    
  28.     using System.Runtime.Remoting;
  29.     using System;
  30.     using System.Reflection;
  31.     [Serializable()]
  32.     internal class MemberHolder
  33.     {
  34.         internal MemberInfo[] members = null;
  35.         internal Type memberType;
  36.         internal StreamingContext context;
  37.        
  38.         internal MemberHolder(Type type, StreamingContext ctx)
  39.         {
  40.             memberType = type;
  41.             context = ctx;
  42.         }
  43.        
  44.         public override int GetHashCode()
  45.         {
  46.             return memberType.GetHashCode();
  47.         }
  48.        
  49.         public override bool Equals(object obj)
  50.         {
  51.             if (!(obj is MemberHolder)) {
  52.                 return false;
  53.             }
  54.            
  55.             MemberHolder temp = (MemberHolder)obj;
  56.            
  57.             if (temp.memberType == memberType && temp.context.State == context.State) {
  58.                 return true;
  59.             }
  60.            
  61.             return false;
  62.         }
  63.     }
  64. }

Developer Fusion