예제 #1
0
        public ISparkViewEntry CreateEntryInternal(SparkViewDescriptor descriptor, bool compile)
        {
            var entry = new CompiledViewEntry
            {
                Descriptor      = descriptor,
                Loader          = CreateViewLoader(),
                Compiler        = LanguageFactory.CreateViewCompiler(this, descriptor),
                LanguageFactory = LanguageFactory
            };


            var chunksLoaded    = new List <IList <Chunk> >();
            var templatesLoaded = new List <string>();

            LoadTemplates(entry.Loader, entry.Descriptor.Templates, chunksLoaded, templatesLoaded);

            if (compile)
            {
                entry.Compiler.CompileView(chunksLoaded, entry.Loader.GetEverythingLoaded());

                entry.Activator = ViewActivatorFactory.Register(entry.Compiler.CompiledType);
            }
            else
            {
                entry.Compiler.GenerateSourceCode(chunksLoaded, entry.Loader.GetEverythingLoaded());
            }

            return(entry);
        }
예제 #2
0
        public IList <SparkViewDescriptor> LoadBatchCompilation(Assembly assembly)
        {
            var descriptors = new List <SparkViewDescriptor>();

            foreach (var type in assembly.GetExportedTypes())
            {
                if (!typeof(ISparkView).IsAssignableFrom(type))
                {
                    continue;
                }

                var attributes = type.GetCustomAttributes(typeof(SparkViewAttribute), false);
                if (attributes == null || attributes.Length == 0)
                {
                    continue;
                }

                var descriptor = ((SparkViewAttribute)attributes[0]).BuildDescriptor();

                var entry = new CompiledViewEntry
                {
                    Descriptor = descriptor,
                    Loader     = new ViewLoader(),
                    Compiler   = new CSharpViewCompiler {
                        CompiledType = type
                    },
                    Activator = ViewActivatorFactory.Register(type)
                };
                CompiledViewHolder.Store(entry);

                descriptors.Add(descriptor);
            }

            return(descriptors);
        }
        public Assembly BatchCompilation(string outputAssembly, IList <SparkViewDescriptor> descriptors)
        {
            List <CompiledViewEntry> list  = new List <CompiledViewEntry>();
            List <string>            list2 = new List <string>();

            foreach (SparkViewDescriptor descriptor in descriptors)
            {
                CompiledViewEntry item = new CompiledViewEntry {
                    Descriptor = descriptor,
                    Loader     = this.CreateViewLoader(),
                    Compiler   = this.LanguageFactory.CreateViewCompiler(this, descriptor)
                };
                List <IList <Chunk> > chunksLoaded    = new List <IList <Chunk> >();
                List <string>         templatesLoaded = new List <string>();
                this.LoadTemplates(item.Loader, descriptor.Templates, chunksLoaded, templatesLoaded);
                item.Compiler.GenerateSourceCode(chunksLoaded, item.Loader.GetEverythingLoaded());
                list2.Add(item.Compiler.SourceCode);
                list.Add(item);
            }
            BatchCompiler compiler2 = new BatchCompiler {
                OutputAssembly = outputAssembly
            };
            Assembly assembly = compiler2.Compile(this.Settings.Debug, "csharp", list2.ToArray());

            foreach (CompiledViewEntry entry3 in list)
            {
                entry3.Compiler.CompiledType = assembly.GetType(entry3.Compiler.ViewClassFullName);
                entry3.Activator             = this.ViewActivatorFactory.Register(entry3.Compiler.CompiledType);
                this.CompiledViewHolder.Store(entry3);
            }
            return(assembly);
        }
        public IList <SparkViewDescriptor> LoadBatchCompilation(Assembly assembly)
        {
            List <SparkViewDescriptor> list = new List <SparkViewDescriptor>();

            foreach (Type type in assembly.GetExportedTypes())
            {
                if (typeof(ISparkView).IsAssignableFrom(type))
                {
                    object[] customAttributes = type.GetCustomAttributes(typeof(SparkViewAttribute), false);
                    if ((customAttributes != null) && (customAttributes.Length != 0))
                    {
                        SparkViewDescriptor item   = ((SparkViewAttribute)customAttributes[0]).BuildDescriptor();
                        CompiledViewEntry   entry2 = new CompiledViewEntry {
                            Descriptor = item,
                            Loader     = new ViewLoader()
                        };
                        CSharpViewCompiler compiler = new CSharpViewCompiler {
                            CompiledType = type
                        };
                        entry2.Compiler  = compiler;
                        entry2.Activator = this.ViewActivatorFactory.Register(type);
                        CompiledViewEntry entry = entry2;
                        this.CompiledViewHolder.Store(entry);
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
예제 #5
0
        public Assembly BatchCompilation(string outputAssembly, IList <SparkViewDescriptor> descriptors)
        {
            var batch      = new List <CompiledViewEntry>();
            var sourceCode = new List <string>();

            foreach (var descriptor in descriptors)
            {
                var entry = new CompiledViewEntry
                {
                    Descriptor = descriptor,
                    Loader     = CreateViewLoader(),
                    Compiler   = LanguageFactory.CreateViewCompiler(this, descriptor)
                };

                var chunksLoaded    = new List <IList <Chunk> >();
                var templatesLoaded = new List <string>();
                LoadTemplates(entry.Loader, descriptor.Templates, chunksLoaded, templatesLoaded);

                entry.Compiler.GenerateSourceCode(chunksLoaded, entry.Loader.GetEverythingLoaded());
                sourceCode.Add(entry.Compiler.SourceCode);

                batch.Add(entry);
            }

            var batchCompiler = new BatchCompiler {
                OutputAssembly = outputAssembly
            };

            var assembly = batchCompiler.Compile(Settings.Debug, "csharp", sourceCode.ToArray());

            foreach (var entry in batch)
            {
                entry.Compiler.CompiledType = assembly.GetType(entry.Compiler.ViewClassFullName);
                entry.Activator             = ViewActivatorFactory.Register(entry.Compiler.CompiledType);
                CompiledViewHolder.Store(entry);
            }
            return(assembly);
        }
예제 #6
0
        public IList<SparkViewDescriptor> LoadBatchCompilation(Assembly assembly)
        {
            var descriptors = new List<SparkViewDescriptor>();

            foreach (var type in assembly.GetExportedTypes())
            {
                if (!typeof(ISparkView).IsAssignableFrom(type))
                    continue;

                var attributes = type.GetCustomAttributes(typeof(SparkViewAttribute), false);
                if (attributes == null || attributes.Length == 0)
                    continue;

                var descriptor = ((SparkViewAttribute)attributes[0]).BuildDescriptor();

                var entry = new CompiledViewEntry
                                {
                                    Descriptor = descriptor,
                                    Loader = new ViewLoader(),
                                    Compiler = new DefaultViewCompiler { CompiledType = type },
                                    Activator = ViewActivatorFactory.Register(type)
                                };
                CompiledViewHolder.Current.Store(entry);

                descriptors.Add(descriptor);
            }

            return descriptors;
        }
예제 #7
0
        public ISparkViewEntry CreateEntryInternal(SparkViewDescriptor descriptor, bool compile)
        {
            var entry = new CompiledViewEntry
            {
                Descriptor = descriptor,
                Loader = CreateViewLoader(),
                Compiler = LanguageFactory.CreateViewCompiler(this, descriptor),
                LanguageFactory = LanguageFactory
            };

            var chunksLoaded = new List<IList<Chunk>>();
            var templatesLoaded = new List<string>();
            LoadTemplates(entry.Loader, entry.Descriptor.Templates, chunksLoaded, templatesLoaded);

            if (compile)
            {
                entry.Compiler.CompileView(chunksLoaded, entry.Loader.GetEverythingLoaded());

                entry.Activator = ViewActivatorFactory.Register(entry.Compiler.CompiledType);
            }
            else
            {
                entry.Compiler.GenerateSourceCode(chunksLoaded, entry.Loader.GetEverythingLoaded());
            }

            return entry;
        }
예제 #8
0
        public Assembly BatchCompilation(string outputAssembly, IList<SparkViewDescriptor> descriptors)
        {
            var batch = new List<CompiledViewEntry>();
            var sourceCode = new List<string>();

            foreach (var descriptor in descriptors)
            {
                var entry = new CompiledViewEntry
                {
                    Descriptor = descriptor,
                    Loader = CreateViewLoader(),
                    Compiler = LanguageFactory.CreateViewCompiler(this, descriptor)
                };

                var chunksLoaded = new List<IList<Chunk>>();
                var templatesLoaded = new List<string>();
                LoadTemplates(entry.Loader, descriptor.Templates, chunksLoaded, templatesLoaded);

                entry.Compiler.GenerateSourceCode(chunksLoaded, entry.Loader.GetEverythingLoaded());
                sourceCode.Add(entry.Compiler.SourceCode);

                batch.Add(entry);
            }

            var batchCompiler = new BatchCompiler { OutputAssembly = outputAssembly };

            var assembly = batchCompiler.Compile(Settings.Debug, sourceCode.ToArray());
            foreach (var entry in batch)
            {
                entry.Compiler.CompiledType = assembly.GetType(entry.Compiler.ViewClassFullName);
                entry.Activator = ViewActivatorFactory.Register(entry.Compiler.CompiledType);
                CompiledViewHolder.Current.Store(entry);
            }
            return assembly;
        }