Exemplo n.º 1
0
        internal AddinDescription Load(Addin iad)
        {
            ainfo = iad;

            ArrayList plugList = new ArrayList();
            ArrayList asmList  = new ArrayList();

            AddinDescription description = iad.Description;

            id            = description.AddinId;
            baseDirectory = description.BasePath;

            // Load the main modules
            LoadModule(description.MainModule, description.Namespace, plugList, asmList);

            // Load the optional modules, if the dependencies are present
            foreach (ModuleDescription module in description.OptionalModules)
            {
                if (CheckAddinDependencies(module))
                {
                    LoadModule(module, description.Namespace, plugList, asmList);
                }
            }

            depAddins  = (RuntimeAddin[])plugList.ToArray(typeof(RuntimeAddin));
            assemblies = (Assembly[])asmList.ToArray(typeof(Assembly));

            if (description.Localizer != null)
            {
                string cls = description.Localizer.GetAttribute("type");

                // First try getting one of the stock localizers. If none of found try getting the type.
                object fob = CreateInstance("Mono.Addins.Localization." + cls + "Localizer", false);
                if (fob == null)
                {
                    fob = CreateInstance(cls, true);
                }

                IAddinLocalizerFactory factory = fob as IAddinLocalizerFactory;
                if (factory == null)
                {
                    throw new InvalidOperationException("Localizer factory type '" + cls + "' must implement IAddinLocalizerFactory");
                }
                localizer = new AddinLocalizer(factory.CreateLocalizer(this, description.Localizer));
            }

            return(description);
        }
Exemplo n.º 2
0
        internal AddinDescription Load(Addin iad)
        {
            ainfo = iad;

            AddinDescription description = iad.Description;

            id                  = description.AddinId;
            baseDirectory       = description.BasePath;
            module              = description.MainModule;
            module.RuntimeAddin = this;

            // Load the assemblies
            if (description.Localizer != null)
            {
                string cls = description.Localizer.GetAttribute("type");

                // First try getting one of the stock localizers. If none of found try getting the type.
                // They are not encoded as an assembly qualified name
                object fob = null;
                if (cls.IndexOf(',') == -1)
                {
                    Type t = GetType().Assembly.GetType("Hyena.Addins.Localization." + cls + "Localizer", false);
                    if (t != null)
                    {
                        fob = Activator.CreateInstance(t);
                    }
                }

                if (fob == null)
                {
                    fob = CreateInstance(cls, true);
                }

                IAddinLocalizerFactory factory = fob as IAddinLocalizerFactory;
                if (factory == null)
                {
                    throw new InvalidOperationException("Localizer factory type '" + cls + "' must implement IAddinLocalizerFactory");
                }
                localizer = new AddinLocalizer(factory.CreateLocalizer(this, description.Localizer));
            }

            return(description);
        }
Exemplo n.º 3
0
        internal AddinDescription Load(Addin iad)
        {
            ainfo = iad;

            AddinDescription description = iad.Description;

            id                  = description.AddinId;
            baseDirectory       = description.BasePath;
            module              = description.MainModule;
            module.RuntimeAddin = this;

            if (description.Localizer != null)
            {
                string cls = description.Localizer.GetAttribute("type");

                // First try getting one of the stock localizers. If none of found try getting the type.
                object fob = null;
                Type   t   = Type.GetType("Mono.Addins.Localization." + cls + "Localizer, " + GetType().Assembly.FullName, false);
                if (t != null)
                {
                    fob = Activator.CreateInstance(t);
                }

                if (fob == null)
                {
                    fob = CreateInstance(cls, true);
                }

                IAddinLocalizerFactory factory = fob as IAddinLocalizerFactory;
                if (factory == null)
                {
                    throw new InvalidOperationException("Localizer factory type '" + cls + "' must implement IAddinLocalizerFactory");
                }
                localizer = new AddinLocalizer(factory.CreateLocalizer(this, description.Localizer));
            }

            return(description);
        }