예제 #1
0
        private void RegisterTypes()
        {
            try
            {
                LogToVSOutputWindow("Registering types...\n");
                //kludge
                if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
                {
                    LogToVSOutputWindow("Already registered\n");
                    return;
                }
                System.Configuration.KeyValueConfigurationElement helperAssembly = null;
                try
                {
                    ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
                    helperAssembly = config.AppSettings["QfHelperAssembly"];
                }
                catch (Exception ex)
                {//nobody cares
                }
                if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
                {
                    IEnumerable <Assembly> assemblies = new Assembly[]
                    { Assembly.LoadFrom(helperAssembly.Value), Assembly.GetExecutingAssembly() };
                    //IEnumerable<Assembly> assemblies = new Assembly[] { Assembly.GetExecutingAssembly(), Assembly.LoadFrom(helperAssembly.Value) };

                    // Don't use AutoRegister(), it registers thousands of types and we only use four.
                    //TinyIoCContainer.Current.AutoRegister(assemblies);
                    TinyIoCContainer.Current.Register(typeof(IWrapperClassMaker), typeof(WrapperClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(ISignatureMaker), typeof(SignatureMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IResultClassMaker), typeof(ResultClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IQueryParamInfo), typeof(QueryParamInfo)).AsMultiInstance();
                }
                else
                {
                    // Don't use AutoRegister(), it registers thousands of types and we only use four.
                    //TinyIoCContainer.Current.AutoRegister();
                    TinyIoCContainer.Current.Register <IProvider, Providers.SqlServer>("System.Data.SqlClient");
                    TinyIoCContainer.Current.Register <IProvider, Providers.Postgres>("Npgsql");
                    TinyIoCContainer.Current.Register <IProvider, Providers.MySql>("MySql.Data.MySqlClient");
                    TinyIoCContainer.Current.Register(typeof(IWrapperClassMaker), typeof(WrapperClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(ISignatureMaker), typeof(SignatureMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IResultClassMaker), typeof(ResultClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IQueryParamInfo), typeof(QueryParamInfo)).AsMultiInstance();
                }
                LogToVSOutputWindow("Registered types...\n");
            }
            catch (Exception ex)
            {
                LogToVSOutputWindow(ex.Message + '\n' + ex.StackTrace);
            }
        }
예제 #2
0
        private void BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
        {
            // Determine whether require extension setting includes debug commenting
            bool commentInDebug = false;

            System.Configuration.KeyValueConfigurationElement requireExtension = null;
            try
            {
                ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
                requireExtension = config.AppSettings["QfRequireExtension"];
            }
            catch (Exception)
            {            //nobody cares
            }
            if (requireExtension != null)
            {
                try
                {
                    if (!Convert.ToBoolean(requireExtension.Value))
                    {
                        commentInDebug = true;
                    }
                }
                catch (Exception)
                {                //still, nobody cares
                }
            }


            if (!_dte.Solution.SolutionBuild.ActiveConfiguration.Name.Contains("Debug") || commentInDebug)
            {
                foreach (Project proj in _dte.Solution.Projects)
                {
                    // Comments !
                    // On opening a query to edit, we "open" the design time comments.
                    // In debug builds, the comment may be compiled "open", and closed by the generated code prior to running the query.
                    // In production builds, to save this step, we verify and "close" all comments section before the build, and
                    // the generated code runs the query as found.
                    SetCommentsForProd(proj.ProjectItems);
                }
            }
        }
예제 #3
0
        private void RegisterTypes(bool force = false)
        {
            try
            {
                var ctr = TinyIoCContainer.Current;
                LogToVSOutputWindow("Registering types...\n");
                //kludge
                if (force == true)
                {
                    ctr.Dispose();
                }
                else if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
                {
                    LogToVSOutputWindow("Already registered\n");
                    return;
                }
                System.Configuration.KeyValueConfigurationElement helperAssembly = null;
                try
                {
                    ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
                    helperAssembly = config.AppSettings["QfHelperAssembly"];
                }
                catch (Exception ex)
                {//nobody cares
                }
                List <Assembly> assemblies = new List <Assembly>();
                if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
                {
                    assemblies.Add(Assembly.LoadFrom(helperAssembly.Value));
                }
                assemblies.Add(Assembly.GetExecutingAssembly());
                TinyIoCContainer.Current.AutoRegister(assemblies, DuplicateImplementationActions.RegisterSingle);
                // IProvider, for instance, has multiple implementations. To resolve we use the provider name on the connection string,
                // which must correspond to the fully qualified name of the implementation. ie. QueryFirst.Providers.SqlClient for SqlServer

                LogToVSOutputWindow("Registered types...\n");
            }
            catch (Exception ex)
            {
                LogToVSOutputWindow(ex.Message + '\n' + ex.StackTrace);
            }
        }
예제 #4
0
        private void RegisterTypes()
        {
            LogToVSOutputWindow("Registering types...\n");
            //kludge
            if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
            {
                LogToVSOutputWindow("Already registered\n");
                return;
            }
            ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
            var helperAssembly           = config.AppSettings["QfHelperAssembly"];

            if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
            {
                IEnumerable <Assembly> assemblies = new Assembly[]
                { Assembly.LoadFrom(helperAssembly.Value), Assembly.GetExecutingAssembly() };
                //IEnumerable<Assembly> assemblies = new Assembly[] { Assembly.GetExecutingAssembly(), Assembly.LoadFrom(helperAssembly.Value) };

                // Don't use AutoRegister(), it registers thousands of types and we only use four.
                //TinyIoCContainer.Current.AutoRegister(assemblies);
                TinyIoCContainer.Current.Register <ITypeMapping>(new TypeMapping());
                TinyIoCContainer.Current.Register(typeof(IWrapperClassMaker), typeof(WrapperClassMaker)).AsMultiInstance();
                TinyIoCContainer.Current.Register(typeof(ISignatureMaker), typeof(SignatureMaker)).AsMultiInstance();
                TinyIoCContainer.Current.Register(typeof(IResultClassMaker), typeof(ResultClassMaker)).AsMultiInstance();
                TinyIoCContainer.Current.Register(typeof(IQueryParam), typeof(QueryParam)).AsMultiInstance();
            }
            else
            {
                // Don't use AutoRegister(), it registers thousands of types and we only use four.
                //TinyIoCContainer.Current.AutoRegister();
                TinyIoCContainer.Current.Register <ITypeMapping, TypeMapping>();
                TinyIoCContainer.Current.Register(typeof(IWrapperClassMaker), typeof(WrapperClassMaker)).AsMultiInstance();
                TinyIoCContainer.Current.Register(typeof(ISignatureMaker), typeof(SignatureMaker)).AsMultiInstance();
                TinyIoCContainer.Current.Register(typeof(IResultClassMaker), typeof(ResultClassMaker)).AsMultiInstance();
                TinyIoCContainer.Current.Register(typeof(IQueryParam), typeof(QueryParam)).AsMultiInstance();
            }
            LogToVSOutputWindow("Registered types...\n");
        }