示例#1
0
        public static void RegisterDecorator <TServiceType>(IServiceDecorator <TServiceType> decorator) where TServiceType : class, IService
        {
            if (decorator == null)
            {
                throw new System.ArgumentNullException("decorator");
            }
            if (!(decorator is TServiceType))
            {
                throw new System.ArgumentException(string.Format("Decorator must implement the service type it is decorating: {0}.", typeof(TServiceType).Name));
            }

            var inst = Services.Get <TServiceType>();

            if (inst == null)
            {
                throw new System.InvalidOperationException(string.Format("Must create a concreate service of type {0} before decorating it.", typeof(TServiceType).Name));
            }

            Entry <TServiceType> .Instance = decorator as TServiceType;
            ReplaceReferences(inst, decorator);

            decorator.Consume(inst);
        }
示例#2
0
 public static void AddDefaultFilters(IServiceDecorator serviceDecorator)
 {
     serviceDecorator.AddFilter <NetworkConnectionServiceFilter>();
 }
示例#3
0
 public ContactService(IConnectionService connectionService, IServiceDecorator serviceDecorator) : base(connectionService, serviceDecorator)
 {
     _contactService = RestService.For <IContact>(ConnectionService._lazyHttpClient.Value, new RefitSettings(new NewtonsoftJsonContentSerializer()));
 }
示例#4
0
 protected BaseService(IConnectionService connectionService, IServiceDecorator serviceDecorator)
 {
     ConnectionService = connectionService;
     ServiceDecorator  = serviceDecorator;
 }