/// <inheritdoc /> public override TypeToRegister CreateSpawnedTypeToRegister( Type type, TypeToIncludeOrigin typeToIncludeOrigin) { var keyInDictionaryStringSerializer = this.KeyInDictionaryStringSerializer; // If a type has an associated KeyInDictionaryStringSerializer and we explore members // (JsonConverterBuilder will be null, otherwise the constructor throws if MemberTypesToInclude != None) // it is very highly unlikely that we want to use that serializer for members that are keys in // dictionaries. Without the code below which null it out, the config would require two entries for // the same type - one where MemberTypesToInclude is None, specifying the dictionary key serializer // and the other with All. Further, the one with the serializer would need to be registered first // (the second registration exists solely to explore members since the type itself will get // registered with the first entry). In the future, we should introduce an enum that describes // how to spawn and just follow those instructions (e.g. something like // CopyKeyInDictionaryStringSerializerWhenTypeToIncludeOriginIsGettingRelatedTypes - which would // only copy the serializer for related types, but not member types). if (typeToIncludeOrigin == TypeToIncludeOrigin.GettingMemberTypes) { keyInDictionaryStringSerializer = null; } var result = new TypeToRegisterForJson(type, this.RecursiveOriginType, this.Type, this.MemberTypesToInclude, this.RelatedTypesToInclude, this.JsonConverterBuilder, keyInDictionaryStringSerializer); return(result); }
private void EnqueueAdditionalTypesToInclude( TypeToRegister typeToRegister, IReadOnlyCollection <Type> additionalTypesToInclude, TypeToIncludeOrigin typeToIncludeOrigin, Queue <TypeToRegister> typesToRegisterQueue) { // This excludes typeToRegister.Type (the dequeued value), // so it's not possible to create any more originating types. additionalTypesToInclude = additionalTypesToInclude .Distinct() .Where(_ => !VersionlessOpenTypeConsolidatingTypeEqualityComparer.Instance.Equals(_, typeToRegister.Type)) .ToList(); foreach (var additionalTypeToInclude in additionalTypesToInclude) { var additionalTypeToRegister = typeToRegister.CreateSpawnedTypeToRegister(additionalTypeToInclude, typeToIncludeOrigin); var additionalTypeToRegisterId = BuildIdIgnoringOrigin(additionalTypeToRegister); if (!this.visitedTypesToRegisterIds.Contains(additionalTypeToRegisterId)) { typesToRegisterQueue.Enqueue(additionalTypeToRegister); } } }
/// <inheritdoc /> public override TypeToRegister CreateSpawnedTypeToRegister( Type type, TypeToIncludeOrigin typeToIncludeOrigin) { var result = new TypeToRegisterForBson(type, this.RecursiveOriginType, this.Type, this.MemberTypesToInclude, this.RelatedTypesToInclude, this.BsonSerializerBuilder, this.PropertyNameWhitelist); return(result); }
/// <inheritdoc /> public override TypeToRegister CreateSpawnedTypeToRegister( Type type, TypeToIncludeOrigin typeToIncludeOrigin) { var result = new TypeToRegisterForPropertyBag(type, this.RecursiveOriginType, this.Type, this.MemberTypesToInclude, this.RelatedTypesToInclude, this.StringSerializerBuilderFunc); return(result); }
/// <summary> /// Creates a <see cref="TypeToRegister"/> that is spawned in processing the <see cref="MemberTypesToInclude"/> and <see cref="RelatedTypesToInclude"/> of this instance. /// </summary> /// <param name="type">The spawned type.</param> /// <param name="typeToIncludeOrigin">The <see cref="TypeToIncludeOrigin"/>.</param> /// <returns> /// The spawned <see cref="TypeToRegister"/>. /// </returns> public abstract TypeToRegister CreateSpawnedTypeToRegister( Type type, TypeToIncludeOrigin typeToIncludeOrigin);