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


C# IServiceProvider.Resolve方法代码示例

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


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

示例1: Context

		public Context(IServiceProvider service)
		{
			Stream = ChunkedMemoryStream.Static();
			Writer = Stream.GetWriter();
			var dqm = service.Resolve<IDatabaseQueryManager>();
			var factory = service.Resolve<IObjectFactory>().CreateInnerFactory();
			factory.RegisterInterfaces(dqm.StartQuery(false));
			Repository = factory.Resolve<IPersistableRepository<World>>();
			BulkReader = factory.BulkRead(ChunkedMemoryStream.Static());
		}
开发者ID:cmsimike,项目名称:FrameworkBenchmarks,代码行数:10,代码来源:Context.cs

示例2: HttpListenerServer

 public HttpListenerServer(IServiceProvider locator)
 {
     Listener = new HttpListener();
     Listener.IgnoreWriteExceptions = true;
     foreach (string key in ConfigurationManager.AppSettings.Keys)
     {
         if (key.StartsWith("HttpAddress", StringComparison.InvariantCultureIgnoreCase))
             Listener.Prefixes.Add(ConfigurationManager.AppSettings[key]);
     }
     if (Listener.Prefixes.Count == 0)
         Listener.Prefixes.Add("http://*:8999/");
     Routes = locator.Resolve<Routes>();
     var customAuth = ConfigurationManager.AppSettings["CustomAuth"];
     if (!string.IsNullOrEmpty(customAuth))
     {
         var authType = Type.GetType(customAuth);
         if (!typeof(HttpAuth).IsAssignableFrom(authType))
             throw new ConfigurationErrorsException("Custom auth does not inherit from HttpAuth. Please inherit from " + typeof(HttpAuth).FullName);
         Authentication = locator.Resolve<HttpAuth>(authType);
     }
     else Authentication = locator.Resolve<HttpAuth>();
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:22,代码来源:HttpListenerServer.cs

示例3: ProvideValue

        /// <inheritdoc />
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            try
            {
                if (this.MemberType != null)
                {
                    var resourceManager = Gu.Localization.ResourceManagers.ForType(this.MemberType);
                    return CreateBindingExpression(resourceManager, this.Member, serviceProvider);
                }

                if (string.IsNullOrEmpty(this.Member))
                {
                    throw new InvalidOperationException("MarkupExtensionStaticMember");
                }

                var qnk = QualifiedNameAndKey.Parse(this.Member);
                if (qnk.QualifiedName == null || qnk.Key == null)
                {
                    return string.Format(Resources.UnknownErrorFormat, this.Member);
                }

                var type = serviceProvider.Resolve(qnk.QualifiedName);
                if (type == null)
                {
                    return string.Format(Resources.MissingResourcesFormat, this.Member);
                }

                var manager = Gu.Localization.ResourceManagers.ForType(type);
                this.Member = qnk.Key;
                return CreateBindingExpression(manager, this.Member, serviceProvider);
            }
            catch (Exception)
            {
                return string.Format(Resources.UnknownErrorFormat, this.Member);
            }
        }
开发者ID:csuffyy,项目名称:Gu.Localization,代码行数:37,代码来源:StaticExtension.cs

示例4: HttpSocketServer

 public HttpSocketServer(IServiceProvider locator)
 {
     this.Locator = locator;
     var endpoints = new List<IPEndPoint>();
     var networkType = AddressFamily.InterNetworkV6;
     foreach (string key in ConfigurationManager.AppSettings.Keys)
     {
         if (key.StartsWith("HttpAddress", StringComparison.InvariantCultureIgnoreCase))
         {
             var addr = new Uri(ConfigurationManager.AppSettings[key]);
             IPAddress ip;
             if (!IPAddress.TryParse(addr.Host, out ip))
             {
                 var ips = Dns.GetHostAddresses(addr.Host);
                 foreach (var i in ips)
                     if (i.AddressFamily == networkType)
                         endpoints.Add(new IPEndPoint(i, addr.Port));
                 if (endpoints.Count == 0 && ips.Length > 0)
                 {
                     if (ips[0].AddressFamily == AddressFamily.InterNetwork)
                     {
                         networkType = AddressFamily.InterNetwork;
                         foreach (var i in ips)
                             if (i.AddressFamily == networkType)
                                 endpoints.Add(new IPEndPoint(i, addr.Port));
                     }
                 }
             }
             else endpoints.Add(new IPEndPoint(ip, addr.Port));
         }
     }
     if (endpoints.Count == 0)
     {
         Console.WriteLine("Http address not found in config. Starting IPv6 on all interfaces");
         endpoints.Add(new IPEndPoint(Socket.OSSupportsIPv6 ? IPAddress.IPv6Any : IPAddress.Any, 8999));
     }
     else if (endpoints.FindAll(it => it.AddressFamily == AddressFamily.InterNetwork).Count == endpoints.Count)
     {
         networkType = AddressFamily.InterNetwork;
     }
     else if (endpoints.FindAll(it => it.AddressFamily == AddressFamily.InterNetworkV6).Count != endpoints.Count)
     {
         throw new ConfigurationErrorsException(@"Unable to setup configuration for both IPv4 and IPv6. Use either only IPv4 or IPv6.
     Please check settings: " + string.Join(", ", endpoints));
     }
     Socket = new Socket(networkType, SocketType.Stream, ProtocolType.Tcp);
     //Socket.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, 0);
     foreach (var ep in endpoints)
     {
         Socket.Bind(ep);
         Console.WriteLine("Bound to: " + ep);
     }
     var customAuth = ConfigurationManager.AppSettings["CustomAuth"];
     if (!string.IsNullOrEmpty(customAuth))
     {
         var authType = Type.GetType(customAuth);
         if (!typeof(HttpAuth).IsAssignableFrom(authType))
             throw new ConfigurationErrorsException("Custom auth does not inherit from HttpAuth. Please inherit from " + typeof(HttpAuth).FullName);
         Authentication = locator.Resolve<HttpAuth>(authType);
     }
     else Authentication = locator.Resolve<HttpAuth>();
     var routes = locator.Resolve<Routes>();
     Context = new ThreadLocal<HttpSocketContext>(() => new HttpSocketContext("http://127.0.0.1/", MessageSizeLimit, routes));
     var ca = ConfigurationManager.AppSettings["Revenj.HttpCapacity"];
     Requests = !string.IsNullOrEmpty(ca)
         ? new BlockingCollection<RequestInfo>((int)Math.Log(int.Parse(ca), 2))
         : new BlockingCollection<RequestInfo>();
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:68,代码来源:HttpSocketServer.cs

示例5: QueueService

		public QueueService(IServiceProvider locator)
		{
			Processor = locator.Resolve<QueueProcessor>();
			InitializeComponent();
		}
开发者ID:dstimac,项目名称:revenj,代码行数:5,代码来源:QueueService.cs

示例6: ReportingTests

 public ReportingTests()
 {
     locator = Common.StartClient();
     tService = locator.Resolve<ITemplaterService>();
     rProxy = locator.Resolve<IReportingProxy>();
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:6,代码来源:ReportingTests.cs

示例7: StandardTests

 public StandardTests()
 {
     locator = Common.StartClient();
     sProxy = locator.Resolve<IStandardProxy>();
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:5,代码来源:StandardTests.cs

示例8: MailService

		public MailService(IServiceProvider locator)
		{
			Contract.Requires(locator != null);

			this.Lookup = locator.Resolve<Func<string, IMailMessage>>();
		}
开发者ID:dstimac,项目名称:revenj,代码行数:6,代码来源:MailService.cs


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