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
function Model(){ | |
this.selectedItems = ko.observableArray(); | |
this.selectNone = function () { | |
this.selectedItems().length = 0; | |
this.selectedItems.valueHasMutated(); | |
} | |
this.hasItemsSelected = ko.dependentObservable(function () { | |
return this.selectedItems().length > 0; | |
}, this); | |
} |
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
html { | |
background: #f6f6f6; | |
padding: 24px; | |
text-align: center; | |
} | |
a { | |
border-radius: 4px; | |
display: inline-block; |
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
html { | |
background: #f6f6f6; | |
padding: 24px; | |
text-align: center; | |
} | |
a { | |
border-radius: 4px; | |
display: inline-block; |
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
img { | |
position: relative; | |
display: block; | |
content: ""; | |
} | |
img:before { | |
display: block; | |
content: ""; | |
position: absolute; |
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
var settings = new JsonSerializerSettings | |
{ | |
ContractResolver = new ConfigurableContractResolver() | |
} | |
JsonSerializer serializer = JsonSerializer.Create(settings); | |
serializer.Serialize(textWriter, valueToSerialize); |
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
using System; | |
using System.Globalization; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
namespace MvcJson | |
{ | |
public class ConfigurableContractResolver: DefaultContractResolver | |
{ | |
public bool UseCamelCase { get; set; } |
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
.border { | |
border: 1px solid #ccc; | |
border: 1px solid rgba(0, 0, 0, 0.15); | |
-webkit-border-radius: 4px; | |
-moz-border-radius: 4px; | |
border-radius: 4px; | |
} |
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
// Data (like the default JsonResult) is the Model being serialized. | |
Type type = this.Data.GetType(); | |
// Wrap Enumerables to avoid potential Json Hijacking. | |
if (TypeHelper.TryWrappingForIEnumerableGenericOrSame(ref type)) | |
{ | |
this.Data = TypeHelper.GetTypeRemappingConstructor(type).Invoke(new object[] { this.Data }); | |
} | |
using (JsonTextWriter jsonTextWriter = new JsonTextWriter(response.Output) { CloseOutput = false }) | |
{ |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace MvcJson.Net.Models | |
{ | |
public class EnumerableWrapper<T> | |
{ | |
public EnumerableWrapper(IEnumerable<T> items) | |
{ |
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
/// <summary> | |
/// Creates a System.Web.Mvc.JsonResult object that serializes the specified object to JavaScript Object Notation (JSON). | |
/// </summary> | |
/// <param name="data">The JavaScript object graph to serialize.</param> | |
/// <param name="contentType">The content type (MIME type).</param> | |
/// <param name="contentEncoding">The content encoding.</param> | |
/// <param name="behavior">The JSON request behavior</param> | |
/// <returns> | |
/// The JSON result object that serializes the specified object to JSON format. | |
/// The result object that is prepared by this method is written to the response |
OlderNewer