public List <int> GetIndices() { // If we have already computed the indices, use those if (CachedBuffIndices != null && CachedBuffIndices.Count > 0) { return(CachedBuffIndices); } // Get the buff index for each ComponentType. // We need to use reflection to create a new type // Then cast it as an IBuff, and read the IBuff property. var componentTypes = ComponentTypes; var buffIndices = ComponentTypes.Select(x => ((IBuff)(Activator.CreateInstance(x.GetManagedType()))).BuffIndex).ToList(); CachedBuffIndices = buffIndices; return(buffIndices); }