public static Update <TCast> OfType <T, TCast>( [NotNull] this Update <T> update, TypeHint <TCast> tHint = default) where TCast : T { if (update is null) { throw new ArgumentNullException(nameof(update)); } return(update.Bind(x => x is TCast result ? result.ToUpdate() : Update <TCast> .Ignore)); }
public static List <TCast> OfType <T, TCast>( [NotNull] this List <T> list, TypeHint <TCast> tHint = default) where TCast : T { if (list is null) { throw new ArgumentNullException(nameof(list)); } return(list.Bind(x => x is TCast result ? result.ToList() : List <TCast> .Empty)); }
public static Either <TLeft, TRight> ToEitherRight <TLeft, TRight>( [NotNull] this TRight instance, TypeHint <TLeft> tLeftHint = default) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } return(Either <TLeft, TRight> .Right(instance)); }
public static Option <TCast> OfType <T, TCast>( [NotNull] this Option <T> option, TypeHint <TCast> tHint = default) where TCast : T { if (option is null) { throw new ArgumentNullException(nameof(option)); } return(option.Bind(x => x is TCast result ? result.ToOption() : Option <TCast> .None)); }
public static string HintToName(TypeHint hint) => hint.HasFlags(TypeHint.Function) ? "func" : hint.HasFlags(TypeHint.Double) ? "f64" : hint.HasFlags(TypeHint.Single) ? "f32" : hint.HasFlags(TypeHint.Byte) ? "i8" : hint.HasFlags(TypeHint.ByteUnsigned) ? "u8" : hint.HasFlags(TypeHint.HalfWord) ? "i16" : hint.HasFlags(TypeHint.HalfWordUnsigned) ? "u16" : hint.HasFlags(TypeHint.Word) ? "i32" : hint.HasFlags(TypeHint.WordUnsigned) ? "u32" : hint.HasFlags(TypeHint.DoubleWord) ? "i64" : "data";
public static bool HasFlags(this TypeHint t, TypeHint flags) => (t & flags) != 0;
/// <summary> /// Initializes a new instance of the <see cref="DiscordTypeHintAttribute"/> class. /// </summary> /// <param name="typeHint">The type hint.</param> public DiscordTypeHintAttribute(TypeHint typeHint) { this.TypeHint = typeHint; }
public Symbol(UInt32 address, string name, TypeHint typeHint, SymbolType type) { Address = address; Name = name; TypeHint = typeHint; }
public Symbol(UInt32 address, string name, TypeHint typeHint) : this(address, name, typeHint, SymbolType.Internal) { }
public Symbol(UInt32 address, TypeHint hint) : this(address, GenName(address, hint), hint) { }
private static string GenName(UInt32 address, TypeHint hint) => string.Format("{0}_{1:X8}", HintToName(hint), address);
public static Func <List <T>, List <TCast> > OfType <T, TCast>(TypeHint <TCast> typeHint = default) where TCast : T { return(x => x.OfType(typeHint)); }
public static Either <TLeft, TRight> Right <TLeft, TRight>( [NotNull] TRight value, TypeHint <TLeft> tLeftHint = default) { return(Either <TLeft, TRight> .Right(value)); }
public static Either <TLeft, TRight> Left <TLeft, TRight>( [NotNull] TLeft value, TypeHint <TRight> tRightHint = default) { return(Either <TLeft, TRight> .Left(value)); }
public Param(string name, object value, TypeHint hint = TypeHint.Unspecified) { Name = name.NonBlank(nameof(name)); Value = value; Type = hint; }
/// <summary> /// Tries to map a TypeHint into a CLR type or null if no mapping possible /// </summary> public static Type TryMap(TypeHint hint) => s_Map.TryGetValue(hint, out var result) ? result : null;