Hilfe Warenkorb Konto Anmelden
 
 
   Schnellsuche   
     zur Expertensuche                      
Professional C# 6 and .NET Core 1.0
  Großes Bild
 
Professional C# 6 and .NET Core 1.0
von: Christian Nagel
Wrox, 2016
ISBN: 9781119096719
1532 Seiten, Download: 124656 KB
 
Format:  PDF
geeignet für: Apple iPad, Android Tablet PC's Online-Lesen PC, MAC, Laptop

Typ: A (einfacher Zugriff)

 

 
eBook anfordern
Inhaltsverzeichnis

  Cover 5  
  Title Page 7  
  Copyright 8  
  About the Author 11  
  About the Technical Editor 13  
  Credits 15  
  Acknowledgments 17  
  Contents 19  
  Introduction 53  
  Part I: The C# Language 67  
     Chapter 1: .NET Application Architectures 69  
        Choosing Your Technologies 69  
        Reviewing .NET History 70  
           C# 1.0—A New Language 70  
           C# 2 and .NET 2 with Generics 71  
           .NET 3—Windows Presentation Foundation 72  
           C# 3 and .NET 3.5—LINQ 72  
           C# 4 and .NET 4—Dynamic and TPL 73  
           C# 5 and Asynchronous Programming 73  
           C# 6 and .NET Core 74  
           Choosing Technologies and Going Forward 75  
        .NET 2015 76  
           .NET Framework 4.6 76  
           .NET Core 1.0 77  
           Assemblies 78  
              Private Assemblies 78  
              Shared Assemblies 79  
           NuGet Packages 79  
           Common Language Runtime 80  
           .NET Native 81  
           Windows Runtime 81  
        Hello, World 82  
        Compiling with .NET 4.6 83  
        Compiling with .NET Core CLI 85  
           Setting Up the Environment 85  
           Building the Application 85  
           Packaging and Publishing the Application 88  
        Application Types and Technologies 89  
           Data Access 89  
           Windows Desktop Applications 90  
           Universal Windows Platform 91  
           SOAP Services with WCF 91  
           Web Services with the ASP.NET Web API 92  
           WebHooks and SignalR 92  
           Windows Services 92  
           Web Applications 93  
           Microsoft Azure 93  
              Software as a Service 93  
              Infrastructure as a Service 93  
              Platform as a Service 93  
        Developer Tools 94  
           Visual Studio Community 94  
           Visual Studio Professional with MSDN 94  
           Visual Studio Enterprise with MSDN 94  
           Visual Studio Code 95  
        Summary 95  
     Chapter 2: Core C# 97  
        Fundamentals of C# 98  
        Creating Hello, World! with Visual Studio 98  
           Creating a Solution 98  
           Creating a New Project 99  
           Compiling and Running the Program 101  
           Taking a Closer Look at the Code 103  
        Working with Variables 104  
           Initializing Variables 105  
           Using Type Inference 105  
           Understanding Variable Scope 106  
              Scope Clashes for Local Variables 107  
              Scope Clashes for Fields and Local Variables 108  
           Working with Constants 108  
        Using Predefined Data Types 109  
           Value Types and Reference Types 109  
           .NET Types 110  
           Predefined Value Types 110  
              Integer Types 110  
              Floating-Point Types 111  
              The Decimal Type 112  
              The Boolean Type 112  
              The Character Type 112  
           Predefined Reference Types 113  
              The object Type 113  
              The string Type 113  
        Controlling Program Flow 115  
           Conditional Statements 115  
              The if Statement 115  
              The switch Statement 117  
           Loops 118  
              The for Loop 118  
              The while Loop 120  
              The do. . .while Loop 120  
              The foreach Loop 121  
           Jump Statements 121  
              The goto Statement 121  
              The break Statement 122  
              The continue Statement 122  
              The return Statement 122  
        Working with Enumerations 122  
        Getting Organized with Namespaces 123  
           The using Directive 124  
           Namespace Aliases 125  
        Understanding the Main Method 126  
        Using Comments 127  
           Internal Comments Within the Source Files 127  
           XML Documentation 128  
        Understanding C# Preprocessor Directives 129  
           #define and #undef 129  
           #if, #elif, #else, and #endif 130  
           #warning and #error 131  
           #region and #endregion 131  
           #line 131  
           #pragma 131  
        C# Programming Guidelines 132  
           Rules for Identifiers 132  
           Usage Conventions 133  
              Naming Conventions 134  
              Use of Properties and Methods 136  
              Use of Fields 136  
        Summary 137  
     Chapter 3: Objects and Types 139  
        Creating and Using Classes 140  
        Classes and Structs 140  
        Classes 141  
        Fields 142  
        Properties 142  
           Auto-Implemented Properties 143  
           Access Modifiers for Properties 143  
        Methods 144  
           Declaring Methods 144  
           Expression-Bodied Methods 145  
           Invoking Methods 145  
           Method Overloading 146  
           Named Arguments 146  
           Optional Arguments 147  
           Variable Number of Arguments 148  
        Constructors 148  
           Calling Constructors from Other Constructors 150  
           Static Constructors 151  
        Readonly Members 153  
           Readonly Fields 153  
           Readonly Properties 154  
           Auto-implemented Readonly Properties 154  
           Expression-Bodied Properties 154  
           Immutable Types 155  
        Anonymous Types 155  
        Structs 156  
           Structs Are Value Types 157  
           Structs and Inheritance 158  
           Constructors for Structs 158  
        Passing Parameters by Value and by Reference 158  
           ref Parameters 159  
           out Parameters 160  
        Nullable Types 160  
        Enumerations 161  
        Partial Classes 163  
        Extension Methods 165  
        The Object Class 166  
        Summary 167  
     Chapter 4: Inheritance 169  
        Inheritance 169  
        Types of Inheritance 169  
           Multiple Inheritance 170  
           Structs and Classes 170  
        Implementation Inheritance 170  
           Virtual Methods 171  
           Polymorphism 173  
           Hiding Methods 173  
           Calling Base Versions of Methods 175  
           Abstract Classes and Methods 175  
           Sealed Classes and Methods 176  
           Constructors of Derived Classes 177  
        Modifiers 179  
           Access Modifiers 179  
           Other Modifiers 180  
        Interfaces 181  
           Defining and Implementing Interfaces 182  
           Interface Inheritance 184  
        is and as Operators 186  
        Summary 187  
     Chapter 5: Managed and Unmanaged Resources 189  
        Resources 189  
        Memory Management Under the Hood 190  
           Value Data Types 190  
           Reference Data Types 193  
           Garbage Collection 195  
        Strong and Weak References 197  
        Working with Unmanaged Resources 198  
           Destructors or Finalizers 199  
           The IDisposable Interface 200  
           The using Statement 201  
           Implementing IDisposable and a Destructor 201  
           IDisposable and Finalizer Rules 203  
        Unsafe Code 203  
           Accessing Memory Directly with Pointers 204  
              Writing Unsafe Code with the unsafe Keyword 205  
              Pointer Syntax 206  
              Casting Pointers to Integer Types 207  
              Casting Between Pointer Types 208  
              void Pointers 208  
              Pointer Arithmetic 208  
              The sizeof Operator 210  
              Pointers to Structs: The Pointer Member Access Operator 210  
              Pointers to Class Members 211  
           Pointer Example: PointerPlayground 212  
           Using Pointers to Optimize Performance 216  
              Creating Stack-based Arrays 216  
              QuickArray Example 219  
        Platform Invoke 220  
        Summary 224  
     Chapter 6: Generics 225  
        Generics Overview 225  
           Performance 226  
           Type Safety 227  
           Binary Code Reuse 228  
           Code Bloat 228  
           Naming Guidelines 228  
        Creating Generic Classes 228  
        Generics Features 232  
           Default Values 233  
           Constraints 233  
           Inheritance 236  
           Static Members 237  
        Generic Interfaces 237  
           Covariance and Contra-variance 238  
           Covariance with Generic Interfaces 238  
           Contra-Variance with Generic Interfaces 240  
        Generic Structs 240  
        Generic Methods 243  
           Generic Methods Example 243  
           Generic Methods with Constraints 244  
           Generic Methods with Delegates 245  
           Generic Methods Specialization 246  
        Summary 247  
     Chapter 7: Arrays and Tuples 249  
        Multiple Objects of the Same and Different Types 249  
        Simple Arrays 250  
           Array Declaration 250  
           Array Initialization 250  
           Accessing Array Elements 251  
           Using Reference Types 252  
        Multidimensional Arrays 253  
        Jagged Arrays 254  
        Array Class 255  
           Creating Arrays 255  
           Copying Arrays 256  
           Sorting 257  
        Arrays as Parameters 260  
           Array Covariance 260  
           ArraySegment 260  
        Enumerators 261  
           IEnumerator Interface 262  
           foreach Statement 262  
           yield Statement 263  
              Different Ways to Iterate Through Collections 265  
              Returning Enumerators with Yield Return 266  
        Tuples 267  
        Structural Comparison 268  
        Summary 270  
     Chapter 8: Operators and Casts 271  
        Operators and Casts 271  
        Operators 272  
           Operator Shortcuts 273  
           The Conditional Operator (?:) 274  
           The checked and unchecked Operators 275  
           The is Operator 276  
           The as Operator 276  
           The sizeof Operator 276  
           The typeof Operator 277  
           The nameof Operator 277  
           The index Operator 278  
           Nullable Types and Operators 278  
           The Null Coalescing Operator 279  
           The Null Propagation Operator 280  
           Operator Precedence and Associativity 281  
        Type Safety 282  
           Type Conversions 283  
              Implicit Conversions 283  
              Explicit Conversions 284  
           Boxing and Unboxing 286  
        Comparing Objects for Equality 287  
           Comparing Reference Types for Equality 287  
              The ReferenceEquals Method 287  
              The Virtual Equals Method 287  
              The Static Equals Method 287  
              Comparison Operator (==) 288  
           Comparing Value Types for Equality 288  
        Operator Overloading 288  
           How Operators Work 289  
           Operator Overloading Example: The struct Vector 290  
           Overloading the Comparison Operators 294  
           Which Operators Can You Overload? 296  
        Implementing Custom Index Operators 297  
        User-Defined Casts 299  
           Implementing User-Defined Casts 300  
              Casts Between Classes 303  
              Casts Between Base and Derived Classes 304  
              Boxing and Unboxing Casts 305  
           Multiple Casting 305  
        Summary 308  
     Chapter 9: Delegates, Lambdas, and Events 309  
        Referencing Methods 309  
        Delegates 310  
           Declaring Delegates 311  
           Using Delegates 312  
           Simple Delegate Example 315  
           Action and Func Delegates 316  
           BubbleSorter Example 317  
           Multicast Delegates 319  
           Anonymous Methods 322  
        Lambda Expressions 324  
           Parameters 324  
           Multiple Code Lines 325  
           Closures 325  
        Events 326  
           Event Publisher 326  
           Event Listener 328  
           Weak Events 329  
        Summary 331  
     Chapter 10: Strings and Regular Expressions 333  
        Examining System.String 334  
           Building Strings 335  
           StringBuilder Members 338  
        String Formats 339  
           String Interpolation 339  
              FormattableString 339  
              Using Other Cultures with String Interpolation 340  
              Escaping Curly Brackets 341  
           DateTime and Number Formats 341  
           Custom String Formats 342  
        Regular Expressions 343  
           Introduction to Regular Expressions 344  
           The RegularExpressionsPlayground Example 345  
           Displaying Results 348  
           Matches, Groups, and Captures 349  
        Summary 351  
     Chapter 11: Collections 353  
        Overview 353  
        Collection Interfaces and Types 354  
        Lists 355  
           Creating Lists 356  
           Collection Initializers 356  
           Adding Elements 357  
           Inserting Elements 357  
           Accessing Elements 358  
           Removing Elements 358  
           Searching 359  
           Sorting 361  
           Read-Only Collections 362  
        Queues 362  
        Stacks 366  
        Linked Lists 368  
        Sorted List 372  
        Dictionaries 374  
           Dictionary Initializers 374  
           Key Type 375  
           Dictionary Example 376  
           Lookups 379  
           Sorted Dictionaries 380  
        Sets 380  
        Performance 382  
        Summary 384  
     Chapter 12: Special Collections 385  
        Overview 385  
        Working with Bits 385  
           BitArray 386  
           BitVector32 388  
        Observable Collections 390  
        Immutable Collections 392  
           Using Builders with Immutable Collections 394  
           Immutable Collection Types and Interfaces 394  
           Using LINQ with Immutable Arrays 395  
        Concurrent Collections 395  
           Creating Pipelines 396  
           Using a BlockingCollection 399  
           Using a ConcurrentDictionary 400  
           Completing the Pipeline 401  
        Summary 402  
     Chapter 13: Language Integrated Query 405  
        LINQ Overview 405  
           Lists and Entities 406  
           LINQ Query 409  
           Extension Methods 409  
           Deferred Query Execution 411  
        Standard Query Operators 413  
           Filtering 414  
           Filtering with Index 415  
           Type Filtering 415  
           Compound from 416  
           Sorting 417  
           Grouping 418  
           Variables Within the LINQ Query 418  
           Grouping with Nested Objects 419  
           Inner Join 420  
           Left Outer Join 421  
           Group Join 422  
           Set Operations 425  
           Zip 426  
           Partitioning 427  
           Aggregate Operators 428  
           Conversion Operators 429  
           Generation Operators 431  
        Parallel LINQ 431  
           Parallel Queries 431  
           Partitioners 432  
           Cancellation 433  
        Expression Trees 433  
        LINQ Providers 436  
        Summary 436  
     Chapter 14: Errors and Exceptions 437  
        Introduction 437  
        Exception Classes 438  
        Catching Exceptions 440  
           Implementing Multiple Catch Blocks 442  
           Catching Exceptions from Other Code 445  
           System.Exception Properties 445  
           Exception Filters 446  
           Re-throwing Exceptions 447  
              Naïve Use to Rethrow the Exception 448  
              Changing the Exception 449  
              Rethrowing the Exception 450  
              Using Filters to Add Functionality 450  
           What Happens If an Exception Isn’t Handled? 451  
        User-Defined Exception Classes 451  
           Catching the User-Defined Exceptions 452  
           Throwing the User-Defined Exceptions 454  
           Defining the User-Defined Exception Classes 457  
        Caller Information 459  
        Summary 460  
     Chapter 15: Asynchronous Programming 461  
        Why Asynchronous Programming Is Important 461  
        Asynchronous Patterns 462  
           Synchronous Call 468  
           Asynchronous Pattern 469  
           Event-Based Asynchronous Pattern 471  
           Task-Based Asynchronous Pattern 471  
        Foundation of Asynchronous Programming 473  
           Creating Tasks 474  
           Calling an Asynchronous Method 474  
           Continuation with Tasks 475  
           Synchronization Context 475  
           Using Multiple Asynchronous Methods 475  
              Calling Asynchronous Methods Sequentially 475  
              Using Combinators 476  
           Converting the Asynchronous Pattern 476  
        Error Handling 477  
           Handling Exceptions with Asynchronous Methods 478  
           Handling Exceptions with Multiple Asynchronous Methods 478  
           Using AggregateException Information 479  
        Cancellation 480  
           Starting a Cancellation 480  
           Cancellation with Framework Features 481  
           Cancellation with Custom Tasks 481  
        Summary 482  
     Chapter 16: Reflection, Metadata, and Dynamic Programming 483  
        Inspecting Code at RunTime and Dynamic Programming 483  
        Custom Attributes 484  
           Writing Custom Attributes 485  
              Specifying the AttributeUsage Attribute 486  
              Specifying Attribute Parameters 487  
              Specifying Optional Attribute Parameters 487  
           Custom Attribute Example: WhatsNewAttributes 488  
              The WhatsNewAttributes Library Assembly 488  
              The VectorClass Assembly 489  
        Using Reflection 491  
           The System.Type Class 491  
              Type Properties 491  
              Methods 492  
           The TypeView Example 493  
           The Assembly Class 495  
              Getting Details About Types Defined in an Assembly 496  
              Getting Details About Custom Attributes 496  
           Completing the WhatsNewAttributes Example 497  
        Using Dynamic Language Extensions for Reflection 501  
           Creating the Calculator Library 501  
           Instantiating a Type Dynamically 502  
           Invoking a Member with the Reflection API 504  
           Invoking a Member with the Dynamic Type 505  
        The Dynamic Type 506  
           Dynamic Behind the Scenes 507  
        Dynamic Language Runtime 510  
        Hosting the DLR ScriptRuntime 510  
        DynamicObject and ExpandoObject 513  
           DynamicObject 513  
           ExpandoObject 514  
        Summary 517  
  Part II: .NET Core and Windows Runtime 519  
     Chapter 17: Visual Studio 2015 521  
        Working with Visual Studio 2015 521  
           Visual Studio Editions 524  
           Visual Studio Settings 524  
        Creating a Project 525  
           Multi-Targeting the .NET Framework 526  
           Selecting a Project Type 528  
              Using Windows Classic Desktop Project Templates 528  
              Using Universal Project Templates 529  
              Using Web Project Templates 530  
              Using WCF Project Templates 532  
        Exploring and Coding a Project 533  
           Build Environments: CLI and MSBuild 533  
           Solution Explorer 534  
              Working with Projects and Solutions 534  
              Adding Projects to a Solution 535  
              Setting the Startup Project 537  
              Discovering Types and Members 537  
              Previewing Items 538  
              Using Scopes 538  
              Adding Items to a Project 539  
              Managing References 539  
              Using NuGet Packages 541  
           Working with the Code Editor 543  
              The Folding Editor 543  
              Navigating Within the Editor 545  
              IntelliSense 545  
              CodeLens 545  
              Using Code Snippets 546  
           Learning and Understanding Other Windows 547  
              Using the Design View Window 547  
              Using the Properties Window 548  
              Using the Class View Window 548  
              Using the Object Browser Window 549  
              Using the Server Explorer Window 550  
              Using the Cloud Explorer 551  
              Using the Document Outline 551  
           Arranging Windows 552  
        Building a Project 553  
           Building, Compiling, and Making Code 553  
           Debugging and Release Builds 553  
              Optimization 553  
              Debugger Symbols 554  
              Extra Source Code Debugging Commands 554  
           Selecting a Configuration 555  
           Editing Configurations 555  
        Debugging Your Code 557  
           Setting Breakpoints 558  
           Using Data Tips and Debugger Visualizers 558  
           Live Visual Tree 559  
           Monitoring and Changing Variables 559  
           Exceptions 561  
           Multithreading 562  
        Refactoring Tools 563  
        Architecture Tools 565  
           Code Map 566  
           Layer Diagram 567  
        Analyzing Applications 569  
           Diagnostics Tools 569  
           Concurrency Visualizer 573  
           Code Analyzers 574  
           Code Metrics 575  
        Summary 575  
     Chapter 18: .NET Compiler Platform 577  
        Introduction 577  
        Compiler Pipeline 579  
        Syntax Analysis 579  
           Using Query Nodes 585  
           Walking Through Nodes 586  
        Semantics Analysis 588  
           Compilation 589  
           Semantic Model 590  
        Code Transformation 591  
           Creating New Trees 591  
           Working with Syntax Rewriter 593  
        Visual Studio Code Refactoring 598  
           VSIX Packages 598  
           Code Refactoring Provider 601  
        Summary 605  
     Chapter 19: Testing 607  
        Overview 607  
        Unit Testing with MSTest 608  
           Creating Unit Tests with MSTest 608  
           Running Unit Tests 610  
           Expecting Exceptions with MSTest 612  
           Testing All Code Paths 613  
           External Dependencies 614  
           Fakes Framework 616  
           IntelliTest 617  
        Unit Testing with xUnit 618  
           Using xUnit with .NET Core 619  
           Creating Facts 619  
           Creating Theories 619  
           Running Unit Tests with the dotnet Tools 620  
           Using a Mocking Library 621  
        UI Testing 624  
        Web Testing 628  
           Creating the Web Test 628  
           Running the Web Test 631  
           Web Load Test 632  
        Summary 633  
     Chapter 20: Diagnostics and Application Insights 635  
        Diagnostics Overview 635  
        Tracing with EventSource 636  
           Examining a Simple Use of EventSource 637  
           Understanding Tools for Tracing 639  
              Logman 639  
              Tracerpt 639  
              PerfView 640  
           Deriving from EventSource 640  
           Using Annotations with EventSource 642  
           Creating Event Manifest Schema 644  
           Using Activity IDs 646  
        Creating Custom Listeners 649  
        Working with Application Insights 650  
           Creating a Universal Windows App 650  
           Creating an Application Insights Resource 651  
           Configure a Windows App 652  
           Using Collectors 653  
           Writing Custom Events 654  
        Summary 655  
     Chapter 21: Tasks and Parallel Programming 657  
        Overview 657  
        Parallel Class 658  
           Looping with the Parallel.For Method 658  
           Stopping Parallel.For Early 661  
           Parallel For Initialization 662  
           Looping with the Parallel.ForEach Method 663  
           Invoking Multiple Methods with the Parallel.Invoke Method 663  
        Tasks 664  
           Starting Tasks 664  
              Tasks Using the Thread Pool 665  
              Synchronous Tasks 666  
              Tasks Using a Separate Thread 666  
           Futures—Results from Tasks 667  
           Continuation Tasks 667  
           Task Hierarchies 668  
           Returning Tasks from Methods 669  
           Waiting for Tasks 669  
        Cancellation Framework 670  
           Cancellation of Parallel.For 670  
           Cancellation of Tasks 671  
        Data Flow 673  
           Using an Action Block 673  
           Source and Target Blocks 673  
           Connecting Blocks 675  
        Summary 677  
     Chapter 22: Task Synchronization 679  
        Overview 680  
        Threading Issues 680  
           Race Conditions 681  
           Deadlocks 683  
        The lock Statement and Thread Safety 685  
        Interlocked 690  
        Monitor 690  
        SpinLock 691  
        WaitHandle 692  
        Mutex 693  
        Semaphore 694  
        Events 695  
        Barrier 698  
        ReaderWriterLockSlim 701  
        Timers 703  
        Summary 705  
     Chapter 23: Files and Streams 707  
        Introduction 708  
        Managing the File System 708  
           Checking Drive Information 709  
           Working with the Path Class 710  
           Creating Files and Folders 711  
           Accessing and Modifying File Properties 712  
           Creating a Simple Editor 713  
           Using File to Read and Write 715  
        Enumerating Files 716  
        Working with Streams 717  
           Working with File Streams 719  
              Creating a FileStream 719  
              Getting Stream Information 720  
              Analyzing Text File Encodings 721  
           Reading Streams 722  
           Writing Streams 722  
           Copying Streams 723  
           Using Random Access to Streams 724  
           Using Buffered Streams 725  
        Using Readers and Writers 726  
           The StreamReader Class 726  
           The StreamWriter Class 727  
           Reading and Writing Binary Files 728  
        Compressing Files 729  
           Using the Deflate Stream 730  
           Zipping Files 730  
        Watching File Changes 731  
        Working with Memory Mapped Files 732  
           Using Accessors to Create Memory Mapped Files 733  
           Using Streams to Create Memory Mapped Files 735  
        Communicating with Pipes 737  
           Creating a Named Pipe Server 737  
           Creating a Named Pipe Client 739  
           Creating Anonymous Pipes 739  
        Using Files and Streams with the Windows Runtime 741  
           Windows App Editor 741  
           Mapping Windows Runtime Types to .NET Types 743  
        Summary 745  
     Chapter 24: Security 747  
        Introduction 747  
        Verifying User Information 748  
           Working with Windows Identities 748  
           Windows Principals 749  
           Using Claims 750  
        Encrypting Data 751  
           Creating and Verifying a Signature 754  
           Implementing Secure Data Exchange 755  
           Signing and Hashing Using RSA 759  
           Implementing Data Protection 761  
        Access Control to Resources 764  
        Distributing Code Using Certificates 766  
        Summary 767  
     Chapter 25: Networking 769  
        Networking 769  
        The HttpClient Class 770  
           Making an Asynchronous Get Request 770  
           Throwing Exceptions 771  
           Passing Headers 772  
           Accessing the Content 773  
           Customizing Requests with HttpMessageHandler 774  
           Creating an HttpRequestMessage Using SendAsync 775  
           Using HttpClient with Windows Runtime 776  
        Working with the WebListener Class 778  
        Working with Utility Classes 782  
           URIs 782  
           IPAddress 783  
           IPHostEntry 785  
           Dns 785  
        Using TCP 786  
           Creating an HTTP Client Using TCP 787  
           Creating a TCP Listener 789  
           Creating a TCP Client 796  
           TCP vs. UDP 800  
        Using UDP 800  
           Building a UDP Receiver 801  
           Creating a UDP Sender 802  
           Using Multicasts 805  
        Using Sockets 805  
           Creating a Listener Using Sockets 806  
           Using NetworkStream with Sockets 808  
           Using Readers and Writers with Sockets 809  
           Implementing a Receiver Using Sockets 810  
        Summary 812  
     Chapter 26: Composition 815  
        Introduction 815  
        Architecture of the Composition Library 817  
           Composition Using Attributes 818  
           Convention-Based Part Registration 824  
        Defining Contracts 826  
        Exporting Parts 830  
           Creating Parts 830  
           Parts Using Parts 835  
           Exporting Metadata 835  
           Using Metadata for Lazy Loading 837  
        Importing Parts 838  
           Importing Collections 841  
           Lazy Loading of Parts 842  
           Reading Metadata 842  
        Summary 845  
     Chapter 27: XML and JSON 847  
        Data Formats 847  
           XML 848  
           XML Standards Support in .NET 849  
           Working with XML in the Framework 850  
           JSON 850  
        Reading and Writing Streamed XML 852  
           Reading XML with XmlReader 853  
              Using Read Methods 854  
              Retrieving Attribute Data 855  
           Using the XmlWriter Class 856  
        Using the DOM in .NET 857  
           Reading with the XmlDocument Class 858  
           Navigating Through the Hierarchy 858  
           Inserting Nodes with XmlDocument 859  
        Using XPathNavigator 860  
           XPathDocument 861  
           XPathNavigator 861  
           XPathNodeIterator 862  
           Navigating Through XML Using XPath 862  
           Using XPath Evaluations 863  
           Changing XML Using XPath 863  
        Serializing Objects in XML 865  
           Serializing a Simple Object 865  
           Serializing a Tree of Objects 867  
           Serializing Without Attributes 869  
        LINQ to XML 872  
           XDocument 873  
           XElement 873  
           XNamespace 874  
           XComment 876  
           XAttribute 877  
           Querying XML Documents with LINQ 877  
           Querying Dynamic XML Documents 878  
           Transforming to Objects 879  
           Transforming to XML 880  
        JSON 881  
           Creating JSON 881  
           Converting Objects 882  
           Serializing Objects 884  
        Summary 884  
     Chapter 28: Localization 885  
        Global Markets 886  
        Namespace System.Globalization 886  
           Unicode Issues 886  
           Cultures and Regions 887  
              Specific, Neutral, and Invariant Cultures 887  
              CurrentCulture and CurrentUICulture 888  
              Number Formatting 889  
              Date Formatting 891  
           Cultures in Action 891  
           Sorting 897  
        Resources 898  
           Resource Readers and Writers 898  
           Using the Resource File Generator 899  
           Using Resource Files with ResourceManager 900  
           The System.Resources Namespace 901  
        Localization with WPF 901  
        Localization with ASP.NET Core 903  
           Registering Localization Services 903  
           Injecting Localization Services 904  
           Culture Providers 905  
           Using Resources from ASP.NET Core 906  
        Localization with the Universal Windows Platform 907  
           Using Resources with UWP 907  
           Localization with the Multilingual App Toolkit 908  
        Creating Custom Cultures 911  
        Summary 912  
  Part III: Windows Apps 913  
     Chapter 29: Core XAML 915  
        Uses of XAML 915  
        XAML Foundation 916  
           Mapping Elements to Classes with WPF 917  
           Mapping Elements to Classes with Universal Windows Apps 918  
           Using Custom .NET Classes 919  
           Setting Properties as Attributes 920  
           Using Properties as Elements 921  
           Using Collections with XAML 921  
        Dependency Properties 922  
           Creating a Dependency Property 923  
           Value Changed Callbacks and Events 924  
           Coerce Value Callback with WPF 924  
        Routed Events 925  
           Routed Events with Windows apps 926  
           Bubbling and Tunneling with WPF 927  
           Implementing Custom Routed Events with WPF 929  
        Attached Properties 930  
        Markup Extensions 933  
           Creating Custom Markup Extensions 933  
           Using XAML-Defined Markup Extensions 935  
        Summary 935  
     Chapter 30: Styling XAML Apps 937  
        Styling 937  
        Shapes 938  
        Geometry 941  
           Geometries Using Segments 941  
           Geometries Using PML 942  
           Combined Geometries (WPF) 943  
        Transformation 944  
           Scaling 944  
           Translating 945  
           Rotating 945  
           Skewing 945  
           Transforming with Groups and Composite Transforms 945  
           Transforming Using a Matrix 946  
           Transforming Layouts 946  
        Brushes 947  
           SolidColorBrush 947  
           LinearGradientBrush 948  
           ImageBrush 948  
           WebViewBrush 948  
           WPF-Only Brushes 949  
              RadialGradientBrush 949  
              DrawingBrush 950  
              VisualBrush 950  
        Styles and Resources 952  
           Styles 952  
           Resources 954  
           Accessing Resources from Code 955  
           Dynamic Resources (WPF) 956  
           Resource Dictionaries 957  
           Theme Resources (UWP) 958  
              Defining Theme Resources 958  
              Selecting a Theme 959  
        Templates 960  
           Control Templates 960  
           Data Templates 966  
           Styling a ListView 967  
           DataTemplate for ListView Items 968  
           Item Container Style 969  
           Items Panel 971  
           List View Control Template 971  
        Animations 973  
           Timeline 973  
           Easing Functions 975  
           Keyframe Animations 982  
           Transitions (UWP Apps) 983  
              Reposition Transition 983  
              Pane Transition 983  
              Transitions for Items 984  
        Visual State Manager 985  
           Predefined States with Control Templates 986  
           Defining Custom States 987  
           Setting Custom States 988  
        Summary 988  
     Chapter 31: Patterns with XAML Apps 989  
        Why MVVM? 989  
        Defining the MVVM Pattern 990  
        Sharing Code 992  
           Using API Contracts with the Universal Windows Platform 992  
           Working with Shared Projects 994  
           Working with Portable Libraries 995  
        Sample Solution 996  
        Models 997  
           Implementing Change Notification 998  
           Using the Repository Pattern 998  
        View Models 1000  
           Commands 1002  
           Services and Dependency Injection 1003  
        Views 1006  
           Injecting the View Models 1007  
           Data Binding with WPF 1007  
           Compiled Data Binding with UWP 1009  
        Messaging Using Events 1011  
        IoC Container 1013  
        Using a Framework 1015  
        Summary 1015  
     Chapter 32: Windows Apps: User Interfaces 1017  
        Overview 1017  
        Navigation 1018  
           Navigating to the Initial Page 1018  
           Overriding Page Class Navigation 1019  
           Navigating Between Pages 1020  
           Back Button 1021  
           Hub 1023  
           Pivot 1025  
           Application Shells 1026  
           Hamburger Button 1029  
           Split View 1031  
           Adding Content to the SplitView Pane 1032  
        Layout 1034  
           VariableSizedWrapGrid 1035  
           RelativePanel 1037  
           Adaptive Triggers 1038  
           XAML Views 1041  
           Deferred Loading 1041  
        Commands 1042  
        Compiled Data Binding 1045  
           Compiled Binding Lifecycle 1045  
           Using Resources for Compiled Data Templates 1047  
        Controls 1048  
           TextBox Control 1048  
           AutoSuggest 1049  
           Inking 1051  
           Pickers for Reading and Writing Strokes 1053  
        Summary 1055  
     Chapter 33: Advanced Windows Apps 1057  
        Overview 1057  
        App Lifetime 1058  
        Application Execution States 1058  
           Navigation Between Pages 1059  
        Navigation State 1061  
           Suspending the App 1061  
           Activating the App from Suspension 1062  
           Testing Suspension 1063  
           Page State 1064  
        Sharing Data 1067  
           Sharing Source 1067  
           Sharing Target 1070  
        App Services 1076  
           Creating the Model 1077  
           Creating a Background Task for App Service Connections 1078  
           Registering the App Service 1079  
           Calling the App Service 1080  
        Camera 1082  
        Geolocation and MapControl 1083  
           Using the MapControl 1083  
           Location Information with Geolocator 1088  
           Street-Side Experience 1090  
           Continuously Requesting Location Information 1091  
        Sensors 1091  
           Light 1092  
           Compass 1094  
           Accelerometer 1095  
           Inclinometer 1096  
           Gyrometer 1096  
           Orientation 1097  
           Rolling Marble Sample 1098  
        Summary 1100  
     Chapter 34: Windows Desktop Applications with WPF 1101  
        Introduction 1102  
        Controls 1102  
           Simple Controls 1102  
           Content Controls 1103  
           Headered Content Controls 1104  
           Items Controls 1106  
           Headered Items Controls 1106  
           Decoration 1106  
        Layout 1107  
           StackPanel 1107  
           WrapPanel 1108  
           Canvas 1108  
           DockPanel 1109  
           Grid 1110  
        Triggers 1111  
           Property Triggers 1111  
           MultiTrigger 1112  
           Data Triggers 1113  
        Menu and Ribbon Controls 1114  
           Menu Controls 1115  
           Ribbon Controls 1116  
        Commanding 1118  
           Defining Commands 1119  
           Defining Command Sources 1119  
           Command Bindings 1120  
        Data Binding 1120  
           BooksDemo Application Content 1121  
           Binding with XAML 1122  
           Simple Object Binding 1125  
           Change Notification 1127  
           Object Data Provider 1129  
           List Binding 1131  
           Master Details Binding 1134  
           MultiBinding 1134  
           Priority Binding 1136  
           Value Conversion 1137  
           Adding List Items Dynamically 1139  
           Adding Tab Items Dynamically 1139  
           Data Template Selector 1140  
           Binding to XML 1142  
           Binding Validation and Error Handling 1144  
              Handling Exceptions 1144  
              Data Error Information 1147  
              Notify Data Error Info 1147  
              Custom Validation Rules 1150  
        TreeView 1152  
        DataGrid 1156  
           Custom Columns 1158  
           Row Details 1158  
           Grouping with the DataGrid 1158  
           Live Shaping 1161  
        Summary 1166  
     Chapter 35: Creating Documents with WPF 1167  
        Introduction 1167  
        Text Elements 1168  
           Fonts 1168  
           TextEffect 1169  
           Inline 1171  
           Block 1172  
           Lists 1174  
           Tables 1174  
           Anchor to Blocks 1176  
        Flow Documents 1178  
        Fixed Documents 1182  
        XPS Documents 1185  
        Printing 1187  
           Printing with the PrintDialog 1187  
           Printing Visuals 1188  
        Summary 1189  
     Chapter 36: Deploying Windows Apps 1191  
        Deployment as Part of the Application Life Cycle 1191  
        Planning for Deployment 1192  
           Overview of Deployment Options 1192  
           Deployment Requirements 1192  
           Deploying the .NET Runtime 1193  
        Traditional Deployment 1193  
           xcopy Deployment 1194  
           Windows Installer 1194  
        ClickOnce 1195  
           ClickOnce Operation 1195  
           Publishing a ClickOnce Application 1195  
           ClickOnce Settings 1197  
           Application Cache for ClickOnce Files 1199  
           Application Installation 1200  
           ClickOnce Deployment API 1201  
        UWP Apps 1201  
           Creating an App Package 1202  
           Windows App Certification Kit 1203  
           Sideloading 1204  
        Summary 1205  
  Part IV: Web Applications and Services 1207  
     Chapter 37: ADO.NET 1209  
        ADO.NET Overview 1209  
           Sample Database 1210  
           NuGet Packages and Namespaces 1211  
        Using Database Connections 1211  
           Managing Connection Strings 1212  
           Connection Pools 1213  
           Connection Information 1213  
        Commands 1213  
           ExecuteNonQuery 1215  
           ExecuteScalar 1216  
           ExecuteReader 1217  
           Calling Stored Procedures 1218  
        Asynchronous Data Access 1219  
        Transactions 1220  
        Summary 1224  
     Chapter 38: Entity Framework Core 1225  
        History of Entity Framework 1225  
        Introducing Entity Framework 1227  
           Creating a Model 1227  
           Creating a Context 1229  
           Writing to the Database 1229  
           Reading from the Database 1230  
           Updating Records 1231  
           Deleting Records 1231  
        Using Dependency Injection 1232  
        Creating a Model 1234  
           Creating a Relation 1235  
           Migrations with .NET CLI 1235  
           Migrations with MSBuild 1237  
           Creating the Database 1238  
           Data Annotations 1239  
           Fluent API 1239  
           Scaffolding a Model from the Database 1241  
        Working with Object State 1241  
           Adding Objects with Relations 1241  
           Object Tracking 1243  
           Updating Objects 1244  
           Updating Untracked Objects 1245  
        Conflict Handling 1246  
           The Last One Wins 1246  
           The First One Wins 1247  
        Using Transactions 1250  
           Using Implicit Transactions 1251  
           Creating Explicit Transactions 1253  
        Summary 1254  
     Chapter 39: Windows Services 1255  
        What Is a Windows Service? 1255  
        Windows Services Architecture 1257  
           Service Program 1257  
              Service Control Manager 1257  
              Main Function, Service-Main, and Handlers 1258  
           Service Control Program 1258  
           Service Configuration Program 1258  
           Classes for Windows Services 1259  
        Creating a Windows Service Program 1259  
           Creating Core Functionality for the Service 1259  
           QuoteClient Example 1262  
           Windows Service Program 1265  
              The ServiceBase Class 1266  
              Main Function 1267  
              Service Start 1267  
              Handler Methods 1268  
           Threading and Services 1269  
           Service Installation 1269  
           Installation Program 1269  
              The Installer Class 1269  
              Process Installer and Service Installer 1271  
              The ServiceInstallerDialog Class 1273  
              installutil 1273  
        Monitoring and Controlling Windows Services 1273  
           MMC Snap-in 1274  
           net.exe Utility 1275  
           sc.exe Utility 1275  
           Visual Studio Server Explorer 1275  
           Writing a Custom Service Controller 1276  
              Monitoring the Service 1276  
              Controlling the Service 1281  
        Troubleshooting and Event Logging 1283  
        Summary 1284  
     Chapter 40: ASP.NET Core 1285  
        ASP.NET Core 1.0 1285  
        Web Technologies 1286  
           HTML 1286  
           CSS 1287  
           JavaScript and TypeScript 1287  
           Scripting Libraries 1287  
        ASP.NET Web Project 1288  
        Startup 1292  
        Adding Static Content 1295  
           Using a JavaScript Package Manager: npm 1296  
           Building with Gulp 1297  
           Using Client-Side Libraries with Bower 1299  
        Request and Response 1301  
           Request Headers 1302  
           Query String 1305  
           Encoding 1305  
           Form Data 1306  
           Cookies 1307  
           Sending JSON 1308  
        Dependency Injection 1309  
           Defining a Service 1309  
           Registering the Service 1309  
           Injecting the Service 1310  
           Calling the Controller 1310  
        Routing Using Map 1311  
        Using Middleware 1312  
        Session State 1314  
        Configuring ASP.NET 1315  
           Reading the Configuration 1316  
           Different Configurations Based on the Environment 1317  
           User Secrets 1318  
        Summary 1319  
     Chapter 41: ASP.NET MVC 1321  
        Setting Up Services for ASP.NET MVC 6 1321  
        Defining Routes 1323  
           Adding Routes 1324  
           Using Route Constraints 1324  
        Creating Controllers 1325  
           Understanding Action Methods 1325  
           Using Parameters 1325  
           Returning Data 1326  
           Working with the Controller Base Class and POCO Controllers 1328  
        Creating Views 1329  
           Passing Data to Views 1330  
           Understanding Razor Syntax 1330  
           Creating Strongly Typed Views 1331  
           Defining the Layout 1333  
              Using a Default Layout Page 1333  
              Using Sections 1335  
           Defining Content with Partial Views 1336  
              Using Partial Views from Server-Side Code 1337  
              Returning Partial Views from the Controller 1339  
           Working with View Components 1339  
           Using Dependency Injection in Views 1341  
           Importing Namespaces with Multiple Views 1341  
        Submitting Data from the Client 1341  
           Model Binder 1343  
           Annotations and Validation 1344  
        Working with HTML Helpers 1345  
           Using Simple Helpers 1345  
           Using Model Data 1346  
           Defining HTML Attributes 1347  
           Creating Lists 1347  
           Using Strongly Typed Helpers 1348  
           Working with Editor Extensions 1348  
           Implementing Templates 1349  
        Getting to Know Tag Helpers 1350  
           Activating Tag Helpers 1350  
           Using Anchor Tag Helpers 1351  
           Using Label Tag Helpers 1351  
           Using Input Tag Helpers 1352  
           Using a Form with Validation 1353  
           Creating Custom Tag Helpers 1355  
        Implementing Action Filters 1357  
        Creating a Data-Driven Application 1359  
           Defining a Model 1359  
           Creating a Database 1360  
           Creating a Service 1362  
           Creating a Controller 1364  
           Creating Views 1367  
        Implementing Authentication and Authorization 1369  
           Storing and Retrieving User Information 1370  
           Starting Up the Identity System 1370  
           Performing User Registration 1371  
           Setting Up User Login 1373  
           Authenticating Users 1374  
        Summary 1375  
     Chapter 42: ASP.NET Web API 1377  
        Overview 1377  
        Creating Services 1378  
           Defining a Model 1379  
           Creating a Repository 1379  
           Creating a Controller 1381  
           Changing the Response Format 1383  
           REST Results and Status Codes 1384  
        Creating an Async Service 1384  
        Creating a .NET Client 1387  
           Sending GET Requests 1387  
           Receiving XML from the Service 1391  
           Sending POST Requests 1392  
           Sending PUT Requests 1393  
           Sending DELETE Requests 1394  
        Writing to the Database 1394  
           Defining the Database 1395  
           Creating the Repository 1396  
        Creating Metadata 1397  
        Creating and Using OData Services 1399  
           Creating a Data Model 1400  
           Creating a Service 1401  
           OData Query 1401  
        Summary 1402  
     Chapter 43: WebHooks and SignalR 1403  
        Overview 1403  
        Architecture of SignalR 1404  
        A Simple Chat Using SignalR 1405  
           Creating a Hub 1405  
           Creating a Client with HTML and JavaScript 1406  
           Creating SignalR .NET Clients 1408  
        Grouping Connections 1411  
           Extending the Hub with Groups 1411  
           Extending the WPF Client with Groups 1412  
        Architecture of WebHooks 1415  
        Creating Dropbox and GitHub Receivers 1416  
           Creating a Web Application 1416  
           Configuring WebHooks for Dropbox and GitHub 1417  
           Implementing the Handler 1417  
           Configuring the Application with Dropbox and GitHub 1419  
           Running the Application 1421  
        Summary 1422  
     Chapter 44: Windows Communication Foundation 1423  
        WCF Overview 1423  
           SOAP 1425  
           WSDL 1425  
        Creating a Simple Service and Client 1426  
           Defining Service and Data Contracts 1426  
           Data Access 1428  
           Service Implementation 1430  
           WCF Service Host and WCF Test Client 1431  
           Custom Service Host 1432  
           WCF Client 1435  
           Diagnostics 1436  
           Sharing Contract Assemblies with the Client 1438  
        Contracts 1439  
           Data Contract 1440  
           Versioning 1440  
           Service and Operation Contracts 1441  
           Message Contract 1442  
           Fault Contract 1442  
        Service Behaviors 1444  
        Binding 1447  
           Standard Bindings 1448  
           Features of Standard Bindings 1449  
           Web Sockets 1450  
        Hosting 1453  
           Custom Hosting 1453  
           WAS Hosting 1454  
           Preconfigured Host Classes 1454  
        Clients 1455  
           Using Metadata 1456  
           Sharing Types 1456  
        Duplex Communication 1457  
           Contract for Duplex Communication 1457  
           Service for Duplex Communication 1458  
           Client Application for Duplex Communication 1459  
        Routing 1460  
           Sample Routing Application 1461  
           Routing Interfaces 1461  
           WCF Routing Service 1461  
           Using a Router for Failover 1462  
           Bridging for Protocol Changes 1464  
           Filter Types 1464  
        Summary 1465  
     Chapter 45: Deploying Websites and Services 1467  
        Deploying Web Applications 1467  
        Preparing for Deployment 1468  
           Creating an ASP.NET 4.6 Web Application 1468  
           Creating an ASP.NET Core 1.0 Web Application 1469  
           Configuration Files with ASP.NET 4.6 1471  
           Configuration Files with ASP.NET Core 1.0 1471  
        Deploying to Internet Information Server 1473  
           Preparing a Web Application Using IIS Manager 1473  
              Creating an Application Pool 1474  
              Creating a Website 1475  
              Creating an Application 1476  
           Web Deploying to IIS 1477  
        Deploying to Microsoft Azure 1480  
           Creating a SQL Database 1480  
           Testing the Local Website with SQL Azure 1480  
           Deploying to a Microsoft Azure Web App 1481  
        Deploying to Docker 1481  
        Summary 1482  
  Index 1483  
  EULA 1532  


nach oben


  Mehr zum Inhalt
Kapitelübersicht
Kurzinformation
Inhaltsverzeichnis
Leseprobe
Blick ins Buch
Fragen zu eBooks?

  Navigation
Belletristik / Romane
Computer
Geschichte
Kultur
Medizin / Gesundheit
Philosophie / Religion
Politik
Psychologie / Pädagogik
Ratgeber
Recht
Reise / Hobbys
Technik / Wissen
Wirtschaft

© 2008-2024 ciando GmbH | Impressum | Kontakt | F.A.Q. | Datenschutz