Exemplo n.º 1
0
        /// <summary>
        /// Called from the base class constructor.
        /// Various types of addons can be initialized in various ways
        /// so Initialize must be overidden in all the Addon derived classes.
        /// </summary>
        protected override void LoadAddonType()
        {
            // Determine which of the subtypes must be loaded.
            // By convention, all navigation addons must expose a object
            // that is derived from NavBaseCtl, and this member is the addon panel.
            // This object must be initialized.
            foreach (System.Type type in this.AddonAssembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(PreviewBaseCtl)) &&
                    type.FullName == this.AddonTypeName)
                {
                    // Call the panel contructor, via .NET Reflection since we don't
                    // now exactly its type...
                    addonPanel = Activator.CreateInstance(type) as PreviewBaseCtl;

                    // Job done. Addon initialized, so exit.
                    return;
                }
            }

            // If we're here, the specified addon is not a valid preview addon.
            string exception =
                $"Failed to load the addon: \"{Name}\".\n\n" +
                $"The associated assembly: \"{AssemblyFileName}\" does not seem to be a valid preview addon,\n" +
                $"because it does not contain any subclasses of \"{typeof(PreviewBaseCtl)}\".\n\n";

            throw new ApplicationException(exception);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called from the base class constructor.
        /// Various types of addons can be initialized in various ways
        /// so Initialize must be overidden in all the Addon derived classes.
        /// </summary>
        protected override void LoadAddonType()
        {
            // Determine which of the subtypes must be loaded.
            // By convention, all navigation addons must expose a object
            // that is derived from NavBaseCtl, and this member is the addon panel.
            // This object must be initialized.
            foreach (System.Type type in this.AddonAssembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(PreviewBaseCtl)) &&
                    type.FullName == this.AddonTypeName)
                {
                    // Call the panel contructor, via .NET Reflection since we don't
                    // now exactly its type...
                    addonPanel = Activator.CreateInstance(type) as PreviewBaseCtl;

                    // Job done. Addon initialized, so exit.
                    return;
                }
            }

            // If we're here, the specified addon is not a valid navigation addon.
            string exception =
                string.Format("An error occured while loading the addon: \"{0}\".\n\n" +
                    "The associated assembly: \"{1}\" does not represent a valid property addon,\n" +
                    "because it does not contain any subclasses of \"{2}\".\n\n" +
                    "The addon might not be properly registered as an OPMedia Property Addon.",
                    this.Name, this.AssemblyFileName, typeof(PreviewBaseCtl).ToString());

            throw new ApplicationException(exception);
        }