Esempio n. 1
0
        public Component LoadComponent(Guid guid)
        {
            // verify if component
            Component comp = GetFromCache(guid);

            if (null != comp)
            {
                return(comp);
            }
            if (!(SearchMethod is IComponentSearchMethod))
            {
                throw new PluginException("Component loader was not initialized with a valid plugin search method.");
            }
            return(LoadComponent(SearchMethod.GetAssemblyBytesFromGuid(guid)));
        }
Esempio n. 2
0
        public IPlugin GetPluginByGuid(Guid guid)
        {
            // check if component not available in cache
            Component comp = GetFromCache(guid);
            IPlugin   searchedPlugin;

            if (null != comp) // available from cache
            {
                searchedPlugin = comp.Plugin;
            }
            else // actually load
            {
                if (!(SearchMethod is IComponentSearchMethod))
                {
                    throw new PluginException("Component loader was not initialized with a valid plugin search method.");
                }
                searchedPlugin = LoadComponent(SearchMethod.GetAssemblyBytesFromGuid(guid)).Plugin;
            }
            if (null != searchedPlugin)
            {
                OnPluginAccessed?.Invoke(searchedPlugin.Guid);
            }
            return(searchedPlugin);
        }