コード例 #1
0
 private bool Save(ref string?error, Stream saveTo, bool leaveOpen)
 {
     try
     {
         using var writer = new Utf8JsonWriter(saveTo);
         var typeDictionary = GlobalBoundary.GetUsedTypes();
         writer.WriteStartObject();
         WriteTypes(writer, typeDictionary);
         WriteBoundaries(writer, typeDictionary);
         writer.WriteEndObject();
         return(true);
     }
     catch (IOException e)
     {
         error = e.Message;
         return(false);
     }
     finally
     {
         if (!leaveOpen)
         {
             saveTo.Dispose();
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Check to see if the given boundary is within the model system.
 /// </summary>
 /// <param name="boundary"></param>
 /// <returns></returns>
 internal bool Contains(Boundary boundary)
 {
     lock (_modelSystemLock)
     {
         if (GlobalBoundary == boundary)
         {
             return(true);
         }
         return(GlobalBoundary.Contains(boundary));
     }
 }
コード例 #3
0
        private void WriteBoundaries(Utf8JsonWriter writer, Dictionary <Type, int> typeDictionary)
        {
            int index = 0;

            writer.WritePropertyName(BoundariesProperty);
            writer.WriteStartArray();
            Dictionary <Node, int> nodeDictionary = new Dictionary <Node, int>();

            GlobalBoundary.Save(ref index, nodeDictionary, typeDictionary, writer);
            writer.WriteEndArray();
        }
コード例 #4
0
 /// <summary>
 /// Generate the concrete model system for execution.
 /// </summary>
 /// <param name="runtime">The XTMF run time that we are executing within.</param>
 /// <param name="error">An error message if it can not be constructed.</param>
 /// <returns>True if it was created, false with message otherwise.</returns>
 internal bool Construct(XTMFRuntime runtime, ref string?error)
 {
     return(GlobalBoundary.ConstructModules(runtime, ref error) &&
            GlobalBoundary.ConstructLinks(ref error));
 }
コード例 #5
0
 /// <summary>
 /// Check that all requirements have been met when constructing the model system.
 /// </summary>
 /// <param name="moduleName">The name of the module that is causing the validation error.</param>
 /// <param name="error">An error message if the validation fails.</param>
 /// <returns>True if the validation passes, false otherwise with an error message.</returns>
 internal bool Validate(ref string?moduleName, ref string?error)
 {
     return(GlobalBoundary.Validate(ref moduleName, ref error));
 }