internal PageBase(ILinkProvider linkProvider, ApiReferenceConfiguration configuration, TModel model) { Model = model ?? throw new ArgumentNullException(nameof(model)); m_LinkProvider = linkProvider ?? throw new ArgumentNullException(nameof(linkProvider)); m_Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); }
public string ResolveLink(string componentUri) { string cacheKey = String.Format(CacheKeyFormat, componentUri); string link = (string)CacheAgent.Load(cacheKey); if (link != null) { if (link.Equals(CacheValueNull)) { return(null); } return(link); } else { ILinkProvider lp = GetLinkProvider(componentUri); if (lp == null) { return(string.Empty); } string resolvedUrl = lp.ResolveLink(componentUri); if (resolvedUrl == null) { //CacheAgent.Store(cacheKey, CacheRegion, CacheValueNull, new List<string>() { String.Format(ComponentFactory.CacheKeyFormatByUri, componentUri) }); CacheAgent.Store(cacheKey, CacheRegion, CacheValueNull); } else { //CacheAgent.Store(cacheKey, CacheRegion, resolvedUrl, new List<string>() { String.Format(ComponentFactory.CacheKeyFormatByUri, componentUri) }); CacheAgent.Store(cacheKey, CacheRegion, resolvedUrl); } return(resolvedUrl); } }
public void UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecordsWithoutImplicitDelete( string sourceItemUri, LinkChangeGroup group, ILinkProvider linkProvider) { UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecords(sourceItemUri, group, linkProvider, false); }
public void UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecords( string sourceItemUri, LinkChangeGroup group, ILinkProvider linkProvider) { UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecords(sourceItemUri, group, linkProvider, true); }
private ILinkProvider GetLinkProvider(string uri) { TcmUri u = new TcmUri(uri); if (u == null) { // invalid uri, return null return(null); } if (_linkProviders.ContainsKey(u.PublicationId)) { return(_linkProviders[u.PublicationId]); } lock (lock1) { if (!_linkProviders.ContainsKey(u.PublicationId)) // we must test again, because in the mean time another thread might have added a record to the dictionary! { Type t = LinkProvider.GetType(); ILinkProvider lp = (ILinkProvider)Activator.CreateInstance(t); lp.PublicationId = u.PublicationId; _linkProviders.Add(u.PublicationId, lp); } } return(_linkProviders[u.PublicationId]); }
public EnrichmentProvider(ILinkProvider linkProvider, IMapper mapper, LinkGenerator linkGenerator, HttpContext httpContext) { _linkProvider = linkProvider; _mapper = mapper; _linkGenerator = linkGenerator; _httpContext = httpContext; }
protected ObjectContentResponseEnricher(ILinkProvider linkProvider, IMapper entityToDtoMapper) { Guard.VerifyObjectNotNull(linkProvider, nameof(linkProvider)); Guard.VerifyObjectNotNull(entityToDtoMapper, nameof(entityToDtoMapper)); LinkProvider = linkProvider; EntityToDtoMapper = entityToDtoMapper; }
public LinkFactory(ILinkProvider linkProvider, IFactoryCommonServices factoryCommonServices) : base(factoryCommonServices) { if (linkProvider == null) throw new ArgumentNullException("linkProvier"); LinkProvider = linkProvider; }
public LinkFactory(ILinkProvider linkProvider, IFactoriesFacade facade) : base(facade) { if (linkProvider == null) throw new ArgumentNullException("linkProvier"); LinkProvider = linkProvider; }
public InternalLink(ILinkProvider linkProvider, String linkText, string pathToRoot, string relativePath, string fileName) : this(linkProvider) { this.LinkText = linkText; this.PathToRoot = pathToRoot; this.RelativePath = relativePath; this.FileName = fileName; }
public EntityToBusinessTranslationService(ILinkProvider linkProvider, IMapper entityToDtoMapper) { Guard.VerifyObjectNotNull(linkProvider, nameof(linkProvider)); Guard.VerifyObjectNotNull(entityToDtoMapper, nameof(entityToDtoMapper)); _linkProvider = linkProvider; _entityToDtoMapper = entityToDtoMapper; }
/// <summary> /// Obtain references to services needed by this class /// </summary> public void InitializeServices(IServiceContainer witDiffServiceContainer) { m_serviceContainer = witDiffServiceContainer; m_configurationService = (ConfigurationService)m_serviceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(m_configurationService != null, "Configuration service is not initialized"); m_linkProvider = witDiffServiceContainer.GetService(typeof(ILinkProvider)) as ILinkProvider; Debug.Assert(m_linkProvider != null, "ILinkProvider service is not initialized"); }
internal static String ReplaceImageEmbeddings(this string template, ILinkProvider linkProvider, String pathToRoot) { string regexPattern = @"\{ImageLink:([^\|\}]+)\|*([^\}]*)\}"; string relativePath = "Images"; var replacements = template.GetLinkReplacementsForImageEmbeddings(linkProvider, regexPattern, pathToRoot, relativePath); return(template.Replace(replacements)); }
internal static String ReplaceSearchPageLinks(this string template, ILinkProvider linkProvider, String pathToRoot) { string regexPattern = @"\{SearchLink:([^\|\}]+)\|*([^\}]*)\}"; string relativePath = "Search"; var replacements = template.GetLinkReplacementsForSearchTags(linkProvider, regexPattern, pathToRoot, relativePath); return(template.Replace(replacements)); }
public LinkFactory(ILinkProvider linkProvider, IFactoriesFacade facade) : base(facade) { if (linkProvider == null) { throw new ArgumentNullException("linkProvier"); } LinkProvider = linkProvider; }
public LinkFactory(ILinkProvider linkProvider, IFactoryCommonServices factoryCommonServices) : base(factoryCommonServices) { if (linkProvider == null) { throw new ArgumentNullException("linkProvier"); } LinkProvider = linkProvider; }
/// <summary> /// Gets the providers supported by this Adapter. /// </summary> /// <param name="serviceType">IAnalysisProvider, IMigrationProvider, or ILinkProvider</param> /// <returns></returns> public object GetService(Type serviceType) { if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new ClearQuestAnalysisProvider(); } return(m_analysisProvider); } else if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new ClearQuestMigrationProvider(); } return(m_migrationProvider); } else if (serviceType == typeof(ILinkProvider)) { if (m_linkProvider == null) { m_linkProvider = new ClearQuestLinkProvider(); } return(m_linkProvider); } else if (serviceType == typeof(IWITDiffProvider)) { if (m_witDiffProvider == null) { m_witDiffProvider = new ClearQuestDiffProvider(); } return(m_witDiffProvider); } else if (serviceType == typeof(ISyncMonitorProvider)) { if (m_syncMonitorProvider == null) { m_syncMonitorProvider = new ClearQuestSyncMonitorProvider(); } return(m_syncMonitorProvider); } else if (serviceType == typeof(IAddin)) { if (m_userIdLookupAddin == null) { m_userIdLookupAddin = new ClearQuestUserIdLookupAddin(); } return(m_userIdLookupAddin); } else { return(null); } }
internal static String ReplaceFeedLinks(this string template, ILinkProvider linkProvider, String pathToRoot) { string regexPattern = @"\{FeedLink\}"; string relativePath = String.Empty; string fileName = "syndication.xml"; string defaultLinkText = String.Empty; var replacements = template.GetLinkReplacementsForFeed(linkProvider, regexPattern, pathToRoot, relativePath, fileName, defaultLinkText); return(template.Replace(replacements)); }
internal static String ReplaceContactPageLinks(this string template, ILinkProvider linkProvider, String pathToRoot) { string regexPattern = @"\{ContactPageLink[:]*([^\}]*)\}"; string relativePath = ""; string fileName = "contact"; string defaultLinkText = "Contact Me"; var replacements = template.GetLinkReplacementsForRootPage(linkProvider, regexPattern, pathToRoot, relativePath, fileName, defaultLinkText); return(template.Replace(replacements)); }
public LinkController(ILinkProvider linkProvider, ILogger logger) { if (linkProvider == null) throw new ArgumentNullException("linkProvider"); if (logger == null) throw new ArgumentNullException("logger"); LinkProvider = linkProvider; Logger = logger; }
protected ObjectContentResponseEnricher(ILinkProvider linkProvider, IMapper entityToDtoMapper, LinkGenerator linkGenerator, HttpContext context) { Guard.VerifyObjectNotNull(linkProvider, nameof(linkProvider)); Guard.VerifyObjectNotNull(entityToDtoMapper, nameof(entityToDtoMapper)); LinkProvider = linkProvider; EntityToDtoMapper = entityToDtoMapper; LinkGenerator = linkGenerator; Context = context; }
private static ILinkProvider GetLinkProvider() { if (_actionContextAccessor == null) { throw new TypeInitializationException(nameof(PageOptionsExtensions), new Exception(@"PageOptionsExtensions._actionContextAccessor was not initialized, did you Configure using ""UseApiExtensions"" in Startup?")); } if (_linkProvider == null) { _linkProvider = (ILinkProvider)_actionContextAccessor.ActionContext.HttpContext.RequestServices.GetService(typeof(ILinkProvider)); } return(_linkProvider); }
public virtual object GetService(Type serviceType) { if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new Tfs2010WitAnalysisProvider(); } return(m_analysisProvider); } if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new Tfs2010WitMigrationProvider(); } return(m_migrationProvider); } if (serviceType == typeof(ILinkProvider)) { if (m_linkProvider == null) { m_linkProvider = new Tfs2010LinkProvider(); } return(m_linkProvider); } if (serviceType == typeof(IWITDiffProvider)) { if (m_witDiffProvider == null) { m_witDiffProvider = new TfsWITDiffProvider(); } return(m_witDiffProvider); } if (serviceType == typeof(ISyncMonitorProvider)) { if (m_syncMonitorProvider == null) { m_syncMonitorProvider = new TfsWITSyncMonitorProvider(); } return(m_syncMonitorProvider); } return(null); }
public LinkController(ILinkProvider linkProvider, ILogger logger) { if (linkProvider == null) { throw new ArgumentNullException("linkProvider"); } if (logger == null) { throw new ArgumentNullException("logger"); } LinkProvider = linkProvider; Logger = logger; }
/// <summary> /// Returns an IDiffProvider given a Migration source and a Dictionary of the providers found /// </summary> private IDiffProvider GetDiffProviderForMigrationSource( Microsoft.TeamFoundation.Migration.BusinessModel.MigrationSource migrationSource, Dictionary <Guid, ProviderHandler> providerHandlers) { Guid providerGuid = new Guid(migrationSource.InternalUniqueId); ProviderHandler providerHandler = providerHandlers[providerGuid]; Type diffProviderType = Session.SessionType == SessionTypeEnum.VersionControl ? typeof(IVCDiffProvider) : typeof(IWITDiffProvider); IDiffProvider diffProvider = providerHandler.Provider.GetService(diffProviderType) as IDiffProvider; if (diffProvider == null) { throw new Exception(string.Format(CultureInfo.InvariantCulture, ServerDiffResources.ProviderDoesNotImplementVCDiffInterface, providerHandler.ProviderName)); } DiffServiceContainer = new ServiceContainer(); DiffServiceContainer.AddService(typeof(ConfigurationService), new ConfigurationService(Config, Session, providerGuid)); DiffServiceContainer.AddService(typeof(Session), Session); DiffServiceContainer.AddService(typeof(ICredentialManagementService), new CredentialManagementService(Config)); // If this is a work item session, and the provider implements ILinkProvider, get and initialize // the ILinkProvider service and add it to the ServiceContainer so that the IDiffProvider implementation // can get and use the ILinkProvider implementation ILinkProvider linkProvider = null; if (Session.SessionType == SessionTypeEnum.WorkItemTracking) { DiffServiceContainer.AddService(typeof(ITranslationService), new WITTranslationService(Session, null)); linkProvider = providerHandler.Provider.GetService(typeof(ILinkProvider)) as ILinkProvider; if (linkProvider != null) { ServerDiffLinkTranslationService diffLinkTranslationService = new ServerDiffLinkTranslationService(this, new Guid(migrationSource.InternalUniqueId), new LinkConfigurationLookupService(Config.SessionGroup.Linking)); DiffServiceContainer.AddService(typeof(ILinkTranslationService), diffLinkTranslationService); linkProvider.Initialize(DiffServiceContainer); linkProvider.RegisterSupportedLinkTypes(); DiffServiceContainer.AddService(typeof(ILinkProvider), linkProvider); m_linkProvidersByMigrationSourceId.Add(new Guid(migrationSource.InternalUniqueId), linkProvider); } } diffProvider.InitializeServices(DiffServiceContainer); diffProvider.InitializeClient(migrationSource); return(diffProvider); }
public static IEnumerable <Uri> ExtractUris(Uri currentUri, ILinkProvider linkProvider) { foreach (var link in linkProvider.GetLinks()) { if (TryCreateUri(link, out Uri uri)) { if (!uri.IsAbsoluteUri) { var absoluteUri = new Uri(currentUri, link); yield return(absoluteUri); } else if (uri.Host == currentUri.Host) { yield return(uri); } } } }
public static IServiceCollection Create(this IServiceCollection ignore, IEnumerable <Template> templates, IEnumerable <Category> categories, ILinkProvider linkProvider, ITemplateProcessor templateProcessor) { var container = new ServiceCollection(); var siteSettings = new SiteSettings() { PostsPerPage = 10.GetRandom(3), PostsPerFeed = 10.GetRandom(3), Title = string.Empty.GetRandom(), Description = string.Empty.GetRandom() }; var contentRepo = new Mock <IContentRepository>(); contentRepo.Setup(r => r.GetSiteSettings()).Returns(siteSettings); container.AddSingleton <IContentRepository>(contentRepo.Object); var templateRepo = new Mock <ITemplateRepository>(); if (templates != null) { templateRepo.Setup(r => r.GetAllTemplates()).Returns(templates); } container.AddSingleton <ITemplateRepository>(templateRepo.Object); if (categories != null) { contentRepo.Setup(r => r.GetCategories()).Returns(categories); } if (linkProvider != null) { container.AddSingleton <ILinkProvider>(linkProvider); } if (templateProcessor != null) { container.AddSingleton <ITemplateProcessor>(templateProcessor); } return(container); }
/// <summary> /// Obtain references to services needed by this class /// </summary> public void InitializeServices(IServiceContainer witDiffServiceContainer) { m_linkProvider = witDiffServiceContainer.GetService(typeof(ILinkProvider)) as ILinkProvider; m_session = witDiffServiceContainer.GetService(typeof(Session)) as Session; m_translationService = witDiffServiceContainer.GetService(typeof(ITranslationService)) as ITranslationService; }
public SimpleParser( ILinkProvider linkProvider, IImageProvider imageProvider) { LinkProvider = linkProvider; ImageProvider = imageProvider; }
public CharacterResourceEnricher(ILinkProvider linkProvider, IMapper entityToDtoMapper) : base(linkProvider, entityToDtoMapper) { }
private void UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecords( string sourceItemUri, LinkChangeGroup group, ILinkProvider linkProvider, bool createDeleteActionImplicitly) { var queryByItem = QueryByItem(sourceItemUri); var perItemExistingLinks = from link in queryByItem where link.RelationshipExistsOnServer select link; if (perItemExistingLinks.Count() == 0) { // no link existed before, all 'add' link actions should be pushed to the other side // AND we are going to record these links as existing on this side now AddLinks(group.Actions); } else { // check the delta link change actions // this list contains all the actions that do not need to push into the pipeline List <LinkChangeAction> actionThatEstablishExistingLinkRelationship = new List <LinkChangeAction>(); foreach (LinkChangeAction action in group.Actions) { if (action.Link.LinkType.GetsActionsFromLinkChangeHistory) { // For link types that can provide a history of link changes, we don't need to keep track of related artifact metadata // so continue to the next LinkChangeAction continue; } Debug.Assert(sourceItemUri.Equals(action.Link.SourceArtifact.Uri), "link of different action exists in the same group"); var linkQuery = from l in perItemExistingLinks where l.Relationship.Equals(action.Link.LinkType.ReferenceName) && l.RelatedArtifactId.Equals(action.Link.TargetArtifact.Uri) select l; if (action.ChangeActionId.Equals(WellKnownChangeActionId.Add)) { if (linkQuery.Count() > 0) { if (!linkQuery.First().OtherProperty.HasValue) { // link lock property is not available - required by backward-compability UpdateLink(action, true); } else { bool linkInStoreHasLock = (((WorkItemLinkStore.LinkLockStatus)linkQuery.First().OtherProperty.Value) == WorkItemLinkStore.LinkLockStatus.Locked); if (action.Link.IsLocked == linkInStoreHasLock) { // link already exist and lock-property matches - no need to push to the other side actionThatEstablishExistingLinkRelationship.Add(action); } else { UpdateLink(action, true); } } } else { // link does not exist, keep it and push through the pipeline // AND we are going to record these links as existing on this side now UpdateLink(action, true); } } else // delete { if (linkQuery.Count() > 0) { // link exists, so we will mark in our store that it no longer exists UpdateLink(action, false); } else { // link does not exist, no need to migrate this action actionThatEstablishExistingLinkRelationship.Add(action); } } } // make sure we generate "Delete Link" action for ones that exist in the our recorded link table but is not included // in delta link actions List <LinkChangeAction> deletionActions = new List <LinkChangeAction>(); if (createDeleteActionImplicitly) { foreach (var recordedExistingLink in perItemExistingLinks) { Debug.Assert(linkProvider.SupportedLinkTypes.ContainsKey(recordedExistingLink.Relationship), "linkProvider.SupportedLinkTypes.ContainsKey(recordedExistingLink.Relationship) returns false"); LinkType linkType = linkProvider.SupportedLinkTypes[recordedExistingLink.Relationship]; if (linkType.GetsActionsFromLinkChangeHistory) { // The link type is one that support link change history, so we ignore the contents of the // RelatedArtifactTable and rely on the link change history instead. continue; } bool recordedActionInGroup = false; foreach (LinkChangeAction action in group.Actions) { if (action.Link.LinkType.ReferenceName.Equals(recordedExistingLink.Relationship, StringComparison.OrdinalIgnoreCase) && action.Link.TargetArtifact.Uri.Equals(recordedExistingLink.RelatedArtifactId, StringComparison.OrdinalIgnoreCase)) { recordedActionInGroup = true; break; } } if (!recordedActionInGroup) { TraceManager.TraceInformation("Link '{0}'->'{1}' ({2}) appears to have been deleted - generating link deletion action to be migrated", recordedExistingLink.ItemId, recordedExistingLink.RelatedArtifactId, recordedExistingLink.Relationship); LinkChangeAction linkDeleteAction = linkType.CreateLinkDeletionAction( recordedExistingLink.ItemId, recordedExistingLink.RelatedArtifactId, recordedExistingLink.Relationship); if (null != linkDeleteAction) { deletionActions.Add(linkDeleteAction); } recordedExistingLink.RelationshipExistsOnServer = false; } } } if (actionThatEstablishExistingLinkRelationship.Count > 0) { foreach (LinkChangeAction actionToDelete in actionThatEstablishExistingLinkRelationship) { group.DeleteChangeAction(actionToDelete); } } if (deletionActions.Count > 0) { group.PrependActions(deletionActions); } } m_context.TrySaveChanges(); }
public static ISearchProvider Create(this ISearchProvider ignore, IEnumerable <Template> templates, IEnumerable <Category> categories, ILinkProvider linkProvider) { var container = (null as IServiceCollection).Create(templates, categories, linkProvider, Mock.Of <ITemplateProcessor>()); return(new PageGenerator(container.BuildServiceProvider())); }
public static IServiceCollection AddLinkProvider(this IServiceCollection container, ILinkProvider linkProvider) { return(container.AddSingleton <ILinkProvider>(linkProvider)); }
/** * Set the ILinkProvider to use if any. * * @param linkprovider the ILinkProvider (@see * {@link HtmlPipelineContext#getLinkProvider()} * @return this <code>HtmlPipelineContext</code> */ public HtmlPipelineContext SetLinkProvider(ILinkProvider linkprovider) { this.linkprovider = linkprovider; return(this); }
/** * Set the ILinkProvider to use if any. * * @param linkprovider the ILinkProvider (@see * {@link HtmlPipelineContext#getLinkProvider()} * @return this <code>HtmlPipelineContext</code> */ virtual public HtmlPipelineContext SetLinkProvider(ILinkProvider linkprovider) { this.linkprovider = linkprovider; return this; }
/** * Set the LinkProvider to use if any. * * @param linkprovider the LinkProvider (@see * {@link HtmlPipelineContext#getLinkProvider()} * @return this <code>HtmlPipelineContext</code> */ public SvgPipelineContext SetLinkProvider(ILinkProvider linkprovider) { this.linkprovider = linkprovider; return this; }