public UnionType() { UnionTypeDescriptor descriptor = new UnionTypeDescriptor(GetType()); Configure(descriptor); if (string.IsNullOrEmpty(descriptor.Name)) { throw new ArgumentException( "A union type name must not be null or empty."); } if (descriptor.Types == null) { throw new ArgumentException( "A union type must have a set of types."); } _typesFactory = r => descriptor.Types .Select(t => t.TypeFactory(r)) .Cast <ObjectType>(); _typeInfos = descriptor.Types; _typeResolver = descriptor.ResolveAbstractType; Name = descriptor.Name; Description = descriptor.Description; }
protected override UnionTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = UnionTypeDescriptor.New( context.DescriptorContext); _configure(descriptor); return(descriptor.CreateDefinition()); }
protected override UnionTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { var descriptor = UnionTypeDescriptor.New( context.DescriptorContext, typeof(T)); _configure(descriptor); return(descriptor.CreateDefinition()); }
protected override UnionTypeDefinition CreateDefinition( ITypeDiscoveryContext context) { var descriptor = UnionTypeDescriptor.FromSchemaType( context.DescriptorContext, GetType()); _configure(descriptor); return(descriptor.CreateDefinition()); }
private void Initialize(Action <IUnionTypeDescriptor> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } UnionTypeDescriptor descriptor = new UnionTypeDescriptor(GetType()); configure(descriptor); Initialize(descriptor); }
private void Initialize(Action <IUnionTypeDescriptor> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var descriptor = new UnionTypeDescriptor(GetType()); configure(descriptor); UnionTypeDescription description = descriptor.CreateDescription(); _types = description.Types; _resolveAbstractType = description.ResolveAbstractType; Name = description.Name; Description = description.Description; }
private void Initialize(UnionTypeDescriptor descriptor) { if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (string.IsNullOrEmpty(descriptor.Name)) { throw new ArgumentException( "A union type name must not be null or empty."); } _types = descriptor.Types; _resolveAbstractType = descriptor.ResolveAbstractType; Name = descriptor.Name; Description = descriptor.Description; }
private void Initialize(Action <IUnionTypeDescriptor> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var descriptor = new UnionTypeDescriptor(GetType()); configure(descriptor); UnionTypeDescription description = descriptor.CreateDescription(); _types = description.Types; _resolveAbstractType = description.ResolveAbstractType; Initialize(description.Name, description.Description, new DirectiveCollection(this, DirectiveLocation.Union, description.Directives)); }