private int GetFieldsMapping(string firstLine, IEnumerable <PropertyInfo> infos, IDictionary <int, PropertyInfo> mappedProperties)
        {
            var fields = firstLine.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < fields.Length; i++)
            {
                var field = fields[i];
                //Find apropriate field in UserInfo
                foreach (var info in infos)
                {
                    var propertyField = field.Trim();
                    if (NameMapping != null && NameMapping.ContainsKey(propertyField))
                    {
                        propertyField = NameMapping[propertyField];
                    }
                    if (!string.IsNullOrEmpty(propertyField) && !ExcludeList.Contains(propertyField) && propertyField.Equals(info.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        //Add to map
                        mappedProperties.Add(i, info);
                    }
                }
                if (!mappedProperties.ContainsKey(i))
                {
                    //No property was found
                    mappedProperties.Add(i, null);
                }
            }
            return(fields.Length);
        }
Example #2
0
        private int GetFieldsMapping(string firstLine, IEnumerable <PropertyInfo> infos, IDictionary <int, PropertyInfo> mappedProperties)
        {
            var fields = firstLine.Split(new string[] { Separators }, StringSplitOptions.RemoveEmptyEntries);

            for (var i = 0; i < fields.Length; i++)
            {
                var field = fields[i];
                foreach (var info in infos)
                {
                    var propertyField = field.Trim();
                    propertyField = propertyField.Trim(Convert.ToChar(TextDelmiter));
                    var title = info.GetCustomAttribute <ResourceAttribute>().Title;

                    if (NameMapping != null && NameMapping.ContainsKey(propertyField))
                    {
                        propertyField = NameMapping[propertyField];
                    }

                    propertyField.Replace(" ", "");

                    if (!string.IsNullOrEmpty(propertyField) &&
                        !ExcludeList.Contains(propertyField) &&
                        (propertyField.Equals(PeopleResource.ResourceManager.GetString(title), StringComparison.OrdinalIgnoreCase) ||
                         propertyField.Equals(info.Name, StringComparison.OrdinalIgnoreCase)))
                    {
                        mappedProperties.Add(i, info);
                    }
                }

                if (!mappedProperties.ContainsKey(i))
                {
                    mappedProperties.Add(i, null);
                }
            }

            return(fields.Length);
        }
 private Boolean NotInExcludeList(String folder)
 => (ExcludeList.Contains(folder) == false);