Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public bool IsSupportedPropertyType(byte propertyType)
 {
     return(PropertyDatabase.IsSupportedPropertyType(propertyType));
 }
Exemplo n.º 7
0
 public bool IsSupportedValue(object value)
 {
     return(PropertyDatabase.IsSupportedValue(value));
 }
Exemplo n.º 8
0
 public Hash128 CreatePropertyHash(string propertyPath)
 {
     return(PropertyDatabase.CreatePropertyHash(propertyPath));
 }
Exemplo n.º 9
0
 public ulong CreateDocumentKey(string documentId)
 {
     return(PropertyDatabase.CreateDocumentKey(documentId));
 }
Exemplo n.º 10
0
 public PropertyDatabaseRecordKey CreateRecordKey(string documentId, Hash128 propertyHash)
 {
     return(PropertyDatabase.CreateRecordKey(documentId, propertyHash));
 }
Exemplo n.º 11
0
 public PropertyDatabaseRecordKey CreateRecordKey(string propertyPath)
 {
     return(PropertyDatabase.CreateRecordKey(propertyPath));
 }
Exemplo n.º 12
0
 public PropertyDatabaseRecordKey CreateRecordKey(ulong documentKey, Hash128 propertyPathHash)
 {
     return(PropertyDatabase.CreateRecordKey(documentKey, propertyPathHash));
 }
Exemplo n.º 13
0
 public PropertyDatabaseRecordKey CreateRecordKey(string documentId, string propertyPath)
 {
     return(PropertyDatabase.CreateRecordKey(documentId, propertyPath));
 }
Exemplo n.º 14
0
 public PropertyDatabaseRecord CreateRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue)
 {
     return(PropertyDatabase.CreateRecord(recordKey, recordValue));
 }
Exemplo n.º 15
0
        public void Invalidate(string documentId)
        {
            var documentKey = PropertyDatabase.CreateDocumentKey(documentId);

            Invalidate(documentKey);
        }
Exemplo n.º 16
0
        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);
            }
        }
Exemplo n.º 17
0
 public PropertyDatabaseRecordKey CreateRecordKey(Hash128 propertyHash)
 {
     return(PropertyDatabase.CreateRecordKey(propertyHash));
 }