private RegisteredType InitializeType( TypeSystemObjectBase typeSystemObject, string?scope, bool isInferred) { try { var discoveryContext = new TypeDiscoveryContext( typeSystemObject, scope, _serviceFactory.Services, _descriptorContext, _interceptor); typeSystemObject.Initialize(discoveryContext); var references = new List <ITypeReference>(); if (!isInferred) { references.Add(TypeReference.Create( typeSystemObject, scope: scope)); } if (!BaseTypes.IsNonGenericBaseType(typeSystemObject.GetType())) { references.Add(TypeReference.Create( typeSystemObject.GetType(), SchemaTypeReference.InferTypeContext(typeSystemObject), scope: scope)); } if (typeSystemObject is IHasTypeIdentity hasTypeIdentity && hasTypeIdentity.TypeIdentity is { }) { var reference = TypeReference.Create( hasTypeIdentity.TypeIdentity, SchemaTypeReference.InferTypeContext(typeSystemObject), scope: scope); if (!references.Contains(reference)) { references.Add(reference); } } var registeredType = new RegisteredType( references, typeSystemObject, discoveryContext, CollectDependencies(discoveryContext), isInferred); return(registeredType); }
private RegisteredType InitializeType( TypeSystemObjectBase typeSystemObject, bool isInferred) { try { var initializationContext = new InitializationContext( typeSystemObject, _serviceFactory.Services, _descriptorContext, _contextData, _interceptor); typeSystemObject.Initialize(initializationContext); var references = new List <ITypeReference>(); if (!isInferred) { references.Add(new SchemaTypeReference(typeSystemObject)); } if (!BaseTypes.IsNonGenericBaseType(typeSystemObject.GetType())) { references.Add(new ClrTypeReference( typeSystemObject.GetType(), SchemaTypeReference.InferTypeContext(typeSystemObject))); } if (typeSystemObject is IHasTypeIdentity hasTypeIdentity && hasTypeIdentity.TypeIdentity is { }) { var reference = new ClrTypeReference( hasTypeIdentity.TypeIdentity, SchemaTypeReference.InferTypeContext(typeSystemObject)); if (!references.Contains(reference)) { references.Add(reference); } } var registeredType = new RegisteredType( references, typeSystemObject, initializationContext, initializationContext.TypeDependencies, isInferred); return(registeredType); }
private RegisteredType InitializeType( TypeSystemObjectBase typeSystemObject, string?scope, bool isInferred) { try { var discoveryContext = new TypeDiscoveryContext( typeSystemObject, _typeRegistry, _typeLookup, _context, _interceptor, scope); typeSystemObject.Initialize(discoveryContext); var references = new List <ITypeReference>(); if (!isInferred) { references.Add(TypeReference.Create(typeSystemObject, scope)); } if (!ExtendedType.Tools.IsNonGenericBaseType(typeSystemObject.GetType())) { references.Add(_context.TypeInspector.GetTypeRef( typeSystemObject.GetType(), SchemaTypeReference.InferTypeContext(typeSystemObject), scope)); } if (typeSystemObject is IHasTypeIdentity hasTypeIdentity && hasTypeIdentity.TypeIdentity is not null) { ExtendedTypeReference reference = _context.TypeInspector.GetTypeRef( hasTypeIdentity.TypeIdentity, SchemaTypeReference.InferTypeContext(typeSystemObject), scope); if (!references.Contains(reference)) { references.Add(reference); } } var registeredType = new RegisteredType( typeSystemObject, references, CollectDependencies(discoveryContext), discoveryContext, isInferred); return(registeredType); } catch (Exception ex) { throw new SchemaException( SchemaErrorBuilder.New() .SetMessage(ex.Message) .SetException(ex) .SetTypeSystemObject(typeSystemObject) .Build()); } }