예제 #1
0
        protected override JsUnit OnAfterExportType(ITypeDefinition ce, JsClrType jsType)
        {
            var extJsType = new ExtJsType
            {
                extend  = jsType.baseTypeName,
                statics = jsType.staticDefinition,
            };
            //if (extJsType.extend == "System.Object")
            //    extJsType.extend = null;
            var json = (JsJsonObjectExpression)Serialize(extJsType);

            //var ctor = json.NamesValues.Where(t => t.Name.Name == "ctor").FirstOrDefault();
            if (jsType.definition == null)
            {
                jsType.definition = new JsObject();
            }
            var ctor = jsType.definition.TryGetValue("ctor");

            if (ctor != null)
            {
                jsType.definition.Remove("ctor");
                jsType.definition.Add("constructor", ctor);
                //ctor.Name.Name = "constructor";
                //var func = ctor.Value as JsFunction;
                //if (func != null)
                //{
                //    func.Block.Statements.Insert(0, Js.This().Member("callSuper").Invoke(Js.Member("arguments")).Statement());
                //}
            }
            foreach (var me in jsType.definition)
            {
                var name  = me.Key;
                var value = (JsExpression)me.Value;
                if (json.NamesValues == null)
                {
                    json.NamesValues = new List <JsJsonNameValue>();
                }
                json.NamesValues.Add(new JsJsonNameValue {
                    Name = new JsJsonMember {
                        Name = name
                    }, Value = value
                });
            }

            var define = Js.Members("Ext.define").Invoke(Js.String(jsType.fullname), json).Statement();
            var unit   = new JsUnit {
                Statements = new List <JsStatement> {
                    define
                }
            };

            return(unit);// base.OnAfterExportType(ce, jsType);
        }
예제 #2
0
        protected override JsUnit OnAfterExportType(ITypeDefinition ce, JsClrType jsType)
        {
            var extJsType = new ExtJsType
            {
                extend = jsType.baseTypeName,
                statics = jsType.staticDefinition,
            };
            //if (extJsType.extend == "System.Object")
            //    extJsType.extend = null;
            var json = (JsJsonObjectExpression)Serialize(extJsType);
            //var ctor = json.NamesValues.Where(t => t.Name.Name == "ctor").FirstOrDefault();
            if (jsType.definition == null)
                jsType.definition = new JsObject();
            var ctor = jsType.definition.TryGetValue("ctor");
            if (ctor != null)
            {
                jsType.definition.Remove("ctor");
                jsType.definition.Add("constructor", ctor);
                //ctor.Name.Name = "constructor";
                //var func = ctor.Value as JsFunction;
                //if (func != null)
                //{
                //    func.Block.Statements.Insert(0, Js.This().Member("callSuper").Invoke(Js.Member("arguments")).Statement());
                //}
            }
            foreach (var me in jsType.definition)
            {
                var name = me.Key;
                var value = (JsExpression)me.Value;
                if (json.NamesValues == null)
                    json.NamesValues = new List<JsJsonNameValue>();
                json.NamesValues.Add(new JsJsonNameValue { Name = new JsJsonMember { Name = name }, Value = value });
            }

            var define = Js.Members("Ext.define").Invoke(Js.String(jsType.fullname), json).Statement();
            var unit = new JsUnit { Statements = new List<JsStatement> { define } };
            return unit;// base.OnAfterExportType(ce, jsType);
        }