コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public VulcanPageSearchProvider()
     : this(
         VulcanHelper.GetService <IVulcanHandler>(),
         VulcanHelper.GetService <LocalizationService>(),
         VulcanHelper.GetService <ISiteDefinitionResolver>(),
         VulcanHelper.GetService <IContentRepository>(),
         VulcanHelper.GetService <IContentTypeRepository>(),
         VulcanHelper.GetService <UIDescriptorRegistry>()
         )
 {
 }
コード例 #2
0
        /// <summary>
        /// Adds full name as search type, and ensures invariant culture for POCO searching.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="client"></param>
        /// <param name="searchDescriptor"></param>
        /// <param name="alias"></param>
        /// <returns></returns>
        public static ISearchResponse <T> PocoSearch <T>(this IVulcanClient client, Func <SearchDescriptor <T>, SearchDescriptor <T> > searchDescriptor = null, string alias = null) where T : class
        {
            VulcanHelper.GuardForNullAlias(ref alias);

            var tempClient         = client.Language.Equals(CultureInfo.InvariantCulture) ? client : VulcanHandler.Service.GetClient(CultureInfo.InvariantCulture, alias);
            var resolvedDescriptor = searchDescriptor?.Invoke(new SearchDescriptor <T>()) ?? new SearchDescriptor <T>();

            resolvedDescriptor = resolvedDescriptor.Type(typeof(T).FullName);

            return(tempClient.Search <T>(resolvedDescriptor));
        }
コード例 #3
0
ファイル: VulcanFieldHelper.cs プロジェクト: oszedev/vulcan
        private static string GetPriceField(string propertyName, string marketId, string currencyCode, ICurrentMarket currentMarket = null)
        {
            currentMarket = currentMarket ?? VulcanHelper.GetService <ICurrentMarket>();
            if (marketId == null)
            {
                marketId = currentMarket.GetCurrentMarket().MarketId.Value;
            }
            if (currencyCode == null)
            {
                currencyCode = currentMarket.GetCurrentMarket().DefaultCurrency.CurrencyCode;
            }

            return("__" + propertyName + "." + marketId + "_" + currencyCode);
        }
コード例 #4
0
ファイル: Helper.cs プロジェクト: oszedev/vulcan
        public static string ResolveView(string view, VirtualPathRegistrationHandler vppHandler = null)
        {
            var resolvedVppHandler  = vppHandler ?? VulcanHelper.GetService <VirtualPathRegistrationHandler>();
            var protectedModulesVpp = resolvedVppHandler
                                      .RegisteredVirtualPathProviders.Where(p => p.Key is VirtualPathNonUnifiedProvider && ((VirtualPathNonUnifiedProvider)p.Key).ProviderName == "ProtectedModules")
                                      .ToList();

            if (!protectedModulesVpp.Any() || !(protectedModulesVpp[0].Key is VirtualPathNonUnifiedProvider provider))
            {
                throw new Exception("Cannot resolve the Vulcan UI views");
            }

            var path = provider.ConfigurationParameters["physicalPath"].Replace(@"\", "/");

            if (!path.StartsWith("~"))
            {
                if (!path.StartsWith("/"))
                {
                    path = "~/" + path;
                }
                else
                {
                    path = "~" + path;
                }
            }
            else if (!path.StartsWith("/"))
            {
                if (!path.StartsWith("~"))
                {
                    path = "~/" + path;
                }
            }

            if (!path.EndsWith("/"))
            {
                path += "/";
            }

            if (!view.StartsWith("/"))
            {
                view = "/" + view;
            }

            return(path + "TcbInternetSolutions.Vulcan.UI/Views" + view);
        }
コード例 #5
0
        private static decimal GetPrice(IReadOnlyDictionary <string, decimal> priceDictionary, string marketId, string currencyCode, ICurrentMarket currentMarket = null)
        {
            currentMarket = currentMarket ?? VulcanHelper.GetService <ICurrentMarket>();
            if (marketId == null)
            {
                marketId = currentMarket.GetCurrentMarket().MarketId.Value;
            }
            if (currencyCode == null)
            {
                currencyCode = currentMarket.GetCurrentMarket().DefaultCurrency.CurrencyCode;
            }

            var key = marketId + "_" + currencyCode;

            if (priceDictionary != null && priceDictionary.ContainsKey(key))
            {
                return(priceDictionary[key]);
            }

            return(0);
        }
コード例 #6
0
        private static IEnumerable <T> GetContentsWorker <T>(ISearchResponse <IContent> searchResponse, IContentLoader contentLoaderRef) where T : class, IContent
        {
            var list = new List <T>();

            if (searchResponse?.Documents == null)
            {
                return(list);
            }

            var contentLoader = contentLoaderRef ?? VulcanHelper.GetService <IContentLoader>();

            foreach (var document in searchResponse.Documents)
            {
                if (!(document is IVulcanContentHit vulcanDocument))
                {
                    continue;
                }

                try
                {
                    var content = contentLoader.Get <T>(vulcanDocument.ContentLink);

                    if (content != null)
                    {
                        list.Add(content);
                    }
                    else
                    {
                        Logger.Warning("Vulcan found a content in the index that was missing with content link: " + vulcanDocument.ContentLink);
                    }
                }
                catch (Exception e)
                {
                    Logger.Warning("Vulcan found a content in the index that could not be loaded with content link: " + vulcanDocument.ContentLink, e);
                }
            }

            return(list);
        }
コード例 #7
0
 private static IContentTypeRepository ResolveContentTypeRepository(IContentTypeRepository contentTypeRepository)
 {
     return(contentTypeRepository ?? VulcanHelper.GetService <IContentTypeRepository>());
 }