public void GenerateCode(SourceCodeBuilder sb) { if (!string.IsNullOrWhiteSpace(_nameSpace)) { sb.AppendLine($"namespace {_nameSpace}"); sb.OpenBlock(); } if (_usingNs.Any()) { foreach (var n in _usingNs) { sb.AppendLine($"using {n};"); } } sb.AppendLine(); sb.AppendLine($"public class {_name}"); if (_interfaces.Any()) { sb.Remove(sb.Length - 2, 2); sb.Append(" : "); sb.Append(string.Join(",", _interfaces)); sb.AppendLine(); } sb.OpenBlock(); foreach (var prop in _props) { sb.AppendLine($"public {prop.Type} {prop.Name} {{ get; set; }}"); } sb.CloseBlock(); if (!string.IsNullOrWhiteSpace(_nameSpace)) { sb.CloseBlock(); } }
public void Write(SourceCodeBuilder sb) { WriteAttributes(sb); sb.Append($"{_type} {_name}"); }
public void GenerateCode(SourceCodeBuilder sb) { if (!string.IsNullOrWhiteSpace(_nameSpace)) { sb.AppendLine($"namespace {_nameSpace}"); sb.OpenBlock(); } if (_usingNs.Any()) { foreach (var n in _usingNs) { sb.AppendLine($"using {n};"); } } sb.AppendLine(); sb.AppendLine($"public class {_name} : Profile"); sb.OpenBlock(); sb.AppendLine($"public {_name}()"); sb.OpenBlock(); string eol = IgnoreProperties.Any() ? "" : ";"; sb.AppendLine($"{sb.Prefix}this.CreateMap<{_sourceType.ToString()}, {_destinationType.ToString()}>(){eol}"); if (IgnoreProperties.Any()) { sb.IndentUp(); for (var index = 0; index < this.IgnoreProperties.Count; index++) { var i = this.IgnoreProperties[index]; eol = index == this.IgnoreProperties.Count - 1 ? ";" : ""; sb.AppendLine($".ForMember(dst => dst.{i}, opt => opt.Ignore()){eol}"); } sb.IndentDown(); } foreach (var m in Mappings) { if (m.SrcType.IsNullable) { sb.AppendLine($"this.CreateMap<{m.SrcType.GenericArguments.First().ToString()}, {_destinationType.ToString()}>().ForMember(x => x.{m.DstMemberName}, opt => opt.MapFrom(dst => dst)).ForAllOtherMembers(opt => opt.Ignore());"); } else { sb.AppendLine($"this.CreateMap<{m.SrcType.ToString()}, {_destinationType.ToString()}>().ForMember(x => x.{m.DstMemberName}, opt => opt.MapFrom(dst => dst)).ForAllOtherMembers(opt => opt.Ignore());"); } } sb.CloseBlock(); sb.CloseBlock(); if (!string.IsNullOrWhiteSpace(_nameSpace)) { sb.CloseBlock(); } }
public bool Equals(SourceCodeBuilder sb) { return(_sb.Equals(sb)); }
public SourceCodeBuilder Append(SourceCodeBuilder value, int startIndex, int count) { _sb.Append(value._sb, startIndex, count); return(this); }
public SourceCodeBuilder Append(SourceCodeBuilder value) { _sb.Append(value); return(this); }