Exemple #1
0
        private bool ValidateScripts(List <SqlScript> scripts)
        {
            bool hasUnknown = scripts.Any(p => p.SqlObjectType == SqlObjectType.Unknown);

            if (ThrowOnUnknownScriptTypes && hasUnknown)
            {
                SqlScript unknownScript    = scripts.First(p => p.SqlObjectType == SqlObjectType.Unknown);
                string    exceptionMessage = $"Was not able to determine type of script {unknownScript.ScriptFullName}.";
                throw new Exception(exceptionMessage);
            }

            return(hasUnknown);
        }
Exemple #2
0
        private List <SqlScript> LoadFromResource(Type resourceType)
        {
            BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
            PropertyInfo resourceManagerProp = resourceType
                                               .GetProperty("ResourceManager", flags);
            ResourceManager resourceManager = (ResourceManager)resourceManagerProp.GetValue(null);

            ResourceSet set = resourceManager
                              .GetResourceSet(CultureInfo.InvariantCulture, true, true);

            Type             stringType = typeof(string);
            List <SqlScript> scripts    = new List <SqlScript>();

            foreach (DictionaryEntry entry in set)
            {
                if (entry.Value.GetType() == stringType)
                {
                    SqlScript script = new SqlScript((string)entry.Value, (string)entry.Key);
                    scripts.Add(script);
                }
            }

            return(scripts);
        }