Esempio n. 1
0
        private string LoadProject(IProject project)
        {
            var change = _changeManager.FindChange(project.ProjectFile());

            return(change != null
                ? change.Content
                : File.ReadAllText(Path.GetFullPath(project.ProjectFile())));
        }
Esempio n. 2
0
        //private string LoadProject(string projectFilePath)
        //{
        //    var change = _changeManager.FindChange(projectFilePath);

        //    return change != null
        //        ? change.Content
        //        : File.ReadAllText(Path.GetFullPath(projectFilePath));
        //}

        private void SaveProject(string filePath, string content)
        {
            var change = _changeManager.FindChange(filePath);

            // Normalize the content of both by parsing with no whitespace and calling .ToString()
            var targetContent   = XDocument.Parse(content).ToString();
            var existingContent = change != null
                ? XDocument.Parse(change.Content).ToString()
                : XDocument.Load(filePath).ToString();

            if (existingContent == targetContent)
            {
                return;
            }

            if (change != null)
            {
                change.ChangeContent(content);
                return;
            }

            _sfEventDispatcher.Publish(new SoftwareFactoryEvent(SoftwareFactoryEvents.OverwriteFileCommand, new Dictionary <string, string>
            {
                { "FullFileName", filePath },
                { "Content", content },
            }));
        }
Esempio n. 3
0
        private string LoadProjectFile()
        {
            var filename = _project.ProjectFile();

            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }
            _doc = _xmlFileCache.GetFile(filename);

            if (_doc == null)
            {
                var change = _changeManager.FindChange(filename);
                if (change == null)
                {
                    throw new Exception($"Trying to sync project file, but unable to find csproj content. {filename}");
                }
                _doc = XDocument.Parse(change.Content);

                _syncProjectFile = (f, c) => change.ChangeContent(c);
            }

            if (_doc.Root == null)
            {
                throw new Exception("_doc.Root is null");
            }

            _namespaces = new XmlNamespaceManager(new NameTable());
            _namespace  = _doc.Root.GetDefaultNamespace();
            _namespaces.AddNamespace("ns", _namespace.NamespaceName);

            _projectElement = _doc.XPathSelectElement("/ns:Project", _namespaces);

            return(filename);
        }