public override void CloneDataFromRead(PngChunk other) { // THIS SHOULD NOT BE CALLED IF ALREADY CLONED WITH COPY CONSTRUCTOR PngChunkUNKNOWN c = (PngChunkUNKNOWN)other; data = c.data; // not deep copy }
/// <summary> /// Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known) /// </summary> /// <param name="cid">Chunk Id</param> /// <param name="info"></param> /// <returns></returns> internal static PngChunk FactoryFromId(String cid, ImageInfo info) { PngChunk chunk = null; if (factoryMap == null) { initFactory(); } if (isKnown(cid)) { Type t = factoryMap[cid]; if (t == null) { Console.Error.WriteLine("What?? " + cid); } System.Reflection.ConstructorInfo cons = t.GetConstructor(new Type[] { typeof(ImageInfo) }); object o = cons.Invoke(new object[] { info }); chunk = (PngChunk)o; } if (chunk == null) { chunk = new PngChunkUNKNOWN(cid, info); } return(chunk); }
/// <summary> /// Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known) /// </summary> /// <param name="cid">Chunk Id</param> /// <param name="info"></param> /// <returns></returns> internal static PngChunk FactoryFromId(String cid, ImageInfo info) { PngChunk chunk = null; if (factoryMap == null) { initFactory(); } if (isKnown(cid)) { Type t = factoryMap[cid]; if (t == null) { System.Diagnostics.Debug.WriteLine("What?? " + cid); } System.Reflection.ConstructorInfo cons = t.GetTypeInfo().DeclaredConstructors.Single( c => { var p = c.GetParameters(); return(p.Length == 1 && p[0].ParameterType == typeof(ImageInfo)); }); object o = cons.Invoke(new object[] { info }); chunk = (PngChunk)o; } if (chunk == null) { chunk = new PngChunkUNKNOWN(cid, info); } return(chunk); }
/// <summary> /// Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known) /// </summary> /// <param name="cid">Chunk Id</param> /// <param name="info"></param> /// <returns></returns> internal static AbstractPngChunk FactoryFromId(string cid, ImageInfo info) { AbstractPngChunk chunk = null; if (factoryMap is null) { _ = InitFactory(); } if (IsKnown(cid)) { var t = factoryMap[cid]; if (t is null) { Console.Error.WriteLine("What?? " + cid); } var cons = t.GetConstructor(new Type[] { typeof(ImageInfo) }); var o = cons.Invoke(new object[] { info }); chunk = (AbstractPngChunk)o; } if (chunk is null) { chunk = new PngChunkUNKNOWN(cid, info); } return(chunk); }
private static byte[] CloneData(PngChunkUNKNOWN other) { if (other is null) { throw new ArgumentNullException(nameof(other)); } return(other.data); }
/// <summary> /// Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known) /// </summary> /// <param name="cid">Chunk Id</param> /// <param name="info"></param> /// <returns></returns> internal static PngChunk FactoryFromId(String cid, ImageInfo info) { PngChunk chunk = null; if (factoryMap == null) { initFactory(); } if (isKnown(cid)) { chunk = factoryMap[cid](info); } if (chunk == null) { Console.WriteLine("unknown chunk " + cid); chunk = new PngChunkUNKNOWN(cid, info); } return(chunk); }
internal static PngChunk FactoryFromId(string cid, ImageInfo info) { PngChunk pngChunk = null; if (factoryMap == null) { initFactory(); } if (isKnown(cid)) { pngChunk = (PngChunk)factoryMap[cid].GetTypeInfo().DeclaredConstructors.First().Invoke(new object[1] { info }); } if (pngChunk == null) { pngChunk = new PngChunkUNKNOWN(cid, info); } return(pngChunk); }
private PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info) : base(c.Id, info) { System.Array.Copy(c.data, 0, data, 0, c.data.Length); }
public override void CloneDataFromRead(PngChunk other) { PngChunkUNKNOWN pngChunkUNKNOWN = (PngChunkUNKNOWN)other; data = pngChunkUNKNOWN.data; }
public PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info) : base(c.Id, info) { Array.Copy(c.data, 0, data, 0, c.data.Length); }