示例#1
0
 public SerializationConfig AddClassDefinition(IClassDefinition classDefinition)
 {
     if (ClassDefinitions.Contains(classDefinition))
     {
         throw new ArgumentException("IClassDefinition for class-id[" + classDefinition.GetClassId() +
                                     "] already exists!");
     }
     ClassDefinitions.Add(classDefinition);
     return(this);
 }
示例#2
0
        /// <summary>
        /// create the class that file helpers uses to read the full file.
        /// </summary>
        public async Task CreateClasStructureForFileHelpers()
        {
            foreach (SourceFileConfiguration file in sourceFiles)
            {
                fileInformation.Add(file.File_UID, await LoadFileDefinition(file.File_UID));
                //Build class for file helpers for current file
                StringBuilder clsdefintion = new StringBuilder();
                clsdefintion.AppendLine(" ");
                clsdefintion.Append("[");
                switch (file.Format)
                {
                case "CSV":
                    clsdefintion.Append(@"DelimitedRecord("",""),IgnoreFirst(");
                    break;

                default:
                    break;
                }
                clsdefintion.Append(file.HeaderRowCount);
                clsdefintion.Append("), IgnoreLast(");
                clsdefintion.Append(file.FooterRowCount);
                clsdefintion.Append("), IgnoreEmptyLines");
                clsdefintion.Append("]");
                clsdefintion.AppendLine("");
                clsdefintion.AppendLine("public class  " + file.Name + "{");
                int count = 0;
                foreach (SourceFileDefinition item in fileInformation[file.File_UID])
                {
                    clsdefintion.AppendLine("");
                    string colname;
                    if (item.pii == true)
                    {
                        colname = "pcrtoken" + count.ToString();
                    }
                    else
                    {
                        colname = item.ColumnName;
                    };
                    clsdefintion.AppendLine("[FieldQuoted('\"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]");
                    clsdefintion.AppendLine($"public {item.datatype} {colname};");
                    count++;
                }
                clsdefintion.AppendLine("");
                clsdefintion.AppendLine("");
                clsdefintion.AppendLine("");
                clsdefintion.Append(" }");

                ClassDefinitions.Add(file.Name, clsdefintion.ToString());
            }
        }