internal static bool GetImageData(ModuleDef module, string typeName, byte[] serializedData, out byte[] imageData)
        {
            imageData = null;
            if (!SerializedImageResourceElementTreeNodeFactory.CheckType(module, typeName, SystemWindowsFormsImageListStreamer))
            {
                return(false);
            }

            var dict = Deserializer.Deserialize(SystemWindowsFormsImageListStreamer.DefinitionAssembly.FullName, SystemWindowsFormsImageListStreamer.ReflectionFullName, serializedData);

            // ImageListStreamer loops over every item looking for "Data" (case insensitive)
            foreach (var v in dict.Values)
            {
                var d = v.Value as byte[];
                if (d == null)
                {
                    continue;
                }
                if ("Data".Equals(v.Name, StringComparison.OrdinalIgnoreCase))
                {
                    imageData = d;
                    return(true);
                }
            }

            return(false);
        }
        public override string CheckCanUpdateData(ResourceElement newResElem)
        {
            var res = base.CheckCanUpdateData(newResElem);

            if (!string.IsNullOrEmpty(res))
            {
                return(res);
            }

            var binData = (BinaryResourceData)newResElem.ResourceData;

            byte[] imageData;
            if (!SerializedImageResourceElementTreeNodeFactory.GetImageData(GetModule(this), binData.TypeName, binData.Data, out imageData))
            {
                return("The new data is not an image.");
            }

            try {
                ImageResourceElementTreeNode.CreateImageSource(imageData);
            }
            catch {
                return("The new data is not an image.");
            }

            return(string.Empty);
        }
        public override void UpdateData(ResourceElement newResElem)
        {
            base.UpdateData(newResElem);

            var binData = (BinaryResourceData)newResElem.ResourceData;

            byte[] imageData;
            SerializedImageResourceElementTreeNodeFactory.GetImageData(GetModule(this), binData.TypeName, binData.Data, out imageData);
            InitializeImageData(imageData);
        }