public void Dispose() { lock (_lock ?? new object()) { _parent?.Release(); _parent = null; GC.SuppressFinalize(this); } }
public IRef <EditorSession> GetSession(string path) { lock (_sessions) { if (_sessions.TryGetValue(path, out var rc) && rc.IsAlive) { return(rc.CreateRef()); } var xaml = _loadFromDisk ? File.ReadAllText(path) : ""; rc = new RefCountable <EditorSession>(new EditorSession(_w, path, xaml)); _sessions[path] = rc; return(rc.CreateRef()); } }
public static (RefCountable <T> rc, IRef <T> r) Create(T item) { var r = new RefCountable <T>(item); return(r, new Ref(r)); }
public Ref(RefCountable <T> parent) { _parent = parent; parent.AddRef(); }