没有合适的资源?快使用搜索试试~ 我知道了~
Programming.Reactive.Extensions.and.LINQ

温馨提示
Pro Reactive Extensions and LINQ is a deep dive into the next important technology for .NET developers: Reactive Extensions. This in-depth tutorial goes beyond what is available anywhere else to teach how to write WPF, Silverlight, and Windows Phone applications using the Reactive Extensions (Rx) to handle events and asynchronous method calls.
资源详情
资源评论
资源推荐


For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Download from Wow! eBook <www.wowebook.com>

iv
Contents at a Glance
About the Authors ...................................................................................................... xi
About the Technical Reviewer .................................................................................. xii
Acknowledgments ................................................................................................... xiii
Foreword ................................................................................................................. xiv
Introduction ............................................................................................................. xvi
■Chapter 1: Introducing LINQ and Rx ........................................................................ 1
■Chapter 2: Core LINQ ............................................................................................. 19
■Chapter 3: Core Rx ................................................................................................. 41
■Chapter 4: Practical Rx .......................................................................................... 57
■Chapter 5: Inside Rx .............................................................................................. 77
■Chapter 6: LINQ to SQL ........................................................................................... 91
■Chapter 7: Reactive Extensions for JavaScript ................................................... 111
■Chapter 8: ReactiveUI .......................................................................................... 125
■Chapter 9: Testing With Rx .................................................................................. 145
Index ....................................................................................................................... 153

xvi
Introduction
Right now, we as programmers are at an impasse—a transition period between the well-understood
world of imperative programming, and a world that is increasingly at odds with this model. In the ’80s,
everything was simple: one machine, one thread, no network.
CPUs are now scaling horizontally, adding more and more cores, instead of scaling the CPU speeds.
Network and disk performance are now increasingly requiring asynchronous I/O in order to build high-
performance solutions.
Our tools to write asynchronous code, however, haven’t kept up with the rest of the world—threads,
locks, and events are the assembly language of asynchronous programming. They are straightforward to
understand, but as the complexity of the application becomes larger, it becomes extremely difficult to
determine if a given block of code will run correctly with respect to the rest of the application.
We need a way to retain the asynchronous nature of modern applications, while also retaining the
deterministic nature of traditional imperative programming.
A compelling solution to these problems is functional reactive programming. This term sounds
academic and overwhelming, however, if you’ve ever written a formula in Excel, good news—you’ve
already done functional reactive programming.
Let’s go through that title piece by piece, starting with the word “functional.” Many people have a
definition of functional programming, often from their college computer science course that covered
Scheme or Common Lisp, usually something along the lines of, “it means never using variables.”
Instead, think of FP as a mindset: “How is the output of my program related to my input, and how
can I describe that relation in code?” In this book, we’ll examine Language Integrated Queries (LINQ), a
powerful technology that allows us to describe a result list based on an input list and a set of
transformations on that input.
The disadvantage to LINQ is that this technology only works on lists, not data that is incoming or
changing. However, there is a type of list that is hiding in plain sight, only disguised—events. Consider
the KeyUp event: for every key that the user presses, an object representing the key will be generated—
“H”–“e”–“l”–“l”–“o”.
What if we thought of an event as a list? What if we could apply everything we know about lists to
events, like how to filter them or create new lists based on existing lists?
Reactive Extensions allow you to treat asynchronous sources of information, such as events, and
reason about them in the same way that you currently can reason about lists. This means, that once you
become proficient with using LINQ to write single-threaded programs, you can apply your knowledge
and write similar programs that are completely asynchronous.
A warning: this book is not easy to understand on first grasp. Rx will stretch your brain in ways it’s
not used to stretching, and you, like the authors, will almost certainly hit a learning curve.
The results, however, are most definitely worth it, as programs that would be incredibly difficult to write
correctly otherwise, are trivially easy to write and reason with Reactive Extensions.

C H A P T E R 1
1
Introducing LINQ and Rx
In a sentence, LINQ is a powerful way to interact with and extract data from collections, while Rx is an
extension of LINQ targeted at asynchronous collections; that is, collections that will be populated
asynchronously, typically from web services or elsewhere in the cloud.
LINQ was introduced to C# programmers with C# 3.0. On the other hand, Reactive Extensions (Rx)
is an emerging technology, born in Microsoft DevLabs and adopted as part of a standalone full product
from Microsoft in 2011.
We believe that the use of LINQ will expand greatly in the next few years, especially in conjunction
with Reactive Extensions. Rx extends many of the principles and features of LINQ to a wide set of
platforms (including JavaScript) and will be a vital part of Windows Phone programming, where
asynchronous events are the rule. As the data we deal with becomes more complex, LINQ will help bring
order and clarity to .NET programming. Similarly, as more and more data is retrieved asynchronously
from the cloud, and elsewhere, Rx will help you create simpler, cleaner, and more maintainable code.
In this chapter you will learn why LINQ and Rx are important and you’ll examine some of the
fundamental operators of both LINQ and Rx. This will provide a context for the coming chapters in
which we’ll dive deeper into both LINQ and Reactive Extensions.
■ Note Throughout this book we use Rx as shorthand for Reactive Extensions, just as we use LINQ for Language
Integrated Query.
What LINQ Is
LINQ (Language Integrated Query)—pronounced “link”—extends .NET to provide a way to query and
transform collections, relational data, and XML documents. It provides a SQL-like syntax within C# for
querying data, regardless of where that data originates.
LINQ also brings a much more declarative or functional approach to programming than previously
available in .NET.
剩余181页未读,继续阅读


















52bb
- 粉丝: 8
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 【Android应用源码】小说翻页效果源码.zip
- 【Android应用源码】小米便签源代码分享.zip
- 【Android应用源码】笑话故事jsoup库使用.zip
- 【Android应用源码】新版特性界面源代码.zip
- 【Android应用源码】写的google map api 应用.zip
- 【Android应用源码】新版网易源码 效果图.zip
- 【Android应用源码】新浪、腾讯、网易、搜狐微博OAuth认证整合版.zip
- 【Android应用源码】悬浮Activity并可拖动(访悬浮歌词).zip
- 【Android应用源码】悬浮窗 监视内容.zip
- 【Android应用源码】炫酷粒子.zip
- 【Android应用源码】旋转魔方.zip
- 【Android应用源码】选择城市列表,配本地数据库,可以直接应用到项目.zip
- 【Android应用源码】颜色选择器.zip
- 【Android应用源码】雪花飘落效果,代码很简单!.zip
- 【Android应用源码】讯飞语音测试源码.zip
- 【Android应用源码】夜间模式示例.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

评论1