示例#1
0
 /// <summary>
 /// Create a table with the given name.  Set your columns in <see cref="ExplicitColumnDefinitions"/>
 /// </summary>
 public CreateTableArgs(DiscoveredDatabase database, string tableName, string schema)
 {
     Database      = database;
     TableName     = tableName;
     Schema        = schema;
     GuessSettings = new GuessSettingsFactory().Create();
 }
        public void Test_GuessSettingsFactory_Defaults()
        {
            //default is true
            Assert.IsTrue(GuessSettingsFactory.Defaults.CharCanBeBoolean);
            var f        = new GuessSettingsFactory();
            var instance = f.Create();

            Assert.IsTrue(instance.CharCanBeBoolean);

            Assert.IsFalse(instance == GuessSettingsFactory.Defaults);

            //changing static defaults
            GuessSettingsFactory.Defaults.CharCanBeBoolean = false;

            try
            {
                //should change the result of Create to the new default
                Assert.IsFalse(f.Create().CharCanBeBoolean);

                var decider = new DecimalTypeDecider(CultureInfo.CurrentCulture);
                Assert.IsFalse(decider.Settings.CharCanBeBoolean);
            }
            finally
            {
                //set the static default back to not interfere with other tests
                GuessSettingsFactory.Defaults.CharCanBeBoolean = true;
            }
        }
        /// <summary>
        /// Determines behaviour of abstract base.  Call from derived classes to indicate what inter compatible Types you support parsing into / guessing
        /// </summary>
        /// <param name="culture"></param>
        /// <param name="compatibilityGroup">How your Type interacts with other Guessers, e.g. can you fallback from one to another</param>
        /// <param name="typesSupported">All the Types your guesser supports e.g. multiple sizes of int (int32, int16 etc).  These should not overlap with other guessers in the app domain</param>
        protected DecideTypesForStrings(CultureInfo culture, TypeCompatibilityGroup compatibilityGroup, params Type[] typesSupported)
        {
            Culture = culture;

            Settings = new GuessSettingsFactory().Create();

            CompatibilityGroup = compatibilityGroup;

            if (typesSupported.Length == 0)
            {
                throw new ArgumentException(SR.DecideTypesForStrings_DecideTypesForStrings_DecideTypesForStrings_abstract_base_was_not_passed_any_typesSupported_by_implementing_derived_class);
            }

            TypesSupported = new HashSet <Type>(typesSupported);
        }