Exemplo n.º 1
0
 public Rig GetRig()
 {
     var store = GetStore();
     if(store.FileExists(rigFileName))
     {
         Rig rig;
         using (var stream = store.OpenFile(rigFileName, FileMode.Open, FileAccess.Read))
         {
             var formatter = new BinaryFormatter();
             try
             {
                 rig = (Rig)formatter.Deserialize(stream);
             }
             catch (SerializationException)
             {
                 // if the file has been corrupted, just delete it and return a new rig
                 store.DeleteFile(rigFileName);
                 rig = new Rig();
             }
         }
         return rig;
     }
     else
     {
         return new Rig();
     }
 }
Exemplo n.º 2
0
 public void SaveRig(Rig rig)
 {
     var store = GetStore();
     if(store.FileExists(rigFileName))
     {
         store.DeleteFile(rigFileName);
     }
     using (var stream = store.OpenFile(rigFileName, FileMode.CreateNew, FileAccess.Write))
     {
         var formatter = new BinaryFormatter();
         formatter.Serialize(stream, rig);
     }
 }
Exemplo n.º 3
0
 public RigController(IRigService rigService, IVHostControllerFactory vHostControllerFactory)
 {
     this.rigService = rigService;
     this.rig = rigService.GetRig();
     this.vHostControllerFactory = vHostControllerFactory;
 }