public void GetSetRegex() { var element = new RegexElement(); var regex = new Regex(".+"); element.Regex = regex; Assert.Equal(regex, element.Regex); }
public PathRegex(string s, Dictionary <string, ItemMatch> definedItemMatches, Dictionary <string, DependencyMatch> definedDependencyMatches, bool ignoreCase) { _definedItemMatches = definedItemMatches; _definedDependencyMatches = definedDependencyMatches; _ignoreCase = ignoreCase; RegexElement e = Parse(s, 0); ChainingInfo topChainingInfo = e.Validate(); if (!topChainingInfo.StartsWithItemMatch) { throw new RegexValidationException(e, null, "Path regex must start with item match"); } if (!topChainingInfo.EndsWithItemMatch) { throw new RegexValidationException(e, null, "Path regex must end with item match"); } _rootExecutionNode = e.CreateDeterministicExecutionGraph(); }
void SetNodeByClassID(int classID, PackedItemNode nodeRoot, List <PackedNativeUnityEngineObject> nativeUnityObjectList) { nodeRoot.Clear(); nodeRoot.nativeType = data.mSnapshot.nativeTypes [classID]; int index = -1; if (memoryFilters) { for (int i = 0; i < memoryFilters.memoryFilterList.Count; i++) { if ((int)memoryFilters.memoryFilterList[i].classID == classID) { index = i; } } } if (index > -1) //这样写好蛋疼啊0.0 { Dictionary <PackedItemNode, RegexElement> tempDict = new Dictionary <PackedItemNode, RegexElement>(); PackedItemNode otherNode = new PackedItemNode("Others"); otherNode.nativeType = data.mSnapshot.nativeTypes [classID]; nodeRoot.AddNode(otherNode); MemoryFilter memoryFilter = memoryFilters.memoryFilterList[index]; for (int i = 0; i < memoryFilter.regexElementList.Count; i++) { PackedItemNode filterNode = new PackedItemNode(memoryFilter.regexElementList[i].key, true); filterNode.nativeType = data.mSnapshot.nativeTypes [classID]; nodeRoot.AddNode(filterNode); tempDict.Add(filterNode, memoryFilter.regexElementList[i]); } while (nativeUnityObjectList.Count > 0) { PackedNativeUnityEngineObject item = nativeUnityObjectList[0]; string name = item.name; PackedItemNode childNode = new PackedItemNode(name); childNode.size = item.size; childNode.instanceID = item.instanceId; childNode.nativeType = data.mSnapshot.nativeTypes [classID]; bool isMatch = false; using (var i = tempDict.GetEnumerator())//replace foreach { while (i.MoveNext()) { RegexElement regexElement = i.Current.Value; for (int j = 0; j < regexElement.regexList.Count; j++) { if (StringMatchWith(name, regexElement.regexList[j])) { i.Current.Key.AddNode(childNode); isMatch = true; break; } } if (isMatch) { break; } } } if (!isMatch) { otherNode.AddNode(childNode); } nativeUnityObjectList.RemoveAt(0); } } else { for (int i = 0; i < nativeUnityObjectList.Count; i++) { PackedNativeUnityEngineObject item = nativeUnityObjectList[i]; string name = item.name; PackedItemNode node = new PackedItemNode(name); node.size = item.size; node.instanceID = item.instanceId; node.nativeType = data.mSnapshot.nativeTypes [classID]; nodeRoot.AddNode(node); } } }
public RegexStar(RegexElement inner) => Inner = inner;
public RegexAlternative(RegexElement left, RegexElement right) { Left = left; Right = right; }
public RegexSequential(RegexElement left, RegexElement right) { Left = left; Right = right; }
public RegexValidationException(RegexElement first, RegexElement second, string message) : base(message) { First = first; Second = second; }