private static void append_interface_properties_other_single(StringBuilder sb, PropertyInfo p, AopCoderDialect dialect) { sb.AppendLine("\t\tpublic " + p.PropertyType.FullName + " " + p.Name + " {"); if (p.CanRead) { sb.AppendLine("\t\t\tget { return " + dialect.GetInvokeTargetThis() + "." + p.Name + ";}"); } if (p.CanWrite) { sb.AppendLine("\t\t\tset { " + dialect.GetInvokeTargetThis() + "." + p.Name + " = value;}"); } sb.AppendLine("\t\t}"); sb.AppendLine(); }
private static void append_method_before(StringBuilder sb, ObservedMethod x, AopCoderDialect dialect) { if (x.Method.GetParameters().Length > 0) { sb.AppendFormat("\t\t\tMethodInfo m = {0}.GetType().GetMethod( \"{1}\", {2} );", dialect.GetInvokeTargetThis(), x.Method.Name, "new Type[] {" + getArgType(x.Method) + "}"); } else { sb.AppendFormat("\t\t\tMethodInfo m = {0}.GetType().GetMethod( \"{1}\", {2} );", dialect.GetInvokeTargetThis(), x.Method.Name, "new Type[]{}"); } sb.AppendLine(); sb.AppendFormat("\t\t\tObject[] args = {0};", getArgArray(x.Method)); sb.AppendLine(); List <MethodObserver> osList = getMethodObserver(x.ObservedType.Type, x.Method.Name); int i = 1; foreach (MethodObserver os in osList) { sb.AppendFormat("\t\t\t{0} observer{1} = {2};", os.GetType().FullName, i, getObserverCreator(os)); sb.AppendLine(); sb.AppendFormat("\t\t\tobserver{0}.Before( m, args, {1} );", i, dialect.GetInvokeTargetThis()); sb.AppendLine(); i++; } }
private static void append_invoke_object(StringBuilder sb, ObservedMethod x, AopCoderDialect dialect) { sb.Append("\t\t\tIMethodInvocation invocation = new MethodInvocation();"); sb.AppendLine(); sb.Append("\t\t\tinvocation.Method = m;"); sb.AppendLine(); sb.AppendFormat("\t\t\tinvocation.Args = args;"); sb.AppendLine(); sb.AppendFormat("\t\t\tinvocation.Target = {0};", dialect.GetInvokeTargetThis()); sb.AppendLine(); sb.AppendFormat("\t\t\tinvocation.IsSubClass = {0};", dialect.IsSubClassStr()); sb.AppendLine(); }
private static void append_interface_methods_other_single(StringBuilder sb, MethodInfo m, AopCoderDialect dialect) { String strReturn = getReturnString(m); String strArgs = getArgString(m); String strArgBody = getArgBody(m); sb.AppendFormat("\t\tpublic {0} {1} ( {2} ) ", strReturn, m.Name, strArgs); sb.Append("{"); sb.AppendLine(); String strReturnLabel = getReturnString(m); strReturnLabel = (strReturnLabel == "void" ? "" : "return "); sb.AppendFormat("\t\t\t{3}{0}.{1}({2});", dialect.GetInvokeTargetThis(), m.Name, strArgBody, strReturnLabel); sb.AppendLine(); sb.Append("\t\t}"); sb.AppendLine(); sb.AppendLine(); }
private static void append_method_before( StringBuilder sb, ObservedMethod x, AopCoderDialect dialect ) { if (x.Method.GetParameters().Length > 0) { sb.AppendFormat( "\t\t\tMethodInfo m = {0}.GetType().GetMethod( \"{1}\", {2} );", dialect.GetInvokeTargetThis(), x.Method.Name, "new Type[] {" + getArgType( x.Method ) + "}" ); } else { sb.AppendFormat( "\t\t\tMethodInfo m = {0}.GetType().GetMethod( \"{1}\", {2} );", dialect.GetInvokeTargetThis(), x.Method.Name, "new Type[]{}" ); } sb.AppendLine(); sb.AppendFormat( "\t\t\tObject[] args = {0};", getArgArray( x.Method ) ); sb.AppendLine(); List<MethodObserver> osList = getMethodObserver( x.ObservedType.Type, x.Method.Name ); int i = 1; foreach (MethodObserver os in osList) { sb.AppendFormat( "\t\t\t{0} observer{1} = {2};", os.GetType().FullName, i, getObserverCreator( os ) ); sb.AppendLine(); sb.AppendFormat( "\t\t\tobserver{0}.Before( m, args, {1} );", i, dialect.GetInvokeTargetThis() ); sb.AppendLine(); i++; } }
private static void append_method_after( StringBuilder sb, ObservedMethod x, AopCoderDialect dialect ) { List<MethodObserver> osList = getMethodObserver( x.ObservedType.Type, x.Method.Name ); int i = 1; foreach (MethodObserver os in osList) { sb.AppendFormat( "\t\t\tobserver{0}.After( returnValue, m, args, {1} );", i, dialect.GetInvokeTargetThis() ); sb.AppendLine(); i++; } }
private static void append_invoke_object( StringBuilder sb, ObservedMethod x, AopCoderDialect dialect ) { sb.Append( "\t\t\tIMethodInvocation invocation = new MethodInvocation();" ); sb.AppendLine(); sb.Append( "\t\t\tinvocation.Method = m;" ); sb.AppendLine(); sb.AppendFormat( "\t\t\tinvocation.Args = args;" ); sb.AppendLine(); sb.AppendFormat( "\t\t\tinvocation.Target = {0};", dialect.GetInvokeTargetThis() ); sb.AppendLine(); sb.AppendFormat( "\t\t\tinvocation.IsSubClass = {0};", dialect.IsSubClassStr() ); sb.AppendLine(); }
private static void append_interface_properties_other_single( StringBuilder sb, PropertyInfo p, AopCoderDialect dialect ) { sb.AppendLine( "\t\tpublic " + p.PropertyType.FullName + " " + p.Name + " {" ); if (p.CanRead) { sb.AppendLine( "\t\t\tget { return " + dialect.GetInvokeTargetThis() + "." + p.Name + ";}" ); } if (p.CanWrite) { sb.AppendLine( "\t\t\tset { " + dialect.GetInvokeTargetThis() + "." + p.Name + " = value;}" ); } sb.AppendLine( "\t\t}" ); sb.AppendLine(); }
private static void append_interface_methods_other_single( StringBuilder sb, MethodInfo m, AopCoderDialect dialect ) { String strReturn = getReturnString( m ); String strArgs = getArgString( m ); String strArgBody = getArgBody( m ); sb.AppendFormat( "\t\tpublic {0} {1} ( {2} ) ", strReturn, m.Name, strArgs ); sb.Append( "{" ); sb.AppendLine(); String strReturnLabel = getReturnString( m ); strReturnLabel = (strReturnLabel == "void" ? "" : "return "); sb.AppendFormat( "\t\t\t{3}{0}.{1}({2});", dialect.GetInvokeTargetThis(), m.Name, strArgBody, strReturnLabel ); sb.AppendLine(); sb.Append( "\t\t}" ); sb.AppendLine(); sb.AppendLine(); }
private static void append_method_after(StringBuilder sb, ObservedMethod x, AopCoderDialect dialect) { List <MethodObserver> osList = getMethodObserver(x.ObservedType.Type, x.Method.Name); int i = 1; foreach (MethodObserver os in osList) { sb.AppendFormat("\t\t\tobserver{0}.After( returnValue, m, args, {1} );", i, dialect.GetInvokeTargetThis()); sb.AppendLine(); i++; } }