Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ShadowAttributes.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  internal sealed class ShadowAttributes
8  {
9  private readonly ShadowContainer container;
10  private readonly object memberKey;
11 
12  public ShadowAttributes(ShadowContainer container, object memberKey)
13  {
14  if (container == null) throw new ArgumentNullException("container");
15  if (memberKey == null) throw new ArgumentNullException("memberKey");
16 
17  this.container = container;
18  this.memberKey = memberKey;
19  }
20 
21  public ShadowContainer Container
22  {
23  get
24  {
25  return container;
26  }
27  }
28 
29  public object Key
30  {
31  get
32  {
33  return memberKey;
34  }
35  }
36 
37  public bool HasAttribute(PropertyKey key)
38  {
39  return Attributes.ContainsKey(key);
40  }
41 
42  public T GetAttribute<T>(PropertyKey<T> key)
43  {
44  return Attributes.Get(key);
45  }
46 
47  public bool TryGetAttribute<T>(PropertyKey<T> key, out T value)
48  {
49  return Attributes.TryGetValue(key, out value);
50  }
51 
52  public void SetAttribute<T>(PropertyKey<T> key, T value)
53  {
54  Attributes.SetObject(key, value);
55  }
56 
57  public PropertyContainer Attributes;
58  }
59 }