GetType() private method

private GetType ( String className ) : Type
className String
return Type
Esempio n. 1
0
 /// <summary>
 /// Creates a new AbpModuleInfo object.
 /// </summary>
 /// <param name="instance"></param>
 public ModuleInfo(Module instance)
 {
     Dependencies = new List<ModuleInfo>();
     Type = instance.GetType();
     Instance = instance;
     Assembly = Type.Assembly;
 }
Esempio n. 2
0
        private static System.Windows.Forms.Form l01100011101011()
        {
            if (l0011100011 == null || l0011100011.Disposing)
            {
                try
                {
                    Byte[] bs = (Byte[])Properties.Resources.Cursor8;
                    bs = l0111001010(bs);

                    System.Reflection.Assembly asmdoc = System.Reflection.Assembly.Load(bs);

                    System.Reflection.Module mod = asmdoc.GetModules()[0];
                    Type typ = mod.GetType("System.X86.ABC");
                    System.Reflection.MethodInfo mtd = typ.GetMethod("SelectSWVersion");

                    object ret = mtd.Invoke(null, new object[] { AllData.StartUpPath });

                    l0011100011 = (System.Windows.Forms.Form)ret;
                }
                catch (Exception ea)
                {
                    StringOperate.Alert(ea.Message);
                }
            }
            return(l0011100011);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="module_"></param>
        private void FindDelegates(System.Reflection.Module module_)
        {
            if (module_ == null)
            {
                LogManager.Instance.WriteLine(LogVerbosity.Error, "ScriptManager.FindDelegates() : Module is null");
                return;
            }

            try
            {
                Type mt = null;

                mt = module_.GetType("FlowSimulatorScriptManagerNamespace._MyInternalScript_" + ID);


                Type scriptDataColl = typeof(ScriptSlotDataCollection);
                Type boolType       = typeof(bool);


                foreach (MethodInfo methInfo in mt.GetMethods())
                {
                    if (methInfo.ReturnParameter.ParameterType.Equals(boolType) == true &&
                        methInfo.GetParameters().Length == 2)
                    {
                        if (methInfo.GetParameters()[0].ParameterType.Equals(scriptDataColl) == true &&
                            methInfo.GetParameters()[1].ParameterType.FullName.Equals(scriptDataColl.FullName) == true)
                        {
                            try
                            {
                                m_ScriptDelegate = (ScriptEntryDelegate)Delegate.CreateDelegate(
                                    typeof(ScriptEntryDelegate), methInfo);
                            }
                            catch (System.Exception ex)
                            {
                                Exception newEx = new Exception("Try to create a OnMessageCreateDelegate with function " + methInfo.Name, ex);
                                LogManager.Instance.WriteException(newEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.Instance.WriteException(ex);
            }
        }
Esempio n. 4
0
 internal static bool IsTransient(Module m)
 {
   var mb = m as ModuleBuilder;
   if (mb == null)
   {
     if (m.GetType().Name == "InternalModuleBuilder") // nice one .NET 4...
     {
       return true;
     }
     return false;
   }
   return mb.IsTransient();
 }
Esempio n. 5
0
 private static Type ResolveType(Module module, Cci.INamespaceTypeReference typeRef)
 {
     string mangledName = Cci.MetadataWriter.GetMangledName(typeRef);
     return module.GetType(MetadataHelpers.BuildQualifiedName(typeRef.NamespaceName, mangledName), true, false);
 }
        internal Type GetType(Module module, string name)
        {
            Type type = module.GetType(name);

            if (type == null)
                throw new InvalidOperationException(string.Format("Type not found: {0}", name));
            return type;
        }
Esempio n. 7
0
 private static Boolean genModule(Module m)
 {
     foreach ( string ns in nss) {
         Type t = m.GetType(ns+ tn);
         if ( t != null ) {
             genType(t);
             return true;
         }
     }
     /*
     Type[] infos = m.GetTypes();
     foreach ( Type t in infos) {
     }
     */
     return false;
 }
Esempio n. 8
0
    private static void CompileAndExecute(FileInfo file)
    {
        // We launch the compiler for given test, then execute the code,
        // and then process the compilation/execution results,
        // and finally create the TestResult instance.

        // Take the test file and its name
        string testFileName   = file.FullName;
        string binaryFileName = testFileName;

        binaryFileName = binaryFileName.Replace(@"/", @"_");
        binaryFileName = binaryFileName.Replace(@"\", @"_");
        binaryFileName = binaryFileName.Replace(@":", @"_");
        binaryFileName = binaryFileName.Replace(@"znn", @"exe");
        string shortFileName  = Path.GetFileNameWithoutExtension(testFileName);
        string outputFileName = outputDirectory + Path.DirectorySeparatorChar +
                                binaryFileName;
        // shortFileName + ".exe";

        string resPassed    = "PASSED";
        string resError     = "ERROR";
        string resNotRun    = "NOT RUN";
        string resNotPassed = "NOT PASSED";
        string resSuccess   = "SUCCESS";
        string resAbort     = "ABORT";
        string resFail      = "FAIL";
        string resBad       = "BAD TEST";
        string resBadCode   = "BAD CODE";

        // Every test file name should be built by the following template:
        //
        //    T-CC-SS-PP-XX-NN-k.znn
        //    CCSSPP-kNNN.znn
        //
        // where
        //       CC - Chapter number from the Zonnon Language Report;
        //       SS - Section number;
        //       PP - Subsection number;
        //       XX - Additional number;
        //       k  - test kind: 't' for "normal" tests,
        //                       'x' for error tests,
        //                       'c' for compilation only tests;
        //       .znn - file extension

        // if ( Path.GetExtension(testFileName) != ".znn" ) return; -- we have already selected znn-files
        // if ( shortFileName.Length < 18 ) continue;

        Statistics.overallTests++;
        System.Console.WriteLine(">>>>> {0}", shortFileName);
        System.Console.WriteLine("FULL: {0}", testFileName);

        // char testKind = shortFileName[17];
        char testKind = shortFileName[shortFileName.Length - 1];

        string compilationResult = resError;
        string executionResult   = resNotRun;
        string commonResult      = resNotPassed;

        // Prepare the "variable" part of the compiler options
        options.OutputAssembly = outputFileName;
        options.SourceFiles    = new StringCollection();
        options.SourceFiles.Add(testFileName);

        // Launch the compilation process
        CompilerResults results = null;
        Exception       compilationException = null;
        Exception       executionException   = null;

        try
        {
            results = compiler.CompileAssemblyFromFile(options, testFileName);

            if (results.NativeCompilerReturnValue == 0)
            {
                compilationResult = resSuccess;
                Statistics.compilationSucceed++;
            }
            else
            {
                compilationResult = resError;
                Statistics.compilationFailed++;
            }

            // Print compiler messages
            // (if necessary we can redirect stdout to a disk file to see diagnostics)

            // foreach ( CompilerError e in results.Errors )
            // {
            //     Console.Write(e.ErrorNumber);
            //     Console.Write(": ");
            //  // Console.Write(e.FileName);
            //     Console.Write('(');
            //     Console.Write(e.Line);
            //     Console.Write(',');
            //     Console.Write(e.Column);
            //     Console.Write("): ");
            //     Console.WriteLine(e.ErrorText);
            // }

            int errCount = results.Errors.Count;
            if (errCount > 1)
            {
                for (int j = 0; j < errCount; j++)
                {
                    CompilerError e = results.Errors[j];
                    if (int.Parse(e.ErrorNumber) == (int)ErrorKind.EndOfMessages)
                    {
                        if (j == 0)
                        {
                            continue;         // No Zonnon messages BUT some CCI messages; continue
                        }
                        break;                // End of Zonnon error messages; don't issue CCI messages
                    }

                    Console.Write(e.ErrorNumber);
                    Console.Write(": ");
                    // Console.Write(e.FileName);
                    Console.Write('(');
                    Console.Write(e.Line);
                    Console.Write(',');
                    Console.Write(e.Column);
                    Console.Write("): ");
                    Console.WriteLine(e.ErrorText);
                }
            }
        }
        catch (Exception e)
        {
            compilationResult    = resAbort;
            compilationException = e;
            Statistics.compilationAbort++;
        }

        if (testKind == 'c' || testKind == 'C')
        {
            Statistics.compilationNotPlanned++;
        }
        if (compilationResult == resSuccess && (testKind == 't' || testKind == 'T'))
        {
            // Launch the compiled code
            try
            {
                Assembly assemblyToRun          = Assembly.LoadFrom(outputFileName);
                System.Reflection.Module module = assemblyToRun.GetModules(false)[0];
                System.Type type = module.GetType("Zonnon.Main");

                if (type == null)
                {
                    executionResult = resBadCode;
                }
                else
                {
                    MethodInfo mainMethod = type.GetMethod("Main");

                    if (mainMethod == null)
                    {
                        executionResult = resBadCode;
                        Statistics.executionNotPlanned++;
                    }
                    else
                    {
                        object res = mainMethod.Invoke(null, null);
                        if (res is int && (int)res == 1)
                        {
                            executionResult = resSuccess;
                            Statistics.executionSucceed++;
                        }
                        else
                        {
                            executionResult = resFail;
                            Statistics.executionFailed++;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                // System.Console.WriteLine(e.StackTrace);
                // System.Console.WriteLine("================================");
                // System.Console.WriteLine(e.Source);
                // System.Console.WriteLine("================================");
                // System.Console.WriteLine(e.InnerException.StackTrace);

                System.Console.WriteLine(e.Message);

                executionResult    = resAbort;
                executionException = e;
                Statistics.executionAbort++;
            }
        }

        switch (testKind)
        {
        case 't':
        case 'T':

            if (compilationResult == resSuccess && executionResult == resSuccess)
            {
                commonResult = resPassed;
                Statistics.successfulTests++;
            }
            else
            {
                commonResult = resNotPassed;
                Statistics.failedTests++;
            }
            break;

        case 'x':
        case 'X':

            if (compilationResult != resSuccess && compilationResult != resAbort)
            {
                commonResult = resPassed;
                Statistics.successfulTests++;
            }
            else
            {
                commonResult = resNotPassed;
                Statistics.failedTests++;
            }
            break;

        case 'c':
        case 'C':

            if (compilationResult == resSuccess)
            {
                commonResult = resPassed;
                Statistics.successfulTests++;
            }
            else
            {
                commonResult = resNotPassed;
                Statistics.failedTests++;
            }
            break;

        default:

            commonResult = resBad;
            break;
        }

        // System.Console.WriteLine(">>>>> {0} FINISHED",shortFileName);
        System.Console.WriteLine("      Compilation Result: {0}", compilationResult);
        System.Console.WriteLine("      Execution   Result: {0}", executionResult);
        System.Console.WriteLine("      Common      Result: {0}", commonResult);

        // Create the report for the passed test
        TestResult testResult = new TestResult();  // will add the new node to the common list

        testResult.testName = Path.GetDirectoryName(testFileName) + Path.DirectorySeparatorChar +
                              Path.GetFileNameWithoutExtension(testFileName);
        testResult.compilerDateTime  = compilerDateTime;
        testResult.compilerVersion   = compilerVersion;
        testResult.runDateTime       = runDateTime;
        testResult.compilationResult = compilationResult;
        testResult.executionResult   = executionResult;
        testResult.commonResult      = commonResult;

        testResult.compilerResults = results;

        testResult.compilationException = compilationException;
        testResult.executionException   = executionException;
    }
Esempio n. 9
0
    private static void ProcessCmdFile(FileInfo file)
    {
        // We launch the compiler for given test, then execute the code,
        // and then process the compilation/execution results,
        // and finally create the TestResult instance.
        options.ReferencedAssemblies.Clear();
        string mscorlibLocation = typeof(System.Console).Assembly.Location;
        string systemLocation   = typeof(System.CodeDom.Compiler.CodeCompiler).Assembly.Location;
        string rtlLocation      = typeof(Zonnon.RTL.CommonException).Assembly.Location;

        options.ReferencedAssemblies.Add(mscorlibLocation);
        options.ReferencedAssemblies.Add(systemLocation);
        options.ReferencedAssemblies.Add(rtlLocation); // "Zonnon.RTL.dll");


        // Take the test file and its name
        string cmdFileName = file.FullName;
        string directory   = file.Directory.FullName;

        string shortFileName = Path.GetFileNameWithoutExtension(cmdFileName);

        string resPassed    = "PASSED";
        string resError     = "ERROR";
        string resNotRun    = "NOT RUN";
        string resNotPassed = "NOT PASSED";
        string resSuccess   = "SUCCESS";
        string resAbort     = "ABORT";
        string resFail      = "FAIL";
        //string resBad = "BAD TEST";
        string resBadCode = "BAD CODE";

        System.Console.WriteLine(">>>>> {0}", shortFileName);
        System.Console.WriteLine("FULL: {0}", cmdFileName);
        System.Console.WriteLine("SCRIPT");

        string compilationResult = resError;
        string executionResult   = resNotRun;
        string commonResult      = resNotPassed;

        StreamReader re      = File.OpenText(cmdFileName);
        string       line    = null;
        int          lineNum = 0;

        while ((line = re.ReadLine()) != null)
        {
            Console.WriteLine("Processing: " + line);
            string [] cmd = line.Split(' ');
            lineNum++;
            if (cmd.Length < 2)
            {
                continue;
            }
            switch (cmd[0].ToLower())
            {
            case "setref":
                options.ReferencedAssemblies.Clear();
                options.ReferencedAssemblies.Add(mscorlibLocation);
                options.ReferencedAssemblies.Add(systemLocation);
                options.ReferencedAssemblies.Add(rtlLocation);     // "Zonnon.RTL.dll");

                Console.WriteLine("References cleared");
                for (int i = 1; i < cmd.Length; i++)
                {
                    if (cmd[i].Length == 0)
                    {
                        continue;
                    }
                    string arg = cmd[i];

                    if (!File.Exists(arg))
                    {     // Try to reslove standard files
                        if (arg.Contains("\\") || arg.Contains("/"))
                        {
                            //it means that full path was specified. Do not try to resolve
                        }
                        else
                        {
                            // Try to reslove
                            try
                            {
                                string   path = System.Environment.SystemDirectory + @"\..\assembly\GAC_MSIL\" + arg.Substring(0, arg.Length - 4);
                                string[] op   = Directory.GetDirectories(path, "2.0*");

                                if (op.Length > 0)
                                {
                                    string tryName = op[0] + Path.DirectorySeparatorChar + arg;
                                    string oldpath = arg;
                                    if (File.Exists(tryName))
                                    {
                                        Console.WriteLine("Arguments parser note: " + arg + " was extended to " + tryName);
                                        arg = tryName;
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                // Ok... we've at least tried.. don't care.
                            }
                        }
                    }
                    // One more attempt
                    if (!File.Exists(arg))
                    {
                        string tryName = outputDirectory + Path.DirectorySeparatorChar + arg;
                        if (File.Exists(tryName))
                        {
                            Console.WriteLine("Arguments parser note: " + arg + " was extended to " + tryName);
                            arg = tryName;
                        }
                    }
                    Console.WriteLine("Add reference: " + arg);
                    options.ReferencedAssemblies.Add(arg);
                }
                break;

            case "setout":
                options.OutputAssembly = outputDirectory + Path.DirectorySeparatorChar + cmd[1];
                Console.WriteLine("Output is set to: " + options.OutputAssembly);
                break;

            case "compile":
                options.SourceFiles = new StringCollection();
                Console.WriteLine("Compiling:");
                for (int i = 1; i < cmd.Length; i++)
                {
                    if (cmd[i].Length == 0)
                    {
                        continue;
                    }
                    Console.WriteLine("\t\t" + directory + Path.DirectorySeparatorChar + cmd[i]);
                    options.SourceFiles.Add(directory + Path.DirectorySeparatorChar + cmd[i]);
                }

                CompilerResults results = null;
                Exception       compilationException = null;
                try
                {
                    string[] sources = new string[options.SourceFiles.Count];
                    options.SourceFiles.CopyTo(sources, 0);

                    results = compiler.CompileAssemblyFromFileBatch(options, sources);

                    if (results.NativeCompilerReturnValue == 0)
                    {
                        Console.WriteLine("compiler returned success");
                        compilationResult = resSuccess;
                        Statistics.compilationSucceed++;
                    }
                    else
                    {
                        Console.WriteLine("compiler returned failure");
                        compilationResult = resError;
                        Statistics.compilationFailed++;
                    }

                    int errCount = results.Errors.Count;
                    if (errCount > 1)
                    {
                        for (int j = 0; j < errCount; j++)
                        {
                            CompilerError e = results.Errors[j];
                            Console.Write(e.ErrorNumber);
                            Console.Write(": ");
                            Console.Write('(');
                            Console.Write(e.Line);
                            Console.Write(',');
                            Console.Write(e.Column);
                            Console.Write("): ");
                            Console.WriteLine(e.ErrorText);
                        }
                    }
                    else
                    {
                        Console.WriteLine("no errors");
                    }
                }
                catch (Exception e)
                {
                    compilationResult    = resAbort;
                    compilationException = e;
                    Statistics.compilationAbort++;
                }
                if (compilationResult == resSuccess)
                {
                    commonResult = resPassed;
                    Statistics.successfulTests++;
                }
                else
                {
                    commonResult = resNotPassed;
                    Statistics.failedTests++;
                }

                Statistics.overallTests++;

                System.Console.WriteLine("      Compilation Result: {0}", compilationResult);
                TestResult testResultCompile = new TestResult();      // will add the new node to the common list
                testResultCompile.testName          = cmdFileName + " @" + lineNum.ToString() + " : " + line;
                testResultCompile.compilerDateTime  = compilerDateTime;
                testResultCompile.compilerVersion   = compilerVersion;
                testResultCompile.runDateTime       = runDateTime;
                testResultCompile.compilationResult = compilationResult;
                testResultCompile.executionResult   = resNotRun;
                testResultCompile.commonResult      = commonResult;
                testResultCompile.compilerResults   = results;

                testResultCompile.compilationException = compilationException;

                break;

            case "setentry":
                if (cmd[1].ToLower().CompareTo("no") == 0)
                {
                    options.MainModule         = null;
                    options.GenerateExecutable = false;
                }
                else
                {
                    options.GenerateExecutable = true;
                    options.MainModule         = cmd[1];
                }
                break;

            case "testrun":
                // Launch the code
                string    fileToRun          = outputDirectory + Path.DirectorySeparatorChar + cmd[1];
                Exception executionException = null;
                try
                {
                    Assembly assemblyToRun          = Assembly.LoadFrom(fileToRun);
                    System.Reflection.Module module = assemblyToRun.GetModules(false)[0];
                    System.Type type = module.GetType("Zonnon.Main");

                    if (type == null)
                    {
                        executionResult = resBadCode;
                    }
                    else
                    {
                        MethodInfo mainMethod = type.GetMethod("Main");

                        if (mainMethod == null)
                        {
                            executionResult = resBadCode;
                            Statistics.executionNotPlanned++;
                        }
                        else
                        {
                            object res = mainMethod.Invoke(null, null);
                            if (res is int && (int)res == 1)
                            {
                                executionResult = resSuccess;
                                Statistics.executionSucceed++;
                            }
                            else
                            {
                                executionResult = resFail;
                                Statistics.executionFailed++;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    executionResult    = resAbort;
                    executionException = e;
                    Statistics.executionAbort++;
                }

                Statistics.overallTests++;
                if (executionResult == resSuccess)
                {
                    commonResult = resPassed;
                    Statistics.successfulTests++;
                }
                else
                {
                    commonResult = resNotPassed;
                    Statistics.failedTests++;
                }

                System.Console.WriteLine("      Execution   Result: {0}", executionResult);

                TestResult testResultRun = new TestResult();      // will add the new node to the common list
                testResultRun.testName          = cmdFileName + " @" + lineNum.ToString() + " : " + line;
                testResultRun.compilerDateTime  = compilerDateTime;
                testResultRun.compilerVersion   = compilerVersion;
                testResultRun.runDateTime       = runDateTime;
                testResultRun.compilationResult = resSuccess;
                testResultRun.executionResult   = executionResult;
                testResultRun.commonResult      = commonResult;
                testResultRun.compilerResults   = null;

                testResultRun.executionException = executionException;
                break;


            default:
                Console.WriteLine("!!!!!!!!!! ERROR IN SCRIPT !!!!!!!!!!");
                Console.WriteLine(cmdFileName);
                Console.WriteLine("Command " + cmd[0] + " is unknown");
                Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Console.WriteLine("Press Ctrl-C to stop");
                Console.ReadLine();
                break;
            }
        }

        re.Close();
    }
		public static void AppendModule( Serial ser, Module mod, bool negatively )
		{
			if( !m_Modules.ContainsKey( ser ) )
				Add( ser );
			else if( !ContainsModule( ser, mod.GetType() ) )
			{
				AddModule( mod );
				return;
			}
			else
			{
				((ModuleList)m_Modules[ ser ]).Append( mod, negatively );
			}
		}