Skip to content

Instantly share code, notes, and snippets.

@sbaer
Last active August 29, 2015 14:27
Show Gist options
  • Save sbaer/ec31b428c9be49b06e00 to your computer and use it in GitHub Desktop.
Save sbaer/ec31b428c9be49b06e00 to your computer and use it in GitHub Desktop.
CreatePlugIn function
public static PlugIn CreatePlugIn(Type pluginType, bool printDebugMessages)
{
if (null == pluginType || !typeof(PlugIn).IsAssignableFrom(pluginType))
return null;
InitializeRhinoCommon();
// If we turn on debug messages, we always get debug output
if (printDebugMessages)
SendDebugToCommandLine = true;
// this function should only be called by Rhino_DotNet.dll
// we could add some safety checks by performing validation on
// the calling assembly
//System.Reflection.Assembly.GetCallingAssembly();
System.Reflection.Assembly plugin_assembly = pluginType.Assembly;
object[] name = plugin_assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyTitleAttribute), false);
string plugin_name = ((System.Reflection.AssemblyTitleAttribute)name[0]).Title;
string plugin_version = plugin_assembly.GetName().Version.ToString();
PlugIn plugin = PlugIn.Create(pluginType, plugin_name, plugin_version);
if (plugin == null)
return null;
PlugIn.m_plugins.Add(plugin);
return plugin;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment