Standing on the shoulders of giants. RSS 2.0
# Friday, May 20, 2005

Mart is experimenting with WSS 2.0 on windows 2003 R2, he just posted his first article on the installation.

Friday, May 20, 2005 11:24:17 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
ASP.NET | Office 2007
# Thursday, May 19, 2005

I saw it tonight, this review by Anthony Lane accurately describes how I feel about it.

And now I would like those 2 hours of my live back please.

[link via Tim Bray's Ongoing]

Thursday, May 19, 2005 12:56:13 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Film
# Sunday, May 15, 2005

When serializing a class with an event, all classes subscribing to that event have to be serializable aswell. Usually you don't have any control over the classes subscribing to that event, or you don't want them to be remoted in the first place.

By adding the NonSerialized attribute to the event, with the field keyword, the field that holds the delegate for the event is stored is not serialized. So those subsribers no longer need to be serializable.

// ===============================================================================
// Copyright (C) 2005 Paul van Brenk
// All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
// ==============================================================================
// Serializing a class with an event sample.
// ==============================================================================


using System;

namespace Paulb.CodeSnippets
{
    [Serializable]
    public class SerializableClass
    {
        public SerializableClass()
        {
            ///
        }
        
        // adding the NonSerialized attribute this way,
        // we don't serialize the field where the delegate for this event is stored,
        // that way those subscribers don't need to be serializable.
        [field: NonSerialized]
        public event EventHandler Event;
    }

    /// <summary>
    /// This class can not be serialized, since the serializable attribute is missing.
    /// </summary>
    public class NotSerializedClass{

        public NotSerializedClass(){
        
            serializable.Event +=new EventHandler(serializable_Event);
        }

        private SerializableClass serializable = new SerializableClass();

        private void serializable_Event(object sender, EventArgs e) {
            // handle event here
        }
    }
}

Some background on how events are compiled from "The C# programming language" p330:

"When compiling a field-like event, the compiler automatically creates storage to hold the delegate and created accessors for the event that add or remove event handlers to the delegate field."

This results in the pseudo code generated for the SerializableClass:

.class public auto ansi serializable beforefieldinit SerializableClass
extends object
{
.event [mscorlib]System.EventHandler Event
{

// event accessors

.addon instance void Paulb.CodeSnippets.SerializableClass::add_Event([mscorlib]System.EventHandler)
.removeon instance void Paulb.CodeSnippets.SerializableClass::add_Event([mscorlib]System.EventHandler)
}


.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
}

// delegate storage
.field private [mscorlib]System.EventHandler Event

}


disclaimer: Use at your own risk. This code is not threatsafe. Bugs, omissions let me know.

SerializingSample.cs (1.42 KB)
Sunday, May 15, 2005 4:19:56 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Codesnippet | Development

I decided to add a new category, Codesnipper, to my blog, where I can post small classes, pieces of sample code and other usefull pieces of code. That way I'll be able to find it again and maybe it's usefull to someone else aswell. So without further ado: the Most Recently Used Hashtable.

Hashtable with a fixed capacity; removing the last one touched when inserting a new entry once the capacity has been reached. Returns null for items older then the maximum age.

// ===============================================================================
// Copyright (C) 2005 Paul van Brenk
// All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
// ==============================================================================
// Hashtable with a fixed capacity; removing the last one touched when inserting a
// new entry once the capacity has been reached.
// Returns null for items older then the maximum age.
// ==============================================================================

using System;
using System.Collections;

namespace PaulB.Collections {

    /// <summary>
    /// CustomHashtable with a fixad capacity removing the oldest item first.
    /// </summary>
    public class MRUHashtable : IEnumerable {
    
        /// <summary>
        ///
        /// note: no max. caching time.
        /// </summary>
        /// <param name="capacity">number of items</param>
        public MRUHashtable( int capacity ) : this( capacity, TimeSpan.MaxValue ){
            //...    
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="capacity">number of items</param>
        /// <param name="maxAge">time to cache items in minutes (0 means no max. caching time)</param>
        public MRUHashtable( int capacity, int maxAge ) : this ( capacity, new TimeSpan(0, maxAge, 0) ){
            ///....
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="capacity">number of items</param>
        /// <param name="maxAge">time to cache items</param>
        public MRUHashtable( int capacity, TimeSpan maxAge ){
            this.itemTable = new Hashtable( capacity );
            this.timeTable = new Hashtable( capacity );
            this.capacity = capacity;
            this.maxAge = maxAge;
        }

        public void Add( object key, object value ){
            
            if( this.Count >= this.capacity ){
                this.RemoveOldestItem();        
            }

            this.timeTable.Add(key, DateTime.UtcNow);
            this.itemTable.Add(key, value);
        }

        public void Clear(){
            this.itemTable.Clear();
            this.timeTable.Clear();
        }

        private void RemoveOldestItem(){
            object item = null;
            DateTime lastAccess = DateTime.MinValue;
            foreach( object key in this.itemTable.Keys ){
                if( item != null && (DateTime)this.timeTable[key] > lastAccess ){
                    continue;
                }
                item = this.itemTable[key];
                lastAccess = (DateTime)this.timeTable[key];
            }
            this.Remove(item);
        }

        public IEnumerator GetEnumerator(){
            return itemTable.GetEnumerator();
        }

        public void Remove(object key){
            this.timeTable.Remove(key);
            this.itemTable.Remove(key);
        }

        public bool Contains( object key ){
            
            CheckAccessTime(key);
            this.UpdateAccessTime(key);
            return this.itemTable.Contains(key);
        }

        private void UpdateAccessTime(object key){
            if( this.timeTable[key] != null ){
                this.timeTable[key] = DateTime.UtcNow;
            }
        }

        private void CheckAccessTime(object key){
         //prevent stale information
            if( timeTable[key] == null || (DateTime.UtcNow - (DateTime)timeTable[key]) > maxAge ){
                this.Remove(key);
            }
        }

        public object this[object key]{
            get{
                CheckAccessTime(key);
                UpdateAccessTime(key);
                return this.itemTable[key];
            }
            set{
                if( this.itemTable[key] == null ){
                    this.timeTable.Add(key, value);
                }else{
                    this.UpdateAccessTime(key);
                }
                this.itemTable[key] = value;
            }
        }

        public int Count{
            get{
                return this.itemTable.Count;
            }
        }

        public object SyncRoot{
            get{
                return this.itemTable.SyncRoot;
            }
        }

        public ICollection Values{
            get{
                return this.itemTable.Values;
            }
        }

        private int capacity;
        private TimeSpan maxAge;
        private Hashtable itemTable;
        private Hashtable timeTable;
    }
}

disclaimer: Use at your own risk. This code is not threatsafe. Bugs, omissions let me know.

MRUHashtable.cs (3.85 KB)
Sunday, May 15, 2005 3:04:54 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Codesnippet | Development
# Sunday, April 10, 2005

Fellow Geeks, we must strive for excellence not only in our code, but also in our interactions with Those Who Think HTML is a Programming Language.

Excellent ‘rant’ about the value of a developer involved in more then just developing software, like sales or customer support. But: “As developers, we are often just not qualified to participate in things like sales or marketing or strategy. We can be too abrasive to talk with customers. We love certain technologies too much to be objective. We forget that users are very different from us.

 

Sunday, April 10, 2005 12:09:55 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Business
# Saturday, March 12, 2005
Sleeping beauties

Sleeping beauties

Saturday, March 12, 2005 6:25:57 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [0] - Trackback

# Tuesday, March 08, 2005

Bart has resurrected his blog and is focusing on using portal technology in real-life applications. Allthough not as technical as Mart's Sharepoint blog, but certainly worth the reading, if you're implementing portal technology for your (internal) customers.

His first post, "Clients demand sharepoint, but sometimes lack portalvision..." , discusses the dissapointment some customers will feel, when they realise Sharepoint will not solve all their problems and world hunger, without a clear understanding what their problems are or without support from the entire organisation. 

Tuesday, March 08, 2005 7:00:43 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [0] - Trackback
Office 2003 | Sharepoint
# Monday, March 07, 2005

The most interesting quote from the press release, would be:

"Windows® and Office are a powerful foundation for productivity and a rich platform for partners to build great solutions and add value,"  Gates said. "The Microsoft Business Solutions group builds on that foundation to deliver world-class business applications that are simpler and less expensive, offering more companies new ways to enhance the way they work."

Which shows MSFT is moving towards further integrating it’s Business Solutions with Office and selling it more and more as a platform as well as an application suite, see also VSTO 2005.

One more quote:

"Project Green," the code name for next-generation Microsoft Business Solutions' development efforts, will be delivered over the course of two waves. The first wave will occur between 2005 and 2007, and will include the release of a shared user interface based around 50 common configurable roles that people have within a company, all seamlessly integrated with Microsoft Office. Microsoft's business applications also will interoperate with service-oriented applications and include a common configurable reporting environment based on SQL Server (TM) Reporting Services and a common security-enhanced intranet and extranet environment based on Microsoft Office SharePoint® Portal Server to enable new levels of collaboration within and across companies. (Emphasize mine)

Looking forward to see what improvements have been made, esp. in Microsoft CRM, est. RTM Q4 2005, since that isn’t the friendliest platform to base a solution on.

Monday, March 07, 2005 11:52:28 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [0] - Trackback
Business
# Monday, February 14, 2005
luke nyswonger posts an incredible amount of powertoys for biz talk server 2004 collected by Erik Leaseburg.
Monday, February 14, 2005 7:20:04 AM (W. Europe Standard Time, UTC+01:00)  #    Comments [0] - Trackback
Development
About
© Copyright 2008
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.8275.16006
All Content © 2008, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)