/// <summary>
        /// 注册类型为动态结构的领域属性
        /// </summary>
        /// <typeparam name="TD"></typeparam>
        /// <typeparam name="OT"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        public static DomainProperty RegisterDynamic <TD, OT>(string name)
            where TD : TypeDefine
        {
            var ownerType = typeof(OT);
            var define    = TypeDefine.GetDefine <TD>();

            var propertyType = define.MetadataType;
            var result       = Register(name, propertyType, ownerType, (o, p) => { return(define.EmptyInstance); }, PropertyChangedMode.Definite, define.MetadataType);

            define.SetBelongProperty(result);
            return(result);
        }
        /// <summary>
        /// 动态类型的集合
        /// </summary>
        /// <typeparam name="TD"></typeparam>
        /// <typeparam name="OT"></typeparam>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        public static DomainProperty RegisterDynamicCollection <TD, OT>(string propertyName)
            where TD : TypeDefine
            where OT : DomainObject
        {
            var define      = TypeDefine.GetDefine <TD>();
            var elementType = define.MetadataType; //动态类型

            return(Register(propertyName, typeof(DomainCollection <dynamic>), typeof(OT), (owner, property) =>
            {
                var collection = new DomainCollection <dynamic>(property);
                collection.Parent = owner;
                return collection;
            }, PropertyChangedMode.Definite, elementType));
        }
Beispiel #3
0
        private void AddDefineIndex(string typeName, TypeDefine define)
        {
            TypeDefine exist = null;

            if (_defineIndex.TryGetValue(typeName, out exist))
            {
                if (exist.GetType() == define.GetType())
                {
                    return;
                }
                throw new DomainDrivenException(string.Format(Strings.DynamicTypeRepeated, typeName));
            }

            _defineIndex.TryAdd(typeName, define);
        }
Beispiel #4
0
        private void FillBy(TypeDefine target)
        {
            this.TypeName           = target.TypeName;
            this.MetadataSchemaCode = target.MetadataSchemaCode;
            this.MetadataCode       = target.MetadataCode;
            this.Metadata           = target.Metadata
            ;
            this.ObjectType   = target.ObjectType;
            this.Constructor  = target.Constructor;
            this.MetadataType = target.MetadataType;

            this.DomainInterfaceType = target.DomainInterfaceType;
            this.QualifiedName       = target.QualifiedName;
            this.RemoteType          = target.RemoteType;
            this.Properties          = target.Properties;
        }
Beispiel #5
0
        /// <summary>
        /// 在程序启动的时候分析所有远程类型的定义,记录信息
        /// </summary>
        public static void Initialize()
        {
            _types = new List <RemoteType>();
            var defineTypes = AssemblyUtil.GetTypesByAttribute <RemoteTypeAttribute>();

            foreach (var defineType in defineTypes)
            {
                if (TypeDefine.IsIgnore(defineType))
                {
                    continue;
                }
                var obj        = (TypeDefine)TypeDefine.Initialize(defineType);
                var remoteType = obj.RemoteType;
                _types.Add(remoteType);
            }
        }
Beispiel #6
0
 public DynamicValueObject(TypeDefine define, bool isEmpty)
     : base(define, isEmpty)
 {
     this.OnConstructed();
 }
Beispiel #7
0
 /// <summary>
 /// 是否忽略类型的定义(因为多个子系统都有同样的定义,那么只使用其中一个)
 /// </summary>
 /// <param name="typeName"></param>
 /// <param name="define"></param>
 /// <returns></returns>
 private static bool IsIgnore(TypeDefine define)
 {
     return(IsIgnore(define.GetType()));
 }
Beispiel #8
0
 public DynamicObject(TypeDefine define, bool isEmpty)
 {
     this.Define = define;
     _isEmpty    = isEmpty;
     this.OnConstructed();
 }
 public DynamicEntity(TypeDefine define, bool isEmpty)
     : base(define, isEmpty)
 {
     this.OnConstructed();
 }
 public RuntimeObjectType(string name, TypeDefine define)
     : base(name)
 {
     this.Define = define;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="typeFullName">远程类型的全称</param>
 /// <param name="define"></param>
 internal static void AddDefineIndex(string remoteTypeFullName, TypeDefine define)
 {
     _defineIndex.TryAdd(remoteTypeFullName, define, TypeDefineComparer.Instance);
 }