Notification

References
A Notification instance can be used to inform the user about various events. For a Notification instance to be displayed in Rhino, it must be added to the NotificationCenter. When added, it will be displayed in the Notifications panel in Rhino. A Notification contains 1 to 3 buttons that are automatically wired to its ButtonClicked Action if it is not null. The buttons are displayed when the Notification is shown modally by either the user clicking on a particular notification in the Notifications panel, or by programatically showing it using ShowModal(). Currently, only process-wide notifications are supported; document specific notifications are not possible. Notification instances contain metadata that can be added, modified, or removed during its life. The metadata is important for LINQ queries and other patterns. For example, a particular action may require that multiple notifications be modified. Thus, a LINQ query can be performed on the NotificationCenter using metadata to retrieve related Notification objects and modify them as a batch. Notification objects implement IAssemblyRestrictedObject. By default, a Notification can be editedby any assembly, but explicitly specifing allowed assemblies in the constructor changes this behavior. Notification objects are not thread-safe and should only be manipulated in UI thread.

Constructors

Notification

#Since v6.0
public Notification()
Creates a new instance that can be edited by any assembly.

Notification

#Since v6.0
public Notification(IEnumerable<Assembly> allowedAssemblies)
Creates a new instance that can be edited by the given assemblies.
Remarks: Specifying one or more assemblies limits certain operations with the notification object, throwing an InvalidOperationException if an assembly outside the ones passed tries to interact with it. Any code that tries to interact with a notification object that has restricted assemblies must be wrapped in a ExecuteAssemblyProtectedCode(Action). For performance reasons, it is imporant that such methods are kept as simple as possible.
allowedAssemblies (IEnumerable<Assembly>)The assemblies that will be allowed to edit the instance. If null or empty, any assembly will be able to edit this notification.

Properties

AllowedAssemblies

#Since v6.0
public ICollection<Assembly> AllowedAssemblies { get; }
The assemblies that can modify this instance.
Remarks: If empty, any assembly is allowed to edit the instance. You may specify additional assemblies that should have access to an instance at creation time.

AlternateButtonTitle

#Since v6.0
public string AlternateButtonTitle { get; set; }
The localized title of the Alternate button.
Remarks: Notifications can 1 to 3 buttons for user input. Each button can have a localized title. With the exception of the Cancel button, setting a button title to null (the default) will prevent that button from appearing in the interface. Note that in order for buttons other than the Cancel button to be displayed, you must set a ButtonClicked Action.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ButtonClicked

#Since v6.0
public Action<ButtonType> ButtonClicked { get; set; }
An Action that will be invoked whenever a button for the notification is clicked or the notification is closed.

CancelButtonTitle

#Since v6.0
public string CancelButtonTitle { get; set; }
The localized title of the Cancel button.
Remarks: Notifications can 1 to 3 buttons for user input. Each button can have a localized title. With the exception of the Cancel button, setting a button title to null (the default) will prevent that button from appearing in the interface. Note that in order for buttons other than the Cancel button to be displayed, you must set a ButtonClicked Action.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ConfirmButtonTitle

#Since v6.0
public string ConfirmButtonTitle { get; set; }
The localized title of the Confirm button.
Remarks: Notifications can 1 to 3 buttons for user input. Each button can have a localized title. With the exception of the Cancel button, setting a button title to null (the default) will prevent that button from appearing in the interface. Note that in order for buttons other than the Cancel button to be displayed, you must set a ButtonClicked Action.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

DateUpdated

#Since v6.0
public DateTime DateUpdated { get; }
The date the notification was last modified.
Remarks: Only visible elements of the notification will cause this property to change. Changes in metadata or other non-visible members will have no effect on this property.

Description

#Since v6.0
public string Description { get; set; }
The description of the notification. The description is displayed in the Notifications panel in Rhino.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

Message

#Since v6.0
public string Message { get; set; }
The message of the notification. The message is shown only when the instance is displayed modally. It should contain details about the notification.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

MetadataCopy

#Since v6.0
public IDictionary<string, string> MetadataCopy { get; }
A copy of all the metadata for this class.
Remarks: Modifying the returned dictionary will have no effect on the metadata for this notification.

SeverityLevel

#Since v6.0
public Notification.Severity SeverityLevel { get; set; }
The severity of the notification. Changing the severity of the notification may change the way Rhino chooses to display the Notifications panel.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ShowEventId

#Since v6.0
public Guid? ShowEventId { get; }
A field used by Rhino for displaying notifications. Not intended for public use.

Title

#Since v6.0
public string Title { get; set; }
The title of the notification. The title is displayed when the notification is displayed modally in Rhino.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

Indexers

this[]

#
public string this[string key] { get; set; }
Gets or sets metadata for this instance.
key (string)The key to use to get or set metadata.
null if the key does not map to any metadata; otherwise returns the string representing the metadata.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

Methods

Editable

#Since v6.3
public bool Editable()
Determines whether an assembly can modify the instance. Any code that modifies an assembly protected notification must be wrapped in a ExecuteAssemblyProtectedCode(Action) method.
Remarks: Before modifying a notification you are not sure you created (such as a notification returned from a LINQ query), you should call this method first to ensure you can indeed edit the object.
Editable

ExecuteAssemblyProtectedCode<TResult>

#Since v6.3
public static TResult ExecuteAssemblyProtectedCode<TResult>(Func<TResult> func)
If a Notification object is only allowed to be modified by certain assemblies, then any code that interacts with it must be wrapped around this method, or a InvalidOperationException will be thrown. For performance reasons, the code wrapped by this method should be kept as simple as possible.
Remarks: This method is not thread-safe and should only be manipulated in UI thread.
func (Func<TResult>)The code to run that modifies one or more notification objects

ExecuteAssemblyProtectedCode

#Since v6.3
public static void ExecuteAssemblyProtectedCode(Action action)
If a Notification object is only allowed to be modified by certain assemblies, then any code that interacts with it must be wrapped around this method, or a InvalidOperationException will be thrown. For performance reasons, the code wrapped by this method should be kept as simple as possible.
Remarks: This method is not thread-safe and should only be manipulated in UI thread.
action (Action)The code to run that modifies one or more notification objects

HideModal

#Since v6.0
public void HideModal()
Tells Rhino to hide the notification if it is being currently shown as a modal.
Remarks: If the notification is not being currently shown but is being queued by Rhino as a result of calling ShowModal(), then the notification will be dequeued. If the notification was never queued, then this method has no effect.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

RemoveMetadata

#Since v6.0
public bool RemoveMetadata(string key)
Removes metadata from this instance.
key (string)The key of the metadata to remove.
true if the metada was removed; otherwise false.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ShowModal

#Since v6.0
public void ShowModal()
Tells Rhino to display the notification modally.
Remarks: The notification will only be displayed if/once the instance is added to the NotificationCenter. Rhino keeps a queue of notifications that need to be shown modally, so calling this method does not mean that this particular notification will be immediately displayed.

ToString

#
public override string ToString()
Returns a readable string representation of the instance.
Object.ToString

Events

PropertyChanged

#Since v6.0
public event PropertyChangedEventHandler PropertyChanged
Triggered whenever a visible property of the instance changes.