Ejemplo n.º 1
0
        private object LoopNodes <K, V>(jsObject Context, K Key, V Value)
        {
            var Var = new jsObject();

            Variable.Assign(Context, Var);

            Var.Set("Key", Key);
            Var.Set("Value", Value);

            foreach (var Node in this.Values)
            {
                if (Node is Return)
                {
                    return(Node);
                }

                var Ret = GetValue(Node, Context);

                if (Ret == Break || Ret == Continue)
                {
                    return(Ret);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        public CustomTypeInstance CreateInstance(jsObject Args)
        {
            Function           Func;
            CustomTypeInstance Instance = new CustomTypeInstance(this);

            Properties.ForEach((K, V) => {
                V.Evaluate(Instance);
            });

            if (Functions.TryGetValue(ShortName, out Func))
            {
                Args.Set("this", Instance);

                Func.Evaluate(Args);
            }

            return(Instance);
        }
Ejemplo n.º 3
0
Archivo: Url.cs Proyecto: azend/Poly
        public new bool Parse(string Url)
        {
            var Matches = Url.Match("{Protocol}://{Routing}/{Path}");

            if (Matches == null)
            {
                return(false);
            }

            this.Set("Protocol", Matches.Get <string>("Protocol"));

            var Route = Matches.Get <string>("Routing");
            var Host  = Route;

            if (Route.Contains("@"))
            {
                var Index = Route.LastIndexOf('@');
                var Auth  = Route.Substring(0, Index);

                if (Auth.Contains(':'))
                {
                    Index = Auth.IndexOf(':');

                    var Username = Auth.Substring(0, Index);
                    var Password = Auth.Substring(Index + 1);

                    this.Set("Username", Username);
                    this.Set("Password", Password);
                }
                else
                {
                    this.Set("Username", Auth);
                }

                Host = Route.Substring(Index + 1);
            }

            if (Host.Contains(':'))
            {
                var Index = Host.IndexOf(':');
                var Port  = Host.Substring(Index + 1);

                Host = Host.Substring(0, Index);
                this.Set("Port", Port.ToInt());
            }

            this.Set("Host", Host);

            Route = Matches.Get <string>("Path");

            if (Route == null)
            {
                Route = "";
            }

            this.Set("Request", "/" + Route);

            if (Route.Contains('#'))
            {
                var Index = Route.IndexOf('#');

                this.Set("Fragment", Route.Substring(Index + 1));

                Route = Route.Substring(0, Index);
            }

            if (Route.Contains('?'))
            {
                var Index = Route.IndexOf('?');
                var Path  = Route.Substring(0, Index);
                var Query = Route.Substring(Index + 1);

                this.Set("Path", Path);

                var Vars = Query.Split('&', ';');
                var QObj = new jsObject();

                for (Index = 0; Index < Vars.Length; Index++)
                {
                    var Pair = Vars[Index].Split('=');

                    if (Pair.Length != 2)
                    {
                        break;
                    }

                    var Key   = Pair[0];
                    var Value = Pair[1];

                    QObj.Set(Key, Value);
                }

                this.Set("Query", QObj);
            }
            else
            {
                this.Set("Path", Route);
            }

            return(true);
        }