Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Override.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Core.Reflection
6 {
7  /// <summary>
8  /// This class is holding the PropertyKey using to store <see cref="OverrideType"/> per object into the <see cref="ShadowObject"/>.
9  /// </summary>
10  public static class Override
11  {
12  /// <summary>
13  /// The OverrideType key.
14  /// </summary>
15  private static readonly PropertyKey<OverrideType> OverrideKey = new PropertyKey<OverrideType>("Override", typeof(Override), DefaultValueMetadata.Static(OverrideType.New));
16 
17  /// <summary>
18  /// Gets the override for the specified member.
19  /// </summary>
20  /// <param name="instance">The instance.</param>
21  /// <param name="memberDescriptor">The member descriptor.</param>
22  /// <returns>OverrideType.</returns>
23  /// <exception cref="System.ArgumentNullException">
24  /// instance
25  /// or
26  /// memberDescriptor
27  /// </exception>
28  public static OverrideType GetOverride(this object instance, IMemberDescriptor memberDescriptor)
29  {
30  if (instance == null) throw new ArgumentNullException("instance");
31  if (memberDescriptor == null) throw new ArgumentNullException("memberDescriptor");
32  OverrideType overrideType;
33  return instance.TryGetDynamicProperty(memberDescriptor, OverrideKey, out overrideType) ? overrideType : OverrideType.Base;
34  }
35 
36  /// <summary>
37  /// Sets the override for the specified member.
38  /// </summary>
39  /// <param name="instance">The instance.</param>
40  /// <param name="memberDescriptor">The member descriptor.</param>
41  /// <param name="overrideType">Type of the override.</param>
42  /// <exception cref="System.ArgumentNullException">
43  /// instance
44  /// or
45  /// memberDescriptor
46  /// </exception>
47  public static void SetOverride(this object instance, IMemberDescriptor memberDescriptor, OverrideType overrideType)
48  {
49  if (instance == null) throw new ArgumentNullException("instance");
50  if (memberDescriptor == null) throw new ArgumentNullException("memberDescriptor");
51  instance.SetDynamicProperty(memberDescriptor, OverrideKey, overrideType);
52  }
53  }
54 }
static void SetOverride(this object instance, IMemberDescriptor memberDescriptor, OverrideType overrideType)
Sets the override for the specified member.
Definition: Override.cs:47
This class is holding the PropertyKey using to store OverrideType per object into the ShadowObject...
Definition: Override.cs:10
OverrideType
A Type of override used on a member value.
Definition: OverrideType.cs:11
static OverrideType GetOverride(this object instance, IMemberDescriptor memberDescriptor)
Gets the override for the specified member.
Definition: Override.cs:28
A class that represents a tag propety.
Definition: PropertyKey.cs:17