本文整理汇总了C#中JsonPropertyCollection类的典型用法代码示例。如果您正苦于以下问题:C# JsonPropertyCollection类的具体用法?C# JsonPropertyCollection怎么用?C# JsonPropertyCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonPropertyCollection类属于命名空间,在下文中一共展示了JsonPropertyCollection类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: JsonDynamicContract
/// <summary>
/// Initializes a new instance of the <see cref="JsonDynamicContract"/> class.
/// </summary>
/// <param name="underlyingType">The underlying type for the contract.</param>
public JsonDynamicContract(Type underlyingType)
: base(underlyingType)
{
ContractType = JsonContractType.Dynamic;
Properties = new JsonPropertyCollection(UnderlyingType);
}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:11,代码来源:JsonDynamicContract.cs
示例2: JsonObjectContract
/// <summary>
/// Initializes a new instance of the <see cref="JsonObjectContract"/> class.
/// </summary>
/// <param name="underlyingType">The underlying type for the contract.</param>
public JsonObjectContract(Type underlyingType)
: base(underlyingType)
{
ContractType = JsonContractType.Object;
Properties = new JsonPropertyCollection(UnderlyingType);
ConstructorParameters = new JsonPropertyCollection(UnderlyingType);
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:12,代码来源:JsonObjectContract.cs
示例3: CreateProperties
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
List<MemberInfo> members = this.GetSerializableMembers(type);
if (members == null)
{
throw new JsonSerializationException("Null collection of seralizable members returned.");
}
JsonPropertyCollection properties = new JsonPropertyCollection(type);
foreach (MemberInfo member in members)
{
JsonProperty property = this.CreateProperty(member, memberSerialization);
if (property != null)
{
properties.AddProperty(property);
}
}
// IList<JsonProperty> orderedProperties = properties.OrderBy(p => p.Order ?? -1).ToList();
return properties;
}
开发者ID:eserozvataf,项目名称:tasslehoff,代码行数:23,代码来源:OrderedContractResolver.cs
示例4: JsonObjectContract
/// <summary>
/// Initializes a new instance of the <see cref="JsonObjectContract"/> class.
/// </summary>
/// <param name="underlyingType">The underlying type for the contract.</param>
public JsonObjectContract(Type underlyingType)
: base(underlyingType)
{
Properties = new JsonPropertyCollection(UnderlyingType);
}
开发者ID:TheoBo,项目名称:Wallet.Net,代码行数:9,代码来源:JsonObjectContract.cs
示例5: CreateProperties
/// <summary>
/// Creates properties for the given <see cref="JsonObjectContract"/>.
/// </summary>
/// <param name="contract">The contract to create properties for.</param>
/// <returns>Properties for the given <see cref="JsonObjectContract"/>.</returns>
protected virtual IList<JsonProperty> CreateProperties(JsonObjectContract contract)
{
List<MemberInfo> members = GetSerializableMembers(contract.UnderlyingType);
if (members == null)
throw new JsonSerializationException("Null collection of seralizable members returned.");
JsonPropertyCollection properties = new JsonPropertyCollection(contract);
foreach (MemberInfo member in members)
{
JsonProperty property = CreateProperty(contract, member);
if (property != null)
properties.AddProperty(property);
}
return properties;
}
开发者ID:AndyStewart,项目名称:docsharp,代码行数:23,代码来源:DefaultContractResolver.cs
示例6: JsonObjectContract
/// <summary>
/// Initializes a new instance of the <see cref="JsonObjectContract"/> class.
/// </summary>
/// <param name="underlyingType">The underlying type for the contract.</param>
public JsonObjectContract(Type underlyingType)
: base(underlyingType)
{
Properties = new JsonPropertyCollection();
CreatedType = underlyingType;
}
开发者ID:martinbowling,项目名称:GowallaOAuthSample,代码行数:10,代码来源:JsonObjectContract.cs
示例7: CreateProperties
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
var objectType = type.GetBaseObjectType() ?? type;
if (!_propertyies.ContainsKey(objectType))
{
var props = base.CreateProperties(objectType, memberSerialization);
if (!objectType.IsBaseObject())
{
_propertyies.Add(objectType, props);
return _propertyies[objectType];
}
if (_config.TypeEntity == objectType)
{
var resProps = new List<JsonProperty>();
foreach (var prop in props)
{
if (prop.PropertyType.IsBaseObject() || prop.PropertyType.IsBaseCollection())
{
if (_editors.All(x => x.PropertyName != prop.PropertyName)) continue;
}
resProps.Add(prop);
}
_propertyies.Add(objectType, resProps);
}
else
{
var config = _uiFasade.GetViewModelConfig(objectType);
if (config == null) return props;
if (objectType.IsDefined(typeof(ComplexTypeAttribute), false)) return props;
var editor = _editors.FirstOrDefault(x => x.EditorType == objectType);
if (editor == null) return props;
if (editor.EditorTemplate == "EasyCollection")
{
var typeEasyCollection = editor.ViewModelConfig.TypeEntity;
if (!_propertyies.ContainsKey(typeEasyCollection))
{
var properties = new JsonPropertyCollection(typeEasyCollection);
properties.AddProperty(CreateProperty(typeEasyCollection.GetProperty("ID"),
memberSerialization));
if (editor.ViewModelConfig.LookupProperty != "ID")
properties.AddProperty(CreateProperty(
typeEasyCollection.GetProperty(editor.ViewModelConfig.LookupProperty), memberSerialization));
_propertyies.Add(typeEasyCollection, properties);
}
}
if (editor.Relationship == Relationship.OneToMany) return props;
var sysColumns = _uiFasade.GetEditors(objectType)
.Where(
c =>
c.IsSystemPropery &&
(c.PropertyName != "RowVersion" && c.PropertyName != "Hidden" &&
c.PropertyName != "SortOrder")).ToList();
props =
props.Where(
p =>
p.PropertyName == config.LookupProperty ||
sysColumns.Any(x => x.PropertyName == p.PropertyName && x.IsSystemPropery)).ToList();
_propertyies.Add(objectType, props);
}
}
return _propertyies[objectType];
}
开发者ID:altaricka,项目名称:vDesign,代码行数:83,代码来源:BoContractResolver.cs
示例8: CreateProperties
protected virtual IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
List<MemberInfo> serializableMembers = this.GetSerializableMembers(type);
if (serializableMembers == null)
throw new JsonSerializationException("Null collection of seralizable members returned.");
JsonPropertyCollection propertyCollection = new JsonPropertyCollection(type);
foreach (MemberInfo member in serializableMembers)
{
JsonProperty property = this.CreateProperty(member, memberSerialization);
if (property != null)
propertyCollection.AddProperty(property);
}
return (IList<JsonProperty>) Enumerable.ToList<JsonProperty>((IEnumerable<JsonProperty>) Enumerable.OrderBy<JsonProperty, int>((IEnumerable<JsonProperty>) propertyCollection, (Func<JsonProperty, int>) (p => p.Order ?? -1)));
}
开发者ID:Zeludon,项目名称:FEZ,代码行数:14,代码来源:DefaultContractResolver.cs
示例9: CreateConstructorParameters
protected virtual IList<JsonProperty> CreateConstructorParameters(ConstructorInfo constructor, JsonPropertyCollection memberProperties)
{
ParameterInfo[] parameters = constructor.GetParameters();
JsonPropertyCollection propertyCollection = new JsonPropertyCollection(constructor.DeclaringType);
foreach (ParameterInfo parameterInfo in parameters)
{
JsonProperty matchingMemberProperty = parameterInfo.Name != null ? memberProperties.GetClosestMatchProperty(parameterInfo.Name) : (JsonProperty) null;
if (matchingMemberProperty != null && matchingMemberProperty.PropertyType != parameterInfo.ParameterType)
matchingMemberProperty = (JsonProperty) null;
JsonProperty constructorParameter = this.CreatePropertyFromConstructorParameter(matchingMemberProperty, parameterInfo);
if (constructorParameter != null)
propertyCollection.AddProperty(constructorParameter);
}
return (IList<JsonProperty>) propertyCollection;
}
开发者ID:Zeludon,项目名称:FEZ,代码行数:15,代码来源:DefaultContractResolver.cs
示例10: CreateProperties
protected override IList<JsonProperty> CreateProperties (Type type, MemberSerialization serialization)
{
var properties = new JsonPropertyCollection(type);
foreach (JsonProperty property in GetSerializableMembers(type).Select(m => CreateProperty(m, serialization)).WhereNotNull())
properties.AddProperty(property);
return properties
.OrderBy(p => p.Order ?? -1)
.ThenBy(IsPropertyCollection)
.ThenBy(GetPropertyTypeDepth)
.ThenBy(p => p.PropertyName)
.ToList();
}
开发者ID:binki,项目名称:Alba.Framework,代码行数:12,代码来源:JsonLinkedContractResolver.cs
示例11: CreateProperties
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
var serializableMembers = GetSerializableMembers(type).Cast<PropertyInfo>();
if (serializableMembers == null)
throw new JsonSerializationException("Null collection of seralizable members returned.");
var typeDefinition = _ServerConfiguration.GetScimTypeDefinition(type);
var propertyCollection = new JsonPropertyCollection(type);
foreach (var member in serializableMembers)
{
var property = CreateProperty(member, memberSerialization);
if (property != null)
{
var state = _InstanceState;
var propertyNameTable = state.NameTable;
bool lockTaken = false;
try
{
Monitor.Enter(propertyNameTable, ref lockTaken);
property.PropertyName = state.NameTable.Add(property.PropertyName);
IScimTypeAttributeDefinition attributeDefinition;
if (typeDefinition != null && typeDefinition.AttributeDefinitions.TryGetValue(member, out attributeDefinition))
{
// Internal json.net deserialization logic will hit the ShouldDeserialize delegate before checking property.Writable
// Still, we'll set Writable to accurately reflect this
property.Writable = attributeDefinition.Mutability != Mutability.ReadOnly; // deserializable?
// setting property.Readable will shortcut the ShouldSerialize delegate
// INTERNAL JSON.NET LOGIC
// if (!property.Ignored && property.Readable && ShouldSerialize(writer, property, value) && IsSpecified(writer, property, value))
property.Readable = attributeDefinition.Mutability != Mutability.WriteOnly; // serializable?
// Only attach a conditional deserialization delegate if the attribute is not ReadWrite.
if (attributeDefinition.Mutability != Mutability.ReadWrite)
{
property.ShouldDeserialize = o =>
{
if (attributeDefinition.Mutability == Mutability.ReadOnly)
return false;
return true;
};
}
// Only attach a conditional serialization delegate if the attribute is not Always returned.
if (attributeDefinition.Returned != Returned.Always)
{
var existingShouldSerializeFunc = property.ShouldSerialize;
property.ShouldSerialize = o =>
{
if (attributeDefinition.Mutability == Mutability.WriteOnly || attributeDefinition.Returned == Returned.Never)
return false;
var httpMethod = AmbientRequestService.HttpMethod;
if (attributeDefinition.Returned == Returned.Default ||
(attributeDefinition.Returned == Returned.Request && (httpMethod == HttpMethod.Post || httpMethod == _Patch || httpMethod == HttpMethod.Put)))
{
var queryOptions = AmbientRequestService.QueryOptions;
if (queryOptions.Attributes.Any() && !queryOptions.Attributes.Contains(property.PropertyName))
return false;
if (queryOptions.ExcludedAttributes.Any() && queryOptions.ExcludedAttributes.Contains(property.PropertyName))
return false;
}
if (existingShouldSerializeFunc != null)
return existingShouldSerializeFunc(o);
return true;
};
}
}
}
finally
{
if (lockTaken)
Monitor.Exit(propertyNameTable);
}
propertyCollection.AddProperty(property);
}
}
return propertyCollection.OrderBy(p => p.Order ?? -1).ToList();
}
开发者ID:PowerDMS,项目名称:Owin.Scim,代码行数:86,代码来源:ScimContractResolver.cs
注:本文中的JsonPropertyCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论