Example #1
0
        public void ParseGuid()
        {
            var parser           = new GuidParser();
            var input            = "05da4492-054d-48f9-8b0e-a0e90c2aee4b";
            var inputWithoutDash = "05da4492054d48f98b0ea0e90c2aee4b";

            var expected = Guid.Parse(input);

            Assert.AreEqual(parser.Parse(input), expected);
            Assert.AreEqual(parser.Parse(inputWithoutDash), expected);
        }
Example #2
0
        public Guid(string g)
        {
            CheckNull(g);
            g = g.Trim();
            GuidParser p    = new GuidParser(g);
            Guid       guid = p.Parse();

            this = guid;
        }
Example #3
0
        public void ThrowsParsingExceptionOnBadInput()
        {
            var parser = new GuidParser();
            var input  = "notactuallyaguid";

            var ex = Assert.Throws <ParsingException>(() => parser.Parse(input));

            Assert.That(ex.Input, Is.EqualTo(input));
            Assert.That(ex.TargetType, Is.EqualTo(typeof(Guid)));
        }
Example #4
0
File: Guid.cs Project: yonder/mono
        public static bool TryParse(string input, out Guid result)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            var parser = new GuidParser(input);

            return(parser.Parse(out result));
        }
Example #5
0
        public static bool TryParseExact(string input, string format, out Guid result)
        {
            if (input == null || format == null)
            {
                result = Empty;
                return(false);
            }

            var parser = new GuidParser(input);

            return(parser.Parse(ParseFormat(format), out result));
        }
Example #6
0
        public static bool TryParse(string input, out Guid result)
        {
            if (input == null)
            {
                result = Empty;
                return(false);
            }

            var parser = new GuidParser(input);

            return(parser.Parse(out result));
        }
Example #7
0
        public Guid(string g)
        {
            CheckNull(g);
            g = g.Trim();
            var  parser = new GuidParser(g);
            Guid guid;

            if (!parser.Parse(out guid))
            {
                throw CreateFormatException(g);
            }

            this = guid;
        }
Example #8
0
File: Guid.cs Project: yonder/mono
        public static bool TryParseExact(string input, string format, out Guid result)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            var parser = new GuidParser(input);

            return(parser.Parse(ParseFormat(format), out result));
        }
Example #9
0
File: Guid.cs Project: slagusev/api
        public Guid(string g)
        {
            CheckNull(g);
            g = g.Trim();
            var  parser = new GuidParser(g);
            Guid guid;

            if (!parser.Parse(out guid))
            {
                throw CreateFormatException(g);
            }

            _a = guid._a;
            _b = guid._b;
            _c = guid._c;
            _d = guid._d;
            _e = guid._e;
            _f = guid._f;
            _g = guid._g;
            _h = guid._h;
            _i = guid._i;
            _j = guid._j;
            _k = guid._k;
        }
 public static Either <TLeft, Guid> ParseToGuid <TLeft>(this string source, TLeft left)
 {
     return(GuidParser.Parse(source, left));
 }
 public static Either <TLeft, Guid> ParseToGuid <TLeft>(this Either <TLeft, string> source, TLeft left)
 {
     return(source.FlatMap(x => GuidParser.Parse(x, left)));
 }
Example #12
0
 public static Maybe <Guid> ParseToGuid(this string source)
 {
     return(GuidParser.Parse(source));
 }