vithigar@lemmy.catoSelfhosted@lemmy.world•Why is HDR in Plex such a chore while it is no problem on VLC?English
1·
16 days agoWhen I initially set up my media server I went with Jellyfin over Plex mostly because the idea of having to create an account on an external service to use software I was hosting myself rubbed me the wrong way. Since then the more learn about Plex the more baffled I am that anyone chooses to use it at all.
C# .NET using reflection, integer underflow, and a touch of LINQ. Should work for all integer types. (edit: also works with
char
values)// this increments i private static T Increment<T>(T i) { var valType = typeof(T); var maxField = valType.GetField("MaxValue"); var minField = valType.GetField("MinValue"); if (maxField != null) { T maxValue = (T)maxField.GetValue(i); T minValue = (T)minField.GetValue(i); var methods = valType.GetTypeInfo().DeclaredMethods; var subMethod = methods.Where(m => m.Name.EndsWith("op_Subtraction")).First(); T interim = (T)subMethod.Invoke( null, [i, maxValue]); return (T)subMethod.Invoke( null, [interim, minValue]); } throw new ArgumentException("Not incrementable."); }