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
type ResultT struct { | |
Response interface{} | |
Errors map[string]string | |
} | |
func NewResultT() ResultT { | |
return ResultT{ | |
Response: nil, | |
Errors: make(map[string]string), | |
} |
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
use std::collections::HashMap; | |
pub struct ResultT<T> { | |
response: Option<T>, | |
errors: HashMap<String, String>, | |
} | |
impl<T> ResultT<T> { | |
pub fn new() -> Self { | |
ResultT { |
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
public static class EnumExtensions | |
{ | |
public static T? GetDefaultValue<T>() where T : Enum | |
{ | |
var enumType = typeof(T); | |
var defaultValueAttribute = Attribute | |
.GetCustomAttribute(enumType, typeof(DefaultValueAttribute)) as DefaultValueAttribute; | |
if (defaultValueAttribute is not null && | |
defaultValueAttribute.Value is T) |
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.ComponentModel; | |
using System.Linq; | |
using System.Reflection; | |
public static class EnumExtension | |
{ | |
public static string GetDescription<TEnum>(this TEnum value) where TEnum : Enum | |
{ | |
FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); |
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.IO; | |
using System.Collections.Generic; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.Linq; | |
namespace Vasconcellos.Extensions | |
{ | |
public static class ObjectExtension | |
{ | |
/// <summary> |
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
public async Task<IActionResult> Example(int? page, int? rows) | |
{ | |
IList<object> entities = await _service.Get(); | |
if (page != null && page > 0 && rows != null && rows > 0) | |
{ | |
entities = query.Skip((int)(rows * (page - 1))).Take((int)rows).ToList(); | |
} | |
else | |
entities = query.ToList(); | |