예제 #1
0
        public static bool is_resolved()
        {
            if (ApplicationParameters.get_merged_assembly_name() == ApplicationParameters.default_merged_assembly_name)
            {
                return(true);
            }

            string log4net_file       = "log4net.dll";
            bool   log4net_dll_exists = false;

            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, log4net_file)))
            {
                log4net_dll_exists = true;
            }

            if (!log4net_dll_exists)
            {
                //try to resolve it anywhere
                try
                {
                    DefaultAssemblyLoader.load_assembly(log4net_file);
                    log4net_dll_exists = true;
                }
                catch (Exception)
                {
                    //the file doesn't exist
                }
            }

            return(log4net_dll_exists);
        }
        public ISessionFactory build_session_factory(Action <Configuration> additional_function)
        {
            string top_namespace = configuration_holder.DatabaseType.Substring(0, configuration_holder.DatabaseType.IndexOf(','));

            top_namespace = top_namespace.Substring(0, top_namespace.LastIndexOf('.'));
            string assembly_name = configuration_holder.DatabaseType.Substring(configuration_holder.DatabaseType.IndexOf(',') + 1);

            try
            {
                string key = configuration_holder.DatabaseType.Substring(0, configuration_holder.DatabaseType.IndexOf(',')) + ", " + ApplicationParameters.get_merged_assembly_name();
                return(build_session_factory(func_dictionary[key](), DefaultAssemblyLoader.load_assembly(ApplicationParameters.get_merged_assembly_name()), top_namespace, additional_function));
            }
            catch (Exception)
            {
                is_merged = false;
                return(build_session_factory(func_dictionary[configuration_holder.DatabaseType](), DefaultAssemblyLoader.load_assembly(assembly_name), top_namespace, additional_function));
            }
        }
        public ISessionFactory build_session_factory(Action <Configuration> additional_function)
        {
            string top_namespace = configuration_holder.DatabaseType.Substring(0, configuration_holder.DatabaseType.IndexOf(','));

            top_namespace = top_namespace.Substring(0, top_namespace.LastIndexOf('.'));
            string assembly_name = configuration_holder.DatabaseType.Substring(configuration_holder.DatabaseType.IndexOf(',') + 1);

            try
            {
                string key = configuration_holder.DatabaseType.Substring(0, configuration_holder.DatabaseType.IndexOf(',')) + ", " +
                             ApplicationParameters.get_merged_assembly_name();
                return(build_session_factory(func_dictionary[key](), Assembly.GetExecutingAssembly(), top_namespace, additional_function));
                //return build_session_factory(func_dictionary[key](), DefaultAssemblyLoader.load_assembly(ApplicationParameters.get_merged_assembly_name()),
                //top_namespace, additional_function);
            }
            catch (Exception ex)
            {
                // Changed from warning to debug. I may not be using session factory and this warning just adds noise.
                Log.bound_to(this).log_a_debug_event_containing("Had an error building session factory from merged, attempting unmerged. The error:{0}{1}", System.Environment.NewLine, ex.ToString());
                return(build_session_factory(func_dictionary[configuration_holder.DatabaseType](), DefaultAssemblyLoader.load_assembly(assembly_name),
                                             top_namespace, additional_function));
            }
        }