C#
- 5 ответов
- 0 вопросов
2
Вклад в тег
var mostRepeatedNumber = array.GroupBy(x => x, x => x)
.OrderByDescending(x => x.Count())
.First().Key;
array = array.Where(val => val !=mostRepeatedNumber).ToArray();
xhrFields:{ responseType: 'blob' }
$.ajax({
url: MY_URL_,
method: "GET",
xhrFields: {
responseType: 'blob'
},
headers: {
"Authorization": "Basic YAZRt45aWDa25wDDdFND232YFmVmb23213ffWEa5OA=="
}
}).then(response => {
console.log(response);
$('#canvas').attr('src', URL.createObjectURL(response));
}).catch(error => {
console.log(error);
})
public static IOrderedQueryable<TSource> OrderByAscOrDesc<TSource>(this IQueryable<TSource> query, string propName, bool isDesc)
{
var entityType = typeof(TSource);
var propInfo = entityType.GetProperty(propName);
if (propInfo.DeclaringType != entityType)
propInfo = propInfo.DeclaringType.GetProperty(propName);
if (propInfo == null) return (IOrderedQueryable<TSource>)query;
var arg = Expression.Parameter(entityType, "x");
var property = Expression.MakeMemberAccess(arg, propInfo);
var selector = Expression.Lambda(property, new ParameterExpression[] { arg });
var methodName = isDesc ? "OrderByDescending" : "OrderBy";
var method = typeof(Queryable).GetMethods()
.Where(x => x.Name == methodName && x.IsGenericMethodDefinition)
.Where(x => x.GetParameters().Length == 2)
.Single();
var genericMethod = method.MakeGenericMethod(entityType, propInfo.PropertyType);
return (IOrderedQueryable<TSource>)genericMethod.Invoke(genericMethod, new object[] { query, selector });
}