Exemplo n.º 1
0
        /// <summary>
        /// Creates the specified method.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="offset">The offset.</param>
        /// <returns></returns>
        public static MethodBodyInfo Create(MethodBase method, int offset, IILStringCollector collector)
        {
            MethodBodyInfo mbi = new MethodBodyInfo
            {
                Identity       = method.GetHashCode(),
                TypeName       = method.GetType().Name,
                MethodToString = method.ToString()
            };

            collector.Initialize(mbi, offset);

            ReadableILStringVisitor visitor = new ReadableILStringVisitor(collector, DefaultFormatProvider.Instance);

            ILReaderFactory.Create(method, offset).Accept(visitor);

            return(mbi);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyFrame"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        public MyFrame(System.Diagnostics.StackFrame item)
        {
            // TODO: Complete member initialization
            var collector = new MethodBodyInfoBuilder();

            this.Offset = item.GetILOffset();
            var m1 = item.GetMethod();

            // Emit
            MethodBodyInfo graph = MethodBodyInfo.Create(m1, this.Offset, collector);
            StringBuilder  st    = new StringBuilder(graph.MethodToString);

            st.AppendLine("<BR />");
            st.Append("{");
            st.AppendLine("<BR />");
            foreach (var il in graph.Instructions)
            {
                st.Append("&nbsp;&nbsp;&nbsp;&nbsp;");
                st.Append(il.ToString());
                st.AppendLine("<BR />");
            }
            st.AppendLine("}");
            this.ReflectionMethod = new MyMethod()
            {
                Code = st.ToString()
            };
            this.ReflectionMethodName = graph.MethodToString;

            if (m1.DeclaringType != null)
            {
                this.ReflectionMethod.Method = m1;
                this.FrameItem            = item;
                this.ReflectionMethodName = m1.ToString();
            }
            else
            {
            }
        }
Exemplo n.º 3
0
 public void Initialize(MethodBodyInfo mbi, int offset)
 {
     this.m_mbi  = mbi;
     this.offset = offset;
 }