summaryrefslogtreecommitdiff
path: root/csharp/src
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src')
-rw-r--r--csharp/src/Ice/Instance.cs73
-rw-r--r--csharp/src/Ice/Util.cs5
2 files changed, 48 insertions, 30 deletions
diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs
index 136d5208889..f191a61415f 100644
--- a/csharp/src/Ice/Instance.cs
+++ b/csharp/src/Ice/Instance.cs
@@ -670,42 +670,41 @@ namespace IceInternal
_initData.threadStop = threadStop;
}
+ //
+ // Return the C# class associated with this Slice type-id
+ // Used for both non-local Slice classes and exceptions
+ //
public Type resolveClass(string id)
{
+ // First attempt corresponds to no cs:namespace metadata in the
+ // enclosing top-level module
+ //
string className = typeToClass(id);
-
Type c = AssemblyUtil.findType(this, className);
//
- // See if the application defined an Ice.Package.MODULE property.
+ // If this fails, look for helper classes in the typeIdNamespaces namespace(s)
//
- if(c == null)
+ if(c == null && _initData.typeIdNamespaces != null)
{
- int pos = id.IndexOf(':', 2);
- if(pos != -1)
+ foreach(var ns in _initData.typeIdNamespaces)
{
- String topLevelModule = id.Substring(2, pos - 2);
- String pkg = _initData.properties.getProperty("Ice.Package." + topLevelModule);
- if(pkg.Length > 0)
+ Type helper = AssemblyUtil.findType(this, ns + "." + className);
+ if(helper != null)
{
- c = AssemblyUtil.findType(this, pkg + "." + className);
+ try
+ {
+ c = helper.GetProperty("targetClass").PropertyType;
+ break; // foreach
+ }
+ catch(Exception)
+ {
+ }
}
}
}
//
- // See if the application defined a default package.
- //
- if(c == null)
- {
- String pkg = _initData.properties.getProperty("Ice.Default.Package");
- if(pkg.Length > 0)
- {
- c = AssemblyUtil.findType(this, pkg + "." + className);
- }
- }
-
- //
// Ensure the class is instantiable.
//
if(c != null && !c.IsAbstract && !c.IsInterface)
@@ -718,19 +717,33 @@ namespace IceInternal
public string resolveCompactId(int compactId)
{
- String className = "IceCompactId.TypeId_" + compactId;
- try
+ string[] defaultVal = {"IceCompactId"};
+ var compactIdNamespaces = new List<string>(defaultVal);
+
+ if(_initData.typeIdNamespaces != null)
{
- Type c = AssemblyUtil.findType(this, className);
- if(c != null)
- {
- return (string)c.GetField("typeId").GetValue(null);
- }
+ compactIdNamespaces.AddRange(_initData.typeIdNamespaces);
}
- catch(Exception)
+
+ string result = "";
+
+ foreach(var ns in compactIdNamespaces)
{
+ string className = ns + ".TypeId_" + compactId;
+ try
+ {
+ Type c = AssemblyUtil.findType(this, className);
+ if(c != null)
+ {
+ result = (string)c.GetField("typeId").GetValue(null);
+ break; // foreach
+ }
+ }
+ catch(Exception)
+ {
+ }
}
- return "";
+ return result;
}
private static string typeToClass(string id)
diff --git a/csharp/src/Ice/Util.cs b/csharp/src/Ice/Util.cs
index 32f8340a424..2833832e580 100644
--- a/csharp/src/Ice/Util.cs
+++ b/csharp/src/Ice/Util.cs
@@ -106,6 +106,11 @@ namespace Ice
/// The value factory manager.
/// </summary>
public ValueFactoryManager valueFactoryManager;
+
+ /// <summary>
+ /// The list of TypeId namespaces. Default is Ice.TypeId.
+ /// </summary>
+ public string[] typeIdNamespaces = { "Ice.TypeId" };
}
/// <summary>