Untitled diff
18 removals
43 lines
19 additions
43 lines
internal static IDictionary<string, RouteMember> GetQueryProperties(Type requestType)
internal static IDictionary<string, RouteMember> GetQueryProperties(Type requestType)
{
{
var result = new Dictionary<string, RouteMember>(StringExtensions.InvariantComparerIgnoreCase());
var result = new Dictionary<string, RouteMember>(PclExport.Instance.InvariantComparerIgnoreCase);
var hasDataContract = requestType.HasAttr<DataContractAttribute>();
var hasDataContract = requestType.HasAttribute<DataContractAttribute>();
foreach (var propertyInfo in requestType.GetPublicProperties())
foreach (var propertyInfo in requestType.GetPublicProperties())
{
{
var propertyName = propertyInfo.Name;
var propertyName = propertyInfo.Name;
if (!propertyInfo.CanRead) continue;
if (!propertyInfo.CanRead) continue;
if (hasDataContract)
if (hasDataContract)
{
{
if (!propertyInfo.IsDefined(typeof(DataMemberAttribute), true)) continue;
if (!propertyInfo.HasAttribute<DataMemberAttribute>()) continue;
var dataMember = propertyInfo.FirstAttribute<DataMemberAttribute>();
var dataMember = propertyInfo.FirstAttribute<DataMemberAttribute>();
if (!string.IsNullOrEmpty(dataMember.Name))
if (!string.IsNullOrEmpty(dataMember.Name))
{
{
propertyName = dataMember.Name;
propertyName = dataMember.Name;
}
}
}
}
else
result[propertyName.ToCamelCase()] = new PropertyRouteMember(propertyInfo)
{
{
if (propertyInfo.IsDefined(typeof(IgnoreDataMemberAttribute), true)) continue;
IgnoreInQueryString = propertyInfo.FirstAttribute<IgnoreDataMemberAttribute>() != null, //but allow in PathInfo
}
};
result[propertyName.ToCamelCase()] = new PropertyRouteMember(propertyInfo);
}
}
if (JsConfig.IncludePublicFields)
if (JsConfig.IncludePublicFields)
{
{
foreach (var fieldInfo in requestType.GetPublicFields())
foreach (var fieldInfo in requestType.GetPublicFields())
{
{
var fieldName = fieldInfo.Name;
var fieldName = fieldInfo.Name;
if (fieldInfo.IsDefined(typeof(IgnoreDataMemberAttribute), true)) continue;
result[fieldName.ToCamelCase()] = new FieldRouteMember(fieldInfo);
result[fieldName.ToCamelCase()] = new FieldRouteMember(fieldInfo)
}
{
IgnoreInQueryString = fieldInfo.FirstAttribute<IgnoreDataMemberAttribute>() != null, //but allow in PathInfo
};
}
}
}
return result;
return result;
}
}