Пример #1
0
        public void TestResourceNameResolving()
        {
            var inspector = new ModelInspector();

            inspector.ImportType(typeof(Road));
            inspector.ImportType(typeof(Way));
            inspector.ImportType(typeof(ProfiledWay));
            inspector.ImportType(typeof(NewStreet));
            //inspector.Process();

            var road = inspector.FindClassMappingForResource("roAd");
            Assert.IsNotNull(road);
            Assert.AreEqual(road.NativeType, typeof(Road));

            var way = inspector.FindClassMappingForResource("Way");
            Assert.IsNotNull(way);
            Assert.AreEqual(way.NativeType, typeof(Way));

            var pway = inspector.FindClassMappingForResource("way", "http://nu.nl/profile#street");
            Assert.IsNotNull(pway);
            Assert.AreEqual(pway.NativeType, typeof(ProfiledWay));

            var pway2 = inspector.FindClassMappingForResource("way", "http://nux.nl/profile#street");
            Assert.IsNotNull(pway2);
            Assert.AreEqual(pway2.NativeType, typeof(Way));

            var street = inspector.FindClassMappingForResource("Street");
            Assert.IsNotNull(street);
            Assert.AreEqual(street.NativeType, typeof(NewStreet));

            var noway = inspector.FindClassMappingForResource("nonexistent");
            Assert.IsNull(noway);
        }
        private static Lazy<ModelInspector> createDefaultModelInspector()
        {
			return new Lazy<ModelInspector>(() =>
                {
                    var result = new ModelInspector();
#if PORTABLE45
                    result.Import(typeof(Resource).GetTypeInfo().Assembly);
#else
				result.Import(typeof(Resource).Assembly);
#endif
                return result;
			});

		}
Пример #3
0
        public void TestEnumTypeResolving()
        {
            var inspector = new ModelInspector();

            inspector.ImportEnum(typeof(SomeEnum));
            inspector.ImportEnum(typeof(ActResource.SomeOtherEnum));

            var result = inspector.FindEnumMappingByType(typeof(SomeEnum));
            Assert.IsNotNull(result);
            Assert.AreEqual(typeof(SomeEnum), result.EnumType);

            result = inspector.FindEnumMappingByType(typeof(ActResource.SomeOtherEnum));
            Assert.IsNotNull(result);
            Assert.AreEqual(typeof(ActResource.SomeOtherEnum), result.EnumType);
        }
Пример #4
0
        public void TypeDataTypeNameResolving()
        {
            var inspector = new ModelInspector();

            inspector.ImportType(typeof(AnimalName));
            inspector.ImportType(typeof(NewAnimalName));

            var result = inspector.FindClassMappingForFhirDataType("animalname");
            Assert.IsNotNull(result);
            Assert.AreEqual(result.NativeType, typeof(NewAnimalName));

            // Validate a mapping for a type will return the newest registration
            result = inspector.FindClassMappingByType(typeof(AnimalName));
            Assert.IsNotNull(result);
            Assert.AreEqual(result.NativeType, typeof(NewAnimalName));
        }
 public RepeatingElementReader(IFhirReader reader)
 {
     _current = reader;
     _inspector = SerializationConfig.Inspector;
 }
 public PrimitiveValueReader(IFhirReader data)
 {
     _current = data;
     _inspector = SerializationConfig.Inspector;
 }
Пример #7
0
 public ComplexTypeWriter(IFhirWriter writer)
 {
     _current = writer;
     _inspector = SerializationConfig.Inspector;
 }
Пример #8
0
        public void TestAssemblyInspection()
        {
            var inspector = new ModelInspector();

            // Inspect the HL7.Fhir.Model assembly
            inspector.Import(typeof(Resource).Assembly);

            // Check for presence of some basic ingredients
            Assert.IsNotNull(inspector.FindClassMappingForResource("patient"));
            Assert.IsNotNull(inspector.FindClassMappingForFhirDataType("HumanName"));
            Assert.IsNotNull(inspector.FindClassMappingForFhirDataType("code"));
            Assert.IsNotNull(inspector.FindClassMappingForFhirDataType("boolean"));

            // Verify presence of nested enumerations
            Assert.IsNotNull(inspector.FindEnumMappingByType(typeof(Address.AddressUse)));

            // Should have skipped abstract classes
            Assert.IsNull(inspector.FindClassMappingForResource("ComplexElement"));
            Assert.IsNull(inspector.FindClassMappingForResource("Element"));
            Assert.IsNull(inspector.FindClassMappingForResource("Resource"));
           
            // The open generic Code<> should not be there
            var codeOfT = inspector.FindClassMappingByType(typeof(Code<>));
            Assert.IsNull(codeOfT);
        }
Пример #9
0
 public ResourceReader(IFhirReader reader)
 {
     _reader = reader;
     _inspector = SerializationConfig.Inspector;
 }
 public RepeatingElementWriter(IFhirWriter writer)
 {
     _current = writer;
     _inspector = SerializationConfig.Inspector;
 }
Пример #11
0
 public ResourceWriter(IFhirWriter writer)
 {
     _writer = writer;
     _inspector = SerializationConfig.Inspector;
 }
Пример #12
0
 public PrimitiveValueWriter(IFhirWriter data)
 {
     _writer = data;
     _inspector = SerializationConfig.Inspector;
 }
Пример #13
0
 public ComplexTypeReader(IFhirReader reader)
 {
     _current = reader;
     _inspector = SerializationConfig.Inspector;
 }
Пример #14
0
 public DispatchingWriter(IFhirWriter data)
 {
     _current = data;
     _inspector = SerializationConfig.Inspector;
 }
Пример #15
0
 public DispatchingReader(IFhirReader data, bool arrayMode = false)
 {
     _current = data;
     _inspector = SerializationConfig.Inspector;
     _arrayMode = arrayMode;
 }