title: AutoMapper Mapping one property to two properties by condition
body: <p>There are two classes</p>
  
  <pre><code>        class A
          {
              public string ProductionDivision { get; set; }
          }
  
  
          class B
          {
              private object _productionDivision;
  
              public enum ProductionDivisionOneofCase
              {
                  None = 0,
                  IsNullproductionDivision = 15,
                  ProductionDivisionValue = 16,
              }
              private ProductionDivisionOneofCase _productionDivisionCase = ProductionDivisionOneofCase.None;
  
  
              public bool IsNullProductionDivision
              {
                  get { return _productionDivisionCase == ProductionDivisionOneofCase.IsNullproductionDivision ? (bool)_productionDivision : false; }
                  set
                  {
                      _productionDivision = value;
                      _productionDivisionCase = ProductionDivisionOneofCase.IsNullproductionDivision;
                  }
              }
  
              public string ProductionDivisionValue
              {
                  get { return _productionDivisionCase == ProductionDivisionOneofCase.ProductionDivisionValue ? (string)_productionDivision : ""; }
                  set
                  {
                      _productionDivision = value;
                      _productionDivisionCase = ProductionDivisionOneofCase.ProductionDivisionValue;
                  }
              }
          }
  </code></pre>
  
  <p>I would like to map the <code>ProductionDivision</code> property to one of properties of class B depending on the  condition - <code>null</code>(map to <code>IsNullProductionDivision</code>)  or not <code>null</code>(map to <code>ProductionDivisionValue</code>)  of the source property value. I can achieve it like as below.</p>
  
  <pre><code>CreateMap&lt;A, B&gt;()
                 .ForMember(g =&gt; g.IsNullProductionDivision, m =&gt;
                 {
                     m.PreCondition(s =&gt; s.ProductionDivision == null);
                     m.MapFrom(b =&gt; true);
                 })
                 .ForMember(g =&gt; g.ProductionDivisionValue, m =&gt;
                 {
                     m.PreCondition(s =&gt; s.ProductionDivision != null);
                     m.MapFrom(b =&gt; b.ProductionDivision);
                 });
  </code></pre>
  
  <p>If the value of {source property name} is <code>null</code> then the value of IsNull{source property name} is <code>true</code>.
  Else if the value of {source property name} is not <code>null</code> then the value of {source property name}Value is the value of {source property name}.</p>
  
  <p>I have many properties that respond this mapping rule. So, I don't want to write mapping rule for each properties like above. I want to configurate a rule for such mapping globally. </p>
  
  <p>How can I configure AutoMapper so that it can handle such complex mapping?</p>