public static DialogResult ShowDialog <T>(T obj, string title, SerializationMgr serializationMgr) { PropertyDlg dlg = new PropertyDlg(title); dlg.AddOption(new PropertyEnvelope <T>(obj)); DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK && serializationMgr != null) { serializationMgr.SaveProfile <T>(obj, title); } return(result); }
public override void Execute(SharedObjects shared) { string fileName = PopValueAssert(shared, true).ToString(); AssertArgBottomAndConsume(shared); VolumeFile volumeFile = shared.VolumeMgr.CurrentVolume.Open(fileName); if (volumeFile == null) { throw new KOSException("File does not exist: " + fileName); } object read = new SerializationMgr(shared).Deserialize(volumeFile.ReadAll().String, JsonFormatter.ReaderInstance); ReturnValue = read; }
public override void Execute(SharedObjects shared) { object pathObject = PopValueAssert(shared, true); AssertArgBottomAndConsume(shared); GlobalPath path = shared.VolumeMgr.GlobalPathFromObject(pathObject); Volume volume = shared.VolumeMgr.GetVolumeFromPath(path); VolumeFile volumeFile = volume.Open(path) as VolumeFile; if (volumeFile == null) { throw new KOSException("File does not exist: " + path); } Structure read = new SerializationMgr(shared).Deserialize(volumeFile.ReadAll().String, JsonFormatter.ReaderInstance) as SerializableStructure; ReturnValue = read; }
public override void Execute(SharedObjects shared) { object pathObject = PopValueAssert(shared, true); SerializableStructure serialized = PopValueAssert(shared, true) as SerializableStructure; AssertArgBottomAndConsume(shared); if (serialized == null) { throw new KOSException("This type is not serializable"); } string serializedString = new SerializationMgr(shared).Serialize(serialized, JsonFormatter.WriterInstance); FileContent fileContent = new FileContent(serializedString); GlobalPath path = shared.VolumeMgr.GlobalPathFromObject(pathObject); Volume volume = shared.VolumeMgr.GetVolumeFromPath(path); ReturnValue = volume.SaveFile(path, fileContent); }
public override void Execute(SharedObjects shared) { string fileName = PopValueAssert(shared, true).ToString(); SerializableStructure serialized = PopValueAssert(shared, true) as SerializableStructure; AssertArgBottomAndConsume(shared); if (serialized == null) { throw new KOSException("This type is not serializable"); } string serializedString = new SerializationMgr(shared).Serialize(serialized, JsonFormatter.WriterInstance); FileContent fileContent = new FileContent(serializedString); if (shared.VolumeMgr != null) { shared.VolumeMgr.CurrentVolume.Save(fileName, fileContent); } }