public bool Serialise(Asap2File tree, StreamWriter stream) { tree.elements.Sort((x, y) => x.OrderID.CompareTo(y.OrderID)); foreach (var item in tree.elements) { if (item.GetType() == typeof(FileComment)) { stream.Write(item.ToString()); stream.Write(Environment.NewLine); } else { foreach (string data in SerialiseNode(item, 0)) { stream.WriteAsync(data); } } } stream.Flush(); return(false); }
public void Merge(ref Asap2File destination, Asap2File source) { var destinationProject = destination.elements.First(x => x is PROJECT) as PROJECT; var sourceProject = source.elements.First(x => x is PROJECT) as PROJECT; if (options.ModuleMerge == Options.ModuleMergeType.Multiple) { foreach (var module in sourceProject.modules.Values) { try { destinationProject.modules.Add(module.Name, module); } catch (ArgumentException) { if (options.MergeConflict == Options.MergeConflictType.UseFromFirstModuleAndWarn) { Console.Error.WriteLine("Warning: Duplicate MODULE with name '{0}' found in {1}", module.Name, source.baseFilename); } if (options.MergeConflict == Options.MergeConflictType.AbortWithError) { throw new ErrorException(ErrorException.ErrorCodes.MergeError, string.Format("Error: Duplicate MODULE with name '{0}' found in {1}", module.Name, source.baseFilename)); } } } } if (options.ModuleMerge == Options.ModuleMergeType.One) { var destinationModule = destinationProject.modules.First().Value; var sourceModule = MergeModulesList(sourceProject.modules); MergeModules(ref destinationModule, sourceModule); } }