////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public SpecStepRuleRow(FabSpecService pService, FabSpecServiceStep pStep,
                        FabSpecServiceStepRule pRule)
 {
     Service = pService;
     Step    = pStep;
     Rule    = pRule;
 }
Exemplo 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);
        }