Glare.Engine.NodeType.GetNodeType C# (CSharp) Method

GetNodeType() public static method

Get the NodeType for a System.Type.
public static GetNodeType ( Type type ) : NodeType
type System.Type
return NodeType
        public static NodeType GetNodeType(Type type)
        {
            NodeType nodeType;

            if (NodeTypes.TryGetValue(type, out nodeType))
                return nodeType;

            if (type == null)
                throw new ArgumentNullException("type");
            if (!type.IsSubclassOf(typeof(Node)))
                throw new ArgumentException("Type " + type.Name + " is not a sub-class of " + typeof(Node).Name);

            return NodeTypes[type] = nodeType = new NodeType(type);
        }

Usage Example

Example #1
0
 /// <summary>Find a property of the type. If not found, this throws an exception.</summary>
 /// <param name="type"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 protected static NodeTypeProperty GetProperty(Type type, string name)
 {
     return(NodeType.GetNodeType(type).GetProperty(name));
 }