Represents a configuration element to map one class member into another.
Inheritance: System.Configuration.ConfigurationElement
Exemple #1
0
        public void MappingConfigurationTest()
        {
            MappingConfigurationSection target = new MappingConfigurationSection();
            TypeMappingElement typeMapping = new TypeMappingElement();
            typeMapping.TargetType = typeof(TestClassA).FullName;
            typeMapping.SourceType = typeof(TestClassB).FullName;

            MemberMappingElement propMapping = new MemberMappingElement();
            propMapping.TargetMemberName = "A";
            propMapping.SourceMemberName = "B";
            typeMapping.MemberMappings.Add(propMapping);
            target.TypeMappings.Add(typeMapping);

            // TODO: change this call to SerializeSection
            var methodInfo = target.GetType().GetMethod(
                "SerializeElement",
                BindingFlags.Instance | BindingFlags.NonPublic);
            var sb = new StringBuilder();

            using (var writer = XmlWriter.Create(sb))
            {
                var res = methodInfo.Invoke(
                    target,
                    new object[] { writer, false });

                writer.Flush();
            }

            const string Expected = @"<MemberMappings><add TargetMemberName=""A"" SourceMemberName=""B"" /></MemberMappings>";
            StringAssert.Contains(Expected, sb.ToString());
        }
Exemple #2
0
 /// <summary>
 ///     Adds the specified element.
 /// </summary>
 /// <param name="element">The element.</param>
 public void Add(MemberMappingElement element)
 {
     BaseAdd(element);
 }
 /// <summary>
 ///     Adds the specified element.
 /// </summary>
 /// <param name="element">The element.</param>
 public void Add(MemberMappingElement element)
 {
     BaseAdd(element);
 }