public VariableBinding(VariableDeclarationStatementSyntax variableDeclaration) { MutableBinding = variableDeclaration.MutableBinding; BindingName = variableDeclaration.Name; Name = BindingName.WithoutNumber(); NameSpan = variableDeclaration.NameSpan; }
public VariableBinding(ParameterSyntax parameter) { MutableBinding = parameter.MutableBinding; BindingName = parameter.Name; Name = BindingName.WithoutNumber(); NameSpan = parameter.Span; }
public void TestNamedParentIntrospection() { IDIContext parentContext = ContextHelper.CreateContext(); parentContext.m().Bind <IApple>(() => new Apple(), BindingName.ForType <Apple>()); IDIContext context = parentContext.Reproduce(); context.m().Bind <IApple>(() => new BigApple(), BindingName.ForType <BigApple>()); IBinding desc = context.Introspect <IApple>(BindingName.ForType <BigApple>()); Assert.IsNotNull(desc); Assert.AreEqual(InstantiationType.Abstract, desc.instantiationType); Assert.That(desc.context == context); object apple = desc.factory(); Assert.That(apple is BigApple); desc = context.Introspect <IApple>(); Assert.IsNotNull(desc); Assert.AreEqual(InstantiationType.Abstract, desc.instantiationType); Assert.That(desc.context == context); apple = desc.factory(); Assert.That(apple is BigApple); desc = context.Introspect <IApple>(BindingName.ForType <Apple>()); Assert.IsNotNull(desc); Assert.AreEqual(InstantiationType.Abstract, desc.instantiationType); Assert.That(desc.context == parentContext); apple = desc.factory(); Assert.That(apple is Apple); }
public void Initialize(IDIContext context) { context.s().Rebind <ILog>(null, BindingName.For(LogType.Decorated)); context.m().Bind <ILogOwner>(() => new MyLogOwner()); context.s().Bind <IWorld>(() => new Earth()); context.s().Bind <ISky>(() => new Sky()); context.m().Bind <IHumanFactory>(() => new HumanFactory()); context.m().Bind <IHuman>(() => new Human()); }
public void UnsafeTypedGetTest() { var context = TestsFactory.BindingContext(); context.Bind <int>().To(() => 42); var name = new BindingName(InnerBindingNames.Empty); var key = new BindingKey(typeof(int)); Assert.DoesNotThrow(() => context.Unsafe.TryGet(name, key, new object[0])); }
protected string FullPath(string bindingName) { int index = BindingName.LastIndexOf('.'); if (index == -1) { return(bindingName); } var path = BindingName.Substring(0, index + 1) + bindingName; return(path); }
public void TestNamedParentResolution() { IDIContext parentContext = ContextHelper.CreateContext(); parentContext.m().Bind <IApple>(() => new Apple(), BindingName.ForType <Apple>()); IDIContext context = parentContext.Reproduce(); context.m().Bind <IApple>(() => new BigApple(), BindingName.ForType <BigApple>()); IApple apple = context.Resolve <IApple>(BindingName.ForType <BigApple>()); Assert.That(apple is BigApple); apple = context.Resolve <IApple>(); Assert.That(apple is BigApple); apple = context.Resolve <IApple>(BindingName.ForType <Apple>()); Assert.That(apple is Apple); }
//----------------------------------------------------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------------------------------------------------- /// <summary> /// /// </summary> public void Start() { lock (SyncRoot) { Binding _binding; var _servicePort = ServicePort; var _address = String.Format("://{0}:{1}/{2}", IpAddress, _servicePort, ServiceName); if (BindingName.ToLower() == "WSHttpBinding".ToLower()) { _address = "http" + _address; WSHttpBinding _binding2 = new WSHttpBinding(); { _binding2.TransactionFlow = false; _binding2.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; _binding2.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; _binding2.Security.Mode = SecurityMode.None; _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.ReaderQuotas = ReaderQuotas; } _binding = _binding2; } else if (BindingName.ToLower() == "WSDualHttpBinding".ToLower()) { _address = "http" + _address; WSDualHttpBinding _binding2 = new WSDualHttpBinding(); { _binding2.TransactionFlow = false; _binding2.Security.Message.ClientCredentialType = MessageCredentialType.None; _binding2.Security.Mode = WSDualHttpSecurityMode.None; _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.ReaderQuotas = ReaderQuotas; } _binding = _binding2; } else if (BindingName.ToLower() == "NetMsmqBinding".ToLower()) { _address = String.Format("net.msmq://{0}/private/{1}", IpAddress, ServiceName); NetMsmqBinding _binding2 = new NetMsmqBinding(); { _binding2.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None; _binding2.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None; _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.SendTimeout = SendTimeout; _binding2.ReceiveTimeout = ReceiveTimeout; _binding2.ReaderQuotas = ReaderQuotas; } _binding = _binding2; } else if (BindingName.ToLower() == "NetNamedPipeBinding".ToLower()) { _address = "net.pipe" + _address; NetNamedPipeBinding _binding2 = new NetNamedPipeBinding(); { _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.SendTimeout = SendTimeout; _binding2.ReceiveTimeout = ReceiveTimeout; _binding2.ReaderQuotas = ReaderQuotas; } _binding = _binding2; } //else if (BindingName.ToLower() == "NetPeerTcpBinding".ToLower()) //{ // _address = "net.peer" + _address; // NetPeerTcpBinding _binding2 = new NetPeerTcpBinding(); // { // _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; // _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; // _binding2.SendTimeout = SendTimeout; // _binding2.ReceiveTimeout = ReceiveTimeout; // _binding2.ReaderQuotas = ReaderQuotas; // } // _binding = _binding2; //} else if (BindingName.ToLower() == "net.tcp".ToLower()) { if (IsPortSharing == true) { _servicePort = SharingPort; } _address = String.Format("net.tcp://{0}:{1}/{2}", IpAddress, _servicePort, ServiceName); NetTcpBinding _binding2 = new NetTcpBinding(); { _binding2.Security.Mode = SecurityMode.None; _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.SendTimeout = SendTimeout; _binding2.ReceiveTimeout = ReceiveTimeout; _binding2.ReaderQuotas = ReaderQuotas; _binding2.PortSharingEnabled = IsPortSharing; } _binding = _binding2; } else if (BindingName.ToLower() == "BasicHttpBinding".ToLower()) { _address = "http" + _address; BasicHttpBinding _binding2 = new BasicHttpBinding(); { _binding2.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; _binding2.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; _binding2.Security.Mode = BasicHttpSecurityMode.None; _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.ReaderQuotas = ReaderQuotas; } _binding = _binding2; } else if (BindingName.ToLower() == "WebHttpBinding".ToLower()) { _address = "http" + _address; WebHttpBinding _binding2 = new WebHttpBinding(); { _binding2.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; _binding2.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; _binding2.Security.Mode = WebHttpSecurityMode.None; _binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; _binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.ReaderQuotas = ReaderQuotas; } _binding = _binding2; } else { _address = "http" + _address; // Create a custom binding that contains two binding elements. ReliableSessionBindingElement _reliableSession = new ReliableSessionBindingElement { InactivityTimeout = TimeSpan.FromDays(7), Ordered = true }; HttpTransportBindingElement _httpTransport = new HttpTransportBindingElement { AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous, HostNameComparisonMode = HostNameComparisonMode.StrongWildcard }; CustomBinding _binding2 = new CustomBinding(_reliableSession, _httpTransport); { //_binding2.MaxReceivedMessageSize *= MaxReceivedMessageSize; //_binding2.MaxBufferPoolSize *= MaxBufferPoolSize; _binding2.SendTimeout = SendTimeout; _binding2.ReceiveTimeout = ReceiveTimeout; } _binding = _binding2; } this.WcfAddress = _address; m_channelFactory = new ChannelFactory <T>(_binding, new EndpointAddress(_address)); } }
public void Initialize(IDIContext context) { context.m().Bind <ILog>(() => new SimpleLog(), BindingName.For(LogType.Simple)); context.m().Bind <ILog>(() => new DecoratedLog(context.Resolve <ILog>(BindingName.For(LogType.Simple))), BindingName.For(LogType.Decorated)); context.m().Bind <ILogOwner>(() => new CoreLogOwner()); }