* Identity.cs: created and identity class for each identity type. It is a more clear...
[mono.git] / mcs / class / corlib / System.Runtime.Remoting / IRemotingTypeInfo.cs
1 //
2 // System.Runtime.Remoting.IRemotingTypeInfo.cs
3 //
4 // AUthor: Duncan Mak  (duncan@ximian.com)
5 //
6 // 2002 (C) Copyright. Ximian, Inc.
7 //
8
9 using System.Reflection;
10 using System.Runtime.Remoting.Messaging;
11
12 namespace System.Runtime.Remoting {
13
14         public interface IRemotingTypeInfo
15         {
16                 string TypeName { get; set; }
17                 bool CanCastTo (Type fromType, object o);
18         }
19
20         // fixme: dont know if we really need this
21         internal class RemotingTypeInfo : IRemotingTypeInfo
22         {
23
24                 string type_name;
25
26                 public RemotingTypeInfo (Type type)
27                 {
28                         type_name = type.AssemblyQualifiedName;
29                 }
30                 
31                 public string TypeName {
32
33                         get {
34                                 return type_name;
35                         }
36
37                         set {
38                                 type_name = value;
39                         }
40                 }
41
42                 public Type GetRealType ()
43                 {
44                         string type_name = null;
45                         Assembly assembly = null;
46                         
47                         int pos = type_name.IndexOf (",");
48                         if (pos >= 0) {
49                                 if (pos != 0) {
50                                         string ass_name = type_name.Substring (0, pos - 1);
51                                         assembly = Assembly.Load (ass_name);
52                                 } 
53                                 type_name = type_name.Substring (pos + 1);
54                         }
55                         return assembly.GetType (type_name);
56                 }
57                 
58                 public bool CanCastTo (Type fromType, object o)
59                 {
60                         return false;
61                 }
62         }
63 }
64