void IEnsoService.RegisterCommand(IEnsoExtension extension, string uri, EnsoCommand command) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } if (extension == null) { throw new ArgumentNullException("extension"); } if (command == null) { throw new ArgumentNullException("command"); } IDictionary <string, EnsoExtensionProxy> extensions = this.extensions; IDictionary <EnsoCommand, EnsoExtensionProxy> commands = this.commands; if (extensions == null || commands == null) { throw new ObjectDisposedException(GetType().Name); } lock (this) { EnsoExtensionProxy extensionProxy; if (!extensions.TryGetValue(uri, out extensionProxy)) { extensionProxy = new EnsoExtensionProxy(extension, uri); RemotingServices.Marshal(extensionProxy, uri, typeof(EnsoExtensionProxy)); extensions.Add(uri, extensionProxy); } else if (extensionProxy.Extension != extension) { throw new EnsoException("Invalid uri."); } try { ensoProxy.RegisterCommand(GetUrlForUri(uri), command.ToString(), command.Description, command.Help, postfixTypes[(int)command.PostfixType]); } catch (Exception e) { throw new EnsoException("RegisterCommand failed", e); } commands.Add(command, extensionProxy); extensionProxy.Commands.Add(command.ToString(), command); } }
public void RegisterExtension(IEnsoExtension extension) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } if (extension == null) { throw new ArgumentNullException("extension"); } extension.Load(this); }
static void Main() { WaitForEnso(); EnsoExtensionServer server = new EnsoExtensionServer(); EnsoExtensionsSection section = (EnsoExtensionsSection)ConfigurationManager.GetSection("ensoExtensions"); foreach (EnsoExtensionElement element in section.EnsoExtensions) { try { Type type = Type.GetType(element.Type); IEnsoExtension extension = (IEnsoExtension)Activator.CreateInstance(type); server.RegisterExtension(extension); } catch (Exception e) { Debug.Fail(e.Message); } } Application.Run(); }
public EnsoExtensionProxy(IEnsoExtension extension, string uri) { this.extension = extension; this.uri = uri; }
public void UnegisterExtension(IEnsoExtension extension) { if (disposed) throw new ObjectDisposedException(GetType().Name); if (extension == null) throw new ArgumentNullException("extension"); extension.Unload(); }
void IEnsoService.RegisterCommand(IEnsoExtension extension, string uri, EnsoCommand command) { if (disposed) throw new ObjectDisposedException(GetType().Name); if (extension == null) throw new ArgumentNullException("extension"); if (command == null) throw new ArgumentNullException("command"); IDictionary<string, EnsoExtensionProxy> extensions = this.extensions; IDictionary<EnsoCommand, EnsoExtensionProxy> commands = this.commands; if (extensions == null || commands == null) throw new ObjectDisposedException(GetType().Name); lock (this) { EnsoExtensionProxy extensionProxy; if (!extensions.TryGetValue(uri, out extensionProxy)) { extensionProxy = new EnsoExtensionProxy(extension, uri); RemotingServices.Marshal(extensionProxy, uri, typeof(EnsoExtensionProxy)); extensions.Add(uri, extensionProxy); } else if (extensionProxy.Extension != extension) throw new EnsoException("Invalid uri."); try { ensoProxy.RegisterCommand(GetUrlForUri(uri), command.ToString(), command.Description, command.Help, postfixTypes[(int)command.PostfixType]); } catch (Exception e) { throw new EnsoException("RegisterCommand failed", e); } commands.Add(command, extensionProxy); extensionProxy.Commands.Add(command.ToString(), command); } }