internal static MethodParameters ToBindingMethodParameters(this BindingSettings bindingSettings) { Func <Type[], Type> argumentResolver = null; var methodParameters = new MethodParameters(); var arguments = bindingSettings.BindingType.GetGenericArguments(); methodParameters.Parameters = new Type[2]; methodParameters.Parameters[0] = arguments[0].MakeByRefType(); arguments = arguments.Skip(1).ToArray(); if (bindingSettings.IsFunction) { methodParameters.ReturnType = arguments.Last(); argumentResolver = AspectArgsContractResolver.ToFunctionAspectArgumentContract; } else { methodParameters.ReturnType = typeof(void); argumentResolver = AspectArgsContractResolver.ToActionAspectArgumentContract; } methodParameters.Parameters[1] = argumentResolver(arguments); return(methodParameters); }
public void WhenValueProviderPropertyChanged_ThenBindingRaisesChanged() { var raised = false; var property = new PropertyBindingSettings(); var binding = new BindingSettings { Properties = { new PropertyBindingSettings { ValueProvider = new ValueProviderBindingSettings { Properties = { property, } } } } }; binding.PropertyChanged += (sender, args) => raised = true; property.Value = "foo"; Assert.True(raised); }
/// <summary> /// Set Binding Property /// </summary> /// <param name="batchSettings"></param> public static void SetBinding(BindingSettings <TDerive> batchSettings) { foreach (var setting in batchSettings) { SetBinding(setting.Key, setting.Value); } }
public void Should_Create_Website_With_Directly_Defined_Binding() { // Arrange var settings = CakeHelper.GetWebsiteSettings("CaptainAmerica"); const string expectedHostName = "CaptainAmerica.web"; const string expectedIpAddress = "*"; const int expectedPort = 981; var binding = new BindingSettings(BindingProtocol.Http) { HostName = expectedHostName, IpAddress = expectedIpAddress, Port = expectedPort, }; settings.Binding = binding; CakeHelper.DeleteWebsite(settings.Name); // Act WebsiteManager manager = CakeHelper.CreateWebsiteManager(); manager.Create(settings); // Assert var website = CakeHelper.GetWebsite(settings.Name); Assert.NotNull(website); Assert.Equal(1, website.Bindings.Count); Assert.Contains(website.Bindings, b => b.Protocol == BindingProtocol.Http.ToString() && b.BindingInformation == binding.BindingInformation && b.BindingInformation.Contains(expectedPort.ToString()) && b.BindingInformation.Contains(expectedHostName) && b.BindingInformation.Contains(expectedIpAddress)); }
private static Settings Convert(V5::Settings old) { var settings = Settings.GetDefaults(); if (settings.Profiles.FirstOrDefault() is Profile profile) { profile.OutputMode = SafeMigrate(old.OutputMode, new PluginSettingStore(typeof(AbsoluteMode))); profile.AbsoluteModeSettings.Display.Area = old.GetDisplayArea(); profile.AbsoluteModeSettings.Tablet.Area = old.GetTabletArea(); profile.AbsoluteModeSettings.EnableAreaLimiting = old.EnableAreaLimiting; profile.AbsoluteModeSettings.EnableClipping = old.EnableClipping; profile.AbsoluteModeSettings.LockAspectRatio = old.LockAspectRatio; profile.RelativeModeSettings.XSensitivity = old.XSensitivity; profile.RelativeModeSettings.YSensitivity = old.YSensitivity; profile.RelativeModeSettings.RelativeRotation = old.RelativeRotation; profile.RelativeModeSettings.ResetTime = old.ResetTime; profile.Filters = SafeMigrateCollection(new PluginSettingStoreCollection(old.Filters.Concat(old.Interpolators))); profile.BindingSettings.TipButton = SafeMigrate(old.TipButton, BindingSettings.GetDefaults().TipButton); profile.BindingSettings.PenButtons = SafeMigrateCollection(old.PenButtons).SetExpectedCount(BindingSettings.PEN_BUTTON_MAX); profile.BindingSettings.AuxButtons = SafeMigrateCollection(old.AuxButtons).SetExpectedCount(BindingSettings.AUX_BUTTON_MAX); } settings.LockUsableAreaDisplay = old.LockUsableAreaDisplay; settings.LockUsableAreaTablet = old.LockUsableAreaTablet; return(settings); }
public void WhenPropertyAdded_ThenBindingRaisesChanged() { var binding = new BindingSettings(); var raised = false; binding.PropertyChanged += (sender, args) => raised = true; binding.Properties.Add(new PropertyBindingSettings()); Assert.True(raised); }
public void WhenTypeIdChanged_ThenBindingRaisesChanged() { var binding = new BindingSettings(); var raised = false; binding.PropertyChanged += (sender, args) => raised = true; binding.TypeId = "foo"; Assert.True(raised); }
private void QueueBind(IModel model, BindingSettings settings) { this.logger.LogInformation( $"Binding queue {settings.QueueName} " + $"to exchange {settings.ExchangeName} " + $"via routing key {settings.RoutingKey}"); model.QueueBind( queue: settings.QueueName, exchange: settings.ExchangeName, routingKey: settings.RoutingKey, arguments: settings.Arguments ); }
public void InitializeContext() { this.settings = new BindingSettings { TypeId = string.Empty }; this.component = "SomeComponent"; var innerDescriptor = new Mock <PropertyDescriptor>("foo", new Attribute[0]); innerDescriptor.Setup(x => x.Name).Returns("Property"); innerDescriptor.Setup(x => x.Attributes).Returns(new AttributeCollection()); innerDescriptor.Setup(x => x.GetValue(this.component)).Returns(this.settings); this.descriptor = new BindingPropertyDescriptor <IValueProvider>(innerDescriptor.Object, new Attribute[0]); }
public void WhenPropertyNameChanged_ThenBindingRaisesChanged() { var binding = new BindingSettings(); var property = new PropertyBindingSettings(); var raised = false; binding.Properties.Add(property); binding.PropertyChanged += (sender, args) => raised = true; property.Name = "hello"; Assert.True(raised); }
public void WhenPropertyValueProviderSet_ThenBindingRaisesChanged() { var binding = new BindingSettings(); var property = new PropertyBindingSettings(); var raised = false; binding.Properties.Add(property); binding.PropertyChanged += (sender, args) => raised = true; property.ValueProvider = new ValueProviderBindingSettings(); Assert.True(raised); }
internal static ArgumentsWeavingSettings ToArgumentsWeavingSettings(this BindingSettings bindingSettings, Type aspectType = null) { var methodParameters = bindingSettings.ToMethodParameters(); return(new ArgumentsWeavingSettings { AspectType = aspectType, MemberType = bindingSettings.MemberType, MemberInfo = bindingSettings.MemberInfo, ReturnType = methodParameters.ReturnType, Parameters = methodParameters.Parameters, ArgumentType = bindingSettings.ArgumentType, HasReturnType = bindingSettings.HasReturnType, BindingsDependency = bindingSettings.BindingDependency }); }
public void Should_Add_MsmqFormatName_Binding() { // Arrange var settings = CreateWebSite(); BindingSettings bindingSettings = IISBindings.MsmqFormatName; // Act Act(settings.Name, bindingSettings); // Assert var website = CakeHelper.GetWebsite(settings.Name); Assert.NotNull(website); Assert.Equal(2, website.Bindings.Count); Assert.Contains(website.Bindings, b => b.Protocol == BindingProtocol.MsmqFormatName.ToString() && b.BindingInformation == bindingSettings.BindingInformation); }
public void Should_Add_MsmqFormatName_Binding() { // Arrange var settings = CreateWebSite(); BindingSettings bindingSettings = IISBindings.MsmqFormatName; // Act Act(settings.Name, bindingSettings); // Assert var website = CakeHelper.GetWebsite(settings.Name); website.ShouldNotBeNull(); website.Bindings.Count.ShouldBe(2); website.Bindings.ShouldContain(b => b.Protocol == BindingProtocol.MsmqFormatName.ToString() && b.BindingInformation == bindingSettings.BindingInformation); }
internal static ArgumentsWeavingSettings ToArgumentsWeavingSettings(this BindingSettings bindingSettings, Type aspectType = null) { Type bindingsDependencyType = null; var methodParameters = bindingSettings.ToMethodParameters(); if (bindingSettings.BindingDependency.IsNotNull()) { bindingsDependencyType = bindingSettings.BindingDependency.FieldType; } return(new ArgumentsWeavingSettings { AspectType = aspectType, IsFunction = bindingSettings.IsFunction, ReturnType = methodParameters.ReturnType, Parameters = methodParameters.Parameters, ArgumentType = bindingSettings.ArgumentType, BindingsDependency = bindingSettings.BindingDependency }); }
internal static MethodParameters ToMethodParameters(this BindingSettings bindingSettings) { var methodParameters = new MethodParameters(); var arguments = bindingSettings.BindingType.GetGenericArguments(); if (bindingSettings.IsFunction()) { var length = arguments.Length - 2; methodParameters.ReturnType = arguments.Last(); methodParameters.Parameters = new Type[length]; Array.Copy(arguments, 1, methodParameters.Parameters, 0, length); } else { methodParameters.Parameters = arguments.Skip(1).ToArray(); } return(methodParameters); }
public void WhenRoundTrippingFullBinding_ThenSucceeds() { IBindingSettings binding = new BindingSettings { TypeId = "foo", Properties = { new PropertyBindingSettings { Name = "Name", Value = "Value", ValueProvider = new ValueProviderBindingSettings { TypeId = "ValueProvider", Properties = { new PropertyBindingSettings { Name = "Id", Value = "1" } } } } } }; var serialized = BindingSerializer.Serialize(binding); var deserialized = BindingSerializer.Deserialize <IBindingSettings>(serialized); Assert.Equal(binding.TypeId, deserialized.TypeId); Assert.Equal(binding.Properties.Count, deserialized.Properties.Count); Assert.Equal(binding.Properties[0].Name, deserialized.Properties[0].Name); Assert.Equal(binding.Properties[0].Value, deserialized.Properties[0].Value); Assert.Equal(binding.Properties[0].ValueProvider.TypeId, deserialized.Properties[0].ValueProvider.TypeId); Assert.Equal(binding.Properties[0].ValueProvider.Properties[0].Name, deserialized.Properties[0].ValueProvider.Properties[0].Name); Assert.Equal(binding.Properties[0].ValueProvider.Properties[0].Value, deserialized.Properties[0].ValueProvider.Properties[0].Value); }
public void WhenPropertyBindingHasEmpty_ThenBindingResolvesToValueProvider() { var settings = new BindingSettings { TypeId = "Foo", Properties = { new PropertyBindingSettings { Name = Reflector <IFoo> .GetProperty(x => x.Message).Name, Value = string.Empty, ValueProvider = new ValueProviderBindingSettings { TypeId = "ValueProvider" } } } }; var binding = this.target.CreateBinding <IFoo>(settings); Assert.True(binding.Evaluate()); Assert.Equal(ValueProviderValue, binding.Value.Message); }
internal static MethodParameters ToBindingMethodParameters(this BindingSettings bindingSettings) { Func <Type[], Type> argumentResolver = null; var methodParameters = new MethodParameters(); var arguments = bindingSettings.BindingType.GetGenericArguments(); var argumentList = new List <Type> { arguments[0].MakeByRefType() }; arguments = arguments.Skip(1).ToArray(); if (bindingSettings.IsProperty()) { methodParameters.ReturnType = arguments.Last(); argumentResolver = typeArguments => { return(typeof(IPropertyArg <>).MakeGenericType(typeArguments)); }; } else { var isFunction = bindingSettings.IsFunction(); var isEventBinding = bindingSettings.IsEvent(); if (isEventBinding) { var @event = (EventInfo)bindingSettings.MemberInfo; argumentList.Add(@event.GetInvokeMethod().DeclaringType); if (isFunction) { methodParameters.ReturnType = arguments.Last(); argumentResolver = AspectArgsContractResolver.ToEventFunctionAspectArgumentContract; } else { methodParameters.ReturnType = typeof(void); argumentResolver = AspectArgsContractResolver.ToEventActionAspectArgumentContract; } } else { if (isFunction) { methodParameters.ReturnType = arguments.Last(); argumentResolver = AspectArgsContractResolver.ToFunctionAspectArgumentContract; } else { methodParameters.ReturnType = typeof(void); argumentResolver = AspectArgsContractResolver.ToActionAspectArgumentContract; } } } argumentList.Add(argumentResolver(arguments)); methodParameters.Parameters = argumentList.ToArray(); return(methodParameters); }
internal BindingMethodAspectDecoratorExpression(IMethodAspectDefinition aspectDefinition, IArgumentsWeavingSettings argumentsWeavingSettings) { this.aspectDefinition = aspectDefinition; bindingSettings = aspectDefinition.ToBindingSettings(); this.argumentsWeavingSettings = argumentsWeavingSettings; }
/// <summary> /// Specifies the IP Address value of the binding. /// </summary> /// <param name="binding">The binding.</param> /// <param name="ipAddress">The IP Address.</param> /// <returns>The same <see cref="BindingSettings"/> instance so that multiple calls can be chained.</returns> public static BindingSettings SetIpAddress(this BindingSettings binding, string ipAddress) { binding.IpAddress = ipAddress; return(binding); }
/// <summary> /// Specifies the host name value of the binding. /// </summary> /// <param name="binding">The binding.</param> /// <param name="hostName">The Host Name.</param> /// <returns>The same <see cref="BindingSettings"/> instance so that multiple calls can be chained.</returns> public static BindingSettings SetHostName(this BindingSettings binding, string hostName) { binding.HostName = hostName; return(binding); }
/// <summary> /// Specifies the port number of the binding. /// </summary> /// <param name="binding">The binding.</param> /// <param name="port">The port number.</param> /// <returns>The same <see cref="BindingSettings"/> instance so that multiple calls can be chained.</returns> public static BindingSettings SetPort(this BindingSettings binding, int port) { binding.Port = port; return(binding); }
private void Act(string siteName, BindingSettings bindingSettings) { WebsiteManager manager = CakeHelper.CreateWebsiteManager(); manager.AddBinding(siteName, bindingSettings); }
/// <summary> /// Specifies the certificate store name of the binding. /// </summary> /// <param name="binding">The binding.</param> /// <param name="certificateStoreName">The certificate store name.</param> /// <returns>The same <see cref="BindingSettings"/> instance so that multiple calls can be chained.</returns> public static BindingSettings SetCertificateStoreName(this BindingSettings binding, string certificateStoreName) { binding.CertificateStoreName = certificateStoreName; return(binding); }
/// <summary> /// Specifies the certificate has of the binding. /// </summary> /// <param name="binding">The binding.</param> /// <param name="certificateHash">The certificate hash.</param> /// <returns>The same <see cref="BindingSettings"/> instance so that multiple calls can be chained.</returns> public static BindingSettings SetCertificateHash(this BindingSettings binding, byte[] certificateHash) { binding.CertificateHash = certificateHash; return(binding); }
public WebsiteSettings() : base() { Bindings = new BindingSettings[] { IISBindings.Http }; }
internal BindingAspectDecoratorExpression(IAspectDefinition aspectDefinition, IArgumentsWeavingSettings argumentsWeavingSettings) { this.aspectDefinition = aspectDefinition; bindingSettings = aspectDefinition.ToBindingSettings(); this.argumentsWeavingSettings = argumentsWeavingSettings; }
private void SetBindingHandlerSettings(InputDeviceTree dev, IOutputMode outputMode, BindingSettings settings) { string group = dev.Properties.Name; var bindingHandler = new BindingHandler(outputMode); var bindingServiceProvider = new ServiceManager(); object pointer = outputMode switch { AbsoluteOutputMode absoluteOutputMode => absoluteOutputMode.Pointer, RelativeOutputMode relativeOutputMode => relativeOutputMode.Pointer, _ => null }; if (pointer is IVirtualMouse virtualMouse) { bindingServiceProvider.AddService <IVirtualMouse>(() => virtualMouse); } var tipbinding = bindingHandler.TipBinding = settings.TipButton?.Construct <IBinding>(); bindingServiceProvider.Inject(tipbinding); bindingHandler.TipActivationPressure = settings.TipActivationPressure; Log.Write(group, $"Tip Binding: [{bindingHandler.TipBinding}]@{bindingHandler.TipActivationPressure}%"); var eraserBinding = bindingHandler.EraserBinding = settings.EraserButton?.Construct <IBinding>(); bindingServiceProvider.Inject(eraserBinding); bindingHandler.EraserActivationPressure = settings.EraserActivationPressure; Log.Write(group, $"Eraser Binding: [{bindingHandler.EraserBinding}]@{bindingHandler.EraserActivationPressure}%"); if (settings.PenButtons != null) { for (int index = 0; index < settings.PenButtons.Count; index++) { var bind = settings.PenButtons[index]?.Construct <IBinding>(); if (!bindingHandler.PenButtonBindings.TryAdd(index, bind)) { bindingHandler.PenButtonBindings[index] = bind; bindingServiceProvider.Inject(bind); } } Log.Write(group, $"Pen Bindings: " + string.Join(", ", bindingHandler.PenButtonBindings)); } if (settings.AuxButtons != null) { for (int index = 0; index < settings.AuxButtons.Count; index++) { var bind = settings.AuxButtons[index]?.Construct <IBinding>(); if (!bindingHandler.AuxButtonBindings.TryAdd(index, bind)) { bindingHandler.AuxButtonBindings[index] = bind; bindingServiceProvider.Inject(bind); } } Log.Write(group, $"Express Key Bindings: " + string.Join(", ", bindingHandler.AuxButtonBindings)); } }
private void SetBindingHandlerSettings(InputDeviceTree dev, IOutputMode outputMode, BindingSettings settings, TabletReference tabletReference) { string group = dev.Properties.Name; var bindingHandler = new BindingHandler(outputMode); var bindingServiceProvider = new ServiceManager(); object?pointer = outputMode switch { AbsoluteOutputMode absoluteOutputMode => absoluteOutputMode.Pointer, RelativeOutputMode relativeOutputMode => relativeOutputMode.Pointer, _ => null }; if (pointer is IMouseButtonHandler mouseButtonHandler) { bindingServiceProvider.AddService(() => mouseButtonHandler); } var tip = bindingHandler.Tip = new ThresholdBindingState { Binding = settings.TipButton?.Construct <IBinding>(bindingServiceProvider, tabletReference), ActivationThreshold = settings.TipActivationThreshold }; if (tip.Binding != null) { Log.Write(group, $"Tip Binding: [{tip.Binding}]@{tip.ActivationThreshold}%"); } var eraser = bindingHandler.Eraser = new ThresholdBindingState { Binding = settings.EraserButton?.Construct <IBinding>(bindingServiceProvider, tabletReference), ActivationThreshold = settings.EraserActivationThreshold }; if (eraser.Binding != null) { Log.Write(group, $"Eraser Binding: [{eraser.Binding}]@{eraser.ActivationThreshold}%"); } if (settings.PenButtons != null && settings.PenButtons.Any(b => b?.Path != null)) { SetBindingHandlerCollectionSettings(bindingServiceProvider, settings.PenButtons, bindingHandler.PenButtons, tabletReference); Log.Write(group, $"Pen Bindings: " + string.Join(", ", bindingHandler.PenButtons.Select(b => b.Value?.Binding))); } if (settings.AuxButtons != null && settings.AuxButtons.Any(b => b?.Path != null)) { SetBindingHandlerCollectionSettings(bindingServiceProvider, settings.AuxButtons, bindingHandler.AuxButtons, tabletReference); Log.Write(group, $"Express Key Bindings: " + string.Join(", ", bindingHandler.AuxButtons.Select(b => b.Value?.Binding))); } if (settings.MouseButtons != null && settings.MouseButtons.Any(b => b?.Path != null)) { SetBindingHandlerCollectionSettings(bindingServiceProvider, settings.MouseButtons, bindingHandler.MouseButtons, tabletReference); Log.Write(group, $"Mouse Button Bindings: [" + string.Join("], [", bindingHandler.MouseButtons.Select(b => b.Value?.Binding)) + "]"); } var scrollUp = bindingHandler.MouseScrollUp = new BindingState { Binding = settings.MouseScrollUp?.Construct <IBinding>(bindingServiceProvider, tabletReference) }; var scrollDown = bindingHandler.MouseScrollDown = new BindingState { Binding = settings.MouseScrollDown?.Construct <IBinding>(bindingServiceProvider, tabletReference) }; if (scrollUp.Binding != null || scrollDown.Binding != null) { Log.Write(group, $"Mouse Scroll: Up: [{scrollUp?.Binding}] Down: [{scrollDown?.Binding}]"); } }
/// <summary> /// Specifies whether or not Server Name Indication (SNI) is required. /// </summary> /// <param name="binding">The binding.</param> /// <param name="requireServerNameIndication">Whether or not Server Name Indication should be required</param> /// <returns>The same <see cref="BindingSettings"/> instance so that multiple calls can be chained.</returns> public static BindingSettings RequireServerNameIndication(this BindingSettings binding, bool requireServerNameIndication) { binding.RequireServerNameIndication = requireServerNameIndication; return(binding); }