ToUInt64() private méthode

private ToUInt64 ( DateTime value ) : ulong
value DateTime
Résultat ulong
        /// <summary>
        ///     Converts the specified search criterion dto.
        /// </summary>
        /// <param name="searchCriterionDto">The search criterion dto.</param>
        /// <returns>ICriterion.</returns>
        /// <exception cref="ArgumentException">Input has to have at least 3 arguments</exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <exception cref="Exception">change this</exception>
        public ICriterion Convert(SearchCriterionDto searchCriterionDto)
        {
            var terminal = (TerminalSearchCriterionDto)searchCriterionDto;
            var args     = terminal.Args;

            if (args.Length < 3)
            {
                throw new ArgumentException("Input has to have at least 3 arguments");
            }
            var reg = Register.Lookup(args[0]);

            if (reg == null)
            {
                throw new ArgumentOutOfRangeException();
            }
            switch (args[1])
            {
            case "-eq":
                return(new RegisterEqualsCriterion(reg, Conv.ToUInt64(args[2]).ToHexString()));

            case "-between":
                var low = Conv.ToUInt64(args[2]);
                var hi  = Conv.ToUInt64(args[3]);    // todo: check before
                return(new RegisterBetweenCriterion(reg, low.ToHexString(), hi.ToHexString()));

            default:
                throw new Exception("change this");
            }
        }
Exemple #2
0
        private void LoadVariables()
        {
            Prefix        = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[NightPVP] "));               // CHAT PLUGIN PREFIX
            PrefixColor   = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#bf0000"));              // CHAT PLUGIN PREFIX COLOR
            ChatColor     = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#dd8e8e"));                // CHAT MESSAGE COLOR
            SteamIDIcon   = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198079320022"));    // SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET /
            starthour     = Convert.ToSingle(GetConfig("Night Time Zone", "Start at", "21"));
            stophour      = Convert.ToSingle(GetConfig("Night Time Zone", "Stop at", "6"));
            leftmin       = Convert.ToDouble(GetConfig("HUD position", "left (0.95 by default)", "0.95"));
            bottom        = Convert.ToDouble(GetConfig("HUD position", "bottom (0.86 by default)", "0.86"));
            HUDtxtsize    = Convert.ToInt32(GetConfig("HUD text size", "(10 by default)", "10"));
            HUDwidth      = Convert.ToDouble(GetConfig("HUD size", "width (0.05 by default)", "0.05"));
            HUDheigth     = Convert.ToDouble(GetConfig("HUD size", "heigth (0.04 by default)", "0.04"));
            HUDpvecolor   = Convert.ToString(GetConfig("HUD color", "for PVE", "0.5 1.0 0.0"));              // CHAT MESSAGE COLOR
            HUDpveopacity = Convert.ToString(GetConfig("HUD opacity", "for PVE", "0.0"));                    // CHAT MESSAGE COLOR
            HUDpvpcolor   = Convert.ToString(GetConfig("HUD color", "for PVP", "0.85 0.2 0.5"));             // CHAT MESSAGE COLOR
            HUDpvpopacity = Convert.ToString(GetConfig("HUD opacity", "for PVP", "0.0"));                    // CHAT MESSAGE COLOR

            //rate = Convert.ToSingle(GetConfig("", "", "300"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
        public ulong ToUInt64(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(SConvert.ToUInt64(value, CultureInfo.InvariantCulture));
        }
 private static void RegisterDecimalConversions(
     ITypeConverterRegistry registry)
 {
     registry.Register <decimal, short>(from => SysConv.ToInt16(from));
     registry.Register <decimal, int>(from => SysConv.ToInt32(from));
     registry.Register <decimal, long>(from => SysConv.ToInt64(from));
     registry.Register <decimal, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <decimal, uint>(from => SysConv.ToUInt32(from));
     registry.Register <decimal, ulong>(from => SysConv.ToUInt64(from));
     registry.Register <decimal, float>(from => SysConv.ToSingle(from));
     registry.Register <decimal, double>(from => SysConv.ToDouble(from));
     registry.Register <decimal, string>(from =>
                                         from.ToString("E", CultureInfo.InvariantCulture));
 }
        private void LoadVariables()
        {
            SteamIDIcon = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198357983957"));        // SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET /
            Prefix      = Convert.ToString(GetConfig("Chat Settings", "Plugin Prefix", "[MBC] "));
            flamingtime = Convert.ToSingle(GetConfig("Flames Settings", "Duration in seconds", "30"));
            cakename    = Convert.ToString(GetConfig("Cake Settings", "Name", "Birthday SPECIAL EDITION"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Exemple #6
0
 private static void RegisterSingleConversions(
     DefaultTypeConverter registry)
 {
     registry.Register <float, byte>(from => SysConv.ToByte(from));
     registry.Register <float, short>(from => SysConv.ToInt16(from));
     registry.Register <float, int>(from => SysConv.ToInt32(from));
     registry.Register <float, long>(from => SysConv.ToInt64(from));
     registry.Register <float, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <float, uint>(from => SysConv.ToUInt32(from));
     registry.Register <float, ulong>(from => SysConv.ToUInt64(from));
     registry.Register <float, decimal>(from => SysConv.ToDecimal(from));
     registry.Register <float, double>(from => SysConv.ToDouble(from));
     registry.Register <float, string>(from =>
                                       from.ToString(CultureInfo.InvariantCulture));
 }
 private static void RegisterDoubleConversions(
     ITypeConverterRegistry registry)
 {
     registry.Register <double, byte>(from => SysConv.ToByte(from));
     registry.Register <double, short>(from => SysConv.ToInt16(from));
     registry.Register <double, int>(from => SysConv.ToInt32(from));
     registry.Register <double, long>(from => SysConv.ToInt64(from));
     registry.Register <double, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <double, uint>(from => SysConv.ToUInt32(from));
     registry.Register <double, ulong>(from => SysConv.ToUInt64(from));
     registry.Register <double, decimal>(from => SysConv.ToDecimal(from));
     registry.Register <double, float>(from => SysConv.ToSingle(from));
     registry.Register <double, string>(from =>
                                        from.ToString(CultureInfo.InvariantCulture));
 }
        private void LoadVariables()
        {
            Prefix         = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[CANNIBAL] "));                                                              // CHAT PLUGIN PREFIX
            PrefixColor    = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#bf0000"));                                                             // CHAT PLUGIN PREFIX COLOR
            ChatColor      = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#dd8e8e"));                                                               // CHAT MESSAGE COLOR
            SteamIDIcon    = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", 76561198261703362));                                                     // SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / 76561198842176097 /
            experiencetime = Convert.ToInt32(GetConfig("Minimum time to play as cannibal, before being able to toggle it off", "in real time minutes", "1440")); // WINNER NAME COLOR

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Exemple #9
0
 private void KillMyMinicopterConsoleCommand(ConsoleSystem.Arg arg)
 {
     if (arg.Args.Length == 1)
     {
         ulong steamid = Convert.ToUInt64(arg.Args[0]);
         if (steamid == null)
         {
             return;
         }
         if (steamid.IsSteamId() == false)
         {
             return;
         }
         BasePlayer player = BasePlayer.FindByID(steamid);
         KillMyMinicopterPlease(player);
     }
 }
Exemple #10
0
        private async Task _postTimer_Elapsed()
        {
            DiscordContext context = new DiscordContext();

            foreach (var channelId in context.SabrinaSettings.Select(ss => ss.FeetChannel).Where(cId => cId != null))
            {
                var channel = await _client.GetChannelAsync(Convert.ToUInt64(channelId));

                try
                {
                    await Task.Run(async() => await PostRandom(channel));
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error in Sankakubot PostRandom");
                    Console.WriteLine(e);
                }
            }
        }
Exemple #11
0
        private async Task PostTimer_Elapsed()
        {
            using DiscordContext context = new DiscordContext();

            foreach (var channelId in context.SabrinaSettings.Select(ss => ss.FeetChannel).Where(cId => cId != null))
            {
                DiscordChannel channel = null;

                if (_client.Guilds.Any(g => g.Value.Channels.Any(c => c.Key == Convert.ToUInt64(channelId))))
                {
                    channel = await _client.GetChannelAsync(Convert.ToUInt64(channelId));

                    try
                    {
                        await PostRandom(channel);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error in Sankakubot PostRandom");
                        Console.WriteLine(e);
                    }
                }
            }
        }
Exemple #12
0
		ulong IConvertible.ToUInt64 (IFormatProvider provider)
		{
			return Convert.ToUInt64 (Value, provider);
		}
Exemple #13
0
		public static string Format (Type enumType, object value, string format)
		{
			if (enumType == null)
				throw new ArgumentNullException ("enumType");
			if (value == null)
				throw new ArgumentNullException ("value");
			if (format == null)
				throw new ArgumentNullException ("format");

			if (!enumType.IsEnum)
				throw new ArgumentException ("enumType is not an Enum type.", "enumType");
			
			Type vType = value.GetType();
			Type underlyingType = Enum.GetUnderlyingType (enumType);
			if (vType.IsEnum) {
				if (vType != enumType)
					throw new ArgumentException (string.Format(CultureInfo.InvariantCulture,
						"Object must be the same type as the enum. The type" +
						" passed in was {0}; the enum type was {1}.",
						vType.FullName, enumType.FullName));
			} else if (vType != underlyingType) {
				throw new ArgumentException (string.Format (CultureInfo.InvariantCulture,
					"Enum underlying type and the object must be the same type" +
					" or object. Type passed in was {0}; the enum underlying" +
					" type was {1}.", vType.FullName, underlyingType.FullName));
			}

			if (format.Length != 1)
				throw new FormatException ("Format String can be only \"G\",\"g\",\"X\"," + 
					"\"x\",\"F\",\"f\",\"D\" or \"d\".");

			char formatChar = format [0];
			string retVal;
			if ((formatChar == 'G' || formatChar == 'g')) {
				if (!enumType.IsDefined (typeof(FlagsAttribute), false)) {
					retVal = GetName (enumType, value);
					if (retVal == null)
						retVal = value.ToString();

					return retVal;
				}

				formatChar = 'f';
			}
			
			if ((formatChar == 'f' || formatChar == 'F'))
				return FormatFlags (enumType, value);

			retVal = String.Empty;
			switch (formatChar) {
			case 'X':
				retVal = FormatSpecifier_X (enumType, value, true);
				break;
			case 'x':
				retVal = FormatSpecifier_X (enumType, value, false);
				break;
			case 'D':
			case 'd':
				if (underlyingType == typeof (ulong)) {
					ulong ulongValue = Convert.ToUInt64 (value);
					retVal = ulongValue.ToString ();
				} else {
					long longValue = Convert.ToInt64 (value);
					retVal = longValue.ToString ();
				}
				break;
			default:
				throw new FormatException ("Format String can be only \"G\",\"g\",\"X\"," + 
					"\"x\",\"F\",\"f\",\"D\" or \"d\".");
			}
			return retVal;
		}
Exemple #14
0
 ulong IConvertible.ToUInt64(IFormatProvider provider)
 {
     return(Convert.ToUInt64(this));
 }
Exemple #15
0
 /// <internalonly/>
 ulong IConvertible.ToUInt64(IFormatProvider provider)
 {
     return(Convert.ToUInt64(m_value));
 }
        protected static internal object ConvertValue(Type type, NSJSValue value)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            object o = FetchValue(type, value);

            if (type == typeof(int))
            {
                o = (o == null ? 0 : Converter.ToInt32(o));
            }
            else if (type == typeof(uint))
            {
                o = (o == null ? 0u : Converter.ToUInt32(o));
            }
            else if (type == typeof(short))
            {
                o = (o == null ? (short)0 : Converter.ToInt16(o));
            }
            else if (type == typeof(ushort))
            {
                o = (o == null ? (ushort)0 : Converter.ToUInt16(o));
            }
            else if (type == typeof(sbyte))
            {
                o = (o == null ? (sbyte)0 : Converter.ToSByte(o));
            }
            else if (type == typeof(byte))
            {
                o = (o == null ? (byte)0 : Converter.ToByte(o));
            }
            else if (type == typeof(long))
            {
                o = (o == null ? 0L : Converter.ToInt64(o));
            }
            else if (type == typeof(ulong))
            {
                o = (o == null ? 0ul : Converter.ToUInt64(o));
            }
            else if (type == typeof(float))
            {
                o = (o == null ? 0f : Converter.ToSingle(o));
            }
            else if (type == typeof(double))
            {
                o = (o == null ? 0d : Converter.ToDouble(o));
            }
            else if (type == typeof(decimal))
            {
                o = (o == null ? 0m : Converter.ToDecimal(o));
            }
            else if (type == typeof(char))
            {
                o = (o == null ? '\0' : Converter.ToChar(o));
            }
            else if (type == typeof(DateTime))
            {
                long ticks = 0;
                if (o is long)
                {
                    ticks = (long)o;
                }
                else if (o != null)
                {
                    ticks = Converter.ToInt64(o);
                }
                o = NSJSDateTime.LocalDateToDateTime(ticks);
            }
            else if (type == typeof(string))
            {
                if (o == null)
                {
                    o = null;
                }
                else if (!(o is string))
                {
                    o = o.ToString();
                }
            }
            else if (typeof(NSJSValue).IsAssignableFrom(type))
            {
                return(type.IsInstanceOfType(value) ? value : null);
            }
            return(o);
        }
Exemple #17
0
 public ulong ToUInt64(object value) 
     => SystemConvert.ToUInt64(value);
Exemple #18
0
        // Special coersion rules for primitives, enums and pointer.
        private static Exception ConvertOrWidenPrimitivesEnumsAndPointersIfPossible(object srcObject, EETypePtr srcEEType, EETypePtr dstEEType, CheckArgumentSemantics semantics, out object?dstObject)
        {
            if (semantics == CheckArgumentSemantics.SetFieldDirect && (srcEEType.IsEnum || dstEEType.IsEnum))
            {
                dstObject = null;
                return(CreateChangeTypeException(srcEEType, dstEEType, semantics));
            }

            if (dstEEType.IsPointer)
            {
                Exception exception = ConvertPointerIfPossible(srcObject, srcEEType, dstEEType, semantics, out IntPtr dstIntPtr);
                if (exception != null)
                {
                    dstObject = null;
                    return(exception);
                }
                dstObject = dstIntPtr;
                return(null);
            }

            if (!(srcEEType.IsPrimitive && dstEEType.IsPrimitive))
            {
                dstObject = null;
                return(CreateChangeTypeException(srcEEType, dstEEType, semantics));
            }

            CorElementType dstCorElementType = dstEEType.CorElementType;

            if (!srcEEType.CorElementTypeInfo.CanWidenTo(dstCorElementType))
            {
                dstObject = null;
                return(CreateChangeTypeArgumentException(srcEEType, dstEEType));
            }

            switch (dstCorElementType)
            {
            case CorElementType.ELEMENT_TYPE_BOOLEAN:
                bool boolValue = Convert.ToBoolean(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, boolValue ? 1 : 0) : boolValue;
                break;

            case CorElementType.ELEMENT_TYPE_CHAR:
                char charValue = Convert.ToChar(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, charValue) : charValue;
                break;

            case CorElementType.ELEMENT_TYPE_I1:
                sbyte sbyteValue = Convert.ToSByte(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, sbyteValue) : sbyteValue;
                break;

            case CorElementType.ELEMENT_TYPE_I2:
                short shortValue = Convert.ToInt16(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, shortValue) : shortValue;
                break;

            case CorElementType.ELEMENT_TYPE_I4:
                int intValue = Convert.ToInt32(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, intValue) : intValue;
                break;

            case CorElementType.ELEMENT_TYPE_I8:
                long longValue = Convert.ToInt64(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, longValue) : longValue;
                break;

            case CorElementType.ELEMENT_TYPE_U1:
                byte byteValue = Convert.ToByte(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, byteValue) : byteValue;
                break;

            case CorElementType.ELEMENT_TYPE_U2:
                ushort ushortValue = Convert.ToUInt16(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, ushortValue) : ushortValue;
                break;

            case CorElementType.ELEMENT_TYPE_U4:
                uint uintValue = Convert.ToUInt32(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, uintValue) : uintValue;
                break;

            case CorElementType.ELEMENT_TYPE_U8:
                ulong ulongValue = Convert.ToUInt64(srcObject);
                dstObject = dstEEType.IsEnum ? Enum.ToObject(dstEEType, (long)ulongValue) : ulongValue;
                break;

            case CorElementType.ELEMENT_TYPE_R4:
                if (srcEEType.CorElementType == CorElementType.ELEMENT_TYPE_CHAR)
                {
                    dstObject = (float)(char)srcObject;
                }
                else
                {
                    dstObject = Convert.ToSingle(srcObject);
                }
                break;

            case CorElementType.ELEMENT_TYPE_R8:
                if (srcEEType.CorElementType == CorElementType.ELEMENT_TYPE_CHAR)
                {
                    dstObject = (double)(char)srcObject;
                }
                else
                {
                    dstObject = Convert.ToDouble(srcObject);
                }
                break;

            default:
                Debug.Fail("Unexpected CorElementType: " + dstCorElementType + ": Not a valid widening target.");
                dstObject = null;
                return(CreateChangeTypeException(srcEEType, dstEEType, semantics));
            }

            Debug.Assert(dstObject.GetEETypePtr() == dstEEType);
            return(null);
        }