public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (ClrTypeReference typeReference in typeReferences.OfType <ClrTypeReference>()) { if (!BaseTypes.IsNonGenericBaseType(typeReference.Type) && _typeInspector.TryCreate(typeReference.Type, out TypeInfo typeInfo)) { Type type = typeInfo.ClrType; if (IsTypeSystemObject(type)) { ClrTypeReference namedTypeReference = typeReference.With(type); if (!typeRegistrar.IsResolved(namedTypeReference)) { typeRegistrar.Register( typeRegistrar.CreateInstance(type), typeReference.Scope, BaseTypes.IsGenericBaseType(type)); } } else { TryMapToExistingRegistration( typeRegistrar, typeInfo, typeReference.Context, typeReference.Scope); } } } }
private static void TryMapToExistingRegistration( ITypeRegistrar typeRegistrar, ITypeInfo typeInfo, TypeContext context, string?scope) { ExtendedTypeReference?normalizedTypeRef = null; var resolved = false; foreach (TypeComponent component in typeInfo.Components) { normalizedTypeRef = TypeReference.Create( component.Type, context, scope); if (typeRegistrar.IsResolved(normalizedTypeRef)) { resolved = true; break; } } if (!resolved && normalizedTypeRef is not null) { typeRegistrar.MarkUnresolved(normalizedTypeRef); } }
public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (ExtendedTypeReference typeReference in typeReferences.OfType <ExtendedTypeReference>()) { if (_typeInspector.TryCreateTypeInfo(typeReference.Type, out ITypeInfo? typeInfo) && !ExtendedType.Tools.IsNonGenericBaseType(typeInfo.NamedType)) { Type namedType = typeInfo.NamedType; if (IsTypeSystemObject(namedType)) { IExtendedType extendedType = _typeInspector.GetType(namedType); ExtendedTypeReference namedTypeReference = typeReference.With(extendedType); if (!typeRegistrar.IsResolved(namedTypeReference)) { typeRegistrar.Register( typeRegistrar.CreateInstance(namedType), typeReference.Scope, ExtendedType.Tools.IsGenericBaseType(namedType)); } } else { TryMapToExistingRegistration( typeRegistrar, typeInfo, typeReference.Context, typeReference.Scope); } } } }
public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (ISchemaTypeReference typeReference in typeReferences.OfType <ISchemaTypeReference>()) { if (!typeRegistrar.IsResolved(typeReference)) { typeRegistrar.Register((TypeSystemObjectBase)typeReference.Type); } } }
public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (ISyntaxTypeReference typeReference in typeReferences.OfType <ISyntaxTypeReference>()) { if (Scalars.TryGetScalar( typeReference.Type.NamedType().Name.Value, out IClrTypeReference namedTypeReference)) { if (!typeRegistrar.IsResolved(namedTypeReference)) { typeRegistrar.Register(typeRegistrar.CreateInstance(namedTypeReference.Type)); } } } }
public void Handle(ITypeRegistrar typeRegistrar, ITypeReference typeReference) { var typeRef = (SchemaTypeReference)typeReference; if (!typeRegistrar.IsResolved(typeReference)) { ITypeSystemMember tsm = typeRef.Type; // if it is a type object we will make sure it is unwrapped. if (typeRef.Type is IType type) { tsm = type.NamedType(); } if (tsm is TypeSystemObjectBase tso) { typeRegistrar.Register(tso, typeReference.Scope); } } }
private void TryMapToExistingRegistration( ITypeRegistrar typeRegistrar, TypeInfo typeInfo, TypeContext context) { ClrTypeReference?normalizedTypeRef = null; bool resolved = false; for (int i = 0; i < typeInfo.Components.Count; i++) { normalizedTypeRef = new ClrTypeReference( typeInfo.Components[i], context); if (typeRegistrar.IsResolved(normalizedTypeRef)) { resolved = true; break; } } if (!resolved && normalizedTypeRef is { })
public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (SyntaxTypeReference typeReference in typeReferences.OfType <SyntaxTypeReference>()) { if (Scalars.TryGetScalar( typeReference.Type.NamedType().Name.Value, out Type? scalarType)) { ExtendedTypeReference namedTypeReference = _typeInspector.GetTypeRef(scalarType); if (!typeRegistrar.IsResolved(namedTypeReference)) { typeRegistrar.Register( typeRegistrar.CreateInstance(namedTypeReference.Type.Type), typeReference.Scope); } } } }
public void Register( ITypeRegistrar typeRegistrar, IEnumerable <ITypeReference> typeReferences) { foreach (SchemaTypeReference typeReference in typeReferences.OfType <SchemaTypeReference>()) { if (!typeRegistrar.IsResolved(typeReference)) { ITypeSystemMember tsm = typeReference.Type; // if it is a type object we will make sure it is unwrapped. if (typeReference.Type is IType type) { tsm = type.NamedType(); } if (tsm is TypeSystemObjectBase tso) { typeRegistrar.Register(tso, typeReference.Scope); } } } }
public void Handle(ITypeRegistrar typeRegistrar, ITypeReference typeReference) { var typeRef = (ExtendedTypeReference)typeReference; if (_typeInspector.TryCreateTypeInfo(typeRef.Type, out ITypeInfo? typeInfo) && !ExtendedType.Tools.IsNonGenericBaseType(typeInfo.NamedType)) { if (typeInfo.NamedType == typeof(IExecutable)) { throw ThrowHelper.NonGenericExecutableNotAllowed(); } Type namedType = typeInfo.NamedType; if (IsTypeSystemObject(namedType)) { IExtendedType extendedType = _typeInspector.GetType(namedType); ExtendedTypeReference namedTypeReference = typeRef.With(extendedType); if (!typeRegistrar.IsResolved(namedTypeReference)) { typeRegistrar.Register( typeRegistrar.CreateInstance(namedType), typeReference.Scope, ExtendedType.Tools.IsGenericBaseType(namedType)); } } else { TryMapToExistingRegistration( typeRegistrar, typeInfo, typeReference.Context, typeReference.Scope); } } }