示例#1
0
 public object Lookup(IIndexArgumentList args)
 {
     if (args.TryGetStringParameter("id") == "x")
     {
         return("passedX");
     }
     return(_value);
 }
示例#2
0
 public object Lookup(IIndexArgumentList args)
 {
     if (args.TryGetStringParameter("id") == "x")
     {
         return("y");
     }
     return(null);
 }
示例#3
0
        public object Lookup(IIndexArgumentList args)
        {
            var text = args.TryGetStringParameter("text");

            if (text != null)
            {
                return(StarWars.AllEntities.Where(e => e.name.Contains(text)));
            }

            return(null);
        }
示例#4
0
        public object Lookup(IIndexArgumentList args)
        {
            var id = args.TryGetStringParameter("id");

            if (id != null)
            {
                return(StarWars.AllEntities.FirstOrDefault(e => e.id == id && e is Starship));
            }

            return(null);
        }
示例#5
0
        public object Lookup(IIndexArgumentList args)
        {
            var ep = args.TryGetStringParameter("episode");

            ep = ep ?? "NEWHOPE";
            Entity result;

            if (StarWars.Heroes.TryGetValue(ep, out result))
            {
                return(result);
            }

            return(null);
        }
示例#6
0
        public object Lookup(IIndexArgumentList args)
        {
            var key = args.TryGetStringParameter(_paramName);

            if (key == null)
            {
                return(null);
            }
            object value;

            if (_values.TryGetValue(key, out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
示例#7
0
        public async Task <object> Lookup(IIndexArgumentList args)
        {
            var key = args.TryGetStringParameter(_paramName);

            if (key == null)
            {
                return(null);
            }
            object value;

            if (_values.TryGetValue(key, out value))
            {
                return(await value.Delayed());
            }
            else
            {
                return(null);
            }
        }
示例#8
0
            public object Lookup(IIndexArgumentList filter)
            {
                var all = new List <Dictionary <string, object> >();

                foreach (var currName in _names)
                {
                    all.Add(new Dictionary <string, object> {
                        ["name"] = currName, ["length"] = (double)currName.Length
                    });
                }

                var name = filter.TryGetStringParameter("name");

                if (name != null)
                {
                    return(all.Where(e => (string)e["name"] == name));
                }

                return(new AsyncError("Not found"));
            }
示例#9
0
            public object Lookup(IIndexArgumentList args)
            {
                var id         = args.TryGetStringParameter("key");
                var capitalize = args.TryGetBooleanParameter("capitalize") == true;

                id = id ?? "foo";

                string result = null;

                if (id == "hello")
                {
                    result = "world";
                }
                else if (id == "foo")
                {
                    result = "bar";
                }
                else
                {
                    result = null;
                }

                return(capitalize ? result?.ToUpper() : result);
            }