-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13e1645
commit 7a801a5
Showing
13 changed files
with
305 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ ServiceHost Language="C#" Debug="true" Service="SampleWebApplication.ServiceModel.Feed" CodeBehind="Feed.svc.cs" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Syndication; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.Extensions.ServiceModel.DependencyInjection; | ||
using SampleWebApplication.Options; | ||
using SampleWebApplication.Services; | ||
|
||
namespace SampleWebApplication.ServiceModel | ||
{ | ||
[SystemWebHostServiceBehavior()] | ||
public class Feed : IFeed | ||
{ | ||
private readonly ISyndicationClient syndicationClient; | ||
private readonly FeedOptions options; | ||
|
||
public Feed(ISyndicationClient syndicationClient, IOptions<FeedOptions> options) | ||
{ | ||
this.syndicationClient = syndicationClient ?? throw new ArgumentNullException(nameof(syndicationClient)); | ||
this.options = options?.Value ?? throw new ArgumentNullException(nameof(options)); | ||
} | ||
|
||
public async Task<string> GetFeedAsync() | ||
{ | ||
var feed = await syndicationClient.GetSyndicationFeedAsync(options.Uri); | ||
|
||
return feed.Title.Text; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.ServiceModel; | ||
using System.ServiceModel.Syndication; | ||
using System.Threading.Tasks; | ||
|
||
namespace SampleWebApplication.ServiceModel | ||
{ | ||
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IFeed" in both code and config file together. | ||
[ServiceContract] | ||
public interface IFeed | ||
{ | ||
[OperationContract(Action = "GetFeed")] | ||
Task<string> GetFeedAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ampleWebApplication/WebServices/Feed.ashx → ...ampleWebApplication/WebHandlers/Feed.ashx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<%@ WebHandler Language="C#" CodeBehind="Feed.ashx.cs" Class="SampleWebApplication.WebServices.FeedHandler" %> | ||
<%@ WebHandler Language="C#" CodeBehind="Feed.ashx.cs" Class="SampleWebApplication.WebHandlers.FeedHandler" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ions.ServiceModel/DependencyInjection/SystemWebHostDependencyInjectionInstanceProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
using System.ServiceModel.Dispatcher; | ||
using System.Web; | ||
|
||
namespace Microsoft.Extensions.ServiceModel.DependencyInjection | ||
{ | ||
internal sealed class SystemWebHostDependencyInjectionInstanceProvider : IInstanceProvider | ||
{ | ||
public static readonly SystemWebHostDependencyInjectionInstanceProvider Shared = new SystemWebHostDependencyInjectionInstanceProvider(); | ||
|
||
public object GetInstance(InstanceContext instanceContext) | ||
{ | ||
return GetInstance(instanceContext, null); | ||
} | ||
|
||
public object GetInstance(InstanceContext instanceContext, Message message) | ||
{ | ||
return HttpRuntime.WebObjectActivator.GetService(instanceContext.Host.Description.ServiceType); | ||
} | ||
|
||
public void ReleaseInstance(InstanceContext instanceContext, object instance) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.