Commit 30f7bfd
Changed files (4)
build
config
product
Gorilla.Commons.Windows.Forms
build/config/AssemblyInfo.cs
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly : AssemblyCulture("")]
[assembly : ComVisible(false)]
[assembly : Guid("89f1a34a-1375-4eeb-a250-86774c9448b0")]
-[assembly : AssemblyVersion("2009.5.12.2030")]
-[assembly : AssemblyFileVersion("2009.5.12.2030")]
\ No newline at end of file
+[assembly : AssemblyVersion("2009.5.13.1246")]
+[assembly : AssemblyFileVersion("2009.5.13.1246")]
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms/Helpers/BindableTextBoxFactory.cs → product/Gorilla.Commons.Windows.Forms/Helpers/BindableTextBoxExtensions.cs
@@ -4,22 +4,19 @@ using Gorilla.Commons.Utility.Extensions;
namespace Gorilla.Commons.Windows.Forms.Helpers
{
- static public class BindableTextBoxFactory
+ static public class BindableTextBoxExtensions
{
- static public IBindableTextBox<ItemToBindTo> create_for<ItemToBindTo>(ITextControl<ItemToBindTo> text_control, params ITextBoxCommand<ItemToBindTo>[] commands)
+ static public IBindableTextBox<ItemToBindTo> apply<ItemToBindTo>(this ITextControl<ItemToBindTo> text_control, params ITextBoxCommand<ItemToBindTo>[] commands)
{
var textbox = new BindableTextBox<ItemToBindTo>(text_control);
commands.each(x => textbox.on_leave(y => x.run(y)));
return textbox;
}
- }
- static public class BindableTextBoxExtensions
- {
static public IBindableTextBox<ItemToBindTo> rebind_with<ItemToBindTo>(
this ITextControl<ItemToBindTo> text_control, Expression<Func<string, ItemToBindTo>> rebind)
{
- return BindableTextBoxFactory.create_for(text_control, new RebindTextBoxCommand<ItemToBindTo>(rebind));
+ return text_control.apply(new RebindTextBoxCommand<ItemToBindTo>(rebind));
}
}
}
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms/Helpers/BindableTextBoxExtensionsSpecs.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Windows.Forms;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Windows.Forms.Helpers
+{
+ public class BindableTextBoxExtensionsSpecs
+ {
+ }
+
+ [Concern(typeof (BindableTextBoxExtensions))]
+ public class when_binding_a_text_control_to_a_command : concerns
+ {
+ it should_run_each_command_when_the_text_changes_in_the_text_control = () => command.was_told_to(x => x.run(result));
+
+ context c = () =>
+ {
+ textbox = new TextBox();
+ command = an<ITextBoxCommand<string>>();
+ };
+
+ because b = () =>
+ {
+ result = new TextControl<string>(textbox).apply(command);
+ textbox.control_is(x => x.OnLeave(new EventArgs()));
+ };
+
+ static TextBox textbox;
+ static ITextBoxCommand<string> command;
+ static IBindableTextBox<string> result;
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms/Gorilla.Commons.Windows.Forms.csproj
@@ -81,7 +81,8 @@
<Compile Include="Helpers\BindableListExtensions.cs" />
<Compile Include="Helpers\BindableListFactory.cs" />
<Compile Include="Helpers\BindableTextBox.cs" />
- <Compile Include="Helpers\BindableTextBoxFactory.cs" />
+ <Compile Include="Helpers\BindableTextBoxExtensions.cs" />
+ <Compile Include="Helpers\BindableTextBoxExtensionsSpecs.cs" />
<Compile Include="Helpers\BindableTextBoxSpecs.cs" />
<Compile Include="Helpers\BitmapRegion.cs" />
<Compile Include="Helpers\ButtonExtensions.cs" />