[commit] r1162 - trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpAddon
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Feb 9 14:28:14 CST 2011
Author: ksmyth
Date: Wed Feb 9 14:28:13 2011
New Revision: 1162
Log:
Copy Registrar from CSharpInterpreter
Replaced:
trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpAddon/Registrar.cs
- copied unchanged from r1159, trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpInterpreter/Registrar.cs
Copied: trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpAddon/Registrar.cs (from r1159, trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpInterpreter/Registrar.cs)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpAddon/Registrar.cs Wed Feb 9 14:28:13 2011 (r1162, copy of r1159, trunk/SDK/DotNet/CSharpComponentWizard/Templates/CSharpInterpreter/Registrar.cs)
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using MGAUtilLib;
+using MGALib;
+using GmeLib;
+using MGACoreLib;
+using Microsoft.Win32;
+
+namespace GME.CSharp
+{
+ [ComVisible(false)]
+ public class RegistrationException : ApplicationException
+ {
+ public RegistrationException(string message) : base(message) { }
+ }
+
+ [ComVisible(false)]
+ public static class Registrar
+ {
+ public static void RegisterComponentsInGMERegistry()
+ {
+ if (ComponentConfig.iconPath == null)
+ {
+ ComponentConfig.iconPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + '\\' + ComponentConfig.iconName;
+ }
+
+ MgaRegistrar registrar = new MgaRegistrar();
+ CheckGMEInterfaceVersion(registrar);
+ registrar.RegisterComponent(ComponentConfig.progID, ComponentConfig.componentType, ComponentConfig.componentName, ComponentConfig.registrationMode);
+ registrar.set_ComponentExtraInfo(ComponentConfig.registrationMode, ComponentConfig.progID, "Icon", ComponentConfig.iconPath);
+
+ if (!ComponentConfig.paradigmName.Equals("*"))
+ {
+ registrar.Associate(
+ ComponentConfig.progID,
+ ComponentConfig.paradigmName,
+ ComponentConfig.registrationMode);
+ }
+ }
+
+ private static void CheckGMEInterfaceVersion(MgaRegistrar registrar)
+ {
+ if ((int)GMEInterfaceVersion_enum.GMEInterfaceVersion_Current != (int)((IGMEVersionInfo)registrar).version)
+ {
+ throw new RegistrationException("GMEInterfaceVersion mismatch: this assembly is using " +
+ (int)GMEInterfaceVersion_enum.GMEInterfaceVersion_Current +
+ " but the GME interface version is " + (int)((IGMEVersionInfo)registrar).version +
+ "\n\nPlease install a compatible GME version or update the interop dlls.");
+ }
+
+ }
+
+
+ public static void UnregisterComponentsInGMERegistry()
+ {
+ MgaRegistrar registrar = new MgaRegistrar();
+ CheckGMEInterfaceVersion(registrar);
+
+ registrar.UnregisterComponent(ComponentConfig.progID, ComponentConfig.registrationMode);
+ }
+ }
+}
More information about the gme-commit
mailing list