public static string GenReactiveMemberProperty(this JObject jom, JObject jo) { string template = @" /* {DESC} */ public ReactiveProperty<{TYPE}> RP_{NAME}; {JSONPROPERTY}{JSONCONVERTER} public {TYPE} {NAME} { get { return RP_{NAME}.Value; } set { RP_{NAME}.Value = value; } }" ; DocType?dt = PGFrameTools.GetDocTypeByWorkspaceAndType(jo ["Workspace"].Value <string> (), jom ["Type"].Value <string> ()); if (dt.HasValue && dt.Value == DocType.Element) { template = template.Replace("{JSONPROPERTY}", string.Empty); } else { template = template.Replace("{JSONPROPERTY}", "[JsonProperty]"); } template = template.Replace("{NAME}", jom ["Name"].Value <string> ()); template = template.Replace("{TYPE}", jom ["Type"].Value <string> ()); template = template.Replace("{DESC}", jom ["Desc"].Value <string> ()); template = template.Replace("{JSONCONVERTER}", GetAttributeCode(jom ["Type"].Value <string> ())); return(template); }
public string GetVMPropertyRefCode(JObject jo) { StringBuilder sb = new StringBuilder(); string ws_name = jo ["Workspace"].Value <string> (); JArray ja_members = jo ["Member"] as JArray; for (int i = 0; i < ja_members.Count; i++) { JObject jo_member = ja_members [i] as JObject; RxType rt = (RxType)Enum.Parse(typeof(RxType), jo_member ["RxType"].Value <string> ()); if (rt == RxType.Property) { string member_name = jo_member ["Name"].Value <string> (); string member_type = jo_member ["Type"].Value <string> (); DocType?dt = PGFrameTools.GetDocTypeByWorkspaceAndType(ws_name, member_type); if (dt.HasValue && dt.Value == DocType.Element) { string element_name = member_type.ConvertToElementName(); sb.AppendFormat(@" if (_{0}View != null) {{ if (_{0}View.GetViewModel () == null) {{ _{0}View.CreateViewModel (); }} ViewModelBase _{0}ViewModel = _{0}View.GetViewModel (); if (_{0}ViewModel != null) {{ VM.{0} = _{0}View.GetViewModel () as {1}ViewModel; }} }}" , member_name, element_name); } } } return(sb.ToString()); }
public string GetVMPropertyViewCode(JObject jo) { StringBuilder sb = new StringBuilder(); string ws_name = jo ["Workspace"].Value <string> (); JArray ja_members = jo ["Member"] as JArray; for (int i = 0; i < ja_members.Count; i++) { JObject jo_member = ja_members [i] as JObject; RxType rt = (RxType)Enum.Parse(typeof(RxType), jo_member ["RxType"].Value <string> ()); if (rt == RxType.Property) { string member_name = jo_member ["Name"].Value <string> (); string member_type = jo_member ["Type"].Value <string> (); DocType?dt = PGFrameTools.GetDocTypeByWorkspaceAndType(ws_name, member_type); if (dt.HasValue && dt.Value == DocType.Element) { string[] element_splited_type = PGFrameTools.SplitWorkspaceAndTypeName(string.Empty, member_type); string element_ws = element_splited_type [0]; string element_type = element_splited_type [1]; string element_name = element_type.ConvertToElementName(); sb.AppendFormat(@" {2}I{1}View {0}View {{ get; set; }}" , member_name, element_name, string.IsNullOrEmpty(element_ws) ? "" : element_ws + "."); } } } return(sb.ToString()); }