public void AddProp(string name, int col) { if (parsers.ContainsKey(name)) { throw new PropertyException("Allready constains a property with that name"); } if (!Array.Exists(pi, p => p.Name == name)) { throw new PropertyException($"No such property found in {type.Name}"); } CsvBasicInfo bInfo = new CsvBasicInfo(type, name, col, separator); PropertyInfo pInfo = type.GetProperty(name); Type propType = pInfo.PropertyType; // prop Type PropertyWrapper pw; IReflection reflect; if (ReflectorsCache.cache.TryGetValue(propType, out reflect)) { // if reflect of type propType exists, get it from cache pw = new PropertyWrapper((PropertyReflect)reflect, bInfo); parsers.Add(name, pw); } else { //if not build a new onde, add to cache and create PropertyWrapper //and add it to parsers Dictionary PropertyReflect pr = new PropertyReflect(propType); ReflectorsCache.cache.Add(propType, pr); pw = new PropertyWrapper(pr, bInfo); parsers.Add(name, pw); } }
public PropertyWrapper(PropertyReflect pReflect, CsvBasicInfo csvInfo) { this.pReflect = pReflect; this.csvInfo = csvInfo; }