Vizibility Community

Welcome to our community site

Welcome to Vizibility Community Sign in | Join | Help
in Search

ligAZ blog

A Blog to Remember

  • InfoCard Control

    Time for post again. This time it will be huge smile_regular

    Prelude 

    Last year Dido and I gave 2 presentations about Windows CardSpace (the most unexplored part of .NET Framework 3).

    The first one was at MS Days Bulgaria (with the help of our GM Ivo). Although we expect more people (there were about 30) to attend it comes out a very good discussion with the audience at the end of the presentation. InfoCard was just renamed to Windows CardSpace and even we did not have time to change the slides smile_regular

    The second one was at the monthly meeting of Sofia .NET User Group. With a couple of changed slides and demos for the final version of CardSpace we gave the talk (unfortunately one of the demos failed, because I was made it on my office PC with Virtual PC 2004 and forgot that I have Virtual PC 2007 on the notebook, so it was quite a big rush to setup the demos again at the last seconds).  Again there were small number of people (this time it was just before Christmas, so everybody was going home), which result in more beer for us beer. But I think it was good rebirth for the group, which did not have a meeting for about 4 months and I think we gave a good start - you can see what happened on this January meeting here pizzasmile_tongue.

    InfoCardControl

    Lets stop the general talk and see what is this post about. I am not going to explain you what is CardSpace (InfoCard) and Identity Metasystem all about and if you are not familiar check the resources here (if you have attended any of the above explained presentations I hope you are already familiar with the idea). What you need to know is that it requires an object tag with type application/x-informationCard and a couple of parameters that describe what claims you require. So what I have done is a server control that has a couple of properties and renders this object tag. But hay InfoCard is not something brand new - arent there someone who already done this? Yes there are - you can find implementation for the CommunityServer here and a standalone one here. So why I did this? First of all both implementations are quite coupled with rendering the object tag and rendering a control to trigger the object tag (respectively the Identity Selector). Second I want to have strong typing for the standard claim URIs (givenname, email, surname, etc.). You could define your own claims deriving from a base class or use the CustomClaim and specify the claim URI. Here is how the control looks on the page:

    <az:InfoCardControl runat="server" ID="infoCard">

        <Claims>

           <az:GivenNameClaim />

           <az:EmailClaim />

           <az:PPIDClaim />

           <az:GenderClaim Required="false" />

           <az:CustomClaim

              ClaimUri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname" />

        </Claims>

    </az:InfoCardControl>

     

    Note that this control renders only the object tag, nothing else. This will allow us to develop other controls using it. You can find this control in the InfoCardControl project in the attached archive.

    CardSpaceButton

    In the same project (InfoCardControl) you can find a control named CardSpaceButton. It is deriving from Button (note that you can change this to be LinkButton or ImageButton) and triggers the associated InfoCardControl. Here is a snippet how to use it:

    <az:InfoCardControl runat="server" ID="infoCard">

        <Claims>

            <az:GivenNameClaim />

            <az:EmailClaim />

            <az:PPIDClaim />

        </Claims>

    </az:InfoCardControl>

    <az:CardSpaceButton ID="CardSpaceButton1" runat="server" InfoCardControlID="infoCard"

        Text="CardSpace Button" OnCardSelected="CardSpaceButton1_CardSelected" />

     

    You must specify the InfoCardControlID to the CardSpaceButton that will be triggered when the button is clicked. On the server you must handle CardSelected event that gives you the submitted token in its EventArgs.

    InfoCardButtonExtender

    To bring the concept further I have created a control extender that can be applied to any control implementing IButtonControl interface (Button, LinkButton, ImageButton, ...). Here all the power of ASP.NET AJAX and AJAX ControlToolkit is utilized. Actually its not exactly an extender in its pure definition, because it has a server side event CardSelected similar to the CardSpaceButtons one. Here is sample code:

    <az:InfoCardControl runat="server" ID="xmlToken">

        <Claims>

            <az:GivenNameClaim />

            <az:EmailClaim />

            <az:PPIDClaim />

        </Claims>

    </az:InfoCardControl>

    <asp:LinkButton ID="btnSend" runat="server" Text="InfoCard" />

    <az:InfoCardButtonExtender runat="server" ID="infoCardExtender" TargetControlID="btnSend"

        InfoCardControlID="xmlToken" OnCardSelected="infoCardExtender_CardSelected" />

    While I was developing the extender I had some problems with the FireFox Identity Selector. After looking at its implementation I found where the problem was and unfortunately it was not in my code, however there is a way to do it in my code. I forgot to mention that in order particular button to trigger the Identity Selector through the object tag, it must be placed outside the main form, otherwise any button will trigger it. You dont have to think about this because it is all done through the server controls. In the extender control I was trying to do this entirely in JavaScript and here is where the FireFox implementation breaks (on IE 7 works fine), however this also can be done on the server, before the page is rendered (this is also the CardSpaceButton implementation).

    Finally here is the download link. Note that you must set up an SSL connection (https://) to your site in order to bring the Identity Selector UI.

    Conclusion

    Feel free to use and modify these controls four your own purposes. I hope it will boost you to start using CardSpace in your daily projects. 

    P.S. In the next post I will show you how to CardSpace enable a site in a couple of minutes.

  • Fundigo

    If you are familiar with WCF and want to have a little fun (and also sneak preview of what is in the next version of WCF + WF = WS BPEL smile_regular) go straight and watch this video on channel9. The new guy Rory in Channel9 have a lot of fun smile_teeth with in Indigo team.

    The best parts of the video are 0:40 when Don Box start to sing a song about Indigo:

    "Indigo is my love
    It has come from above
    Indigo is so good
    I think you like it too."

    and when Doug Purdy start to dance like a Pinocchio (24:05).

    Isn't it great to work with these guys?

  • What to do when you spill coke on your ThinkPad notebook

    Today I spill a whole glass of coke on my notebook. Bad. Very bad smile_confused. However as you can see (read) everything is ok now. So I will describe the procedure to clean such a mess in case some of you get lucky as me and pour his laptop.

    Switch it off immediately

    First of all turn off the computer ASAP, because the liquid may come near the power cable and things to go very wrong.

    Turn it upside down

    Turn the laptop upside down so the coke can flow out of the panel.

    Clean the keyboard

    Here is the tough part. If the liquid is water it will steam away and everything is fine. But in case with coke you have to clean the keyboard keys. You have to carefully pick out every single key from the keyboard so you will be free to clean them and also the space beneath them. Here is a picture of my keyboard almost key free:

    And here are the keys:

     

    To clean up the mess you will need special tools:

    Also a wet handkerchiefs and a needle will be needed to clean the space under the keys.

    The most difficult keys to clean are the functional ones and the space bar. Even now the space bar is a little gummy.

    Conclusion

    ThinkPads are durable. Drink coke away from you personal computer (on work you can drink freely next to the PC smile_wink)

  • Photosynth - the next big thing

    The last year Google released Google Earth and everybody was astonished by its capabilities. Flying around, visiting famous placed, looking at the neighbourhood, just great. Definitely this was the app of the year.

    So this year was it was Microsoft's turn to turn your world arround. So here it is - Photosynth. No comments, just go there and install the ActiveX plugin (in the future there will be standalone windows app, I think) and buy a decent video card (you already know that the Vista is RTMed). I was aware of this app, but have only watched the videos, but know when you can feel it, WHAO!!!

    What is all about?

    Photosynth takes a large amount of photos and analyze them for common patterns. Then it generates a 3D model that reconstructs the place that you have photed. It also allow you to have a overall look of all photos and zoom them. There are another great features, but these are the basic one, that make the app great. Read more here.

    Features to try while using it:

    • Use the right top menu for navigation (especially the cameras feature is very good)
    • Use your mouse to drag the screen/photos and the wheel to zoom in/out.
    • Click F11 to use it in full screen and feel it much better
    • Click 1 to start slideshow feature.

    What do you think? Do you have any words left? smile_regular

    Links:

    Photosynth Blog

    Video on Channel 9

  • sgen.exe continued

    A while ago I posted a solution how to fix the problem with sgen.exe when you build your projects in release mode. This was only solution how to fix the problem, but did not goes deep why this happens. Today I will go deep and show you how to really to fix the problem:

    Why and when to use to use sgen.exe?

    The XML Serializer Generator Tool (Sgen.exe) is used when you want to generate XML serialization assembly for your assembly. What that means is that if you are using XML serialization in your code and want to increase the performance of the serialization you must use this tool. It generates an assembly called MyAssembly.XmlSerializers.dll if the target assembly is called MyAssembly.dll. So when the CLR starts to serialize an object from your assembly if it finds this special assembly it will use the code for serialization that is in it (note that this code is specially optimized for your types). If the CLR did not find it, it will start the normal reflection based serialization. Now you see why it increases performance.

    Why sgen.exe failed to generate XML serializers assembly?

    But the question is still there. Why the generation failed? There are maybe many answers to that one, so it is best to dig out what is the problem in your particular case. How do to so? You must start the sgen.exe from the VS command prompt and point it to your assembly. And here is the trick: you must use the command line argument /v, which stands for verbose. Using it you will see detailed information which types in your assembly failed to be generated, causing the entire assembly generation to fail, causing the entire build to fail if you've enabled the XML Serialization.

    In my particular case I have two types called Status. Although they were in different CLR Namespaces they both want to be serialized as Status in the XML Namespace that was created for my assembly. So how to fix that? You must use the XmlTypeAttribute to name each Status class with different name in the XML or you could simply rename your class (if this can be done without to much pain and trouble). More info on XmlTypeAttribute and advanced XML serialization topics here and here.

    In Conclusion

    XML serialization assembly generation is very good enhancement in .NET Framework 2.0. But you should really ask your self do you actually need it. I needed and this is way I have to figure what is happening under the covers. Good luck in yours XML Serialization Journeys.

  • How to patch the QTEK with the latest ROM = firmware + OS

    If you are like me have an windows based PDA phone and the manufacturer is Qtek here I will describe how to patch it with the latest firmware. Personally I (as you may already know) have Qtek 9100 so the procedure I will describe applies to it (but I am sure it will be the same for other models too, only you have to download different installation package).

    So here it is:

    1. First you have to restart your phone. When it boots be careful and watch the carefully the numbers after the IPL and SPL. If the end up with .001 then go to 2. If they do not go to 3.
    2. Your phone f*cked :) Go here to find out how to fix it.
    3. So to be able to install new ROM you have to unlock your CID (Country ID)(Note that if the ROM manufacturer is the same you may did not have to do this, but it is best to do it). Download this tool to do this - what is nice about it also is that it is able to unlock your phone if it is SIM locked. Go to 4.
    4. Finally you will be able to install the ROM. Download it from here.and follow the instructions (note that your battery should be charged, because the whole process takes about 10min and if anything goes bad you have to be able to restore your phone. Also it is best if you have laptop, because the power may go down :) In this directory there are also other ROMs you can experiment with - some are very interesting ones - with integrated .NET Framework 2.0; with a lot of free space by default; with a lot of goodies (themes,software,etc.). Go to 5.
    5. Your are done.

    So for me this procedure works. I upgraded my phone from ancient 1.6.7 version to 2.17, which is a way better (faster, more responsive, ...)

    I learned all this from the ultimate place for Qtek phones - http://forum.xda-developers.com/

  • Code Snippets Returned

    Almost a year ago I blogged about how easy is to create a code snippets in VS.NET 2005. Today I will post three useful (if you are web developer) snippets that I wrote and use frequently.

    1. ViewState Property

    This one allows you to store data in the ViewState encapsulation the access to it with property. Actually this was one of my first properties, but just these days it has been upgraded (after reading this post) to its latest version :) When I first wrote this it look like this in the getter (setter is trivial):

     

    if ( ViewState["PropertyName"] == null )
    {
    return someDefaultValue;
    }
    else
    {
    return (long) ViewState["PropertyName"];
    }

     

    Then I realize that if the property was already set I was taking it twice from the ViewState dictionary, so the code was refactored as this:

     

    object objectState = ViewState["PropertyName"];
    if ( objectState == null )
    {
    return someDefaultValue;
    }
    else
    {
    return (long) objectState;
    }

     

    Actually this is the implementation used by Microsoft in their controls. So what is wrong with that. Nothing. Only that it is ~10 lines of code. But how to squash them. As I mentioned after reading this post I was able to do it on 1 line using the new ?? operator in C# 2.0. If you wonder what that do here is the line from the documentation: The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand. So here is the final version:

     

    (long)(ViewState["PropertyName"] ?? someDefaultValue)

     

    Cool ah :)

    2. Web Control Event

    This one creates event that a control (or page) exposes. It also creates protected virtual method to raise the event and put the Event in the Control.Events collection as described as a best practice in the bible for building web controls. Here is a sample code generated by the snippet:

     

     

    private static readonly object EventDataBound = new object();

    public event EventHandler DataBound
    {
    add
    {
    Events.AddHandler(EventDataBound, value);
    }
    remove
    {
    Events.RemoveHandler(EventDataBound, value);
    }
    }

    protected virtual void OnDataBound(EventArgs e)
    {
    EventHandler handler
    = (EventHandler)Events[EventDataBound];
    if (handler != null)
    {
    handler(
    this, e);
    }
    }
     

     

    3. If Item or AlternatingItem

    This is the simplest of the the three. It checks whether the current items type is item or alternating item. Usually used in ItemDataBound and ItemCreated event handlers for data bound web controls. Here is its code:

     

    if (e.Item.ItemType == ListItemType.Item
    || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    }

     

    The only special about this snippet is that it is "SurroundWith" one.

     

    You can download all of the three here. Hope you will like them and put em in use. 

    Speaking of code snippets I think that they bring some interesting topic. It is that they are the smallest unit of encapsulated knowledge and best practice. What do you think about this?

  • IE 7 object activation fix

    With the release of IE 7 (currently in RC1) there is a new security feature that requires to click on the the object to start using it - "Click to activate and use this control". There are a lot of solutions on the net, but actually I have to write a new one, because others were not correctly working on my machine. So here it is:

    if (navigator.userAgent.toLowerCase().indexOf("msie") != -1)
    {
    window.onload
    = RewriteObjects;
    }

    function RewriteObjects()
    {
    objects
    = document.getElementsByTagName("object");


    for (var i = 0; i < objects.length; i++)
    {
    var closedTagIndex = objects[i].outerHTML.toLowerCase().indexOf(>)
    var contents = objects[i].outerHTML.substring(0, closedTagIndex + 1);
    for (var j = 0; j < objects[i].childNodes.length; j++)
    {
    contents
    += objects[i].childNodes[j].outerHTML;
    }
    contents
    += </object>;


    objects[i].outerHTML
    = contents;
    }

    }

    Here is the link to the file.

    Edit: There was a bug in the code, but its now fixed.

  • Back to blogging 2

    Phew. It seems I did not have enough time to post, although there are a lot things to cover.  Here is a list of things that happened:

    • I'm back into the university. Remember what happened last year :)
    • Speaking of university Dido and I will be teaching ASP.NET 2 as a part of the elective course "Programming for .NET Framework" in the university. Thanks to Marto Kulov who give us 20-25h to present the material starting from basic web concepts to advanced ASP.NET programming.
    • I have a dozen little developer things to blog about. Hope will post them all.
    • MS Days and WebTech are gone and I did not said anything :( Also hoping I will do. BTW the files from the the WebTech presentation are in the files section.
    • As you can see (and still can read through CSS :) the blogs are update to 2.1 and the problem that I have to set up them under the root (so the rss feeds url be preserved) is gone. If someone is interested to know how to do the hack drop a line
    • Finally it will be good if you install netfx3, because a great things are about to come :)

    This is for now. Wait for my Back to blogging 3 part after 2-3 more months :)

  • Back to blogging

    Wow. My last blog post was posted 2+ months ago. That's a century in our fast and dynamic world :) So if you wonder why I was quiet these months stay tuned. I will try to blog it all. Here is the agenda in reversed date order:

    I hope will not miss anything that I wish to blog during these two months.

  • Bluejacking

    Bluejacking is fun. For everybody not familiar with the term, it means using your bluetooth enabled mobile gadget to send some information (ex. contact named "Waz up Bro?" :) to near staying guy whose bluetooth is on. Then the fun starts. The guy start to look around and see what is going on. If he/she is a smart guy he/she may just smile or laugh, if not he/she may get confused or even angry.

    I have many victims since I bought my Sony Ericsson T610. Nokias, Siemens, other SE, PDAs even ones I've connect to someones hands-free device. But my favorite one is when I was going back to my home town - Kazanlak. The bus was double-decker. I saw a guy with Nokia brick and fortunately he was just beneath me on the first floor. During the whole trip I sent him messages about his "perfect" telephone (I did not like Nokias much :), funny pictures and sounds. When we arrived and the bus stopped the guys start to look at all passengers strangely. "Who was that?". Hahahah. "It wasn't me :)"

    P.S. Bluejacking is another reason to buy mobile device with bluetooth :)

  • "sgen.exe" exited with code 1

    If you are having this problem while building your VS.NET 2005 project in Release mode here is the solution:

    Go to the project properties. Click on the build tab and set the value of the "Generate Serialization Assembly" dropdown to Off.

    P.S. If you wonder for what is this sgen.exe here is explanation from the msdn: "The XML Serializer Generator creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types.".

  • Vista Sidebar on XP

    Windows Sidebar will be one of the attractive features of Windows Vista. There are still few sidebar gadgets (that leverage the system model), but as Vista is coming on its way the gadget mania will definitely explode.

    For those of still using the XP (is anybody using Vista yet) and missing this new fancy feature - here is the way you could get the sidebar on XP. Needed files can be found here. Is you want to install new parts (extension for gadget is *.part :) just copy them to the folder Parts located at C:\Documents and Settings\{UserName}\Parts if you install the OS on C: of course.

    P.S. Here are some useful links for eager developers

    Windows Vista Feb. CTP - Sidebar Gadget Development Overview
    Windows Vista Feb. CTP - Sidebar Gadget Object Model

  • LINQ - look at the future of .NET

    In Saturday me and my friend Deyan make a presentation about LINQ for the first time in Bulgaria (as we know nobody else present it before [may be even in Europe :]). It was general preview of LINQ, a lot of the content copied from the slides from the PDC 2005 (10x to Anders Hejlsberg presentations :). As Picasso said: "Good artists create, great artists copy". Just a joke. The presentation went wall, only one guy in the audience had ever heard about LINQ. Only few were interest but this is not a problem because it was held in Technical University of Sofia and there are few developish people there. Hope next time (Sofia University) on 16.04.2006 the audience will be more intrigued .

    P.S.: You could download the presentation here.

    P.P.S. See you on 16 of April this year in FMI. Hope I will update this post after that.

  • Web vNext

    The term Web 2.0 is so popular that it comes out almost from any place in the net. Many definitions can be made trying to describe this term (read one interesting here), but the most clear is if we just look at the picture and define it for ourselves:

    Web20

    http://www.flickr.com/photos/kosmar/62381076/

    Did you find something from Microsoft in the picture? Look closer :)

    So if you finally thought out what Web 2.0 is (or going to be) let's go beyond. What will be the next Web - the one after 2.0 euphoria. If you search for Web 3.0 we will get quite a lot of results and nothing clear (only here). So I extend my search and try Web 4.0. And yes I got to an interesting post.The comment on the post get my attention where some guy give his definition:

    Web 1.0 was the Hypertext/CGI Web. (the basics)
    Web 2.0 is the Community Web (for people: apps/sites connecting them).
    Web 3.0 is the Semantic Web (for machines).

    Web 2.0 and Web 3.0 are a fork we are moving into now, where one is focused on internet architectures for people/community/usability and the other is focused on internet architectures for machines.

    Web 4.0 is when these technologies come together to form what I call the "Learning Web". This is moving more into the area of Artificial Intelligence.

    The Learning Web is where the Web is actually learning by itself and is a user alongside human users, generating new ideas, information and products without direct human input. This may be possible on a large-scale when more sensors/actuators/semantic structure/ontologies are advanced and in place someday (maybe 10-15 years).

    Yes Web 1.0 (if there was so :) was the basics - just internet get spread all over the world and people get used to it. Then it comes 1.5 step with google search invasion, portals like yahoo, ebay, etc. You know them. So we are now in the 2.0 phase where community is getting place (forums, blogs, tags, photos, ...), richer web apps powered by Ajax targeted to the end user and his participation in the community. What's next? With all these boom of technologies leveraging Xml (Web Servcies, Rss, ...) the next big thing will be the programmable web where you will program for (against) the Web (and its open standards). And yes computers love Xml because they can parse it :) Things like WebOS may become reality. This programmable web (2.5) will lay down the basic for the so called Semantic Web, when computers will be capable of extracting information from the net, benefit from it and use it for their needs. Combined with the widespread of RFID amazing (and not so amazing :) things can happen.

    These things will happen inevitable. When and how the future will show. One thing is for sure the web is getting more the web is getting more and more interactive. The conclusion may be only one: the future is in the web and yes - web is the future.

    P.S. For those of you who missed the last decade and still writing client applications, just forget them and go for the web. Encourage you to start with ASP.NET (2.0 & Atlas) and learn the .NET Framework (upcoming WinFx API) if you want to be part of the modern and near future.

    P.P.S. I tried googling for Web 5.0 also. Guess who gets the first place?

More Posts Next page »
Powered by Community Server, by Telligent Systems