Exemplo n.º 1
0
        /// <summary>
        /// Loads the plug in.
        /// </summary>
        /// <param name="File">The file.</param>
        private void LoadPlugIn(FileInfo File)
        {
            Assembly ass;

            try {
                ass = Assembly.LoadFrom(File.FullName);
                foreach (Type t in ass.GetTypes())
                {
                    bool         IsSystem  = false;
                    SinglePlugIn PlugInCtr = null;
                    foreach (Type i in t.GetInterfaces())
                    {
                        if (i.FullName == typeof(IAfterCommand <eTerm443Async, eTerm443Packet>).FullName)
                        {
                            IAfterCommand <eTerm443Async, eTerm443Packet> plugIn = (IAfterCommand <eTerm443Async, eTerm443Packet>)System.Activator.CreateInstance(t);
                            object[] attris = t.GetCustomAttributes(typeof(AfterASynCommandAttribute), true);
                            PlugInCtr = new SinglePlugIn()
                            {
                                FullName = t.FullName,
                                Title    = plugIn.Description
                            };
                            foreach (AfterASynCommandAttribute att in attris)
                            {
                                if (att.IsSystem)
                                {
                                    IsSystem = att.IsSystem;
                                }
                                PlugInCtr.Append(att.ASynCommand);
                            }
                        }
                        else if (i.FullName == typeof(IAfterCommand <eTerm363Session, eTerm363Packet>).FullName)
                        {
                            IAfterCommand <eTerm363Session, eTerm363Packet> plugIn = (IAfterCommand <eTerm363Session, eTerm363Packet>)System.Activator.CreateInstance(t);
                            object[] attris = t.GetCustomAttributes(typeof(AfterASynCommandAttribute), true);
                            PlugInCtr = new SinglePlugIn()
                            {
                                FullName = t.FullName,
                                Title    = plugIn.Description
                            };
                            foreach (AfterASynCommandAttribute att in attris)
                            {
                                if (att.IsSystem)
                                {
                                    IsSystem = att.IsSystem;
                                }
                                PlugInCtr.Append(att.ASynCommand);
                            }
                        }
                    }
                    if (!IsSystem && PlugInCtr != null)
                    {
                        this.flowLayoutInter.Controls.Add(PlugInCtr);
                    }
                }
            }
            catch { }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the plug in.
        /// </summary>
        /// <param name="File">The file.</param>
        private void LoadPlugIn(FileInfo File)
        {
            Assembly ass;

            try {
                ass = Assembly.LoadFrom(File.FullName);
                foreach (Type t in ass.GetTypes())
                {
                    foreach (Type i in t.GetInterfaces())
                    {
                        if (i.FullName == typeof(IAfterCommand <eTerm443Async, eTerm443Packet>).FullName)
                        {
                            IAfterCommand <eTerm443Async, eTerm443Packet> plugIn = (IAfterCommand <eTerm443Async, eTerm443Packet>)System.Activator.CreateInstance(t);
                            object[] attris = t.GetCustomAttributes(typeof(AfterASynCommandAttribute), true);
                            foreach (AfterASynCommandAttribute att in attris)
                            {
                                this.ASyncSetup.PlugInCollection.Add(new PlugInSetup()
                                {
                                    AssemblyPath  = File.FullName,
                                    PlugInName    = att.ASynCommand,
                                    TypeFullName  = i.FullName,
                                    ASyncInstance = plugIn
                                });
                            }
                        }
                        else if (i.FullName == typeof(IAfterCommand <eTerm363Session, eTerm363Packet>).FullName)
                        {
                            IAfterCommand <eTerm363Session, eTerm363Packet> plugIn = (IAfterCommand <eTerm363Session, eTerm363Packet>)System.Activator.CreateInstance(t);
                            object[] attris = t.GetCustomAttributes(typeof(AfterASynCommandAttribute), true);
                            foreach (AfterASynCommandAttribute att in attris)
                            {
                                this.ASyncSetup.PlugInCollection.Add(new PlugInSetup()
                                {
                                    AssemblyPath          = File.FullName,
                                    PlugInName            = att.ASynCommand,
                                    TypeFullName          = i.FullName,
                                    ClientSessionInstance = plugIn
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex) {
                throw ex;
            }
        }