示例#1
0
        private void CompleteAbstractTypeResolver(
            ITypeInitializationContext context)
        {
            if (_resolveAbstractType == null)
            {
                // if there is now custom type resolver we will use this default
                // abstract type resolver.
                IReadOnlyCollection <ObjectType> types = null;
                _resolveAbstractType = (c, r) =>
                {
                    if (types == null)
                    {
                        types = context.GetPossibleTypes(this);
                    }

                    foreach (ObjectType type in types)
                    {
                        if (type.IsOfType(c, r))
                        {
                            return(type);
                        }
                    }

                    return(null); // todo: should we throw instead?
                };
            }
        }