Posted by
jasper22
at
15:34 |
Friday, July 1, 2011
Description
Real-life sharing rethought for mobile.
Google+ (Google Plus) is still in active development and not yet available to everyone. You need an invitation to sign in.
Google+ for mobile makes sharing the right things with the right people a lot simpler. Huddle lets you send super-fast messages to the people you care about most. With your permission, Instant Upload automatically puts the photos and videos you take into a private album in the cloud, so you can share them anytime, from anywhere. And no matter where you are, the stream lets you stay in the loop about what your friends are sharing and where they’re checking in.
ברוח הרשת החברתית החדשה שהשיקה גוגל השבוע, החליטה החברה לרענן גם את הממשקים הקיימים שלה, וביניהם לוח השנה והדואר האלקטרוני המוכרים לכולם.
נראה כי החברה החליטה ללכת על קו אחיד, נקי ואלגנטי ל"סט המוצרים" שלה, ומנסה להפוך את הגלישה בכל דפי החברה לאחידה ונעימה לעין.
עיצוב חדש
העיצוב החדש שמציעה גוגל לדואר האלקטרוני זהה לחלוטין לעיצוב של הרשת החברתית החדשה שלה, גוגל פלוס. דף לבן עם סרגלי כלים אפורים, ומעט אדום וכחול לצורך הדגשת כפתורים עיקריים כגון חיפוש בתוך המייל ויצירת הודעה חדשה. בעוד שהעיצוב דיי מקל על קריאת הודעות חדשות וניווט ברחבי המייל, הוא עדיין נראה בשלבים הראשונים שלו ונדמה כי יש עוד הרבה עבודה עד שיהיה מושלם.
גוגל הודיעה בבלוג הרשמי שלה שהיא תעבוד בהדרגה על העיצובים החדשים במהלך החודשים הקרובים. כרגע ניתן לצפות בקדימון של העיצוב המתוכנן, על ידי כניסה ללשונית ה-Themes, ובתחתית העמוד מופיעות לנו שתי ערכות עיצוב חדשות, Preview ו-Preview Dense שבמבט ראשוני אולי נראות זהות, אך הראשונה מציעה מבט מעט יותר מרווח של דף הג'ימייל.
Posted by
jasper22
at
13:11 |
Thursday, June 30, 2011
------- This email message and any attachments thereto are intended only for use by the addressee(s) named above, and may contain legally privileged and/or confidential information. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the jjasper22@gmail.com and destroy the original message.
Debugging memory leak is a must-have skill for most server side app developers especially when you move to cloud. Usually you don't have luxury to attach debugger to the running process on the server. Even if you have the luxury, it might not be as easy as you think. A good solution to this problem which many developers are using is getting memory dump for the process in which you suspect there is memory leak and then debugging it with windbg. In summary, the below are reasons for using windbg to debug managed code memory leak with memory dump. 1. It is needed for server side applications and especially cloud applications 2. Creating memory dump is easy and you can analyze it offline as long as you want 3. Windbg is powerful, relatively lightweight and free!
This task is not as hard as it sounds like. I just simply used the below 9 steps to debug one possible memory leak at work a while back. 1. .symfix and .reload -f 2. .loadby sos mscorwks! 3. !VerifyHeap 4. !EEHeap 5. !dumpheap -stat 6. !dumpheap -type 7. !do 8. !threads 9. kb
Let's see how I debug the memory leak easily one step by one step. I will give brief description for each step. 1. .symfix and .reload -f The idea here is finding correct symbols. If .symfix doesn't work, you will need to set the symbol path manually from the menu or use .sympath. This is important and make sure to do it right. Debugging without symbols is harder and very inconvenient.
2. .loadby sos mscorwks sos is the debugger extension for managed coding debugging. Type !help to see what command are available and how to use them. The help is really useful and do read it. The commands are case insensitive and there are also shortcuts for some commands. Read more: Paul Lou's blog QR:
Be nice to be able to make wildcard certificates for use in development with makecert – turns out, it’s real easy. Just ensure that your CN= is the wildcard string to use.The following sequence generates a CA cert, then the public/private key pair for a wildcard certificate REM make the CA rem CA Certificate: makecert -r -pe -n "CN=AA Contoso Test Root Authority" -ss CA -sr CurrentUser -a sha1 -sky signature -cy authority -sv CA.pvk CA.cer -len 2048 REM now make the server wildcard cert makecert -pe -n "CN=*.contosotest.com" -a sha1 -len 2048 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -ic CA.cer -iv CA.pvk -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -sv wildcard.pvk wildcard.cer pvk2pfx -pvk wildcard.pvk -spc wildcard.cer -pfx wildcard.pfxRead more: Shawn Cicoria QR:
The integral types WPARAM, LPARAM, and LRESULT are 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems. What happens when a 32-bit process sends a message to a 64-bit window or vice versa? There's really only one choice when converting a 64-bit value to a 32-bit value: Truncation. When a 64-bit process sends a message to a 32-bit window, the 64-bit WPARAM and LPARAM values are truncated to 32 bits. Similarly, when a 64-bit window returns an LRESULT back to a 32-bit sender, the value is truncated. But converting a 32-bit value to a 64-bit value introduces a choice: Do you zero-extend or sign-extend?The answer is obvious if you remember the history of WPARAM, LPARAM, and LRESULT, or if you just look at the header file. The WPARAM is zero-extended, while LPARAM and LRESULT are sign-extended.If you remember that WPARAM used to be a WORD and LPARAM and LRESULT used to be LONG, then this follows from the fact that WORD is an unsigned type (therefore zero-extended) and LONG is a signed type (therefore sign-extended). Read more: The old new thing QR:
This is part one in a series of blog-posts about best practices for writing C libraries. Base libraries Since libc is a fairly low-level set of libraries, there exists higher-level libraries to make C programming a more pleasant experience including libraries in the GLib and and GTK+ stack. Even while the following is going to be somewhat GLib- and GTK+-centric, these notes are written to be useful for any C code whether it's based on libc, GLib or other libraries such as NSPR, APR or some of the Samba libraries. Most programmers would agree that it's usually a bad idea to implement basic data-types such as string handling, memory allocation, lists, arrays, hash-tables or queues yourself just because you can - it only makes code harder to read and harder to maintain by others. This is where C libraries such as GLib and GTK+ come into play - these libraries provides much of this out of the box. Plus, when you end up needing non-trivial utility functions (and chances are you will) for, say, Unicode manipulation, rendering complex scripts, D-Bus support or calculating checksums, ask yourself (or worse: wait until your manager or peers ask you) if the decision to avoid a well-tested and well-maintained library was a good decision. In particular, for things like cryptography, it is usually a bad idea to implement it yourself (however inventing your own algorithm is worse); instead, it is better to use an existing well-tested library such as NSS (and even if you do, be careful of using the library correctly). Specifically, said library may even be FIPS-140 certified which is a requirement if you want to do business with the US government. Read more: inactivity log for davidz QR:
My previous post outlined the benefits of automated code analysis and introduced the Delay.FxCop custom code analysis assembly. The initial release of Delay.FxCop included only one rule, DF1000: Check spelling of all string literals, which didn't seem like enough to me, so today's update doubles the number of rules! :) The new rule is DF1001: Resources should be referenced - but before getting into that I'm going to spend a moment more on spell-checking... What I planned to write for the second code analysis rule was something to check the spelling of .NET string resources (i.e., strings from a RESX file). This seemed like another place misspellings might occur and I'd heard of other custom rules that performed this same task (for example, here's a sample by Jason Kresowaty). However, in the process of doing research, I discovered rule CA1703: Resource strings should be spelled correctly which is part of the default set of rules! To make sure it did what I expected, I started a new application, added a misspelled string resource, and ran code analysis. To my surprise, the misspelling was not detected... However, I noticed a different warning that seemed related: CA1824: Mark assemblies with NeutralResourcesLanguageAttribute "Because assembly 'Application.exe' contains a ResX-based resource file, mark it with the NeutralResourcesLanguage attribute, specifying the language of the resources within the assembly." Sure enough, when I un-commented the (project template-provided) NeutralResourcesLanguage line in AssemblyInfo.cs, the desired warning showed up: CA1703 : Microsoft.Naming : In resource 'WpfApplication.Properties.Resources.resx', referenced by name 'SampleResource', correct the spelling of 'mispelling' in string value 'This string has a mispelling.'. In my experience, a some people suppress CA1824 instead of addressing it. But as we've just discovered, they're also giving up on free spell checking for their assembly's string resources. That seems silly, so I recommend setting NeutralResourcesLanguageAttribute for its helpful side-effects! Note: For expository purposes, I've included an example in the download: CA1703 : Microsoft.Naming : In resource 'WpfApplication.Properties.Resources.resx', referenced by name 'IncorrectSpelling', correct the spelling of 'mispelling' in string value 'This string has a single mispelling.'. Read more: Delay's Blog QR:
I prefer to use vim for most of my systems administration and programming related editing tasks. Aside from the usual argument that it will be present on any *nix system worth its silicon that you log in to, I choose it because of the succinct and expressive power of its syntax. While I am still learning new commands and techniques all the time, and while it is true that the learning curve to be anything resembling proficient is rather steep, few editors can boast such a wide range of actions in so few commands. Right of out the box, however, vim isn’t as suited to editing Python code as it could be. In fact, it’s rather annoying to write Python code with an uncustomized instance of vim. What follows is a description of how to put into place what I see as the most essential features of the editor one chooses to write code, especially Python code, in as manifested with vim. With the following changes, you can create a highly customized and powerful IDE, allowing you to increase your productivity without purchasing a commercial offering. Before the good stuff, a few requirements. You need to make sure you have vim-full and vim-python installed. Some systems come with vim-minimal, which is lacking in many advanced features. These packages should be in most repositories. Aside from these package installs, configuration changes described are made in ~/.vimrc. A quick word on the syntax of this file. Double quotation marks denote a line as a comment. I make it a rule to place a comment line before every configuration line or block thereof, so I have some sense later of what the change was for (it’s amazing how fast syntax leaks out of my head when I don’t use it regularly). Regarding Python files, I eventually also began to collect the related customizations into a file “~/.vim/ftplugin/python.vim”. This is loaded whenever Python type files are opened, and allows me to isolate related configurations. Syntax highlightingHaving code displayed with proper highlighting of the logical components makes reading that code easier to read and understand. Any decent code editor allows for coloring particular to a number of languages, and vim is no exception. To get this working, simply add: syntax on Read more: tail -f findings.out QR:
The HTMLOur page will consist of 6 sections: header, footer and 4 articles. On the right, we’ll place an unordered list that links between the articles and remains fixed on the page so it doesn’t move. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" ></script> <script type="text/javascript" src="scripts/nbw-parallax.js"></script> <script type="text/javascript" src="scripts/jquery.inview.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#nav').localScroll(); }) </script>To start, at the top of the page, we’ll reference all of the JavaScript files we’ll use to make the effect work. The scripts we’re using are: jQuery 1.4.4 The script written by Ian Lunn (which we’ll cover shortly) jQuery Inview (determines whether a particular article is in view)Inside of our body tag, we have the containers that will make up each article. <div id="intro"> <div class="story"> Article content here </div> <!--.story--> </div> <!--#intro--> Read more: Despiration QR:
Several people have asked me about using data annotations for validation outside of a UI framework, like ASP.NET MVC or Silverlight. The System.ComponentModel.DataAnnotations assembly contains everything you need to execute validation logic in the annotations. Specifically, there is a static Validator class to execute the validation rules. For example, let's say you have the following class in a console mode application: public class Recipe { [Required] public string Name { get; set; } }You could validate the recipe with the following code:var recipe = new Recipe(); var context = new ValidationContext(recipe, serviceProvider: null, items: null); var results = new List<ValidationResult>();var isValid = Validator.TryValidateObject(recipe, context, results);if (!isValid) { foreach (var validationResult in results) { Console.WriteLine(validationResult.ErrorMessage); } }Result: "The Name field is required".You can construct the ValidationContext class without a service provider or items collection, as shown in the above code, as they are optional for the built-in validation attributes. The Validator also executes any custom attributes you have defined, and for custom attributes you might find the serviceProvider useful as a service locator, while the items parameter is a dictionary of extra data to pass along. The Validator also works with self validating objects that implement IValidatableObject. public class Recipe : IValidatableObject { [Required] public string Name { get; set; } public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { // ... } } Read more: Ode to code QR:
SSL and network monitoring aren’t the most compatible of partners – even with the most sophisticated detection infrastructure in the world, you’ll not derive many useful indicators from the barren randomness of encrypted traffic. Consider the plight of the Sguil sensor shown below:
The webserver’s use of SSL means that network-based incident detection is problematic. No amount of tuning of the sensor’s Snort instance will help it detect intrusion attempts – the only traffic it will see is HTTPS. Also, if an incident is detected by other means (e.g., customer notification, web server log file monitoring, etc.) the investigative value of Sguil’s full packet capture is greatly diluted. There are a number of ways to get back the visibility stolen by SSL, including the following. You could: Terminate the SSL “in front of” the webserver, perhaps on a reverse-proxying loadbalancer or web application firewall. You can then monitor the decrypted traffic between the loadbalancer and the webserver. Perform monitoring tasks on the webserver itself, perhaps by increasing the level of web and application logging. Give your existing sensor platforms the means to decrypt the SSL sessions.Each approach has its pros and cons; this article will show you how to leverage the latter technique to restore the eyesight of your blind Sguil sensors. SSL DecryptionWe first need to understand a little about the mechanics of SSL decryption; you can read about it in depth here. In a nutshell there are two conditions that must be met before we can proceed: The server must be using the RSA key exchange mechanism (see here, bottom of page, and here, section F.1.1.2). Fortunately, this is the most common form of key exchange for SSL based servers; if you’re using DSA keypairs or the Diffie-Hellman key exchange mechanism you’re probably out of luck. You must have access to the server’s private RSA key, and be able to copy it onto your Sguil sensor.The latter point means that the only SSL decryption we’re going to be able to pull off is decryption of traffic to and from servers that we own – we’re not going to be able to magically decrypt arbitrary SSL traffic (darn!) However, this is quite adequate from the viewpoint of intrusion detection and network forensics. Read more: InfoSec QR:
Posted by
jasper22
at
09:44 |
Tuesday, June 28, 2011
First, let me start that if you want a lot of people to download something, make sure that the words "HTML5," "Support" and "Update" appear in the title. I'm sure if the folks that are making Diablo 3 called it "Diablo 3 HTML5 Support Update" that a metric buttload more people would download it. That said, a bunch of folks in the Web Platform and Tools team created the Web Standards Update package with HTML5 Support for the Visual Studio 2010 Editor.This Web Standards Update is something that anyone in the community could have released, just extending Visual Studio in a standard way. Like many other (most) extensions in Visual Studio Extension Gallery, it was not "signed." It was not a formal project done by Microsoft. Ratherthis was something that a bunch of us did for the community in our after work hours. The only reason why this got in spotlight was because press caught the wind of it having HTML5 and CSS3 support. Certainly a lot of people wanted it because in 4 days it's now the #1 most popular thing in the Visual Studio Gallery. Take that NuGet! ;)Here's where the trouble starts. Then, it was written about in the press as if it were a "gaffe." I admit that we (mostly I) did a lousy mediocre job of making it clear that this update was a "community update from the inside," as it were. It's not official, but we're hoping support like this will make its way into the next version of Visual Studio. When you downloaded the MSI installer with IE9, as with all MSIs that aren't signed, you get a message like this:
And that's normal and quite lovely. Then we see this scary red bar (this is a shot from another gallery item):
This is the IE9 SmartScreen system warning us, rightfully so, that this is not something downloaded all the time. In fact, this is a really useful feature of IE9 and is fairly unique amongst the browsers so far. It's using some special sauce (some hash, some math, some metrics) to make a non-biased judgment about this download. Even though it's coming from a Microsoft.com website it doesn't matter. SmartScreen is unbiased. It's never seen this before, and it's not trusted. UPDATE: Looks like as of my test just now that SmartScreen now recognizes our download as safe! Read more: Scott Hanselman Computer Zen QR:
SilverlightShow starts launching its most successful article series as fully offline resources! Check out SilverlightShow Ebook area for all available ebook listings! The first two ebooks released are: XNA for Silverlight developers - a 14-part article series by Peter Kuhn Working with Collections in WCF RIA Services - a 2-part series by Kevin DockxEach ebook package contains a PDF and Word version of the series, packed with all source code. You may instantly download the ebooks right after payment. We'll be giving some ebooks for free in our webinars and upcoming trainings, so stay tuned for our news and announcements on Twitter, Facebook and LinkedIn!Read more: SilverlightShow QR:
לפני מספר ימים הוכרז על Patch חדש ל – Visual Studio 2010 SP1.ה – Patch מכיל תיקוני באגים בעיקר עבור כלי הבדיקות, רשימה מלאה של התיקונים נמצאת בסוף הפוסט. ניתן להוריד את ה – Patch מהלינק:http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=36847 יש להתקין Visual Studio 2010 SP1 לפני התקנת ה – Patch.צירפתי את תיאור הבעיות אותן פותר ה – Patch מאתר ההורדה:
An update rollup is available that resolves the following issues for the testing tools in Microsoft Visual Studio 2010 Service Pack 1 (SP1). Issue 1 When you run tests on the test agent that is installed on a computer that has Visual Studio 2010 SP1 installed, the tests may not run, and the following error message is logged:Attempted to access an unloaded AppDomain. (Exception from HRESULT: 0x80131014) Issue 2 When you run a playback of a Coded UI Test on certain Windows Presentation Foundation (WPF) controls, a Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException exception occurs, and then you receive the following error message: "Search may have failed at '<name>' <control type> as it may have virtualized children. If the control being searched is descendant of '<name>' <control type> then including it as the parent container may solve the problem." Notes One of the causes of this error message is that the WPF controls are deep in the UI control hierarchy. Therefore, the control cannot be addressed in the recorded QuerID UI control hierarchy in the UI map. After you install this update, the control can be addressed. Read more: Eran Ruso QR:
In a real world application, many-a-times it is required that the application performs a two-way communication i.e. the client application sends request to the service and then service should have capability to initiate action itself and send the data back to the client. In Silverlight, we can perform this kind of operation using Socket programming as well as using Duplex bindings. In Silverlight 4.0, we can do this using net.tcp binding. In this small article, I have used Polling Duplex communication. In WCF service, duplex communication is implemented using PollingDuplexBinding. When you install Silverlight, you get the following path where the polling duplex assembly is stored: C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dllThe above assembly reference is used by the WCF Service for the Duplex communication mechanism and the assembly used by the Silverlight client application is available at: C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.ServiceModel.PollingDuplex.dllSince the communication between Silverlight 4 and WCF is performed using Http, the Silverlight client has to send the request to the service to initiate the communication. Once this connection is established, the PollingDuplexBinding allows the established channel to keep alive, until the timeout occurs. Let’s see a practical implementation in this articleStep 1: Open VS2010 and create a new Silverlight application, name it as ‘SL4_Duplex_Service’. You will now see the ‘SL4_Duplex_Service.Web’ host project. Step 2: In the Web host project, add a reference to the ‘System.ServiceModel.PollingDuplex.dll’ from the following path:C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll Step 3: In the Web host project, add a new Silverlight enabled WCF service and call it ‘MyService.svc’. Also in the project, add a new Interface file and name it as ‘IService.cs’, the same file will define the ServiceContract and OperationContract as shown below:
If you’re reading this, I probably don’t have to tell you about Freshmeat. This repository of open source code and projects has been around quite a while, and is used by a number of prominent projects. What you may not know, however, is that Freshmeat offers a well-designed Freshmeat API to help developers access the data on Freshmeat for any purpose that makes sense. The API is RESTful, and accepts inputs in either JSON or XML. It requires an authentication token, which every active Freshmeat account already has. If you have an account already, get yours here. If not, make yourself an account, then go there. The API is completely free to use, and the only limitation is a request limit of 600 requests per hour. For those who want even more simplicity, there’s a pretty good Perl library and a Ruby library for using the API. The documentation has a nice list of what one can access through the API: This API deals with data gathering and data entry for the following data types: Projects Comments Dependencies Project Filters Votings Releases Screenshots Subscriptions Tags URLs SearchNow, the question is, what would you build with it? Read more: ProgrammableWeb QR:
SortedSet is one class that is been added to the .Net class library 4.0 which actually merges the behaviour of HashSet and SortedList together. It maintains the sorted ordering of the list without affecting performance. Lets see how it works :SortedSet<int> sorted = new SortedSet<int> { 1, 43, 65, 23, 44, 56, 43, 1, 56, 66, 24 }; foreach(int number in sorted) { Console.WriteLine(number); } Console.Read(); Read more: Daily .Net Tips QR:
I'm stealing this story from one of my colleagues. I remember one app from a long time ago that had a feature where you could hit a global short cut key (or something like that) to launch the dictionary. It was also smart in that it would detect the current selected text and immediately search the dictionary for that term. One day I was running a Perl script that took several hours to run. It was nearly done and for whatever I decided to launch the dictionary. It sent a Ctrl+C to my Perl script and killed it. And that's why you don't send Ctrl+C to arbitrary applications. Active Accessibility gives you access to the text under the cursor. There's also a newer interface known as UI Automation which has a handy method called ITextProvider::GetSelection. (On the managed side, you have System.Windows.Automation.TextPattern.GetSelection.) Read more: The old new thing QR:
"Ref returns" are the subject of another great question from StackOverflow that I thought I might share with a larger audience.Ever since C# 1.0 you've been able to create an "alias" to a variable by passing a "ref to a variable" to certain methods: static void M(ref int x) { x = 123; } ... int y = 456; M(ref y);Despite their different names, "x" and "y" are now aliases for each other; they both refer to the same storage location. When x is changed, y changes too because they are the same thing. Basically, "ref" parameters allow you to pass around variables as variables rather than as values. This is a sometimes-confusing feature (because it is easy to confuse "reference types" with "ref" aliases to variables,) but it is generally a pretty well-understood and frequently-used feature. However, it is a little-known fact that the CLR type system supports additional usages of "ref", though C# does not. The CLR type system also allows methods to return refs to variables, and allows local variables to be aliases for other variables. The CLR type system however does not allow for fields that are aliases to other variables. Similarly arrays may not contain managed references to other variables. Both fields and arrays containing refs are illegal because making it legal would overly complicates the garbage collection story. (I also note that the "managed reference to variable" types are not convertible to object, and therefore may not be used as type arguments to generic types or methods. For details, see the CLI specification Partition I Section 8.2.1.1, "Managed pointers and related types" for information about this feature.) As you might expect, it is entirely possible to create a version of C# which supports both these features. You could then do things likestatic ref int Max(ref int x, ref int y) { if (x > y) return ref x; else return ref y; }Read more: Fabulous Adventures In Coding QR:
As I am tweeting around the facts on Nulls for last couple of days, I thought of writing a blog on that as many of you have already requested me on this regard. This post is basically dealing with Nulls and will go through only with basic C# stuffs, so for geeks, it is not recommended and you might end up knowing a little or almost nothing. So if you just here for time pass, then I refer to read on. Considering the fact Nulls appear on any objects, we have mainly two categories of programmable storage in .NET. Nullables (generally mutable with exceptions like strings) Value Types / struct (generally immutable) Nullables are types that either user defined or in framework in which one of its value can be null. .NET treats null specially. Say for instance :class Program { static void Main(string[] args) { X xobj = null; Y yobj = null; } }Here both xobj and yobj holds null, but you cannot equate xobj == yobj. It is illegal.Another important fact is Unassigned local values are not treated as null. .NET compiler throws exception when an unassigned variable is used. But if you declare the member of a class unassigned, it will automatically be assigned to null. Hence : static void Main(string[] args) { X xobj; Y yobj = null; xobj = xobj ?? new X(); } Read more: DOT NET TRICKS QR:
Project Description This is a Visual Studio add-in which builds Silverlight Library directly from standard .NET class library just by a simple right click. The idea is to simplify the management of two separate .csproj files pointing to same code base and soft linking between them. This version of BuildAsSilverlight is tested with the following environment only: .NET Runtime 4.0 Visual Studio 2010 Professional Silverlight 4UsageOpen any .NET Class library project. Right Click and click BuildAsSilverlight4 as shown below:
One of the interesting feature that is added with .NET 4.0 is the support of BigInteger. Big numbers are needed when a number cannot be held with any of the existing data types available with .NET framework. Long has the highest value of 9,223,372,036,854,775,807 which is 0x7FFFFFFFFFFFFFFF in hexadecimal. This is the highest value of a variable which you can store in .NET. Or rather you can say UInt64 to store the highest value of 18,446,744,073,709,551,615 if you don’t need negatives. But this is not actually sufficient when dealing with certain situations like dealing with yearly analytical reports, statistical data etc. BigInteger is a new type(struct) introduced in .NET 4.0 which deals with the situation and can store any value. To use it you need to add System.Numarics.dll.For instance :BigInteger binteger = new BigInteger(3824783785434543); Console.WriteLine(binteger);Here in the constructor I have specified the value with which the binteger is to be initialized. You can also use assignment operator and any operators with this object.BigInteger binteger = 3824783785434543; Console.WriteLine(binteger); Console.WriteLine(binteger > 32948454); Console.Read(); Read more: Daily .Net Tips QR:
IntroductionThis article explains a simple way to add mail support in your application. Just use the classes:POP3class methods: string DoConnect(String pop3host,int port, String user, String pwd) string GetStat() string GetList() string GetList(int num) string Retr(int num) string Dele(int num) string Rset() string Quit() string GetTop(int num) string GetTop(int num_mess, int num_lines) string GetUidl() string GetUidl(int num) string GetNoop() MessageClass methods: string GetFrom(string messTop) string GetDate(string messTop) string GetMessID(string messTop) string GetTo(string messTop) string GetSubject(string messTop) string GetBody(string AllMessage) Using the codeThe following sample illustrates how to use the classes: POP3class pop3; pop3 = new POP3class(); pop3.DoConnect("your.mail.server",110,"username","password"); pop3.GetStat(); // and if we have mail:MessageClass msg; msg = new MessageClass(); string sMessageTop = msg.GetTop(1); //OK, message is well, lets download it. Read more: Codeproject QR:
When Silverlight introduced it was considered as a Player Framework because of its capability to handle Rich media. This is one of the first technology to handle true 720p and 1080p HD media. Since its evolution, Silverlight 1 to Silverlight 5 the digital media experience improved a lot. So this post we will take a dig into media concepts and its integration with Silverlight along with various option available. This post will focus extensively on the Microsoft Media Platform Framework from Microsoft, a open source player framework and its implementation.Read more: Greg's Cool [Insert Clever Name] of the Day Read more: Enhancing Media Experience in Silverlight with Microsoft Media Platform (MMPPF) QR:
Everyone know that one of the keys to have a great SEO for your website is making sure you keep your website updated, new and fresh. Whether you do this with a blog, or you change your homepage with new offers, coupons or new products, it serves to show Google that your site is “alive.” For many small businesses in particular, this is a real challenge. So you already have great, fresh content on your site – what’s next? Do you know what is coming that may benefit your business? What are QR codes?QR codes (abbreviation for Quick Response code) are a popular type of two-dimensional barcode. They are also known as hardlinks or physical world hyperlinks. QR Codes store up to 4,296 alphanumeric characters of arbitrary text. This text can be anything, for example URL, contact information, a telephone number, even a poem! QR codes can be read by an optical device with the appropriate software. Such devices range from dedicated QR code readers to mobile phones. QR code for your site?There are various QR code generators available online but, generating QR code without using generators is also very easy. We will use Google Chart APIs to generate QR code for us. Creating QR code Google charts API allows us to generate QR code by passing various parameters to their API. Below is the short description of each parameter-
Name
Required?
Description
cht=qr
Yes
Specifies a QR code.
chs=<width>x<height>
Yes
Image size. (Remember it’s English alphabet ‘x’ and not cross ’X’ )
choe=<output_encoding>
No
How to encode the data in the chart. Here are the available values: UTF-8 [Default] Shift_JIS ISO-8859-1
I recently got a bug report from a user who was attempting to use Fiddler in a pure-IPv6 environment, where IPv4 is entirely disabled. On startup, he saw the following message:The problem here is an obscure one, which makes it somewhat interesting. What’s happening is that Fiddler is trying to create an IPv4 listener socket listening on port 8888 locally. However, because this is a pure IPv6 environment, permission to create such a socket is denied. By default, Fiddler will create an IPv4 listen socket unless the following three criteria are met: The computer supports IPv6 (Vista+ support it by default; various installs are required for XP) The Enable IPv6 option is ticked inside Tools > Fiddler Options > General The Allow remote computers to connect option is set inside Tools > Fiddler Options > ConnectionsNow, the first two requirements are somewhat self-explanatory, but the third bears some explanation. If only the first two requirements are met, Fiddler will be able to connect to IPv6 sites, but the browser will only be able to connect to Fiddler using IPv4. The reason that the third requirement exists is that some clients (particularly IE6’s WinINET, and likely others) don’t support IPv6-literal proxy addresses, and hence attempting to poke [::1]:8888 into the system proxy settings would fail for such clients. So, Fiddler cannot safely bind to IPAddress.IPv6Loopback, and will bind to IPAddress.Loopback instead. However, if you enable the Allow remote computers to connect option, Fiddler will instead bind to IPAddress.IPv6Any which allows connecting on both IPv4 and IPv6 addresses on any adapter. Read more: Fiddler Web Debugger
שלום לכולם,כאן דן ויזנפלד מצוות התמיכה של Microsoft.כמעט כל אחד מאתנו עושה שימוש במידע אישי, שמסיבה כזו או אחרת, הוא אינו מעוניין לאפשר למשתמשים אחרים גישה אליו. פתרונות האבטחה שמוצעים היום בשוק (חומות אש ותוכנות אבטחה שונות) יכולים לסייע לכם במצבים בהם קיימת כוונה של פורץ כזה או אחר לגשת למידע האישי שלכם מרחוק (וגם כן, לא בכל המצבים).עם זאת, אף אחד מהפתרונות הללו לא יכול להגן עליכם במצב בו לאותו פורץ יש גישה פיזית ישירה למחשב שלכם. Microsoft הציגה במערכות ההפעלה האחרונות (בכל הגרסאות העסקיות של מערכות ההפעלה החל מ-Windows 2000) יכולת הצפנה מתקדמת ביותר, הידועה בשם EFS – Encrypted File System.במדריך הבא (המחולק לשני חלקים), אבקש להסביר לכם יותר על שיטת ההצפנה הזו – בטרם נלמד כיצד להפעילה וכיצד להשתמש בה. למה חשוב להכיר את המנגנון לעומק?1. בכדי למנוע מצבים טרגיים נפוצים בהם מצפינים קבצים מסוימים בצורה לא נכונה, ולאחר מכן לא ניתן לפתוח יותר את אותם הקבצים.2. בכדי למנוע מצבים טרגיים לא פחות בהם ההצפנה בוצעה בצורה לא תקינה, ומידע שחשבתם שהוא מוצפן ומאובטח – בעצם גלוי לעיני כל. טוב, אז לאחר שהבנו את חשיבות ההיכרות עם מנגנון ההצפנה, נלמד טיפה יותר על איך הוא עובד. אבל לפני שאגע ואסביר כיצד עובד המנגנון, חשוב להכיר כמה מונחים בסיסיים בתורת הקריפטוגרפיה:הצפנה סימטרית –שיטת הצפנה בה המפתח בו נעשה שימוש על מנת להצפין את המידע, הוא היחיד שגם יכול לשמש למטרת פענוח המידע שהוצפן. כלומר, אם הצפנתי מידע באמצעות מפתח מסוים, עלי להעביר את אותו המפתח לנמען שלי יחד עם המידע שהוצפן, על מנת שהוא יוכל לפענח אותו. הצפנה א-סימטרית –שיטת הצפנה בה המפתח בו נעשה שימוש על מנת להצפין את המידע הוא אינו המפתח בו נעשה שימוש על מנת לפענח את המידע.
Module is a simple container of values, types definition and sub modules. There are two types of modules. Local modules and top level ones. The following video clips show how to define them. You can find the source code as part of my F# Fundamentals course. Its community version is available for free personal usage at www.abelski.com. Read more: Life Michael
IntroductionI started recently setting up a TeamCity 6.5 server on a Windows 2008 R2 machine. The install was straight forward, but unfortunately TeamCity doesn’t use a mainstream database server out of the box. The good news is that you can configure TeamCity to use a different database server to run the TeamCity repository. I decided to use MySQL. This blog post has detailed steps for switching TeamCity to MySQL. Why would someone want to switch to MySQL? PerformanceThe most important reason is performance. Moving to a database server that is enterprise grade and located on a separate machine is boosting TeamCity response times significantly. IntegrationThe second reason is integration. I am working on a prototype of a WordPress plug-in called LabPress that needs to be able to access TeamCity tables directly. Step by stepBefore we start here is a link to the TeamCity Documentation for switching the database engine. Important Note: The following steps assume that you start from a clean TeamCity 6.5 system or you don’t need to migrate existing build configurations and projects to the new database. Step 0Install TeamCity 6.5 and MySQL, and optionally phpMyAdmin to administer MySQL via a web browser. The TeamCity install is straight forward. MySQL can be installed conveniently via the Microsoft Web Platform Installer. Read more: Tellingmachine
The F# programming language supports many of the well known object oriented possibilities we know in C#. The following video clips show some of these capabilities. You can find the source code as part of my F# Fundamentals course. Its community version is available for free personal use at www.abelski.com. Read more: Life Michael
Theory behind WCF Tracing is not an exception of classical definition of Tracing. Through Tracing an application provides information about itself. Information may vary from internal state of object to passed input parameter to method. This information should be logged, persisted or saved somewhere. WCF Tracing can be used for the instrumentation of the WCF Service.There are essentially four steps involved in WCF Tracing
Emitting Trace information from ServiceTo emit trace information WCF provides different sources. However you have choice to create trace source using TraceSource class as well. You can choose any of WCF Assembly level trace source to emit the tracing information. WCF Assembly level Trace Sources are as below, System.ServiceModel System.ServiceModel.MessageLogging System.ServiceModel.IdentityModel System.ServiceModel.Activation System.Runtime.Serilization System.IO.LogRead more: DEBUG MODE……
IntroductionEvery WPF developer knows the situation where you have a large line-of-business application, you’ve implemented all the features and when you finally run it on real data – it runs s-l-o-w. Optimization Time!Optimization for performance is fun since a 1% change of code gets you 99% change in performance. However, finding the one location you should change can be a pain.This is why we’ve invented performance profilers. Profilers can help you pin-point the problem. WPF?WPF applications performance problems can usually be categorized to several kinds, for example, layout related, rendering related, etc. Following is a nice list of common places to optimize when you work with WPF applications. Microsoft provides a profiler specifically tuned for finding WPF related issues. You can find the installation guidelines on MSDN.Note: if this is the first time you use it, and you don’t get the data, try the patch mentioned in this post. When the profiler does work, it produces very interesting information. For example, in the following image we can see the visual tree on the left and in it the hot element (painted red) where a lot of CPU cycles went (either due to rendering or layout). Read more: Arik Poznanski's Blog
This post demonstrates the use of a digital signing function to ensure data within a table is unaltered outside a given set of stored procs. To understand how these and other crytographic functions can be employed to improve the security of database applications, please review this post. The first step in the demonstration is to create an empty database within which sensitive data will be housed:USE master; GO
IF EXISTS (SELECT * FROM sys.databases WHERE name = ‘SigningFunctionDemo’) DROP DATABASE SigningFunctionDemo; GOCREATE DATABASE SigningFunctionDemo; GONext, a table will be created to house some sensitive data. It’s important to note that for this demonstration, the data is not being encrypted but it could be to make unauthorized access and modifications more challenging: USE SigningFunctionDemo; GO
CREATE TABLE dbo.MySensitiveData ( Id INT NOT NULL IDENTITY(1,1), MyData NVARCHAR(25) NOT NULL, MySignature VARBINARY(256) NOT NULL ); GOTo support signing, an asymmetric key will be created along with two stored procedures making the signing and verification calls on behalf of the application: CREATE ASYMMETRIC KEY MySigningKey WITH ALGORITHM = RSA_2048 ENCRYPTION BY PASSWORD = N’asd!i36oheQ#wr8iW#%qwei4!orqhq9w7as’; GO
CREATE PROC dbo.spPutData @MyData NVARCHAR(25) AS INSERT INTO dbo.MySensitiveData (MyData, MySignature) SELECT @MyData, SIGNBYASYMKEY( ASYMKEY_ID(‘MySigningKey’), @MyData, N’asd!i36oheQ#wr8iW#%qwei4!orqhq9w7as’ ); GO
CREATE PROC dbo.spGetData @Id int AS SELECT MyData, VERIFYSIGNEDBYASYMKEY( ASYMKEY_ID(‘MySigningKey’), MyData, MySignature ) AS IsValid FROM dbo.MySensitiveData WHERE Id = @Id; GOWith this in place, data can now be placed into the database along with a signature: EXEC dbo.spPutData N’This is my sensitive data’ GOAccessing the table directly, the data and its signature can be seen:SELECT * FROM dbo.MySensitiveData GORead more: MSDN Blogs
Herb Sutter recently announced C++ AMP at the AMD Fusion Developer Summit as part of his keynote. Here, Daniel Moth, a program manager on Microsoft's Parallel Computing Platform Team, digs deeper into C++ AMP with code samples and more. Please download the slides from the link below as the recording of this session doesn't do them justice. Big thanks to AMD for providing Channel 9 with this excellent content!To get full performance out of mainstream hardware, high-performance code needs to harness, not only multi-core CPUs, but also GPUs (whether discrete cards or integrated in the processor) and other compute accelerators to achieve orders-of-magnitude speed-up for data parallel algorithms. How can you as a C++ developer fully utilize all that heterogeneous hardware from your Visual Studio environment? How can your code benefit from this tremendous performance boost without sacrificing your developer productivity or the portability of your solution? The answers will be presented in this session that introduces a new technology from Microsoft. Read more: Channel9
In the event you got lulled into a groovy seat dance by that most excellent muzak above, let us repeat - this app does not protect your lockscreen. That said, Visidon's Applock will prevent the privacy-adverse from messing with your personally curated app collection. Have a nosy significant lover? No sweat -- snap a pick with your front-facing cam, enable the face-lock in your settings, and those sexts are as good as blocked. It's far from foolproof, however, as some comments indicate an extended bit of facial-wriggling tricks the app into unlock mode. Oh well, you're so vain, you'll probably think this Android market link is for you -- don't you? Read more: Engadget QR:
A brave new worldWindows 8 will ship with a pair of runtimes; a new .NET runtime (currently version stamped 4.5), and a native code C++ runtime (technically, COM, or a derivative thereof), named WinRT. There will be a new native user interface library, DirectUI, that builds on top of the native Direct2D and DirectWrite APIs that were introduced with Windows 7. A new version of Silverlight, apparently codenamed Jupiter, will run on top of DirectUI. WinRT and DirectUI will both be directly accessible from .NET through built-in wrappers. WinRT provides a clean and modern API for many of the things that Win32 does presently. It will be, in many ways, a new, modern Win32. The API is designed to be easy to use from "modern" C++ (in contrast to the 25 year old, heavily C-biased design of Win32); it will also map cleanly onto .NET concepts. In Windows 8, it's unlikely that WinRT will cover everything Win32 can do—Win32 is just so expansive that modernizing it is an enormous undertaking—but I'm told that this is the ultimate, long-term objective. And WinRT is becoming more and more extensive with each new build that leaks from Redmond. WinRT isn't just providing a slightly nicer version of the existing Win32 API, either. Microsoft is taking the opportunity to improve the API's functionality, too. The clipboard API, for example, has been made easier to use and more flexible. There will also be pervasive support for asynchronous operations, providing a clean and consistent way to do long-running tasks in the background. DirectUI is built around a core subset of current WPF/Silverlight technology. It includes support for XAML, the XML language for laying out user interfaces, and offers the rich support for layouts that Win32 has never had. This core will give C++ programs their modern user interface toolkit and, at its heart, it will be the same toolkit that .NET developers use too. (DirectUI is a name Microsoft has used before, internally, for a graphics library used by Windows Live Messenger. The new DirectUI appears to be unrelated.) Jupiter is essentially Silverlight 6; a fully-featured, flexible toolkit for building applications. The exact relationship between DirectUI and Jupiter isn't entirely clear at the moment. It's possible that they're one and the same—and that DirectUI will grow in functionality until it's able to do everything that Silverlight can do. It's also possible that DirectUI will retain only core functionality, with a more complete framework built on top of its features. Another option is that Jupiter refers specifically to immersive, full-screen, touch-first applications. Read more: Ars technica QR:
1. IntroductionWith the release of Silverlight 3, a lot of new cool features have been introduced. One of my favorite definitely is the support of behaviors and triggers. In WPF the triggers are extremely powerful. They allow you to declaratively associate an action with an event or property value. In the previous versions of Silverlight one of the things that were really missing were the triggers and the behaviors. It was not possible, for example, to add mouse-overs to objects declaratively (as in WPF). Currently it is still not possible, you have to write procedural code, but at least that code is separated, so the designer doesn’t have to write it or understand it. In that post I will focus exactly on that new feature in Silverlight and will show you how to create your own custom behaviors and triggers. You can find the demos in the end of each section.Download Source 2. PrerequisitesIn order to write behaviors and triggers you need to have installed the Microsoft Expression Blend SDK on your machine. After that you need to add a reference to the System.Windows.Interactivity.dll assembly which is located in: {Program Files}\Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries\SilverlightI don’t know why but this assembly currently is not part of the Silverlight SDK. You can download the Expression Blend product from here. 3. Behavior typesCurrently you can use three types of bevahors: Behavour, TriggerAction and TargetedTriggerAction. The class diagram is shown on the next figure:
4. Using the Behavior<T> classFor simple scenarios the generic Behavior<T> class is excellent choice. This class has only two overridable methods which notify the current behavior when an object is attached and detached from it. For my post I will create two behaviors: the first one just inverts the color of an image, when the image is clicked, and the second is little more complicated – it adds an animation and creates a magnifier when the mouse is over the image. The first thing you should do when creating behaviors is to create a new class which inherits from the generic class Behavior<T>, where T is a dependency object. In the most cases you will inherit from the Behavior<FrameworkElement> or Behavior<UIElement>. public class InverseColorClickBehavior : Behavior<FrameworkElement> { public InverseColorClickBehavior() : base() { } }For that particular case I am interested in the mouse click event. That’s why in the OnAttached method I will attach to the MouseLeftButtonDown event of the associated with that behavior object. And respectively in the OnDetaching method I will detach from that event. protected override void OnAttached() { base.OnAttached(); this.AssociatedObject.MouseLeftButtonDown += new MouseButtonEventHandler( AssociatedObject_MouseLeftButtonDown ); } protected override void OnDetaching() { base.OnDetaching(); this.AssociatedObject.MouseLeftButtonDown -= new MouseButtonEventHandler( AssociatedObject_MouseLeftButtonDown );Read more: Silverlight Show QR:
SSH is a life-saver when you need to remotely manage a computer, but did you know you can also upload and download files, too? Using SSH keys, you can skip having to enter passwords and use this for scripts! This process works on Linux and Mac OS, provided that they’re properly configured for SSH access. If you’re using Windows, you can use Cygwin to get Linux-like functionality, and with a little tweaking, SSH will run as well. Copying Files Over SSHSecure copy is a really useful command, and it’s really easy to use. The basic format of the command is as follows: scp [options] original_file destination_fileThe biggest kicker is how to format the remote part. When you address a remote file, you need to do it in the following manner: user@server:path/to/fileThe server can be a URL or an IP address. This is followed by a colon, then the path to the file or folder in question. Let’s look at an example. scp –P 40050 Desktop/url.txt yatri@192.168.1.50:~/Desktop/url.txt This command features the [-P] flag (note that it’s a capital P). This allows me to specify a port number instead of the default 22. This is necessary for me because of the way I’ve configured my system.Read more: How-to geek QR:
Posted by
jasper22
at
17:55 |
Monday, June 27, 2011
A brave new worldWindows 8 will ship with a pair of runtimes; a new .NET runtime (currently version stamped 4.5), and a native code C++ runtime (technically, COM, or a derivative thereof), named WinRT. There will be a new native user interface library, DirectUI, that builds on top of the native Direct2D and DirectWrite APIs that were introduced with Windows 7. A new version of Silverlight, apparently codenamed Jupiter, will run on top of DirectUI. WinRT and DirectUI will both be directly accessible from .NET through built-in wrappers. WinRT provides a clean and modern API for many of the things that Win32 does presently. It will be, in many ways, a new, modern Win32. The API is designed to be easy to use from "modern" C++ (in contrast to the 25 year old, heavily C-biased design of Win32); it will also map cleanly onto .NET concepts. In Windows 8, it's unlikely that WinRT will cover everything Win32 can do—Win32 is just so expansive that modernizing it is an enormous undertaking—but I'm told that this is the ultimate, long-term objective. And WinRT is becoming more and more extensive with each new build that leaks from Redmond. WinRT isn't just providing a slightly nicer version of the existing Win32 API, either. Microsoft is taking the opportunity to improve the API's functionality, too. The clipboard API, for example, has been made easier to use and more flexible. There will also be pervasive support for asynchronous operations, providing a clean and consistent way to do long-running tasks in the background. DirectUI is built around a core subset of current WPF/Silverlight technology. It includes support for XAML, the XML language for laying out user interfaces, and offers the rich support for layouts that Win32 has never had. This core will give C++ programs their modern user interface toolkit and, at its heart, it will be the same toolkit that .NET developers use too. (DirectUI is a name Microsoft has used before, internally, for a graphics library used by Windows Live Messenger. The new DirectUI appears to be unrelated.) Jupiter is essentially Silverlight 6; a fully-featured, flexible toolkit for building applications. The exact relationship between DirectUI and Jupiter isn't entirely clear at the moment. It's possible that they're one and the same—and that DirectUI will grow in functionality until it's able to do everything that Silverlight can do. It's also possible that DirectUI will retain only core functionality, with a more complete framework built on top of its features. Another option is that Jupiter refers specifically to immersive, full-screen, touch-first applications. Read more: Ars technica QR:
In the event you got lulled into a groovy seat dance by that most excellent muzak above, let us repeat - this app does not protect your lockscreen. That said, Visidon's Applock will prevent the privacy-adverse from messing with your personally curated app collection. Have a nosy significant lover? No sweat -- snap a pick with your front-facing cam, enable the face-lock in your settings, and those sexts are as good as blocked. It's far from foolproof, however, as some comments indicate an extended bit of facial-wriggling tricks the app into unlock mode. Oh well, you're so vain, you'll probably think this Android market link is for you -- don't you? Read more: Engadget QR:
If you are doing Silverlight development, you are no doubt slapping in the tag or using the control (if in ASP.NET) to host your Silverlight content/application. This is all great, but don't forget about deployment! When I talk about Silverlight I like to relay a story I heard from one of the Silverlight program managers (PM) a while back. The PM was pretty excited about a feature just completed in Silverlight and one of the samples that had been created. He went home to show his wife and told her to 'go to 'dub-dub-dub-dot-something-dot-com' (yelling from the other room of course) and to tell him what she thought. After a long pause of a few minutes he shouted back 'what do you think?' Her response: 'It's lame.' He was no doubt offended until he walked up to her machine and on the screen saw this:
The ProblemYou see, 'Get Silverlight' means nothing to your mother-in-law (or wife in this matter). Technology means nothing to non-geek users. Content is king. And to your non-savvy users (and even your savvy ones), leaving this default experience isn't a wise one. It doesn't convey that there is anything of value by installing something they might not have. It doesn't even convey what the action is going to be when they 'Get Microsoft Silverlight.' Leaving this experience unchecked leaves your users in the dark as well as a reputation rank downward in my opinion. NOTE: This site is likely riddled with these badges as seen above. I'm claiming exempt status because they are samples :-).While in Silverlight 1.0 creating a great install experience was possible, Silverlight 2 makes that process so much easier. In Silverlight 1.0, the use of the silverlight.js file could aid in detection and direction to an alternate experience. This method is still possible in Silverlight 2, and in fact might be a best practice still. Most interactive developers using Flash use some method of script creation in instantiating the Flash host. This is mostly due to the IE EOLAS "click to activate" issue that has been resolved and will remedy in an upcoming IE update. Some SolutionsSo that brings a few methods for instantiating the Silverlight control host. You can still use a script method to do the check for you and provide alternate content or redirect to something. You can also still simply include the tag itself. My favorite is using the simple tag and tricking the HTML. You see an object tag might look like this:
1. IntroductionWith the release of Silverlight 3, a lot of new cool features have been introduced. One of my favorite definitely is the support of behaviors and triggers. In WPF the triggers are extremely powerful. They allow you to declaratively associate an action with an event or property value. In the previous versions of Silverlight one of the things that were really missing were the triggers and the behaviors. It was not possible, for example, to add mouse-overs to objects declaratively (as in WPF). Currently it is still not possible, you have to write procedural code, but at least that code is separated, so the designer doesn’t have to write it or understand it. In that post I will focus exactly on that new feature in Silverlight and will show you how to create your own custom behaviors and triggers. You can find the demos in the end of each section.Download Source 2. PrerequisitesIn order to write behaviors and triggers you need to have installed the Microsoft Expression Blend SDK on your machine. After that you need to add a reference to the System.Windows.Interactivity.dll assembly which is located in: {Program Files}\Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries\SilverlightI don’t know why but this assembly currently is not part of the Silverlight SDK. You can download the Expression Blend product from here. 3. Behavior typesCurrently you can use three types of bevahors: Behavour, TriggerAction and TargetedTriggerAction. The class diagram is shown on the next figure:
4. Using the Behavior<T> classFor simple scenarios the generic Behavior<T> class is excellent choice. This class has only two overridable methods which notify the current behavior when an object is attached and detached from it. For my post I will create two behaviors: the first one just inverts the color of an image, when the image is clicked, and the second is little more complicated – it adds an animation and creates a magnifier when the mouse is over the image. The first thing you should do when creating behaviors is to create a new class which inherits from the generic class Behavior<T>, where T is a dependency object. In the most cases you will inherit from the Behavior<FrameworkElement> or Behavior<UIElement>. public class InverseColorClickBehavior : Behavior<FrameworkElement> { public InverseColorClickBehavior() : base() { } }For that particular case I am interested in the mouse click event. That’s why in the OnAttached method I will attach to the MouseLeftButtonDown event of the associated with that behavior object. And respectively in the OnDetaching method I will detach from that event. protected override void OnAttached() { base.OnAttached(); this.AssociatedObject.MouseLeftButtonDown += new MouseButtonEventHandler( AssociatedObject_MouseLeftButtonDown ); } protected override void OnDetaching() { base.OnDetaching(); this.AssociatedObject.MouseLeftButtonDown -= new MouseButtonEventHandler( AssociatedObject_MouseLeftButtonDown );Read more: Silverlight Show QR: