本文整理汇总了C#中ILArray.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# ILArray.Serialize方法的具体用法?C# ILArray.Serialize怎么用?C# ILArray.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILArray
的用法示例。
在下文中一共展示了ILArray.Serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Serialize
public void Test_Serialize() {
int errorCode = 0;
try {
double[] data = new double[1000 * 1000 * 10];
String filename = "ILDoubleArray_SerializeTest1.ils";
for (int i = 0; i < data.Length; i++)
data[i] = (double)i;
ILArray<double> A = new ILArray<double>(data, 1000,1000,10);
FileStream fs = new FileStream(filename, FileMode.Create);
Info("Serializing to file: (please wait...)");
A.Serialize(fs);
fs.Close();
FileInfo fi = new FileInfo(filename);
Info("Serialized to file: [1000 x 1000 x 10] => " + ((int)(fi.Length/1024)) + "kB");
// create reference storage from smaler range -> should Detach()
errorCode = 1;
filename = "ILDoubleArray_SerializeTest2.ils";
fs = new FileStream(filename, FileMode.Create);
ILArray<double> AR1 = (ILArray<double>)A[0,"0:600;30:400;0:end"];
AR1.Serialize(fs);
fs.Close();
fi = new FileInfo(filename);
Info("Serialized to file: [600 x 360 x 10] => " + ((int)(fi.Length / 1024)) + "kB");
// if reference storage saved effective memory - keep it as reference
errorCode = 2;
filename = "ILDoubleArray_SerializeTest3.ils";
fs = new FileStream(filename, FileMode.Create);
ILArray<double> AR2 = (ILArray<double>)A[0,"0:end,0:end;0:end,0:end;0:end"];
AR2.Serialize(fs);
fs.Close();
fi = new FileInfo(filename);
Info("Serialized to file: [2000 x 2000 x 20] => " + ((int)(fi.Length / 1024)) + "kB");
// test if small reference would NOT store full data array
errorCode = 4;
filename = "ILDoubleArray_SerializeTest4.ils";
fs = new FileStream(filename, FileMode.Create);
ILArray<double> AR3 = (ILArray<double>)A["3;3;1"];
AR3.Serialize(fs);
fs.Close();
fi = new FileInfo(filename);
Info("Serialized to file: [1 x 1] => " + ((int)(fi.Length / 1024)) + "kB");
if (fi.Length > 1024 * 2)
throw new Exception("Small reference storages should get detached before serializing!");
errorCode = 5;
Success("Test_serialize successfull");
} catch (SerializationException e) {
Error("Test_serialize failed on ErrorCode: "+ errorCode +"due: " + e.Message);
} catch (Exception e) {
Error("Test_serialize failed on ErrorCode: " + errorCode + "due: " + e.Message);
}
}