public static CodeTypeMember CreatePropertyCode(this SAPDataParameter p) { CodeSnippetTypeMember snippet = new CodeSnippetTypeMember(); if (p.Comment != null) { snippet.Comments.Add(new CodeCommentStatement(p.Comment, true)); } snippet.Text = string.Format("public {0} {1} {{get;set;}}", p.Type.ToString(), p.Name); return(snippet); }
void _sapGuiSession_Change(GuiSession Session, GuiComponent Component, object CommandArray) { if (_stepAction == null) { return; } SapCompInfo cpInfo = new SapCompInfo(); cpInfo.Id = Component.Id; cpInfo.Name = Component.Name; cpInfo.Type = Component.GetDetailType(); if (Component is GuiVComponent) { var vc = Component as GuiVComponent; try { cpInfo.Tip = vc.DefaultTooltip == "" ? vc.Tooltip : vc.DefaultTooltip; } catch { } } if (_isFindById) { cpInfo.FindMethod = Component.FindByIdCode(); } else { cpInfo.FindMethod = Component.FindByNameCode(); } RecordStep step = new RecordStep(); step.CompInfo = cpInfo; object[] objs = CommandArray as object[]; objs = objs[0] as object[]; switch (objs[0].ToString().ToLower()) { case "m": step.Action = BindingFlags.InvokeMethod; break; case "sp": step.Action = BindingFlags.SetProperty; break; } var action = objs[1].ToString(); upperFirstChar(ref action); step.ActionName = action; var count = objs.Count(); if (count > 2) { step.ActionParams = new List <SAPDataParameter>(); if (step.Action == BindingFlags.InvokeMethod) { MethodInfo method = GetSAPTypeInfo(step.CompInfo.Type).GetMethod(step.ActionName); //MethodInfo method = SAPAutomationHelper.Current.GetSAPTypeInfo<MethodInfo>(step.CompInfo.Type, t => t.GetMethod(step.ActionName)); int index = 2; foreach (var pInfo in method.GetParameters()) { var para = new SAPDataParameter(); para.Type = pInfo.ParameterType; para.Comment = pInfo.Name; para.Value = objs[index]; para.Name = pInfo.Name; step.ActionParams.Add(para); index++; } } else { for (int i = 2; i < count; i++) { var para = new SAPDataParameter(); para.Type = objs[i].GetType(); para.Value = objs[i]; para.Comment = step.CompInfo.Tip; step.ActionParams.Add(para); } } } _stepAction(step); }
public static CodeVariableReferenceExpression GetVariableReference(this SAPDataParameter p, string dataClass) { return(new CodeVariableReferenceExpression(string.Format("{0}.{1}", dataClass, p.Name))); }