Exemple #1
0
        public static void AddQueryModelBinders(System.Reflection.Assembly assembly, IKernel kernel)
        {
            var queryTypes = assembly.GetExportedTypes()
                .Where(t => typeof(RaffleLib.Domain.Queries.IQuery).IsAssignableFrom(t));

            foreach (var queryType in queryTypes)
            {
                var queryInterface = queryType.GetInterfaces().Where(i => i.Name.EndsWith(queryType.Name)).FirstOrDefault();
                if (queryInterface != null)
                    ModelBinders.Binders.Add(queryInterface, new WebLib.Ninject.NinjectModelBinder(queryType, kernel));
            }
        }
Exemple #2
0
        /// <summary>
        /// Finds all Extension methods defined in an assembly
        /// </summary>
        /// <param name="asm"></param>
        /// <returns></returns>
        public static IEnumerable<ExtensionMethodRecord> EnumExtensionMethods(System.Reflection.Assembly asm)
        {
            var exported_types = asm.GetExportedTypes();

            foreach (var extending_type in exported_types)
            {
                foreach (var emi in EnumExtensionMethods(extending_type))
                {
                    yield return emi;
                }
            }
        }
        private static void addTypes(System.Reflection.Assembly assembly)
        {
            try
            {
                if (assembly is System.Reflection.Emit.AssemblyBuilder)
                    return;
                var types = assembly.GetExportedTypes();
                for (var i = 0; i < types.Length; i++)
                {
                    NamespaceProvider.types[types[i].FullName] = types[i];
                }
            }
            catch
            {

            }
        }
Exemple #4
0
    /// <summary>
    /// Parses a plugin and create all the commands defined therein.
    /// </summary>
    /// <param name="pPlugIn">Plugin to harvest for commands.</param>
    /// <param name="pluginAssembly">Assembly associated with the plugin.</param>
    /// <returns>The number of newly created commands.</returns>
    public static int CreateCommands(IntPtr pPlugIn, System.Reflection.Assembly pluginAssembly)
    {
      int rc = 0;
      // This function must ONLY be called by Rhino_DotNet.Dll
      if (IntPtr.Zero == pPlugIn || null == pluginAssembly)
        return rc;

      Type[] exported_types = pluginAssembly.GetExportedTypes();
      if (null == exported_types)
        return rc;

      Type command_type = typeof(Commands.Command);
      for (int i = 0; i < exported_types.Length; i++)
      {
        if (exported_types[i].IsAbstract)
          continue;
        if (command_type.IsAssignableFrom(exported_types[i]))
        {
          if( Rhino.PlugIns.PlugIn.CreateCommandsHelper(null, pPlugIn, exported_types[i], null))
            rc++;
        }
      }

      return rc;
    }
		private static Type[] TryGetExportedTypes(System.Reflection.Assembly asm)
		{
			try
			{
				return asm.GetExportedTypes();
			}
			catch (Exception)
			{
				tracer.Warn("Failed to retrieve exported types from assembly {0}.", asm.FullName);
				return new Type[0];
			}
		}
    public static void RegisterProviders(System.Reflection.Assembly assembly, System.Guid pluginId)
    {
      Rhino.PlugIns.PlugIn plugin = Rhino.PlugIns.PlugIn.GetLoadedPlugIn(pluginId);
      if (plugin == null)
        return;

      Type[] exported_types = assembly.GetExportedTypes();

      if (exported_types != null)
      {
        List<Type> provider_types = new List<Type>();
        for (int i = 0; i < exported_types.Length; i++)
        {
          Type t = exported_types[i];
          if (!t.IsAbstract && t.IsSubclassOf(typeof(Rhino.Render.CustomRenderMesh.Provider)) && t.GetConstructor(new Type[] { }) != null)
            provider_types.Add(t);
        }

        if (provider_types.Count == 0)
          return;

        RdkPlugIn rdk_plugin = RdkPlugIn.GetRdkPlugIn(plugin);
        if (rdk_plugin == null)
          return;

        foreach (Type t in provider_types)
        {
          Provider p = System.Activator.CreateInstance(t) as Provider;
          if (p == null) continue;
          IntPtr pCppObject = p.CreateCppObject(pluginId);
          if (pCppObject != IntPtr.Zero)
          {
            //rdk_plugin.AddRegisteredCRMProvider(p);
            m_all_providers.Add(p.m_runtime_serial_number, p);
            UnsafeNativeMethods.Rdk_RegisterCRMProvider(pCppObject);
          }
        }

      }
    }
 internal static void LoadCLRAssembly(System.Reflection.Assembly Assembly, Frame caller)
 {
     foreach (System.Type type in Assembly.GetExportedTypes())
         Load(type, caller, true);
 }
    /// <summary>
    /// Call this method once from your plug-ins OnLoad override for each
    /// assembly containing a custom mesh provider.  Only publicly exported
    /// classes derived from CustomRenderMeshProvider with a public constructor
    /// that has no parameters will get registered.
    /// </summary>
    /// <param name="assembly">
    /// Assembly to search for valid CustomRenderMeshProvider derived classes.
    /// </param>
    /// <param name="pluginId">
    /// The plug-in that owns the custom mesh providers.
    /// </param>
    public static void RegisterProviders(System.Reflection.Assembly assembly, Guid pluginId)
    {
      var plugin = PlugIns.PlugIn.GetLoadedPlugIn(pluginId);
      if (plugin == null)
        return;

      var exported_types = assembly.GetExportedTypes();
      var provider_types = new List<Type>();
      var custom_type = typeof(CustomRenderMeshProvider);
      var options = new Type[] {};

      foreach (var type in exported_types)
        if (!type.IsAbstract && type.IsSubclassOf(custom_type) && type.GetConstructor(options) != null)
          provider_types.Add(type);

      if (provider_types.Count == 0)
        return;

      var rdk_plugin = RdkPlugIn.GetRdkPlugIn(plugin);
      if (rdk_plugin == null)
        return;

      foreach (var type in provider_types)
      {
        var provider = Activator.CreateInstance(type) as CustomRenderMeshProvider;
        if (provider == null) continue;
        var cpp_object = provider.CreateCppObject(pluginId);
        if (cpp_object == IntPtr.Zero) continue;
        g_all_providers.Add(provider.m_runtime_serial_number, provider);
        UnsafeNativeMethods.Rdk_RegisterCRMProvider(cpp_object);
      }
    }
Exemple #9
0
    public static Type[] RegisterContentIo(System.Reflection.Assembly assembly, System.Guid pluginId)
    {
      Rhino.PlugIns.PlugIn plugin = Rhino.PlugIns.PlugIn.GetLoadedPlugIn(pluginId);
      if (plugin == null)
        return null;

      //Find all public types exported in the plug-in that we're dealing with
      Type[] exported_types = assembly.GetExportedTypes();
      if (exported_types != null)
      {
        List<Type> contentio_types = new List<Type>();
        for (int i = 0; i < exported_types.Length; i++)
        {
          //If the type is a Render.IOPlugIn, add it to the "to register" list.
          Type t = exported_types[i];
          if (!t.IsAbstract && t.IsSubclassOf(typeof(Rhino.Render.IOPlugIn)) && t.GetConstructor(new Type[] { }) != null)
          {
            contentio_types.Add(t);
          }
        }

        // make sure that content types have not already been registered
        for (int i = 0; i < contentio_types.Count; i++)
        {
          Type t = contentio_types[i];

          if (!RdkPlugIn.RenderContentIoTypeIsRegistered(t))
          {
            //The object registers itself in a static array
            IOPlugIn pi = System.Activator.CreateInstance(t) as IOPlugIn;
            pi.Construct(pluginId);
          }
        }        
        
        return contentio_types.ToArray();
      }
      return null;
    }
 private void ProbeAssembly(System.Reflection.Assembly a)
 {
     foreach (Type t in a.GetExportedTypes())
     {
         if (MetaPlugin.IsPlugin(t))
         {
             MetaPlugin plugin = new MetaPlugin(t);
             if (!plugins.ContainsKey(plugin.Name))
             {
                 plugins.Add(plugin.Name, plugin);
                 Logger.Info("Found plugin: " + plugin);
             }
             else
                 Logger.Info("Already have plugin: " + plugin);
         }
     }
 }