استخدام CustomImplementationFactory لإنشاء تطبيق مخصص لـ Memory Stream
Contents
[
Hide
]
سيناريوهات الاستخدام الممكنة
قدم Aspose.Cells API اسمهCellsHelper.CustomImplementationFactoryوالتي تمكن المستخدم من توفير تنفيذ مخصص مثل استخدام تنفيذ الذاكرة القابلة لإعادة التدوير بدلاً من MemoryStream الافتراضي.
استخدام CustomImplementationFactory لإنشاء تطبيق مخصص لـ Memory Stream
يوضح نموذج التعليمات البرمجية التالي كيفية الاستفادة منCellsHelper.CustomImplementationFactoryفي برنامجك. في بعض الأحيان ، توجد ذاكرة كافية في نظامك ولكن الذاكرة ليست متجاورة. تستخدم كائنات دفق الذاكرة ذاكرة متجاورة ولكن يمكنك توفير تنفيذ دفق الذاكرة بطريقة تستخدم الذاكرة غير المتجاورة بدلاً من ذلك ،
عينة من الرموز
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Implement CustomImplementationFactory - CELLSNET-45461 | |
public class MM : CustomImplementationFactory | |
{ | |
RecyclableMemoryStreamManager manager = new RecyclableMemoryStreamManager(); | |
public override MemoryStream CreateMemoryStream() | |
{ | |
return manager.GetStream("MM"); | |
} | |
public override MemoryStream CreateMemoryStream(int capacity) | |
{ | |
return manager.GetStream("MM", capacity); | |
} | |
} | |
//---------------------------------------- | |
//---------------------------------------- | |
//Assign implementation instance of CustomImplementationFactory | |
CellsHelper.CustomImplementationFactory = new MM(); | |
//Light cells data handler implementation | |
LightCellsDataHandlerVisitCells v = new LightCellsDataHandlerVisitCells(); | |
//Create workbook object | |
Workbook wb = new Workbook(sourceDir, new LoadOptions() { MemorySetting = MemorySetting.MemoryPreference, LightCellsDataHandler = v }); | |
//Print miscellaneous data | |
Console.WriteLine("Total sheets: " + wb.Worksheets.Count + ", cells: " + v.CellCount + ", strings: " + v.StringCount + ", formulas: " + v.FormulaCount); |