/*--------------------------------------------------------------------------------------------*/ private static FabSpecService BuildService(FabService pSvc, Func <string, ApiEntry> pGetEntry) { var s = new FabSpecService(); s.Name = pSvc.Name; s.Uri = pSvc.Uri; s.Summary = ApiLang.Text <ServiceText>(s.Name + "Summ"); s.Description = ApiLang.Text <ServiceText>(s.Name + "Desc"); s.Operations = new List <FabSpecServiceOperation>(); foreach (FabServiceOperation svcOp in pSvc.Operations) { if (svcOp == null) { throw new Exception("Missing ServiceOperation for '" + pSvc.Name + "'."); } string key = svcOp.Method + " " + s.Uri + svcOp.Uri; ApiEntry ae; try { ae = pGetEntry(key); } catch (Exception e) { throw new Exception("No ApiEntry for '" + pSvc.Name + "' with key '" + key + "'.", e); } FabSpecServiceOperation sso = BuildServiceOp(s.Name, svcOp, ae); s.Operations.Add(sso); } return(s); }
/*--------------------------------------------------------------------------------------------*/ private static FabSpecServiceOperation BuildServiceOp(string pSvcName, FabServiceOperation pSvcOp, ApiEntry pEntry) { var so = new FabSpecServiceOperation(); so.Name = pSvcOp.Name; so.Uri = pSvcOp.Uri; so.Method = pSvcOp.Method; so.Return = ApiLang.TypeName(pEntry.ResponseType); so.Description = ApiLang.Text <ServiceOpText>(pSvcName + "_" + so.Name + "_" + so.Method); so.Auth = (pEntry.MemberAuth ? "Member" : "None"); so.Parameters = new List <FabSpecServiceParam>(); for (int i = 0; i < pEntry.Params.Count; i++) { ApiEntryParam aep = pEntry.Params[i]; var sop = new FabSpecServiceParam(); sop.Index = i; sop.Name = aep.Name; sop.Type = ApiLang.TypeName(aep.ParamType); so.Parameters.Add(sop); string langKey = (aep.LangKey ?? pSvcName + "_" + so.Name + "_" + sop.Name); sop.Description = ApiLang.Text <ServiceOpParamText>(langKey); } return(so); }