I am trying to figure out the easiest method to create/convert multiple classes and have them created under the proper sub-classes.
Below is the code for my Event Class
public class Event
{
public Dictionary<string, string> dictionary = new Dictionary<string, string>();
public Event(string[] headers, string[] values)
{
if (headers.Length != values.Length)
throw new Exception("Length of headers does not match length of values");
for (int i = 0; i < values.Length; i++)
dictionary.Add(headers[i], values[i]);
}
public override string ToString()
{
return dictionary.ToString();
}
public string getTimeStamp()
{
return DateTime.Parse(dictionary["event_ts"]).ToLocalTime().ToString();
}
public string getKey()
{
return dictionary["hbase_key"];
}
public string getEventType()
{
return dictionary["event_type"];
}
}
Beyond that, I am going to have multiple classes that are extensions of the Event Class that define more methods for different types of Events. However, I need an easy way based off the EventType to create the proper class. For example if event_type = testEvent I will need to use my TestEvent class. Is there some sort of method I can put in Event that will parse the event_type and figure out which class it should create.
All the information I am getting is from parsing a CSV File with the headers as the first line and the values is the specific row's values.