Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Filters {
- public int var1 = 1,
- var2 = 2,
- var3 = 3;
- }
- Filters filter1 = new Filters();
- foreach (var prop in filter1.props) {
- Console.WriteLine(filter1[prop] + 3);
- }
- 4
- 5
- 6
- public class Filters
- {
- public int var1 { get; set; } = 1;
- public int var2 { get; set; } = 2;
- public int var3 { get; set; } = 3;
- }
- static void Main(string[] args)
- {
- Filters filter1 = new Filters();
- foreach (var prop in filter1.GetType().GetProperties())
- {
- Console.WriteLine("{0}={1}", prop.Name, (int)prop.GetValue(filter1, null) + filter1.GetType().GetProperties().Length);
- }
- Console.ReadKey();
- }
- 4
- 5
- 6
- public class Filter
- {
- public IDictionary<string, object> Properties { get; } = new Dictionary<string, object>();
- }
- public class Filter
- {
- public int Var1 { get; set; } = 1;
- public int Var2 { get; set; } = 2;
- public int Var3 { get; set; } = 3;
- }
- var filter = new Filter();
- var filterType = filter.GetType();
- var readableProperties = filterType.GetProperties().Where( p => p.GetGetMethod() != null );
- foreach (var property in readableProperties)
- {
- var value = (int)property.GetValue( filter );
- Console.WriteLine( $"{property.Name} = {value + 3}" );
- }
- FieldInfo[] fields = typeof(GeneralFilters).GetFields();
- for (int i = 0; i < fields.Length; i++)
- {
- //MANIPULATE HERE
- BlankTemplate tempFilter = (BlankTemplate)fields[i].GetValue(filters);
- // Ignore this for now. tempFilter.selectedItems;
- }
- public class BlankTemplate
- {
- public string[] selectedItems;
- public bool selectAll = false;
- }
- var fieldNames = Object.keys(filterObject);
- for (var i = 0; i < fieldNames.length; i++) {
- doSomething( filterObject[fieldNames[i]] );
- }
Add Comment
Please, Sign In to add comment