예제 #1
0
파일: Control.cs 프로젝트: freeman888/GI
        public static IOBJ GetControlFromXmlElement(GTWPF.GasControl.Page.GasPage basepage, XmlElement xmlelement)
        {
            var  cname   = xmlelement.Name;
            IOBJ control = null;

            switch (cname)
            {
            case "Bubble":
                control = GasControl.Control.Bubble.GetBubbleFromXml(xmlelement);
                break;

            case "EditText":
                control = GasControl.Control.EditText.GetEditTextFromXml(xmlelement);
                break;

            case "Image":
                control = GasControl.Control.Image.GetImageFromXml(xmlelement);
                break;

            case "Switcher":
                control = GasControl.Control.Switcher.GetSwitcherFromXml(xmlelement); break;

            case "TextCell":
                control = GasControl.Control.TextCell.GetTextCellFromXml(xmlelement); break;

            case "Tip":
                control = GasControl.Control.Tip.GetTipFromXml(xmlelement); break;

            case "WebView":
                control = GasControl.Control.WebView.GetWebViewFromXml(xmlelement); break;

            case "GridFlat":
                control = GasControl.ContentControl.GridFlat.GetGridFlatFromXml(basepage, xmlelement); break;

            case "ListFlat":
                control = GasControl.ContentControl.ListFlat.GetListFlatFromXml(basepage, xmlelement); break;

            case "ScrollFlat":
                control = GasControl.ContentControl.ScrollFlat.GetScrollFlatFromXml(basepage, xmlelement); break;

            case "StackFlat":
                control = GasControl.ContentControl.StackFlat.GetStackFlatFromXml(basepage, xmlelement); break;

            default:
                throw new Exceptions.RunException(Exceptions.EXID.无对应属性);
            }
            if (control != null)
            {
                basepage.controls.Add(xmlelement.GetAttribute("Name"), control);
            }
            return(control);
        }
예제 #2
0
        public GClass(string type, string parent, Hashtable xc, IFunction ctor)
        {
            this.ctor = ctor;
            this.type = type;
            if (!string.IsNullOrEmpty(parent))
            {
                //由此得出构造顺序,先构造父对象,再构造本对象,给父对象传入的依旧是本对象构造函数的参数,这儿可以考虑修改
                var ct_parent = xc.GetCSVariable <GClassTemplate>(parent);
                var func      = ctor as Function.New_Creat_Function;
                if (ctor != null && func != null && func.baseresulter != null)
                {
                    var alist = new ArrayList();

                    foreach (var i in func.baseresulter.resulters)
                    {
                        alist.Add(i.Run(xc).Result);
                    }
                    var newsc = Variable.Resulter.Setvariablesname(ct_parent.ctor.Istr_xcname, alist, ct_parent.poslib);

                    this.parent = ct_parent.CreatFromClassTemplate(newsc);
                }
                else
                {
                    this.parent = ct_parent.CreatFromClassTemplate(Variable.GetOwnVariables(ct_parent.poslib));
                }

                //如果继承自内部对象的话,内部对象如果有可能使用gasoline对象的时候需要给内部对象绑定gasoline对象,所以实现了内部对象
                //和gasoline对象的相互绑定。内部对象只绑定继承次数最大的对象。最子的对象。
                if (this.parent is IGasObjectContainer)
                {
                    gasObjectContainer = this.parent as IGasObjectContainer;
                }
                else if (this.parent is GClass)
                {
                    if (((GClass)this.parent).gasObjectContainer != null)
                    {
                        gasObjectContainer = ((GClass)this.parent).gasObjectContainer;
                    }
                }
            }
        }
예제 #3
0
파일: System.cs 프로젝트: freeman888/GI
            public System_Lib()
            {
                myThing.Add("GetType", new Variable(new System_Function_Gettype()));
                myThing.Add("Exit", new Variable(new System_Function_Exit()));
                myThing.Add("Const", new Variable(new System_Function_Const()));
                myThing.Add("const", new Variable(new System_Function_Const()));
                myThing.Add("GetInterpreterVersion", new Variable(new DFunction {
                    IInformation = "get the version of interpreter", dRun = (xc) => new Variable(GIInfo.GIVersion)
                }));
                myThing.Add("GetInterpreter", new Variable(new DFunction {
                    IInformation = "get the name of interpreter", dRun = (xc) => new Variable("GI")
                }));
                myThing.Add("GetPlatform", new Variable(new DFunction {
                    IInformation = "get the paltform", dRun = (xc) => new Variable(GIInfo.Platform)
                }));
                myThing.Add("GetFolderPath", new Variable(new System_Function_GetFolderPath()));
                #region 获取时间
                myThing.Add("GetTime", new Variable(new DFunction
                {
                    IInformation = @"get the time.
[val(string)]:
y or year
m or month
d or day
h or hour
min or minute
s or second
date
time",
                    str_xcname   = "val",
                    dRun         = (xc) =>
                    {
                        DateTime dateTime = DateTime.Now;
                        string val        = Variable.GetTrueVariable <object>(xc, "val").ToString().ToLower();
                        switch (val)
                        {
                        case "y":
                        case "year":
                            return(new Variable(dateTime.Year));


                        case "m":
                        case "month":
                            return(new Variable(dateTime.Month));

                        case "d":

                        case "day":
                            return(new Variable(dateTime.Day));

                        case "h":

                        case "hour":
                            return(new Variable(dateTime.Hour));

                        case "min":

                        case "minute":
                            return(new Variable(dateTime.Minute));

                        case "s":

                        case "second":
                            return(new Variable(dateTime.Second));

                        case "date":
                            return(new Variable(dateTime.ToLongDateString()));

                        case "time":
                            return(new Variable(dateTime.ToLongTimeString()));

                        default:
                            return(null);
                        }
                    }
                }));
                #endregion
                myThing.Add("Debug", new Variable(new DFunction {
                    IInformation = "output when debugging", str_xcname = "str", dRun = (xc) => { Gdebug.WriteLine(xc.GetVariable <object>("str").ToString()); return(new Variable(0)); }
                }));
                myThing.Add("Help", new Variable(new DFunction
                {
                    IInformation = "return the help of \'in\'",
                    str_xcname   = "in",
                    dRun         = (xc) =>
                    {
                        object o = xc.GetCSVariable <object>("in");
                        if (o is IFunction)
                        {
                            var function = o as IFunction;
                            return(new Variable($"function \n param : {function.Istr_xcname} \n is a reffun : {function.Iisreffunction} \n information : {function.IInformation}"));
                        }
                        return(new Variable(0));
                    }
                }));
                myThing.Add("async", new Variable(new Asyncfunc()));
                myThing.Add("await", new Variable(new System_Function_Await()));
                myThing.Add("wait", new Variable(new System_Function_Wait()));
                myThing.Add("Shell", new Variable(new System_Function_Shell()));
                myThing.Add("GetAppPath", new Variable(new System_Function_GetAppPath()));
                myThing.Add("GetResourcesPath", new Variable(new System_Function_GetResourcesPath()));
                myThing.Add("ObjEqual", new Variable(new DFunction
                {
                    IInformation = "compare the object",
                    str_xcname   = "o1,o2",
                    dRun         = (xc) =>
                    {
                        IOBJ o1 = xc.GetVariable <IOBJ>("o1"), o2 = xc.GetVariable <IOBJ>("o2");
                        if (o1.IGetCSValue() == null)
                        {
                            return(new Variable(o1.Equals(o2)));
                        }
                        else
                        {
                            return(new Variable(o1.IGetCSValue().Equals(o2.IGetCSValue())));
                        }
                    }
                }));
            }
예제 #4
0
 public MFunction(IFunction function, IOBJ self)
 {
     this.function = function;
     this.self     = self;
     poslib        = function.poslib;
 }
예제 #5
0
파일: MyExFuncs.cs 프로젝트: freeman888/GI
        public static T GetCSVariable <T>(this Hashtable hashtable, string varname)
        {
            IOBJ io = ((Variable)hashtable[varname]).value;

            return((T)io.IGetCSValue());
        }