Exemplo n.º 1
0
        /// <summary>
        /// Adds the Entity Framework nuget package to the project.
        /// </summary>
        /// <param name="EFVersion">The Entity Framework version.</param>
        private void AddEFNugetPackage(string EFVersion)
        {
            Project   activeProj     = null;
            VSProject vsProj         = null;
            DTE2      vsApp          = MySqlDataProviderPackage.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
            Array     activeProjects = (Array)vsApp.ActiveSolutionProjects;

            if (activeProjects.Length > 0)
            {
                activeProj = (Project)activeProjects.GetValue(0);
                vsProj     = activeProj.Object as VSProject;
                string          projectPath          = System.IO.Path.GetDirectoryName(activeProj.FullName);
                TargetFramework targetNetworkMoniker = (TargetFramework)Enum.ToObject(typeof(TargetFramework), vsApp.Solution.Projects.Item(1).Properties.Item("TargetFramework").Value);
                string          NetFxVersion         = GetNetFxVersion(targetNetworkMoniker);
                AddNugetPackage(vsProj, projectPath, NetFxVersion, "EntityFramework", EFVersion, true);
                AddNugetPackage(vsProj, projectPath, NetFxVersion, mySQLData, _mySQLEF6Version, true);
                switch (EFVersion)
                {
                case EF5Version:
                    AddNugetPackage(vsProj, projectPath, NetFxVersion, mySQLEF, mySQLEF5Version, true);
                    break;

                case EF6Version:
                    AddNugetPackage(vsProj, projectPath, NetFxVersion, mySQLEF, _mySQLEF6Version, true);
                    break;

                default:
                    throw new Exception("Not supported Entity Framework version.");
                }

                activeProj.Save();
                vsProj.Project.Save();
            }
        }
Exemplo n.º 2
0
        public WebConfigDlg()
        {
            InitializeComponent();

            dte = MySqlDataProviderPackage.GetGlobalService(
                typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
            solution = (Solution2)dte.Solution;
            FindCurrentWebProject();
            EnsureWebConfig();
            LoadInitialState();
            PageChanged();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Removes the entity framework section from an existing web config file.
        /// </summary>
        private void RemoveEntityFrameworkSection()
        {
            Project   activeProj     = null;
            VSProject vsProj         = null;
            DTE2      vsApp          = MySqlDataProviderPackage.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
            Array     activeProjects = (Array)vsApp.ActiveSolutionProjects;

            if (activeProjects.Length > 0)
            {
                activeProj = (Project)activeProjects.GetValue(0);
                vsProj     = activeProj.Object as VSProject;
                string projectPath = System.IO.Path.GetDirectoryName(activeProj.FullName);
                WebConfigTools.RemoveEFWebConfig(projectPath);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the entity framework section to an existing web config file.
        /// </summary>
        /// <param name="EFVersion">The Entity Framework version.</param>
        /// <param name="mySqlVersion">The My SQL version.</param>
        private void AddEntityFrameworkSection(string EFVersion, string mySqlVersion)
        {
            Project   activeProj     = null;
            VSProject vsProj         = null;
            DTE2      vsApp          = MySqlDataProviderPackage.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
            Array     activeProjects = (Array)vsApp.ActiveSolutionProjects;

            if (activeProjects.Length > 0)
            {
                activeProj = (Project)activeProjects.GetValue(0);
                vsProj     = activeProj.Object as VSProject;
                string projectPath = System.IO.Path.GetDirectoryName(activeProj.FullName);
                WebConfigTools.EFWebConfigTransformation(projectPath, EFVersion, mySqlVersion, _mySQLEF6Version);
            }
        }
Exemplo n.º 5
0
 public WebConfigDlg()
 {
     InitializeComponent();
     CreateStepsLabels();
     SetSelectedStepLabel(pagesDescription[0]);
     dte = MySqlDataProviderPackage.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
     if (dte != null)
     {
         solution = (Solution2)dte.Solution;
     }
     FindCurrentWebProject();
     EnsureWebConfig();
     LoadInitialState();
     PageChanged();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Removes the Entity Framework references from the project.
        /// </summary>
        /// <param name="removeEFReferences">When set to <c>true</c> will [remove the Entity Framework references] from the project.</param>
        private void RemoveEFReferences(bool removeEFReferences)
        {
            Project   activeProj     = null;
            VSProject vsProj         = null;
            DTE2      vsApp          = MySqlDataProviderPackage.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
            Array     activeProjects = (Array)vsApp.ActiveSolutionProjects;

            if (activeProjects.Length > 0)
            {
                activeProj = (Project)activeProjects.GetValue(0);
                vsProj     = activeProj.Object as VSProject;
                if (vsProj.References.Find(mySQLData) != null)
                {
                    vsProj.References.Find(mySQLData).Remove();
                }

                if (vsProj.References.Find(string.Format("{0}.EF5", mySQLEF)) != null)
                {
                    vsProj.References.Find(string.Format("{0}.EF5", mySQLEF)).Remove();
                }

                if (vsProj.References.Find(string.Format("{0}.EF6", mySQLEF)) != null)
                {
                    vsProj.References.Find(string.Format("{0}.EF6", mySQLEF)).Remove();
                }

                if (removeEFReferences)
                {
                    if (vsProj.References.Find("EntityFramework") != null)
                    {
                        vsProj.References.Find("EntityFramework").Remove();
                    }

                    if (vsProj.References.Find("EntityFramework.SqlServer") != null)
                    {
                        vsProj.References.Find("EntityFramework.SqlServer").Remove();
                    }
                }
            }
        }
Exemplo n.º 7
0
        public static Font GetFont(string name)
        {
            MySqlDataProviderPackage package = MySqlDataProviderPackage.Instance as MySqlDataProviderPackage;
            IVsFontAndColorStorage   pStorage;

            pStorage = (IVsFontAndColorStorage)package.GetVsService(
                typeof(IVsFontAndColorStorage));

            Guid textCategory = new Guid("{A27B4E24-A735-4d1d-B8E7-9716E1E3D8E0}");
            int  result       = pStorage.OpenCategory(ref textCategory, (int)(__FCSTORAGEFLAGS.FCSF_LOADDEFAULTS));

            if (result == VSConstants.S_OK)
            {
                FontInfo[] fi = new FontInfo[1];
                fi[0]  = new FontInfo();
                result = pStorage.GetFont(null, fi);
                pStorage.CloseCategory();
                if (result == VSConstants.S_OK)
                {
                    return(new Font(fi[0].bstrFaceName, (float)fi[0].wPointSize));
                }
            }
            return(null);
        }