示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleBooleans()
        public virtual void ShouldHandleBooleans()
        {
            TRUE.writeTo(_converter);
            assertThat(_converter.value(), equalTo(true));
            FALSE.writeTo(_converter);
            assertThat(_converter.value(), equalTo(false));
        }
示例#2
0
 protected internal virtual void applyFilters(BatchStatisticsQuery query)
 {
     if (!string.ReferenceEquals(batchId, null))
     {
         query.batchId(batchId);
     }
     if (!string.ReferenceEquals(type, null))
     {
         query.type(type);
     }
     if (TRUE.Equals(withoutTenantId))
     {
         query.withoutTenantId();
     }
     if (tenantIds != null && tenantIds.Count > 0)
     {
         query.tenantIdIn(tenantIds.ToArray());
     }
     if (TRUE.Equals(suspended))
     {
         query.suspended();
     }
     if (FALSE.Equals(suspended))
     {
         query.active();
     }
 }
示例#3
0
        internal static IndexType GetIndexType(IDictionary <string, string> config)
        {
            string     type                = config[LuceneIndexImplementation.KEY_TYPE];
            IndexType  result              = null;
            Similarity similarity          = GetCustomSimilarity(config);
            bool?      toLowerCaseUnbiased = !string.ReferenceEquals(config[LuceneIndexImplementation.KEY_TO_LOWER_CASE], null) ? ParseBoolean(config[LuceneIndexImplementation.KEY_TO_LOWER_CASE], true) : null;
            Analyzer   customAnalyzer      = GetCustomAnalyzer(config);

            if (!string.ReferenceEquals(type, null))
            {
                // Use the built in alternatives... "exact" or "fulltext"
                if ("exact".Equals(type))
                {
                    // In the exact case we default to false
                    bool toLowerCase = TRUE.Equals(toLowerCaseUnbiased);

                    result = toLowerCase ? new CustomType(new LowerCaseKeywordAnalyzer(), true, similarity) : EXACT;
                }
                else if ("fulltext".Equals(type))
                {
                    // In the fulltext case we default to true
                    bool toLowerCase = !FALSE.Equals(toLowerCaseUnbiased);

                    Analyzer analyzer = customAnalyzer;
                    if (analyzer == null)
                    {
                        analyzer = TRUE.Equals(toLowerCase) ? LuceneDataSource.LOWER_CASE_WHITESPACE_ANALYZER : LuceneDataSource.WhitespaceAnalyzer;
                    }
                    result = new CustomType(analyzer, toLowerCase, similarity);
                }
                else
                {
                    throw new System.ArgumentException("The given type was not recognized: " + type + ". Known types are 'fulltext' and 'exact'");
                }
            }
            else
            {
                // In the custom case we default to true
                bool toLowerCase = !FALSE.Equals(toLowerCaseUnbiased);

                // Use custom analyzer
                if (customAnalyzer == null)
                {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                    throw new System.ArgumentException("No 'type' was given (which can point out " + "built-in analyzers, such as 'exact' and 'fulltext')" + " and no 'analyzer' was given either (which can point out a custom " + typeof(Analyzer).FullName + " to use)");
                }
                result = new CustomType(customAnalyzer, toLowerCase, similarity);
            }
            return(result);
        }
示例#4
0
 public bool?Apply(string from)
 {
     // Perform identity equality here to differentiate between the default value (which is explicitly allocated
     // as a new instance, and is thus known to be unique), and explicitly being configured as "true".
     //noinspection StringEquality
     if (string.ReferenceEquals(from, AS_DEFAULT_VALUE)) // yes, this should really be ==
     {                                                   // the default value, as opposed to explicitly configured to "true"
         // Should result in UDC being enabled, unless one of the other ways to configure explicitly disables it
         string enabled = System.getProperty(udc_enabled.Name());
         if (FALSE.equalsIgnoreCase(enabled))
         {                              // the 'enabled' system property tries to disable UDC
             string disabled = System.getProperty(UdcDisabled());
             if (string.ReferenceEquals(disabled, null) || disabled.Equals(TRUE, StringComparison.OrdinalIgnoreCase))
             {                                   // the 'disabled' system property does nothing to enable UDC
                 return(false);
             }
         }
         else if (TRUE.equalsIgnoreCase(System.getProperty(UdcDisabled())))
         {                                                   // the 'disabled' system property tries to disable UDC
             return(!string.ReferenceEquals(enabled, null)); // only disable if 'enabled' was not defined
         }
         return(true);
     }
     else if (FALSE.equalsIgnoreCase(from))
     {                         // the setting tries to disable UDC
         // if any other way of configuring UDC enables it, trust that instead.
         string enabled  = System.getProperty(udc_enabled.Name());
         string disabled = System.getProperty(UdcDisabled());
         if (string.ReferenceEquals(enabled, null) || enabled.Equals(FALSE, StringComparison.OrdinalIgnoreCase))
         {                              // the 'enabled' system property does nothing to enable UDC
             if (string.ReferenceEquals(disabled, null) || disabled.Equals(TRUE, StringComparison.OrdinalIgnoreCase))
             {                          // the 'disabled' system property does nothing to enable UDC
                 return(false);
             }
         }
         return(true);
     }
     else
     {                         // the setting enabled UDC
         return(true);
     }
 }