internal static StreamFile TryGetFromCache(IntPtr native) { if (native == null) { return(null); } if (cacheRepo.ContainsKey(native)) { StreamFile cacheRet; cacheRepo[native].TryGetTarget(out cacheRet); if (cacheRet != null) { cbg_StreamFile_Release(native); return(cacheRet); } else { cacheRepo.Remove(native); } } var newObject = new StreamFile(new MemoryHandle(native)); cacheRepo[native] = new WeakReference <StreamFile>(newObject); return(newObject); }
internal static StreamFile GenerateStreamFile(swig.StreamFile o, GenerationType type) { if (o == null) { return(null); } var p = o.GetPtr(); var existing = GC.StreamFiles.GetObject(p); existing = GenerateInternal(existing, o, type); if (existing != null) { return(existing); } var ret = new StreamFile(o); GC.StreamFiles.AddObject(p, ret); return(ret); }
public StreamFile CreateStreamFile(string path) { var ret = cbg_File_CreateStreamFile(selfPtr, path); return(StreamFile.TryGetFromCache(ret)); }