public bool TryGetComplexType(Type clrComplexType, out IComplexType complexType) { complexType = null; return(clrComplexType != null && this.ClrTypeToComplexTypeDictionary != null && this.ClrTypeToComplexTypeDictionary.TryGetValue(clrComplexType, out complexType)); }
private void AddComplexType(IComplexType type) { if (!type.IsFake && ComplexTypes.TryGetValue(type.Name, out var already) && !type.Equals(already)) { throw new Exception($"Non-uniform definition of complex type {type.Name}"); } ComplexTypes[type.Name] = type; }
// PUBLIC METHODS /////////////////////////////////////////////////// #region Assert Methods public static void Equal(IComplexType expected, IComplexType actual) { if (expected == null) { Assert.Null(actual); return; } Assert.NotNull(actual); Assert.Equal(expected.ClrType, actual.ClrType); AttributesInfoAssert.Equal(expected.AttributesInfo, actual.AttributesInfo); }
public void TestComplexTypeBuilderCreateComplexType(string name, IComplexTypeFactory complexTypeFactory, IConventions conventions, IComplexType expectedComplexType) { this.Output.WriteLine("Test Name: {0}", name); this.Output.WriteLine(String.Empty); // Arrange var serializerSettings = new JsonSerializerSettings { Converters = new[] { (JsonConverter) new StringEnumConverter() }, Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Include }; var expectedJson = expectedComplexType.ToJson(serializerSettings); this.Output.WriteLine("Expected ComplexType"); this.Output.WriteLine(expectedJson); // Act var actualComplexType = complexTypeFactory.Create(conventions); this.Output.WriteLine(String.Empty); var actualJson = actualComplexType.ToJson(serializerSettings); this.Output.WriteLine("Actual ComplexType"); this.Output.WriteLine(actualJson); // Assert ComplexTypeAssert.Equal(expectedComplexType, actualComplexType); }