コード例 #1
0
        private static ThriftServiceContainer MustThriftServiceContainer(IServiceContainer container)
        {
            ThriftServiceContainer realContainer = container as ThriftServiceContainer;

            if (realContainer == null)
            {
                throw new NullReferenceException("非ThriftServiceContainer继承类无法使用该扩展方法");
            }

            return(realContainer);
        }
コード例 #2
0
        public virtual void RegisterServices(IEnumerable <Service> services)
        {
            _services = new HashSet <ThriftService>(services.Cast <ThriftService>());
            ThriftServiceContainer thriftContainer = GlobalSetting.Container as ThriftServiceContainer;

            if (thriftContainer == null)
            {
                throw new NullReferenceException("IServiceContainer接口无法转换成ThriftServiceContainer");
            }
            foreach (ThriftService servic in _services)
            {
                thriftContainer.Add(servic.ServiceInterfaceType, type => Create(type));
            }
        }