Example #1
0
        public static String GetTypeInfo(String typeName, String assemblyName)
        {
            try
            {
                if (_assemblyForType.Keys.Contains(typeName) &&
                    _assemblyForType[typeName] == assemblyName &&
                    _assembliesLoaded.Keys.Contains(assemblyName))
                {
                    Assembly a2 = _assembliesLoaded[assemblyName];
                    Ionic.Cscomp.TypeInfo ti2= new Ionic.Cscomp.TypeInfo(a2, typeName);
                    return ti2.AsSexp();
                }

                // Load from a strongname, eg
                // "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

                Assembly a= Assembly.Load(assemblyName);

                if ((a == null) && (System.IO.File.Exists(assemblyName)))
                    a= Assembly.LoadFrom(assemblyName);

                if (a == null)
                {
                    System.Console.Error.WriteLine("Cannot load that assembly");
                    return null;
                }

                Ionic.Cscomp.TypeInfo ti= new Ionic.Cscomp.TypeInfo(a, typeName);
                return ti.AsSexp();
            }
            catch(TypeLoadException e2)
            {
                Console.Error.WriteLine("TypeLoadException: Could not load type: \"{0}\"\n{1}", typeName, e2);

                return null;
            }
            catch (Exception e1)
            {
                Console.Error.WriteLine("Exception: type '{0}'\n{1}", typeName, e1);
                return null;
            }
        }
Example #2
0
        public static string GetConstructors(string typeName)
        {
            Tracing.Trace("GetConstructors: {0}", typeName);
            if (!_assemblyForType.Keys.Contains(typeName))
                return "nil";

            Assembly a = AssemblyIsLoaded(_assemblyForType[typeName]);
            if (a==null)
                return "nil";

            var tinfo= new Ionic.Cscomp.TypeInfo(a, typeName);
            return tinfo.GetConstructorsSexp();
        }