示例#1
0
        private void ImportEmbeddedStyleMixins(AbcFile app)
        {
            var swcResource = GetType().GetResourceStream("mixins.swc");

            if (swcResource == null)
            {
                throw new InvalidOperationException("Unable to load mixins");
            }

            var depsResource = GetType().GetResourceStream("mixins.dep");
            var deps         = new SwcDepFile(depsResource);

            var swc = new SwcFile(swcResource);

            swc.ResolveDependencies(new SimpleSwcLinker(_compiler.AppAssembly), deps);

            ImportStyleMixins(app, swc, false);
        }
示例#2
0
        private void ImportStyleMixins(AbcFile app)
        {
#if PERF
            int start = Environment.TickCount;
            Console.WriteLine("ImportStyleMixins");
#endif
            string styleMixins = _compiler.Options.StyleMixins;
            if (!string.IsNullOrEmpty(styleMixins) &&
                File.Exists(styleMixins))
            {
                var swc = new SwcFile(styleMixins);
                swc.ResolveDependencies(new SimpleSwcLinker(_compiler.AppAssembly), null);
                ImportStyleMixins(app, swc, true);
                return;
            }

            ImportEmbeddedStyleMixins(app);

#if PERF
            Console.WriteLine("ImportStyleMixins: {0}", Environment.TickCount - start);
#endif
        }
示例#3
0
        public Linker(IAssembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            var data = assembly.CustomData();

            if (data.Linker != null)
            {
                throw new InvalidOperationException();
            }

            data.Linker = this;

            Assembly = assembly;

            // we should always listen TypeLoaded event to fill AssemblyLinked
            if (Assembly.Loader != null)
            {
                Assembly.Loader.TypeLoaded += OnTypeLoaded;
            }

            var resource = Assembly.MainModule.Resources.FirstOrDefault(
                x => x.Name.EndsWith(".abc", StringComparison.OrdinalIgnoreCase) ||
                x.Name.EndsWith(".swc", StringComparison.OrdinalIgnoreCase));

            if (resource != null)
            {
                data.Flags |= InternalAssembyFlags.HasAbcImports;

                if (resource.Name.EndsWith(".abc", StringComparison.OrdinalIgnoreCase))
                {
                    _abc = new AbcFile(resource.Data)
                    {
                        Assembly = Assembly
                    };
                    data.Abc = _abc;
                    _cache   = new AbcCache();
                    _cache.Add(_abc);
                }
                else if (resource.Name.EndsWith(".swc", StringComparison.OrdinalIgnoreCase))
                {
                    string swcName = GetResFileName(resource.Name);

                    _swcDeps = LoadSwcDep(swcName);
                    _swc     = new SwcFile(resource.Data)
                    {
                        Assembly = Assembly,
                        Name     = swcName
                    };
                    _cache = _swc.AbcCache;

                    data.SWC = _swc;
                }
            }

            // create all linkers to subscribe on AssemblyLoader.TypeLoaded event before we start process
            assembly.ProcessReferences(true,
                                       asm =>
            {
                if (asm.CustomData().Linker == null)
                {
                    asm.CustomData().Linker = new Linker(asm);
                }
            });

            if (_swc != null)
            {
                _swc.ResolveDependencies(this, _swcDeps);
            }
        }