Ejemplo n.º 1
0
        /*--------------------------------------------------------------------------------------------*/
        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);
        }
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public SpecStepRuleRow(FabSpecService pService, FabSpecServiceStep pStep,
                        FabSpecServiceStepRule pRule)
 {
     Service = pService;
     Step    = pStep;
     Rule    = pRule;
 }
Ejemplo n.º 3
0
        /*--------------------------------------------------------------------------------------------*/
        private static FabSpecService BuildTraversalService(FabService pSvc,
                                                            Func <string, ApiEntry> pGetEntry)
        {
            IList <ITravRule> rules = TraversalUtil.GetTravRules();
            var map = new Dictionary <SpecStepAttribute, IList <ITravRule> >();

            foreach (ITravRule rule in rules)
            {
                SpecStepAttribute ssa = GetAttribute <SpecStepAttribute>(rule.Step.GetType());

                if (!map.ContainsKey(ssa))
                {
                    map.Add(ssa, new List <ITravRule>());
                }

                map[ssa].Add(rule);
            }

            ////

            FabSpecService svc = BuildService(pSvc, pGetEntry);

            svc.Steps = new List <FabSpecServiceStep>();

            foreach (SpecStepAttribute ssa in map.Keys)
            {
                if (ssa.IsRoot)
                {
                    continue;
                }

                svc.Steps.Add(BuildTraversalServiceStep(ssa, map[ssa]));
            }

            return(svc);
        }