public LinkResource Execute() { var link = _repository.CreateShortUrl(_linkResource.LongUrl); LinkMapper mapper = new LinkMapper(); return(mapper.Map(link)); }
public LinkMapperTests() { context = new LinkFactoryContext(); httpLink = new HttpLink(TestHref, TestHttpMethod); sut = new LinkMapper <HttpLink>(context, httpLink); }
public void MapShouldConvertDataProperly() { // Arrange var readerService = A.Fake <ISqliteDataReaderService>(); A.CallTo(() => readerService.GetInt64(A <IDataReader> .Ignored, "rowid", A <long> .Ignored)) .Returns(42); A.CallTo(() => readerService.GetInt64(A <IDataReader> .Ignored, "UserId", A <long> .Ignored)) .Returns(12); A.CallTo(() => readerService.GetInt64(A <IDataReader> .Ignored, "Redirects", A <long> .Ignored)) .Returns(24); A.CallTo(() => readerService.GetString(A <IDataReader> .Ignored, "Url", A <string> .Ignored)) .Returns("some url"); A.CallTo(() => readerService.GetDateTime(A <IDataReader> .Ignored, "CreationDate", A <DateTime> .Ignored)) .Returns(new DateTime(2012, 1, 1)); var mapper = new LinkMapper(readerService); // Act var result = mapper.Map(null) as Link; // Assert Assert.That(result.Id, Is.EqualTo(42)); Assert.That(result.CreationDate, Is.EqualTo(new DateTime(2012, 1, 1))); Assert.That(result.Redirects, Is.EqualTo(24)); Assert.That(result.Url, Is.EqualTo("some url")); Assert.That(result.UserId, Is.EqualTo(12)); }
public LinkResource Run() { var link = _repository.GetById(_linkId); LinkMapper mapper = new LinkMapper(); return(mapper.Map(link)); }
public IEnumerable <LinkResource> Run() { var links = _repository.GetAll(); LinkMapper mapper = new LinkMapper(); return(mapper.Map(links)); }
protected string GetMediaUrl(CommerceMedia media) { if (media == null) { return(String.Empty); } var contentLinkMap = LinkMapper.Find(new Guid(media.AssetKey)); if (contentLinkMap == null) { return(String.Empty); } return(contentLinkMap.MappedUrl.ToString()); }
/// <summary> /// Maps a <see cref="LinkMapper{TValue}"/> to the corresponding <see cref="JProperty"/> /// in the current <see cref="JObject"/>. A <see cref="JProperty"/> will be created if /// one doesn't already exist (with a default value). /// </summary> /// <typeparam name="TEntity">The property value type.</typeparam> /// <param name="propertyMapper">The property mapper.</param> /// <param name="reload">Optionally specifies that the model is being reloaded.</param> /// <returns><c>true</c> if the mapped value changed.</returns> /// <remarks> /// <note> /// Pass <paramref name="reload"/>=<c>true</c> to reload data from a new /// <see cref="JObject"/> into the model. In this case, the implementation /// must ensure that all appropriate property and collection change notifications /// are raised to ensure that any listening UX elements will be updated. /// </note> /// </remarks> protected bool MapProperty <TEntity>(ref LinkMapper <TEntity> propertyMapper, bool reload = false) where TEntity : class, IDynamicEntity, new() { var jsonName = propertyMapper.JsonName; var jProperty = JObject.Properties().SingleOrDefault(p => p.Name == jsonName); if (jProperty == null) { jProperty = new JProperty(propertyMapper.JsonName, default); JObject.Add(jProperty); } return(propertyMapper.Load(jProperty, reload)); }
static void ConvertBlog(string inputXml, string outDir) { BlogMLBlog blog; using (var fs = File.OpenRead(inputXml)) { blog = BlogMLSerializer.Deserialize(fs); } // Load the document and set the root element. var blogDoc = new XmlDocument(); using (XmlTextReader tr = new XmlTextReader(inputXml)) { tr.Namespaces = false; blogDoc.Load(inputXml); } var categories = blog.Categories .Select(cat => new CategoryRef { Title = cat.Title, Id = cat.ID }) .ToDictionary(x => x.Id); var convertedPostCount = 0; ITextFormatter textFormatter = new DefaultTextFormatter(); IBlogUrlConverter blogUrlConverter = new TechnologyToolboxBlogUrlConverter(); IBlogAttachmentService blogPostAttachmentService = new TechnologyToolboxBlogAttachmentService(); ICodeBlockAnalyzer codeBlockAnalyzer = new OneNoteCodeBlockAnalyzer(); var reverseMarkdownConfig = new Config { CodeBlockLanguageMapper = new TechnologyToolboxCodeBlockLanguageMapper(), EmphasisChar = '_', GithubFlavored = true, HorizontalRuleString = "---", ListNumberingStyle = ListNumberingStyle.AlwaysOne, RemoveExcessIndentationFromCode = true, RemoveTrailingWhitespaceFromCode = true }; var imageUrlMapper = new TechnologyToolboxImageUrlMapper(); var linkMapper = new LinkMapper(blogUrlConverter); blog.Posts.ForEach(post => { var pipeline = new BlogPostConversionPipelineBuilder() .ForPost(post) .WithOutputDirectory(outDir) .AddStep(new SlugDeterminationStep(blogUrlConverter)) .AddStep(new TechnologyToolboxMsdnBlogUrlExtractionStep(blogDoc)) // Extract tags *before* preprocessing blog post (for // example, to allow the preprocessing step to remove tags // embedded in the content of the post) .AddStep(new TechnologyToolboxTagExtractionStep(blogDoc)) // Replace image URLs *before* preprocessing blog post (for // example, to allow the preprocessing step to replace <img> // elements embedded in the content of the post with Hugo // "figure" shortcodes) .AddStep(new ImageUrlReplacementStep(imageUrlMapper)) .AddStep(new FixHtmlFormattingIssuesStep()) .AddStep(new TechnologyToolboxBlogPostPreprocessor( linkMapper)) // Perform code analysis *after* preprocessing blog post (for // example, to avoid overwriting "Text" language specified for // log excerpts) .AddStep(new CodeBlockAnalysisStep( codeBlockAnalyzer, reverseMarkdownConfig.CodeBlockLanguageMapper)) .AddStep(new ReverseMarkdownPreprocessingStep()) .AddStep(new ReverseMarkdownConversionStep( reverseMarkdownConfig)) .AddStep(new ReverseMarkdownPostprocessingStep()) .AddStep(new AttachmentLookupStep(blogPostAttachmentService)) .AddStep(new CategoryLookupStep(categories)) .AddStep(new SaveMarkdownStep(textFormatter, false)) .AddStep(new CreateBlogArchivePagesStep()) .Build(); pipeline.Execute(); convertedPostCount++; }); Console.WriteLine($"Posts converted: {convertedPostCount}"); }
internal LinkCollectionProxy(Tfs.WorkItem item) { _item = item; _linkHelper = new LinkHelper(); _linkMapper = new LinkMapper(); }