private List <string> GetPropertyAssignments(ClassModel domainModel, ParameterModel operationParameterModel)
        {
            var statements = new List <string>();
            var dto        = operationParameterModel.TypeReference.Element.AsDTOModel();

            foreach (var dtoField in dto.Fields)
            {
                var domainAttribute = domainModel.Attributes.FirstOrDefault(p => p.Name.Equals(dtoField.Name, StringComparison.OrdinalIgnoreCase));
                if (domainAttribute == null)
                {
                    statements.Add($"// Warning: No matching field found for {dtoField.Name}");
                    continue;
                }
                if (domainAttribute.Type.Element.Id != dtoField.TypeReference.Element.Id)
                {
                    statements.Add($"// Warning: No matching type for Domain: {domainAttribute.Name} and DTO: {dtoField.Name}");
                    continue;
                }
                statements.Add($"{domainModel.Name.ToCamelCase()}.set{domainAttribute.Name.ToPascalCase()}({operationParameterModel.Name}.get{dtoField.Name.ToPascalCase()}());");
            }

            return(statements);
        }
        private string EmitPropertyAssignments(ClassModel domainModel, string domainVarName, ParameterModel operationParameterModel)
        {
            var sb  = new StringBuilder();
            var dto = operationParameterModel.TypeReference.Element.AsDTOModel();

            foreach (var dtoField in dto.Fields)
            {
                var domainAttribute = domainModel.Attributes.FirstOrDefault(p => p.Name.Equals(dtoField.Name, StringComparison.OrdinalIgnoreCase));
                if (domainAttribute == null)
                {
                    sb.AppendLine($"        // Warning: No matching field found for {dtoField.Name}");
                    continue;
                }
                if (domainAttribute.Type.Element.Id != dtoField.TypeReference.Element.Id)
                {
                    sb.AppendLine($"        // Warning: No matching type for Domain: {domainAttribute.Name} and DTO: {dtoField.Name}");
                    continue;
                }
                sb.AppendLine($"        {domainVarName}.set{domainAttribute.Name.ToPascalCase()}({operationParameterModel.Name}.get{dtoField.Name.ToPascalCase()}());");
            }
            return(sb.ToString().Trim());
        }
Exemplo n.º 3
0
 public bool Equals(ParameterModel other)
 {
     return(Equals(_element, other?._element));
 }