private XElement CreateXml(DotSettings dotSettings)
 {
     return new XElement(
         Xmlns.Winfx + "ResourceDictionary",
         new XAttribute(XNamespace.Xml + "space", "preserve"),
         new XAttribute(XNamespace.Xmlns + "x", Xmlns.Xaml.NamespaceName),
         new XAttribute(XNamespace.Xmlns + "s", Xmlns.Corlib.NamespaceName),
         new XAttribute(XNamespace.Xmlns + "ss", Xmlns.Storage.NamespaceName),
         new XAttribute(XNamespace.Xmlns + "wpf", Xmlns.Winfx.NamespaceName),
         dotSettings.Layers.OrderBy(x => x.RelativePriority).SelectMany(CreateLayerElements));
 }
        private bool AreEqual(TeamSharperSettings teamSharperSettings, DotSettings dotSettings)
        {
            // We require the absolute path to be our exact dummy to enshure constistency:
            if (dotSettings.Layers.Any(x => !x.AbsolutePath.Equals(absolutePathDummy, StringComparison.Ordinal)))
            {
                return false;
            }

            var absoluteTeamSettingsLayersPaths = teamSharperSettings.Layers
                .OrderBy(x => x.RelativePriority)
                .Select(x => x.RelativePath)
                .Select(x => PathHelper.MakeFilePathAbsoluteToDirectory(x, teamSharperSettings.FilePath))
                .Select(x => x.ToLowerInvariant());

            var absoluteDotSettingsLayersPaths = dotSettings.Layers
                .OrderBy(x => x.RelativePriority)
                .Select(x => x.RelativePath)
                .Select(x => PathHelper.MakeFilePathAbsoluteToDirectory(x, dotSettings.FilePath))
                .Select(x => x.ToLowerInvariant());

            return absoluteTeamSettingsLayersPaths.SequenceEqual(absoluteDotSettingsLayersPaths);
        }
        internal void AdjustPathsInDotSettings(DotSettings dotSettings, TeamSharperSettings teamSharperSettings)
        {
            dotSettings.Layers.Clear();
            foreach (TeamSharperSettingsLayer teamSharperSettingsLayer in teamSharperSettings.Layers.OrderBy(x => x.RelativePriority))
            {
                string layerReferenceAbsolute = PathHelper.MakeFilePathAbsoluteToDirectory(teamSharperSettingsLayer.RelativePath, Path.GetDirectoryName(teamSharperSettings.FilePath));
                string layerReferenceRelativeToSolution = PathHelper.MakeFilePathRelativeToDirectory(layerReferenceAbsolute, dotSettings.FilePath);

                dotSettings.Layers.Add(new DotSettingsLayer
                {
                    Id = teamSharperSettingsLayer.Id,
                    AbsolutePath = absolutePathDummy,
                    RelativePriority = teamSharperSettingsLayer.RelativePriority,
                    RelativePath = layerReferenceRelativeToSolution
                });
            }
        }
        private void UpdateDotSettings(DotSettings dotSettings, TeamSharperSettings teamSharperSettings)
        {
            AdjustPathsInDotSettings(dotSettings, teamSharperSettings);

            // Finally, save the settings:
            this.dotSettingsSerializer.Save(dotSettings);
        }
        // ---------------- SAVING ------------------------------------------------

        public void Save(DotSettings dotSettings)
        {
            this.CreateXml(dotSettings).Save(dotSettings.FilePath);
        }