namespace TimelapseApi; public abstract class TimelapseExtension : IDisposable { public Api? Instance {get;internal set;} private class Nill : TimelapseExtension { public override string Name => "Timelapse"; public override Guid Id => Guid.Empty; } private static Nill _null=new Nill(); public static TimelapseExtension Null {get {return _null;}} public abstract string Name {get;} public string? FileName {get;internal set;} public abstract Guid Id {get;} protected virtual async Task OnCreateAsync(ExtensionFeatures features) { await Task.FromResult(true); } protected virtual void OnCreate(ExtensionFeatures features) { } public string GetExtensionFolder() { string p = Api.GetInternalFile($"ExtensionData/{Id}"); Directory.CreateDirectory(p); return p; } public TimelapseFileSystem? GetProjectSpecificLocation() { if(Instance != null && Instance.Project != null && Instance.Project.ProjectLocation != null) { Instance.Project.ProjectLocation.CreateDirectory("ExtensionData"); Instance.Project.ProjectLocation.CreateDirectory($"ExtensionData/{Id}"); var f= Instance.Project.ProjectLocation + $"ExtensionData/{Id}"; return new Protect(f); } return null; } internal async Task _Create() { ExtensionFeatures features=new ExtensionFeatures(this); await OnCreateAsync(features); OnCreate(features); features.Close(); } public void Dispose() { OnDestroy(); } protected virtual void OnDestroy() { } }