コード例 #1
0
        void IDextopAssemblyPreprocessor.ProcessAssemblies(DextopApplication application, IList <System.Reflection.Assembly> assemblies, Stream outputStream, Stream cacheStream)
        {
            var typeFilter = TypeFilter ?? ((x, y) => true);

            using (var w = new StreamWriter(outputStream))
            {
                var jw = new DextopJsWriter(w, DextopJsWriterOptions.Localization);
                foreach (var assembly in assemblies)
                {
                    var formTypes = AssemblyHelper.GetTypeAttributeDictionaryForAssembly <DextopFormAttribute>(assembly, false);
                    foreach (var formTypeAttribute in formTypes)
                    {
                        if (typeFilter(formTypeAttribute.Key, this))
                        {
                            var type       = formTypeAttribute.Key;
                            var formFields = DextopFormBuilder.BuildForm(type);
                            var name       = application.MapTypeName(type, ".form");
                            jw.Write("Ext.define('{0}', ", name);
                            jw.StartLocalizationScope();
                            jw.StartBlock();
                            jw.AddProperty("extend", "Dextop.ItemFactory");
                            jw.StartFunctionBlock("getDictionary", "options");
                            jw.WriteLine("options = options || {};");
                            jw.WriteLine("options.data = options.data || {};");
                            jw.WriteLine("var dict = Ext.apply({}, options.apply);");
                            WriteDictRecursively(jw, formFields);
                            jw.WriteLine("return dict;");
                            jw.CloseBlock();
                            jw.StartFunctionBlock("buildItems", "dict");
                            jw.Write("return [");
                            for (var i = 0; i < formFields.Count; i++)
                            {
                                if (i > 0)
                                {
                                    jw.Write(", ");
                                }
                                if (formFields[i].ItemName != null)
                                {
                                    jw.Write("dict['{0}']", formFields[i].ItemName);
                                }
                                else
                                {
                                    jw.WriteObject(formFields[i]);
                                }
                            }
                            jw.Write("];");
                            jw.CloseBlock();//function
                            jw.WriteLocalizations();
                            jw.CloseBlock();
                            jw.WriteLine(");"); //Ext.define(
                            jw.WriteLine();

                            jw.Flush();
                        }
                    }
                }
            }
        }
コード例 #2
0
        void IDextopAssemblyPreprocessor.ProcessAssemblies(DextopApplication application, IList <Assembly> assemblies, Stream outputStream, Stream cacheStream)
        {
            var typeFilter = TypeFilter ?? ((x, y) => true);

            using (var w = new StreamWriter(outputStream))
            {
                var jw = new DextopJsWriter(w, DextopJsWriterOptions.Localization | DextopJsWriterOptions.ItemFactory);
                foreach (var assembly in assemblies)
                {
                    var headerTypes = AssemblyHelper.GetTypeAttributeDictionaryForAssembly <DextopGridAttribute>(assembly, false);

                    foreach (var cap in headerTypes)
                    {
                        if (typeFilter(cap.Key, this))
                        {
                            var type    = cap.Key;
                            var headers = DextopGridManager.BuildHeaders(type);
                            var name    = application.MapTypeName(type, ".columns");
                            jw.Write("Ext.define('{0}', ", name);
                            jw.StartLocalizationScope();
                            jw.StartBlock();
                            jw.AddProperty("extend", "Dextop.ItemFactory");
                            jw.StartFunctionBlock("getDictionary");
                            jw.WriteLine("var dict = {};");
                            WriteDictRecursively(jw, headers);
                            jw.WriteLine("return dict;");
                            jw.CloseBlock();
                            jw.StartFunctionBlock("buildItems", "dict");
                            jw.Write("return [");
                            for (var i = 0; i < headers.Count; i++)
                            {
                                if (i > 0)
                                {
                                    jw.Write(", ");
                                }
                                jw.Write("dict['{0}']", headers[i].id);
                            }
                            jw.Write("];");
                            jw.CloseBlock();//function
                            jw.WriteLocalizations();
                            jw.CloseBlock();
                            jw.WriteLine(");"); //Ext.define(

                            jw.Flush();
                        }
                    }
                }
            }
        }