示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
 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";
示例#6
0
 public static bool HasFlags(this TypeHint t, TypeHint flags) =>
 (t & flags) != 0;
示例#7
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;
 }
示例#8
0
 public Symbol(UInt32 address, string name, TypeHint typeHint, SymbolType type)
 {
     Address  = address;
     Name     = name;
     TypeHint = typeHint;
 }
示例#9
0
 public Symbol(UInt32 address, string name, TypeHint typeHint)
     : this(address, name, typeHint, SymbolType.Internal)
 {
 }
示例#10
0
 public Symbol(UInt32 address, TypeHint hint)
     : this(address, GenName(address, hint), hint)
 {
 }
示例#11
0
 private static string GenName(UInt32 address, TypeHint hint) =>
 string.Format("{0}_{1:X8}", HintToName(hint), address);
示例#12
0
文件: List.cs 项目: jhbertra/FunSharp
 public static Func <List <T>, List <TCast> > OfType <T, TCast>(TypeHint <TCast> typeHint = default) where TCast : T
 {
     return(x => x.OfType(typeHint));
 }
示例#13
0
 public static Either <TLeft, TRight> Right <TLeft, TRight>(
     [NotNull] TRight value,
     TypeHint <TLeft> tLeftHint = default)
 {
     return(Either <TLeft, TRight> .Right(value));
 }
示例#14
0
 public static Either <TLeft, TRight> Left <TLeft, TRight>(
     [NotNull] TLeft value,
     TypeHint <TRight> tRightHint = default)
 {
     return(Either <TLeft, TRight> .Left(value));
 }
示例#15
0
文件: Command.cs 项目: azist/azos
 public Param(string name, object value, TypeHint hint = TypeHint.Unspecified)
 {
     Name  = name.NonBlank(nameof(name));
     Value = value;
     Type  = hint;
 }
示例#16
0
文件: Command.cs 项目: azist/azos
 /// <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;