Ejemplo n.º 1
0
        /*--------------------------------------------------------------------------------------------*/
        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);
        }
Ejemplo n.º 2
0
        /*--------------------------------------------------------------------------------------------*/
        private static FabSpecServiceStep BuildTraversalServiceStep(SpecStepAttribute pStepAttr,
                                                                    IList <ITravRule> pRules)
        {
            var s = new FabSpecServiceStep();

            s.Name        = pStepAttr.Name;
            s.Description = ApiLang.Text <StepText>(s.Name);
            s.Parameters  = new List <FabSpecServiceParam>();
            s.Rules       = new List <FabSpecServiceStepRule>();

            ITravStep ts0 = pRules[0].Step;

            foreach (ITravStepParam tsp in ts0.Params)
            {
                var p = new FabSpecServiceParam();
                p.Index       = tsp.ParamIndex;
                p.Name        = tsp.Name;
                p.Description = ApiLang.Text <StepParamText>(s.Name + "_" + p.Name);
                p.Type        = ApiLang.TypeName(tsp.DataType);
                p.Min         = tsp.Min;
                p.Max         = tsp.Max;
                p.LenMax      = tsp.LenMax;
                p.ValidRegex  = tsp.ValidRegex;
                s.Parameters.Add(p);

                if (tsp.IsGenericDataType)
                {
                    p.Type = "T";
                }

                if (tsp.AcceptedStrings != null)
                {
                    p.AcceptedStrings = tsp.AcceptedStrings.ToArray();
                }
            }

            foreach (ITravRule rule in pRules)
            {
                ITravStep ts = rule.Step;

                var r = new FabSpecServiceStepRule();
                r.Name  = ts.Command;
                r.Uri   = "/" + ts.Command;
                r.Entry = ApiLang.TypeName(rule.FromType);
                s.Rules.Add(r);

                if (rule.ToType != null)
                {
                    r.Return = ApiLang.TypeName(rule.ToType);
                }

                if (ts.ToAliasType)
                {
                    r.ReturnsAliasType = true;
                }

                if (ts.ParamValueType != null)
                {
                    r.T = ApiLang.TypeName(ts.ParamValueType);
                }
            }

            return(s);
        }