internal Condition(AddinEngine addinEngine, ExtensionNodeDescription element, BaseCondition parent) : base(parent)
 {
     this.addinEngine = addinEngine;
     typeId           = element.GetAttribute("id");
     addin            = element.GetAttribute(SourceAddinAttribute);
     node             = element;
 }
Exemple #2
0
 internal void SetData(AddinEngine addinEngine, string plugid, ExtensionNodeType nodeType, ModuleDescription module)
 {
     this.addinEngine = addinEngine;
     this.addinId     = plugid;
     this.nodeType    = nodeType;
     this.module      = module;
 }
Exemple #3
0
        internal AddinRegistry(AddinEngine engine, string registryPath, string startupDirectory, string addinsDir, string databaseDir)
        {
            basePath = Path.GetFullPath(Util.NormalizePath(registryPath));

            if (addinsDir != null)
            {
                addinsDir = Util.NormalizePath(addinsDir);
                if (Path.IsPathRooted(addinsDir))
                {
                    this.addinsDir = Path.GetFullPath(addinsDir);
                }
                else
                {
                    this.addinsDir = Path.GetFullPath(Path.Combine(basePath, addinsDir));
                }
            }
            else
            {
                this.addinsDir = Path.Combine(basePath, "addins");
            }

            if (databaseDir != null)
            {
                databaseDir = Util.NormalizePath(databaseDir);
                if (Path.IsPathRooted(databaseDir))
                {
                    this.databaseDir = Path.GetFullPath(databaseDir);
                }
                else
                {
                    this.databaseDir = Path.GetFullPath(Path.Combine(basePath, databaseDir));
                }
            }
            else
            {
                this.databaseDir = Path.GetFullPath(basePath);
            }

            // Look for add-ins in the hosts directory and in the default
            // addins directory
            addinDirs = new StringCollection();
            addinDirs.Add(DefaultAddinsFolder);

            // Initialize the database after all paths have been set
            database = new AddinDatabase(engine, this);

            // Get the domain corresponding to the startup folder
            if (startupDirectory != null && startupDirectory.Length > 0)
            {
                this.startupDirectory = Util.NormalizePath(startupDirectory);
                currentDomain         = database.GetFolderDomain(null, this.startupDirectory);
            }
            else
            {
                currentDomain = AddinDatabase.GlobalDomain;
            }
        }
        /// <summary>
        /// Initializes the add-in engine.
        /// </summary>
        /// <param name="configDir">
        /// Location of the add-in registry.
        /// </param>
        /// <remarks>
        /// The add-in engine needs to be initialized before doing any add-in operation.
        /// Configuration information about the add-in registry will be stored in the
        /// provided location. The add-in engine will look for add-ins in an 'addins'
        /// subdirectory of the provided directory.
        ///
        /// When specifying a path, it is possible to use a special folder name as root.
        /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced
        /// by the location of the Environment.SpecialFolder.Personal folder. Any value
        /// of the Environment.SpecialFolder enumeration can be used (always between square
        /// brackets)
        /// </remarks>
        public static void Initialize(string configDir)
        {
            Assembly asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                asm = Assembly.GetCallingAssembly();
            }
            AddinEngine.Initialize(asm, null, configDir, null, null);
        }
Exemple #5
0
        public TreeNode(AddinEngine addinEngine, string id)
        {
            this.id          = id;
            this.addinEngine = addinEngine;

            // Root node
            if (id.Length == 0)
            {
                childrenLoaded = true;
            }
        }
        /// <summary>
        /// Initializes the add-in engine.
        /// </summary>
        /// <remarks>
        /// The add-in engine needs to be initialized before doing any add-in operation.
        /// When initialized with this method, it will look for add-ins in the global add-in registry.
        /// </remarks>
        public static void Initialize()
        {
            // Code not shared with the other Initialize since I need to get the calling assembly
            Assembly asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                asm = Assembly.GetCallingAssembly();
            }
            AddinEngine.Initialize(asm, null, null, null, null);
        }
 internal RuntimeAddin(AddinEngine addinEngine, RuntimeAddin parentAddin, ModuleDescription module)
 {
     this.addinEngine = addinEngine;
     this.parentAddin = parentAddin;
     this.module      = module;
     id                  = parentAddin.id;
     baseDirectory       = parentAddin.baseDirectory;
     privatePath         = parentAddin.privatePath;
     ainfo               = parentAddin.ainfo;
     localizer           = parentAddin.localizer;
     module.RuntimeAddin = this;
 }
Exemple #8
0
        internal static AddinRegistry GetGlobalRegistry(AddinEngine engine, string startupDirectory)
        {
            AddinRegistry reg = new AddinRegistry(engine, GlobalRegistryPath, startupDirectory, null, null);
            string        baseDir;

            if (Util.IsWindows)
            {
                baseDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles);
            }
            else
            {
                baseDir = "/etc";
            }

            reg.GlobalAddinDirectories.Add(Path.Combine(baseDir, "Hyena.Addins"));
            return(reg);
        }
 /// <summary>
 /// Checks if an add-in has been loaded.
 /// </summary>
 /// <param name="id">
 /// Full identifier of the add-in.
 /// </param>
 /// <returns>
 /// True if the add-in is loaded.
 /// </returns>
 public static bool IsAddinLoaded(string id)
 {
     return(AddinEngine.IsAddinLoaded(id));
 }
Exemple #10
0
 public ExtensionTree(AddinEngine addinEngine, ExtensionContext context) : base(addinEngine, "")
 {
     this.context = context;
 }
Exemple #11
0
 /// <summary>
 /// Unregister a listener of extension node changes.
 /// </summary>
 /// <param name="path">
 /// Path of the node.
 /// </param>
 /// <param name="handler">
 /// A handler method.
 /// </param>
 /// <remarks>
 /// This method unregisters a delegate from the node change event of a path.
 /// </remarks>
 public static void RemoveExtensionNodeHandler(string path, ExtensionNodeEventHandler handler)
 {
     AddinEngine.CheckInitialized();
     AddinEngine.RemoveExtensionNodeHandler(path, handler);
 }
Exemple #12
0
 /// <summary>
 /// Unregister a listener of extension node changes.
 /// </summary>
 /// <param name="instanceType">
 /// Type defining the extension point
 /// </param>
 /// <param name="handler">
 /// A handler method.
 /// </param>
 public static void RemoveExtensionNodeHandler(Type instanceType, ExtensionNodeEventHandler handler)
 {
     AddinEngine.CheckInitialized();
     AddinEngine.RemoveExtensionNodeHandler(instanceType, handler);
 }
Exemple #13
0
 /// <summary>
 /// Gets extension nodes registered in a path.
 /// </summary>
 /// <param name="path">
 /// An extension path.>
 /// </param>
 /// <returns>
 /// All nodes registered in the provided path.
 /// </returns>
 public static ExtensionNodeList GetExtensionNodes(string path)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionNodes(path));
 }
Exemple #14
0
 /// <summary>
 /// Gets extension objects registered in a path.
 /// </summary>
 /// <param name="path">
 /// An extension path.
 /// </param>
 /// <param name="reuseCachedInstance">
 /// When set to True, it will return instances created in previous calls.
 /// </param>
 /// <returns>
 /// An array of objects registered in the path.
 /// </returns>
 /// <remarks>
 /// This method can only be used if all nodes in the provided extension path
 /// are of type Hyena.Addins.TypeExtensionNode. The returned array is composed
 /// by all objects created by calling the TypeExtensionNode.CreateInstance()
 /// method for each node (or TypeExtensionNode.GetInstance() if
 /// reuseCachedInstance is set to true).
 ///
 /// An InvalidOperationException exception is thrown if one of the found
 /// objects is not a subclass of the provided type.
 /// </remarks>
 public static T[] GetExtensionObjects <T> (string path, bool reuseCachedInstance)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionObjects <T> (path, reuseCachedInstance));
 }
Exemple #15
0
 /// <summary>
 /// Forces the loading of an add-in.
 /// </summary>
 /// <param name="statusMonitor">
 /// Status monitor to keep track of the loading process.
 /// </param>
 /// <param name="id">
 /// Full identifier of the add-in to load.
 /// </param>
 /// <remarks>
 /// This method loads all assemblies that belong to an add-in in memory.
 /// All add-ins on which the specified add-in depends will also be loaded.
 /// Notice that in general add-ins don't need to be explicitly loaded using
 /// this method, since the add-in engine will load them on demand.
 /// </remarks>
 public static void LoadAddin(IProgressStatus statusMonitor, string id)
 {
     AddinEngine.LoadAddin(statusMonitor, id);
 }
Exemple #16
0
 /// <summary>
 /// Finalizes an add-in engine.
 /// </summary>
 public static void Shutdown()
 {
     AddinEngine.Shutdown();
 }
Exemple #17
0
 internal RuntimeAddin(AddinEngine addinEngine)
 {
     this.addinEngine = addinEngine;
 }
Exemple #18
0
 /// <summary>
 /// Gets extension objects registered for a type extension point.
 /// </summary>
 /// <param name="instanceType">
 /// Type defining the extension point
 /// </param>
 /// <param name="reuseCachedInstance">
 /// When set to True, it will return instances created in previous calls.
 /// </param>
 /// <returns>
 /// A list of extension objects.
 /// </returns>
 public static object[] GetExtensionObjects(Type instanceType, bool reuseCachedInstance)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionObjects(instanceType, reuseCachedInstance));
 }
Exemple #19
0
 /// <summary>
 /// Gets extension nodes for a type extension point
 /// </summary>
 /// <param name="instanceType">
 /// Type defining the extension point
 /// </param>
 /// <param name="expectedNodeType">
 /// Expected extension node type
 /// </param>
 /// <returns>
 /// A list of nodes
 /// </returns>
 /// <remarks>
 /// This method returns all nodes registered for the provided type.
 /// It will throw a InvalidOperationException if the type of one of
 /// the registered nodes is not assignable to the provided node type.
 /// </remarks>
 public static ExtensionNodeList GetExtensionNodes(Type instanceType, Type expectedNodeType)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionNodes(instanceType, expectedNodeType));
 }
Exemple #20
0
 /// <summary>
 /// Gets extension nodes registered in a path.
 /// </summary>
 /// <param name="path">
 /// An extension path.
 /// </param>
 /// <returns>
 /// A list of nodes
 /// </returns>
 /// <remarks>
 /// This method returns all nodes registered under the provided path.
 /// It will throw a InvalidOperationException if the type of one of
 /// the registered nodes is not assignable to the provided type.
 /// </remarks>
 public static ExtensionNodeList <T> GetExtensionNodes <T> (string path) where T : ExtensionNode
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionNodes <T> (path));
 }
Exemple #21
0
 /// <summary>
 /// Gets extension nodes registered in a path.
 /// </summary>
 /// <param name="path">
 /// An extension path.
 /// </param>
 /// <param name="expectedNodeType">
 /// Expected node type.
 /// </param>
 /// <returns>
 /// A list of nodes
 /// </returns>
 /// <remarks>
 /// This method returns all nodes registered under the provided path.
 /// It will throw a InvalidOperationException if the type of one of
 /// the registered nodes is not assignable to the provided type.
 /// </remarks>
 public static ExtensionNodeList GetExtensionNodes(string path, Type expectedNodeType)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionNodes(path, expectedNodeType));
 }
Exemple #22
0
 /// <summary>
 /// Checks if the provided add-ins are installed, and requests the installation of those
 /// which aren't.
 /// </summary>
 /// <param name="message">
 /// Message to show to the user when new add-ins have to be installed.
 /// </param>
 /// <param name="addinIds">
 /// List of IDs of the add-ins to be checked.
 /// </param>
 /// <remarks>
 /// This method checks if the specified add-ins are installed.
 /// If some of the add-ins are not installed, it will use
 /// the installer assigned to the DefaultAddinInstaller property
 /// to install them. If the installation fails, or if DefaultAddinInstaller
 /// is not set, an exception will be thrown.
 /// </remarks>
 public static void CheckInstalled(string message, params string[] addinIds)
 {
     AddinEngine.CheckInstalled(message, addinIds);
 }
Exemple #23
0
 /// <summary>
 /// Gets extension objects registered in a path.
 /// </summary>
 /// <param name="path">
 /// An extension path.
 /// </param>
 /// <returns>
 /// An array of objects registered in the path.
 /// </returns>
 /// <remarks>
 /// This method can only be used if all nodes in the provided extension path
 /// are of type Hyena.Addins.TypeExtensionNode. The returned array is composed
 /// by all objects created by calling the TypeExtensionNode.CreateInstance()
 /// method for each node.
 ///
 /// An InvalidOperationException exception is thrown if one of the found
 /// objects is not a subclass of the provided type.
 /// </remarks>
 public static T[] GetExtensionObjects <T> (string path)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionObjects <T> (path));
 }
Exemple #24
0
 /// <summary>
 /// Sets the default localizer to be used for this add-in engine
 /// </summary>
 /// <param name="localizer">
 /// The add-in localizer
 /// </param>
 public static void InitializeDefaultLocalizer(IAddinLocalizer localizer)
 {
     AddinEngine.InitializeDefaultLocalizer(localizer);
 }
Exemple #25
0
 /// <summary>
 /// Gets extension objects registered in a path.
 /// </summary>
 /// <param name="path">
 /// An extension path.
 /// </param>
 /// <param name="arrayElementType">
 /// Type of the return array elements.
 /// </param>
 /// <param name="reuseCachedInstance">
 /// When set to True, it will return instances created in previous calls.
 /// </param>
 /// <returns>
 /// An array of objects registered in the path.
 /// </returns>
 /// <remarks>
 /// This method can only be used if all nodes in the provided extension path
 /// are of type Hyena.Addins.TypeExtensionNode. The returned array is composed
 /// by all objects created by calling the TypeExtensionNode.CreateInstance()
 /// method for each node (or TypeExtensionNode.GetInstance() if
 /// reuseCachedInstance is set to true).
 ///
 /// An InvalidOperationException exception is thrown if one of the found
 /// objects is not a subclass of the provided type.
 /// </remarks>
 public static object[] GetExtensionObjects(string path, Type arrayElementType, bool reuseCachedInstance)
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionObjects(path, arrayElementType, reuseCachedInstance));
 }
Exemple #26
0
 /// <summary>
 /// Gets extension nodes for a type extension point
 /// </summary>
 /// <param name="instanceType">
 /// Type defining the extension point
 /// </param>
 /// <returns>
 /// A list of nodes
 /// </returns>
 /// <remarks>
 /// This method returns all nodes registered for the provided type.
 /// It will throw a InvalidOperationException if the type of one of
 /// the registered nodes is not assignable to the specified node type argument.
 /// </remarks>
 public static ExtensionNodeList <T> GetExtensionNodes <T> (Type instanceType) where T : ExtensionNode
 {
     AddinEngine.CheckInitialized();
     return(AddinEngine.GetExtensionNodes <T> (instanceType));
 }
Exemple #27
0
 /// <summary>
 /// Creates a new extension context.
 /// </summary>
 /// <returns>
 /// The new extension context.
 /// </returns>
 /// <remarks>
 /// Extension contexts can be used to query the extension model using particular condition values.
 /// </remarks>
 public static ExtensionContext CreateExtensionContext()
 {
     return(AddinEngine.CreateExtensionContext());
 }