Пример #1
0
 void Named(StringBuilder sb, Meta v)
 {
     if (Spec.named)
     {
         Rfc6570.Named(sb, Var.key, v.IsNullOrEmpty, Spec.ifemp, Spec.allow);
     }
 }
Пример #2
0
        void Expand(IParams keys)
        {
            Var[] vars;
            var   spec  = Rfc6570.spec(Variable, out vars);
            var   first = true;

            for (var i = 0; i < vars.Length; ++i)
            {
                var var = vars[i];

                object obj;
                if (!keys.TryGetValue(var.key, out obj))
                {
                    continue;
                }

                var meta = Meta(obj);
                if (meta.IsNull || (!meta.IsString && meta.IsEmpty))
                {
                    continue;
                }

                var key   = var.key;
                var fst   = spec.fst;
                var sep   = spec.sep;
                var named = spec.named;
                var ifemp = spec.ifemp;
                var allow = spec.allow;

                Builder.Append(tos(first ? fst : sep));

                if (!meta.IsEnumerable || meta.IsString)
                {
                    if (var.prefix)
                    {
                        Scalar(Builder, named, ifemp, allow, key, var.length, meta);
                    }
                    else
                    {
                        Scalar(Builder, named, ifemp, allow, key, meta);
                    }
                }
                else if (var.explode)
                {
                    Explode(Builder, sep, named, ifemp, allow, key, meta);
                }
                else
                {
                    NoExplode(Builder, named, ifemp, allow, key, meta);
                }

                first = false;
            }
        }
Пример #3
0
            public Expansion(Rfc6570 rfc, Spec spec, Var[] vars)
            {
                var actions = new List <Act>();

                for (var i = 0; i < vars.Length; ++i)
                {
                    actions.Add(new Act(rfc, spec, vars[i]));
                }

                _rfc     = rfc;
                _actions = actions.ToArray();
            }
Пример #4
0
 void Prefix(StringBuilder sb, Meta v, bool first)
 {
     sb.Append(tos(first ? Spec.fst : Spec.sep));
     Rfc6570.Scalar(sb, Spec.named, Spec.ifemp, Spec.allow, Var.key, v);
 }
Пример #5
0
 public Act(Rfc6570 rfc, Spec spec, Var var)
 {
     Rfc  = rfc;
     Spec = spec;
     Var  = var;
 }