예제 #1
0
 public ComposerStrings(IEnumDbReader dbReader, IEnumLog log = null)
 {
     _dbReader  = dbReader;
     _log       = log ?? new DedbugLog();
     SqlModels  = new List <ModelSql>();
     EnumModels = new List <EnumModel>();
 }
예제 #2
0
 public CodeScanner(IEnumDbReader dbReader, IEnumLog log = null)
 {
     _dbReader  = dbReader;
     _log       = log ?? new DedbugLog();
     SqlModels  = new List <ModelSql>();
     EnumModels = new List <EnumModel>();
 }
예제 #3
0
        public DbReader(string sqlServer, string sqlDatabase, IEnumLog log)
        {
            _log = log;
            if (_log == null)
            {
                _log = new DedbugLog();
            }

            _scnn = BuildSqlConnectionString(sqlServer, sqlDatabase);
        }
예제 #4
0
        private void RunComposerScan(IEnumLog log)
        {
            try
            {
                RunComposerScan_Inner(log);
            }
            catch (Exception ex)
            {
                string message = "Sorry, and exception has occurred." + Environment.NewLine + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "See the Output\\Debug window for details.";
                if (log != null)
                {
                    string logMessage = DedbugLog.ExceptionMessage(ex);
                    log.WriteLine(logMessage);
                }

                //IVsUIShell uiShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); //todo: new dialog
                //Guid clsid = Guid.Empty;
                //int result;
                //uiShell.ShowMessageBox(0,
                //       ref clsid,
                //       "EnumComposer Visual Studio Package",
                //       message,
                //       string.Empty,
                //       0,
                //       OLEMSGBUTTON.OLEMSGBUTTON_OK,
                //       OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                //       OLEMSGICON.OLEMSGICON_INFO,
                //       0,        // false
                //       out result);

                //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
                string title = "EnumComposerCommand";

                // Show a message box to prove we were here
                VsShellUtilities.ShowMessageBox(
                    this.ServiceProvider,
                    message,
                    title,
                    OLEMSGICON.OLEMSGICON_INFO,
                    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
        }
예제 #5
0
        private void RunComposerScan_Inner(IEnumLog log)
        {
            DTE2 applicationObject = (DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE));

            TextDocument document = ObtainActiveDocument(applicationObject);

            if (document == null)
            {
                log.WriteLine("not a C# file.");
                return;
            }

            DbReader          dbReader        = new DbReader(null, null, log);
            IEnumConfigReader configReaderVsp = new ConfigReaderVsp(applicationObject.ActiveDocument.ProjectItem.ContainingProject);

            dbReader._configReader = configReaderVsp;

            ComposerStrings composer = new ComposerStrings(dbReader, log);

            ApplyComposer(document, composer);
        }
예제 #6
0
        public void Compose(string inputFile, string outputFile, IEnumDbReader dbReader, IEnumLog log = null)
        {
            if (File.Exists(inputFile) == false)
            {
                throw new ApplicationException("Input file wasn't found. File path: '" + inputFile + "'.");
            }

            if (File.Exists(outputFile))
            {
                FileInfo fi = new FileInfo(outputFile);
                if (fi.IsReadOnly)
                {
                    throw new ApplicationException("Output file is read-only. File path: '" + outputFile + "'.");
                }
            }

            ComposerStrings composer   = new ComposerStrings(dbReader, log);
            string          sourceText = File.ReadAllText(inputFile);

            composer.Compose(sourceText);

            string contents = composer.GetResultFile();

            File.WriteAllText(outputFile, contents);
        }
예제 #7
0
 public ConfigReader(string fromBottomDirectory, string toUpDirectory, IEnumLog log)
 {
     _fromBottomDirectory = fromBottomDirectory;
     _toUpDirectory       = toUpDirectory;
     _log = log;
 }