Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using Teigha.DatabaseServices;
  7. using Teigha.Runtime;
  8. using Teigha.Geometry;
  9. using HostMgd.ApplicationServices;
  10. using HostMgd.EditorInput;
  11. using System.Reflection;
  12. using System.IO;
  13.  
  14. namespace CommandProxy
  15. {
  16.     public class CommandsProxy : IExtensionApplication
  17.     {
  18.         public void Initialize()
  19.         {
  20.             DebugReloadDll();
  21.         }
  22.  
  23.         public void Terminate()
  24.         {
  25.  
  26.         }
  27.  
  28.         private void ReloadDelegate(string pathToDll)
  29.         {
  30.             byte[] assemblyBytes = File.ReadAllBytes(pathToDll);
  31.             DLL = Assembly.Load(assemblyBytes);
  32.             Type cls = DLL.GetType("Sample1.CommandsDelegate");
  33.             commandsDelegate = Activator.CreateInstance(cls);
  34.         }
  35.  
  36.         [CommandMethod("DebugReloadDll")]
  37.         public void DebugReloadDll() =>
  38.             ReloadDelegate(@"C:\Users\talmaza\Documents\Visual Studio 2015\Projects\Sample1\Sample1\bin\Debug NCAD\Sample1.dll");
  39.  
  40.         [CommandMethod("Face")]
  41.         public void WritePoint()
  42.         {
  43.             var method = commandsDelegate.GetType().GetMethod("WritePoint");
  44.             method.Invoke(commandsDelegate, null);
  45.         }
  46.  
  47.         [CommandMethod("Face2")]
  48.         public void WritePoint2()
  49.         {
  50.             var method = commandsDelegate.GetType().GetMethod("WritePoint2");
  51.             method.Invoke(commandsDelegate, null);
  52.         }
  53.  
  54.         private static Assembly DLL;
  55.         private static object commandsDelegate;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement