Why does Resources class methods that return arrays of Objects aren’t marked with TypeInferenceRuleAttribute as it does for methods that return a single Object (e.g. Resources.Load)?
I just want to cast it like that:
MyComp[] comps = Resources.LoadAll (path, typeof (MyComp)) as MyComp[];
MyComp[] comps = (MyComp[])Resources.LoadAll (path, typeof (MyComp));
I’ve tried using TypeInferenceRule myself, writing a wrapper like:
[TypeInferenceRule (TypeInferenceRules.ArrayOfTypeReferencedByFirstArgument)]
static Object[] LoadAll (Type type, string path) {
return Resources.LoadAll (string, type);
}
But no success. Still invalid cast operation.
For performance reasons, I prefer not to use Linq’s Cast<>.