Пример #1
0
 public static void FindEvents(IMutableServiceDefinition serviceDefinition)
 {
     if (serviceDefinition.Implementation != null)
     {
         foreach (var eventInfo in serviceDefinition.Implementation.GetEvents(
                      BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
         {
             if (serviceDefinition.FindEvent(eventInfo.Name) == null && eventInfo.IsEventCandidate())
             {
                 serviceDefinition.GetEvent(eventInfo.Name);
             }
         }
     }
     else
     {
         foreach (var interfaceType in serviceDefinition.Interfaces)
         {
             foreach (var eventInfo in interfaceType.GetEvents(
                          BindingFlags.Public | BindingFlags.Instance))
             {
                 if (serviceDefinition.FindEvent(eventInfo.Name) == null && eventInfo.IsEventCandidate())
                 {
                     serviceDefinition.GetEvent(eventInfo.Name);
                 }
             }
         }
     }
 }
Пример #2
0
 public static void FindMethods(IMutableServiceDefinition serviceDefinition)
 {
     if (serviceDefinition.Implementation != null)
     {
         foreach (var methodInfo in serviceDefinition.Implementation.GetMethods(
                      BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
         {
             if (serviceDefinition.FindMethod(methodInfo.Name) == null &&
                 (methodInfo.IsQueryCandidate() || methodInfo.IsCommandCandidate() || methodInfo.IsEventHandlerCandidate()))
             {
                 serviceDefinition.GetMethod(methodInfo.Name);
             }
         }
     }
     else
     {
         foreach (var interfaceType in serviceDefinition.Interfaces)
         {
             foreach (var methodInfo in interfaceType.GetMethods(
                          BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
             {
                 if (serviceDefinition.FindMethod(methodInfo.Name) == null &&
                     (methodInfo.IsQueryCandidate() || methodInfo.IsCommandCandidate()))
                 {
                     serviceDefinition.GetMethod(methodInfo.Name);
                 }
             }
         }
     }
 }
 public static ServiceDefinitionBuilder CreateByImplementationType(
     Type serviceImplementationType, IMutableServiceDefinition serviceDefinition) =>
 (ServiceDefinitionBuilder)Activator.CreateInstance(
     typeof(ServiceDefinitionBuilder <>).MakeGenericType(serviceImplementationType),
     new object[] { serviceDefinition });
 public ServiceDefinitionBuilder(IMutableServiceDefinition serviceDefinition)
 {
     ServiceDefinition = serviceDefinition;
 }
 public static ExternalServiceDefinitionBuilder CreateByInterfaceType(
     Type serviceInterfaceType, IMutableServiceDefinition serviceDefinition) =>
 (ExternalServiceDefinitionBuilder)Activator.CreateInstance(
     typeof(ExternalServiceDefinitionBuilder <>).MakeGenericType(serviceInterfaceType),
     new object[] { serviceDefinition });