static GamePacketMetadataMarker() { AssemblyTypes = typeof(GamePacketMetadataMarker) .Assembly .GetExportedTypes(); GamePacketPayloadTypes = AssemblyTypes .Where(t => typeof(GamePacketPayload).IsAssignableFrom(t)) .ToArray(); SerializableTypes = GamePacketPayloadTypes .Concat(AssemblyTypes.Where(t => t.GetCustomAttribute <WireDataContractAttribute>() != null)) .Distinct() .ToArray(); UnimplementedOperationCodes = new Lazy <IReadOnlyCollection <NetworkOperationCode> >(() => { var codes = GamePacketPayloadTypes .Where(t => t.GetCustomAttribute <GamePayloadOperationCodeAttribute>(true) != null) .Select(t => t.GetCustomAttribute <GamePayloadOperationCodeAttribute>(true).OperationCode) .Distinct() .ToArray(); return(((NetworkOperationCode[])Enum.GetValues(typeof(NetworkOperationCode))) .Where(o => !codes.Contains(o)) .ToArray()); }, true); }
static GamePacketStubMetadataMarker() { AssemblyTypes = typeof(GamePacketStubMetadataMarker) .Assembly .GetExportedTypes(); GamePacketPayloadStubTypes = AssemblyTypes .Where(t => typeof(GamePacketPayload).IsAssignableFrom(t)) .ToArray(); }
public static void Configure(ContainerBuilder builder, bool isProduction) { builder.RegisterSource(new ContravariantRegistrationSource()); var repositoryTypes = AssemblyTypes.Where(t => t.ImplementsInterface <IService>()).ToArray(); foreach (var repositoryType in repositoryTypes) { builder.RegisterType(repositoryType) .AsImplementedInterfaces() .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies) .WithParameter(new ResolvedParameter((p, ctx) => p.Name == "asNoTracking", (p, ctx) => false)) .InstancePerLifetimeScope(); } var eventHandlerTypes = AssemblyTypes.Where(t => t.Name.EndsWith("EventHandler")).ToArray(); foreach (var eventHandlerType in eventHandlerTypes) { builder.RegisterType(eventHandlerType) .AsImplementedInterfaces() .PropertiesAutowired() .WithParameter(AppConfigParameter) .InstancePerLifetimeScope(); } builder.RegisterType <EntityChangeEventPublisherEntityContextInterceptor>().PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies).InstancePerLifetimeScope(); builder.RegisterType <EntityContext>() .As <IEntityContext>() .PropertiesAutowired() .EnableInterfaceInterceptors() .InterceptedBy(typeof(EntityChangeEventPublisherEntityContextInterceptor)) .InstancePerLifetimeScope(); builder.RegisterType <UnitOfWork>().As <IUnitOfWork>().PropertiesAutowired().InstancePerLifetimeScope(); builder.RegisterType <EventPublisher>().As <IEventPublisher>().PropertiesAutowired().InstancePerLifetimeScope(); }
public IEnumerable <Type> AssemblyNamespaceTypes(string ns) { return(AssemblyTypes. Where(t => ns == t.Namespace). OrderBy(t => SortName(t))); }