Ejemplo n.º 1
0
        private void LoadScreensFromTemplate(string template)
        {
            if (File.Exists(template) == false)
            {
            #if DEBUG
                string path = Slyce.Common.RelativePaths.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location, @"..\..\..\..\ArchAngel.Templates\NHibernate\Template\NHibernate.AAT.DLL");

                if (File.Exists(path))
                    template = path;
                else
                    throw new Exception("Could not find the Template file at " + template);
            #else
                throw new Exception("Could not find the Template file at " + template);
            #endif
            }
            Assembly assembly = Assembly.LoadFile(template);
            TemplateLoader loader = new TemplateLoader(assembly);
            var screens = loader.CallCustomNewProjectScreensFunction();
            if (screens.Count > 0)
            {
                AddScreens(screens);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the new assembly, unloading the previously loaded assembly, if it is loaded.
        /// </summary>
        /// <param name="filepath"></param>
        private bool LoadAssembly(string filepath)
        {
            if (filepath == null)
            {

            }
            log.Debug("Loading Template Assembly");
            Reset(true);

            if (!string.IsNullOrEmpty(filepath) && !File.Exists(filepath))
            {
                throw new Exception("Could not file the template file at " + filepath);
            }

            _CurrentProjectTemplateAssembly = filepath;
            TemplateFolder = Path.GetDirectoryName(filepath);

            List<string> searchPaths = new List<string>();
            searchPaths.AddRange(new[] { Path.GetDirectoryName(Application.ExecutablePath), TemplateFolder });

            string providerFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Providers");

            if (Directory.Exists(providerFolder))
            {
                searchPaths.Add(providerFolder);
            }

            SharedData.AddAssemblySearchPaths(searchPaths);

            // Assembly.LoadFile needs an absolute path
            string absoluteFilePath = Path.GetFullPath(filepath);

            // Does this ArchAngel template exist in the executable directory? If yes, then use this version.
            string betterPath = "";

            #if DEBUG
            betterPath = Path.Combine(Slyce.Common.RelativePaths.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location, @"..\..\..\..\ArchAngel.Templates\NHibernate\Template"), Path.GetFileName(filepath));
            #else
            betterPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Path.GetFileName(filepath));
            #endif

            if (File.Exists(betterPath))
                absoluteFilePath = betterPath;

            // Create a new TemplateLoader with the new assembly we are working with.
            Assembly assembly = Assembly.LoadFile(absoluteFilePath);
            TemplateLoader = new TemplateLoader(assembly);
            TemplateLoader.SetAssemblySearchPaths(new List<string>(SharedData.AssemblySearchPaths));

            LoadProjectFunctions();

            return true;
        }