コード例 #1
0
        static DefaultOdinPropertyResolverLocator()
        {
            SearchIndex.AddIndexedTypes(ResolverUtilities.GetResolverAssemblies()
                                        .SelectMany(a => a.SafeGetTypes())
                                        .Where(type => type.IsAbstract == false &&
                                               typeof(OdinPropertyResolver).IsAssignableFrom(type) &&
                                               !type.IsDefined <OdinDontRegisterAttribute>())
                                        .Select(type =>
            {
                var result = new TypeSearchInfo()
                {
                    MatchType = type,
                    Priority  = ResolverUtilities.GetResolverPriority(type),
                };

                if (type.ImplementsOpenGenericType(typeof(OdinPropertyResolver <>)))
                {
                    if (type.ImplementsOpenGenericType(typeof(OdinPropertyResolver <,>)))
                    {
                        result.Targets = type.GetArgumentsOfInheritedOpenGenericType(typeof(OdinPropertyResolver <,>));
                    }
                    else
                    {
                        result.Targets = type.GetArgumentsOfInheritedOpenGenericType(typeof(OdinPropertyResolver <>));
                    }
                }
                else
                {
                    result.Targets = Type.EmptyTypes;
                }

                return(result);
            }));
        }
コード例 #2
0
 static DefaultOdinAttributeProcessorLocator()
 {
     SearchIndex.AddIndexedTypes(ResolverUtilities.GetResolverAssemblies()
                                 .SelectMany(a => a.SafeGetTypes())
                                 .Where(type => type.IsAbstract == false &&
                                        typeof(OdinAttributeProcessor).IsAssignableFrom(type) &&
                                        type.IsDefined <OdinDontRegisterAttribute>() == false)
                                 .OrderByDescending(type => ResolverUtilities.GetResolverPriority(type))
                                 .Select(type => new TypeSearchInfo()
     {
         MatchType = type,
         Priority  = ResolverUtilities.GetResolverPriority(type),
         Targets   = type.ImplementsOpenGenericClass(typeof(OdinAttributeProcessor <>)) ? new Type[] { type.GetArgumentsOfInheritedOpenGenericClass(typeof(OdinAttributeProcessor <>))[0] } : Type.EmptyTypes
     }));
 }
コード例 #3
0
        static OdinPropertyProcessorLocator()
        {
            SearchIndex.AddIndexedTypes(
                ResolverUtilities.GetResolverAssemblies()
                .SelectMany(a => a.SafeGetTypes())
                .Where(type => !type.IsAbstract &&
                       typeof(OdinPropertyProcessor).IsAssignableFrom(type) &&
                       !type.IsDefined <OdinDontRegisterAttribute>(false))
                .Select(type =>
            {
                if (type.ImplementsOpenGenericClass(typeof(OdinPropertyProcessor <>)))
                {
                    if (type.ImplementsOpenGenericClass(typeof(OdinPropertyProcessor <,>)))
                    {
                        // Value/attribute targeted resolver
                        return(new TypeSearchInfo()
                        {
                            MatchType = type,
                            Targets = type.GetArgumentsOfInheritedOpenGenericClass(typeof(OdinPropertyProcessor <,>)),
                            Priority = ResolverUtilities.GetResolverPriority(type)
                        });
                    }

                    // Value targeted resolver
                    return(new TypeSearchInfo()
                    {
                        MatchType = type,
                        Targets = type.GetArgumentsOfInheritedOpenGenericClass(typeof(OdinPropertyProcessor <>)),
                        Priority = ResolverUtilities.GetResolverPriority(type)
                    });
                }

                // No target constraints resolver (only CanResolveForProperty)
                return(new TypeSearchInfo()
                {
                    MatchType = type,
                    Targets = Type.EmptyTypes,
                    Priority = ResolverUtilities.GetResolverPriority(type)
                });
            }));
        }