Browse by Tags
All Tags »
C# (
RSS)
Acyclic Visitor Design Pattern The Visitor Design Pattern allow new functions to be added to existing class hierarchies without affecting those hierarchies. The Acyclic Visitor Design Pattern is saved you from implementing some unrequired methods using downcasting. The following code sample display 3 elements: Element1 , Element2 and Element3 , and two concrete visitors: Visitor12 and Visitor3 . The Acyclic Visitor Design Pattern is preventing you from implement method Visit(Element3) in Visitor12...
Serializable CollectionBase Class The idea of class CollectionBase is to have a base class which is based on list for serialization, and also on dictionary for fast retrieval. So I have tried to create class CollectionBase class which is serializable, and when I try to serialize it with XmlSerializable , I got the following runtime exception: "To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy...
User Defined Exception Class Let's say you want to define Serializable Exception-Derived type MyException , and you want it to inherits from class exception. The following class sameple show how to derived new serializable class from class Exception: [ Serializable ] // Making your exception serializable public class MyException : Exception , ISerializable { private String m_errorId; public String ErrorId { get { return m_errorId; } } public override String Message { get { if (m_errorId == null...