public void OnProvidersExecuting(DomainObjectModelContext context) { var allTypes = context.DomainLayerAssembly.SelectMany(s => s.GetTypes().Where(type => TypeHelper.IsConcrete(type))); foreach (var findType in allTypes) { if (!DomainTypeHelper.IsDomainObject(findType)) { continue; } var entityDes = GetEntityDescriptor(findType); var aggregateRootDes = GetAggregateRootDescriptor(findType); var valueObjectDes = GetValueObjectDescriptor(findType); if (entityDes != null) { context.Result.Entities.Add(entityDes); } if (aggregateRootDes != null) { context.Result.AggregateRoots.Add(aggregateRootDes); } if (valueObjectDes != null) { context.Result.VauleObjects.Add(valueObjectDes); } } }
private void ValidateCodeExists(Code value, string domainType, VersionNumber version, bool isCda, string propertyPath, Hl7Errors errors) { Type returnType = null; if (StringUtils.IsNotBlank(domainType)) { returnType = (Type)DomainTypeHelper.GetReturnType(domainType, version, CodeTypeRegistry.GetInstance()); } if (returnType == null) { // for CDA usage, domainType not always supplied if (!isCda) { errors.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Could not locate a registered domain type to match \"" + domainType + "\"", propertyPath)); } } else { if (GetCode(returnType, value.CodeValue, value.CodeSystem) == null) { errors.AddHl7Error(CreateCodeValueNotFoundError(value, returnType, propertyPath)); } } }
private VauleObjectDescriptor GetValueObjectDescriptor(Type type) { if (!DomainTypeHelper.IsValueObject(type)) { return(null); } return(new VauleObjectDescriptor(type)); }
private EntityDescriptor GetEntityDescriptor(Type type) { if (!DomainTypeHelper.IsEntity(type)) { return(null); } return(new EntityDescriptor(type)); }
internal static object GetFixedValue(Relationship relationship, VersionNumber version, bool isR2, Hl7Errors errors, string propertyPath) { string fixedValue = relationship.FixedValue; if (StringUtils.Equals("BL", relationship.Type)) { return(true.ToString().EqualsIgnoreCase(fixedValue)); } else { if (StringUtils.Equals("INT.POS", relationship.Type)) { return(System.Convert.ToInt32(fixedValue)); } else { if (StringUtils.Equals("ST", relationship.Type)) { return(fixedValue); } else { if (relationship.CodedType) { Type codeType = DomainTypeHelper.GetReturnType(relationship, version, CodeTypeRegistry.GetInstance()); if (codeType == null) { codeType = typeof(Code); } Code code = CodeResolverRegistry.Lookup(codeType, fixedValue); if (code == null) { string message = System.String.Format("Fixed code lookup could not find match for {0}.{1}", relationship.DomainType, fixedValue ); errors.AddHl7Error(new Hl7Error(Hl7ErrorCode.VALUE_NOT_IN_CODE_SYSTEM, ErrorLevel.WARNING, message, propertyPath)); } //Fixup for .NET if (isR2) { return(code == null ? null : new CodedTypeR2 <Code>(code)); } else { return(code); } } else { throw new MarshallingException("Cannot handle a fixed relationship of type: " + relationship.Type); } } } } }
private AggregateRootDescriptor GetAggregateRootDescriptor(Type type) { if (!DomainTypeHelper.IsAggregateRoot(type)) { return(null); } var result = new AggregateRootDescriptor(type); return(result); }
private object ResolveCodeValue(Relationship relationship, string attributeValue, VersionNumber version, bool isR2) { Type returnType = (Type)DomainTypeHelper.GetReturnType(relationship, version, CodeTypeRegistry.GetInstance()); Code codeLookup = CodeResolverRegistry.Lookup(returnType, attributeValue); object result = codeLookup; if (isR2) { result = CodedTypeR2Helper.ConvertCodedTypeR2(new CodedTypeR2 <Code>(codeLookup), returnType); } return(result); }
/// <summary> /// Add customer repository. /// </summary> /// <param name="serviceType">Interface type of repository</param> /// <param name="implementationType">Implementation type of repository</param> public static void RegisterRepository(this ModuleConfigServiceContext context, Type serviceType, Type implementationType) { if (!DomainTypeHelper.IsRepository(serviceType)) { throw new ArgumentException($"{serviceType.FullName} is not a {nameof(IRepository)},Please give a right type!"); } if (!DomainTypeHelper.IsRepository(implementationType)) { throw new ArgumentException($"{implementationType.FullName} is not a {nameof(IRepository)},Please give a right type!"); } var services = context.Services; services.AddTransient(serviceType, implementationType); }
public virtual void Execute(object needAuditEntity, RepositoryEntityState entityState) { //Only deal with micake domain object. var entityType = needAuditEntity.GetType(); if (!typeof(IPersistentObject).IsAssignableFrom(entityType) && !DomainTypeHelper.IsDomainObject(entityType)) { return; } var model = new AuditObjectModel(needAuditEntity, entityState); foreach (var auditProvider in _providers) { auditProvider.ApplyAudit(model); } }
/// <summary> /// Add customer <see cref="IDomainService"/> /// </summary> /// <param name="context"></param> /// <param name="serviceType">Interface type of domain service</param> /// <param name="implementationType">ImplementationType type of domain service</param> /// <param name="miCakeServiceLifeTime"><see cref="MiCakeServiceLifetime"/></param> public static void RegisterDomainService( this ModuleConfigServiceContext context, Type serviceType, Type implementationType, MiCakeServiceLifetime miCakeServiceLifeTime = MiCakeServiceLifetime.Transient) { if (!DomainTypeHelper.IsDomainService(serviceType)) { throw new ArgumentException($"{serviceType.FullName} is not a domain service,Please give a right type!"); } if (!DomainTypeHelper.IsRepository(implementationType)) { throw new ArgumentException($"{implementationType.FullName} is not a domain service,Please give a right type!"); } var serviceDescpritor = new ServiceDescriptor(serviceType, implementationType, miCakeServiceLifeTime.ConvertToMSLifetime()); context.Services.TryAdd(serviceDescpritor); }
private AggregateRootDescriptor GetAggregateRootDescriptor(Type type, List <Type> persistentTypes) { if (!DomainTypeHelper.IsAggregateRoot(type)) { return(null); } var result = new AggregateRootDescriptor(type); //get persistent object. var currentPersistentType = persistentTypes.FirstOrDefault(s => TypeHelper.GetGenericArguments(s, typeof(IPersistentObject <,>))?[1] == type); if (currentPersistentType != null) { result.SetPersistentObject(currentPersistentType); } return(result); }
private Assembly[] GetDomianLayer(IMiCakeModuleCollection miCakeModules) { return(miCakeModules.GetAssemblies(false).Where(asm => asm.GetTypes().AsEnumerable().Any(inModuleType => DomainTypeHelper.IsDomainObject(inModuleType))).ToArray()); }
public virtual System.Type GetExpectedReturnType() { return(DomainTypeHelper.GetReturnType(this.relationship, this.version, this.codeTypeHandler)); }
public Type GetTypeAsClass(String version) { return(DomainTypeHelper.GetReturnType(this.type, version, CodeTypeRegistry.GetInstance())); }