Exemplo n.º 1
0
        public RegistCheckResult Check(Ctrip.SOA.Infratructure.IOCFactoryModel.RegistObjectContext context)
        {
            var returnValue = new RegistCheckResult();
            returnValue.IsPass = false;

            var objType = context.ObjType;

            ConstructorInfo[] constructs = objType.GetConstructors();
            if (constructs.Length != 1)
            {
                returnValue.Message = string.Format("regist as DI Inst must and only have 1 construct method");
                return returnValue;
            }

            var construct = constructs[0];

            var pArray = construct.GetParameters();

            foreach (var p in pArray)
            {
                if (!p.ParameterType.IsInterface)
                {
                    returnValue.Message = string.Format("regsit as DI Inst the construct method's paramters must be interface type");
                    return returnValue;
                }
            }
            return true;
        }
        public void Test()
        {
            Booking booking = new Ctrip();
            Booking railway = new RailwayStation();

            Assert.Equal(railway.BuyTicket(), booking.BuyTicket());
        }
Exemplo n.º 3
0
 public object CreateInst(Ctrip.SOA.Infratructure.IOCFactoryModel.RegistObjectContext context, params object[] param)
 {
     if (context.Obj == null)
     {
         lock (context)
         {
             var diCreator = InstCreatorFactory.Create(Ctrip.SOA.Infratructure.IOCFactoryModel.InstType.DI);
             context.Obj = diCreator.CreateInst(context, param);
         }
     }
     return context.Obj;
 }
Exemplo n.º 4
0
 public Ctrip.SOA.Infratructure.IOCFactoryModel.RegistCheckResult Check(Ctrip.SOA.Infratructure.IOCFactoryModel.RegistObjectContext context)
 {
     var diCreator = InstCreatorFactory.Create(Ctrip.SOA.Infratructure.IOCFactoryModel.InstType.DI);
     return diCreator.Check(context);
 }