Beispiel #1
0
        public static void GetDefaultPropertyDrawers(InspectorProperty property, List <TypeSearchResult> resultList)
        {
            resultList.Clear();

            var queries = CachedQueryResultList;

            queries.Clear();

            // First we make and gather lots of small queries, which are essentially instant, as they are
            //  all cached by the search index.
            {
                // Empty query (for all drawers with no type constraints at all)
                queries.Add(SearchIndex.GetMatches(Type.EmptyTypes));

                // Value query
                if (property.ValueEntry != null)
                {
                    queries.Add(SearchIndex.GetMatches(property.ValueEntry.TypeOfValue));
                }

                // Attribute queries
                for (int i = 0; i < property.Attributes.Count; i++)
                {
                    var attr = property.Attributes[i].GetType();
                    queries.Add(SearchIndex.GetMatches(attr));

                    // Attribute and value query
                    if (property.ValueEntry != null)
                    {
                        queries.Add(SearchIndex.GetMatches(attr, property.ValueEntry.TypeOfValue));

                        if (InvalidAttributeTargetUtility.ShowInvalidAttributeErrorFor(property, attr))
                        {
                            queries.Add(GetInvalidAttributeTypeSearchResult(attr));
                        }
                    }
                }
            }

            var finalResults = TypeSearchIndex.GetCachedMergedQueryResults(queries);

            // Build up the final result list, filtering invalid drawer types away
            //  as we go.
            for (int i = 0; i < finalResults.Length; i++)
            {
                var result = finalResults[i];

                if (DrawerTypeCanDrawProperty(result.MatchedType, property))
                {
                    resultList.Add(finalResults[i]);
                }
            }
        }
Beispiel #2
0
        public static IEnumerable <TypeSearchResult> GetDefaultPropertyDrawers(InspectorProperty property)
        {
            var queries = CachedQueryResultList;

            queries.Clear();

            // First we make and gather lots of small queries, which are essentially instant, as they are
            //  all cached by the search index.
            {
                // Empty query (for all drawers with no type constraints at all)
                queries.Add(SearchIndex.GetMatches(Type.EmptyTypes));

                // Value query
                if (property.ValueEntry != null)
                {
                    queries.Add(SearchIndex.GetMatches(property.ValueEntry.TypeOfValue));
                }

                // Attribute queries
                for (int i = 0; i < property.Attributes.Count; i++)
                {
                    var attr = property.Attributes[i].GetType();
                    queries.Add(SearchIndex.GetMatches(attr));

                    // Attribute and value query
                    if (property.ValueEntry != null)
                    {
                        queries.Add(SearchIndex.GetMatches(attr, property.ValueEntry.TypeOfValue));

                        if (InvalidAttributeTargetUtility.ShowInvalidAttributeErrorFor(property, attr))
                        {
                            queries.Add(new TypeSearchResult[]
                            {
                                new TypeSearchResult()
                                {
                                    MatchedInfo = new TypeSearchInfo()
                                    {
                                        MatchType = typeof(InvalidAttributeNotificationDrawer <>),
                                        Priority  = double.MaxValue,
                                        Targets   = Type.EmptyTypes
                                    },
                                    MatchedRule    = InvalidAttributeRule,
                                    MatchedTargets = Type.EmptyTypes,
                                    MatchedType    = typeof(InvalidAttributeNotificationDrawer <>).MakeGenericType(attr)
                                }
                            });
                        }
                    }
                }
            }

            var finalResults = TypeSearchIndex.GetCachedMergedQueryResults(queries);

            // Yield the final result array, filtering invalid drawer types away
            //  as we go.
            for (int i = 0; i < finalResults.Length; i++)
            {
                var result = finalResults[i];

                if (DrawerTypeCanDrawProperty(result.MatchedType, property))
                {
                    yield return(finalResults[i]);
                }
            }
        }