public RpcServer(int _backLength, int _port, bool _usessl, string _sslfile, int timeoutSec, string _sslpassword = "", ISerializer _serializer = null) { backLength = _backLength; port = _port; useSSl = _usessl; sslFile = _sslfile; sslPassword = _sslpassword; this.apiActionTable = new ApiActionTable(); this.PacketIdProvider = new PacketIdProvider(); this.TaskSetterTable = new TaskSetterTable <long>(); this.TimeOut = TimeSpan.FromSeconds(timeoutSec); if (_serializer == null) { this.Serializer = new DefaultSerializer(); } else { this.Serializer = _serializer; } this.GlobalFilters = new FastGlobalFilters(); this.DependencyResolver = new DefaultDependencyResolver(); this.FilterAttributeProvider = new DefaultFilterAttributeProvider(); allSessions = new ConcurrentDictionary <string, FastSession>(); DomainAssembly.GetAssemblies().ForEach(item => this.BindService(item)); }
public static IAppBuilder UseWebApi(this IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); Container container = ContainerFactory.Create( new AsyncScopedLifestyle(), DomainAssembly.ToList(), c => { c.RegisterWebApiControllers(config); c.RegisterInitializer <ApiController>(apiController => { apiController.Mediator = c.GetInstance <IMediator>(); }); IEnumerable <Type> notificationHandlers = c.GetTypesToRegister( typeof(INotificationHandler <>), ProcessAssembly, new TypesToRegisterOptions { IncludeGenericTypeDefinitions = true }); c.RegisterCollection( typeof(INotificationHandler <>), notificationHandlers); }); config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); config.MapHttpAttributeRoutes(); // formatters config.Formatters.Clear(); JsonMediaTypeFormatter jsonFormatter = new JsonMediaTypeFormatter(); jsonFormatter.SupportedMediaTypes.Clear(); jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); config.Formatters.Add(jsonFormatter); // set JSON serialiser used by WebApi to use our desired serialisation settings config.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), DateFormatHandling = DateFormatHandling.IsoDateFormat, DateParseHandling = DateParseHandling.DateTime, DateTimeZoneHandling = DateTimeZoneHandling.Utc, NullValueHandling = NullValueHandling.Ignore }; config.Services.Replace(typeof(IExceptionHandler), new CustomExceptionHandler()); app.UseWebApi(config); return(app); }
public async Task <IEnumerable <IEvent> > GetEventsAsync(Guid entityId) { var records = await Options.GetCloudTable(EventTable) .ExecuteTableQueryAsync(new TableQuery <EventTableEntity>() .Where(TableQuery.GenerateFilterCondition( "PartitionKey", QueryComparisons.Equal, entityId.ToString()))); return(records.OrderBy(r => r.Timestamp) .Select(r => JsonConvert.DeserializeObject(r.Data, DomainAssembly.GetType(r.Type)) as IEvent)); }
/// <summary> /// Http服务 /// </summary> public HttpMiddleware() { this.httpActionList = new HttpActionList(); this.ModelBinder = new DefaultModelBinder(); this.GlobalFilters = new HttpGlobalFilters(); this.MIMECollection = new HttpMIMECollection(); this.FilterAttributeProvider = new DefaultFilterAttributeProvider(); this.DependencyResolver = new DefaultDependencyResolver(); this.MIMECollection.FillBasicMIME(); DomainAssembly.GetAssemblies().ForEach(item => this.BindController(item)); }
/// <summary> /// fast协议中间件 /// </summary> public FastMiddleware() { this.apiActionList = new ApiActionList(); this.PacketIdProvider = new PacketIdProvider(); this.TaskSetActionTable = new TaskSetActionTable(); this.Serializer = new DefaultSerializer(); this.GlobalFilters = new FastGlobalFilters(); this.DependencyResolver = new DefaultDependencyResolver(); this.FilterAttributeProvider = new DefaultFilterAttributeProvider(); DomainAssembly.GetAssemblies().ForEach(item => this.BindService(item)); }
/// <summary> /// JsonWebSocket中间件 /// </summary> public JsonWebSocketMiddleware() { this.apiActionList = new ApiActionList(); this.PacketIdProvider = new PacketIdProvider(); this.TaskSetterTable = new TaskSetterTable <long>(); this.TimeOut = TimeSpan.FromSeconds(30); this.JsonSerializer = new DefaultDynamicJsonSerializer(); this.GlobalFilters = new WebSocketGlobalFilters(); this.DependencyResolver = new DefaultDependencyResolver(); this.FilterAttributeProvider = new DefaultFilterAttributeProvider(); DomainAssembly.GetAssemblies().ForEach(item => this.BindService(item)); }
/// <summary> /// fast协议中间件 /// </summary> public FastMiddleware() { this.apiActionTable = new ApiActionTable(); this.PacketIdProvider = new PacketIdProvider(); this.TaskSetterTable = new TaskSetterTable <long>(); this.TimeOut = TimeSpan.FromSeconds(30); this.Serializer = new DefaultSerializer(); this.GlobalFilters = new FastGlobalFilters(); this.DependencyResolver = new DefaultDependencyResolver(); this.FilterAttributeProvider = new DefaultFilterAttributeProvider(); DomainAssembly.GetAssemblies().ForEach(this.BindService); }
public override Type GetTypeFromTypeName(string typeName) { IClassMap classMap = this.context.DomainMap.GetClassMap(typeName); if (classMap != null) { Type type = this.Context.AssemblyManager.GetTypeFromClassMap(classMap); if (type != null) { return(type); } } return(DomainAssembly.GetType(typeName)); }
/// <summary> /// 搜索程序域内所有HttpAction /// </summary> /// <returns></returns> private IEnumerable <HttpAction> FindAllHttpActions() { return(DomainAssembly .GetAssemblies() .SelectMany(item => this.GetHttpActions(item))); }
public virtual Type GetTypeFromTypeName(string typeName) { return(DomainAssembly.GetType(typeName)); }