Exemplo n.º 1
0
        private void LoadAssemblies(string[] filenames)
        {
            foreach (var filename in filenames)
            {
                string             completePath = Path.Combine(Utils.ExtensionsDirectory, filename);
                Assembly           assem        = Assembly.LoadFrom(completePath);
                Type[]             types        = assem.GetExportedTypes();
                IMVSynchronization provisionDll = null;

                foreach (Type type in types)
                {
                    if (type.GetInterface("Microsoft.MetadirectoryServices.IMVSynchronization") != null)
                    {
                        provisionDll = (IMVSynchronization)assem.CreateInstance(type.FullName);
                    }
                }

                // If an object type starting with "MVExtension" could not be found,
                // or if an instance could not be created, throw an exception.
                if (provisionDll == null)
                {
                    throw new Exception("Unable to load file " + completePath + " as an provisioning assembly (IMVSynchronization)");
                }

                _loadedDlls.Add(provisionDll);

                // Call the Initialize() method on each MV extension object.
                provisionDll.Initialize();
            }
        }
Exemplo n.º 2
0
 public void LoadExternalAssembly()
 {
     if (string.IsNullOrEmpty(this.FilenameFull))
     {
         return;
     }
     Tracer.TraceInformation("enter-loadexternalassembly");
     try
     {
         {
             Tracer.TraceInformation("loading-loadexternalassembly {0}", Path.Combine(Utils.ExtensionsDirectory, this.FilenameFull));
             this.Assembly = Assembly.LoadFile(FilenameFull);
             Type[] types = Assembly.GetExportedTypes();
             Type   type  = types.FirstOrDefault(u => u.GetInterface("Microsoft.MetadirectoryServices.IMVSynchronization") != null);
             if (type != null)
             {
                 instance = Activator.CreateInstance(type) as IMVSynchronization;
             }
             else
             {
                 Tracer.TraceError("interface-not-implemented {0}", "Microsoft.MetadirectoryServices.IMVSynchronization");
                 throw new NotImplementedException("interface-not-implemented");
             }
         }
     }
     catch (Exception ex)
     {
         Tracer.TraceError("loadexternalassembly {0}", ex.GetBaseException());
         throw;
     }
     finally
     {
         Tracer.TraceInformation("exit-loadexternalassembly");
     }
 }