示例#1
0
        protected static HWResource GetOrCreateFromFile(HWContext context,
                                                        string filename,
                                                        HWResourceType
                                                        expectedType =
                                                        HWResourceType.None)
        {
            // Set the extension based on the resource type if the filename doesn't have one
            if (string.IsNullOrEmpty(Path.GetExtension(filename)) &&
                TypeExtensions.TryGetValue(expectedType,
                                           out string defaultExtension))
            {
                filename = Path.ChangeExtension(filename, defaultExtension);
            }

            var resource = CreateResource(context, filename);

            resource?.Load(File.ReadAllBytes(resource.AbsolutePath));

            return(resource);
        }
示例#2
0
 public HWResourceTypeDefinition(HWResourceType type, Type resourceClass)
 {
     Type  = type;
     Class = resourceClass;
 }