Esempio n. 1
0
        private bool checkModuleIsSocket(ModulesType modulesType)
        {
            string   className     = ResourceHelper.Library.GetString("Module" + modulesType.ToString());
            Type     typeofControl = null;
            Assembly tempAssembly  = Assembly.Load(assemblyName);

            if (tempAssembly == null)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("AssemblyIsNull")));
            }
            if (className == null)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongClassName") + "(" + modulesType.ToString() + ")"));
            }
            typeofControl = tempAssembly.GetType(className);

            if (typeofControl.BaseType.Name == "SocketModulesBase")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        private dynamic createCustomParameter(ModulesType modulesType, string parameterFolderPath, string deviceName)
        {
            string className = ResourceHelper.Library.GetString("Parameter" + modulesType.ToString());

            object[] obj           = new object[] { parameterFolderPath, deviceName };
            dynamic  result        = null;
            Type     typeofControl = null;
            Assembly tempAssembly  = Assembly.Load(assemblyName);

            typeofControl = tempAssembly.GetType(className);

            try
            {
                result = Activator.CreateInstance(typeofControl, obj);
            }
            catch (TargetInvocationException ex)
            {
                throw new Exception(ex.InnerException.Message);
            }
            return(result);
        }
Esempio n. 3
0
        public static dynamic CreateModule(ModulesType modulesType, string xmlFilePath, string deviceName)
        {
            string className = ResourceHelper.Library.GetString("Module" + modulesType.ToString());

            object[] obj           = new object[] { (object)modulesType, (object)xmlFilePath, (object)deviceName };
            dynamic  result        = null;
            Type     typeofControl = null;
            Assembly tempAssembly  = Assembly.Load(AssemblyName);

            if (tempAssembly == null)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("AssemblyIsNull")));
            }
            if (className == null)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongClassName") + " ( " + deviceName + " : " + modulesType.ToString() + " )"));
            }

            typeofControl = tempAssembly.GetType(className);

            if (typeofControl == null)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongClassName") + " ( " + deviceName + " : " + modulesType.ToString() + " )"));
            }

            try
            {
                result = Activator.CreateInstance(typeofControl, obj);
            }
            catch (TargetInvocationException ex)
            {
                if (ex.InnerException is Exception)
                {
                    throw new Exception(ex.InnerException.Message + " ( " + deviceName + " : " + modulesType.ToString() + " )");
                }
            }
            return(result);
        }
Esempio n. 4
0
        private bool checkModulesParameterClass(ModulesType modulesType)
        {
            string className = ResourceHelper.Library.GetString("Parameter" + modulesType.ToString());

            return(className != null ? true : false);
        }