Assembly: DigitalRune.Geometry (in DigitalRune.Geometry.dll) Version: 1.9.0.0 (1.9.3.9490)
Syntax
| C# |
|---|
public Shape Shape { get; set; } |
| Visual Basic |
|---|
Public Property Shape As Shape Get Set |
| Visual C++ |
|---|
public: virtual property Shape^ Shape { Shape^ get () sealed; void set (Shape^ value) sealed; } |
Field Value
The shape. The shape must not be nullNothingnullptra null reference (Nothing in Visual Basic), but it can be of type EmptyShape (see Empty).Implements
IGeometricObject..::..Shape
Remarks
Changing this property raises the ShapeChanged event.
Important: An IGeometricObject instance registers event handlers for the Changed event of the contained Shape. Therefore, a Shape will have an indirect reference to the IGeometricObject. This is no problem if the geometric object exclusively owns the shape. However, this could lead to problems ("life extension bugs" a.k.a. "memory leaks") when multiple geometric objects share the same shape: One geometric object is no longer used but it cannot be collected by the garbage collector because the shape still holds a reference to the object.
Therefore, when Shapes are shared between multiple IGeometricObjects: Always set the property Shape to Empty when the IGeometricObject is no longer used. Empty is a special immutable shape that never raises any Changed events. Setting Shape to Empty ensures that the internal event handlers are unregistered and the object can be garbage-collected properly.
Exceptions
| Exception | Condition |
|---|---|
| System..::..ArgumentNullException | value is nullNothingnullptra null reference (Nothing in Visual Basic). |