Exemple #1
0
        public static void Serialize(Assembly assembly, System.IO.Stream stream)
        {
            CultureInfo prevCulture = SwapCulture();

            try
            {
                OpCodeList.LoadOpCodes();

                Package package = new Package();

                foreach (MethodBase mb in FindMethods(assembly))
                {
                    MethodBody body = new MethodBody(mb);

                    String procName = Helper.GetFullMethodName(mb, assembly);

                    Procedure p = new Procedure(procName);
                    foreach (Instruction ili in body.GetInstructions())
                    {
                        ILInstr i = new ILInstr(ili, assembly);
                        p.AddInstruction(i);
                    }

                    package.AddProcedure(p);
                }

                package.Prepare();

                XmlSerializer          s  = new XmlSerializer(typeof(Package));
                System.IO.MemoryStream ms = new System.IO.MemoryStream();

                using (System.IO.StreamWriter wr = new System.IO.StreamWriter(stream, Encoding.UTF8, 8192, true))
                {
                    s.Serialize(wr, package);
                }
            }
            finally
            {
                SwapCulture(prevCulture);
            }
        }
Exemple #2
0
 public void AddInstruction(ILInstr instruction)
 {
     instructions.Add(instruction);
 }