コード例 #1
0
 private void ValidateSameFileName(IProjectSettingsFile otherProjectSettingsFile)
 {
     if (FileName != otherProjectSettingsFile.FileName)
     {
         throw new Exception("Trying to merge different project files!");
     }
 }
コード例 #2
0
 public void BuildAndApplyProjectSettings(IBuildVariant buildVariant,
                                          IEnumerable <IProjectSettingsFile> additionalSettings    = null,
                                          IProjectSettingsFile ignoreAdditionalProjectSettingsFile = null,
                                          YamlNode ignoreAdditionalNode = null)
 {
     if (additionalSettings == null)
     {
         additionalSettings = Enumerable.Empty <IProjectSettingsFile>();
     }
     else
     {
         if (ignoreAdditionalProjectSettingsFile != null)
         {
             additionalSettings = additionalSettings.Where(p => p.FileName != ignoreAdditionalProjectSettingsFile.FileName);
             if (ignoreAdditionalNode != null)
             {
                 additionalSettings = additionalSettings.Append(
                     new ProjectSettingsFile {
                     FileName = ignoreAdditionalProjectSettingsFile.FileName,
                     RootNode =
                         ignoreAdditionalProjectSettingsFile.RootNode.
                         Diff(ignoreAdditionalProjectSettingsFile.RootNode.GetChildBranch(ignoreAdditionalNode))
                 });
             }
         }
     }
     _projectSettingsStorage.SaveProjectSettings(
         _baseSettings.Concat(buildVariant.GetFinalProjectSettings()).
         Concat(additionalSettings).Merge().ToList());
     _actualProjectSettings = _projectSettingsStorage.LoadProjectSettings();
     InvalidateDiffCache();
 }
コード例 #3
0
 public void Merge(IProjectSettingsFile projectSettingsFile, YamlNode settingsNode)
 {
     ProjectSettingsFiles = ProjectSettingsFiles.Cast <IProjectSettingsFile>().Append(new ProjectSettingsFile {
         FileName = projectSettingsFile.FileName,
         RootNode = projectSettingsFile.RootNode.GetChildBranch(settingsNode)
     }).Merge()
                            .Cast <ProjectSettingsFile>().ToList();
 }
コード例 #4
0
        public IProjectSettingsFile Diff(IProjectSettingsFile otherProjectSettingsFile)
        {
            ValidateSameFileName(otherProjectSettingsFile);
            var rootNode = RootNode != null?RootNode.Diff(otherProjectSettingsFile.RootNode) : null;

            return(rootNode != null ? new ProjectSettingsFile {
                FileName = FileName, RootNode = rootNode
            } : null);
        }
コード例 #5
0
 public IProjectSettingsFile Merge(IProjectSettingsFile otherProjectSettingsFile)
 {
     ValidateSameFileName(otherProjectSettingsFile);
     return(new ProjectSettingsFile {
         FileName = FileName,
         RootNode = RootNode != null
             ? RootNode.Merge(otherProjectSettingsFile.RootNode)
             : otherProjectSettingsFile.RootNode
     });
 }
コード例 #6
0
 public static IEnumerable <IProjectSettingsFile> Append(
     this IEnumerable <IProjectSettingsFile> settings,
     IProjectSettingsFile projectSettingsFile)
 {
     foreach (var setting in settings)
     {
         yield return(setting);
     }
     yield return(projectSettingsFile);
 }
コード例 #7
0
        public void Revert(IProjectSettingsFile projectSettingsFile, YamlNode settingsNode)
        {
            Revert(projectSettingsFile);
            var rootNode = projectSettingsFile.RootNode.Diff(projectSettingsFile.RootNode.GetChildBranch(settingsNode));

            if (rootNode != null)
            {
                ProjectSettingsFiles = ProjectSettingsFiles.Cast <IProjectSettingsFile>().Append(new ProjectSettingsFile {
                    FileName = projectSettingsFile.FileName,
                    RootNode = rootNode
                }).
                                       Merge().Cast <ProjectSettingsFile>().ToList();
            }
        }
コード例 #8
0
        public static IEnumerable <IProjectSettingsFile> Merge(
            this IEnumerable <IProjectSettingsFile> settings)
        {
            var groupedFiles = settings.Where(p => p.RootNode != null).GroupBy(
                p => p.FileName,
                p => p,
                (filename, files) => new { FileName = filename, ProjectSettingsFiles = files.ToList() });

            foreach (var group in groupedFiles)
            {
                IProjectSettingsFile projectSettingsFile = null;
                foreach (var file in group.ProjectSettingsFiles)
                {
                    projectSettingsFile = projectSettingsFile == null ? file : projectSettingsFile.Merge(file);
                }
                yield return(projectSettingsFile);
            }
        }
コード例 #9
0
        public static IEnumerable <IProjectSettingsFile> Diff(this IEnumerable <IProjectSettingsFile> settings,
                                                              IEnumerable <IProjectSettingsFile> otherSettings)
        {
            var groupedFiles = settings.Concat(otherSettings).GroupBy(
                p => p.FileName,
                p => p,
                (filename, files) => new { FileName = filename, ProjectSettingsFiles = files.ToList() });

            foreach (var group in groupedFiles)
            {
                IProjectSettingsFile projectSettingsFile = null;
                foreach (var file in group.ProjectSettingsFiles)
                {
                    projectSettingsFile = projectSettingsFile == null ? file : projectSettingsFile.Diff(file);
                }
                if (projectSettingsFile != null)
                {
                    yield return(projectSettingsFile);
                }
            }
        }
コード例 #10
0
 public void Merge(IProjectSettingsFile projectSettingsFile)
 {
     ProjectSettingsFiles = ProjectSettingsFiles.Cast <IProjectSettingsFile>().Append(projectSettingsFile).Merge()
                            .Cast <ProjectSettingsFile>().ToList();
 }
コード例 #11
0
 public void Revert(IProjectSettingsFile projectSettingsFile)
 {
     ProjectSettingsFiles = ProjectSettingsFiles.Where(p => p != projectSettingsFile).ToList();
 }
コード例 #12
0
        private void DrawNode(IBuildVariant inspectedBuildVariant,
                              IProjectSettingsFile projectSettingsFile, SettingsCategory category, YamlNode node, YamlNode labelNode = null)
        {
            if (node == null)
            {
                return;
            }
            EditorGUI.indentLevel++;

            Action revertAction = null;
            Action saveAction   = null;

            if (category == SettingsCategory.ActualSettingsDiff || category == SettingsCategory.ActualRevertableSettingsDiff)
            {
                saveAction = () => {
                    inspectedBuildVariant.Merge(projectSettingsFile, node);
                    _projectSettingsController.InvalidateDiffCache();
                };
                if (category == SettingsCategory.ActualRevertableSettingsDiff)
                {
                    revertAction = () => {
                        _projectSettingsController.BuildAndApplyProjectSettings(inspectedBuildVariant,
                                                                                _projectSettingsController.GetDiffWithActualSettings(inspectedBuildVariant),
                                                                                projectSettingsFile, node);
                    }
                }
                ;
            }
            else if (category == SettingsCategory.VariantDiff)
            {
                revertAction = () => {
                    var currentDiff = _projectSettingsController.GetDiffWithActualSettings(inspectedBuildVariant).ToList();
                    inspectedBuildVariant.Revert(projectSettingsFile, node);
                    _projectSettingsController.BuildAndApplyProjectSettings(inspectedBuildVariant, currentDiff);
                };
            }

            if (node.NodeType == YamlNodeType.Mapping)
            {
                EditorGUILayout.BeginHorizontal();
                var expanded = inspectedBuildVariant.IsFieldExpanded(string.Format("{0}_{1}_{2}",
                                                                                   category.ToString(), projectSettingsFile.FileName, labelNode));

                expanded = EditorGUILayout.Foldout(expanded, string.Format("{0} ({1})",
                                                                           labelNode, ((YamlMappingNode)node).Children.Count));
                inspectedBuildVariant.SetFieldExpanded(string.Format("{0}_{1}_{2}",
                                                                     category.ToString(), projectSettingsFile.FileName, labelNode), expanded);
                DrawSaveRevert(revertAction, saveAction);
                EditorGUILayout.EndHorizontal();
                if (expanded)
                {
                    foreach (var keyValue in ((YamlMappingNode)node).Children)
                    {
                        DrawNode(inspectedBuildVariant, projectSettingsFile, category, keyValue.Value, keyValue.Key);
                    }
                }
            }
            else if (node.NodeType == YamlNodeType.Scalar || node.NodeType == YamlNodeType.Sequence)
            {
                EditorGUILayout.BeginHorizontal();
                if (labelNode != null)
                {
                    EditorGUILayout.LabelField(labelNode.ToString());
                }
                EditorGUILayout.HelpBox(node.ToString(), MessageType.None);
                DrawSaveRevert(revertAction, saveAction);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUI.indentLevel--;
        }