Ejemplo n.º 1
0
        public void application_ReleaseRequestState(object sender, EventArgs e)
        {
            HttpContext  httpContext = HttpContext.Current;
            HttpResponse response    = httpContext.Response;

            if (viewStateStatus != null &&
                viewStateStatus.Active == true)
            {
                memoryFilter    = new MemoryFilter(response.Filter, viewStateStatus);
                response.Filter = memoryFilter;
            }
        }
        private static Filter ConvertStreamToFilter(Stream stream)
        {
            using var memoryStream = new MemoryStream();
            stream.CopyTo(memoryStream);

            var byteArray = memoryStream.ToArray();

            var memoryFilter = new MemoryFilter(byteArray.Length, false);

            using var filterWriter = new FilterWriter(memoryFilter);

            filterWriter.WriteBuffer(byteArray);
            memoryFilter.SetAsInputFilter();

            return(memoryFilter);
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }