public Laborer(string Name, IDeputy Method) : this() { Work = Method; LaborerName = Name; SystemCode = new Usid(($"{Work.KeyBlock}.{DateTime.Now.ToBinary()}").GetHashKey()); }
/// <summary> /// Initializes a new instance of the <see cref="NoteEvoker"/> class. /// </summary> /// <param name="sender">The sender<see cref="Labor"/>.</param> /// <param name="recipient">The recipient<see cref="Labor"/>.</param> /// <param name="relayLabors">The relayLabors<see cref="List{Labor}"/>.</param> public NoteEvoker(Labor sender, Labor recipient, List <Labor> relayLabors) { Sender = sender; SenderName = sender.Laborer.LaborerName; Recipient = recipient; RecipientName = recipient.Laborer.LaborerName; SerialCode = new Usid(($"{SenderName}.{RecipientName}").UniqueKey()); RelationLabors = relayLabors; RelationNames.AddRange(RelationLabors.Select(rn => rn.Laborer.LaborerName)); }
public NoteEvoker(Labor sender, string recipientName, IList<string> relayNames) { Sender = sender; SenderName = sender.Laborer.LaborerName; List<Labor> objvl = Sender.Scope.Subjects.AsCards().Where(m => m.Value.Labors.ContainsKey(recipientName)).SelectMany(os => os.Value.Labors.AsCards().Select(o => o.Value)).ToList(); if (objvl.Any()) Recipient = objvl.First(); RecipientName = recipientName; SystemCode = new Usid(($"{SenderName}.{RecipientName}").GetHashKey()); RelationNames = new List<string>(relayNames); RelationLabors = Sender.Scope.Subjects.AsCards().Where(m => m.Value.Labors.AsIdentifiers().Where(k => relayNames.Select(rn => rn.GetHashKey()).Contains(k.KeyBlock)).Any()).SelectMany(os => os.Value.Labors.AsCards().Select(o => o.Value)).ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="NoteEvoker"/> class. /// </summary> /// <param name="sender">The sender<see cref="Labor"/>.</param> /// <param name="recipient">The recipient<see cref="Labor"/>.</param> /// <param name="relayNames">The relayNames<see cref="List{string}"/>.</param> public NoteEvoker(Labor sender, Labor recipient, List <string> relayNames) { Sender = sender; SenderName = sender.Laborer.LaborerName; Recipient = recipient; RecipientName = recipient.Laborer.LaborerName; SerialCode = new Usid(($"{SenderName}.{RecipientName}").UniqueKey()); RelationNames = relayNames; RelationLabors = Sender.Scope.Subjects.AsCards() .Where(m => m.Value.Labors.AsIdentifiers() .Where(k => relayNames .Select(rn => rn.UniqueKey()).Contains(k.UniqueKey)).Any()) .SelectMany(os => os.Value.Labors.AsCards() .Select(o => o.Value)).ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="NoteEvoker"/> class. /// </summary> /// <param name="sender">The sender<see cref="Labor"/>.</param> /// <param name="recipientName">The recipientName<see cref="string"/>.</param> /// <param name="relayLabors">The relayLabors<see cref="IList{Labor}"/>.</param> public NoteEvoker(Labor sender, string recipientName, IList <Labor> relayLabors) { Sender = sender; SenderName = sender.Laborer.LaborerName; RecipientName = recipientName; SerialCode = new Usid(($"{SenderName}.{RecipientName}").UniqueKey()); List <Labor> objvl = Sender.Scope.Subjects.AsCards() .Where(m => m.Value.Labors.ContainsKey(recipientName)) .SelectMany(os => os.Value.Labors.AsCards().Select(o => o.Value)).ToList(); if (objvl.Any()) { Recipient = objvl.First(); } RelationLabors = new List <Labor>(relayLabors); RelationNames.AddRange(RelationLabors.Select(rn => rn.Laborer.LaborerName)); }
public static void DeserializeType(IEnumerable <PropertyInfo> map, IDictionary <string, object> bag, object instance) { System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; foreach (PropertyInfo info in map) { bool mutated = false; string key = info.Name; if (!bag.ContainsKey(key)) { key = info.Name.Replace("_", ""); if (!bag.ContainsKey(key)) { key = info.Name.Replace("-", ""); if (!bag.ContainsKey(key)) { continue; } } } object value = bag[key]; if (value != null && value.GetType() == typeof(String)) { if (value.Equals("null")) { value = null; } } if (value != null) { if (info.PropertyType == typeof(byte[])) { if (value.GetType() == typeof(List <object>)) { value = ((List <object>)value).Select(symbol => Convert.ToByte(symbol)).ToArray(); } else { value = ((object[])value).Select(symbol => Convert.ToByte(symbol)).ToArray(); } } else if (info.PropertyType == typeof(Usid)) { value = new Usid(value.ToString()); } else if (info.PropertyType == typeof(Single)) { value = Convert.ToSingle(value, nfi); } else if (info.PropertyType == typeof(DateTime)) { value = Convert.ToDateTime(value); } else if (info.PropertyType == typeof(double)) { value = Convert.ToDouble(value, nfi); } else if (info.PropertyType == typeof(decimal)) { value = Convert.ToDecimal(value, nfi); } else if (info.PropertyType == typeof(int)) { value = Convert.ToInt32(value); } else if (info.PropertyType == typeof(long)) { value = Convert.ToInt64(value); } else if (info.PropertyType == typeof(short)) { value = Convert.ToInt16(value); } else if (info.PropertyType == typeof(bool)) { value = Convert.ToBoolean(value); } else if (info.PropertyType == typeof(IFigure)) { object n = info.GetValue(instance, null); DeserializeType(n.GetType().GetProperties(), (Dictionary <string, object>)value, n); mutated = true; } else if (info.PropertyType == typeof(DealContext)) { object inst = new object(); Dictionary <string, object> subbag = (Dictionary <string, object>)value; IEnumerable <PropertyInfo> submap = PrepareInstance(out inst, typeof(DealContext)); DeserializeType(submap, subbag, inst); info.SetValue(instance, inst, null); mutated = true; } else if (info.PropertyType == typeof(MemberIdentity)) { object inst = new object(); Dictionary <string, object> subbag = (Dictionary <string, object>)value; IEnumerable <PropertyInfo> submap = PrepareInstance(out inst, typeof(MemberIdentity)); DeserializeType(submap, subbag, inst); info.SetValue(instance, inst, null); mutated = true; } else if (info.PropertyType == typeof(Type)) { object typevalue = info.GetValue(instance, null); if (value != null) { typevalue = Type.GetType(value.ToString()); } value = typevalue; } else if (info.PropertyType.IsEnum) { object enumvalue = info.GetValue(instance, null); enumvalue = Enum.Parse(info.PropertyType, value.ToString()); value = enumvalue; } } if (!mutated) { info.SetValue(instance, value, null); } } }