void createParamEditor(DesignerStructPropertyInfo structParam, Nodes.Action action) { MethodDef method = action.Method; if (method != null) { List <MethodDef.Param> parameters = method.GetParams(structParam); if (parameters != null && parameters.Count > 0) { foreach (MethodDef.Param p in parameters) { Type editorType = null; if (structParam.ElmentIndexInArray != -1) { object member = p.Value; editorType = p.Attribute.GetEditorType(member); } else { editorType = typeof(DesignerParameterComboEnumEditor); } string arugmentsName = " " + p.DisplayName; Label label = propertyGrid.AddProperty(arugmentsName, editorType, p.Attribute != null ? p.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly) : false); label.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56))))); label.MouseEnter += label_MouseEnter; DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag; editor.Enabled = true; //editor.SetRootNode(this._node); editor.SetParameter(p, action, false); editor.MouseEnter += new EventHandler(editor_MouseEnter); editor.ValueWasAssigned(); editor.ValueWasChanged += editor_ValueWasChanged; } { propertyGrid.UpdateSizes(); propertyGrid.PropertiesVisible(true, true); } } } }
internal static void ILSpyMtNoRt(ClassDef classDef, MethodDef methodDef, Method startLogMethod, Method endLogMethod) { string classNameString = MethodLoggerUtil.GetQualifiedClassName(classDef); string methodNameString = methodDef.Name(); string paramsString = MethodLoggerUtil.GetParamsAsString(methodDef.GetParams()); List <Local> CLRLocals = new List <Local>(); CLRLocals.Clear(); Param[] parms = methodDef.GetParams(); if (methodDef.GetMaxStack() < 3) { methodDef.SetMaxStack(3); } string strGuid = Guid.NewGuid().ToString(); CILInstructions instructions = methodDef.GetCodeBuffer(); if (instructions == null) { return; } instructions.StartInsert(); instructions.Inst(Op.nop); instructions.StartBlock(); // Try #1 instructions.StartBlock(); // Try #2 instructions.Inst(Op.nop); instructions.ldstr(strGuid); instructions.ldstr(classNameString); instructions.ldstr(methodNameString); instructions.ldstr(paramsString); instructions.MethInst(MethodOp.call, startLogMethod); instructions.EndInsert(); while (instructions.GetNextInstruction().GetPos() < instructions.NumInstructions() - 2) { ; } instructions.StartInsert(); instructions.Inst(Op.nop); CILLabel cel0 = instructions.NewLabel(); CILLabel cel9 = instructions.NewLabel(); instructions.Branch(BranchOp.leave_s, cel9); TryBlock tBlk2 = instructions.EndTryBlock(); // #2 instructions.StartBlock(); int istloc = 0; if (methodDef.GetLocals() != null) { istloc = methodDef.GetLocals().Length; } instructions.IntInst(IntOp.stloc_s, istloc); instructions.Inst(Op.nop); //instructions.Inst(Op.rethrow); CILLabel cel = instructions.NewLabel(); instructions.CodeLabel(cel0); instructions.OpenScope(); //start---add exceptiong to stocks variables Local loc = new Local("SpyMtNoRt", Runtime.SystemExceptionRef); if (methodDef.GetLocals() != null) { foreach (Local lab in methodDef.GetLocals()) { CLRLocals.Add(lab); } } CLRLocals.Add(loc); methodDef.AddLocals(CLRLocals.ToArray(), false); foreach (Local la in methodDef.GetLocals()) { instructions.BindLocal(la); } //start---add exceptiong to stocks variables instructions.CloseScope(); instructions.IntInst(IntOp.ldloc_s, istloc); Method LogException = null; MethodLoggerUtil.GetMethodsFromClass("LogException", out LogException); instructions.MethInst(MethodOp.call, LogException); instructions.Inst(Op.nop); instructions.Inst(Op.nop); instructions.Branch(BranchOp.leave_s, cel9); instructions.EndCatchBlock(Runtime.SystemExceptionRef, tBlk2); instructions.CodeLabel(cel9); instructions.Branch(BranchOp.leave_s, cel); TryBlock tBlk1 = instructions.EndTryBlock(); // #1 instructions.StartBlock(); // Finally instructions.Inst(Op.nop); instructions.ldstr(strGuid); instructions.ldstr(classNameString); instructions.ldstr(methodNameString); instructions.ldstr(paramsString); instructions.MethInst(MethodOp.call, endLogMethod); instructions.Inst(Op.nop); instructions.Inst(Op.nop); instructions.Inst(Op.endfinally); instructions.EndFinallyBlock(tBlk1); instructions.CodeLabel(cel); instructions.EndInsert(); }