当前位置: 首页>>代码示例>>C#>>正文


C# IUnitOfWork.GetTypedRepository方法代码示例

本文整理汇总了C#中IUnitOfWork.GetTypedRepository方法的典型用法代码示例。如果您正苦于以下问题:C# IUnitOfWork.GetTypedRepository方法的具体用法?C# IUnitOfWork.GetTypedRepository怎么用?C# IUnitOfWork.GetTypedRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUnitOfWork的用法示例。


在下文中一共展示了IUnitOfWork.GetTypedRepository方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Register

        /// <summary>Registers the specified configuration.</summary>
        /// <param name="config">The configuration.</param>
        /// <param name="unityContainer">The unity container.</param>
        /// <param name="unitOfWork">The unit of work.</param>
        public static void Register(HttpConfiguration config, IUnityContainer unityContainer, IUnitOfWork unitOfWork)
        {
            var applicationSettingRepository = unitOfWork.GetTypedRepository<IApplicationSettingRepository>();

            etagCacheServerDuration = applicationSettingRepository.GetOrCreateByName<int>("EtagCacheServerDuration");
            etagCacheClientDuration = applicationSettingRepository.GetOrCreateByName<int>("EtagCacheClientDuration");

#if !DEBUG

    // Configure Web API to use only bearer token authentication.
    // Only suppress if not in debug mode, this allows browsing the WebAPI if in debug mode.
            config.SuppressDefaultHostAuthentication();
#endif

            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
            config.Filters.Add(new ModelStateValidationFilter());
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new SelectSupportConverter());

            var browserFormatter = new BrowserJsonFormatter
            {
                SerializerSettings =
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }
            };

            browserFormatter.SerializerSettings.Converters.Add(new SelectSupportConverter());

            config.Formatters.Add(browserFormatter);

            config.DependencyResolver = new UnityDependencyResolver(unityContainer);

            // Changing this setting requires a website restart
            if (applicationSettingRepository.GetOrCreateByName<bool>("Caching_EnableEtags"))
            {
                var etagStore = new SqlServerEntityTagStore(ConfigurationManager.ConnectionStrings["InSite.Commerce"].ConnectionString);

                // The vary by in the constructor needs to be something that is unique per user so it generates ETags uniquely per user
                // Cookie contains a cookie we generate InsiteCacheId that is a guid per user.
                var cacheHandler = new CachingHandler(config, etagStore, "Cookie")
                {
                    // This must be false so IE client side caching works, anything that needs to vary needs to be done by uri or querystring
                    AddVaryHeader = false,
                    AddLastModifiedHeader = true,
                    RoutePatternProvider = new CacheRoutePatternProvider(),
                    CacheControlHeaderProvider = CacheControlHeaderProvider,
                    CacheRefreshPolicyProvider = CacheRefreshPolicyProvider
                };
                config.MessageHandlers.Add(cacheHandler);
            }

            config.MessageHandlers.Add(new LocalizationHandler());
            config.MapHttpAttributeRoutes(new InheritanceDirectRouteProvider());

            // There can be multiple exception loggers. (By default, no exception loggers are registered.)
            config.Services.Add(typeof(IExceptionLogger), unityContainer.Resolve<IExceptionLogger>());

            // There must be exactly one exception handler. (There is a default one that may be replaced.)
            config.Services.Replace(typeof(IExceptionHandler), unityContainer.Resolve<IExceptionHandler>());
        }
开发者ID:Barterdm04,项目名称:Demo,代码行数:66,代码来源:WebApiConfig.cs


注:本文中的IUnitOfWork.GetTypedRepository方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。