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

  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. ** ValueType: StreamingContext
  18. **
  19. **
  20. ** Purpose: A value type indicating the source or destination of our streaming.
  21. **
  22. **
  23. ===========================================================*/
  24. namespace System.Runtime.Serialization
  25. {
  26.    
  27.     using System.Runtime.Remoting;
  28.     using System;
  29.     [Serializable()]
  30.     [System.Runtime.InteropServices.ComVisible(true)]
  31.     public struct StreamingContext
  32.     {
  33.         internal object m_additionalContext;
  34.         internal StreamingContextStates m_state;
  35.        
  36.         public StreamingContext(StreamingContextStates state) : this(state, null)
  37.         {
  38.         }
  39.        
  40.         public StreamingContext(StreamingContextStates state, object additional)
  41.         {
  42.             m_state = state;
  43.             m_additionalContext = additional;
  44.         }
  45.        
  46.         public object Context {
  47.             get { return m_additionalContext; }
  48.         }
  49.        
  50.         public override bool Equals(object obj)
  51.         {
  52.             if (!(obj is StreamingContext)) {
  53.                 return false;
  54.             }
  55.             if (((StreamingContext)obj).m_additionalContext == m_additionalContext && ((StreamingContext)obj).m_state == m_state) {
  56.                 return true;
  57.             }
  58.             return false;
  59.         }
  60.        
  61.         public override int GetHashCode()
  62.         {
  63.             return (int)m_state;
  64.         }
  65.        
  66.         public StreamingContextStates State {
  67.             get { return m_state; }
  68.         }
  69.     }
  70.    
  71.     // **********************************************************
  72.     // Keep these in sync with the version in vm\runtimehandles.h
  73.     // **********************************************************
  74.     [Serializable(), Flags()]
  75.     [System.Runtime.InteropServices.ComVisible(true)]
  76.     public enum StreamingContextStates
  77.     {
  78.         CrossProcess = 1,
  79.         CrossMachine = 2,
  80.         File = 4,
  81.         Persistence = 8,
  82.         Remoting = 16,
  83.         Other = 32,
  84.         Clone = 64,
  85.         CrossAppDomain = 128,
  86.         All = 255
  87.     }
  88. }

Developer Fusion