public override bool TrySetMember(SetMemberBinder binder, object value) { var key = binder.Name.Convert <TKey>(); if (value is TEntity entity) { _dictionary.Remove(key); _dictionary.Add(key, entity); return(true); } else { var maybeEntity = _dictionary.Get(key); if (maybeEntity == null) { _dictionary.Add(key, (TEntity)Entity.Create(typeof(IEntitySubject <>).MakeGenericType(value.GetType()), value)); return(true); } else if (maybeEntity is IEntitySubject <object> entityValue) { entityValue.OnNext(value); return(true); } } return(false); }
/// <summary></summary> public void Add(string entityName, IEntity entity) { if (_entities.ContainsKey(entityName)) { _entities.Remove(entityName); } _entities.Add(entityName, entity); }