Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ObservableNodeTemplateProvider.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 using SiliconStudio.Presentation.View;
6 
7 namespace SiliconStudio.Presentation.Quantum.View
8 {
9  /// <summary>
10  /// A base class for implementations of <see cref="ITemplateProvider"/> that can provide templates for <see cref="IObservableNode"/> instances.
11  /// </summary>
13  {
14  /// <inheritdoc/>
15  public override bool Match(object obj)
16  {
17  return obj is IObservableNode && MatchNode((IObservableNode)obj);
18  }
19 
20  /// <summary>
21  /// Indicates whether this instance of <see cref="ITemplateProvider"/> can provide a template for the given <see cref="IObservableNode"/>.
22  /// </summary>
23  /// <param name="node">The node to test.</param>
24  /// <returns><c>true</c> if this template provider can provide a template for the given node, <c>false</c> otherwise.</returns>
25  /// <remarks>This method is invoked by <see cref="Match"/>.</remarks>
26  public abstract bool MatchNode(IObservableNode node);
27 
28  /// <summary>
29  /// Indicates whether the given node matches the given type, either with the <see cref="IObservableNode.Type"/> property
30  /// or the type of the <see cref="IObservableNode.Value"/> property.
31  /// </summary>
32  /// <param name="node">The node to check.</param>
33  /// <param name="type">The type to match.</param>
34  /// <returns><c>true</c> if the node matches the given type, <c>false</c> otherwise.</returns>
35  protected static bool MatchType(IObservableNode node, Type type)
36  {
37  return type.IsAssignableFrom(node.Type) || type.IsInstanceOfType(node.Value);
38  }
39  }
40 }
An abstract implementation of the ITemplateProvider interface.
A base class for implementations of ITemplateProvider that can provide templates for IObservableNode ...
static bool MatchType(IObservableNode node, Type type)
Indicates whether the given node matches the given type, either with the IObservableNode.Type property or the type of the IObservableNode.Value property.
override bool Match(object obj)
Indicates whether this instance of ITemplateProvider can provide a template for the given object...