public void SetTargetValue(Direction direction, CSEntry csentry, MVEntry mventry, object Value) { AttributeType at = direction.Equals(Direction.Import) ? mventry[this.Name].DataType : csentry[this.Name].DataType; bool isMultivalued = direction.Equals(Direction.Import) ? mventry[this.Name].IsMultivalued : csentry[this.Name].IsMultivalued; Tracer.TraceInformation("target-attribute: name: {0}, type: {1}, is-multivalue: {2}", this.Name, at, isMultivalued); if (Value == null || string.IsNullOrEmpty(Value.ToString())) { switch (this.ActionOnNullSource) { case AttributeAction.None: Tracer.TraceInformation("decline-mapping-since-no-default-action"); throw new DeclineMappingException("no-default-action"); case AttributeAction.Delete: Tracer.TraceInformation("deleting-target-attribute-value: attr: {0}, type: {1}", this.Name, at); if (direction.Equals(Direction.Import)) { mventry[this.Name].Delete(); } else { csentry[this.Name].Delete(); } break; case AttributeAction.SetDefault: Tracer.TraceInformation("set-target-attribute-default-value: attr: {0}, type: {1}, value: '{2}'", this.Name, at, this.DefaultValue); if (direction.Equals(Direction.Import)) { mventry[this.Name].Value = this.DefaultValue; } else { csentry[this.Name].Value = this.DefaultValue; } break; default: throw new DeclineMappingException("no-default-action"); } } else { Tracer.TraceInformation("set-target-attribute-value: attr: {0}, type: {1}, value: '{2}', direction: {3}", this.Name, at, Value, direction); if (direction.Equals(Direction.Import)) { if (at == AttributeType.Reference) { Exception ex = new NotSupportedException("cannot-import-to-reference"); Tracer.TraceError("mapping-exception {0}", ex.GetBaseException()); throw ex; } else { if (isMultivalued) { mventry[this.Name].Values.Clear(); foreach (object val in FromValueCollection(Value)) { mventry[this.Name].Values.Add(val as string); } } else { mventry[this.Name].Value = Value as string; } } } else { switch (at) { case AttributeType.Reference: csentry[this.Name].ReferenceValue = csentry.MA.CreateDN(Value as string); break; case AttributeType.Integer: if (isMultivalued) { csentry[this.Name].Values.Clear(); foreach (object val in FromValueCollection(Value)) { csentry[this.Name].Values.Add(long.Parse(Value as string)); } } else { csentry[this.Name].IntegerValue = long.Parse(Value as string); } break; default: if (isMultivalued) { csentry[this.Name].Values.Clear(); foreach (object val in FromValueCollection(Value)) { csentry[this.Name].Values.Add(val as string); } } else { csentry[this.Name].Value = Value as string; } break; } } } }