Ejemplo n.º 1
0
        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            base.GenerateCode(assemblyBuilder);
            WXMLModel model = null;

            using (XmlReader xr = new XmlTextReader(_fileName))
            {
                model = WXMLModel.LoadFromXml(xr);
            }

            IRepositoryProvider prov = WmsDefinitionManager.GetRepositoryProvider();

            foreach (CodeCompileUnit unit in prov.CreateCompileUnits(model))
            {
                assemblyBuilder.AddCodeCompileUnit(this, unit);
            }

            string fn = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(assemblyBuilder.GetTempFilePhysicalPath("dll")));

            AssemblyLoadEventHandler d = null;

            d = delegate(object sender, AssemblyLoadEventArgs args)
            {
                if (args.LoadedAssembly.ManifestModule.Name.StartsWith(fn))
                {
                    prov.SetRepositoryAssembly(args.LoadedAssembly);
                    AppDomain.CurrentDomain.AssemblyLoad -= d;
                }
            };

            AppDomain.CurrentDomain.AssemblyLoad += d;
        }