Beispiel #1
0
        /// <summary>
        /// 生成定义的语句
        /// </summary>
        /// <param name="pClassFullName">类全名</param>
        /// <param name="pDefinitionConfigs">类定义的配置项</param>
        /// <param name="pPrevTabs">脚本所有内容都包含的前导tab键数,用于排版</param>
        /// <returns>Ext JS类的定义语句</returns>
        public static string ToDefineScript(string pClassFullName, Dictionary <string, object> pDefinitionConfigs, int pPrevTabs = 1)
        {
            //检查
            if (string.IsNullOrEmpty(pClassFullName))
            {
                throw new ArgumentNullException("pClassFullName");
            }
            //
            var tabs = Keyboard.TAB.ConcatRepeatly(pPrevTabs);
            //
            StringBuilder script = new StringBuilder();

            script.AppendFormat("{1}Ext.define({3}{2}{3},{0}", Environment.NewLine, tabs, pClassFullName, JSONConst.STRING_WRAPPER);
            var configs = ExtJSClass.ToConfigScript(pPrevTabs, pDefinitionConfigs);

            script.Append(configs);
            script.AppendFormat("{1});{0}", Environment.NewLine, tabs);
            //
            return(script.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// 生成创建类实例的脚本
        /// </summary>
        /// <param name="pPrevTabs">脚本所有内容都包含的前导tab键数,用于排版</param>
        /// <returns>Ext JS的创建类实例的语句</returns>
        public virtual string ToCreationScript(int pPrevTabs)
        {
            //检查
            if (string.IsNullOrEmpty(this.ClassFullName))
            {
                throw new ArgumentNullException("ClassFullName");
            }
            //
            var tabs = Keyboard.TAB.ConcatRepeatly(pPrevTabs);
            //
            StringBuilder script = new StringBuilder();

            script.AppendFormat("{1}Ext.create({2}{3}{2},{0}", Environment.NewLine, tabs, JSONConst.STRING_WRAPPER, this.ClassFullName);
            var configs = ExtJSClass.ToConfigScript(pPrevTabs, this.InitConfigs);

            //configs = configs.TrimStart(Keyboard.SPACE);
            script.Append(configs);
            script.AppendFormat("{0});", tabs);
            //
            return(script.ToString());
        }
Beispiel #3
0
        /// <summary>
        /// 生成类实例创建配置项的脚本
        /// <remarks>
        /// <para>1.此种方式为采用xtype来创建.</para>
        /// </remarks>
        /// </summary>
        /// <param name="pPrevTabs">脚本所有内容都包含的前导tab键数,用于排版</param>
        /// <returns>Ext JS使用xtype创建类实例的语句</returns>
        public virtual string ToCreationConfigScript(int pPrevTabs)
        {
            if (string.IsNullOrEmpty(this.XType))
            {
                throw new ArgumentNullException(this.XType);
            }
            Dictionary <string, object> configs = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(this.XType))
            {
                configs.Add("xtype", this.XType);
            }
            if (this.InitConfigs != null)
            {
                foreach (var config in this.InitConfigs)
                {
                    configs.Add(config.Key, config.Value);
                }
            }
            //
            return(ExtJSClass.ToConfigScript(pPrevTabs, configs));
        }
Beispiel #4
0
 /// <summary>
 /// Javascript对象转换成对象的脚本块
 /// <remarks>
 /// <para>对于Ext JS的类,生成脚本块都采用配置项的方式来生成.</para>
 /// </remarks>
 /// </summary>
 /// <param name="pPrevTabs">脚本所有内容都包含的前导tab键数,用于排版</param>
 /// <returns>Javascript脚本块</returns>
 public virtual string ToScriptBlock(int pPrevTabs)
 {
     return(ExtJSClass.ToConfigScript(pPrevTabs, this.InitConfigs));
 }