Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DatabaseUploadCollectionParameters
- {
- public String Server { get; set; }
- public String Database { get; set; }
- public String UserID { get; set; }
- public String Password { get; set; }
- public List<SearchField> SearchFields { get; set; }
- public List<FieldCollection> FieldCollections { get; set; }
- public DatabaseUploadCollectionParameters(String server, String database, String userID, String password)
- {
- Server = server;
- Database = database;
- UserID = userID;
- Password = password;
- SearchFields = new List<SearchField>();
- FieldCollections = new List<FieldCollection>();
- }
- public void AddTerm(SearchField searchTerm)
- {
- SearchFields.Add(searchTerm);
- }
- public void AddTerms(List<SearchField> searchTerms)
- {
- SearchFields.AddRange(searchTerms);
- }
- public void AddCollection(String name, List<object> fieldCollections)
- {
- if (fieldCollections != null)
- {
- List<FieldCollection> Collections = getFieldCollection(fieldCollections);
- foreach (FieldCollection FC in Collections)
- {
- FC.Name = name;
- }
- FieldCollections.AddRange(Collections);
- }
- }
- public static List<FieldCollection> getFieldCollection(List<Object> ClassItems)
- {
- List<FieldCollection> objectInstances = new List<FieldCollection>();
- foreach (Object ClassItem in ClassItems)
- {
- String ClassName = ClassItem.GetType().Name;
- List<Field> ObjectFields = new List<Field>();
- var Properties = ClassItem.GetType().GetProperties();
- foreach (PropertyInfo FI in Properties)
- {
- String Name = FI.Name;
- String Type = FI.PropertyType.Name.ToString();
- String Value = null;
- if (FI.GetValue(ClassItem, null) != null)
- Value = FI.GetValue(ClassItem, null).ToString();
- ObjectFields.Add(new Field(Name, Type, Value));
- }
- objectInstances.Add(new FieldCollection(ClassName, ObjectFields));
- }
- return objectInstances;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement