コード例 #1
0
        public void Decode_0H_17()
        {
            const string input  = "0H";
            long         result = Base36.Decode(input);

            Assert.AreEqual(17L, result);
        }
コード例 #2
0
ファイル: BMSChart.cs プロジェクト: riku0623/Lanotalium
        private static bool ParseSummary(string command2, string strParam1, string strParam2, HashSet <int> channels, out int combos)
        {
            int verse;

            if (!int.TryParse(command2, out verse))
            {
                combos = 0;
                return(false);
            }
            int channel = GetChannelNumberById(strParam2);

            if ((channel > 10 && channel < 30) || (channel > 50 && channel < 70))
            {
                channels.Add(channel);
                int lCombos = 0;
                for (int i = 0, length = strParam1.Length / 2; i < length; i++)
                {
                    int value = Base36.Decode(strParam1.Substring(i * 2, 2));
                    if (value > 0)
                    {
                        lCombos++;
                    }
                }
                combos = lCombos;
                return(true);
            }
            combos = 0;
            return(false);
        }
コード例 #3
0
ファイル: Base36Tests.cs プロジェクト: devopskartik/ndc-bingo
        public void EncodesAndDecodes(long expected)
        {
            var code   = Base36.Encode(expected);
            var actual = Base36.Decode(code);

            Assert.Equal(expected, actual);
        }
コード例 #4
0
        public void Decode_100000000_2821109907456()
        {
            const string input  = "100000000";
            long         result = Base36.Decode(input);

            Assert.AreEqual(2821109907456L, result);
        }
コード例 #5
0
        public void Decode_CRE66I9S_1000000000000()
        {
            const string input  = "CRE66I9S";
            long         result = Base36.Decode(input);

            Assert.AreEqual(1000000000000L, result);
        }
コード例 #6
0
ファイル: RsmqCsharp.cs プロジェクト: tontonrally/rsmqCsharp
        /// <summary>
        /// Asynchronously receive the next message from the queue and delete it.
        ///
        /// Important: This method deletes the message it receives right away. There is no way to receive the message again if something goes wrong while working on the message.
        ///
        /// returns null if no message is there
        /// </summary>
        public async Task <RsmqMessage> PopMessageAsync(PopMessageOptions options)
        {
            // todo: validate (qname)
            var key = $"{this._options.Namespace}:{options.QueueName}";
            var q   = await this.GetQueue(options.QueueName);

            var res = await _popMessage.EvaluateAsync(
                this.RedisClient,
                new
            {
                key       = key,
                timestamp = q.Timestamp
            }
                );

            var vals = (string[])res;

            if (vals.Length != 4)
            {
                return(null);
            }

            return(new RsmqMessage
            {
                Id = vals[0],
                Message = vals[1],
                ReceivedCount = int.Parse(vals[2]),
                FirstReceived = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(vals[3])).UtcDateTime,
                Sent = DateTimeOffset.FromUnixTimeMilliseconds(Base36.Decode(vals[0].Substring(0, 10)) / 1000).UtcDateTime
            });
        }
コード例 #7
0
ファイル: RsmqCsharp.cs プロジェクト: tontonrally/rsmqCsharp
        /// <summary>
        /// Asynchronously receive the next message from the queue.
        /// </summary>
        public async Task <RsmqMessage> ReceiveMessageAsync(ReceiveMessageOptions options)
        {
            Validate(options, "QueueName");
            var q = await this.GetQueue(options.QueueName);

            options.VisibilityTimer = options.VisibilityTimer.HasValue ? options.VisibilityTimer.Value : q.VisibilityTimer;
            Validate(options);

            var res = await _receiveMessage.EvaluateAsync(
                this.RedisClient,
                new
            {
                key              = (RedisKey)$"{this._options.Namespace}:{options.QueueName}",
                timestamp        = q.Timestamp,
                timestampTimeout = q.Timestamp + options.VisibilityTimer * 1000
            }
                );

            var vals = (string[])res;

            if (vals.Length != 4)
            {
                return(null);
            }

            return(new RsmqMessage
            {
                Id = vals[0],
                Message = vals[1],
                ReceivedCount = int.Parse(vals[2]),
                FirstReceived = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(vals[3])).UtcDateTime,
                Sent = DateTimeOffset.FromUnixTimeMilliseconds(Base36.Decode(vals[0].Substring(0, 10)) / 1000).UtcDateTime
            });
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: polytronicgr/GalaxyE
        static void Main(string[] args)
        {
            Sector sector = new Sector(
                (uint)Base36.Decode("368"), (uint)Base36.Decode("4V5"));


            Console.ReadLine();
        }
コード例 #9
0
        public void Decode_A_Returns10()
        {
            long expected = 10;

            long actual = Base36.Decode("a");

            Assert.That(actual, Is.EqualTo(expected));
        }
コード例 #10
0
        public void Decode_Z_Returns35()
        {
            long expected = 35;

            long actual = Base36.Decode("z");

            Assert.That(actual, Is.EqualTo(expected));
        }
コード例 #11
0
        public void Static_Decoding_IsCorrect()
        {
            const ulong  output = 292_756_934_830;
            const string input  = "3QHNX4MM";

            var result = Base36.Decode(input);

            Assert.Equal(output, result);
        }
コード例 #12
0
        public void Decode_null_ArgumentNullException()
        {
            // Arrange
            string data = default;

            // Act

            // Assert
            Assert.ThrowsException <ArgumentNullException>(() => Base36.Decode(data));
        }
コード例 #13
0
        public void Decode_7CLZzI_FormatException()
        {
            // Arrange
            string data = "7CLZzI";

            // Act

            // Assert
            Assert.ThrowsException <FormatException>(() => Base36.Decode(data));
        }
コード例 #14
0
        public void Decode_7CLZI_12345678()
        {
            // Arrange
            int    expected = 12345678;
            string data     = "7CLZI";

            // Act
            var result = Base36.Decode(data);

            // Assert
            Assert.AreEqual(expected, result);
        }
コード例 #15
0
            private bool ParseFileName(string filename, out int x, out int z)
            {
                x = 0;
                z = 0;

                Match match = _namePattern.Match(filename);

                if (!match.Success)
                {
                    return(false);
                }

                x = (int)Base36.Decode(match.Groups[1].Value);
                z = (int)Base36.Decode(match.Groups[2].Value);
                return(true);
            }
コード例 #16
0
ファイル: MinifyRec.cs プロジェクト: lapierj01/project8765
    //Query the NOSQL DB to get the URL
    public static string GetUrl(string Base36ID)
    {
        // Open database (or create if not exits)
        using (var db = new LiteDatabase(HttpContext.Current.Server.MapPath("~/") + @"Minify.db"))
        {
            var col = db.GetCollection <MinifyRec>("MinifyRec");

            // Use Linq to query documents
            //var results = col.Find(x => x.Id.StartsWith("Jo"));
            //var results = col.Find(x => x.Id.Equals(Base36.Decode(Base36ID)));
            //var results = col.Find(Query.EQ("Id", Base36.Decode(Base36ID)));


            int Id2Find; Int32.TryParse(Base36.Decode(Base36ID).ToString(), out Id2Find);

            if (Id2Find > 0)
            {
                var results = col.FindById(Id2Find);

                if (results == null)
                {
                    return("");
                }
                else
                {
                    // Update a visit a collection
                    results.Visits = results.Visits + 1;
                    col.Update(results);

                    //Check URL validity end add HTTP if not specified
                    if (!results.Url.Contains("http://"))
                    {
                        if (!results.Url.Contains("https://"))
                        {
                            results.Url = "http://" + results.Url;
                        }
                    }

                    return(results.Url);
                }
            }
            else
            {
                return("");
            }
        }
    }
コード例 #17
0
ファイル: BMSChart.cs プロジェクト: riku0623/Lanotalium
        /*
         *  Special mapping for channels
         *  01 = 1, 02 = 2, ..., 09 = 9,
         *  0A = 1010, 0B = 1011, ... 0Z = 1035,
         *  11 = 11, 12 = 12, ... 19 = 19,
         *  1A = 1110, 1B = 1111, ..., 1Z = 1135,
         *  ...,
         *  2A = 1210, 2B = 1211, ..., 2Z = 1235,
         *  ...,
         *  Z1 = 351, Z2 = 352, ..., Z9 = 359,
         *  ZA = 4510, ZB = 4511, ..., ZZ = 4535
         *  Illegal channel format: -99
         */
        private static int GetChannelNumberById(string channel)
        {
            if (string.IsNullOrEmpty(channel) || channel.Length > 2)
            {
                return(-99);
            }
            int channelRaw = Base36.Decode(channel);

            if (channelRaw < 0)
            {
                return(-99);
            }
            int digit1 = channelRaw % 36, digit2 = channelRaw / 36;
            int result = digit1 > 9 ? (digit2 * 100 + digit1 + 1000) : (digit2 * 10 + digit1);

            return(result);
        }
コード例 #18
0
ファイル: CustomId.cs プロジェクト: DDROrg/MyCommunity
        public static Guid ToGuidId(this string id)
        {
            try
            {
                // replace Square shape in UTF8 with ascii dash (-) see
                id = id.Replace((char)8208, (char)45);
                id = id.Replace("-", String.Empty).ToUpper();
                ulong  lCustomerId       = Base36.Decode(id);
                byte[] bitConvertedBytes = BitConverter.GetBytes(lCustomerId);
                byte[] guidBytes         = new byte[16];
                bitConvertedBytes.CopyTo(guidBytes, 8);

                Guid resultGuid = new Guid(guidBytes);
                return(resultGuid);
            }
            catch (Exception)
            {
                return(Guid.Empty);
            }
        }
コード例 #19
0
ファイル: ChunkFile.cs プロジェクト: AlphaDelta/SharpBukkit
        public ChunkFile(string file)
        {
            // Referenced classes of package net.minecraft.src:
            //            ChunkFilePattern
            field_22209_a = file;
            //java.util.regex.Matcher matcher = net.minecraft.src.ChunkFilePattern.field_22119_a
            //	.Matcher(file.GetName());
            var m = ChunkFilePattern.field_22119_a.Match(file);

            if (m.Success)
            {
                field_22208_b = (int)Base36.Decode(m.Groups[1].Value);
                field_22210_c = (int)Base36.Decode(m.Groups[2].Value);
            }
            else
            {
                field_22208_b = 0;
                field_22210_c = 0;
            }
        }
コード例 #20
0
ファイル: RIF.cs プロジェクト: dsdude123/CosmosRIF
        private void draw(Canvas c, int x, int y)
        {
            List <int> imageData = new List <int>();

            int h = (int)Base36.Decode(readHelper());
            int v = (int)Base36.Decode(readHelper());


            int i;

            for (i = 0; i < v; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    String nextVal = readHelper();
                    Color  pixel;
                    if (nextVal.Contains("&"))
                    {
                        int idx = (int)Base36.Decode(nextVal.Substring(1));
                        pixel = Color.FromArgb((int)imageData[idx]);
                    }
                    else
                    {
                        int argb;
                        if (nextVal.Contains("+"))
                        {
                            argb  = (int)Base36.Decode(nextVal.Substring(1));
                            pixel = Color.FromArgb(argb);
                        }
                        argb = -(int)Base36.Decode(nextVal);
                        imageData.Add(argb);
                        pixel = Color.FromArgb(argb);
                    }

                    Pen color = new Pen(pixel);
                    c.DrawPoint(color, x + j, y + i);
                }
            }
        }
コード例 #21
0
ファイル: BMSChart.cs プロジェクト: riku0623/Lanotalium
        private bool ParseResourceLine(string command2, string strParam1, string strParam2)
        {
            switch (command2)
            {
            case "wav":
                AddResource(ResourceType.wav, Base36.Decode(strParam2), strParam1);
                break;

            case "bmp":
                AddResource(ResourceType.bmp, Base36.Decode(strParam2), strParam1);
                break;

            case "bga":
                string[] strParams = strParam1.Split(' ');
                AddResource(ResourceType.bga, Base36.Decode(strParam2), string.Empty, new object[] {
                    Base36.Decode(strParams[0]),   // index
                    float.Parse(strParams[1]),     // x1
                    float.Parse(strParams[2]),     // x2
                    float.Parse(strParams[3]),     // y1
                    float.Parse(strParams[4]),     // y2
                    float.Parse(strParams[5]),     // dx
                    float.Parse(strParams[6])      // dy
                });
                break;

            case "bpm":
                AddResource(ResourceType.bpm, Base36.Decode(strParam2), string.Empty, float.Parse(strParam1));
                break;

            case "stop":
                AddResource(ResourceType.stop, Base36.Decode(strParam2), string.Empty, float.Parse(strParam1));
                break;

            default: return(false);
            }
            return(true);
        }
コード例 #22
0
ファイル: BMSChart.cs プロジェクト: riku0623/Lanotalium
        private static bool ParseContentLine(string command2, string strParam1, string strParam2, List <BMSEvent> bmev)
        {
            int verse;

            if (!int.TryParse(command2, out verse))
            {
                return(false);
            }
            int channel = GetChannelNumberById(strParam2);

            if (channel < 0)
            {
                return(false);
            }
            strParam1 = spaceMatcher.Replace(strParam1, string.Empty);
            int          length = strParam1.Length / 2;
            BMSEventType evType;

            switch (channel)
            {
            case 1: evType = BMSEventType.WAV; break;

            case 2:
                bmev.InsertInOrdered(new BMSEvent
                {
                    measure = verse,
                    beat    = 0,
                    Data2F  = double.Parse(strParam1),
                    type    = BMSEventType.BeatReset
                });
                return(true);

            case 3: evType = BMSEventType.BPM; break;

            case 4:
            case 6:
            case 7: evType = BMSEventType.BMP; break;

            case 8: evType = BMSEventType.BPM; break;

            case 9: evType = BMSEventType.STOP; break;

            default:
                if (channel > 10 && channel < 30)
                {
                    evType = BMSEventType.Note;
                }
                else if (channel > 50 && channel < 70)
                {
                    evType = BMSEventType.LongNoteStart;
                }
                else
                {
                    evType = BMSEventType.Unknown;
                }
                break;
            }
            for (int i = 0; i < length; i++)
            {
                int value = Base36.Decode(strParam1.Substring(i * 2, 2));
                if (value > 0)
                {
                    bmev.InsertInOrdered(new BMSEvent
                    {
                        measure = verse,
                        beat    = (float)i / length,
                        type    = evType,
                        data1   = channel,
                        data2   = value
                    }, null, 0, -1, false);
                }
            }
            return(true);
        }
コード例 #23
0
 public void Base36DecodeTest()
 {
     Assert.AreEqual(107, Base36.Decode("2Z"));
 }
コード例 #24
0
 public void When_decoding() => Base36.Decode("A").ShouldBe(10);