void TraverseNode(NodeData nodeData, NodeData parentData) { if (parentData != null) { if (parentData.Connector != null) { nodeData.Encoding = (parentData.Encoding == string.Empty) ? parentData.Connector.ToString() + nodeData.Connector.ToString() : parentData.Encoding.ToString() + nodeData.Connector; } else { nodeData.Encoding = nodeData.Connector.ToString(); } } if ((nodeData.LeftNode == null) && (nodeData.RightNode == null)) { var keyChar = Convert.ToChar(nodeData.Characters); if (!_encodingDictionary.ContainsKey(keyChar)) { nodeData.Encoding = parentData.Encoding + nodeData.Connector.ToString(); _encodingDictionary.Add(keyChar, nodeData.Encoding); } } if (!(nodeData.LeftNode == null)) { TraverseNode(nodeData.LeftNode, nodeData); } if (!(nodeData.RightNode == null)) { TraverseNode(nodeData.RightNode, nodeData); } }
private void AddNamespace(string prefix, string ns) { this.nsManager.AddNamespace(prefix, ns); int length = this.nsAttrCount++; if (this.nsAttributes == null) { this.nsAttributes = new NodeData[this.InitialNamespaceAttributeCount]; } if (length == this.nsAttributes.Length) { NodeData[] destinationArray = new NodeData[this.nsAttributes.Length * 2]; Array.Copy(this.nsAttributes, 0, destinationArray, 0, length); this.nsAttributes = destinationArray; } if (this.nsAttributes[length] == null) { this.nsAttributes[length] = new NodeData(); } if (prefix.Length == 0) { this.nsAttributes[length].Set(XmlNodeType.Attribute, this.xmlns, string.Empty, this.xmlns, this.xmlnsUri, ns); } else { this.nsAttributes[length].Set(XmlNodeType.Attribute, prefix, this.xmlns, base.reader.NameTable.Add(this.xmlns + ":" + prefix), this.xmlnsUri, ns); } this.state = State.ClearNsAttributes; this.curNsAttr = -1; }
public NodeEvent GetEvent(ZWaveNode node, byte[] message) { //Set up the color values array var colordata = node.GetData("ColorValues"); if (colordata == null) { colordata = new NodeData("ColorValues", new List<ColorValue>()); } var colorvals = colordata.Value as List<ColorValue>; NodeEvent nodeEvent = null; byte cmdType = message[1]; if (cmdType == (byte)Command.SwitchColorCapabilityReport) { for (int i = 2; i < 4; i++) { for (int j = 0; j < 8; j++) { if ((message[i] & 0x1 << j) > 0) { var colnum = (ZWaveSwitchColorNumber)(8*i+j); var exist = (from val in colorvals where val.ColorNumber == colnum select val).FirstOrDefault(); if (exist == null) { colorvals.Add(new ColorValue { ColorNumber = colnum, Value = 0 }); } Get(node, 8 * i + j); } } } } else if (cmdType == (byte)Command.SwitchColorReport) { } node.UpdateData("ColorValues", colorvals); return nodeEvent; }
public static BoxL.Box AddNodeEx(this BoxL.Container p, double w, double h, string s) { var box = p.AddBox(w, h); var node_data = new NodeData(); node_data.Text = s; box.Data = node_data; return box; }
public Node(string prop_name, object val, comparison c) { data = new NodeData() { value = val, prop = prop_name, comp = c }; }
public NodeBuilder(NodeToken token) { _token = token; _token.NodeData = null; _data = new NodeData(_token.NodeTypeId, _token.ContentListTypeId) { IsShared = false, SharedData = null, }; }
void UpdateVerletSim(NodeData node) { Vector3 force = (Settings.Gravity * Settings.Mass) * TimeMultiplier * TimeMultiplier; Vector3 newPos = node.Position * 2 - node.LastPosition + (force / Settings.Mass) * (Time.deltaTime * Time.deltaTime); node.CurrentMoveDir = newPos - node.Position; node.LastPosition = node.Position; node.Position = node.Position + (node.CurrentMoveDir * (1 - Settings.Damping)); node.Node.position = node.Position; }
public string GetTitle(Node node, RequestContext context) { var contextData = new NodeData(context); if (node.Data == contextData) { node.Data.CopyQueryString(context); var id = GetId(node.Data, context); if (id > 0) { return GetTitleInternal(node, id); } } return DefaultTitle; }
private static ExplorationNode Decode(NodeData data) { ExplorationNode newNode = new ExplorationNode(data.State.Decode()); newNode.Id = data.NodeId; newNode.PageRank = data.PageRank; newNode.InversePageRank = data.InversePageRank; StoreMinCuts(newNode, data.MinCutIn, newNode.SetMinCutIn); StoreMinCuts(newNode, data.MinCutOut, newNode.SetMinCutOut); return newNode; }
internal XmlSubtreeReader(XmlReader reader) : base(reader) { this.curNsAttr = -1; this.InitialNamespaceAttributeCount = 4; this.initialDepth = reader.Depth; this.state = State.Initial; this.nsManager = new XmlNamespaceManager(reader.NameTable); this.xmlns = reader.NameTable.Add("xmlns"); this.xmlnsUri = reader.NameTable.Add("http://www.w3.org/2000/xmlns/"); this.tmpNode = new NodeData(); this.tmpNode.Set(XmlNodeType.None, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); this.SetCurrentNode(this.tmpNode); }
private long GetId(NodeData nodeData, RequestContext context) { long result; if (context.RouteData.Values.ContainsKey(IdKey) && context.RouteData.Values[IdKey] != null && long.TryParse(context.RouteData.Values[IdKey].ToString(), out result)) { return result; } if (long.TryParse(context.HttpContext.Request.QueryString.Get(IdKey), out result)) { return result; } if (nodeData.RouteValues.ContainsKey(IdKey) && nodeData.RouteValues[IdKey] != null && long.TryParse(nodeData.RouteValues[IdKey].ToString(), out result)) { return result; } return 0; }
//ContentListTypeId //BinaryPropertyTypeIds internal static CacheDependency CreateNodeDataDependency(NodeData nodeData) { if (nodeData == null) throw new ArgumentNullException("nodeData"); var aggregateCacheDependency = new System.Web.Caching.AggregateCacheDependency(); aggregateCacheDependency.Add( new NodeIdDependency(nodeData.Id), new PathDependency(nodeData.Path), //new VersionIdDependency(nodeData.VersionId), new NodeTypeDependency(nodeData.NodeTypeId) ); return aggregateCacheDependency; }
public void Load(NodeData data) { gizmoSize = data.gizmoSize; frontControl = data.frontControl; backControl = data.backControl; trackWidthModifier = data.trackWidthModifier; rightCurvature = data.rightCurvature; // between 0 and 1 leftCurvature = data.leftCurvature; // between 0 and 1 transform.position = data.position; transform.rotation = data.rotation; frontTransform.position = data.frontControl; backTransform.position = data.backControl; reverse = data.reverse; }
public bool CreateGraph(IDictionary<char, int> uniqueCharacterToFrequencyMap) { Graph = null; Graph = new NodeData(); _uniqueCharToFreqMapSortedInDesc = uniqueCharacterToFrequencyMap; IList<NodeData> firstLevelNodes = new List<NodeData>(); foreach (var item in _uniqueCharToFreqMapSortedInDesc) { var newLeafNode = CreateLeafNode(item.Key.ToString(), item.Value); //_characterGraph.AddFirst(newLeafNode); firstLevelNodes.Add(newLeafNode); } //var firstLevelNodes = _uniqueCharToFreqMapSortedInDesc.Select(x => x.Value).ToList(); var isSuccess = TraverseBreadthAndCreateNewCombineNodes(firstLevelNodes); return isSuccess; }
IEnumerator CountAction (int count) { // Init Debug.Log ("Init counter"); int current = 0; NodeData data = new NodeData (); yield return data; // Run while (!data.ShouldReset && ++current <= count) { Debug.Log (current); yield return Running; } yield return Success; }
protected IEnumerator Run (ExecutionMode mode) { WaitForSeconds frameDelay = new WaitForSeconds (1.0f / Frequency); do { // Start running the tree root - grabbing its node data yielded on the init frame IEnumerator rootRoutine = Root (); rootRoutine.MoveNext (); m_RootData = rootRoutine.Current as NodeData; // Keep running until we're disabled while (Application.isPlaying && enabled) { // Break out if the root was reset if (m_RootData != null && m_RootData.ShouldReset) { break; } // Break out if the tree breaks or completes with success or failure if (!rootRoutine.MoveNext () || Success.Equals (rootRoutine.Current) || Failure.Equals (rootRoutine.Current)) { break; } yield return frameDelay; } // Reset the root if (m_RootData != null) { m_RootData.Reset (); rootRoutine.MoveNext (); } } while (mode == ExecutionMode.Continuous && Application.isPlaying && enabled); }
public void AddToNodeSet(NodeData node) { NodeSet.Add(node.Id, node); }
public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) { base.PropagateNodeData( nodeData, ref dataCollector ): if( m_inputPorts[ 0 ].IsConnected ) dataCollector.DirtyNormal = true: }
protected void OnGUI() { if (data == null) { return; } //TAB EditorGUILayout.BeginHorizontal(); var tabnames = new List <string>(); for (int i = 0; i < data.GetTabCount(); i++) { tabnames.Add(data.GetTab(i).GetName()); } if (tabnames.Count == 0) { return; } if (selectedTabIndex >= tabnames.Count) { selectedTabIndex = 0; } selectedTabIndex = ToolUtils.Tabs(tabnames.ToArray(), selectedTabIndex, false, 50, false); searchKeyword = EditorGUILayout.TextField("", searchKeyword, GUILayout.MinWidth(100)); bool isCmd = searchKeyword.StartsWith("!"); if (isCmd) { var cmd = searchKeyword.Substring(1); if (cmd.Equals("+")) { var thisTab = data.GetTab(selectedTabIndex); for (int j = 0; j < thisTab.GetNodeCount(); j++) { var node = thisTab.GetNode(j); node.expand = true; } } else if (cmd.Equals("-")) { var thisTab = data.GetTab(selectedTabIndex); for (int j = 0; j < thisTab.GetNodeCount(); j++) { var node = thisTab.GetNode(j); node.expand = false; } } else { OnCmd(cmd); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); EditorGUILayout.BeginVertical(); //每行占18像素,Tab行也占18像素高度 int firstIndex = (int)(scrollPos.y / 18); int excludeLastIndex = firstIndex + viewCount; GUILayout.Space(firstIndex * 18); int index = 0; var tab = data.GetTab(selectedTabIndex); for (int j = 0; j < tab.GetNodeCount(); j++) { var node = tab.GetNode(j); bool nodeHit = isCmd || node.Hit(searchKeyword); if (nodeHit || node.IsChildrenHit(searchKeyword)) { index++; if (index > firstIndex && index < excludeLastIndex) { var foldpos = GUILayoutUtility.GetRect(18, 18); foldpos.width = 18; var style = selectedNodeData == node ? EditorStyles.whiteLabel : EditorStyles.label; node.expand = EditorGUI.Foldout(foldpos, node.expand, ""); var btnpos = new Rect(foldpos.x + foldpos.width, foldpos.y, position.width - foldpos.width, foldpos.height); if (GUI.Button(btnpos, node.GetName(), style)) { OnClick(node, null, false); var delta = watcher.ElapsedMilliseconds; if (delta < 500 && selectedNodeData == node) { OnClick(node, null, true); } selectedNodeData = node; selectedLeafData = null; watcher.Reset(); watcher.Start(); } } if (node.expand) { for (int k = 0; k < node.GetLeafCount(); k++) { var leaf = node.GetLeaf(k); if (nodeHit || leaf.Hit(searchKeyword)) { index++; if (index > firstIndex && index < excludeLastIndex) { var estyle = selectedLeafData == leaf ? EditorStyles.whiteLabel : EditorStyles.label; if (GUILayout.Button(" " + leaf.GetName(), estyle, GUILayout.Height(18))) { OnClick(node, leaf, false); var delta = watcher.ElapsedMilliseconds; if (delta < 500 && selectedLeafData == leaf) { OnClick(node, leaf, true); } selectedNodeData = null; selectedLeafData = leaf; watcher.Reset(); watcher.Start(); } } } } } } } var space = (index - viewCount - firstIndex) * 18; if (space < 0) { space = 0; } GUILayout.Space(space); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); if (Event.current.type == EventType.repaint) { var viewSize = GUILayoutUtility.GetLastRect(); int newViewcount = (int)(viewSize.height / 18) + 1; viewCount = newViewcount; } }
public void InsertNodeAndVersionRows(NodeData nodeData, out int lastMajorVersionId, out int lastMinorVersionId) { _writer.InsertNodeAndVersionRows(nodeData, out lastMajorVersionId, out lastMinorVersionId); WriteLog(MethodBase.GetCurrentMethod(), nodeData, lastMajorVersionId, lastMinorVersionId); }
private static void SaveNodeProperties(NodeData nodeData, SavingAlgorithm savingAlgorithm, INodeWriter writer, bool isNewNode) { int versionId = nodeData.VersionId; foreach (var propertyType in nodeData.PropertyTypes) { var slotValue = nodeData.GetDynamicRawData(propertyType) ?? propertyType.DefaultValue; bool isModified = nodeData.IsModified(propertyType); if (!isModified && !isNewNode) { continue; } switch (propertyType.DataType) { case DataType.String: writer.SaveStringProperty(versionId, propertyType, (string)slotValue); break; case DataType.DateTime: writer.SaveDateTimeProperty(versionId, propertyType, (DateTime)slotValue); break; case DataType.Int: writer.SaveIntProperty(versionId, propertyType, (int)slotValue); break; case DataType.Currency: writer.SaveCurrencyProperty(versionId, propertyType, (decimal)slotValue); break; case DataType.Text: writer.SaveTextProperty(versionId, propertyType, true, (string)slotValue); //TODO: ?? isLoaded property handling BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeTextProperties, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); break; case DataType.Reference: var ids = (IEnumerable <int>)slotValue; if (!isNewNode || (ids != null && ids.Count() > 0)) { var ids1 = ids.Distinct().ToList(); if (ids1.Count != ids.Count()) { nodeData.SetDynamicRawData(propertyType, ids1); } writer.SaveReferenceProperty(versionId, propertyType, ids1); } BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeReferenceProperties, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); break; case DataType.Binary: var binValue = (BinaryDataValue)slotValue; if (binValue == null || binValue.IsEmpty) { writer.DeleteBinaryProperty(versionId, propertyType); } else if (binValue.Id == 0 || savingAlgorithm != SavingAlgorithm.UpdateSameVersion) { writer.InsertBinaryProperty(binValue, versionId, propertyType.Id, isNewNode); } else { writer.UpdateBinaryProperty(binValue); } BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeBinaries, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); break; default: throw new NotSupportedException(propertyType.DataType.ToString()); } } }
public void calculatePath(Node start, Node end, out List <Vector3> path, out List <Node> nodesInPath) { //Debug.Log("start algorithm"); List <NodeData> openList = new List <NodeData>(); List <NodeData> closeList = new List <NodeData>(); NodeData start_node = start.data; NodeData end_node = end.data; start_node.F = 0; start_node.G = 0; start_node.H = 0; NodeData current_node = start.data; // Put node_start on the OPEN list openList.Add(start_node); // while the OPEN list is not empty while (openList.Count > 0) { // Get the node off the OPEN list with the lowest f and call it node_current int index_to_remove = 0; current_node = openList[0]; for (int i = 0; i < openList.Count; i++) { if (openList[i].F <= current_node.F) { current_node = openList[i]; index_to_remove = i; } } openList.RemoveAt(index_to_remove); // If node_current is the same state as node_goal: break from the while loop if (current_node.node.transform.position == end.transform.position) { closeList.Add(current_node); break; } // Generate each state node_successor that can come after node_current List <NodeData> successors = new List <NodeData>(); successors.Clear(); for (int i = 0; i < current_node.node.accessibleNodes.Count; i++) { NodeData n = new NodeData(); n.node = current_node.node.accessibleNodes[i]; n.F = n.node.F; n.G = n.node.G + 1.0f; n.H = n.node.H; n.name = n.node.gameObject.name; //I came from this node, important for getting the path later. n.CameFrom = current_node; successors.Add(n); } // For each node_successor of node_current for (int i = 0; i < successors.Count; i++) { //RaycastHit hit; // Set the G of node_successor to be the G of node_current plus the G to get to node_successor from node_current successors[i].G = successors[i].G + Vector3.Distance(successors[i].node.transform.position, current_node.node.transform.position); // Find node_successor on the OPEN list bool found_in_open_list = false; for (int a = 0; a < openList.Count; a++) { // If node_successor is on the OPEN list but the existing one is as good or better then discard this successor and continue with next successor if (successors[i].node.transform.position == openList[a].node.transform.position) { if (successors[i].G >= openList[a].G) { found_in_open_list = true; } break; } } if (found_in_open_list) { continue; } // If node_successor is on the CLOSED list but the existing one is as good or better then discard this successor and continue with next successor bool found_in_close_list = false; for (int a = 0; a < closeList.Count; a++) { if (successors[i].node.transform.position == closeList[a].node.transform.position) { if (successors[i].G >= closeList[a].G) { found_in_close_list = true; } break; } } if (found_in_close_list) { continue; } // Remove occurences of node_successor from OPEN and CLOSED for (int b = 0; b < openList.Count; b++) { if (successors[i].node.transform.position == openList[b].node.transform.position) { openList.RemoveAt(b); } } for (int b = 0; b < closeList.Count; b++) { if (successors[i].node.transform.position == closeList[b].node.transform.position) { closeList.RemoveAt(b); } } //CHECK THIS PART. // Set h to be the estimated distance to node_goal (using the H function (euclidean distance) ) successors[i].H = Vector3.Distance(successors[i].node.transform.position, end_node.node.transform.position); successors[i].F = successors[i].G + successors[i].H; // Add node_successor to the OPEN list openList.Add(successors[i]); } closeList.Add(current_node); } int counter = 0; path = new List <Vector3>(); nodesInPath = new List <Node>(); NodeData endNode = closeList[closeList.Count - 1]; /*from the last node, we get the path * * end->camefrom->camefrom->camefrom = path * */ while (endNode.CameFrom != null) { path.Add(new Vector3(endNode.node.transform.position.x, 1.0f, endNode.node.transform.position.z)); endNode = endNode.CameFrom; if (counter != 0) { Debug.DrawRay(new Vector3(path[counter - 1].x, 1.0f, path[counter - 1].z), new Vector3(path[counter].x, 1.0f, path[counter].z) - new Vector3(path[counter - 1].x, 1.0f, path[counter - 1].z), Color.magenta, 30); } counter++; } path.Reverse(); }
public static void Assert_DynamicPropertiesAreEqualExceptBinaries(NodeData expected, NodeData actual, params string[] excludedProperties) { // prepare collections var expectedProps = (Dictionary <int, object>)(new ObjectAccessor(expected).GetField("dynamicData")); foreach (var propName in excludedProperties) { var pt = PropertyType.GetByName(propName); expectedProps.Add(pt.Id, expected.GetDynamicRawData(pt)); } var actualProps = (Dictionary <int, object>)(new ObjectAccessor(actual).GetField("dynamicData")); // Compare signatures var expectedSignature = expectedProps.Keys.OrderBy(y => y).ToArray(); var actualSignature = actualProps.Keys.OrderBy(y => y).ToArray(); var expectedNames = expectedProps.Keys.Select(x => ActiveSchema.PropertyTypes.GetItemById(x).Name).OrderBy(y => y).ToArray(); var actualNames = actualProps.Keys.Select(x => ActiveSchema.PropertyTypes.GetItemById(x).Name).OrderBy(y => y).ToArray(); Assert_AreEqual(expectedNames, actualNames, "DynamicPropertySignature"); // Compare properties foreach (var key in expectedSignature) { var propertyType = NodeTypeManager.Current.PropertyTypes.GetItemById(key); var expectedValue = expectedProps[key]; var actualValue = actualProps[key]; switch (propertyType.DataType) { case DataType.String: case DataType.Text: Assert_AreEqual((string)expectedValue, (string)actualValue, propertyType.Name); break; case DataType.Int: try { Assert_AreEqual((int?)expectedValue, (int?)actualValue, propertyType.Name); } catch (InvalidCastException) { Assert_AreEqual((int)expectedValue, (int)actualValue, propertyType.Name); } break; case DataType.Currency: Assert_AreEqual((decimal?)expectedValue, (decimal?)actualValue, propertyType.Name); break; case DataType.DateTime: Assert_AreEqual((DateTime?)expectedValue, (DateTime?)actualValue, propertyType.Name); break; case DataType.Binary: break; case DataType.Reference: Assert_AreEqual((IEnumerable <int>)expectedValue, (IEnumerable <int>)actualValue, $"ReferenceProperty '{propertyType.Name}'"); break; default: throw new ArgumentOutOfRangeException(); } } }
public ExampleGraphData() { metadata = new WayMetadata(); nodes = new NodeData(); edges = new EdgeData(); }
public virtual void OnNodeGUI(Rect position, NodeData data) { }
//子类重写 public virtual bool OnMakeTrue(NodeData wData) { return(true); }
public void CopyAndUpdateVersion(NodeData nodeData, int previousVersionId, int destinationVersionId, out int lastMajorVersionId, out int lastMinorVersionId) { _writer.CopyAndUpdateVersion(nodeData, previousVersionId, destinationVersionId, out lastMajorVersionId, out lastMinorVersionId); WriteLog(MethodBase.GetCurrentMethod(), nodeData, previousVersionId, destinationVersionId, lastMajorVersionId, lastMinorVersionId); }
protected internal abstract void DeleteVersion(int versionId, NodeData nodeData, out int lastMajorVersionId, out int lastMinorVersionId);
public void UpdateVersionRow(NodeData nodeData, out int lastMajorVersionId, out int lastMinorVersionId) { _writer.UpdateVersionRow(nodeData, out lastMajorVersionId, out lastMinorVersionId); WriteLog(MethodBase.GetCurrentMethod(), nodeData, lastMajorVersionId, lastMinorVersionId); }
// ====================================================== Index document save / load operations internal static void SaveIndexDocument(NodeData nodeData, byte[] indexDocumentBytes) { Current.UpdateIndexDocument(nodeData, indexDocumentBytes); }
protected abstract void OnClick(NodeData node, LeafData nullableLeaf, bool isDoubleClick);
private void ParseAttributeValueSlow(int curPos, char quoteChar, NodeData attr) { int pos = curPos; char[] chars = _ps.chars; int attributeBaseEntityId = _ps.entityId; int valueChunkStartPos = 0; LineInfo valueChunkLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos); NodeData lastChunk = null; Debug.Assert(_stringBuilder.Length == 0); for (;;) { // parse the rest of the attribute value unsafe { while (_xmlCharType.IsAttributeValueChar(chars[pos])) { pos++; } } if (pos - _ps.charPos > 0) { _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); _ps.charPos = pos; } if (chars[pos] == quoteChar && attributeBaseEntityId == _ps.entityId) { break; } else { switch (chars[pos]) { // eol case (char)0xA: pos++; OnNewLine(pos); if (_normalize) { _stringBuilder.Append((char)0x20); // CDATA normalization of 0xA _ps.charPos++; } continue; case (char)0xD: if (chars[pos + 1] == (char)0xA) { pos += 2; if (_normalize) { _stringBuilder.Append(_ps.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA _ps.charPos = pos; } } else if (pos + 1 < _ps.charsUsed || _ps.isEof) { pos++; if (_normalize) { _stringBuilder.Append((char)0x20); // CDATA normalization of 0xD and 0xD 0xA _ps.charPos = pos; } } else { goto ReadData; } OnNewLine(pos); continue; // tab case (char)0x9: pos++; if (_normalize) { _stringBuilder.Append((char)0x20); // CDATA normalization of 0x9 _ps.charPos++; } continue; case '"': case '\'': case '>': pos++; continue; // attribute values cannot contain '<' case '<': Throw(pos, SR.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0')); break; // entity referece case '&': if (pos - _ps.charPos > 0) { _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); } _ps.charPos = pos; int enclosingEntityId = _ps.entityId; LineInfo entityLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos + 1); switch (HandleEntityReference(true, EntityExpandType.All, out pos)) { case EntityType.CharacterDec: case EntityType.CharacterHex: case EntityType.CharacterNamed: break; case EntityType.Unexpanded: if (_parsingMode == ParsingMode.Full && _ps.entityId == attributeBaseEntityId) { // construct text value chunk int valueChunkLen = _stringBuilder.Length - valueChunkStartPos; if (valueChunkLen > 0) { NodeData textChunk = new NodeData(); textChunk.lineInfo = valueChunkLineInfo; textChunk.depth = attr.depth + 1; textChunk.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(valueChunkStartPos, valueChunkLen)); AddAttributeChunkToList(attr, textChunk, ref lastChunk); } // parse entity name _ps.charPos++; string entityName = ParseEntityName(); // construct entity reference chunk NodeData entityChunk = new NodeData(); entityChunk.lineInfo = entityLineInfo; entityChunk.depth = attr.depth + 1; entityChunk.SetNamedNode(XmlNodeType.EntityReference, entityName); AddAttributeChunkToList(attr, entityChunk, ref lastChunk); // append entity ref to the attribute value _stringBuilder.Append('&'); _stringBuilder.Append(entityName); _stringBuilder.Append(';'); // update info for the next attribute value chunk valueChunkStartPos = _stringBuilder.Length; valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); _fullAttrCleanup = true; } else { _ps.charPos++; ParseEntityName(); } pos = _ps.charPos; break; case EntityType.ExpandedInAttribute: if (_parsingMode == ParsingMode.Full && enclosingEntityId == attributeBaseEntityId) { // construct text value chunk int valueChunkLen = _stringBuilder.Length - valueChunkStartPos; if (valueChunkLen > 0) { NodeData textChunk = new NodeData(); textChunk.lineInfo = valueChunkLineInfo; textChunk.depth = attr.depth + 1; textChunk.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(valueChunkStartPos, valueChunkLen)); AddAttributeChunkToList(attr, textChunk, ref lastChunk); } // construct entity reference chunk NodeData entityChunk = new NodeData(); entityChunk.lineInfo = entityLineInfo; entityChunk.depth = attr.depth + 1; entityChunk.SetNamedNode(XmlNodeType.EntityReference, _ps.entity.Name); AddAttributeChunkToList(attr, entityChunk, ref lastChunk); _fullAttrCleanup = true; // Note: info for the next attribute value chunk will be updated once we // get out of the expanded entity } pos = _ps.charPos; break; default: pos = _ps.charPos; break; } chars = _ps.chars; continue; default: // end of buffer if (pos == _ps.charsUsed) { goto ReadData; } // surrogate chars else { char ch = chars[pos]; if (XmlCharType.IsHighSurrogate(ch)) { if (pos + 1 == _ps.charsUsed) { goto ReadData; } pos++; if (XmlCharType.IsLowSurrogate(chars[pos])) { pos++; continue; } } ThrowInvalidChar(chars, _ps.charsUsed, pos); break; } } } ReadData: // read new characters into the buffer if (ReadData() == 0) { if (_ps.charsUsed - _ps.charPos > 0) { if (_ps.chars[_ps.charPos] != (char)0xD) { Debug.Assert(false, "We should never get to this point."); Throw(SR.Xml_UnexpectedEOF1); } Debug.Assert(_ps.isEof); } else { if (!InEntity) { if (_fragmentType == XmlNodeType.Attribute) { if (attributeBaseEntityId != _ps.entityId) { Throw(SR.Xml_EntityRefNesting); } break; } Throw(SR.Xml_UnclosedQuote); } if (HandleEntityEnd(true)) { // no EndEntity reporting while parsing attributes Debug.Assert(false); Throw(SR.Xml_InternalError); } // update info for the next attribute value chunk if (attributeBaseEntityId == _ps.entityId) { valueChunkStartPos = _stringBuilder.Length; valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); } } } pos = _ps.charPos; chars = _ps.chars; } if (attr.nextAttrValueChunk != null) { // construct last text value chunk int valueChunkLen = _stringBuilder.Length - valueChunkStartPos; if (valueChunkLen > 0) { NodeData textChunk = new NodeData(); textChunk.lineInfo = valueChunkLineInfo; textChunk.depth = attr.depth + 1; textChunk.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(valueChunkStartPos, valueChunkLen)); AddAttributeChunkToList(attr, textChunk, ref lastChunk); } } _ps.charPos = pos + 1; attr.SetValue(_stringBuilder.ToString()); _stringBuilder.Length = 0; }
private static bool?IsUturnAllowedConfigurable(NodeData node) => node?.Type switch {
private void SetupEndEntityNodeInContent() { Debug.Assert(_lastEntity != null); _reportedEncoding = _ps.encoding; _reportedBaseUri = _ps.baseUriStr; _curNode = _nodes[_index]; Debug.Assert(_curNode.depth == _index); _curNode.SetNamedNode(XmlNodeType.EndEntity, _lastEntity.Name); _curNode.lineInfo.Set(_ps.lineNo, _ps.LinePos - 1); if (_index == 0 && _parsingFunction == ParsingFunction.ElementContent) { _parsingFunction = ParsingFunction.DocumentContent; } }
private string FormatNodeData(NodeData nodeData) { return(String.Format("NodeData: {0}, '{1}'", nodeData.Id, nodeData.Path)); }
private NodeData AllocNode(int nodeIndex, int nodeDepth) { Debug.Assert(nodeIndex < _nodes.Length); if (nodeIndex >= _nodes.Length - 1) { NodeData[] newNodes = new NodeData[_nodes.Length * 2]; Array.Copy(_nodes, 0, newNodes, 0, _nodes.Length); _nodes = newNodes; } Debug.Assert(nodeIndex < _nodes.Length); NodeData node = _nodes[nodeIndex]; if (node == null) { node = new NodeData(); _nodes[nodeIndex] = node; } node.depth = nodeDepth; return node; }
/// <summary> /// Loads up the dialogue just sent. Populates the nodeData variable with the first Node based on the Start Node. Also returns the current NodeData package. /// </summary> /// <param name="diagToLoad"></param> /// <returns>NodeData</returns> public NodeData BeginDialogue(VIDE_Assign diagToLoad) { //First we load the dialogue we requested //if (diagToLoad.diags.Count < 1) diagToLoad.loadFiles(); if (Load(diagToLoad.diags[diagToLoad.assignedIndex])) { isLoaded = true; } else { isLoaded = false; Debug.LogError("Failed to load '" + diagToLoad.diags[diagToLoad.assignedIndex] + "'"); return(null); } //Make sure that variables were correctly reset after last conversation if (nodeData != null) { Debug.LogError("You forgot to call 'EndDialogue()' on last conversation!"); return(null); } assigned = diagToLoad; if (assigned.overrideStartNode != -1) { startPoint = assigned.overrideStartNode; } int startIndex = -1; bool isPlayer = false; for (int i = 0; i < npcDiags.Count; i++) { if (startPoint == npcDiags[i].ID) { startIndex = i; isPlayer = false; break; } } for (int i = 0; i < playerDiags.Count; i++) { if (startPoint == playerDiags[i].ID) { startIndex = i; isPlayer = true; break; } } if (startIndex == -1) { Debug.LogError("Start point not found! Check your IDs!"); return(null); } if (isPlayer) { currentPlayerStep = playerDiags[startIndex]; nodeData = new NodeData(true, false, currentPlayerStep.ID, GetOptions(), null, null, null); return(nodeData); } else { currentNPCStep = npcDiags[startIndex]; List <string> ns = new List <string>(); string[] rawSplit = Regex.Split(currentNPCStep.text, "<br>"); foreach (string s in rawSplit) { if (s != "" && s != " ") { ns.Add(s.Trim()); } } nodeData = new NodeData(false, false, currentNPCStep.ID, null, ns.ToArray(), currentNPCStep.extraData, currentNPCStep.tag); return(nodeData); } }
private string LookupNamespace(NodeData node) { string ns = _namespaceManager.LookupNamespace(node.prefix); if (ns != null) { return ns; } else { Throw(SR.Xml_UnknownNs, node.prefix, node.LineNo, node.LinePos); return null; } }
/// <summary> /// Populates nodeData with the data from next Node based on the current nodeData. /// </summary> /// <returns></returns> public NodeData Next() { int option = nodeData.selectedOption; if (!isLoaded) { Debug.LogError("You must call the 'BeginDialogue()' method before calling the 'Next()' method!"); return(null); } if (!jumped) { if (!nodeData.currentIsPlayer) { if (currentNPCStep.endConversation && nodeData.npcCommentIndex == nodeData.npcComment.Length - 1) { nodeData.isEnd = true; return(nodeData); } } } jumped = false; bool nextIsPlayer = true; if (!nodeData.currentIsPlayer) { nextIsPlayer = true; if (currentNPCStep.outputSet == null) { nextIsPlayer = false; } } else { nextIsPlayer = false; } if (!nodeData.currentIsPlayer) { if (nodeData.npcCommentIndex != nodeData.npcComment.Length - 1) { nodeData.npcCommentIndex++; return(nodeData); } if (nextIsPlayer) { currentPlayerStep = currentNPCStep.outputSet; nodeData = new NodeData(true, false, currentPlayerStep.ID, GetOptions(), null, null, null); } else { currentNPCStep = currentNPCStep.outputNPC; List <string> ns = new List <string>(); string[] rawSplit = Regex.Split(currentNPCStep.text, "<br>"); foreach (string s in rawSplit) { if (s != "" && s != " ") { ns.Add(s.Trim()); } } nodeData = new NodeData(false, false, currentNPCStep.ID, null, ns.ToArray(), currentNPCStep.extraData, currentNPCStep.tag); } return(nodeData); } else { //Pick option 0 as default as we passed no params currentNPCStep = currentPlayerStep.comment[option].outputAnswer; List <string> ns = new List <string>(); string[] rawSplit = Regex.Split(currentNPCStep.text, "<br>"); foreach (string s in rawSplit) { if (s != "" && s != " ") { ns.Add(s.Trim()); } } nodeData = new NodeData(false, false, currentNPCStep.ID, null, ns.ToArray(), currentNPCStep.extraData, currentNPCStep.tag); return(nodeData); } }
private bool ParseAttributeValueChunk() { char[] chars = _ps.chars; int pos = _ps.charPos; _curNode = AddNode(_index + _attrCount + 1, _index + 2); _curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); if (_emptyEntityInAttributeResolved) { _curNode.SetValueNode(XmlNodeType.Text, string.Empty); _emptyEntityInAttributeResolved = false; return true; } Debug.Assert(_stringBuilder.Length == 0); for (;;) { unsafe { while (_xmlCharType.IsAttributeValueChar(chars[pos])) pos++; } switch (chars[pos]) { // eol D case (char)0xD: Debug.Assert(_ps.eolNormalized, "Entity replacement text for attribute values should be EOL-normalized!"); pos++; continue; // eol A, tab case (char)0xA: case (char)0x9: if (_normalize) { chars[pos] = (char)0x20; // CDATA normalization of 0xA and 0x9 } pos++; continue; case '"': case '\'': case '>': pos++; continue; // attribute values cannot contain '<' case '<': Throw(pos, SR.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0')); break; // entity reference case '&': if (pos - _ps.charPos > 0) { _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); } _ps.charPos = pos; // expand char entities but not general entities switch (HandleEntityReference(true, EntityExpandType.OnlyCharacter, out pos)) { case EntityType.CharacterDec: case EntityType.CharacterHex: case EntityType.CharacterNamed: chars = _ps.chars; if (_normalize && _xmlCharType.IsWhiteSpace(chars[_ps.charPos]) && pos - _ps.charPos == 1) { chars[_ps.charPos] = (char)0x20; // CDATA normalization of character references in entities } break; case EntityType.Unexpanded: if (_stringBuilder.Length == 0) { _curNode.lineInfo.linePos++; _ps.charPos++; _curNode.SetNamedNode(XmlNodeType.EntityReference, ParseEntityName()); return true; } else { goto ReturnText; } default: Debug.Assert(false, "We should never get to this point."); break; } chars = _ps.chars; continue; default: // end of buffer if (pos == _ps.charsUsed) { goto ReadData; } // surrogate chars else { char ch = chars[pos]; if (XmlCharType.IsHighSurrogate(ch)) { if (pos + 1 == _ps.charsUsed) { goto ReadData; } pos++; if (XmlCharType.IsLowSurrogate(chars[pos])) { pos++; continue; } } ThrowInvalidChar(chars, _ps.charsUsed, pos); break; } } ReadData: if (pos - _ps.charPos > 0) { _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); _ps.charPos = pos; } // read new characters into the buffer if (ReadData() == 0) { if (_stringBuilder.Length > 0) { goto ReturnText; } else { if (HandleEntityEnd(false)) { SetupEndEntityNodeInAttribute(); return true; } else { Debug.Assert(false, "We should never get to this point."); } } } pos = _ps.charPos; chars = _ps.chars; } ReturnText: if (pos - _ps.charPos > 0) { _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); _ps.charPos = pos; } _curNode.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString()); _stringBuilder.Length = 0; return true; }
private void Recursive(int depth) { Console.WriteLine(String.Format("Beginning Depth: {0}", depth)); Dictionary <int, Node> nodesToAdd = new Dictionary <int, Node>(); //Process all nodes at this depth foreach (Node prev in _tree.Where(t => t.Value.Depth == depth).Select(t => t.Value)) { //Console.WriteLine(String.Format("Starting Node: {0}", prev.ToString())); SetRobotCurrentLocations(prev); foreach (int i in _robotsByPriority) { foreach (Direction d in _allDirections) { _numberOfNodesEvaluated++; RobotMove move = _model.MoveRobot(i, d).FirstOrDefault(); if (move == null) { continue; //an Invalid move not worth saving } Console.WriteLine(move.ToString()); NodeData nodeData = new NodeData(move, new Dictionary <int, Cell>(_model.RobotCurrentLocations)); Node next = new Node(nodeData, depth + 1, prev); prev.Next.Add(next); //This move found a solution, we're done processing. if (_model.CurrentWinningDestination.X != _winningDestination.X || _model.CurrentWinningDestination.Y != _winningDestination.Y) { Console.WriteLine("Solution Found with this move."); _winningNode = next; _model.UndoMove(); return; } //Check for a repeating position in the tree. Any repeated position does not need to be evaluated. //It either occurs in the same number of moves, or fewer, since this is a breadth first algorithm. if (!_tree.ContainsKey(next.GetIndex()) && !nodesToAdd.ContainsKey(next.GetIndex())) { nodesToAdd.Add(next.GetIndex(), next); } _model.UndoMove(); } } } //If we didn't add any new nodes, we've searched everything. if (nodesToAdd.Count == 0) { return; } _tree = _tree.Concat(nodesToAdd).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); if (_winningNode == null && depth < 12) //depths >13 will not be explored by BreadthFirst. { Recursive(depth + 1); } }
private void radioButtonAction_Click(object sender, EventArgs e) { textBoxKeyChar.Enabled = textBoxKeyCode.Enabled = false; textBoxKeyChar.Text = textBoxKeyCode.Text = string.Empty; comboBoxCmdProperty.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSound.Enabled = true; comboBoxCmdProperty.Enabled = true; var node = getNode("COMMAND"); var data = new NodeData("COMMAND", "ACTION", "7"); node.Tag = data; UpdateCombo(ref comboBoxCmdProperty, actionList, GetFriendlyName(Enum.GetName(typeof (Action.ActionType), Convert.ToInt32(data.Value)))); node.Text = "Action \"" + (string) comboBoxCmdProperty.SelectedItem + "\""; ((NodeData) node.Tag).Focus = checkBoxGainFocus.Checked; changedSettings = true; }
public bool FindShortestPath(GameObject startNode, GameObject finishNode) /* reset and change data in node for navigate * can only navigate in same floor*/ { GameObject floorObject = startNode.GetComponent <NodeData>().GetParentObjectData().GetParentFloorObject(); ResetAllVertexData(floorObject); FloorData currentFloor = floorObject.GetComponent <FloorData>(); List <GameObject> unVisitedList = new List <GameObject>(); foreach (GameObject node in floorObject.GetComponent <FloorData>().GetNodesList()) { unVisitedList.Add(node); } bool isFounded = false; float costToadjacentNode = 0; GameObject currentNode = startNode; NodeData currentNodeData = currentNode.GetComponent <NodeData>(); currentNodeData.cost = 0; Debug.Log(" first node cost 0"); Debug.Log(" - - - - " + (unVisitedList.Count > 0)); while (currentNode != finishNode && (unVisitedList.Count >= 0)) //unVisitedList.Count.CompareTo(0) || (unvisitedLeft > 0) { //check adjacentNode foreach (GameObject adjacentObject in currentNodeData.adjacentNodeList) { NodeData adjacentNodeData = adjacentObject.GetComponent <NodeData>(); Debug.Log(" -@ " + currentNodeData.nodeID + " -Adjacent |" + adjacentNodeData.nodeID + "| End at " + finishNode.GetComponent <NodeData>().nodeID); if (adjacentNodeData.GetParentObjectData().roomName == finishNode.GetComponent <NodeData>().GetParentObjectData().roomName) { // if adjacent is final node (adjacentObject == finishNode) adjacentNodeData.cost = Vector3.Distance(currentNodeData.position, adjacentNodeData.position) + currentNodeData.cost; unVisitedList.Remove(currentNode); unVisitedList.Remove(adjacentObject); adjacentNodeData.predecessor = currentNode; currentNode = adjacentObject; currentNodeData = currentNode.GetComponent <NodeData>(); isFounded = true; Debug.Log(" - - Break - -"); break; } else if (unVisitedList.Contains(adjacentObject)) { //neightbor are not visited, Update it costToadjacentNode = Vector3.Distance(currentNodeData.position, adjacentNodeData.position) + currentNodeData.cost; if (costToadjacentNode < adjacentNodeData.cost) { Debug.Log("cost from here are less than older " + costToadjacentNode + "<" + adjacentNodeData.cost); adjacentNodeData.cost = costToadjacentNode; adjacentNodeData.predecessor = currentNode; Debug.Log("Predecessor of " + adjacentNodeData.nodeID + " are " + adjacentNodeData.predecessor.GetComponent <NodeData>().nodeID); } Debug.Log(" Update " + adjacentNodeData.nodeID + " to " + adjacentNodeData.cost); } } if (isFounded) { break; } // find Least cost and choose to current node GameObject leastCostNode = finishNode; foreach (GameObject unVisitedObj in unVisitedList) { NodeData unVisitedNode = unVisitedObj.GetComponent <NodeData>(); if (unVisitedNode.cost < leastCostNode.GetComponent <NodeData>().cost&& unVisitedObj != currentNode) { leastCostNode = unVisitedObj; } Debug.Log("Compare " + unVisitedNode.nodeID + "- " + unVisitedNode.cost + "<" + leastCostNode.GetComponent <NodeData>().cost + " Least cost are:" + leastCostNode.GetComponent <NodeData>().nodeID + " cost:" + leastCostNode.GetComponent <NodeData>().cost); } unVisitedList.Remove(currentNode); Debug.Log("change predecessor of leastcostnode|" + leastCostNode.GetComponent <NodeData>().nodeID + "| form " + leastCostNode.GetComponent <NodeData>().predecessor + " To " + currentNode); currentNode = leastCostNode; currentNodeData = currentNode.GetComponent <NodeData>(); Debug.Log(" =====" + " Unvisited left " + unVisitedList.Count + " >=0 is " + (unVisitedList.Count >= 0)); Debug.Log("===== CurrentNode are " + currentNode.GetComponent <NodeData>().nodeID); } /* set successor from reverse finishNode's preDecessor */ currentNode = finishNode; Debug.Log(" From : " + finishNode.GetComponent <NodeData>().nodeID); while (currentNode != startNode) { currentNode.GetComponent <NodeData>().predecessor.GetComponent <NodeData>().successor = currentNode; currentNode = currentNode.GetComponent <NodeData>().predecessor; Debug.Log(currentNode.GetComponent <NodeData>().nodeID); } Debug.Log(" To : " + startNode.GetComponent <NodeData>().nodeID); return(isFounded); }
private void radioButtonToggle_Click(object sender, EventArgs e) { textBoxKeyChar.Enabled = textBoxKeyCode.Enabled = false; textBoxKeyChar.Text = textBoxKeyCode.Text = string.Empty; comboBoxSound.Enabled = true; comboBoxCmdProperty.Enabled = false; comboBoxCmdProperty.Items.Clear(); comboBoxCmdProperty.Text = "none"; var node = getNode("COMMAND"); var data = new NodeData("COMMAND", "TOGGLE", "-1"); node.Tag = data; node.Text = "Toggle Layer"; ((NodeData) node.Tag).Focus = checkBoxGainFocus.Checked; changedSettings = true; }
protected internal abstract void UpdateIndexDocument(NodeData nodeData, byte[] indexDocumentBytes);
public void UpdateNodeRow(NodeData nodeData) { WriteLog(MethodBase.GetCurrentMethod(), nodeData); _writer.UpdateNodeRow(nodeData); }
private void AddAttributeChunkToList(NodeData attr, NodeData chunk, ref NodeData lastChunk) { if (lastChunk == null) { Debug.Assert(attr.nextAttrValueChunk == null); lastChunk = chunk; attr.nextAttrValueChunk = chunk; } else { lastChunk.nextAttrValueChunk = chunk; lastChunk = chunk; } }
internal void SaveNodeData(NodeData nodeData, NodeSaveSettings settings, out int lastMajorVersionId, out int lastMinorVersionId) { if (nodeData == null) { throw new ArgumentNullException("nodeData"); } lastMajorVersionId = 0; lastMinorVersionId = 0; bool isNewNode = nodeData.Id == 0; // shortcut string path; if (nodeData.Id != Identifiers.PortalRootId) { var parent = NodeHead.Get(nodeData.ParentId); if (parent == null) { throw new ContentNotFoundException(nodeData.ParentId.ToString()); } path = RepositoryPath.Combine(parent.Path, nodeData.Name); } else { path = Identifiers.RootPath; } Node.AssertPath(path); nodeData.Path = path; var writer = this.CreateNodeWriter(); try { var savingAlgorithm = settings.GetSavingAlgorithm(); writer.Open(); if (settings.NeedToSaveData) { SaveNodeBaseData(nodeData, savingAlgorithm, writer, settings, out lastMajorVersionId, out lastMinorVersionId); BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeBaseData, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); if (!isNewNode && nodeData.PathChanged && nodeData.SharedData != null) { writer.UpdateSubTreePath(nodeData.SharedData.Path, nodeData.Path); } SaveNodeProperties(nodeData, savingAlgorithm, writer, isNewNode); } else { writer.UpdateNodeRow(nodeData); } writer.Close(); BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeFlatProperties, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); foreach (var versionId in settings.DeletableVersionIds) { DeleteVersion(versionId, nodeData, out lastMajorVersionId, out lastMinorVersionId); } } catch // rethrow { if (isNewNode) { // Failed save: set NodeId back to 0 nodeData.Id = 0; } throw; } }
private void SetupEndEntityNodeInAttribute() { _curNode = _nodes[_index + _attrCount + 1]; Debug.Assert(_curNode.type == XmlNodeType.EntityReference); Debug.Assert(Ref.Equal(_lastEntity.Name, _curNode.localName)); _curNode.lineInfo.linePos += _curNode.localName.Length; _curNode.type = XmlNodeType.EndEntity; }
public void SetNodeData(NodeData nodeData, int x, int y) { grid[x + y * gridWidth] = nodeData; }
private void OnEof() { Debug.Assert(_ps.isEof); _curNode = _nodes[0]; _curNode.Clear(XmlNodeType.None); _curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); _parsingFunction = ParsingFunction.Eof; _readState = ReadState.EndOfFile; _reportedEncoding = null; }
protected internal override void DeleteVersion(int versionId, NodeData nodeData, out int lastMajorVersionId, out int lastMinorVersionId) { base.DeleteVersion(versionId, nodeData, out lastMajorVersionId, out lastMinorVersionId); WriteLog(MethodInfo.GetCurrentMethod(), versionId, nodeData, lastMajorVersionId, lastMinorVersionId); }
private void AddNamespace(string prefix, string uri, NodeData attr) { if (uri == XmlReservedNs.NsXmlNs) { if (Ref.Equal(prefix, _xmlNs)) { Throw(SR.Xml_XmlnsPrefix, (int)attr.lineInfo2.lineNo, (int)attr.lineInfo2.linePos); } else { Throw(SR.Xml_NamespaceDeclXmlXmlns, prefix, (int)attr.lineInfo2.lineNo, (int)attr.lineInfo2.linePos); } } else if (uri == XmlReservedNs.NsXml) { if (!Ref.Equal(prefix, _xml) && !_v1Compat) { Throw(SR.Xml_NamespaceDeclXmlXmlns, prefix, (int)attr.lineInfo2.lineNo, (int)attr.lineInfo2.linePos); } } if (uri.Length == 0 && prefix.Length > 0) { Throw(SR.Xml_BadNamespaceDecl, (int)attr.lineInfo.lineNo, (int)attr.lineInfo.linePos); } try { _namespaceManager.AddNamespace(prefix, uri); } catch (ArgumentException e) { ReThrow(e, (int)attr.lineInfo.lineNo, (int)attr.lineInfo.linePos); } #if DEBUG if (prefix.Length == 0) { Debug.Assert(_xmlContext.defaultNamespace == uri); } #endif }
protected internal override void UpdateIndexDocument(NodeData nodeData, byte[] indexDocumentBytes) { WriteLog(MethodInfo.GetCurrentMethod(), nodeData, indexDocumentBytes); base.UpdateIndexDocument(nodeData, indexDocumentBytes); }
private bool AddDefaultAttributeDtd(IDtdDefaultAttributeInfo defAttrInfo, bool definedInDtd, NodeData[] nameSortedNodeData) { if (defAttrInfo.Prefix.Length > 0) { _attrNeedNamespaceLookup = true; } string localName = defAttrInfo.LocalName; string prefix = defAttrInfo.Prefix; // check for duplicates if (nameSortedNodeData != null) { if (Array.BinarySearch<object>(nameSortedNodeData, defAttrInfo, DtdDefaultAttributeInfoToNodeDataComparer.Instance) >= 0) { return false; } } else { for (int i = _index + 1; i < _index + 1 + _attrCount; i++) { if ((object)_nodes[i].localName == (object)localName && (object)_nodes[i].prefix == (object)prefix) { return false; } } } NodeData attr = AddDefaultAttributeInternal(defAttrInfo.LocalName, null, defAttrInfo.Prefix, defAttrInfo.DefaultValueExpanded, defAttrInfo.LineNumber, defAttrInfo.LinePosition, defAttrInfo.ValueLineNumber, defAttrInfo.ValueLinePosition, defAttrInfo.IsXmlAttribute); Debug.Assert(attr != null); if (DtdValidation) { if (_onDefaultAttributeUse != null) { _onDefaultAttributeUse(defAttrInfo, this); } attr.typedValue = defAttrInfo.DefaultValueTyped; } return attr != null; }
public void AddNode(NodeData node) { Nodes.TryAdd(node.NodeId, node); }
private void radioButtonActWindow_Click(object sender, EventArgs e) { comboBoxCmdProperty.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSound.Enabled = true; comboBoxCmdProperty.Enabled = true; var node = getNode("COMMAND"); var data = new NodeData("COMMAND", "WINDOW", "0"); node.Tag = data; UpdateCombo(ref comboBoxCmdProperty, windowsListFiltered, GetFriendlyName(Enum.GetName(typeof (GUIWindow.Window), Convert.ToInt32(data.Value)))); node.Text = "Window \"" + (string) comboBoxCmdProperty.SelectedItem + "\""; ((NodeData) node.Tag).Focus = checkBoxGainFocus.Checked; changedSettings = true; }
public override void PropagateNodeData(NodeData nodeData, ref MasterNodeDataCollector dataCollector) { base.PropagateNodeData(nodeData, ref dataCollector); dataCollector.DirtyNormal = true; }
public NodeDataActor(int nodeIndex) { NodeIndex = nodeIndex; NodeData = new NodeData(nodeIndex); SetReceive(); }
/// <summary> /// 构建节点 /// </summary> /// <param name="nodeData">节点数据</param> public BaseNode CreateNode(NodeData nodeData) { if (nodeData == null) { throw new Exception($"BehaviorTreeManager.CreateNode() \n nodeData is null."); } var proxyData = _proxyManager.GetProxyData(nodeData.ClassType); if (proxyData == null) { throw new Exception($"BehaviorTreeManager.CreateNode({nodeData.ClassType}) \n proxyData is null."); } BaseNode baseNode = null; switch (proxyData.NodeType) { case NodeType.Action: baseNode = new ActionNode { NodeType = NodeType.Action }; break; case NodeType.Composite: baseNode = new CompositeNode { NodeType = NodeType.Composite }; break; case NodeType.Condition: baseNode = new ConditionNode { NodeType = NodeType.Condition }; break; case NodeType.Decorator: baseNode = new DecorateNode { NodeType = NodeType.Condition }; break; } if (baseNode == null) { throw new Exception($"CreateNode {proxyData.Name} Failed"); } baseNode.SetData(nodeData); baseNode.SetProxyData(proxyData); if (baseNode is CompositeNode) { if (nodeData.Childs == null || nodeData.Childs.Count == 0) { throw new Exception($"{proxyData.NodeType} node must have child nodes"); } var compositeNode = baseNode as CompositeNode; for (int i = 0; i < nodeData.Childs.Count; i++) { var childNodeData = nodeData.Childs[i]; var childNode = CreateNode(childNodeData); compositeNode.AddChild(childNode); } } return(baseNode); }