当前位置: 首页>>代码示例>>C#>>正文


C# Set.UnionUpdate方法代码示例

本文整理汇总了C#中Set.UnionUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# Set.UnionUpdate方法的具体用法?C# Set.UnionUpdate怎么用?C# Set.UnionUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Set的用法示例。


在下文中一共展示了Set.UnionUpdate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SimpleValueTests

        public void SimpleValueTests()
        {
            Set<int> empty = new Set<int>();
            Set<int> a = new Set<int>(1, 2, 3);
            Set<int> b = new Set<int>(3, 4, 5);

            Set<int> a_and_b = a + b;

            Assert.AreEqual("{}", empty.ToString());
            Assert.AreEqual("{ 1, 2, 3 }", a.ToString());
            Assert.AreEqual("{ 3, 4, 5 }", b.ToString());

            Assert.AreEqual("{ 1, 2, 3, 4, 5 }", a_and_b.ToString());

            Assert.AreEqual("{}", (empty * a).ToString());
            Assert.AreEqual("{}", (a * empty).ToString());

            Assert.IsTrue(a_and_b * a == a);
            Assert.IsTrue((a_and_b * a).Equals(a));

            Assert.IsTrue(a_and_b - a == new Set<int>(4, 5));
            Assert.IsTrue(a - a == new Set<int>());
            Assert.IsTrue(a * a == a);

            Assert.IsTrue(a.IsSubsetOf(a_and_b));
            Assert.IsTrue(b.IsSubsetOf(a_and_b));
            Assert.IsTrue(a_and_b.IsSubsetOf(a_and_b));

            Assert.IsTrue(a.IsSubsetOf(a));
            Assert.IsTrue(b.IsSubsetOf(b));

            Assert.IsFalse(a.IsSubsetOf(b));
            Assert.IsFalse(b.IsSubsetOf(a));
            Assert.IsFalse(a_and_b.IsSubsetOf(a));
            Assert.IsFalse(a_and_b.IsSubsetOf(b));

            Set<int> a_copy = a.Copy();
            Set<int> b_copy = b.Copy();

            a.UnionUpdate(b);
            Assert.AreEqual(a, a_and_b);

            a.DifferenceUpdate(b);
            Assert.AreEqual(a, a_and_b - b);

            a.UnionUpdate(9);
            Assert.AreEqual(a, (a_and_b - b) + new Set<int>(9));

            a.DifferenceUpdate(1);
            Assert.AreEqual(a, (a_and_b - b) + new Set<int>(9) - new Set<int>(1));

            a_copy.IntersectionUpdate(b_copy);
            Assert.AreEqual(new Set<int>(3), a_copy);
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:54,代码来源:TestSet.cs

示例2: FindConstraint

        ForeignKeyConstraint FindConstraint(string tableName, params string[] columnNames)
        {
            Table table = _database.TablesByShortName[tableName];

            Set<Column> columns = new Set<Column>();

            foreach (string columnName in columnNames)
            {
                columns.UnionUpdate(table.Columns[columnName]);
            }

            foreach (ForeignKeyConstraint constraint in table.ForeignKeyConstraints)
            {
                if (new Set<Column>(constraint.KeyColumns).Equals(columns)) return constraint;
            }

            throw new KeyNotFoundException(string.Format(
                "The table \"{0}\" does not have a constraint with the specified key columns ({1}).",
                tableName, NaturalStrings.FormatList(columnNames)));
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:20,代码来源:Plan.cs

示例3: CompareInCurrentDirectory

        internal static void CompareInCurrentDirectory()
        {
            List<Database> databases = LoadDatabasesInCurrentDirectory();

            // Find which tables are common to all databases:
            Set<ObjectName> allTables = new Set<ObjectName>();
            Set<ObjectName> commonTables = new Set<ObjectName>();

            if (databases.Count > 0) commonTables.UnionUpdate(databases[0].TablesByName.Keys);

            foreach (Database database in databases)
            {
                Set<ObjectName> tablesInThisDatabase = new Set<ObjectName>(database.TablesByName.Keys);

                allTables.UnionUpdate(tablesInThisDatabase);
                commonTables.IntersectionUpdate(tablesInThisDatabase);
            }

            Set<ObjectName> nonCommonTables = Set<ObjectName>.Difference(allTables, commonTables);

            Console.WriteLine(nonCommonTables);

            // Find which columns are common to all databases:
            foreach (ObjectName commonTableName in commonTables)
            {
                Set<string> allColumns = new Set<string>();
                Set<string> commonColumns = new Set<string>();

                if (databases.Count > 0)
                {
                    Set<string> columns = new Set<string>(databases[0].TablesByName[commonTableName].Columns.Keys);
                    commonColumns.UnionUpdate(columns.Map<string>(NormaliseColumnName));
                }

                foreach (Database database in databases)
                {
                    Set<string> columnsInThisTable = new Set<string>(database.TablesByName[commonTableName].Columns.Keys).Map<string>(NormaliseColumnName);

                    commonColumns.IntersectionUpdate(columnsInThisTable);
                    allColumns.UnionUpdate(columnsInThisTable);
                }

                Set<string> nonCommonColumns = Set<string>.Difference(allColumns, commonColumns);

                if (nonCommonColumns.Count > 0)
                {
                    Console.WriteLine(commonTableName.Name);
                    Console.WriteLine(nonCommonColumns);
                }
            }
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:51,代码来源:Dependencies.cs

示例4: CreateFilteredDependenciesGraph

        public static void CreateFilteredDependenciesGraph(Database database, Table startTable, Plan plan)
        {
            Set<Table> visited = new Set<Table>();
            Stack<Table> seen = new Stack<Table>();

            seen.Push(startTable);

            // The relations that, as a precondition of the delete, must not exist:
            while (seen.Count > 0)
            {
                Table table = seen.Pop();

                visited.UnionUpdate(table);

                foreach (ForeignKeyConstraint constraint in table.ForeignKeyDependencies)
                {
                    if (plan.IsConstraintExcludedFromDependencyDiagram(constraint)) continue;

                    if (!visited.Contains(constraint.Table))
                    {
                        seen.Push(constraint.Table);
                    }
                }
            }

            CreateDependenciesGraph(database, visited);
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:27,代码来源:Dependencies.cs

示例5: PopulateNoTagsSet

        void PopulateNoTagsSet()
        {
            _noEndTags = new Set<string>();

            _noEndTags.UnionUpdate("img");
            _noEndTags.UnionUpdate("br");
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:7,代码来源:HtmlRenderer.cs

示例6: CheckNames

        void CheckNames(Protocol protocol)
        {
            Set<string> usedDeclarationNames = new Set<string>();

            foreach (Declaration declaration in protocol.Declarations)
            {
                if (usedDeclarationNames.Contains(declaration.Identifier))
                {
                    throw new SemanticException(string.Format("The name \"{0}\" is used in more than one declaration.",
                        declaration.Identifier));
                }

                usedDeclarationNames.UnionUpdate(declaration.Identifier);

                Set<string> usedMemberNames = new Set<string>();

                foreach (DeclarationMember member in declaration.MemberBases)
                {
                    if (usedMemberNames.Contains(member.Identifier))
                    {
                        throw new SemanticException(string.Format(
                            "The name \"{0}\" in the declaration \"{1}\" is used in more " +
                            " than once within the declaration.", member.Identifier, declaration.Identifier));
                    }
                }
            }
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:27,代码来源:Compilation.cs

示例7: CodePatchMain

        static void CodePatchMain(string[] args)
        {
            DatabaseConnectionString connectionString = new DatabaseConnectionString();
            connectionString.ServerName = "SERVER14";
            connectionString.DatabaseName = "RMTSv2";
            connectionString.UseIntegratedAuthentication = false;
            connectionString.Username = "tmsplus";
            connectionString.Password = "cool";

            Database database;

            using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
            {
                connection.Open();

                database = Database.FromConnection(connection);
            }

            Dictionary<string, string> fieldMappings = GetColumnTypeMappings(database);

            Dictionary<string, string> functionMap = new Dictionary<string,string>();
            functionMap["char"] = "FieldCasts.FromChar";
            functionMap["nvarchar"] = "FieldCasts.FromNVarChar";
            functionMap["nchar"] = "FieldCasts.FromNChar";
            functionMap["float"] = "FieldCasts.FromFloat";
            functionMap["real"] = "FieldCasts.FromReal";
            functionMap["datetime"] = "FieldCasts.FromDateTime";
            functionMap["bit"] = "FieldCasts.FromBit";
            functionMap["varchar"] = "FieldCasts.FromVarChar";
            functionMap["text"] = "FieldCasts.FromText";
            functionMap["ntext"] = "FieldCasts.FromNText";
            functionMap["numeric"] = "FieldCasts.FromNumeric";
            functionMap["int"] = "FieldCasts.FromInt";
            functionMap["image"] = "FieldCasts.FromImage";
            functionMap["varbinary"] = "FieldCasts.FromVarBinary";
            functionMap["smallint"] = "FieldCasts.FromSmallInt";
            functionMap["tinyint"] = "FieldCasts.FromTinyInt";

            DirectoryInfo info = new DirectoryInfo(@"C:\Versioning\Haulage");

            FileInfo[] files = info.GetFiles("*.vb", SearchOption.AllDirectories);

            Set<string> unknownFields = new Set<string>();

            foreach (FileInfo file in files)
            {
                using (StreamReader reader = new StreamReader(file.FullName))
                {
                    string entireFile = reader.ReadToEnd();

                    _fields.Replace(entireFile, (MatchEvaluator)delegate(Match match)
                    {
                        Console.WriteLine(match.Value);

                        string characterBeforeIdentifier = match.Groups[1].Value;
                        string recordSetIdentifier = match.Groups[2].Value;
                        string fieldName = match.Groups[3].Value;

                        string converterName = "FieldCasts.Identity";

                        if (fieldMappings.ContainsKey(fieldName.ToLower()))
                        {
                            string fieldType = fieldMappings[fieldName.ToLower()];

                            converterName = functionMap[fieldType];
                        }
                        else
                        {
                            unknownFields.UnionUpdate(fieldName.ToLower());
                        }

                        string replacementText = string.Format("{0}{1}({2}.Fields(\"{3}\").Value)",
                            characterBeforeIdentifier, converterName, recordSetIdentifier, fieldName);

                        Console.WriteLine("    " + replacementText);

                        return replacementText;
                    });
                }
            }
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:81,代码来源:Program.cs

示例8: GetColumnTypeMappings

        static Dictionary<string, string> GetColumnTypeMappings(Database database)
        {
            Dictionary<string, string> fieldMappings = new Dictionary<string, string>();

            Set<string> ambiguousMappings = new Set<string>();

            foreach (Table table in database.Tables)
            {
                foreach (KeyValuePair<string, Column> pair in table.Columns)
                {
                    string fieldNameLower = pair.Key.ToLower();

                    if (fieldMappings.ContainsKey(fieldNameLower))
                    {
                        if (fieldMappings[fieldNameLower] != pair.Value.DataType)
                        {
                            ambiguousMappings.UnionUpdate(fieldNameLower);
                        }
                    }
                    else
                    {
                        fieldMappings[fieldNameLower] = pair.Value.DataType;
                    }
                }
            }

            foreach (string ambiguousMapping in ambiguousMappings)
            {
                fieldMappings.Remove(ambiguousMapping);
            }

            return fieldMappings;
        }
开发者ID:gregorypilar,项目名称:interlace,代码行数:33,代码来源:Program.cs


注:本文中的Set.UnionUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。