public object build() { bool isOk = ((this.id != null) && (this.name != null) && (this.description != null) && (this.softwarename != null)); ExperimentSeries expSeries = null; if (isOk) { expSeries = ExperimentSeries.create(this.id, this.name, this.description, this.experiments.Cast <IExperiment>().ToList(), this.softwarename); } else { throw new ArgumentException("Properties 'id', 'name', 'description', " + "'experiments' and 'softwarename' of " + "ExperimentSeries must be setted completely."); } return(expSeries); }
private IExperimentSeries parseExperimentSeries(IJsonReader <TokenType> jreader) { if (jreader.getCurrentTokenType() == TokenType.StartObject) { jreader.readNextToken(); } String sid = ""; String name = ""; String desc = ""; String esof = ""; List <IExperiment> expList = new List <IExperiment>(); do { TokenType type = jreader.getCurrentTokenType(); object value = jreader.getCurrentValue(); bool isOk = ((type == TokenType.PropertyName) && (value != null) && (value is String)); if (isOk) { if (String.Compare((String)value, "series_id") == 0) { jreader.readNextToken(); sid = (String)jreader.getCurrentValue(); } else if (String.Compare((String)value, "name") == 0) { jreader.readNextToken(); name = (String)jreader.getCurrentValue(); } else if (String.Compare((String)value, "description") == 0) { jreader.readNextToken(); desc = (String)jreader.getCurrentValue(); } else if (String.Compare((String)value, "experiment_software") == 0) { jreader.readNextToken(); esof = (String)jreader.getCurrentValue(); } else if (String.Compare((String)value, "experiments") == 0) { jreader.readNextToken(); if (jreader.getCurrentTokenType() != TokenType.StartArray) { throw new ArgumentException("TokenType must be a StartArray."); } do { jreader.readNextToken(); expList.Add(this.parseExperiment(jreader)); jreader.readNextToken(); } while(TokenType.EndArray != jreader.getCurrentTokenType()); } else { this.skipJsonField(jreader); } jreader.readNextToken(); } else { throw new ArgumentException("Argument 'type' must be a TokenType " + "with option of PropertyName.\n" + "Argument 'value' must be not null " + "and of type String."); } } while(TokenType.EndObject != jreader.getCurrentTokenType()); return(ExperimentSeries.create(sid, name, desc, expList, esof)); }