Пример #1
0
        public void Evaluate()
        {
            //Step 1)  Apply uses
            var use = Object["use"];

            if (use?.Count > 0)
            {
                foreach (var u in use)
                {
                    var eles = u.Value.Split(new char[] { ' ', '\t', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var ele in eles)
                    {
                        var intop = InteropProvider.Get(ele);
                        if (intop == null)
                        {
                            throw new NullReferenceException("Interop Provider not found for " + u.Value);
                        }

                        intop.Install();
                    }
                }
            }

            //Step 2)  Apply type
            if (Is.MetaedObject(Object))
            {
                switch (Object.Value.ToLower())
                {
                case "set":
                    Console.WriteLine("It's a set!");
                    break;

                case "app":
                case "application":
                    //Do nothing, same as default
                    break;

                default:
                    throw new InvalidOperationException("Unknown application-object type: " + Object.Value);
                }
            }

            //Step 3)  Validate

            //Step 4)  Ready
            if (!HasReadied)
            {
                HasReadied = true;
                var whenReady = Object.Get("when", "ready");
                if (!whenReady.IsUndefined)
                {
                    Evaluator.Evaluate(whenReady.Value);
                }
                else if (!string.IsNullOrEmpty(Object.Value))
                {
                    Evaluator.Evaluate(Object.Value);
                }
            }

            //Step 5)  Running
            while (RunningCount > 0)
            {
                Thread.Sleep(50);
            }
        }