/// <summary> /// Get the type associated with the given information. If typeadd is true, then add those values to the node types if not found. /// </summary> /// <param name="typeid">identifier of the node type</param> /// <param name="typename">Name for the node type</param> /// <param name="typeadd">default is false. If not found add the typename to the nodetypes.</param> /// <returns></returns> public NodeType GetNodeType(string typename, bool typeadd = false) { NodeType ntype = null; using (SystemMapEntities db = new SystemMapEntities()) { ntype = db.nodetypes .Where(nt => nt.name == typename) .Select(nt => new NodeType { typeId = nt.typeid, name = nt.name, description = nt.descr, iconUrl = nt.iconurl }) .SingleOrDefault(); if (ntype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename)) { //Go ahead and add it nodetype addtype = new nodetype { name = typename }; db.nodetypes.Add(addtype); db.SaveChanges(); ntype = new NodeType { name = typename, typeId = addtype.typeid }; } } return(ntype); }
private static nodetype CreateDatasetNode([NotNull] DatasetNode datasetNode, bool useQualifiedLabel) { Dataset dataset = datasetNode.Dataset; // shorthand var node = new nodetype { id = datasetNode.NodeId }; string label = useQualifiedLabel ? string.Format("{0}: {1}", dataset.Model.Name, dataset.Name) : dataset.Name; string geometryTypeName = dataset.GeometryType == null ? string.Empty : dataset.GeometryType.Name; var data = new List <datatype> { CreateData(_keyNodeLabel, label), CreateData(_keyGeometryType, geometryTypeName), CreateData(_keyModelName, dataset.Model.Name) }; node.Items = data.Cast <object>().ToArray(); return(node); }
public node_t() { children = new List <node_t>(); set = new SortedSet <char>(); id = 0; nt = nodetype.None; greedy = false; invert = false; A = 0; B = 0; parent = null; }
private void setNtype(String ntype) { if (ntype.Equals("UNITS")) { _ntype = nodetype.UNITS; } else if (ntype.Equals("TREEROOT")) { _ntype = nodetype.TREEROOT; } else { _ntype = nodetype.OTHER; } }
public void UpdateNodeType(NodeType udata) { using (SystemMapEntities db = new SystemMapEntities()) { nodetype utype = db.nodetypes .Where(nt => nt.typeid == udata.typeId) .SingleOrDefault(); if (utype != null) { utype.name = udata.name; utype.descr = udata.description; utype.iconurl = udata.iconUrl; db.SaveChanges(); } } }
// добавить специфичного потомка (пресеты) node_t add_child(node_t parent, nodetype node_type) { if (node_type == nodetype.Repeat || node_type == nodetype.Char || node_type == nodetype.Block) { throw new Exception("Use specialized function"); } if (parent.nt == nodetype.Block) { parent.nt = nodetype.None; } node_t child = new node_t(); child.nt = node_type; child.parent = parent; node_t tmp = insert_child(parent, child); if (tmp != child) { // такой блок уже был //delete child; return(tmp); } else { // У структурных блоков нет ID if (node_type != nodetype.None && node_type != nodetype.Token) { child.id = root.next_id(); } elements.Add(child); } return(child); }
/// <summary> /// Add a new NodeType entry to storage /// </summary> /// <param name="ntype"></param> /// <returns></returns> public NodeType AddNodeType(NodeType ntype) { NodeType typeval = null; using (SystemMapEntities db = new SystemMapEntities()) { //check that we don't already have this name int ecount = db.nodetypes.Where(n => n.name == ntype.name).Count(); if (ecount == 0) { //Go ahead and add it nodetype addtype = new nodetype { name = ntype.name, descr = ntype.description, iconurl = ntype.iconUrl }; db.nodetypes.Add(addtype); db.SaveChanges(); typeval = new NodeType { typeId = addtype.typeid, name = addtype.name, description = addtype.descr, iconUrl = addtype.iconurl }; } else { typeval = db.nodetypes .Where(n => n.name == ntype.name) .Select(n => new NodeType { typeId = n.typeid, name = n.name, description = n.descr, iconUrl = n.iconurl }) .FirstOrDefault(); } } return(typeval); }