private SvgDocument LoadSvg(Stream sourceStream) { try { return(SvgDocument.Open <SvgDocument>(sourceStream)); } catch { throw new RequestInputException(Localized.Get("SvgImageCanNotBeLoaded")); } }
public string GetLocalizedString(Localized enumIdentifier) { var identifier = enumIdentifier.ToString().Replace('_', '.'); var localizedString = GetLocalizedString(identifier); if (localizedString.IsNullOrEmpty()) { _loggingService.Report(new LocalizationException(enumIdentifier), this); } return(localizedString); }
public string GetLocalizedString(Localized identifier) { var strIdent = identifier.ToString(); var translation = GetLocalizedString(strIdent); if (translation == strIdent) { _loggingService.Report(new LocalizationException(identifier), this); } return(translation); }
public List <Place> GetPlacesLocalized(Localized localized = Localized.English) { string local = localized == Localized.Arabic ? "$.ar" : localized == Localized.French ? "$.fr" : "$.en"; return(_context.Places.SqlQuery("SELECT Id, name-> @p0 as Name FROM places", new[] { local }) .Select(x => new Place { Id = x.Id, Name = x.Name.Replace("\"", string.Empty).Trim() }) .ToList()); }
protected override async Task <ResultWithMetrologyProperties <Result> > DoRunAsync(Request request) { var owner = await DbContext.Users.SingleAsync(u => u.Id == request.Owner); var image = new Domain.Image { Name = request.Name, Description = request.Description, Source = request.Source, Owner = owner, VersionDescription = Localized.Get("InitialImageVersionCreation"), VersionType = ImageVersionType.Creation, InitialUploadUtcDate = runDate ?? DateTime.UtcNow }; image.LastChangeUtcDate = image.InitialUploadUtcDate; image.OriginalContentType = request.ContentType; image.OriginalSize = request.Blob.Length; image.OriginalBlob = request.Blob; using var sourceStream = new MemoryStream(request.Blob); using var originalImage = GetBitmap(sourceStream, request.ContentType); image.SmallBlob = ResizeImage(originalImage, 100); image.SmallBlobSize = image.SmallBlob.Length; image.MediumBlob = ResizeImage(originalImage, 600); image.MediumBlobSize = image.MediumBlob.Length; image.BigBlob = ResizeImage(originalImage, bigImageWidth); image.BigBlobSize = image.BigBlob.Length; DbContext.Images.Add(image); await DbContext.SaveChangesAsync(); return(new ResultWithMetrologyProperties <Result>(new Result(), ("ImageName", request.Name.ToString()), ("DescriptionLength", request.Description.Length.ToString()), ("SourceFieldLength", request.Source.Length.ToString()), ("ContentType", request.ContentType), ("ImageSize", image.OriginalSize.ToString()) )); }
protected override async Task <ResultWithMetrologyProperties <Result> > DoRunAsync(Request request) { var tagName = await DbContext.Tags.Where(tag => tag.Id == request.TagId).Select(tag => tag.Name).SingleAsync(); var previousVersionCreator = new PreviousVersionCreator(DbContext); foreach (var cardId in request.CardIds) { if (!DbContext.TagsInCards.Any(tagInCard => tagInCard.CardId == cardId && tagInCard.TagId == request.TagId)) { var card = await previousVersionCreator.RunAsync(cardId, request.VersionCreator.Id, Localized.Get("AddTag") + $" '{tagName}'"); card.VersionCreator = request.VersionCreator; //A priori inutile, à confirmer DbContext.TagsInCards.Add(new TagInCard() { TagId = request.TagId, CardId = cardId }); } } await DbContext.SaveChangesAsync(); return(new ResultWithMetrologyProperties <Result>(new Result(), ("TagId", request.TagId.ToString()), ("TagName", tagName), ("CardCount", request.CardIds.Count().ToString()))); }
public override int GetHashCode() => Localized.GetHashCode();
public string GetLocalizedString(Localized identifier) => identifier.ToString();
public void GetDescription_Uses_Fallabck_When_Problem_With_DisplayAttribute(Localized value, string expected) { value.GetDescription().Should().Be(expected); }
public void GetDescription_Uses_DisplayAttribute(Localized value, string expected) { value.GetDescription().Should().Be(expected); }
public string Localize(string phraseKey) { return(Localized.Where(x => x.Key == phraseKey).SingleOrDefault().Value); }
protected override async Task <ResultWithMetrologyProperties <Result> > DoRunAsync(Request request) { foreach (var cardId in request.CardIds) { var previousVersionCreator = new PreviousVersionCreator(DbContext); var card = await previousVersionCreator.RunAsync(cardId, request.UserId, Localized.Get("Deletion"), deletionUtcDate); await previousVersionCreator.RunForDeletionAsync(card, deletionUtcDate); await DbContext.SaveChangesAsync(); var actualCard = await DbContext.Cards.SingleAsync(card => card.Id == cardId); DbContext.Cards.Remove(actualCard); await DbContext.SaveChangesAsync(); } return(new ResultWithMetrologyProperties <Result>(new Result(), ("CardCount", request.CardIds.Count().ToString()))); }
public LocalizationException(Localized identifier) : base($"No translation found for ${identifier}.") { }
public FirstName() { localized = new Localized(); preferredLocale = new PreferredLocale(); }