コード例 #1
0
        public static ServiceRegistration FromType(Type serviceInterfaceType, object service)
        {
            PublicServiceAttribute attribute = serviceInterfaceType.GetCustomAttribute <PublicServiceAttribute>();
            Type serviceProxyType            = attribute.ServiceProxyType;
            ServiceRegistration registration = new ServiceRegistration(serviceInterfaceType, serviceProxyType, service);

            return(registration);
        }
コード例 #2
0
        public static ServiceRegistration FromService(object service)
        {
            Type serviceInterfaceType = FindServiceInterfaceType(service.GetType());

            if (serviceInterfaceType == null)
            {
                throw new TempException(string.Format("Type {0} is not marked as service", service.GetType()));
            }
            PublicServiceAttribute attribute = serviceInterfaceType.GetCustomAttribute <PublicServiceAttribute>();
            Type serviceProxyType            = attribute.ServiceProxyType;
            ServiceRegistration registration = new ServiceRegistration(serviceInterfaceType, serviceProxyType, service);

            return(registration);
        }
コード例 #3
0
 public static Type FindServiceInterfaceType(Type serviceType)
 {
     if (serviceType.IsInterface)
     {
         PublicServiceAttribute attribute = serviceType.GetCustomAttribute <PublicServiceAttribute>();
         if (attribute != null)
         {
             return(serviceType);
         }
     }
     Type[] serviceInterfaceTypes = serviceType.GetInterfaces();
     foreach (Type serviceInterfaceType in serviceInterfaceTypes)
     {
         PublicServiceAttribute attribute = serviceInterfaceType.GetCustomAttribute <PublicServiceAttribute>();
         if (attribute != null)
         {
             return(serviceInterfaceType);
         }
     }
     return(null);
 }