Visual basic NET power tools (2004)

1.3K 111 0
Visual basic  NET power tools (2004)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Team Fly Cover Team Fly Team Fly Page iii Visual Basic™ Net Power Tools Evangelos Petroutsos and Richard Mansfield Team Fly Team Fly Page vii Acknowledgments WE WERE FORTUNATE TO have several smart, thoughtful editors assist us in polishing this manuscript First, we'd like to thank Development Editor Tom Cirtin He deserves credit for his discernment, and the high quality of his editing He's very good at dealing with his authors, and equally skilled at raising important questions and improving their chapters Technical Editor Greg Guntle carefully reviewed the manuscript and made many useful suggestions, caught a number of inconsistencies, and helped improve several code examples Production Editor Leslie Light ensured that this book moved smoothly through production and was most helpful with suggestions about the graphics, drawings, and screen shots Suzanne Goraj, copy editor, combed through every line of our text, making improvements throughout To all these, and the other good people at Sybex who contributed to this book, our thanks for the intelligence and care that they brought to this book In addition, the authors would like to give special thanks to their agents, Matt Wagner and David Fugate, of Waterside Productions, whose contributions to the authors' careers goes above and beyond the call of duty Team Fly Team Fly Page viii Contents at a Glance xix Introduction Chapter 1 • Understanding the NET Framework Chapter 2 • New Ways of Doing Traditional Jobs 23 59 Chapter 3 • Serialization Techniques Chapter 4 • Leveraging Microsoft Office in Your Applications 93 119 Chapter 5 • Understanding NET Security Chapter 6 • Encryption, Hashing, and Creating Keys 139 159 Chapter 7 • Advanced Printing 191 Chapter 8 • Upon Reflection Chapter 9 • Building Bug-Free and Robust Applications 215 243 Chapter 10 • Deploying Windows Applications Chapter 11 • Building Data-Driven Web 271 Applications 289 Chapter 12 • Peer-to-Peer Programming 319 Chapter 13 • Advanced Web Services Chapter 14 • Building Asynchronous Applications with Message Queues 341 391 Chapter 15 • Practical ADO.NET Chapter 16 • Building Middle-Tier Components 441 475 Chapter 17 • Exploring XML Techniques Chapter 18 • Designing Data-Driven Windows Applications 505 Chapter 19 • Working with Regular Expressions 543 589 Chapter 20 • Advanced Graphics 623 Chapter 21 • Designing the User Interface Chapter 22 • Using the NET Compact Framework and Its Emerging Technologies 643 665 Index Team Fly Team Fly Page ix Contents xix Introduction Chapter 1 • Understanding the NET Framework Why Read This Chapter Help! Grappling with Framework Class Descriptions The Hunt for a Grammar Why Two Ways? About Constructors Assemblies Three Ways Understanding Data Types About System.Object MemberWiseClone 10 10 11 11 12 12 all kinds of special cases surfaced during the tests Getting the correct regular expression takes a few trials, and we recommend that you test your regular expressions with long documents that are likely to contain a large number of matches For example, you may write a regular expression to match e-mail addresses that works with the sample document you provide, but misses addresses that contain periods in the username Referring to a previous subexpression in the same match is also known as backreference Backreferences are references to earlier groups of the same match by their number, and you can refer to the last nine groups in the same match as \1, \2, etc up to \9 Notice that you can't make backreferences by name Named groups can be used in a replacement pattern, but not in the same regular expression you're using to search the text Another example along the same lines is the formatting of dates in a standard format throughout a document The following regular expression will locate dates in the text: \b(?\d{1,2})[/|-](?\d{1,2})[/|-](?\d{2,4})\b The regular expression isn't going to validate the dates (it will happily locate a date like 13/13/2004, which is clearly an invalid date in the western calendar) However, it will accept dates with backslashes and/or dashes as separators Each part of the date is a different group of the match, because they're Team Fly Team Fly Page 575 CAPTURE 8 value12 CAPTURE 9 value13 GROUP 5564 CAPTURE 1 34 CAPTURE 2 405 CAPTURE 3 4534 CAPTURE 4 45 CAPTURE 5 3334 CAPTURE 6 -4554 CAPTURE 7 3904 CAPTURE 8 456 CAPTURE 9 5564 The first group contains a single capture, which is the entire matched string The second group contains the pairs of keys and values, as they appear in the matched text The last two groups contain the names of the keys and the corresponding values If you test the pattern shown in this example with a large segment of text, you'll realize that the operation will take a while, but this is the most efficient method of parsing text made up of items with the same structure The problem with processing text files with regular expressions is that you won't get any indications about possible errors (errors that you would normally catch from within your code if you wrote a parsing routine in VB) You should make sure that the file has the correct structure before processing it with regular expressions Because the syntax of regular expressions is so cryptic, you should also test your regular expressions with some simple text to make sure that they locate the desired patterns Try to include in your sample text patterns that are similar to the ones you want to capture but that don't qualify After you're certain that the regular expression you have built locates the desired patterns in the sample text, use it with a large segment of text Lookahead and Lookbehind Assertions A lookahead assertion is a tool for specifying not a match, but a pattern that will precede the match For example, we may be interested in extracting the century from a date's year (the numeric value 17 from 1789, for example) We want to grab the first two digits from a four-digit string This is a positive lookahead assertion and can be expressed with the following regular expression: \d\d(?=89) This regular expression will match the string ''17" in "1789." There are positive and negative lookaheads A positive lookahead specifies the pattern that must follow the match, and it must appear in a pair of parentheses and be prefixed with a question mark and the equals sign A negative lookahead specifies the pattern that must not follow the match, and it must appear in a pair of parentheses prefixed by a question mark and the exclamation mark Lookbehind assertions are equivalent to lookahead assertions, but they specify the pattern that must precede the match A positive lookbehind specifies the pattern that must precede the match, and it must appear in a pair of parentheses and be prefixed by a question mark, the left angle bracket, and the equals sign The following regular expression is a positive lookbehind that matches the "34" in 1934 and the "99" in "1999." (?

Ngày đăng: 25/03/2019, 16:35

Mục lục

  • Cover

  • Visual Basic .Net Power Tools

  • Acknowledgments

  • Contents at a Glance

  • Contents

  • Introduction

  • Complexity and the Avant-Garde

  • Who Should Read This Book, and Why?

  • Chapter 1 Understanding the .NET Framework

    • Why Read This Chapter

    • Help!

    • Grappling with Framework Class Descriptions

    • The Hunt for a Grammar

    • Understanding Data Types

    • Exploiting the Framework

    • A Useful Class View Utility

    • A Brief Lexicon

    • Summary

    • Chapter 2 New Ways of Doing Traditional Jobs

      • Working with ''Control Arrays

      • Using Arrays

      • The Flexible ArrayList

Tài liệu cùng người dùng

Tài liệu liên quan