/**
         * Post with a specified initializer.
         */
        public void Post(string notificationId, NotificationInitializer initializer)
        {
            NotificationInstance notif = NotificationInstance.Borrow(notificationId);

            initializer(notif);
            Post(notif);             // will return notification instance here
        }
        /**
         * Borrows an instance.
         */
        public static NotificationInstance Borrow(string id)
        {
            NotificationInstance instance = null;

            if (instanceStack.Count > 0)
            {
                instance = instanceStack.Pop();
            }
            else
            {
                instance = new NotificationInstance();
            }

            instance.Init(id);
            instance.Activate();
            return(instance);
        }
        /**
         * Notify with a certain Notification instance.
         */
        public void Post(NotificationInstance notification)
        {
            if (handlerList.Count == 0)
            {
                // no notification handlers to handle it
                NotificationInstance.Return(notification);
                return;
            }

            LinkedListNode <NotificationHandler> currentNode = handlerList.First;

            do
            {
                currentNode.Value.HandleNotification(notification);
                currentNode = currentNode.Next;
            } while(currentNode != null);

            // we return the instance after posting so it will be deactivated and may not be used again
            NotificationInstance.Return(notification);
        }
 /**
  * Returns an instance.
  */
 public static void Return(NotificationInstance instance)
 {
     instance.Deactivate();
     instanceStack.Push(instance);
 }
 /**
  * Utility function to start a notification with parameter. This was made to avoid usage of closures which may instantiate memory.
  */
 public NotificationInstance Begin(string notificationId)
 {
     return(NotificationInstance.Borrow(notificationId));
 }
 /**
  * Notify with a notification id.
  */
 public void Post(string notificationId)
 {
     Post(NotificationInstance.Borrow(notificationId));
 }