コード例 #1
0
 /// <summary>
 /// Checks if service url and index are configured
 /// </summary>
 /// <param name="configuration">Find configuration</param>
 /// <returns>True if configured, false otherwise</returns>
 private bool SearchIndexIsConfigured(EPiServer.Find.Configuration configuration)
 {
     return(!configuration.ServiceUrl.IsNullOrEmpty() &&
            !configuration.ServiceUrl.Contains("YOUR_URI") &&
            !configuration.DefaultIndex.IsNullOrEmpty() &&
            !configuration.DefaultIndex.Equals("YOUR_INDEX"));
 }
コード例 #2
0
 internal static IClient CreateFromConfig(bool bypassLicenseRestriction)
 {
     EPiServer.Find.Configuration configuration = EPiServer.Find.Configuration.GetConfiguration();
     if (configuration.ServiceUrl.IsNullOrWhiteSpace())
     {
         throw new ConfigurationErrorsException("The serviceUrl cannot be empty");
     }
     if (configuration.DefaultIndex.IsNullOrWhiteSpace())
     {
         throw new ConfigurationErrorsException("The defaultIndex cannot be empty");
     }
     if (!configuration.ServiceUrl.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) && !configuration.ServiceUrl.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
     {
         throw new ConfigurationErrorsException("The serviceUrl must start with http:// or https://.");
     }
     return((IClient) new Client((ICommands) new Commands(configuration.ServiceUrl, (IJsonRequestFactory) new JsonRequestFactory(configuration.DefaultRequestTimeout), new Func <JsonSerializer>(Serializer.CreateDefault), (ICache) new RuntimeCacheAdapter()), configuration.DefaultIndex, bypassLicenseRestriction));
 }