Exemple #1
0
        private DomainObject ConstructObject(Type objectType, DynamicData data)
        {
            var constructorTip = ConstructorRepositoryAttribute.GetTip(objectType);
            var constructor    = constructorTip.Constructor;
            var args           = CreateArguments(constructorTip, data);

            return((DomainObject)constructor.CreateInstance(args));
        }
Exemple #2
0
        private DomainObject ConstructDynamicObject(Type objectType, TypeDefine define)
        {
            var constructor = ConstructorRepositoryAttribute.GetDynamicConstructor(objectType);

            using (var temp = ArgsPool.Borrow2())
            {
                var args = temp.Item;
                args[0] = define;
                args[1] = false; //不为空 empty参数
                return((DomainObject)constructor.CreateInstance(args));
            }
        }
Exemple #3
0
        private object[] CreateArguments(ConstructorRepositoryAttribute tips, DynamicData data)
        {
            var length = tips.Parameters.Count();

            if (length == 0)
            {
                return(Array.Empty <object>());
            }
            object[] args = new object[length];
            foreach (var prm in tips.Parameters)
            {
                var arg = CreateArgument(prm, data);
                args[prm.Index] = arg;
            }
            return(args);
        }