public static To MapTo <From, To>(this IDomainEntity <From> domainEntity, IMapper mapper) where From : Entity where To : new() { var to = new To(); domainEntity.With(entity => mapper.Map(entity, to)); return(to); }
private void UnsubscribeSelectedItem(IDomainEntity <T> newValue) { if (oldSelectedItem != null) { oldSelectedItem.PropertyChanged -= SelectedItem_PropertyChanged; } oldSelectedItem = newValue; }
private async Task TrySetCreationAuditsFor <TEntityPrimaryKey>(IDomainEntity entity) { if (!(entity is ICreationAudited <TEntityPrimaryKey, TUserKey> creationAuditedEntity)) { return; } var userId = await _loggedInUserIdProvider.GetUserLoggedInIdAsync(); creationAuditedEntity.CreationTime = DateTime.Now; creationAuditedEntity.CreatorUserId = userId; }
public IDomainEntity <T> GetDomainEntity <T>() where T : class { IDomainEntity <T> result = null; if (mapCreatorEntity.ContainsKey(typeof(T))) { result = mapCreatorEntity[typeof(T)]() as IDomainEntity <T>; } return(result); }
public IDomainEntity <T> GetDomainEntity <T>(T entity, long position) where T : class { IDomainEntity <T> result = null; if (mapEntity.ContainsKey(typeof(T))) { result = mapEntity[typeof(T)](entity, position) as IDomainEntity <T>; } return(result); }
public bool CanIndex(IDomainEntity entity) { var type = entity.GetType(); if (type.FullName.StartsWith("System.Data.Entity.DynamicProxies")) { type = type.BaseType; } return(_indexers.ContainsKey(type)); }
private async Task TrySetModificationAuditsFor <TEntityPrimaryKey>(IDomainEntity entity) { if (!(entity is IModificationAudited <TEntityPrimaryKey, TUserKey> modificationAuditedEntity)) { return; } var userId = await _loggedInUserIdProvider.GetUserLoggedInIdAsync(); modificationAuditedEntity.LastModificationTime = DateTime.Now; modificationAuditedEntity.LastModifierUserId = userId; }
/// <summary> /// The Dapper Repository as every other repository should receive a Domain Object to maintain the validity of the Domain, /// It will also call the IsValid Function on the DomainEntity /// </summary> /// <param name="DomainEntity">A Domain Entity should never be invalid</param> public void Update(IDomainEntity DomainEntity) { DomainEntity.Validate(); if (!DomainEntity.IsValid) { throw new EntityIsInvalidException(); } dynamic n = DomainEntity; db.Update(n); }
protected void SendBackMessage() { if (Messenger != null) { IDomainEntity <T> currentSelectedItem = SelectedItem; Model.ApplySearchCriteria(); if (currentSelectedItem != null && Entities.All(x => x.Id != currentSelectedItem.Id)) { Messenger?.Send(CommandName.ShowMismatchSearchCriteriaMessage, new EventArgs()); } GoToSearchControl(); } }
public async Task AuditDeletion <TEntityPrimaryKey>(IDomainEntity entity) { if (!(entity is IDeletionAudited <TEntityPrimaryKey, TUserKey> deletionAuditedEntity)) { return; } if (!deletionAuditedEntity.IsDeleted || deletionAuditedEntity.DeletionTime.HasValue) { return; } var userId = await _loggedInUserIdProvider.GetUserLoggedInIdAsync(); deletionAuditedEntity.DeletionTime = DateTime.Now; deletionAuditedEntity.DeleterUserId = userId; }
public async Task AuditDeletion(IDomainEntity entity, params Type[] keyTypes) { var method = GetType().GetMethods().FirstOrDefault(x => x.Name.Equals("AuditDeletion") && x.ContainsGenericParameters); if (method == null) { return; } var task = (Task)method.MakeGenericMethod(keyTypes).Invoke(this, new object[] { entity }); if (task == null) { return; } await task; }
public SearchResult GetSearchResult(IDomainEntity entity) { return(BuildSearchResult(entity as T)); }
public void IndexEntity(Type entityType, int id, bool recursive, Type contextType) { DateTime startTime = DateTime.Now; IDomainEntity entity = GetEntity(entityType, id); IEntityIndexer indexer = _registry.GetIndexer(entityType); if ((entity != null) && (indexer != null)) { EntityIndex index = _indexContext.GetEntityIndex(entityType.FullName, id); if (index != null) { _indexContext.DeleteEntityIndex(index); } else { index = new EntityIndex(); _indexContext.EntityIndexes.Add(index); } HashSet <SearchKeyword> keywords = ProcessKeywords(indexer.GetKeyWords(entity)); index.EntityTypeID = _indexContext.GetEntityTypeID(entityType.FullName); index.EntityKey = id; //if (entity is ISegregatedEntity) // index.DataAreaID = (entity as ISegregatedEntity).GetDataAreaID(); //else // index.DataAreaID = null; index.IndexTimeUTC = DateTime.Now.ToUniversalTime(); foreach (var kw in keywords) { EntityKeyword indexKW = new EntityKeyword(); if (kw.Keyword.Length < 50) { indexKW.Keyword = kw.Keyword; } else { indexKW.Keyword = kw.Keyword.Substring(0, 49); } if (kw.RefType != null) { indexKW.ReferenceEntityKey = kw.RefID; indexKW.ReferenceEntityTypeID = _indexContext.GetEntityTypeID(kw.RefType.FullName); } index.Keywords.Add(indexKW); } //index.IndexDuration = (DateTime.Now.TimeOfDay - startTime.TimeOfDay).Ticks; } if (recursive) { List <EntityIndex> relatedIndexes = _indexContext.GetRelatedIndexes(entityType.FullName, id); //Type.GetType(entityType.FullName, x => ) foreach (var idx in relatedIndexes) { Type relatedEntityType = _registry.LookupEntityType(idx.EntityType.Name); _indexQueue.QueueIndexWork(relatedEntityType, idx.EntityKey, false, contextType); } } }
public void Initialize(IDomainEntity compositeViewModel) { this._composite = compositeViewModel as ICommonDomainEntity; }
public IEnumerable <SearchKeyword> GetKeyWords(IDomainEntity entity) { return(BuildKeyWords(entity as T)); }
public ActivateMememberShip(IDomainEntity domainEntity) : base(domainEntity) { }
public static void MapFrom <From, To>(this IDomainEntity <To> domainEntity, From from, IMapper mapper) where To : Entity { domainEntity.With(entity => mapper.Map(from, entity)); }
/// <summary> /// /// </summary> /// <param name="eventSource">代表事件来源的领域实体</param> public DomainEvent(IDomainEntity eventSource) { this.eventSource = eventSource; }
public VideoPackingSlipRule(IDomainEntity domainEntity) : base(domainEntity) { }
public bool EntityEquals(IDomainEntity other) { return(this.BinaryEquals(other)); }
public BaseBusinessRule(IDomainEntity domainEntity) { _domainEntity = domainEntity; }
public $resource$Controller(IDomainEntity resource, I$resource$Repository repo)
public virtual void AddUpdatedEvent(IDomainEntity oldValue) { var type = typeof(EntityUpdated <>).MakeGenericType(GetType()); AddEntityEvent((EntityEvent)Activator.CreateInstance(type, this, oldValue)); }
public DuplicateSlipRule(IDomainEntity domainEntity) : base(domainEntity) { }
public void Delete(IDomainEntity DomainEntity) { dynamic n = DomainEntity; db.Delete(n); }
public async Task AuditModification <TEntityPrimaryKey>(IDomainEntity entity) { await TrySetModificationAuditsFor <TEntityPrimaryKey>(entity); }
public void AddToEntityTracker(IDomainEntity <TKey> internalEntity, IDomainEntity <TKey> externalEntity) { _entityTracker.Add(internalEntity, externalEntity); }
public MemberShipUpgrade(IDomainEntity domainEntity) : base(domainEntity) { }