Read Rss into DataSet

The simple trick shows how to read rss feed into DataSet .

using System;
using System.Data;
using System.Net;
 
namespace DevIntelligence.Examples
{
    class RssReader
    {
        [STAThread]
        static void Main(string[] args)
        {
            HttpWebRequest feed = 
            HttpWebRequest.Create("http://msdn.microsoft.com/rss.xml") 
            as HttpWebRequest;
            
            DataSet data = new DataSet();
            data.ReadXml( feed.GetResponse().GetResponseStream()) ;
        }
    }
}

.Net Sample for Amazon Web Services (AWS) Request Authentication

The following code sample demonstrates how to calculate a request signature to sign authenticated requests to AWS.

 

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
 
 
namespace Devintelligence.Aws
{
    /// <summary>
    /// Generation authentication signatures for AWS Platform requests.
    /// </summary>
    public class AwsUtils
    {
        /// <summary>
        /// Computes RFC 2104-compliant HMAC signature.
        /// </summary>
        /// <param name="data">The data to be signed.</param>
        /// <param name="key">The signing key.</param>
        /// <returns>The Base64-encoded RFC 2104-compliant HMAC signature.</returns>
        public static string calculateRFC2104HMAC(string data, string key)
        {
            byte[] bData = Encoding.UTF8.GetBytes(data);
            byte[] bKey = Encoding.UTF8.GetBytes(key);
 
 
            HMACSHA1 hmac = new HMACSHA1(bKey);
            using(CryptoStream cryptoStream =
                      new CryptoStream(Stream.Null, hmac, CryptoStreamMode.Write) )
            {
                cryptoStream.Write(bData, 0, bData.Length);
            }
            return Convert.ToBase64String(hmac.Hash);
        }
 
 
 
 
 
        /// <summary>
        /// Gets the time stamp.
        /// </summary>
        /// <param name="dateTime">Date time.</param>
        /// <returns></returns>
        public static string GetTimeStamp(DateTime dateTime)
        {
            return dateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
        }
 
    }
}

Use BackgroundWorker with any class

BackgroundWorker works only with the classes that implements interface ISynchronizeInvoke – in order to use BackgroundWorker with any class necessary to make the following changes in the code.

The code after the changes ( BackgroundWorker.cs ):

private void InvokeDelegate(Delegate del, params object[] args)
{
    ISynchronizeInvoke synchronizer = del.Target as ISynchronizeInvoke;
    try
    {
        if(synchronizer != null) //A Windows Forms object
        {
            if (synchronizer.InvokeRequired == false)
            {
                del.DynamicInvoke(args);
                return;
            }
            synchronizer.Invoke(del, args);
        }
        else //Not a Windows Forms object
        {
            del.DynamicInvoke(args);
        }
    }
    catch (Exception e)
    {
        Trace.WriteLine(e.Message);
    }
}

 

 

Thanks to Roy Osherove for help in the solution of this problem

System.Drawing.Color serialization

The Person class includes a HairColor property that stores a Color object. Because a Color cannot be automatically serialized/deserialized using the .NET System.Xml.Serialization.XmlSerializer class, the Color object is saved to the XML file as an HTML string, and converted back into a Color when the XML file is loaded.

sing System;
using System.Drawing;
using System.Xml.Serialization;
 
 
//To support binary serialization you need to 
// add the "[Serializable]" attribute
[Serializable]
public class Person
{
    private Color _HairColor = Color.Empty;
        
    // Initializes a new instance of the Person class.
    // (required for serialization)
    public Person()
    {
            
    }
        
        
    // Set serialization to ignore this property
        // because the 'HairColorHtml' property
        // is used instead to serialize
        // the 'HairColor' Color as an HTML string.
    [XmlIgnoreAttribute()]
    public Color HairColor
    {
        get
        {
            return _HairColor;
        }
        set
        {
            _HairColor = value;
        }
    }
        
        
    // Serializes the 'HairColor' Color to XML.
    [XmlElement("HairColor")]
    public string HairColorHtml
    {
        get 
        { 
            return
                ColorTranslator.ToHtml(_HairColor);
        }
        set 
        { 
            _HairColor = ColorTranslator.FromHtml( value );
        }
    }
        
}

Microsoft: .NET 2.0 | Clone Attack :-)

The Windows Forms team has posted .NET 2.0 versions of their UI clone apps, including:

 Quicken Look and Feel – Mike Harsh   
This is a UI front end that has the look and feel of Quicken

Outlook 2003 Look and Feel – Joe Stegman   
This is a UI front end that has the look and feel of Microsoft Outlook 2003. 

File Explorer Look and Feel – Joe Stegman   
This is a UI front end that has the look and feel of Windows File Explorer 

Microsoft Money Look and Feel – Joe Stegman   
This is a UI front end that has the look and feel of Microsoft Money 

Internet Explorer Look and Feel – Joe Stegman   
This is a Windows Forms app that looks like Internet Explorer 6 and uses the new WebBrowser control. 

[Via Chris Sells]


Page 4 of 41234