예제 #1
0
        public ManifestDiff GetManifestDiff(Manifest other)
        {
            var ret = new ManifestDiff();

            if (SkcVersion != other.SkcVersion)
            {
                ret.NewVersion = SkcVersion;
                ret.OldVersion = other.SkcVersion;
            }
            if (SkcFile != other.SkcFile)
            {
                ret.NewVersion = SkcFile.ToString();
                ret.OldVersion = other.SkcFile == null ? "" : other.SkcFile.ToString();
            }
            if (DefinedSymbols != other.DefinedSymbols)
            {
                ret.NewDefines = DefinedSymbols;
                ret.OldDefines = other.DefinedSymbols;
            }

            var sourceDiffs = new CollectionDiff <ManifestFile>(SourceFiles, other.SourceFiles);

            ret.AddedSourceFilenames = sourceDiffs.NewItems.ToList();
            if (ret.AddedSourceFilenames.Count == 0)
            {
                ret.AddedSourceFilenames = null;
            }
            ret.RemovedSourceFilenames = sourceDiffs.RemovedItems.ToList();
            if (ret.RemovedSourceFilenames.Count == 0)
            {
                ret.RemovedSourceFilenames = null;
            }

            var contentDiffs = new CollectionDiff <ManifestFile>(ExternalFiles, other.ExternalFiles);

            ret.AddedExternalFiles = contentDiffs.NewItems.ToList();
            if (ret.AddedExternalFiles.Count == 0)
            {
                ret.AddedExternalFiles = null;
            }
            ret.RemovedExternalFiles = contentDiffs.RemovedItems.ToList();
            if (ret.RemovedExternalFiles.Count == 0)
            {
                ret.RemovedExternalFiles = null;
            }

            //var contentDiffs = new CollectionDiff<ManifestFile>(ContentFiles, other.ContentFiles);
            //ret.AddedContentFiles = contentDiffs.NewItems.ToList();
            //if (ret.AddedContentFiles.Count == 0)
            //    ret.AddedContentFiles = null;
            //ret.RemovedContentFiles = contentDiffs.RemovedItems.ToList();
            //if (ret.RemovedContentFiles.Count == 0)
            //    ret.RemovedContentFiles = null;

            var referenceDiffs = new CollectionDiff <ManifestFile>(ReferencedFiles, other.ReferencedFiles);

            ret.AddedReferences = referenceDiffs.NewItems.ToList();
            if (ret.AddedReferences.Count == 0)
            {
                ret.AddedReferences = null;
            }
            ret.RemovedReferences = referenceDiffs.RemovedItems.ToList();
            if (ret.RemovedReferences.Count == 0)
            {
                ret.RemovedReferences = null;
            }

            //var outputFileDiff = new CollectionDiff<string>(this.OutputFiles, other.OutputFiles);
            //ret.NewOutputFiles = referenceDiffs.NewItems.ToList();
            //if (ret.NewOutputFiles.Count == 0)
            //    ret.NewOutputFiles = null;
            //ret.OldOutputFiles = referenceDiffs.RemovedItems.ToList();
            //if (ret.OldOutputFiles.Count == 0)
            //    ret.OldOutputFiles = null;
            return(ret);
        }
예제 #2
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            if (NewVersion != null)
            {
                sb.AppendFormat("New version: {0} (Old:{1})\n", NewVersion, OldVersion);
            }
            if (NewDefines != null)
            {
                var defs    = NewDefines.Split(';');
                var oldDefs = OldDefines.IsNullOrEmpty() ? new string[] { } : OldDefines.Split(';');
                var defDiff = new CollectionDiff <string>(defs, oldDefs);
                if (defDiff.NewItems.Count() > 0)
                {
                    sb.AppendFormat(defDiff.NewItems.StringConcat("Defined symbols added: ", ", ", "\n"));
                }
                if (defDiff.RemovedItems.Count() > 0)
                {
                    sb.AppendFormat(defDiff.RemovedItems.StringConcat("Defined symbols removed: ", ", ", "\n"));
                }
            }
            if (NewLoadedPlugins != null)
            {
                var plgs    = NewLoadedPlugins.Split(',');
                var olgPlgs = OldLoadedPlugins.IsNullOrEmpty() ? new string[] { } : OldLoadedPlugins.Split(';');
                var plgDiff = new CollectionDiff <string>(plgs, olgPlgs);
                if (plgDiff.NewItems.Count() > 0)
                {
                    sb.AppendFormat(plgDiff.NewItems.StringConcat("Defined symbols added:\n", ",\n", "\n"));
                }
                if (plgDiff.RemovedItems.Count() > 0)
                {
                    sb.AppendFormat(plgDiff.RemovedItems.StringConcat("Defined symbols removed:\n", ",\n", "\n"));
                }
            }
            if (AddedReferences != null && AddedReferences.Count > 0)
            {
                sb.AppendFormat(AddedReferences.Select(t => t.ToString()).StringConcat("Added references:\n", ",\n", "\n"));
            }
            if (RemovedReferences != null && RemovedReferences.Count > 0)
            {
                sb.AppendFormat(RemovedReferences.Select(t => t.ToString()).StringConcat("Removed references:\n", ",\n", "\n"));
            }
            if (AddedSourceFilenames != null && AddedSourceFilenames.Count > 0)
            {
                sb.AppendFormat(AddedSourceFilenames.Select(t => t.ToString()).StringConcat("Added source files:\n", ",\n", "\n"));
            }
            if (RemovedSourceFilenames != null && RemovedSourceFilenames.Count > 0)
            {
                sb.AppendFormat(RemovedSourceFilenames.Select(t => t.ToString()).StringConcat("Removed source files:\n", ",\n", "\n"));
            }
            if (AddedContentFiles != null && AddedContentFiles.Count > 0)
            {
                sb.AppendFormat(AddedContentFiles.Select(t => t.ToString()).StringConcat("Added content files:\n", ",\n", "\n"));
            }
            if (RemovedContentFiles != null && RemovedContentFiles.Count > 0)
            {
                sb.AppendFormat(RemovedContentFiles.Select(t => t.ToString()).StringConcat("Removed content files:\n", ",\n", "\n"));
            }
            //if (OldOutputFiles != null && OldOutputFiles.Count > 0)
            //    sb.AppendFormat(OldOutputFiles.StringConcat("Old output files:\n", ",\n", "\n"));
            //if (NewOutputFiles != null && NewOutputFiles.Count > 0)
            //    sb.AppendFormat(NewOutputFiles.StringConcat("New output files:\n", ",\n", "\n"));
            return(sb.ToString());
        }