Пример #1
0
        /* API */
        #region API

        /// <summary>
        /// Returns the interface when given the module class.
        /// </summary>
        /// <returns>The module interface</returns>
        /// <param name="m">clsModule</param>
        public Interfaces.iModule clsToiMod(clsModule m)
        {
            try
            {
                return(ModuleMap[m.filename]);
            } catch (Exception) {
                throw new ArgumentOutOfRangeException
                          ("ERROR: Module is not in the list of loaded modules");
            }
        }
Пример #2
0
        /* API */
        #region API
        /// <summary>
        /// Initializes a new instance of the <see cref="Classes.clsModule"/> class.
        /// </summary>
        /// <param name="filepath">Filepath.</param>
        public clsModule(string filepath)
        {
            clsModule newModule = null;

            using (FileStream f = new FileStream(filepath, FileMode.Open)) {
                DataContractJsonSerializer ser =
                    new DataContractJsonSerializer(typeof(clsModule));

                newModule = (clsModule)ser.ReadObject(f);

                f.Close();
            }

            // Set readonly variables
            this.gettype  = newModule.gettype;
            this.filename = newModule.filename;
            this.commands = newModule.commands;

            if (commands == null || commands.Count == 0)
            {
                throw new ArgumentException
                          ("ERROR: A module without commands is useless!");
            }
        }
Пример #3
0
 /// <summary>
 /// Returns the interface when given the module class.
 /// </summary>
 /// <returns>The module interface</returns>
 /// <param name="m">clsModule</param>
 public Interfaces.iModule clsToiMod(clsModule m)
 {
     try
       {
     return ModuleMap[m.filename];
       } catch (Exception) {
     throw new ArgumentOutOfRangeException
       ("ERROR: Module is not in the list of loaded modules");
       }
 }