public void SaveContentPackBuffers(ContentPackDB contentPack) { FileStream output = null; if (null != contentPack.ContentPackIcon && contentPack.ContentPackIcon.Length > 0) { string iconFile = System.IO.Path.Combine (this.ContentPath, contentPack.ContentPackIconFile); if (System.IO.File.Exists (iconFile)) System.IO.File.Delete (iconFile); using (Bitmap iconData = BitmapFactory.DecodeByteArray(contentPack.ContentPackIcon, 0, contentPack.ContentPackIcon.Length)) { output = new FileStream (iconFile, FileMode.CreateNew); try { iconData.Compress (Bitmap.CompressFormat.Png, 100, output); } catch (System.IO.IOException ex) { #if DEBUG System.Diagnostics.Debug.WriteLine ("Error saving content pack icon file! {0}", ex.ToString ()); #endif } finally { output.Close (); } } } if (null != contentPack.ContentPackAd && contentPack.ContentPackAd.Length > 0) { string adFile = System.IO.Path.Combine (this.ContentPath, contentPack.ContentPackAdFile); if (System.IO.File.Exists (adFile)) System.IO.File.Delete (adFile); using (Bitmap adData = BitmapFactory.DecodeByteArray(contentPack.ContentPackAd,0,contentPack.ContentPackAd.Length)) { output = new FileStream (adFile, FileMode.CreateNew); try { adData.Compress (Bitmap.CompressFormat.Png, 100, output); } catch (System.IO.IOException ex) { #if DEBUG System.Diagnostics.Debug.WriteLine ("Error saving content ad file! {0}", ex.ToString ()); #endif } finally { output.Close (); } } } }
public static ContentPackDB ConvertFromContentPack(ContentPack item) { ContentPackDB toReturn = new ContentPackDB (); toReturn.ContentPackAd = item.ContentPackAd; toReturn.ContentPackAvailableDate = item.ContentPackAvailableDate; toReturn.ContentPackDescription = item.ContentPackDescription; toReturn.ContentPackEndDate = item.ContentPackEndDate; toReturn.ContentPackIcon = item.ContentPackIcon; toReturn.ContentPackID = item.ContentPackID; toReturn.ContentPackIsFree = item.ContentPackIsFree; toReturn.ContentPackPrice = item.ContentPackPrice; toReturn.ContentPackSaleEndDate = item.ContentPackSaleEndDate; toReturn.ContentPackSalePrice = item.ContentPackSalePrice; toReturn.ContentPackTitle = item.ContentPackTitle; toReturn.ContentPackTypeID = item.ContentPackTypeID; toReturn.Errors = item.Errors; return toReturn; }