private bool UpdateName(Function function) { if (function.TranslationUnit.Module != null) { Generator.CurrentOutputNamespace = function.TranslationUnit.Module.OutputNamespace; } var @params = function.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType) .Select(p => p.QualifiedType.ToString()); // Include the conversion type in case of conversion operators var method = function as Method; if (method != null && method.IsOperator && (method.OperatorKind == CXXOperatorKind.Conversion || method.OperatorKind == CXXOperatorKind.ExplicitConversion)) { @params = @params.Concat(new[] { method.ConversionType.ToString() }); } var signature = string.Format("{0}({1})", function.Name, string.Join(", ", @params)); signature = FixSignatureForConversions(function, signature); if (Count == 0) { Count++; } if (!methodSignatures.ContainsKey(signature)) { methodSignatures.Add(signature, 0); return(false); } var methodCount = ++methodSignatures[signature]; if (Count < methodCount + 1) { Count = methodCount + 1; } if (function.IsOperator) { // TODO: turn into a method; append the original type (say, "signed long") // of the last parameter to the type so that the user knows which overload is called diagnostics.Warning("Duplicate operator {0} ignored", function.Name); function.ExplicitlyIgnore(); } else if (method != null && method.IsConstructor) { diagnostics.Warning("Duplicate constructor {0} ignored", function.Name); function.ExplicitlyIgnore(); } else { function.Name += methodCount.ToString(CultureInfo.InvariantCulture); } return(true); }
/// <summary> /// This method will add catchment connections to nodes with /// the same id as the catchment id, for catchments in the <paramref name="rrFile"/> /// </summary> private static void UpdateCatchmentConnections(Mike1DData mike1DData, IFilePath rrFile, IDiagnostics diagnostics) { // Make a map of all node id's - for fast searching on node id, used to only add connections to existing nodes var nodeIdDictionary = new HashSet <string>(mike1DData.Network.Nodes.Select(n => n.Id), StringComparer.OrdinalIgnoreCase); // Assume rrFile path is relative to setup file. rrFile.BaseFilePath = mike1DData.Connection.FilePath; // load rrFile - but only header, not data. IResultData resultData = new ResultData(); resultData.Connection = Connection.Create(rrFile); Diagnostics resultDiagnostics = new Diagnostics("Example"); resultData.LoadHeader(resultDiagnostics); // Create new CatchmentConnections int countCreated = 0; int countSkipped = 0; foreach (IRes1DCatchment res1DCatchment in resultData.Catchments) { // Only add if node with this ID exists if (nodeIdDictionary.Contains(res1DCatchment.ID)) { CatchmentConnection catchmentConnection = new CatchmentConnection { Fraction = 1, CatchmentId = res1DCatchment.ID, NodeId = res1DCatchment.ID }; mike1DData.Network.CatchmentConnections.Add(catchmentConnection); countCreated++; } else { diagnostics.Warning(new DiagnosticItem(string.Format("Catchment-Node with ID {0} not found, catchment is ignored", res1DCatchment.ID))); countSkipped++; } } string msgs = string.Format("Updating Catchment Connections {0}, skipped {1} - for file: {2}", countCreated, countSkipped, rrFile.Path); Console.Out.WriteLine(msgs); diagnostics.Info(msgs); }