コード例 #1
0
        public PluginTypeInfo[] GetAssemblyTypes(FileInfo assemblyLocation)
        {
            PluginTypeInfo[] types = new PluginTypeInfo[] { };

            if (string.IsNullOrEmpty(assemblyLocation.Directory.FullName))
            {
                throw new InvalidOperationException(
                          "Directory can't be null or empty.");
            }

            if (!Directory.Exists(assemblyLocation.Directory.FullName))
            {
                throw new InvalidOperationException(
                          string.Format(CultureInfo.CurrentCulture,
                                        "Directory not found {0}",
                                        assemblyLocation.Directory.FullName));
            }

            AppDomain childDomain = BuildChildDomain(
                AppDomain.CurrentDomain);

            try
            {
                Type loaderType = typeof(AssemblyLoader);
                if (loaderType.Assembly != null)
                {
                    var loader =
                        (AssemblyLoader)childDomain.
                        CreateInstanceFrom(
                            loaderType.Assembly.Location,
                            loaderType.FullName).Unwrap();
                    loader.SetCCNETServiceDirectory(CCNETServiceDirectory);
                    loader.LoadAssembly(
                        assemblyLocation.FullName);

                    types =
                        loader.GetTypes(
                            assemblyLocation.Directory.FullName, assemblyLocation.FullName);
                }
                return(types);
            }
            finally
            {
                AppDomain.Unload(childDomain);
            }
        }
コード例 #2
0
            internal PluginTypeInfo[] GetTypes(string path, string dll)
            {
                PluginTypeInfo[] types = new PluginTypeInfo[] { };

                DirectoryInfo       directory           = new DirectoryInfo(path);
                ResolveEventHandler resolveEventHandler =
                    (s, e) =>
                {
                    return(OnReflectionOnlyResolve(
                               e, directory));
                };

                AppDomain.CurrentDomain.AssemblyResolve += resolveEventHandler;

                types = Assembly.LoadFrom(dll).GetTypes().Where(t => IsDefinedAttributeData <ReflectorTypeAttribute>(t)).Select(t => new PluginTypeInfo(t)).ToArray();

                AppDomain.CurrentDomain.AssemblyResolve -= resolveEventHandler;

                return(types);
            }