public Node CreateInstance(Node parent)
{
if (parent == null)
throw new ArgumentNullException("parent");
if (_type == null)
_type = TypeHandler.GetType(_className);
if (_type == null)
{
string exceptionMessage = String.Concat("Type not found, therefore the node can't be created.",
"\nClass name: ", _className,
"\nNode type path: ", _nodeTypePath,
"\nParent class name: ", (_parent != null ? _parent._className : "Parent is null"), "\n");
throw new ApplicationException(exceptionMessage);
}
//---- only public ctor is valid: public NodeDescendant(Node parent, string nodeTypeName)
ConstructorInfo ctor = _type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, _newArgTypes, null);
if (ctor == null)
throw new TypeInitializationException(String.Concat("Constructor not found. Valid signature: ctor(Node, string).\nClassName: ", _className), null);
Node node;
try
{
node = (Node)ctor.Invoke(new object[] { parent, this.Name });
}
catch (Exception ex) //rethrow
{
throw new ApplicationException(String.Concat("Couldn't create an instance of type '", _className,
"'. The invoked constructor threw an exception of type ", ex.GetType().Name, " (it said '", ex.Message, "')."), ex);
}
return node;
}
internal Node CreateInstance(NodeToken token)