1. Trang chủ
  2. » Công Nghệ Thông Tin

windows vista for developers delivery guide phần 10 docx

17 179 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 17
Dung lượng 1,35 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

When the user subscribes to a feed, the feed is added to the Common Feed List, which is a collection of Really Simple Syndication RSS feeds that is available for other applications to us

Trang 1

Windows RSS Platform Overview

As part of the RSS support in Microsoft Internet Explorer® 7, users can discover and

subscribe to RSS feeds within the browser When the user subscribes to a feed, the feed is

added to the Common Feed List, which is a collection of Really Simple Syndication

(RSS) feeds that is available for other applications to use in addition to or instead of their

own list

The Microsoft Windows RSS Platform is an application programming interface (API)

that enables applications to access and manipulate the Common Feed List

You can use the Windows RSS Platform in your applications to:

• Subscribe to new feeds and enumerate existing subscriptions

• Easily access properties of feeds (channels), feed items, and enclosures

• Manage and organize feeds into folders

• Listen for and respond to feed and feed folder events

• Check the status of the background Feed Download Engine or modify settings

• Normalize the Extensible Markup Language (XML) source of a feed

Trang 2

Windows RSS platform components include:

• The Common Feed List A shared hierarchical representation of all the feeds to which

the current user is subscribed

• The Feed Store The central location in Windows of your RSS feeds

• The Feed Download Engine The background process that merges new feed items

and enclosures into the Feed Store The Feed Download Engine automatically

downloads the feed items from the source URL specified in the feed These

downloads can occur on a schedule or as requested by the user The value of the

Interval property and TTL (time to live) element of the feed determine how often the

feed is downloaded

Trang 3

Managing Subscriptions by Using the Common Feed

List

The Common Feed List is a shared hierarchical representation of all the feeds to which

the current user is subscribed The Common Feed List resembles a hierarchical file

system with folders and feeds

You can use the Microsoft Windows RSS Platform APIs to manage the common feed list

To do this, you will use the following objects and interfaces:

• FeedsManager The top-level object in the Windows RSS Platform is the

FeedsManager object To create the object for scripting, reference the

Microsoft.FeedsManager library

• FeedFolder The IFeedFolder interface contains properties and methods for

accessing feeds contained within the folder in addition to properties and methods for

accessing subfolders The root folder of the Common Feed List is accessed through

the FeedsManager.RootFolder property, which returns an object of type

IFeedFolder

• Feed The IFeed interface exposes the required and optional elements of an RSS feed

To subscribe to a feed, you must assign it to a folder by calling

FeedFolder.CreateFeed(name,url)

Trang 4

• FeedItem Individual items in a feed are represented by FeedItem objects

Depending on the type of feed, these items are aggregated as news items that are merged into the feed or as list items that replace the contents of the previous list Additional RSS 2.0 item elements, such as GUID and source, are available in the XML source document of the feed

• FeedEnclosure The IFeedEnclosure interface provides access to the optional media

file attachment that may be associated with each feed item

The following table lists the methods and properties that are used to traverse and

manipulate the Common Feed List hierarchy

Object.Method Description

FeedsManager.RootFolder Returns top-level system feed folder

FeedFolder.Subfolders Returns collection of subfolders

FeedsManager.GetFolder(path) Returns specific folder by path

FeedFolder.GetSubfolder(name) Returns specific subfolder

FeedFolder.CreateSubfolder(name) Creates and returns new subfolder

FeedFolder.Delete Deletes folder, including its subfolders and feeds

FeedsManager.GetFeed(path) Returns specific feed by feed list path

FeedFolder.GetFeedByUrl(url) Returns specific feed, if subscribed, by URL

FeedFolder.GetFeed(name) Returns specific feed by name

FeedFolder.Feeds Returns collection of feeds

FeedFolder.CreateFeed(name,url) Creates feed in folder and subscribes to it

FeedsManager.DeleteFeed(path) Deletes the feed

Feed.Delete Deletes the feed

Trang 5

Implementing Feed and Folder Events

The Microsoft Windows RSS Platform includes a rich eventing subsystem that

developers can use to build applications that will listen for and respond to feed and folder

events To do this, the developer must configure the applications to register for events on

folders and on feeds

To register for these events, the application calls the GetWatcher method on the folder

or feed, specifying the scope and mask The interface returned by GetWatcher is an

IConnectionPointContainer, which the application uses to register its implementation

of the event sink interface

Defining the event scope

When registering for events on a folder, the application can specify a value from the

FEEDS_EVENTS_SCOPE enumeration that indicates which of the events will be fired

The following options are available:

• FES_SELF_ONLY Raise events for this folder and its feeds

• FES_SELF_AND_CHILDREN_ONLY Raise events for this folder and its feeds and

for its direct subfolders and their feeds

• FES_ALL Raise events for this folder and its feeds and all subfolders recursively

and their feeds

Trang 6

Defining the event mask

To limit which events are raised, applications can specify the FEEDS_EVENTS_MASK This mask determines which events will be raised by the Windows RSS Platform The

following options are available:

• FEM_FOLDEREVENTS Raise folder events only (added, deleted, renamed, moved)

• FEM_FEEDEVENTS Raise feed events only (added, deleted, renamed, moved)

As an example, the following code shows how to subscribe to the

FeedItemCountChanged event:

// Declaration of FeedList objects

FeedsManager fm = new FeedsManager();

IFeedFolder rootFolder = (IFeedFolder)fm.RootFolder;

IFeedFolderEvents_Event fw;

fw = (IFeedFolderEvents_Event)rootFolder.GetWatcher(

FEEDS_EVENTS_SCOPE.FES_ALL,

FEEDS_EVENTS_MASK.FEM_FEEDEVENTS);

fw.FeedItemCountChanged += new

IFeedFolderEvents_FeedItemCountChangedEventHandler(fw_FeedItemCountChanged);

The following table lists some of the folder events that are available

Event Description Mask

FolderAdded(path) A subfolder was added FEM_FOLDEREVENTS

FolderDeleted(path) A subfolder was deleted FEM_FOLDEREVENTS

FolderItemCountChanged(path,count,

unread)

The number of items (aggregated)

or the number of unread items (aggregated) changed

FEM_FOLDEREVENTS

FeedAdded(path) A feed was added FEM_FEEDEVENTS

The following table lists some of the feed events that are available

Event Description Mask

FeedDeleted(path) A feed was deleted FEM_FEEDEVENTS

FeedUrlChanged(path) The URL of a feed changed FEM_FEEDEVENTS

FeedDownloading(path) A feed has started downloading FEM_FEEDEVENTS

FeedDownloadCompleted(path,error) A feed has completed downloading

(success or error)

FEM_FEEDEVENTS

FeedItemCountChanged(path,count,

unread)

The number of items or the number of unread items changed

FEM_FEEDEVENTS

Error An error has occurred in the

eventing subsystem

N/A

Trang 7

Demonstration 1: Building an RSS Reader

In this demonstration, you will see how you can build an RSS reader by using the

Microsoft Windows RSS Platform

Key Point

The key point of this demonstration is:

• You can write an RSS reader application that uses the Windows Vista APIs to read

and manipulate RSS feeds

Trang 8

Querying the Windows Search Engine

Introduction

One of the important new features in Windows Vista is the new search functionality You

can configure Windows Search to index all of the important content sources on your

computer and then search that index to locate relevant documents and other content very

quickly By using the Windows Vista APIs, you can integrate this search capability into

any application you write

Objectives

After completing this section, you will be able to:

• Describe how the property system works for Windows Search

• Describe how to query the Windows Search system by using the OLEDB provider

Trang 9

Windows Search Property System Overview

The goal of the Windows Search system is to return the most precise results possible The

properties assigned to documents and other content are at the heart of the Windows

Search system Properties allow searches to return more precise results by ensuring that

all search results meet the properties specified in the search For example, properties such

as file author, creation date, and size may be important criteria when searching for a file

The results returned by a search will also include properties Some applications may

simply provide path to the actual item in the search result, but in most cases, the search

also displays the properties for all items returned in the search The user can then use

these properties to quickly identify which item in the search result to look at first

Properties are identified in two ways in Window Vista:

• Canonical name In SQL-style searches, the canonical name is used This is a text

name for the property System-defined properties all start with the term System For

example, the following are valid canonical names:

• System.Author

• System.Photo.FNumber

• System.Music.Artist

Trang 10

Companies could devise their own application-specific canonical names by using a

format such as CompanyName.GroupName.PropertyName The first GroupName value

can be anything, but it would typically be the name of an application or a suite of

applications

• PROPERTYKEY The second way of identifying a property is through a unique binary identifier This is the usual way of identifying the properties in an application when working with the search and property shell API This option is often more convenient to work with because it uses a fixed-size binary structure rather than a string

You can also use structures like the following to map between the PROPERTYKEY binary format and the canonical name:

struct PROPERTYKEY

{

GUID fmtid;

DWORD propid;

};

Trang 11

Querying Windows Search by Using the OLEDB

Provider

One of the easiest ways to query the Windows Search system is to use the OLE DB

provider To use the OLE DB provider, you will write a series of SQL-like SELECT

statements that use the following syntax:

SELECT <properties>

FROM [machineName.]SYSTEMINDEX SCOPE()

[WHERE <predicates>]

[GROUP BY <properties>]

[ORDER BY <properties>]

The statement includes the following elements:

• SELECT The <properties> represents a list of one or more comma-separated column

names in which the columns correspond to properties defined in the new Windows

Vista property system Property names must be enclosed in double quotation marks

(due to the period used in the naming convention) SELECT * is not supported, so

you will need to specify at least one property name

• FROM The FROM clause can specify only a single index that can be queried You

can precede SYSTEMINDEX SCOPE() with a machine name to execute a query

against the local index of a remote machine

Trang 12

• WHERE The optional WHERE clause supports a number of predicates

• Simple predicates: Literal value comparisons (<,>,=) and LIKE

• Full-text predicates: CONTAINS and FREETEXT

• Search depth predicates: SCOPE and DIRECTORY

• GROUP BY The optional GROUP BY clause supports multi-level grouping

• ORDER BY The optional ORDER BY clause supports locale-aware sorting

An example of a simple query that returns all messages that contain the word Expense

and that were sent by Marie is:

SELECT "System.DisplayFolder", "System.Title"

FROM SYSTEMINDEX SCOPE()

WHERE CONTAINS("Expense")

AND System.Message.FromName = "Marie"

GROUP BY System.Kind

The Microsoft OLE DB Provider for Microsoft Search is called Search.CollatorDSO.1

You can use the following connection string when instantiating the OleDBConnection

object:

"provider=Search.CollatorDSO.1;EXTENDED PROPERTIES=\"Application=Windows\""

This code is included in the following code snippet:

string indexerConnString = "provider=Search.CollatorDSO.1;EXTENDED

PROPERTIES=\"Application=Windows\"";

using (OleDbConnection conn = new OleDbConnection(indexerConnString))

{

conn.Open();

string sqlCommand = "Select \"System.Title\", \"System.Size\" FROM

systemindex scope() WHERE \"System.Size\" > 1024";

OleDbCommand cmd = new OleDbCommand(sqlCommand, conn);

using (OleDbDataReader reader = cmd.ExecuteReader())

{

while (reader.Read())

{

}

}

conn.Close();

}

Trang 13

Demonstration 2: Querying the Windows Search

Engine

In this demonstration, you will see how you can query the Windows Search engine by

using the OLE DB provider

Key Points

The key points of this demonstration are:

• You can easily write an application that can use the Windows Search engine to locate

information on the computer

• You can configure the search to look for files with specific properties, and you can

configure how the result set is ordered

Trang 14

Session Summary

In addition to providing support for the new features in NET Framework 3.0, Windows

Vista also provides many enhanced and new application programming interfaces (APIs)

that can be used by developers when creating applications

This session described:

• The new API features available in Windows Vista

• How to develop an RSS reader by using the Windows Vista API

• How to query Windows Search by using the Windows Vista API

Trang 15

Next Steps

Access the Vista Bridge sample library to view managed wrappers the new Vista APIs:

• http://windowssdk.msdn.microsoft.com/en-us/library/ms756482.aspx

Trang 16

Questions and Answers

Trang 17

Clinic Evaluation

Your evaluation of this product will help Microsoft understand the quality of your

learning experience

Please work with your training provider to access the product evaluation form

Microsoft will keep your answers to this survey private and confidential and will use your

responses to improve your future learning experience Your open and honest feedback is

valuable and appreciated

Ngày đăng: 14/08/2014, 02:22

TỪ KHÓA LIÊN QUAN

w