Beispiel #1
0
        private void ExtractFromProperty(PropertyInfo propInfo, TypeExtraction typExtracted)
        {
            FieldExtraction fextraction = new FieldExtraction()
            {
                Name     = $"_{propInfo.Name}",
                TypeName = propInfo.PropertyType.ToString()
            };

            typExtracted.Fields.Add(fextraction);

            PropertyExtraction pextraction = new PropertyExtraction()
            {
                Name     = propInfo.Name,
                TypeName = propInfo.PropertyType.ToString(),
                HasGet   = propInfo.CanRead,
                HasSet   = propInfo.CanWrite
            };

            typExtracted.Properties.Add(pextraction);
        }
 protected virtual void FormatProperty(StringBuilder sb, PropertyExtraction propField)
 {
     sb.AppendLine($"\t\tpublic {propField.TypeName} {propField.Name}");
     sb.AppendLine("\t\t{");
     if (propField.HasGet)
     {
         sb.AppendLine("\t\t\tget");
         sb.AppendLine("\t\t\t{");
         sb.AppendLine($"\t\t\t\t{ProxyBeforeExecution(propField, true)}");
         sb.AppendLine($"\t\t\t\treturn _{propField.Name};");
         sb.AppendLine($"\t\t\t\t{ProxyAfterExecution(propField, true)}");
         sb.AppendLine("\t\t\t}");
     }
     if (propField.HasSet)
     {
         sb.AppendLine("\t\t\tset");
         sb.AppendLine("\t\t\t{");
         sb.AppendLine($"\t\t\t\t{ProxyBeforeExecution(propField, false)}");
         sb.AppendLine($"\t\t\t\treturn _{propField.Name};");
         sb.AppendLine($"\t\t\t\t{ProxyAfterExecution(propField, false)}");
         sb.AppendLine("\t\t\t}");
     }
     sb.AppendLine("\t\t}\n");
 }
 public abstract string ProxyAfterExecution(PropertyExtraction propField, bool isGet);
 public override string ProxyBeforeExecution(PropertyExtraction propField, bool isGet)
 {
     return(string.Empty);
 }