HttpWebRequest.AllowReadStreamBuffering = false... Still buffering up to 4kb!

by Patrice 6/26/2008 6:58:00 AM

So why when you set it to "false" it doesn't seem to take effect?

This wasn't easy to guess... and this property is new in Beta 2 so not so much "discussion" on the web about it. After few hours stolen from my sleep time, I've found that the BeginGetResponse callback parameter will be called only when you'll have at least 4kb "buffered"... (is this "by design"?)...after 4kb of data received, you can receive a single byte at a time if you need to!

Look at my post on Silverlight forum for more details.

 

Update: This problem is specific to IE. It works in Firefox... but I have found another issue with Firefox; if you set a custom header webrequest.Headers["custom"]="custom" , AllowReadStreamBuffering won't work.... no effect... it will wait until the stream is all arrived.

Damn! Expression Blend 2.5 June Preview allow Template editing from Silverlight projects

by Patrice 6/9/2008 7:26:59 AM

In last my post about "Silverlight Project Structure" in Visual Studio, I talked about how Jose Fajardo was defining his project's structure and how it seems being a good approach. One problem, as Jose mentioned, was that "templates" edition weren't supported by VS-Blend combo. The solution was just to create a regular UserControl (so editable in Blend) and copy&paste the content in the app.xaml TemplateControl section (considering a "global" template).

If you got it right-on, that was good but after few copy&paste it became annoying. I was tired of editing my templates manually... manually as in "edit UserControl in Blend, open app.xaml, copy & paste UserControl code into the the TemplateControl section".

So I've started "googling" on "Visual Studio addon"... and it pointed me to the Visual Studio Extensibilty (VSX) web site... I've downloaded the SDK, tried the "wizard" project, modified it here and there, done some tests...

 

I ended up with a nice addon that converts my UserControl to TemplateControl by right-clicking my XAML file. Wow, that was much more effecient then a copy&paste...

 

 

 

 

 

 

 

 

All this to say that I was going to publish in more details my VS addon code and description project but after the last byte of Expression Blend 2.5 June Preview and Silverlight 2 Beta 2 releases, it's now irrelevant...

Missing ToTitleCase from TextInfo (Silverlight)

by Patrice 5/4/2008 12:35:00 AM

The other day I was converting some "utility" classes to be used within my Silverlight project and I realized (well, the compiler told me) that the ToTitleCase method was missing from System.Globalization.TextInfo. So I created one that ended up being more useful then the original one (well, for my own usage).

The default utility of ToTitleCase is obviously to change the first letter to uppercase and the rest to lowercase (mine can take a complete sentence too). Then a friend of mine gave me a case where it wouldn't work. Take for example "Merriam-Webster"; the W after the dash will be lower case. That's why I added a parameter to my ToTitleCase method, a character list, that are used as "uppercase after this character". The default value is naturally " " (space).

While I was there, I used the new Method Extensions feature.  So it can be used like:

"this sentence to titlecase".ToTitleCase(); 

 

   1:  public static  class UtilsClient
   2:  {
   3:      public static string ToTitleCase(this string value)
   4:      {
   5:          return ToTitleCase(value, new List<char> { ' ' });
   6:      }
   7:   
   8:      public static string ToTitleCase(this string value, List<char> separators)
   9:      {
  10:          string result = "";
  11:          bool nextUpper = true; //first letter always upper case
  12:   
  13:          value = value.ToLower();//initialize all to lower case
  14:   
  15:          for (int charIndex = 0; charIndex < value.Length; charIndex++)
  16:          {
  17:              string nextChar = value[charIndex].ToString();
  18:              if (nextUpper)
  19:              {
  20:                  nextChar = nextChar.ToUpper();
  21:              }
  22:   
  23:              result += nextChar;
  24:   
  25:              if (separators.Any(c => c.Equals(value[charIndex])))//put next char to upper case
  26:                  nextUpper = true;
  27:              else
  28:                  nextUpper = false;
  29:   
  30:          }
  31:   
  32:          return result;
  33:      }
  34:  }

Silverlight Project Structures : Design vs. Business Logic ( or UI vs. UX )

by Patrice 5/2/2008 11:07:00 PM

Since I've been experimenting with Silverlight V2.0 Beta1 (business logic in V1.0 was mostly JavaScript code, so mostly the same structure as regular web development), I've just played around by testing snippets of code in "test" projects. Now that I try to build more serious projects, I struggle on how structuring my project. I know, it might sounds stupid but Silverlight is not  Winform nor ASP.NET...or a little of both.

As much as people like to talk about the separation between design and business logic, I think it's a personal thing (as in "you", "your team" or "your company"). When the language/platform allows the developer to write "design" part in the business logic side and some business logic in the design side, it always ends up with "spaghetti" code. I remember classic ASP when we were mixing the client side JavaScript and the server side JavaScript code between HTML tags (supposedly the design part)... and when ASP.NET arrived it was supposed to be "the" answer for "spaghetti" code... I think I've seen worst in ASP.NET then ASP... design part done by spitting HTML strings from server controls. Even if it's the core of ASP.NET (hide the HTML spitting from the developers), there are a better ways of doing this (but anyway that's old technology, LOL).

With Silverlight, there is no "server side" code... but there is still a layer separation: user interface (UI) vs. user experience (UX).  So, we are faced again with the same interrogations... for example, should I write my "animation" in directly in XAML or create it dynamically from C#?  I'll find my way through experimentations...

I read Jose Fajardo blog frequently and two weeks ago he wrote about his preferred way of structuring his Silverlight projects. I really like it. I'll "borrow" his idea and start my new project with this structure. We'll see how much I'll keep the original form.

Powered by BlogEngine.NET 1.3.1.0

LFDX Software Inc.

About the author

P. Lafond Patrice Lafond
(and yes, it's Mr!)
Software Engineer
French Canadian expat in Bermuda for over 7 years.
flag QC  flag BDA

E-mail me Send mail

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2009

    Sign in