private SolutionMessage BuildSolutionMessage(Individual individual, int solutionId = 0) { lock (clientLock) { SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder(); protobufBuilder.SolutionId = solutionId; foreach (var variable in individual.Values) { try { MessageBuilder.AddToMessage(variable.Value, variable.Key, protobufBuilder); } catch (ArgumentException ex) { throw new InvalidOperationException(string.Format("ERROR while building solution message: Parameter {0} cannot be added to the message", Name), ex); } } return(protobufBuilder.Build()); } }
protected virtual SolutionMessage BuildSolutionMessage() { lock (clientLock) { SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder(); protobufBuilder.SolutionId = 0; foreach (IParameter param in CollectedValues) { IItem value = param.ActualValue; if (value != null) { ILookupParameter lookupParam = param as ILookupParameter; string name = lookupParam != null ? lookupParam.TranslatedName : param.Name; try { MessageBuilder.AddToMessage(value, name, protobufBuilder); } catch (ArgumentException ex) { throw new InvalidOperationException(string.Format("ERROR while building solution message: Parameter {0} cannot be added to the message", name), ex); } } } return(protobufBuilder.Build()); } }