示例#1
0
        private EbObject DeserializeJsonObject()
        {
            EbObject obj = null;

            try
            {
                string regexed = EbSerializers.JsonToNETSTD(this.Json);
                obj = EbSerializers.Json_Deserialize <EbObject>(regexed);
            }
            catch (Exception ex)
            {
                EbLog.Info("DeserializeJsonPage error inside pagewrapper");
                EbLog.Error(ex.Message);
            }
            return(obj);
        }
示例#2
0
        private void GetJsObject(object obj)
        {
            this.CtrlCounters += obj.GetType().GetTypeInfo().Name.Substring(2) + "Counter : 0,";
            string _props = string.Empty;

            PropertyInfo[] props = obj.GetType().GetAllProperties();

            //if (obj is EbControlContainer)
            //    _props += @"this.IsContainer = true;";

            foreach (PropertyInfo prop in props)
            {
                IEnumerable <Attribute> propattrs = prop.GetCustomAttributes();////////////////

                if (prop.IsDefined(typeof(EnableInBuilder), false) &&
                    prop.GetCustomAttribute <EnableInBuilder>().BuilderTypes.Contains(this.BuilderType))
                {
                    _props += JsVarDecl(prop, obj);
                }
            }


            this.AllMetas += @"
'@Name'  : @MetaCollection,"
                             .Replace("@Name", obj.GetType().Name)
                             .Replace("@MetaCollection", JsonConvert.SerializeObject(this.GetMetaCollection(obj)));
            try
            {
                EbObject  EbO_obj       = (obj as EbObject);
                bool      isEbObject    = obj is EbObject;
                EbControl sampOBJ       = (obj as EbControl);
                string    AssemblyQname = obj.GetType().AssemblyQualifiedName;

                this.JsObjects += @"
EbObjects.@Name = function @Name(id, jsonObj) {
    this.$type = '@Type';
    this.EbSid = id;
    @Props
    this.EbSid_CtxId = id;
    @InitFunc
    @4botHtml
    this.$Control = $( @html.replace(/@id/g, this.EbSid) );
    this.BareControlHtml = `@bareHtml`.replace(/@id/g, this.EbSid);
	this.DesignHtml = @html;
    var MyName = this.constructor.name;
    this.RenderMe = function () { 
var NewHtml = this.$BareControl.outerHTML(), me = this, metas = AllMetas[MyName];
    $.each(metas, function (i, meta) { 
        var name = meta.name;
        if (meta.IsUIproperty){
            NewHtml = NewHtml.replace('@' + name + ' ', me[name]);
        }
    });
    if(!this.IsContainer)
        $('#' + id).html($(NewHtml).html());
};
    if (jsonObj){
        jsonObj.RenderMe  = this.RenderMe;
        jsonObj.Html  = this.Html;
        jsonObj.Init   = this.Init;
        $.extend(this, jsonObj);
        //_.mergeWith(
	       // {}, this, jsonObj,
        //  (a, b) => b === null ? a : undefined
        //)
        if(jsonObj.IsContainer)
            this.Controls  = new EbControlCollection( {} );
        //if(this.Init)
        //    jsonObj.Init(id);
    }
    else{
        if(this.Init)
            this.Init(id);
    }
};"
                                  .Replace("@Name", obj.GetType().Name)
                                  .Replace("@Type", AssemblyQname.Split(",")[0] + "," + AssemblyQname.Split(",")[1])
                                  .Replace("@Props", _props)
                                  .Replace("@InitFunc", isEbObject ? EbO_obj.GetJsInitFunc() : string.Empty)
                                  .Replace("@html", isEbObject ? EbO_obj.GetDesignHtml() : "``")
                                  .Replace("@4botHtml", (obj is EbControl) ? ("this.$WrapedCtrl4Bot = $(`" + (obj as EbControl).GetWrapedCtrlHtml4bot(ref sampOBJ) + "`);") : string.Empty)
                                  .Replace("@bareHtml", isEbObject ? EbO_obj.GetBareHtml() : string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.ToString());
            }
        }
        //[ProtoBuf.ProtoMember(1)]
        //[Browsable(false)]
        //public IEbControl[] Controls2
        //{
        //    get
        //    {
        //        IEbControl[] ca = new IEbControl[this.Controls.Count];
        //        this.Controls.CopyTo(ca, 0);
        //        return ca;
        //    }
        //    set
        //    {
        //        foreach (IEbControl c in value)
        //            this.Controls.Add((Control)c);
        //    }
        //}

        public void DoDesignerLayout(pF.pDesigner.IpDesigner designer, EbObject serialized_ctrl)
        {
            //var ctrl = designer.ActiveDesignSurface.CreateControl(this.GetType(), this.Size, this.Location) as System.Windows.Forms.Control;
            //ctrl.Name = this.Name;
        }