forked from aspnet/Mvc
-
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.
Changes to introduce CanWriteResult for Xml OutputFormatters.
- Loading branch information
sornaks
committed
Aug 20, 2014
1 parent
041d350
commit b9f1586
Showing
11 changed files
with
195 additions
and
13 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
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
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
33 changes: 33 additions & 0 deletions
33
test/WebSites/FormatterWebSite/Controllers/DataContractSerializerController.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,33 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.AspNet.Mvc; | ||
|
||
namespace FormatterWebSite | ||
{ | ||
/// <summary> | ||
/// Summary description for DataContractSerializerController | ||
/// </summary> | ||
public class DataContractSerializerController : Controller | ||
{ | ||
public override void OnActionExecuted(ActionExecutedContext context) | ||
{ | ||
var result = context.Result as ObjectResult; | ||
if (result != null) | ||
{ | ||
result.Formatters.Add(new XmlSerializerOutputFormatter()); | ||
result.Formatters.Add(new XmlDataContractSerializerOutputFormatter()); | ||
} | ||
|
||
base.OnActionExecuted(context); | ||
} | ||
|
||
[HttpPost] | ||
public Person GetPerson(string name) | ||
{ | ||
// The XmlSerializer should skip and the | ||
// DataContractSerializer should pick up this output. | ||
return new Person(name); | ||
} | ||
} | ||
} |
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,19 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.Serialization; | ||
|
||
namespace FormatterWebSite | ||
{ | ||
[DataContract] | ||
public class Person | ||
{ | ||
public Person(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
[DataMember] | ||
public string Name { get; set; } | ||
} | ||
} |