public Guid(string g) { CheckNull(g); g = g.Trim(); GuidParser p = new GuidParser(g); Guid guid = p.Parse(); this = guid; }
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))); }
public void Run() { var service = XrmCommand.GetService(); var core = new SlaService(service); var parsedId = GuidParser.TryParseIdOrThrow(SlaId); var parsedBusinessId = core.TryGetBusinessHours(BusinessHoursId); core.UpdateSLA(parsedId, IsDefault, IsActive, parsedBusinessId); }
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); }
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)); }
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)); }
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)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { var v = GuidParser.Convert(value);// as Guid; var param = parameter.ToString(); return(v.GetObject(param)?.NameSearch); } catch { return(value); } }
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; }
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)); }
public void PopulatePossibleValues() { // Get possible values PossibleValues.Clear(); var type = GetTypeName(SelectedProeprty.PropertyType); HashSet <string> collections = new HashSet <string>(); foreach (var item in Inputs) { var val = _SelectedProeprty.GetValue(item, null)?.ToString(); if (val != null) { if (type == "Guid") { try { var attributes = _SelectedProeprty.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute; var option = attributes.Options; if (string.IsNullOrWhiteSpace(option) || option.Contains(">") || string.IsNullOrWhiteSpace(val)) { continue; } var link = DS.Generic(option)?.GetById(GuidParser.Convert(val));//, true) as IEnumerable<IDocument>; if (link == null) { continue; } collections.Add(link?.Name); StatusLabel = $"{_("Récupération des données")} - {link?.Name}"; NotifyOfPropertyChange("StatusLabel"); } catch (Exception s) { DataHelpers.ShowMessage(s.Message); } } else { collections.Add(val as string); } } } PossibleValues.AddRange(collections); StatusLabel = _($"Términé"); NotifyOfPropertyChange("StatusLabel"); NotifyOfPropertyChange("PossibleValues"); }
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 Maybe <Guid> ParseToGuid(this string source) { return(GuidParser.Parse(source)); }
string ToString(Format format) { int length; switch (format) { case Format.B: case Format.P: length = 38; break; case Format.D: length = 36; break; case Format.N: length = 32; break; case Format.X: length = 68; break; default: throw new NotImplementedException(format.ToString()); } StringBuilder res = new StringBuilder(length); bool has_hyphen = GuidParser.HasHyphen(format); if (format == Format.P) { res.Append('('); } else if (format == Format.B) { res.Append('{'); } else if (format == Format.X) { res.Append('{').Append('0').Append('x'); } AppendInt(res, _a); if (has_hyphen) { res.Append('-'); } else if (format == Format.X) { res.Append(',').Append('0').Append('x'); } AppendShort(res, _b); if (has_hyphen) { res.Append('-'); } else if (format == Format.X) { res.Append(',').Append('0').Append('x'); } AppendShort(res, _c); if (has_hyphen) { res.Append('-'); } if (format == Format.X) { res.Append(',').Append('{').Append('0').Append('x'); AppendByte(res, _d); res.Append(',').Append('0').Append('x'); AppendByte(res, _e); res.Append(',').Append('0').Append('x'); AppendByte(res, _f); res.Append(',').Append('0').Append('x'); AppendByte(res, _g); res.Append(',').Append('0').Append('x'); AppendByte(res, _h); res.Append(',').Append('0').Append('x'); AppendByte(res, _i); res.Append(',').Append('0').Append('x'); AppendByte(res, _j); res.Append(',').Append('0').Append('x'); AppendByte(res, _k); res.Append('}').Append('}');; } else { AppendByte(res, _d); AppendByte(res, _e); if (has_hyphen) { res.Append('-'); } AppendByte(res, _f); AppendByte(res, _g); AppendByte(res, _h); AppendByte(res, _i); AppendByte(res, _j); AppendByte(res, _k); if (format == Format.P) { res.Append(')'); } else if (format == Format.B) { res.Append('}'); } } return(res.ToString()); }
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))); }
public Client() { Series = GuidParser.Convert((MyModuleBase())?.SeriesDefault); }
public async Task <ApiResponse <Unit> > Delete(string fuelingId) => await GuidParser.ParseGuid(fuelingId) .ToResult(Errors.Error($"Provided id was in incorrect format: {fuelingId}")) .BindAsync(id => Storage.Delete(id)) .DoWhenErrorAsync(e => Logger.Warn(e.Message, e.Exception)) .ToResponseAsync();
public AssignWorkflowsToUser(string connectionString, string userId) { XrmCommand = new XrmCommand(connectionString); UserId = GuidParser.TryParseIdOrThrow(userId); }
public AssignWorkflowsToUser(IXrmCommand xrmCommand, string userId, IWorkflowService service = null) { XrmCommand = xrmCommand; UserId = GuidParser.TryParseIdOrThrow(userId); WorkflowService = service; }