/// <summary> /// Creates properties for the given <see cref="JsonContract"/>. /// </summary> /// <param name="type">The type to create properties for.</param> /// /// <param name="memberSerialization">The member serialization mode for the type.</param> /// <returns>Properties for the given <see cref="JsonContract"/>.</returns> protected override IList <JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization) { var members = GetSerializableMembers(type); if (members == null) { throw new JsonSerializationException("Null collection of seralizable members returned."); } var properties = new JsonPropertyCollection(type); var modelConfiguration = _breezeConfigurator.GetModelConfiguration(type); foreach (var member in members) { var property = CreateProperty(type, member, memberSerialization, modelConfiguration); if (property != null) { var nameTable = DefaultContractResolverStateNameTableField.GetValue(this); // nametable is not thread-safe for multiple writers lock (nameTable) { property.PropertyName = (string)PropertyNameTableAddMethod .Invoke(nameTable, new object[] { property.PropertyName }); } properties.AddProperty(property); } } var syntheticPoperties = _getMetadataFunc(type).GetSyntheticProperties(); if (syntheticPoperties != null && syntheticPoperties.Any()) { foreach (var syntheticProp in syntheticPoperties) { var propertyName = ResolvePropertyName(syntheticProp.Name); // Skip manually added syntetic properties if (!properties.Any(x => x.PropertyName == propertyName)) { properties.Add(new JsonProperty { Readable = true, Writable = true, PropertyName = propertyName, PropertyType = syntheticProp.PkType.ReturnedClass, ValueProvider = new NHSyntheticPropertyValueProvider(syntheticProp) }); } } } IList <JsonProperty> orderedProperties = properties.OrderBy(p => p.Order ?? -1).ToList(); ApplySerializationRules(type, orderedProperties, memberSerialization); return(orderedProperties); }