/// <summary> /// Default constructor /// </summary> /// <param name="baseTransformationInformation">Page transformation information object</param> /// <param name="sourceContext">ClientContext of the source page</param> /// <param name="targetContext">ClientContext of the target page</param> /// <param name="logObservers">Connected loggers</param> public UrlTransformator(BaseTransformationInformation baseTransformationInformation, ClientContext sourceContext, ClientContext targetContext, IList <ILogObserver> logObservers = null) { // Hookup logging if (logObservers != null) { foreach (var observer in logObservers) { base.RegisterObserver(observer); } } // Ensure source and target context are set if (sourceContext == null && targetContext != null) { sourceContext = targetContext; } if (targetContext == null && sourceContext != null) { targetContext = sourceContext; } // Grab the needed information to drive url rewrite this.sourceContext = sourceContext; this.targetContext = targetContext; sourceContext.Site.EnsureProperties(p => p.ServerRelativeUrl, p => p.Url); this.sourceSiteUrl = sourceContext.Site.Url; this.sourceWebUrl = sourceContext.Web.GetUrl(); if (CacheManager.Instance.IsPublishingWeb(this.sourceWebUrl)) { this.pagesLibrary = CacheManager.Instance.GetPublishingPagesLibraryName(this.sourceContext); } else { this.pagesLibrary = "sitepages"; } this.targetWebUrl = targetContext.Web.GetUrl(); // Load the URL mapping file if (!string.IsNullOrEmpty(baseTransformationInformation?.UrlMappingFile)) { this.urlMapping = CacheManager.Instance.GetUrlMapping(baseTransformationInformation.UrlMappingFile, logObservers); } this.skipDefaultUrlRewrite = baseTransformationInformation.SkipDefaultUrlRewrite; }
/// <summary> /// User Transformator constructor /// </summary> /// <param name="baseTransformationInformation">Transformation configuration settings</param> /// <param name="sourceContext">Source Context</param> /// <param name="targetContext">Target Context</param> /// <param name="logObservers">Connected loggers</param> public UserTransformator(BaseTransformationInformation baseTransformationInformation, ClientContext sourceContext, ClientContext targetContext, IList <ILogObserver> logObservers = null) { // Hookup logging if (logObservers != null) { foreach (var observer in logObservers) { base.RegisterObserver(observer); } } // Ensure source and target context are set if (sourceContext == null && targetContext != null) { sourceContext = targetContext; } if (targetContext == null && sourceContext != null) { targetContext = sourceContext; } this._sourceContext = sourceContext; this._targetContext = targetContext; // Load the User mapping file if (!string.IsNullOrEmpty(baseTransformationInformation?.UserMappingFile)) { this._userMapping = CacheManager.Instance.GetUserMapping(baseTransformationInformation.UserMappingFile, logObservers); } else { this._userMapping = default; //Pass through if there is no mapping } if (!string.IsNullOrEmpty(baseTransformationInformation.LDAPConnectionString)) { _ldapSpecifiedByUser = baseTransformationInformation?.LDAPConnectionString; } else { _ldapSpecifiedByUser = default; } _sourceVersion = baseTransformationInformation?.SourceVersion ?? SPVersion.SPO; // SPO Fall Back _skipUserMapping = baseTransformationInformation.SkipUserMapping; }
/// <summary> /// Instantiates the content transformator /// </summary> /// <param name="page">Client side page that will be updates</param> /// <param name="pageTransformation">Transformation information</param> public ContentTransformator(ClientContext sourceClientContext, ClientSidePage page, PageTransformation pageTransformation, BaseTransformationInformation transformationInformation, IList <ILogObserver> logObservers = null) : base() { //Register any existing observers if (logObservers != null) { foreach (var observer in logObservers) { base.RegisterObserver(observer); } } this.page = page ?? throw new ArgumentException("Page cannot be null"); this.pageTransformation = pageTransformation ?? throw new ArgumentException("pageTransformation cannot be null"); this.globalTokens = CreateGlobalTokenList(page.Context, transformationInformation.MappingProperties); this.functionProcessor = new FunctionProcessor(sourceClientContext, this.page, this.pageTransformation, transformationInformation, base.RegisteredLogObservers); this.transformationInformation = transformationInformation; this.sourceClientContext = sourceClientContext; this.isCrossSiteTransfer = IsCrossSiteTransfer(); }
/// <summary> /// Constructor for the Term Transformator class /// </summary> /// <param name="baseTransformationInformation"></param> /// <param name="sourceContext"></param> /// <param name="targetContext"></param> /// <param name="logObservers"></param> public TermTransformator(BaseTransformationInformation baseTransformationInformation, ClientContext sourceContext, ClientContext targetContext, IList <ILogObserver> logObservers = null) { // Hookup logging if (logObservers != null) { foreach (var observer in logObservers) { base.RegisterObserver(observer); } } // Ensure source and target context are set if (sourceContext == null && targetContext != null) { sourceContext = targetContext; } if (targetContext == null && sourceContext != null) { targetContext = sourceContext; } this._sourceContext = sourceContext; this._targetContext = targetContext; // Load the Term mapping file if (!string.IsNullOrEmpty(baseTransformationInformation?.TermMappingFile)) { this.termMappings = CacheManager.Instance.GetTermMapping(baseTransformationInformation.TermMappingFile, logObservers); } if (baseTransformationInformation != null) { this.skipTermStoreMapping = baseTransformationInformation.SkipTermStoreMapping; this._baseTransformationInformation = baseTransformationInformation; } }
/// <summary> /// Default constructor /// </summary> public WikiHtmlTransformator(ClientContext sourceContext, ClientSidePage page, BaseTransformationInformation basePageTransformationInformation, IList <ILogObserver> logObservers = null) { //Register any existing observers if (logObservers != null) { foreach (var observer in logObservers) { base.RegisterObserver(observer); } } this.sourceContext = sourceContext; this.page = page; this.mappingProperties = basePageTransformationInformation.MappingProperties; // Instantiate BuiltIn functions class this.builtInFunctions = new BuiltIn(basePageTransformationInformation, this.page.Context, this.sourceContext, this.page, base.RegisteredLogObservers); // Instantiate the AngleSharp Html parser parser = new HtmlParser(new HtmlParserOptions() { IsEmbedded = true }); }