Ejemplo n.º 1
0
 public static string ValidateModel(ref EmraldModel sim, string modelText, string modelDir)
 {
     try
     {
         sim = new EmraldModel();
         sim.DeserializeJSON(modelText, modelDir); //throws and exception of failed
         return("");
     }
     catch (Exception error)
     {
         string retError = "Failed to load model :" + Environment.NewLine;
         retError += error.Message;
         if (error.InnerException != null && error.InnerException.Message != "")
         {
             retError += " - " + error.InnerException.Message;
         }
         return(retError);
     }
 }
Ejemplo n.º 2
0
 private bool ValidateModel()
 {
     // Attempt to deserialize the json string
     try
     {
         // Create a new EmraldModel object called sim
         _model = new EmraldModel();
         // Deserialize the json string into sim
         _model.DeserializeJSON(_modelJsonStr, Path.GetDirectoryName(options.inpfile));
     }
     // If there is an error in deserialization, create an error message
     catch (Exception error)
     {
         _error  = "Failed to load model :";
         _error += error.Message;
         if (error.InnerException != null && error.InnerException.Message != "")
         {
             _error += " - " + error.InnerException.Message;
         }
         return(false);
     }
     return(true);
 }