static void Init() { if (s_Initialize) { return; } Log("Initialize search monitor", 0UL); s_TransactionManager = new TransactionManager(k_TransactionDatabasePath); s_TransactionManager.Init(); propertyDatabase = new PropertyDatabase("Library/Search/propertyDatabase.db", true); propertyAliases = new PropertyDatabase("Library/Search/propertyAliases.db", true); EditorApplication.quitting += OnQuitting; AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; EditorSceneManager.activeSceneChangedInEditMode += (_, __) => InvalidateCurrentScene(); PrefabStage.prefabStageOpened += _ => InvalidateCurrentScene(); PrefabStage.prefabStageClosing += _ => InvalidateCurrentScene(); ObjectChangeEvents.changesPublished += OnObjectChanged; s_Initialize = true; }
public PropertyDatabaseView(PropertyDatabase propertyDatabase, PropertyDatabaseVolatileMemoryStore volatileMemoryStore, PropertyDatabaseMemoryStore memoryStore, PropertyDatabaseFileStore fileStore, PropertyStringTable stringTable, bool delayedSync) { m_PropertyDatabase = propertyDatabase; m_MemoryStore = memoryStore; m_FileStore = fileStore; m_VolatileMemoryStoreView = (PropertyDatabaseVolatileMemoryStoreView)volatileMemoryStore.GetView(); m_MemoryStoreView = (PropertyDatabaseMemoryStoreView)memoryStore.GetView(); m_FileStoreView = (PropertyDatabaseFileStoreView)fileStore.GetView(); m_StringTableView = stringTable.GetView(delayedSync); m_Disposed = false; m_DelayedSync = delayedSync; }
public SearchMonitorView(PropertyDatabase propertyDatabase, PropertyDatabase propertyAliases, bool delayedSync = false) { m_Disposed = false; if (s_PropertyDatabaseViews.TryGetValue(Thread.CurrentThread.ManagedThreadId, out var currentViews)) { propertyDatabaseView = currentViews.propertyDatabaseView; propertyAliasesView = currentViews.propertyAliasesView; m_NeedsDispose = false; } else { propertyDatabaseView = propertyDatabase.GetView(delayedSync); propertyAliasesView = propertyAliases.GetView(delayedSync); m_NeedsDispose = true; s_PropertyDatabaseViews.TryAdd(Thread.CurrentThread.ManagedThreadId, this); } }
public void Dispose() { if (m_Disposed) { return; } if (m_DelayedSync) { Sync(); } m_PropertyDatabase = null; m_MemoryStore = null; m_FileStore = null; m_VolatileMemoryStoreView.Dispose(); m_MemoryStoreView.Dispose(); m_FileStoreView.Dispose(); m_StringTableView.Dispose(); m_DelayedSync = false; m_Disposed = true; }
public bool TryLoadProperty(ulong documentKey, string propertyName, out PropertyDatabaseRecordKey recordKey, out object value, out string alias) { var propertyHash = PropertyDatabase.CreatePropertyHash(propertyName); recordKey = PropertyDatabase.CreateRecordKey(documentKey, propertyHash); if (!propertyAliasesView.TryLoad(recordKey, out object aliasObj)) { value = null; alias = propertyName; SearchMonitor.Log($"<color=red>Failed</color> to load {propertyName} without alias", recordKey, propertyName); return(false); } alias = (aliasObj as string) ?? propertyName; if (propertyDatabaseView.TryLoad(recordKey, out value)) { SearchMonitor.Log($"Load property {propertyName}", recordKey, value); return(true); } SearchMonitor.Log($"<color=red>Failed</color> to load property {propertyName}", recordKey, propertyName); return(false); }
public bool IsSupportedPropertyType(byte propertyType) { return(PropertyDatabase.IsSupportedPropertyType(propertyType)); }
public bool IsSupportedValue(object value) { return(PropertyDatabase.IsSupportedValue(value)); }
public Hash128 CreatePropertyHash(string propertyPath) { return(PropertyDatabase.CreatePropertyHash(propertyPath)); }
public ulong CreateDocumentKey(string documentId) { return(PropertyDatabase.CreateDocumentKey(documentId)); }
public PropertyDatabaseRecordKey CreateRecordKey(string documentId, Hash128 propertyHash) { return(PropertyDatabase.CreateRecordKey(documentId, propertyHash)); }
public PropertyDatabaseRecordKey CreateRecordKey(string propertyPath) { return(PropertyDatabase.CreateRecordKey(propertyPath)); }
public PropertyDatabaseRecordKey CreateRecordKey(ulong documentKey, Hash128 propertyPathHash) { return(PropertyDatabase.CreateRecordKey(documentKey, propertyPathHash)); }
public PropertyDatabaseRecordKey CreateRecordKey(string documentId, string propertyPath) { return(PropertyDatabase.CreateRecordKey(documentId, propertyPath)); }
public PropertyDatabaseRecord CreateRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue) { return(PropertyDatabase.CreateRecord(recordKey, recordValue)); }
public void Invalidate(string documentId) { var documentKey = PropertyDatabase.CreateDocumentKey(documentId); Invalidate(documentKey); }
public static SerializedProperty FindProperty(UnityEngine.Object obj, string propertyPath, out SerializedObject so) { if (!obj) { so = null; return(null); } so = new SerializedObject(obj); var property = so.FindProperty(propertyPath); if (property != null) { return(property); } #if USE_PROPERTY_DATABASE using (var view = SearchMonitor.GetView()) #endif { #if USE_PROPERTY_DATABASE var unresolvedPropertyPath = $"{obj.GetType().Name}.{propertyPath}"; var propertyPathRecordKey = PropertyDatabase.CreateRecordKey(obj.GetType().Name, unresolvedPropertyPath); if (view.TryLoadAlias(propertyPathRecordKey, out var resolvedPropertyPath)) { if (string.IsNullOrEmpty(resolvedPropertyPath)) { so?.Dispose(); return(null); } var resolvedProperty = so.FindProperty(resolvedPropertyPath); if (resolvedProperty != null) { return(resolvedProperty); } } #endif property = so.FindProperty($"m_{propertyPath}"); if (property != null) { #if USE_PROPERTY_DATABASE view.StoreAlias(propertyPathRecordKey, property.propertyPath); #endif return(property); } property = so.GetIterator(); var next = property.NextVisible(true); while (next) { if (property.name.EndsWith(propertyPath, StringComparison.OrdinalIgnoreCase)) { #if USE_PROPERTY_DATABASE view.StoreAlias(propertyPathRecordKey, property.propertyPath); #endif return(property); } next = property.NextVisible(property.hasChildren); } #if USE_PROPERTY_DATABASE view.StoreAlias(propertyPathRecordKey, string.Empty); #endif so?.Dispose(); so = null; return(null); } }
public PropertyDatabaseRecordKey CreateRecordKey(Hash128 propertyHash) { return(PropertyDatabase.CreateRecordKey(propertyHash)); }