public static ResourceData FromResource(ResourceLang lang, Byte[] rawData) { ResourceTypeIdentifier typeId = lang.Name.Type.Identifier; // get a list of suitable factories ResourceDataFactory[] factories = ResourceDataFactory.GetFactoriesForType(typeId); // try the factories in order of compatibility. Int32 i = 0; ResourceData data = null; while (data == null) { if (i >= factories.Length) { throw new AnolisException("Unable to locate factory for resource data."); } try { data = factories[i++].FromResource(lang, rawData); } catch (ResourceDataException) { } } return(data); }
private static IconImageResourceDataFactory GetIconImageFactory() { IconImageResourceDataFactory factory = null; ResourceTypeIdentifier typeId = new ResourceTypeIdentifier(new IntPtr((int)Win32ResourceType.IconImage)); ResourceDataFactory[] factories = ResourceDataFactory.GetFactoriesForType(typeId); foreach (ResourceDataFactory f in factories) { if (f is IconImageResourceDataFactory) { factory = f as IconImageResourceDataFactory; break; } } if (factory == null) { throw ME(new ApplicationException("Unable to locate IconImageResourceDataFactory")); } return(factory); }