System.Data.Common.DBConnectionString.ValidateCombinedSet C# (CSharp) Method

ValidateCombinedSet() private method

private ValidateCombinedSet ( DBConnectionString componentSet, DBConnectionString combinedSet ) : void
componentSet DBConnectionString
combinedSet DBConnectionString
return void
        private void ValidateCombinedSet(DBConnectionString componentSet, DBConnectionString combinedSet)
        {
            Debug.Assert(combinedSet != null, "The combined connection string should not be null");
            if ((componentSet != null) && (combinedSet._restrictionValues != null) && (componentSet._restrictionValues != null))
            {
                if (componentSet._behavior == KeyRestrictionBehavior.AllowOnly)
                {
                    if (combinedSet._behavior == KeyRestrictionBehavior.AllowOnly)
                    {
                        // Component==Allow, Combined==Allow
                        // All values in the Combined Set should also be in the Component Set
                        // Combined - Component == null
                        Debug.Assert(combinedSet._restrictionValues.Except(componentSet._restrictionValues).Count() == 0, "Combined set allows values not allowed by component set");
                    }
                    else if (combinedSet._behavior == KeyRestrictionBehavior.PreventUsage)
                    {
                        // Component==Allow, Combined==PreventUsage
                        // Preventions override allows, so there is nothing to check here
                    }
                    else
                    {
                        Debug.Assert(false, string.Format("Unknown behavior for combined set: {0}", combinedSet._behavior));
                    }
                }
                else if (componentSet._behavior == KeyRestrictionBehavior.PreventUsage)
                {
                    if (combinedSet._behavior == KeyRestrictionBehavior.AllowOnly)
                    {
                        // Component==PreventUsage, Combined==Allow
                        // There shouldn't be any of the values from the Component Set in the Combined Set
                        // Intersect(Component, Combined) == null
                        Debug.Assert(combinedSet._restrictionValues.Intersect(componentSet._restrictionValues).Count() == 0, "Combined values allows values prevented by component set");
                    }
                    else if (combinedSet._behavior == KeyRestrictionBehavior.PreventUsage)
                    {
                        // Component==PreventUsage, Combined==PreventUsage
                        // All values in the Component Set should also be in the Combined Set
                        // Component - Combined == null
                        Debug.Assert(componentSet._restrictionValues.Except(combinedSet._restrictionValues).Count() == 0, "Combined values does not prevent all of the values prevented by the component set");
                    }
                    else
                    {
                        Debug.Assert(false, string.Format("Unknown behavior for combined set: {0}", combinedSet._behavior));
                    }
                }
                else
                {
                    Debug.Assert(false, string.Format("Unknown behavior for component set: {0}", componentSet._behavior));
                }
            }
        }