public static DynamicPropertyName ToModel(this DynamicPropertyNameEntity entity) { var result = new DynamicPropertyName(); result.InjectFrom(entity); return(result); }
public static DynamicPropertyNameEntity ToEntity(this DynamicPropertyName model) { var result = new DynamicPropertyNameEntity(); result.InjectFrom(model); return(result); }
public virtual DynamicPropertyName ToModel(DynamicPropertyName propName) { if (propName == null) { throw new ArgumentNullException(nameof(propName)); } propName.Locale = Locale; propName.Name = Name; return(propName); }
public virtual DynamicPropertyNameEntity FromModel(DynamicPropertyName propName) { if (propName == null) { throw new ArgumentNullException(nameof(propName)); } Locale = propName.Locale; Name = propName.Name; return(this); }
protected override void ExecuteCommand() { if (!String.IsNullOrEmpty(OutputFolder) && !Directory.Exists(OutputFolder)) { throw new Exception($"there is no such a folder {OutputFolder}"); } this.Consume(ea => { try { var body = ea.Body; var message = Encoding.UTF8.GetString(body); dynamic uniqueId = String.Empty; dynamic entity = Newtonsoft.Json.JsonConvert.DeserializeObject <ExpandoObject>(message); if (entity != null) { try { if (!String.IsNullOrEmpty(DynamicPropertyName)) { foreach (var item in DynamicPropertyName.Split(".".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { entity = ((IDictionary <string, object>)entity)[item]; } uniqueId = entity; } } catch (Exception ex) { throw new Exception($"ReceivedMessage: {message}", ex); } } if (!String.IsNullOrEmpty(OutputFolder)) { //create file var fileName = string.Format(OutputFileNameFormat, uniqueId); var filePath = Path.Combine(OutputFolder, fileName); FileManager.CreateFileWithData(filePath, message); } Notification.Notify($"Done:{DynamicPropertyName}:{uniqueId}"); if (ShowHeaders) { foreach (var item in ea.BasicProperties.Headers) { String value = item.Value?.ToString(); if (item.Value?.GetType() == typeof(byte[])) { value = Encoding.UTF8.GetString((byte[])item.Value); } Notification.Notify($"{item.Key} : {value}"); } } } catch (Exception ex) { Notification.Notify(ex, NotifyTo.CONSOLE); } }); }