public IFieldProcessor GetTicketFieldProcessor(RtTicket ticket, string ticketFieldName) { IFieldProcessor fieldProcessor = null; var m = RtCustomField.CustomFieldNameRegex.Matches(ticketFieldName); if (m.Count > 0) { var match = m[0]; var groupCollection = match.Groups; fieldProcessor = _customFieldProcessors[groupCollection[1].ToString()] ?? DefaultCustomFieldProcessor.Instance; } else { if (_standardFieldProcessors.ContainsKey(ticketFieldName)) fieldProcessor = _standardFieldProcessors[ticketFieldName]; if (fieldProcessor != null) return fieldProcessor; try { var p = typeof(RtTicket).GetProperty(ticketFieldName.UppercaseFirst()); var t = p.PropertyType; fieldProcessor = _typeFieldProcessors[t]; } catch (Exception ex) { Console.WriteLine("Exception while processing property '{0}'", ticketFieldName.UppercaseFirst()); } } return fieldProcessor ?? DefaultFieldProcessor.Instance; }
private static RtTicket ProcessTicketData(IDictionary<string, string> ticketData) { var ticket = new RtTicket(); foreach (var e in ticketData) { var fieldProcessor = FieldProcessorRegistry.Instance.GetTicketFieldProcessor(ticket, e.Key); fieldProcessor.Process(ticket, e.Key, e.Value); } return ticket; }