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
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        private static byte[] CloneData(PngChunkUNKNOWN other)
        {
            if (other is null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            return(other.data);
        }
示例#6
0
        /// <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);
        }
示例#7
0
        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);
        }
示例#8
0
 private PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info)
     : base(c.Id, info)
 {
     System.Array.Copy(c.data, 0, data, 0, c.data.Length);
 }
示例#9
0
 private PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info)
     : base(c.Id, info)
 {
     System.Array.Copy(c.data, 0, data, 0, c.data.Length);
 }
示例#10
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkUNKNOWN pngChunkUNKNOWN = (PngChunkUNKNOWN)other;

            data = pngChunkUNKNOWN.data;
        }
示例#11
0
 public PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info)
     : base(c.Id, info)
 {
     Array.Copy(c.data, 0, data, 0, c.data.Length);
 }