public IVBComponent SubstituteCode(IVBComponent module, string newCode)
        {
            if (module.Type == ComponentType.Document)
            {
                //We cannot substitute the code of a document module via the file.
                return(module);
            }

            var fileName = _tempSourceFileHandler.Export(module);

            if (fileName == null || !File.Exists(fileName))
            {
                return(module);
            }
            File.WriteAllText(fileName, newCode, Encoding.Default);
            return(_tempSourceFileHandler.ImportAndCleanUp(module, fileName));
        }
        public void SubstituteCode(QualifiedModuleName module, string newCode)
        {
            if (module.ComponentType == ComponentType.Document)
            {
                //We cannot substitute the code of a document module via the file.
                return;
            }

            var component = _projectsProvider.Component(module);

            if (component == null)
            {
                return;
            }

            var fileName = _tempSourceFileHandler.Export(component);

            if (fileName == null || !File.Exists(fileName))
            {
                return;
            }
            File.WriteAllText(fileName, newCode);
            _tempSourceFileHandler.ImportAndCleanUp(component, fileName);
        }