public static void Main() { try { MyTypeDelegatorClass myType; Console.WriteLine("Determine whether MyContextBoundClass is marshalled by reference."); // Determine whether MyContextBoundClass type is marshalled by reference. myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass)); if (myType.IsMarshalByRef) { Console.WriteLine(typeof(MyContextBoundClass) + " is marshalled by reference."); } else { Console.WriteLine(typeof(MyContextBoundClass) + " is not marshalled by reference."); } // Determine whether int type is marshalled by reference. myType = new MyTypeDelegatorClass(typeof(int)); Console.WriteLine("\nDetermine whether int is marshalled by reference."); if (myType.IsMarshalByRef) { Console.WriteLine(typeof(int) + " is marshalled by reference."); } else { Console.WriteLine(typeof(int) + " is not marshalled by reference."); } } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
public static void Main() { try { Console.WriteLine("Determine whether int is a primitive type."); MyTypeDelegatorClass myType; myType = new MyTypeDelegatorClass(typeof(int)); // Determine whether int is a primitive type. if (myType.IsPrimitive) { Console.WriteLine(typeof(int) + " is a primitive type."); } else { Console.WriteLine(typeof(int) + " is not a primitive type."); } Console.WriteLine("\nDetermine whether string is a primitive type."); myType = new MyTypeDelegatorClass(typeof(string)); // Determine if string is a primitive type. if (myType.IsPrimitive) { Console.WriteLine(typeof(string) + " is a primitive type."); } else { Console.WriteLine(typeof(string) + " is not a primitive type."); } } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
public static void Main() { try { MyTypeDelegatorClass myType; Console.WriteLine("Check whether MyContextBoundClass can be hosted in a context."); // Check whether MyContextBoundClass is contextful. myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass)); if (myType.IsContextful) { Console.WriteLine(typeof(MyContextBoundClass) + " can be hosted in a context."); } else { Console.WriteLine(typeof(MyContextBoundClass) + " cannot be hosted in a context."); } // Check whether the int type is contextful. myType = new MyTypeDelegatorClass(typeof(MyTypeDemoClass)); Console.WriteLine("\nCheck whether MyTypeDemoClass can be hosted in a context."); if (myType.IsContextful) { Console.WriteLine(typeof(MyTypeDemoClass) + " can be hosted in a context."); } else { Console.WriteLine(typeof(MyTypeDemoClass) + " cannot be hosted in a context."); } } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }