using DTLib.Dtsod.V24.KerepTypes; namespace DTLib.Dtsod.V24.Autoarr; using AutoarrPtr=IntPtr; public abstract class AutoarrFunctions { static AutoarrFunctions() { DependencyResolver.CopyLibs(); } internal abstract AutoarrPtr Create(ushort maxBlocksCount, ushort maxBlockLength); internal abstract void Free(AutoarrPtr ar); internal abstract T Get(AutoarrPtr ar, uint index); internal abstract void Add(AutoarrPtr ar, T element); internal abstract void Set(AutoarrPtr ar, uint index, T element); internal abstract uint Length(AutoarrPtr ar); internal abstract uint MaxLength(AutoarrPtr ar); private static AutoarrFunctions f_uni = new AutoarrUnitypeFunctions(); private static AutoarrFunctions f_kvp = new AutoarrKVPairFunctions(); static internal AutoarrFunctions GetFunctions() { if (f_kvp is AutoarrFunctions f) return f; else if (f_uni is AutoarrFunctions ff) return ff; else throw new Exception($"unsupported type: {typeof(T)}"); /*if (typeof(T) == typeof(Unitype)) return (AutoarrFunctions)Convert.ChangeType(f_uni, typeof(AutoarrFunctions)); else if (typeof(T) == typeof(KVPair)) return (AutoarrFunctions) Convert.ChangeType(f_kvp, typeof(AutoarrFunctions)); else throw new Exception($"unsupported type: {typeof(T)}");*/ } }