private void OnSerializing(StreamingContext context) { // if IsTempFile but no ResourceFile, create resource file so it can be serialized if (IsTempFile && ResourceIdentifier == null) { var resFile = new EngineResourceFile(string.Format("mediafile_{0}.zip", FileName), null, false); resFile.Add(ResourceFileType, Alias, InputStream); ResourceIdentifier = new EngineResourceFileIdentifier(resFile, ResourceFileType, Alias); } }
private void OnSerializing(StreamingContext context) { // if Bitmap is not a physical file and there is no ResourceFile, create resource file so it can be serialized if (string.IsNullOrWhiteSpace(_imgFile) && ResourceIdentifier == null) { var resFile = new EngineResourceFile(string.Format("tilesheet_{0}.zip", this.Name), null, false); var converter = new ImageConverter(); resFile.Add(EngineResourceFileTypes.Bitmap, this.Name, (Stream)converter.ConvertTo(_bmp, typeof(Stream))); ResourceIdentifier = new EngineResourceFileIdentifier(resFile, EngineResourceFileTypes.Bitmap, this.Name); } }