Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SiliconStudio.Core.PropertyContainer Struct Reference

Represents a container that can hold properties, lightweight to embed (lazy initialized). More...

Inheritance diagram for SiliconStudio.Core.PropertyContainer:
IEnumerable< KeyValuePair< PropertyKey, object >>

Classes

class  Serializer
 Serializer for the PropertyContainer
 
class  ValueHolder
 
class  ValueHolder< T >
 

Public Member Functions

delegate void PropertyUpdatedDelegate (ref PropertyContainer propertyContainer, PropertyKey propertyKey, object newValue, object oldValue)
 Property changed delegate. More...
 
 PropertyContainer (object owner)
 
IEnumerator< KeyValuePair
< PropertyKey, object > > 
GetEnumerator ()
 Gets the key-properties value pairs in this instance. More...
 
void Clear ()
 
void Add< T > (PropertyKey< T > key, T value)
 Adds the specified key-value pair. More...
 
bool ContainsKey (PropertyKey key)
 Determines whether the specified instance contains this key. More...
 
void Add (PropertyKey key, object value)
 
bool Remove (PropertyKey propertyKey)
 
void CopyTo (ref PropertyContainer destination)
 Copies properties from this instance to a container. More...
 
object Get (PropertyKey propertyKey)
 Gets the specified tag value. More...
 
Get< T > (PropertyKey< T > propertyKey)
 Gets the specified tag value. More...
 
bool TryGetValue (PropertyKey propertyKey, out object value)
 Tries to get a tag value. More...
 
bool TryGetValue< T > (PropertyKey< T > propertyKey, out T value)
 Tries to get a tag value. More...
 
void Set< T > (PropertyKey< T > propertyKey, T tagValue)
 Sets the specified tag value. More...
 
void SetObject (PropertyKey propertyKey, object tagValue)
 Sets the specified tag value. More...
 
IEnumerator IEnumerable. GetEnumerator ()
 

Static Public Member Functions

static void AddAccessorProperty (Type type, PropertyKey propertyKey)
 

Properties

object Owner [get, set]
 
int Count [get]
 Gets the number of properties stored in this container. More...
 
bool IsReadOnly [get]
 
object this[PropertyKey key] [get, set]
 
ICollection< PropertyKeyKeys [get]
 
ICollection< object > Values [get]
 

Events

PropertyUpdatedDelegate PropertyUpdated
 Occurs when a property is modified. More...
 

Detailed Description

Represents a container that can hold properties, lightweight to embed (lazy initialized).

Tag properties system purpose is to allow binding of properties that aren't logically supposed to be in a general class (probably because the property exists only in a higher level part of the engine). A typical example includes source mesh, collision data and various bouding volumes for a Geometry object: including them directly in the low-level Geometry class would be a terrible design decision ! And the other well known solution, which consist of maintaining a Dictionary of object to properties isn't really nice either (especially with non-deterministic object destruction, it's hard to clean it up, would require lot of events). As a result, a specific system has been implemented. A class that could hold such tag properties should have an instance of PropertyContainer as a mutable field member. An cool feature of this system is that if a property doesn't exist, it could be generated during first access from a delegate or come from a default value.

Definition at line 29 of file PropertyContainer.cs.

Constructor & Destructor Documentation

SiliconStudio.Core.PropertyContainer.PropertyContainer ( object  owner)

Definition at line 51 of file PropertyContainer.cs.

Member Function Documentation

void SiliconStudio.Core.PropertyContainer.Add ( PropertyKey  key,
object  value 
)

Definition at line 150 of file PropertyContainer.cs.

void SiliconStudio.Core.PropertyContainer.Add< T > ( PropertyKey< T >  key,
value 
)

Adds the specified key-value pair.

Template Parameters
T
Parameters
keyThe key.
valueThe value.

Definition at line 133 of file PropertyContainer.cs.

static void SiliconStudio.Core.PropertyContainer.AddAccessorProperty ( Type  type,
PropertyKey  propertyKey 
)
static
void SiliconStudio.Core.PropertyContainer.Clear ( )

Definition at line 102 of file PropertyContainer.cs.

bool SiliconStudio.Core.PropertyContainer.ContainsKey ( PropertyKey  key)

Determines whether the specified instance contains this key.

Parameters
keyThe key.
Returns
true if the specified instance contains this key; otherwise, false.

Definition at line 145 of file PropertyContainer.cs.

void SiliconStudio.Core.PropertyContainer.CopyTo ( ref PropertyContainer  destination)

Copies properties from this instance to a container.

Parameters
destinationThe destination.

Definition at line 218 of file PropertyContainer.cs.

object SiliconStudio.Core.PropertyContainer.Get ( PropertyKey  propertyKey)

Gets the specified tag value.

Parameters
propertyKeyThe tag property.
Returns
Value of the tag property

Definition at line 229 of file PropertyContainer.cs.

Referenced by SiliconStudio.Paradox.UI.Panels.Panel.PanelChildrenComparer.Compare(), SiliconStudio.Paradox.UI.Panels.GridBase.GetElementGridPositions(), and SiliconStudio.Paradox.UI.Panels.GridBase.GetElementSpanValues().

Gets the specified tag value.

Template Parameters
TType of the tag value
Parameters
propertyKeyThe tag property.
Returns
Typed value of the tag property

Definition at line 275 of file PropertyContainer.cs.

References SiliconStudio.Core.PropertyKey.AccessorMetadata, SiliconStudio.Core.PropertyKey.DefaultValueMetadata, SiliconStudio.Core.PropertyKey.IsValueType, and SiliconStudio.Core.DefaultValueMetadata.KeepValue.

IEnumerator<KeyValuePair<PropertyKey, object> > SiliconStudio.Core.PropertyContainer.GetEnumerator ( )

Gets the key-properties value pairs in this instance.

Definition at line 73 of file PropertyContainer.cs.

IEnumerator IEnumerable. SiliconStudio.Core.PropertyContainer.GetEnumerator ( )

Definition at line 566 of file PropertyContainer.cs.

delegate void SiliconStudio.Core.PropertyContainer.PropertyUpdatedDelegate ( ref PropertyContainer  propertyContainer,
PropertyKey  propertyKey,
object  newValue,
object  oldValue 
)

Property changed delegate.

Parameters
containerThe property container.
keyThe property key.
newValueThe property new value.
oldValueThe property old value.
bool SiliconStudio.Core.PropertyContainer.Remove ( PropertyKey  propertyKey)

Definition at line 155 of file PropertyContainer.cs.

void SiliconStudio.Core.PropertyContainer.Set< T > ( PropertyKey< T >  propertyKey,
tagValue 
)
void SiliconStudio.Core.PropertyContainer.SetObject ( PropertyKey  propertyKey,
object  tagValue 
)

Sets the specified tag value.

Parameters
propertyKeyThe tag property.
tagValueThe tag value.

Definition at line 454 of file PropertyContainer.cs.

bool SiliconStudio.Core.PropertyContainer.TryGetValue ( PropertyKey  propertyKey,
out object  value 
)

Tries to get a tag value.

Template Parameters
TType of the tag value
Parameters
propertyKeyThe tag property.
valueThe value or default vaue if not found
Returns
Returns true if the was found; false otherwise

Definition at line 322 of file PropertyContainer.cs.

Referenced by SiliconStudio.Paradox.Effects.Modules.Renderers.LightingGroupInfo.GetOrCreate().

bool SiliconStudio.Core.PropertyContainer.TryGetValue< T > ( PropertyKey< T >  propertyKey,
out T  value 
)

Tries to get a tag value.

Template Parameters
TType of the tag value
Parameters
propertyKeyThe tag property.
valueThe value or default vaue if not found
Returns
Returns true if the was found; false otherwise

Definition at line 343 of file PropertyContainer.cs.

Property Documentation

int SiliconStudio.Core.PropertyContainer.Count
get

Gets the number of properties stored in this container.

The count of properties.

Definition at line 112 of file PropertyContainer.cs.

bool SiliconStudio.Core.PropertyContainer.IsReadOnly
get

Definition at line 120 of file PropertyContainer.cs.

ICollection<PropertyKey> SiliconStudio.Core.PropertyContainer.Keys
get

Definition at line 197 of file PropertyContainer.cs.

object SiliconStudio.Core.PropertyContainer.Owner
getset

Definition at line 59 of file PropertyContainer.cs.

object SiliconStudio.Core.PropertyContainer.this[PropertyKey key]
getset

Definition at line 185 of file PropertyContainer.cs.

ICollection<object> SiliconStudio.Core.PropertyContainer.Values
get

Definition at line 206 of file PropertyContainer.cs.

Event Documentation

PropertyUpdatedDelegate SiliconStudio.Core.PropertyContainer.PropertyUpdated

Occurs when a property is modified.

Definition at line 49 of file PropertyContainer.cs.


The documentation for this struct was generated from the following file: