Dynamo.Graph.Workspaces.WorkspaceModel.GetModelForElement C# (CSharp) Method

GetModelForElement() public method

Gets model by GUID which is contained in given Xml data.
public GetModelForElement ( XmlElement modelData ) : Dynamo.Models.ModelBase
modelData System.Xml.XmlElement Xml data to find model.
return Dynamo.Models.ModelBase
        public ModelBase GetModelForElement(XmlElement modelData)
        {
            // TODO(Ben): This may or may not be true, but I guess we should be
            // using "System.Type" (given the "type" information in "modelData"),
            // and determine the matching category (e.g. is this a Node, or a
            // Connector?) instead of checking in each and every collections we
            // have in the workspace.
            //
            // System.Type type = System.Type.GetType(helper.ReadString("type"));
            // if (typeof(Dynamo.Models.NodeModel).IsAssignableFrom(type))
            //     return Nodes.First((x) => (x.GUID == modelGuid));

            var helper = new XmlElementHelper(modelData);
            Guid modelGuid = helper.ReadGuid("guid");

            ModelBase foundModel = GetModelInternal(modelGuid);
            if (null != foundModel)
                return foundModel;

            throw new ArgumentException(
                string.Format("Unhandled model type: {0}", helper.ReadString("type", modelData.Name)));
        }
WorkspaceModel