/// <summary> /// Constructor required by deserialization /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected BlockRef(SerializationInfo info, StreamingContext context) : base(info, context) { idea = InfoReader.Read(info, "Idea", typeof(Block)) as Block; insertion = (ModOp)InfoReader.Read(info, "Insertion", typeof(ModOp)); colorDef = ColorDef.Read(info, context); }
private ICreationInfo[] ReadArray(BinaryReader br, Type arrayType, InfoReader infoReader) { var elementType = arrayType.GetElementType(); var length = br.ReadInt32(); var arr = new ICreationInfo[length]; for (int i = 0; i < length; i++) { arr[i] = infoReader.Read(br, elementType); } return(arr); }
/// <summary> /// Constructor required by deserialization /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected HatchStyleList(SerializationInfo info, StreamingContext context) { try { unsortedEntries = info.GetValue("UnsortedEntries", typeof(HatchStyle[])) as HatchStyle[]; } catch (SerializationException) { // alte Dateien beinhalten entries direkt entries = (SortedList)info.GetValue("Entries", typeof(SortedList)); } current = (HatchStyle)InfoReader.Read(info, "Current", typeof(HatchStyle)); resourceId = "HatchStyleList"; }
/// <summary> /// Constructor required by deserialization /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected LayerList(SerializationInfo info, StreamingContext context) : this() { try { unsortedEntries = info.GetValue("UnsortedEntries", typeof(Layer[])) as Layer[]; } catch (SerializationException) { // alte Dateien beinhalten entries direkt entries = (SortedList)info.GetValue("Entries", typeof(SortedList)); } current = (Layer)InfoReader.Read(info, "Current", typeof(Layer)); }
public void ReadObjectTypefromStream() { InfoReader ir = new InfoReader(); using (Stream stream = new MemoryStream()) using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream))) using (BinaryReader br = new BinaryReader(stream)) { wr.Write(new SampleClass()); stream.Seek(0, SeekOrigin.Begin); var info = ir.Read <SampleClass>(br); Assert.AreSame(typeof(SampleClass), ((ObjectInfo)info).ObjectType); } }
public void ReadPublicFieldNamefromStream() { InfoReader ir = new InfoReader(); using (Stream stream = new MemoryStream()) using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream))) using (BinaryReader br = new BinaryReader(stream)) { wr.Write(new SampleClass()); stream.Seek(0, SeekOrigin.Begin); var info = ir.Read <SampleClass>(br) as ObjectInfo; string expectedName = "simpleMember"; Assert.IsTrue(info.Fields.ContainsKey(expectedName)); } }
private static ICreationInfo WriteObjectAndReadInfo <T>(T objectToWrite) { ICreationInfo info; using (Stream stream = new MemoryStream()) using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream))) using (BinaryReader br = new BinaryReader(stream)) { wr.Write(objectToWrite); stream.Seek(0, SeekOrigin.Begin); InfoReader ir = new InfoReader(); info = ir.Read <T>(br); } return(info); }
public void ReadPublicIntFieldValuefromStream() { InfoReader ir = new InfoReader(); using (Stream stream = new MemoryStream()) using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream))) using (BinaryReader br = new BinaryReader(stream)) { const int five = 5; var simpleObject = new SampleClass { simpleMember = five }; wr.Write(simpleObject); stream.Seek(0, SeekOrigin.Begin); var info = ir.Read <SampleClass>(br) as ObjectInfo; Assert.AreEqual(five, info.Fields["simpleMember"].GetInstance(null)); } }
private ICreationInfo Read(FieldInfo fieldInfo, BinaryReader br, InfoReader infoReader) { var type = fieldInfo.FieldType; return(infoReader.Read(br, type)); }