Esempio n. 1
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);
     }
 }