private static IndexState readPreviousIndexState(string indexStatePath)
        {
            IndexState previousIndexState = new IndexState();

            if (!File.Exists(indexStatePath))
            {
                return(null);                //no file - solution indexed for the first time
            }

            XmlSerializer xmlSerializer = null;
            TextReader    textReader    = null;

            try
            {
                xmlSerializer      = new XmlSerializer(typeof(IndexState));
                textReader         = new StreamReader(indexStatePath);
                previousIndexState = (IndexState)xmlSerializer.Deserialize(textReader);
            }
            finally
            {
                if (textReader != null)
                {
                    textReader.Close();
                }
            }
            return(previousIndexState);
        }
Exemplo n.º 2
0
 private static IndexState readCurrentIndexState(string indexDirectoryPath, string extensionPointsConfigurationPath)
 {
     IndexState currentIndexState = new IndexState();
     findAndAddRelevantFilesToIndexState(indexDirectoryPath, currentIndexState);
     string extensionPointsConfigurationFilePath = Path.Combine(extensionPointsConfigurationPath, "ExtensionPointsConfiguration.xml");
     FileInfo configFileInfo = new FileInfo(extensionPointsConfigurationFilePath);
     currentIndexState.RelevantFilesInfo.Add(new RelevantFileInfo() { FullName = configFileInfo.FullName, LastWriteTime = configFileInfo.LastWriteTime });
     return currentIndexState;
 }
        public static void SaveCurrentIndexState()
        {
            if (string.IsNullOrEmpty(IndexDirectoryPath) || string.IsNullOrEmpty(IndexStatePath))
            {
                ConstructIndexPaths();
            }
            var        sandoOptions      = ServiceLocator.Resolve <ISandoOptionsProvider>().GetSandoOptions();
            IndexState currentIndexState = readCurrentIndexState(IndexDirectoryPath, sandoOptions.ExtensionPointsConfigurationFilePath);

            saveIndexState(currentIndexState, IndexStatePath);
        }
Exemplo n.º 4
0
 private static void findAndAddRelevantFilesToIndexState(string directoryPath, IndexState currentIndexState)
 {
     DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
     IEnumerable<RelevantFileInfo> relevantFilesInfo = from fileInfo in directoryInfo.EnumerateFiles("*.dll", SearchOption.AllDirectories)
                                                       select new RelevantFileInfo
                                                       {
                                                           FullName = fileInfo.FullName,
                                                           LastWriteTime = fileInfo.LastWriteTime
                                                       };
     currentIndexState.RelevantFilesInfo.AddRange(relevantFilesInfo);
 }
        private static IndexState readCurrentIndexState(string indexDirectoryPath, string extensionPointsConfigurationPath)
        {
            IndexState currentIndexState = new IndexState();

            findAndAddRelevantFilesToIndexState(indexDirectoryPath, currentIndexState);
            string   extensionPointsConfigurationFilePath = Path.Combine(extensionPointsConfigurationPath, "ExtensionPointsConfiguration.xml");
            FileInfo configFileInfo = new FileInfo(extensionPointsConfigurationFilePath);

            currentIndexState.RelevantFilesInfo.Add(new RelevantFileInfo()
            {
                FullName = configFileInfo.FullName, LastWriteTime = configFileInfo.LastWriteTime
            });
            return(currentIndexState);
        }
        public static bool IsIndexRecreationRequired()
        {
            if (string.IsNullOrEmpty(IndexDirectoryPath) || string.IsNullOrEmpty(IndexStatePath))
            {
                ConstructIndexPaths();
            }
            IndexState previousIndexState = readPreviousIndexState(IndexStatePath);
            var        sandoOptions       = ServiceLocator.Resolve <ISandoOptionsProvider>().GetSandoOptions();;

            IndexState currentIndexState = readCurrentIndexState(IndexDirectoryPath, sandoOptions.ExtensionPointsConfigurationFilePath);
            bool       result            = previousIndexState == null || !previousIndexState.Equals(currentIndexState);

            saveIndexState(currentIndexState, IndexStatePath);
            return(result);
        }
Exemplo n.º 7
0
        public override bool Equals(object obj)
        {
            IndexState indexState = obj as IndexState;

            if (indexState == null)
            {
                return(false);
            }

            if (RelevantFilesInfo.Count != indexState.RelevantFilesInfo.Count)
            {
                return(false);
            }
            if (RelevantFilesInfo.Count(f => !indexState.RelevantFilesInfo.Exists(f2 => f.FullName == f2.FullName && f.LastWriteTime == f2.LastWriteTime)) > 0)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
        private static IndexState readPreviousIndexState(string indexStatePath)
        {
            IndexState previousIndexState = new IndexState();
            if(!File.Exists(indexStatePath))
            {
                return null; //no file - solution indexed for the first time
            }

            XmlSerializer xmlSerializer = null;
            TextReader textReader = null;
            try
            {
                xmlSerializer = new XmlSerializer(typeof(IndexState));
                textReader = new StreamReader(indexStatePath);
                previousIndexState = (IndexState)xmlSerializer.Deserialize(textReader);
            }
            finally
            {
                if(textReader != null)
                    textReader.Close();
            }
            return previousIndexState;
        }
        private static void saveIndexState(IndexState currentIndexState, string indexStatePath)
        {
            if (currentIndexState == null)
            {
                return;
            }

            XmlSerializer xmlSerializer = null;
            TextWriter    textWriter    = null;

            try
            {
                xmlSerializer = new XmlSerializer(typeof(IndexState));
                textWriter    = new StreamWriter(indexStatePath);
                xmlSerializer.Serialize(textWriter, currentIndexState);
            }
            finally
            {
                if (textWriter != null)
                {
                    textWriter.Close();
                }
            }
        }
Exemplo n.º 10
0
        private static void findAndAddRelevantFilesToIndexState(string directoryPath, IndexState currentIndexState)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
            IEnumerable <RelevantFileInfo> relevantFilesInfo = from fileInfo in directoryInfo.EnumerateFiles("*.dll", SearchOption.AllDirectories)
                                                               select new RelevantFileInfo
            {
                FullName      = fileInfo.FullName,
                LastWriteTime = fileInfo.LastWriteTime
            };

            currentIndexState.RelevantFilesInfo.AddRange(relevantFilesInfo);
        }
Exemplo n.º 11
0
        private static void saveIndexState(IndexState currentIndexState, string indexStatePath)
        {
            if(currentIndexState == null)
                return;

            XmlSerializer xmlSerializer = null;
            TextWriter textWriter = null;
            try
            {
                xmlSerializer = new XmlSerializer(typeof(IndexState));
                textWriter = new StreamWriter(indexStatePath);
                xmlSerializer.Serialize(textWriter, currentIndexState);
            }
            finally
            {
                if(textWriter != null)
                    textWriter.Close();
            }
        }