New site building!

0

This night I started to build my own new site from scratch… 

Just a word on my new domain name: “codebrainr”: I left my old xmlguy because I changed my opinion on xml and related things in general and even because problems with my old hosting provider gives me an opportunty (from a problem) to rethink my “nickname”, and then I choosed Codebrainr one who thinks, who makes code with brain and not with feets as many does… I mean “who maes code with feet” not just about code quality (I’m not a guru and I need to continuos learning) but more specific making code without thinking, without take right decisions, without think about “system” I say.. but thinking only about put money in my pocket doing maybe the poor’s work as I can… but thi is another story…

A while ago I moved away from WebHosting4life, frankly I was not so happy to move because in the beginning, I really loved it, but in the last year the service, the customer service and the quality itself went down to my shoes.. too troubles, no way to resolve such stupid issues.. after that I realized to move to a more seriously provider and after some googlin’ and asking through socials.. I found Arvixe a strong and cool web hosting provider, cheap and powerfull for the services provided.. Personally I’m on the Personal Class Asp profile, $4 per month and so many features… 

The coolest thing is that I want to build a personal site from scratch, using some cool oss frameworks, and publish the site itself as oss. These are farmeworks I intend to use:

  1. OpenRasta, a cool and strong alternative to standard ASP.NET MVC
  2. RavenDB, the coolest thing at now!! About that I’m excited to try to implement it on my own site
  3. Magnum, on of the coolest system-wide frameworks I seen in the past years on .NET!
  4. SharpTiles, as view engine, the only limit is that OpenRasta hasn’t a codec right now, so I want to implment it..
  5. what else… 

Now these are the rocks, maybe something new will be added….

What kind of site I wish to implement? Simple.. a simple personal site, nothing more.. Yes, I heard what you’re sayin’: “why those materials for a simple personal site?”, The answer is simple:

  • because continuos learning is my blood for me..
  • because is cool…
  • because I would try everytime to make me better than yesterday.. 

There’s another strange feature i would like to implement, but I wish to talk about in the future…

What is your experience with those frameworks? You know them? Could you give me suggestions? A simple comment? 

See you soon

Points of view

0

 

In these days I’m thinkng about the concept of “Achitecture” and “Architect”. Even now I’m experimenting what I’ve experienced for years about what the folks (in my country) thinks about that, and I’m, or better, I can be too confused..

I don’t want to fall here in discussions about what is an architect or what is and what makes an architecture because I thinks many good peolple talked about that (i.e. Arnon Rotem), I want just to post some thoughts about the fact generally people, in this job, think about architecture, design, development, as maybe the easiest thing to… I’m saying that because every day when decisions needs to be taken, or things have to be done well, the words I usually listen are “It must works”, “It must be done early and dirty” and so on… you can imagine what is the flow…

What I think, and everytime I stay on that, software architectures, software architect, doing this job in general, is not a trivial job as It can seems to the folks (I say this with caution..) It’s not possible to think our job could be done by everybody, not because to be architects or related is to be an elite, but because IT’S NOT SO SIMPLE AS IT COULD SEEMS in general.

I’m not helped by my poor english to explain my concept, but I hope I can try.. I fell in so many troubles about bad decisions, bad organizations, bad communications, and so on in my tiny past (11yr) even me I did in bad things, but I hope I’ve learned from my mistakes.. but this story is going on and sometimes I think it never stops..

Recently I’m thinking about the fact, technologies, framework, tools, languages and so on, became everytime more detailed, more in general, and the learning curve is eccesive than before, I think about the VB3/4/5/6, COM times, sometimes I thinks this could helps to understand the fact we have to continuosly learn, concepts became everytime more sofisticated, we have to be professionals and good programming can’t be made by tools, Drag and dropping things or something similar. We daily read good people and good techinicians blogs, read articles and more, but our daily life it’s more soiled than the “dreaming” reality people continuosly read about… I call it “dreaming” because I would like if it could be reality, but in real, things are so dirty, and we have to fight to try to do things well, and why not with passion…

I can continue talking about that hours, but now I stop, I’d like to know you’re opinion, how are things in your reality, in your country, or better near to you? I’m living in Italy..

 

Technorati Tag: Personal,Work

Blogging tales: What’s new on the way…

0

Hi, recently I bought a web space to finally host my web site an official blog. I’m experiencing some troubles with subtext so I haven’t do an entire blog export from here to there, I have problems with the image publishing feature, but at now, it’s still alive, some post are there, the layout is standard one, I hope I can change it soon…

The new blog is at http://xml-guy.com/Blog/ and soon wille available in the root my new web site..as professionals says “stay tuned!”

Ciao

Technorati Tag: Personal,Tools

ASP.NET MVC Released

0

 

Hi this morning I found an email with this notice: “ASP.NET MVC RELEASED”… In the firs time I found it a joke or something else which doesn’t matter, but the email continue with a link to the download page.

Now I’m reading the release notes..very interesting, and as the email says: “I don’t think there’s been an official announcement yet, but we all
kind of knew (or highly suspected) it was coming at MIX anyway.”

Ciao

Technorati Tag: ASP.NET,ASP.NET MVC

Developer Events n°1 – UGIALT.net Conference

0

 

UGI Alt.net conf

Hi, I will share and give my support to the next UGIALT.net event, I hope I could be there, but however you find in my Events page details about events I support or I will partecipate to.

This kind of event is one the best suitable for developers who shares the “ALT philosophy”, I invite you to go the the site (go to link above) and to see the detailed agenda. unfortunately the link, the material and the event all is in Italian..

Ciao!

Tags: ALT, Events

Developer News – Outlook HOL WPF Gotcha!

0

Recently I’m doing some study on some WPF code, I fall in an interesting example from Microsoft called Outlook HOL WPF, which basically shows how to do an Outlook UI WPF replica, I found many posts about that but each with the same problem, where is the source code?? The missing..

So, after some Googlin’ I found it!! Here I whish to share with you the Outlook HOL WPF link I hope someone will find interesting as I do!

I found starting from an  MSDN Forum post, as the post describes, the last in the thead, you can download a zip file WPF.zip and insied you will the things: Code, Presentations and more!

Enjoy, Ciao!

Tags: Development, WPF

Developer Tales n°5- Generic Enum parsing

0

Hi,

recently I was doing some code about enum parsing, I think  an operation everyone’s involved in one time. After some Googlin’ I found some well or not well done examples. Doing a generic parse method is too simple as you can see on Windows.NET Blog post but you don’t have no type check code or constraints, or something about a default check value, so I done my implementation, which assumes that the target enum type has some well defined constraints like: inheriting from the struct base type,  having an Undefined or a None element.. if not the first enum member is assumed as the default one. Here is my little code

    /// <summary>
    /// Translates from a string name enum member
    ///  to the given gene ric enumeration Type
    /// </summary>
    /// <param name="name">the name string to translate</param>
    /// <returns></returns>
    private T TranslateFrom<T>(string name)
        where T : struct
    {
        const string DEFAULT = "Undefined";
        const string NONE = "None";
        Type enumType = typeof(T);
        T result;
        if (Enum.IsDefined(enumType, command))
        {
            result = (T)Enum.Parse(enumType, command, true);
        }
        else
        {
            string defaultName = null;
            if (Enum.IsDefined(enumType, DEFAULT))
                defaultName = DEFAULT;
            else if (Enum.IsDefined(enumType, NONE))
                defaultName = NONE;

            if (!string.IsNullOrEmpty(defaultName))
            { result = (T)Enum.Parse(enumType, command, true); }
            else
            {
                string[] values = Enum.GetNames(enumType);
                result = (T)Enum.Parse(enumType, values[0], true);
            }
        }
        return result;
    }

This is just a little helper method I wish to share, enjoy!

Ciao

Tags: Development

Developer Tales n°4.1 – Seralization how-to..

0

Hi, as I said in my previous post, I’m working on a kind of soa-like system, in the system we are exchanging some envelopes messages, something like this:

<Envelope>
   <AuthData name="" pwd="" />
   <ContextData name="" />
   <Input>
      <FirstNode />
      <FirstNode />
      <SecondNode />
   </Input>
   <Output>
      <ThirdNode />
      <FourthNode />
      <FourthNode />
   </Output>
</Envelope>

 

 

In my previous post Xml Default serialization I was talking about some serialization problems I found, especialy with serializing collections. I have to say that the Service, the remote service is an old-style ASMX Web Service, wich accept a string parameter and returns a string representing the output message. Well, while I was coding up a client to that service, I tried, first, to evolve the Client using a WCF style proxy, we know it’s truly possible to call an ASMX service from with a WCF client, but talking about the client proxy I made is out of the scope of this post.

Well, I made a Proxy library with a Proxy client and some Objects, well..Contracts, describing the solution and then using a DataContractSerializer in conjunction with an XmlSerializer to serialize-deserialize messages regarding the simple-and-raw message string representation which the Service expect..

So, the First problem was, How to create a DataContract object with a Input and Output DataMembers properties which could accept any kind of object? This because, clearly, I can send in the envelope any operation-request and expect the related operation-response..but how can I put them in to the evelope-DataContract-Object?? after some search I realized that the better thing was to accept in the Input and in the Output DataMember properties an xml String, so the things are:

  1. create the Message object
  2. create the Operation object
  3. serialize with an XmlSerializer the operation itself and put the result in the Input part of the Message previously created

But, when I tried to do as above, I fall into a DataContractSerializer behavior wich will “encode” the xml string, so the string instead of been passed for example as “<xml></xml>” is passed as “&lt;xml&gt;&lt;/xml&gt;”, it’s clear that the encode xml string will not be accepted as a valid xml, so what could I try more?

A developer team I was working with, take the solution using an XmlDocument and let it be serialized-deserialized by the serializer, but I don’t really love this solution nor the XmlDocument itself for many reasons, then I took a solution from a forum-port I found on the net regarding a problem as mine, how to serialize a raw-xml string without involve in encoding-issue which is not an Issue but in my case it was..

so here is the solution, the brilliant one (I cannot find where I put the original forum-post-idea link), the solution is mixing the IXmlSerializable and the DataContractSerializer serialization. The DataContractSerializer we know will serialize DataContracts, DataMembers and more, even types marked as inheriting from IXmlSerializable, so using an object of that type as a DataMember of my Message-envelope will produce a well defined, not encoded xml string. The thing is made using implicit operators which will do the magic of translating an xml string to and from this kind of object.

I named the object XmlRawData because it represent a special place-holder object to represent an xml string inside a DataMember representation, but here is the code:

    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Serialization;

    namespace XGuy.Common.Serialization
    {
        /// <summary>
        /// Rpresent a wrapper-placeholder for raw xml string
        /// representation where is not possible to use direct
       /// <b>string</b> data type
       /// </summary>
       public class XmlRawData : IXmlSerializable
       {
           /// <summary>
           /// implicit operator from <b>XmlRawData</b> to <b>string</b>
           /// </summary>
           /// <param name="item">
           ///  the XmlRawData instance to convert
           /// </param>
           /// <returns>the content string</returns>
           public static implicit operator string(XmlRawData item)
           {
               return item == null ? null : item.Content;
           }

           /// <summary>
           /// implicit operator from <b>string</b> to <b>XmlRawData</b>
           /// </summary>
           /// <param name="content">the xml raw string to convert
           /// and wrap with an XmlRawData object</param>
           /// <returns>the XmlRawData object</returns>
           public static implicit operator XmlRawData(string content)
          {
               return content == null ? null : new XmlRawData(content);
           }

           /// <summary>
           /// Gets or sets the string content of the object
           /// </summary>
           public string Content
           {
               get { return _content; }
               set{ _content = value;}
           }

           /// <summary>internal content string placeholder</summary>
           private string _content;

           /// <summary>
           /// Creates a new <b>XmlRawData</b> instance
           /// </summary>
           public XmlRawData()
           {}

           /// <summary>
           /// Creates a new <b>XmlRawData</b> instance
           /// </summary>
           /// <param name="content">the raw xml string to wrap</param>
           public XmlRawData(string content)
           {
               _content = content;
           }

           /// <summary>
           /// Get the schema instance of the schema
           /// related to the content
           /// string
           /// </summary>
           /// <returns>a null reference</returns>
           public XmlSchema GetSchema()
           {
               return null;
           }

           /// <summary>
           /// Read from an xml reader the raw xml string content
           /// previous serialized
           /// </summary>
           /// <param name="reader"></param>
           /// <remarks>
           /// Here is the first part of the magic of the object which
           /// will take the inner xml of the containing xml and
           /// reads it
           /// into the inner content placeholder preventing the
           /// encoding-decoding steps
           /// </remarks>
           public void ReadXml(XmlReader reader)
           {
               if (reader.IsEmptyElement)
               { _content = string.Empty; }
               else
               {
                   switch (reader.NodeType)
                   {
                       case XmlNodeType.EndElement:
                           _content = string.Empty; break;
                       case XmlNodeType.Element:
                           _content = reader.ReadInnerXml();
                          break;
                  }
              }
          }

          /// <summary>
          /// Writes the raw xml string into an <see cref="XmlWriter"/>
          /// </summary>
          /// <param name="writer"></param>
          /// <remarks>
          /// Here is the second part of the magic of the object which
          /// will take the raw xml string and writes out with the
          /// WriteRaw method this preventing the
          /// encoding-decoding steps so the xml result clear
          /// </remarks>
          public void WriteXml(XmlWriter writer)
          {
              if(!string.IsNullOrEmpty(_content))
                  writer.WriteRaw(_content);
          }

          /// <summary>
          /// Returns the inner raw xml string
          /// </summary>
          /// <returns></returns>
          public override string ToString()
          {
              return Content;
          }
      }
 }

The above code shows how we can avoid the raw xml encoding step during the serialization, but let explaing and showing it with an usage example:

using System.ServiceModel;
using System.Runtime.Serialization;

namespace XGuy.Common.Serialization.Test
{
     //first of all define a DataContract which will
     //contains the xml raw DataMember property   

     [DataContract(Namespace = "http://xguy.serialization/2008/11")]
     public class SimpleEnvelope
     {
         ///<summary>
         /// Contains the envelope operation name
         ///</summary>
         [DataMember()]
         public string Name { get; set; }

         ///<summary>
         /// Contains the envelope input data xml
         ///</summary>
         [DataMember()]
         public XmlRawData Input { get; set; }

         ///<summary>
         /// Contains the envelope output data xml
         ///</summary>
         [DataMember(EmitDefaultValue = false)]
         public XmlRawData Output { get; set; }
     }

     ///<summary>
     /// Simple test class
     ///</summary>
     public class XmlRawDataTest()
     {
         public void Run()
         {
             //now I can do something like this
             SimpleEnvelope env = new SimpleEvelope()
             {
                 Name = "TestOperation",
                 Input = @"<Operation><Data>Test data
                                       content</Data></Operation>"
             };

             StringBuilder buffer
                 = new StringBuilder();

             XmlWriterSettings settings = new XmlWriterSettings();
             settings.OmitXmlDeclaration = true;

             using (StringWriter writer  = new StringWriter(buffer))
             using (XmlWriter xwriter    =
                           XmlDictionaryWriter.Create(writer, settings))
             {

                 DataContractSerializer ser =
                    new DataContractSerializer(typeof(SimpleEnvelope));
                 ser.WriteObject(xwriter, env);
                 xwriter.Flush();
              }

             Console.WriteLine(buffer.ToString());
         }
     }
}

So the result written out in the console will be:

<SimpleEnvelope
    xmlns="http://xguy.serialization/2008/11">
    <Name>TestOperation</Name>
    <Input>
    <!-- this is the raw xml added part -->
        <Operation><Data>Test data content</Data></Operation>
    </Input>
<SimpleEnvelope/>

instead of the following without the XmlRawData object:

<SimpleEnvelope
    xmlns="http://xguy.serialization/2008/11">
    <Name></Name>
    <Input>
    <!-- this is the encoded raw xml added part-->
        <Operation><Data>Test
             data content</Data></Operation>
    </Input>
</SimpleEnvelope>

the difference it’s clear and no needs of more explain! Hope this Helps!

Ciao!

Developer Tales n°4 – Xml (Default) Serialization

1
 

I’m working on a “SOA-Like” system, which lives and exchange data in the xml-envelope form which many of us knows as

   1: <Envelope>
   2:     <AuthData name="" pwd="" />
   3:     <ContextData name="" />
   4:     <Input>
   5:         <FirstNode />
   6:         <FirstNode />
   7:         <SecondNode />
   8:     </Input>
   9:     <Output>
  10:         <ThirdNode />
  11:         <FourthNode />
  12:         <FourthNode />
  13:     </Output>
  14: </Envelope>

I’m starting from an xsd schema which describes the envelope and each “Message” which will be enclosed in the “Input” part, then the operation-result message will be returned as a child of “Output” node. Until now everything could be fine, a standard Envelope, ESB-Message, or what else you want to name it, but a standard situation. But here my problems begins.

First of all, I cannot use a DataContract-fashion-class and the DataContractSerializer, because for the DataContract context it’s impossible to render an xml as above where child nodes are “variables” in the sense of I have a container, in my case the “Input” Object, which could have childs, maybe represented by a form of xmltype-anonymoustype array of objects, every time I can write a collection, an array in the form of:

   1: <Input>
   2:     <FirstNodeCollection>
   3:         <FirstNode />
   4:         <FirstNode />
   5:     </FirstNodeCollection>
   6: </Input>

in this way my objects hierarchy must be InputObject -> FirstNodeCollection -> FirtsNodeObject. I hate this way of representing the objects, but DataContract-fashion-classes and DataContractSerializer, could not produce a different “rendering”

Second, If I want to use the XmlSerializer instead of the DataContractSerializer, first I have to fill my classes of a lot of attributes, and even here, I can have some troubles, even if the only object which natively support the above representation is just the XmlSerializer.

Well, the XmlSerializer could help me, but the first thing which makes me hate it, is the fact that for each Type which it’ll represent, the XmlSerializer will generate a Temp assembly containing the ad-hoc serializer for that Type, and this is the thing which makes me really angry and hungry..of what?? of a normal, well driven, serialization API!

Personally I don’t know which makes Microsoft to choiche this kind of implementation about the DataContractSerializer, but I cannot believe there’s not an easy, more customizable way of doing it. Yes, someone could say me : “Hey, look at the IXmlSerializable interface” but this is a RAW implementation, this makes me think an Italian way to say, (..orrible translation..) “doing everything or doing nothing”, I try to explain it.. saying this I’m saying that Microsoft could makes a Monster, complicated over-rich API, or a simplest, it doesn’t know a “middle way” of doing things.

So, here I’m starting my provocation: why we cannot implement a simple new serialization API? maybe we could make in the beginning simple, and then let it grow and become more complicated! Maybe we could learn something from some JAVA implementation… I hope I can find anyone which wants to talk about, and maybe, start to think to implement something!

Ciao

Technorati Tag: Developer Tales,Xml

Working Facts: Installing Team Foundation Server (Question)

0

 

Hi, now, while I’ve changed the project I’m working on, has been assigned to me a new, strange for myself, task: installing a new Team Foundation Server from scratch and migrating source control from VSS 2005 to Team Foundation. I can’t hide I’m a bit worried about, ’cause I know It’s not trivial task, I read all the planning and installation check lists, I saw a big area of work… I hope I can accomplish in a week, but I hope maybe less, I don’t now, so know I wish to ask to you, to everybody has done before, or still working on, if my time “plan” is correct and what kind of “dangerous things” I can expect, so please comment or send me a message about!

After I will say what has been my experience!

Ciao

Technorati Tag: Team System,Work
Go to Top