示例#1
0
 public static Obj Save_P(Obj fname, RelAutoBase automaton, RelAutoUpdaterBase updater, object env)
 {
     try {
         DataWriter writer = IO.FileDataWriter(fname.GetString());
         automaton.WriteState(writer);
         return(SymbObj.Get(true));
     }
     catch (Exception e) {
         updater.lastException = e;
         return(SymbObj.Get(false));
     }
 }
示例#2
0
        public static bool Load(Obj fname, RelAutoBase automaton, RelAutoUpdaterBase updater)
        {
            try {
                using (Stream stream = new FileStream(fname.GetString(), FileMode.Open)) {
                    automaton.LoadState(new StreamReader(stream));
                }
            }
            catch (Exception e) {
                updater.lastException = e;
                return(false);
            }

            if (!automaton.FullCheck())
            {
                updater.lastException = new Exception("Invalid state");
                return(false);
            }

            return(true);
        }
示例#3
0
        public static Obj Error_P(RelAutoBase automaton, RelAutoUpdaterBase updater, object env)
        {
            Exception e   = updater.lastException;
            string    msg = "";

            if (e != null)
            {
                if (e is KeyViolationException || e is ForeignKeyViolationException)
                {
                    msg = e.ToString();
                }
                else
                {
                    DataWriter writer = IO.StringDataWriter();
                    writer.Write(e.ToString());
                    writer.Flush();
                    msg = writer.Output();
                }
            }
            return(Conversions.StringToObj(msg));
        }