private void Initialize(IPEndPoint endpoint, string group) { items = new SortedDictionary <string, IDataItemClient>(new CaseInsensitiveStringComparer()); // load the config Type diGenType = typeof(DataItemClient <>); Type mapFieldsGenericType = typeof(MapFieldsDataItemClient <>); DatasetXmlParser.ParseConfig(delegate(DataItemDescriptor desc, string specialType, List <KeyValuePair <string, string> > attributes) { if (specialType == "mapfields") { Type mapFieldsType = mapFieldsGenericType.MakeGenericType(desc.DataType); Add(desc.Name, (IDataItemClient)Activator.CreateInstance(mapFieldsType, desc, this)); } else { // general case Type diType = diGenType.MakeGenericType(desc.DataType); Add(desc.Name, (IDataItemClient)Activator.CreateInstance(diType, desc)); } }, group); // initialize the listener object InitializeListener(endpoint); }
private void InitItems(string group) { items = new Dictionary <string, IDataItemSource>(new CaseInsensitiveStringComparer()); Type diGenType = typeof(DataItemSource <>); DatasetXmlParser.ParseConfig(delegate(DataItemDescriptor ds, string specialType, List <KeyValuePair <string, string> > attributes) { if (specialType == "runrate") { RunRateDataItemSource runRate = new RunRateDataItemSource(ds, attributes); Add(ds.Name, runRate); } else { Type diType = diGenType.MakeGenericType(ds.DataType); object dataItem = Activator.CreateInstance(diType, ds); Add(ds.Name, (IDataItemSource)dataItem); } }, group); }