/// <include file='doc\DebugHandleTracker.uex' path='docs/doc[@for="DebugHandleTracker.HandleType.HandleEntry.ToString"]/*' />
                /// <devdoc>
                ///     Converts this handle to a printable string.  the string consists
                ///     of the handle value along with the callstack for it's
                ///     allocation.
                /// </devdoc>
                public string ToString(HandleType type)
                {
                    StackParser sp = new StackParser(callStack);

                    // Discard all of the stack up to and including the "Handle.create" call
                    //
                    sp.DiscardTo("HandleCollector.Add");

                    // Skip the next call as it is always a debug wrapper
                    //
                    sp.DiscardNext();

                    // Now recreate the leak list with ten stack entries maximum, and
                    // put it all on one line.
                    //
                    sp.Truncate(10);

                    string description = "";

                    if (type.name.Equals("GDI") || type.name.Equals("HDC"))
                    {
                        int objectType = UnsafeNativeMethods.GetObjectType(new HandleRef(null, handle));
                        switch (objectType)
                        {
                        case NativeMethods.OBJ_DC: description = "normal DC"; break;

                        case NativeMethods.OBJ_MEMDC: description = "memory DC"; break;

                        case NativeMethods.OBJ_METADC: description = "metafile DC"; break;

                        case NativeMethods.OBJ_ENHMETADC: description = "enhanced metafile DC"; break;

                        case NativeMethods.OBJ_PEN: description = "Pen"; break;

                        case NativeMethods.OBJ_BRUSH: description = "Brush"; break;

                        case NativeMethods.OBJ_PAL: description = "Palette"; break;

                        case NativeMethods.OBJ_FONT: description = "Font"; break;

                        case NativeMethods.OBJ_BITMAP: description = "Bitmap"; break;

                        case NativeMethods.OBJ_REGION: description = "Region"; break;

                        case NativeMethods.OBJ_METAFILE: description = "Metafile"; break;

                        case NativeMethods.OBJ_EXTPEN: description = "Extpen"; break;

                        default: description = "?"; break;
                        }
                        description = " (" + description + ")";
                    }

                    return(Convert.ToString((int)handle, 16) + description + ": " + sp.ToString());
                }
Example #2
0
                public string ToString(System.Internal.DebugHandleTracker.HandleType type)
                {
                    StackParser parser = new StackParser(this.callStack);

                    parser.DiscardTo("HandleCollector.Add");
                    parser.DiscardNext();
                    parser.Truncate(40);
                    string str = "";

                    return(Convert.ToString((int)this.handle, 0x10) + str + ": " + parser.ToString());
                }
                public string ToString(HandleType type)
                {
                    StackParser stackParser = new StackParser(callStack);

                    stackParser.DiscardTo("HandleCollector.Add");
                    stackParser.DiscardNext();
                    stackParser.Truncate(40);
                    string str = "";

                    return(Convert.ToString((int)handle, 16) + str + ": " + stackParser.ToString());
                }
Example #4
0
        public void ResponseTest()
        {
            //const string input = "I like to golf";
            const string input = "I am a cat";

            var stacks = StackParser.Parse(input);

            var primary = stacks.First().First().OrderedSearch();

            var str = primary.TokensToResponse();

            Assert.AreEqual("How do you feel about the fact that you are a cat?", str);
        }
Example #5
0
                /// <summary>
                /// Converts this handle to a printable string.  the string consists of the handle value along with
                /// the callstack for it's allocation.
                /// </summary>
                public string ToString(HandleType type)
                {
                    StackParser sp = new StackParser(callStack);

                    // Discard all of the stack up to and including the "Handle.create" call
                    sp.DiscardTo("HandleCollector.Add");

                    // Skip the next call as it is always a debug wrapper
                    sp.DiscardNext();

                    // Now recreate the leak list with a lot of stack entries
                    sp.Truncate(40);

                    string description = "";

                    return(Convert.ToString(unchecked ((int)handle), 16) + description + ": " + sp.ToString());
                }
Example #6
0
        public void GrammarTest()
        {
            var success = new List <string> {
                "I love a dog",
                "I love dogs",
                "I am a cat",
                "The dog chases the cat",
                "Cats love me",
                "A dog bites a cat",
                "I like to golf",
                "The cat with the cat with the fish chases the dog",
            };

            var failed = new List <string> {
                "",
                "  ",
                "\n",
                "dfsdf",
                "dog is love",
                "am is love",
                "dog cat fish",
            };

            foreach (var input in success)
            {
                Token head;
                var   hasCorrectGrammer = StackParser.TryParseFirst(input, out head);

                Assert.IsTrue(hasCorrectGrammer);

                var str = head.OrderedSearch().TokensToString();

                Assert.AreEqual(input.ToLower().Trim(), str);
            }

            foreach (var input in failed)
            {
                Token head;
                var   hasCorrectGrammer = StackParser.TryParseFirst(input, out head);

                Assert.IsFalse(hasCorrectGrammer);
            }
        }
                /// <include file='doc\DebugHandleTracker.uex' path='docs/doc[@for="DebugHandleTracker.HandleType.HandleEntry.ToString"]/*' />
                /// <devdoc>
                ///     Converts this handle to a printable string.  the string consists
                ///     of the handle value along with the callstack for it's
                ///     allocation.
                /// </devdoc>
                public string ToString(HandleType type) {
                    StackParser sp = new StackParser(callStack);

                    // Discard all of the stack up to and including the "Handle.create" call
                    //
                    sp.DiscardTo("HandleCollector.Add");

                    // Skip the next call as it is always a debug wrapper
                    //
                    sp.DiscardNext();

                    // Now recreate the leak list with a lot of stack entries
                    //
                    sp.Truncate(40);

                    string description = "";
                    /*if (type.name.Equals("GDI") || type.name.Equals("HDC")) {
                        int objectType = UnsafeNativeMethods.GetObjectType(new HandleRef(null, handle));
                        switch (objectType) {
                            case NativeMethods.OBJ_DC: description = "normal DC"; break;
                            case NativeMethods.OBJ_MEMDC: description = "memory DC"; break;
                            case NativeMethods.OBJ_METADC: description = "metafile DC"; break;
                            case NativeMethods.OBJ_ENHMETADC: description = "enhanced metafile DC"; break;

                            case NativeMethods.OBJ_PEN: description = "Pen"; break;
                            case NativeMethods.OBJ_BRUSH: description = "Brush"; break;
                            case NativeMethods.OBJ_PAL: description = "Palette"; break;
                            case NativeMethods.OBJ_FONT: description = "Font"; break;
                            case NativeMethods.OBJ_BITMAP: description = "Bitmap"; break;
                            case NativeMethods.OBJ_REGION: description = "Region"; break;
                            case NativeMethods.OBJ_METAFILE: description = "Metafile"; break;
                            case NativeMethods.OBJ_EXTPEN: description = "Extpen"; break;
                            default: description = "?"; break;
                        }
                        description = " (" + description + ")";
                    }*/

                    return Convert.ToString(unchecked((int)handle), 16) + description + ": " + sp.ToString();
                }
 public string ToString(DebugHandleTracker.HandleType type)
 {
     StackParser parser = new StackParser(this.callStack);
     parser.DiscardTo("HandleCollector.Add");
     parser.DiscardNext();
     parser.Truncate(40);
     string str = "";
     return (Convert.ToString((int) this.handle, 0x10) + str + ": " + parser.ToString());
 }