Пример #1
0
        public ClassContentReader(
            IContentReaderCollection contentReaderCollection,
            IXmlAttributeInterpreter xmlAttributeInterpreter,
            OnDeserializeConfiguration onDeserializeConfiguration)
        {
            this.onDeserializeConfiguration = onDeserializeConfiguration;
            emitConstruction = ReadHelpers.EmitConstruction <T>();
            var infos =
                typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty);

            foreach (var propertyInfo in infos)
            {
                if (PropertyIsBad(propertyInfo))
                {
                    continue;
                }
                if (propertyInfo.IsDefined(typeof(XmlAttributeAttribute), false))
                {
                    var name = xmlAttributeInterpreter.GetXmlNodeName(propertyInfo);
                    attributeMap.Add(name, ReadHelpers.BuildSetter <T>(propertyInfo, contentReaderCollection));
                }
                else
                {
                    var name = xmlAttributeInterpreter.GetXmlNodeName(propertyInfo);
                    propertiesMap.Add(name, ReadHelpers.BuildSetter <T>(propertyInfo, contentReaderCollection));
                }
            }
        }
        public void TestNoPublicConstructor()
        {
            var emitConstruction = ReadHelpers.EmitConstruction <CNoPublic>();

            Assert.AreEqual(0, CNoPublic.count);
            var result = emitConstruction();

            Assert.AreEqual(0, result.localCount);
            Assert.AreEqual(0, CNoPublic.count);
        }
        public void TestHasPublicConstructor()
        {
            var emitConstruction = ReadHelpers.EmitConstruction <CWithPublic>();

            Assert.AreEqual(0, CWithPublic.count);
            var cWithPublic = emitConstruction();

            Assert.AreEqual(1, cWithPublic.localCount);
            Assert.AreEqual(1, CWithPublic.count);
        }
Пример #4
0
 public CustomContentReader()
 {
     emitConstruction = ReadHelpers.EmitConstruction <T>();
 }