public WFMappingTarget(string target, Type targettype, WFMappingTargetTypes mappingtargettype) { if (target == null || target == string.Empty || targettype == null) throw new Exception("Invalid arguments"); string property = string.Empty; this.TargetType = TargetTypes.Unknown; this.Property = default(MethodInfo); this.Value = null; string[] splitdata = target.Split(new char[] { '@' }); if (splitdata.Length == 1) { property = splitdata[0]; this.TargetType = TargetTypes.Property; } else { property = splitdata[1]; switch (splitdata[0].ToUpper()) { case "VALUE": this.TargetType = TargetTypes.Value; break; case "PROPERTY": this.TargetType = TargetTypes.Property; break; } } if (this.TargetType == TargetTypes.Unknown) throw new Exception("Invalid arguments"); if (this.TargetType == TargetTypes.Property) { try { if(mappingtargettype == WFMappingTargetTypes.WFTarget) this.Property = targettype.GetProperty(property).GetSetMethod(); else this.Property = targettype.GetProperty(property).GetGetMethod(); } catch (Exception ex) { throw new Exception("GetProperty or SetProperty failed arguments", ex); } } else this.Value = property; }
public WFMappingTarget(string target, Type targettype, WFMappingTargetTypes mappingtargettype) { if (target == null || target == string.Empty || targettype == null) { throw new Exception("Invalid arguments"); } string property = string.Empty; this.TargetType = TargetTypes.Unknown; this.Property = default(MethodInfo); this.Value = null; string[] splitdata = target.Split(new char[] { '@' }); if (splitdata.Length == 1) { property = splitdata[0]; this.TargetType = TargetTypes.Property; } else { property = splitdata[1]; switch (splitdata[0].ToUpper()) { case "VALUE": this.TargetType = TargetTypes.Value; break; case "PROPERTY": this.TargetType = TargetTypes.Property; break; } } if (this.TargetType == TargetTypes.Unknown) { throw new Exception("Invalid arguments"); } if (this.TargetType == TargetTypes.Property) { try { if (mappingtargettype == WFMappingTargetTypes.WFTarget) { this.Property = targettype.GetProperty(property).GetSetMethod(); } else { this.Property = targettype.GetProperty(property).GetGetMethod(); } } catch (Exception ex) { throw new Exception("GetProperty or SetProperty failed arguments", ex); } } else { this.Value = property; } }