コード例 #1
0
ファイル: Interpreter.cs プロジェクト: retahc/old-code
        public static object Execute(LogoContext context, ICollection runlist, params object[] template_args)
        {
            string[] runlist_strs = new string[runlist.Count];
            int      i            = 0;

            foreach (object o in runlist)
            {
                if (o is ICollection)
                {
                    runlist_strs[i] = Funcs.ListToString((ICollection)o, 0, true);
                }
                else
                {
                    runlist_strs[i] = o.ToString();
                }
                i++;
            }

            Interpreter interp = new Interpreter((Interpreter)context.CallingEngine, context);

            interp.template_args = template_args;

            Parser parser = new Parser(interp.stores, null);

            parser.AllowQuestionMark = true;
            InstructionList tree = parser.Parse(runlist_strs);

            return(interp.Execute(tree));
        }
コード例 #2
0
        public void Invoke(LogoContext context, ICollection arguments, ref object result)
        {
            // Debug (arguments);

            LogoContext cc   = new LogoContext(context);
            Hashtable   dict = cc.Dict;

            object[] arguments_list = new object[arguments.Count];
            arguments.CopyTo(arguments_list, 0);

            int i = 0;

            foreach (ArgumentInfo info in args)
            {
                if (i < arguments_list.Length)
                {
                    dict[info.name] = arguments_list[i];
                }
                else if (info.val != null)
                {
                    dict[info.name] = info.val;
                }
                i++;
            }

            // Collect remaining arguments
            if (args.Length > 0 && args[args.Length - 1].collect)
            {
                int col_len = arguments_list.Length - args.Length;
                if (col_len < 0)
                {
                    col_len = 0;
                }
                object[] collector = new object[col_len];
                if (col_len > 0)
                {
                    Array.Copy(arguments_list, args.Length, collector, 0, col_len);
                }

                dict[args[args.Length - 1].name] = collector;
            }

            Interpreter interp = new Interpreter((Interpreter)context.CallingEngine, cc);

            result = interp.Execute(tree);
        }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: patravishek/ukdc
        public ActionResult UploadLogo(LogoModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.File.ContentLength > 0)
                {
                    string FileName = Path.GetFileName(model.File.FileName);
                    string SavePath = Path.Combine(Server.MapPath("~/Logo"), FileName);
                    if (!Directory.Exists(Server.MapPath("~/Logo")))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/Logo"));
                    }
                    model.File.SaveAs(SavePath);
                    var logoContext = new LogoContext
                    {
                        AltText  = model.AltText,
                        LogoPath = FileName
                    };

                    using (var context = new ApplicationDbContext())
                    {
                        var logoInfo = context.LogoContexts.FirstOrDefault();
                        if (logoInfo == null)
                        {
                            context.LogoContexts.Add(logoContext);
                        }
                        else
                        {
                            logoInfo.AltText  = model.AltText;
                            logoInfo.LogoPath = FileName;
                        }

                        context.SaveChanges();
                    }
                }
            }
            return(View());
        }
コード例 #4
0
ファイル: Interpreter.cs プロジェクト: retahc/old-code
 public Interpreter(Interpreter interp, LogoContext context)
 {
     this.stores  = interp.stores;
     this.context = context;
 }
コード例 #5
0
ファイル: Interpreter.cs プロジェクト: retahc/old-code
 public Interpreter(IMessageStoreCollection stores)
 {
     this.stores = stores;
     context     = new LogoContext(null);
 }
コード例 #6
0
ファイル: Compiler.cs プロジェクト: retahc/old-code
 protected Compiler(IMessageStoreCollection stores)
 {
     this.stores = stores;
     context     = new LogoContext(null);
 }