Esempio n. 1
0
 /// <summary>
 /// Default constructor with dependency injection
 /// </summary>
 /// <param name="taxonomyHelper">The taxonomy helper</param>
 /// <param name="fieldSchemaHelper">Field schema builder</param>
 /// <param name="fieldValueWriter">Field value wirter</param>
 /// <param name="log">Logging utility</param>
 public FieldHelper(ITaxonomyHelper taxonomyHelper, IFieldSchemaHelper fieldSchemaHelper, IFieldValueWriter fieldValueWriter, ILogger log)
 {
     this.taxonomyHelper = taxonomyHelper;
     this.fieldSchemaHelper = fieldSchemaHelper;
     this.fieldValueWriter = fieldValueWriter;
     this.log = log;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserProfilePropertyHelper" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="taxonomyHelper">The taxonomy helper.</param>
 /// <param name="siteTaxonomyCacheManager">The site taxonomy cache manager.</param>
 public UserProfilePropertyHelper(
     ILogger logger, 
     ITaxonomyHelper taxonomyHelper, 
     ISiteTaxonomyCacheManager siteTaxonomyCacheManager)
 {
     this.logger = logger;
     this.taxonomyHelper = taxonomyHelper;
     this.siteTaxonomyCacheManager = siteTaxonomyCacheManager;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SiteTaxonomyCache"/> class.
        /// </summary>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="termStoreName">
        /// The term store name.
        /// </param>
        /// <param name="taxonomyHelper">The taxonomy helper.</param>
        public SiteTaxonomyCache(SPSite site, string termStoreName, ITaxonomyHelper taxonomyHelper)
        {
            SPMonitoredScope monitor = null;
            this.taxonomyHelper = taxonomyHelper;

            try
            {
                monitor = new SPMonitoredScope("GSoft.Dynamite - Site taxonomy cache initialization");
            }
            catch (TypeInitializationException)
            {
                // Failed to initialize local diagnostics service. Fail to log monitor trace.
            }
            catch (ArgumentNullException)
            {
                // Failed to initialize local diagnostics service. Fail to log monitor trace.
            }

            if (site == null)
            {
                throw new ArgumentNullException("site", "SPSite is currently null, please pass a valid site as argument.");
            }

            this.SiteId = site.ID;

            // Don't send in the updateCache=true setting - let the SharePoint inner Taxonomy cache refresh itself normally (every 10 seconds or so)
            this.TaxonomySession = new TaxonomySession(site);

            if (!string.IsNullOrEmpty(termStoreName))
            {
                this.SiteCollectionGroup = this.TaxonomySession.TermStores[termStoreName].GetSiteCollectionGroup(site);
            }
            else
            {
                // Use default term store
                TermStore termStore = null;

                if (taxonomyHelper != null)
                {
                    termStore = this.taxonomyHelper.GetDefaultSiteCollectionTermStore(this.TaxonomySession);
                }
                else
                {
                    termStore = this.TaxonomySession.DefaultSiteCollectionTermStore;
                }

                if (termStore != null)
                {
                    this.SiteCollectionGroup = termStore.GetSiteCollectionGroup(site);
                }
            }

            if (monitor != null)
            {
                monitor.Dispose();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigationService" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 /// <param name="catalogNavigation">The catalog navigation.</param>
 /// <param name="taxonomyHelper">The taxonomy helper.</param>
 public NavigationService(
     ILogger logger, 
     INavigationHelper navigationHelper, 
     ISearchHelper searchHelper, 
     IVariationNavigationHelper catalogNavigation,
     ITaxonomyHelper taxonomyHelper)
 {
     this.logger = logger;
     this.navigationHelper = navigationHelper;
     this.searchHelper = searchHelper;
     this.catalogNavigation = catalogNavigation;
     this.taxonomyHelper = taxonomyHelper;
 }
        /// <summary>
        /// The get site taxonomy cache.
        /// </summary>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="termStoreName">
        /// The term store name.
        /// </param>
        /// <param name="taxonomyHelper">The taxonomy helper.</param>
        /// <returns>
        /// The <see cref="SiteTaxonomyCache"/>.
        /// </returns>
        public SiteTaxonomyCache GetSiteTaxonomyCache(SPSite site, string termStoreName, ITaxonomyHelper taxonomyHelper)
        {
            // No caching if outside HttpContext
            if (HttpContext.Current == null)
            {
                return new SiteTaxonomyCache(site, termStoreName, taxonomyHelper);
            }

            string cacheKey = KeyPrefix + site.ID.ToString();

            // Create the Site Taxonomy Cache because it does not yet exist. No need for locking because
            // we only cache per-request using the HttpContext cache.
            if (HttpContext.Current.Items[cacheKey] == null)
            {
                var newTaxCache = new SiteTaxonomyCache(site, termStoreName, this.taxonomyHelper);
                HttpContext.Current.Items[cacheKey] = newTaxCache;
            }

            // Return the existing Session
            return (SiteTaxonomyCache)HttpContext.Current.Items[cacheKey];
        }
 /// <summary>
 /// Per-request taxonomy cache manager (using HttpContext.Items)
 /// </summary>
 /// <param name="taxonomyHelper">The taxonomy helper.</param>
 public PerRequestSiteTaxonomyCacheManager(ITaxonomyHelper taxonomyHelper)
 {
     this.taxonomyHelper = taxonomyHelper;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaxonomyService" /> class.
 /// </summary>
 /// <param name="taxonomyCacheManager">The taxonomy cache manager</param>
 /// <param name="taxonomyHelper">The taxonomy helper to use.</param>
 public TaxonomyService(ISiteTaxonomyCacheManager taxonomyCacheManager, ITaxonomyHelper taxonomyHelper)
 {
     this.taxonomyCacheManager = taxonomyCacheManager;
     this.taxonomyHelper = taxonomyHelper;
 }