You are previewing Professional C# 6 and .NET Core 1.0.
O'Reilly logo
Professional C# 6 and .NET Core 1.0

Book Description

A true professional's guide to C# 6

Professional C# 6 and .NET Core 1.0 provides complete coverage of the latest updates, features, and capabilities, giving you everything you need for C#. Get expert instruction on the latest changes to Visual Studio 2015, Windows Runtime, ADO.NET, ASP.NET, Windows Store Apps, Windows Workflow Foundation, and more, with clear explanations, no-nonsense pacing, and valuable expert insight. This incredibly useful guide serves as both tutorial and desk reference, providing a professional-level review of C# architecture and its application in a number of areas. You'll gain a solid background in managed code and .NET constructs within the context of the 2015 release, so you can get acclimated quickly and get back to work.

The new updates can actively streamline your workflow, with major changes including reimagined C# refactoring support, a new .NET Web app stack, and the .NET compiler platform that makes C# and Visual Basic compilers available as APIs. This book walks you through the changes with a comprehensive C# review.

  • Explore the new Visual Studio templates for ASP.NET Core 1.0, Web Forms, and MVC
  • Learn about the networking switch to HttpClient and ASP.NET Web API's replacement of WCF Data Services
  • Work with the latest updates to the event log, Windows Runtime 2.0, and Windows 8.1 deployment and localization
  • Dig deep into the new .NET 5.0 GC behaviors and the Migrations addition to ADO.NET

Microsoft has stepped up both the cadence and magnitude of their software releases. Professional C# 6 and .NET Core 1.0 shows you everything you need to know about working with C# in a real-world context.

Table of Contents

  1. Introduction
    1. The Significance of .NET Core
    2. The Significance of C#
    3. What’s New in C# 6
    4. What’s New with the Universal Windows Platform
    5. What You Need to Write and Run C# Code
    6. What This Book Covers
    7. Conventions
    8. Source Code
    9. Errata
    10. p2p.wrox.com
  2. Part I: The C# Language
    1. Chapter 1: .NET Application Architectures
      1. Choosing Your Technologies
      2. Reviewing .NET History
      3. .NET 2015
      4. Hello, World
      5. Compiling with .NET 4.6
      6. Compiling with .NET Core CLI
      7. Application Types and Technologies
      8. Developer Tools
      9. Summary
    2. Chapter 2: Core C#
      1. Fundamentals of C#
      2. Creating Hello, World! with Visual Studio
      3. Working with Variables
      4. Using Predefined Data Types
      5. Controlling Program Flow
      6. Working with Enumerations
      7. Getting Organized with Namespaces
      8. Understanding the Main Method
      9. Using Comments
      10. Understanding C# Preprocessor Directives
      11. C# Programming Guidelines
      12. Summary
    3. Chapter 3: Objects and Types
      1. Creating and Using Classes
      2. Classes and Structs
      3. Classes
      4. Anonymous Types
      5. Structs
      6. Passing Parameters by Value and by Reference
      7. Nullable Types
      8. Enumerations
      9. Partial Classes
      10. Extension Methods
      11. The Object Class
      12. Summary
    4. Chapter 4: Inheritance
      1. Inheritance
      2. Types of Inheritance
      3. Implementation Inheritance
      4. Modifiers
      5. Interfaces
      6. is and as Operators
      7. Summary
    5. Chapter 5: Managed and Unmanaged Resources
      1. Resources
      2. Memory Management Under the Hood
      3. Strong and Weak References
      4. Working with Unmanaged Resources
      5. Unsafe Code
      6. Platform Invoke
      7. Summary
    6. Chapter 6: Generics
      1. Generics Overview
      2. Creating Generic Classes
      3. Generics Features
      4. Generic Interfaces
      5. Generic Structs
      6. Generic Methods
      7. Summary
    7. Chapter 7: Arrays and Tuples
      1. Multiple Objects of the Same and Different Types
      2. Simple Arrays
      3. Multidimensional Arrays
      4. Jagged Arrays
      5. Array Class
      6. Arrays as Parameters
      7. Enumerators
      8. Tuples
      9. Structural Comparison
      10. Summary
    8. Chapter 8: Operators and Casts
      1. Operators and Casts
      2. Operators
      3. Type Safety
      4. Comparing Objects for Equality
      5. Operator Overloading
      6. Implementing Custom Index Operators
      7. User-Defined Casts
      8. Summary
    9. Chapter 9: Delegates, Lambdas, and Events
      1. Referencing Methods
      2. Delegates
      3. Lambda Expressions
      4. Events
      5. Summary
    10. Chapter 10: Strings and Regular Expressions
      1. Examining System.String
      2. String Formats
      3. Regular Expressions
      4. Summary
    11. Chapter 11: Collections
      1. Overview
      2. Collection Interfaces and Types
      3. Lists
      4. Queues
      5. Stacks
      6. Linked Lists
      7. Sorted List
      8. Dictionaries
      9. Sets
      10. Performance
      11. Summary
    12. Chapter 12: Special Collections
      1. Overview
      2. Working with Bits
      3. Observable Collections
      4. Immutable Collections
      5. Concurrent Collections
      6. Summary
    13. Chapter 13: Language Integrated Query
      1. LINQ Overview
      2. Standard Query Operators
      3. Parallel LINQ
      4. Expression Trees
      5. LINQ Providers
      6. Summary
    14. Chapter 14: Errors and Exceptions
      1. Introduction
      2. Exception Classes
      3. Catching Exceptions
      4. User-Defined Exception Classes
      5. Caller Information
      6. Summary
    15. Chapter 15: Asynchronous Programming
      1. Why Asynchronous Programming Is Important
      2. Asynchronous Patterns
      3. Foundation of Asynchronous Programming
      4. Error Handling
      5. Cancellation
      6. Summary
    16. Chapter 16: Reflection, Metadata, and Dynamic Programming
      1. Inspecting Code at RunTime and Dynamic Programming
      2. Custom Attributes
      3. Using Reflection
      4. Using Dynamic Language Extensions for Reflection
      5. The Dynamic Type
      6. Dynamic Language Runtime
      7. Hosting the DLR ScriptRuntime
      8. DynamicObject and ExpandoObject
      9. Summary
  3. Part II: .NET Core and Windows Runtime
    1. Chapter 17: Visual Studio 2015
      1. Working with Visual Studio 2015
      2. Creating a Project
      3. Exploring and Coding a Project
      4. Building a Project
      5. Debugging Your Code
      6. Refactoring Tools
      7. Architecture Tools
      8. Analyzing Applications
      9. Summary
    2. Chapter 18: .NET Compiler Platform
      1. Introduction
      2. Compiler Pipeline
      3. Syntax Analysis
      4. Semantics Analysis
      5. Code Transformation
      6. Visual Studio Code Refactoring
      7. Summary
    3. Chapter 19: Testing
      1. Overview
      2. Unit Testing with MSTest
      3. Unit Testing with xUnit
      4. UI Testing
      5. Web Testing
      6. Summary
    4. Chapter 20: Diagnostics and Application Insights
      1. Diagnostics Overview
      2. Tracing with EventSource
      3. Creating Custom Listeners
      4. Working with Application Insights
      5. Summary
    5. Chapter 21: Tasks and Parallel Programming
      1. Overview
      2. Parallel Class
      3. Tasks
      4. Cancellation Framework
      5. Data Flow
      6. Summary
    6. Chapter 22: Task Synchronization
      1. Overview
      2. Threading Issues
      3. The lock Statement and Thread Safety
      4. Interlocked
      5. Monitor
      6. SpinLock
      7. WaitHandle
      8. Mutex
      9. Semaphore
      10. Events
      11. Barrier
      12. ReaderWriterLockSlim
      13. Timers
      14. Summary
    7. Chapter 23: Files and Streams
      1. Introduction
      2. Managing the File System
      3. Enumerating Files
      4. Working with Streams
      5. Using Readers and Writers
      6. Compressing Files
      7. Watching File Changes
      8. Working with Memory Mapped Files
      9. Communicating with Pipes
      10. Using Files and Streams with the Windows Runtime
      11. Summary
    8. Chapter 24: Security
      1. Introduction
      2. Verifying User Information
      3. Encrypting Data
      4. Access Control to Resources
      5. Distributing Code Using Certificates
      6. Summary
    9. Chapter 25: Networking
      1. Networking
      2. The HttpClient Class
      3. Working with the WebListener Class
      4. Working with Utility Classes
      5. Using TCP
      6. Using UDP
      7. Using Sockets
      8. Summary
    10. Chapter 26: Composition
      1. Introduction
      2. Architecture of the Composition Library
      3. Defining Contracts
      4. Exporting Parts
      5. Importing Parts
      6. Summary
    11. Chapter 27: XML and JSON
      1. Data Formats
      2. Reading and Writing Streamed XML
      3. Using the DOM in .NET
      4. Using XPathNavigator
      5. Serializing Objects in XML
      6. LINQ to XML
      7. JSON
      8. Summary
    12. Chapter 28: Localization
      1. Global Markets
      2. Namespace System.Globalization
      3. Resources
      4. Localization with WPF
      5. Localization with ASP.NET Core
      6. Localization with the Universal Windows Platform
      7. Creating Custom Cultures
      8. Summary
  4. Part III: Windows Apps
    1. Chapter 29: Core XAML
      1. Uses of XAML
      2. XAML Foundation
      3. Dependency Properties
      4. Routed Events
      5. Attached Properties
      6. Markup Extensions
      7. Summary
    2. Chapter 30: Styling XAML Apps
      1. Styling
      2. Shapes
      3. Geometry
      4. Transformation
      5. Brushes
      6. Styles and Resources
      7. Templates
      8. Animations
      9. Visual State Manager
      10. Summary
    3. Chapter 31: Patterns with XAML Apps
      1. Why MVVM?
      2. Defining the MVVM Pattern
      3. Sharing Code
      4. Sample Solution
      5. Models
      6. View Models
      7. Views
      8. Messaging Using Events
      9. IoC Container
      10. Using a Framework
      11. Summary
    4. Chapter 32: Windows Apps: User Interfaces
      1. Overview
      2. Navigation
      3. Layout
      4. Commands
      5. Compiled Data Binding
      6. Controls
      7. Summary
    5. Chapter 33: Advanced Windows Apps
      1. Overview
      2. App Lifetime
      3. Application Execution States
      4. Navigation State
      5. Sharing Data
      6. App Services
      7. Camera
      8. Geolocation and MapControl
      9. Sensors
      10. Summary
    6. Chapter 34: Windows Desktop Applications with WPF
      1. Introduction
      2. Controls
      3. Layout
      4. Triggers
      5. Menu and Ribbon Controls
      6. Commanding
      7. Data Binding
      8. TreeView
      9. DataGrid
      10. Summary
    7. Chapter 35: Creating Documents with WPF
      1. Introduction
      2. Text Elements
      3. Flow Documents
      4. Fixed Documents
      5. XPS Documents
      6. Printing
      7. Summary
    8. Chapter 36: Deploying Windows Apps
      1. Deployment as Part of the Application Life Cycle
      2. Planning for Deployment
      3. Traditional Deployment
      4. ClickOnce
      5. UWP Apps
      6. Summary
  5. Part IV: Web Applications and Services
    1. Chapter 37: ADO.NET
      1. ADO.NET Overview
      2. Using Database Connections
      3. Commands
      4. Asynchronous Data Access
      5. Transactions
      6. Summary
    2. Chapter 38: Entity Framework Core
      1. History of Entity Framework
      2. Introducing Entity Framework
      3. Using Dependency Injection
      4. Creating a Model
      5. Working with Object State
      6. Conflict Handling
      7. Using Transactions
      8. Summary
    3. Chapter 39: Windows Services
      1. What Is a Windows Service?
      2. Windows Services Architecture
      3. Creating a Windows Service Program
      4. Monitoring and Controlling Windows Services
      5. Troubleshooting and Event Logging
      6. Summary
    4. Chapter 40: ASP.NET Core
      1. ASP.NET Core 1.0
      2. Web Technologies
      3. ASP.NET Web Project
      4. Startup
      5. Adding Static Content
      6. Request and Response
      7. Dependency Injection
      8. Routing Using Map
      9. Using Middleware
      10. Session State
      11. Configuring ASP.NET
      12. Summary
    5. Chapter 41: ASP.NET MVC
      1. Setting Up Services for ASP.NET MVC 6
      2. Defining Routes
      3. Creating Controllers
      4. Creating Views
      5. Submitting Data from the Client
      6. Working with HTML Helpers
      7. Getting to Know Tag Helpers
      8. Implementing Action Filters
      9. Creating a Data-Driven Application
      10. Implementing Authentication and Authorization
      11. Summary
    6. Chapter 42: ASP.NET Web API
      1. Overview
      2. Creating Services
      3. Creating an Async Service
      4. Creating a .NET Client
      5. Writing to the Database
      6. Creating Metadata
      7. Creating and Using OData Services
      8. Summary
    7. Chapter 43: WebHooks and SignalR
      1. Overview
      2. Architecture of SignalR
      3. A Simple Chat Using SignalR
      4. Grouping Connections
      5. Architecture of WebHooks
      6. Creating Dropbox and GitHub Receivers
      7. Summary
    8. Chapter 44: Windows Communication Foundation
      1. WCF Overview
      2. Creating a Simple Service and Client
      3. Contracts
      4. Service Behaviors
      5. Binding
      6. Hosting
      7. Clients
      8. Duplex Communication
      9. Routing
      10. Summary
    9. Chapter 45: Deploying Websites and Services
      1. Deploying Web Applications
      2. Preparing for Deployment
      3. Deploying to Internet Information Server
      4. Deploying to Microsoft Azure
      5. Deploying to Docker
      6. Summary
  6. Advert
  7. EULA