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


C# Utilities.IndentedTextWriter类代码示例

本文整理汇总了C#中System.Data.Entity.Migrations.Utilities.IndentedTextWriter的典型用法代码示例。如果您正苦于以下问题:C# IndentedTextWriter类的具体用法?C# IndentedTextWriter怎么用?C# IndentedTextWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndentedTextWriter类属于System.Data.Entity.Migrations.Utilities命名空间,在下文中一共展示了IndentedTextWriter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteClassStart

        protected void WriteClassStart(string @namespace, string className, IndentedTextWriter writer,
                                                string @base, bool designer = false)
        {
            var baseClassName = @base == typeof (IMigrationMetadata).Name ? @base : typeof (nTestSwarmDbMigration).FullName;

            base.WriteClassStart(@namespace, className, writer, baseClassName, designer);
        }
开发者ID:erichexter,项目名称:TestSwarm,代码行数:7,代码来源:nTestSwarmMigrationCodeGenerator.cs

示例2: Generate

 protected override void Generate(AddForeignKeyOperation addForeignKeyOperation, IndentedTextWriter writer)
 {
     var isReadonly = ReadonlyEntities.Contains(addForeignKeyOperation.PrincipalTable) || ReadonlyEntities.Contains(addForeignKeyOperation.DependentTable); ;
     //if (!isReadonly)
     {
         base.Generate(addForeignKeyOperation, writer);
     }
 }
开发者ID:goodwillguy,项目名称:DeviceManagerService,代码行数:8,代码来源:SkipReadonlyEntityCodeMigration.cs

示例3: Random_access_of_indents_works

        public void Random_access_of_indents_works()
        {
            var writer = new IndentedTextWriter(new StringWriter(), "   ");

            foreach (var i in new[] { 4, 2, 5, -7, 0, 5, -1, 9, 0, 0 })
            {
                writer.Indent = i;
                var j = i < 0 ? 0 : i;
                Assert.Equal(j * 3, writer.CurrentIndentation().Length);
                Assert.Equal(j * 3, writer.CurrentIndentation().Length);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:IndentedTextWriterTests.cs

示例4: Generate

        protected override void Generate(AlterColumnOperation alterColumnOperation, IndentedTextWriter writer)
        {
            AlterColumnOperation alter = null;
              if (alterColumnOperation.Inverse != null)
            alter = new AlterColumnOperation(TrimSchemaPrefix(alterColumnOperation.Table), alterColumnOperation.Column, alterColumnOperation.IsDestructiveChange, (AlterColumnOperation)alterColumnOperation.Inverse);
              else
            alter = new AlterColumnOperation(TrimSchemaPrefix(alterColumnOperation.Table), alterColumnOperation.Column, alterColumnOperation.IsDestructiveChange);

              if (alter != null)
            base.Generate(alter, writer);
              else
            base.Generate(alterColumnOperation);
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:13,代码来源:MySqlMigrationSqlGenerator.cs

示例5: Generate

        protected virtual string Generate(
            IEnumerable<MigrationOperation> operations, string @namespace, string className)
        {
            Contract.Requires(operations != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(className));

            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                using (var writer = new IndentedTextWriter(stringWriter, "    "))
                {
                    WriteClassStart(
                        @namespace, className, writer, "DbMigration", designer: false,
                        namespaces: GetNamespaces(operations));

                    writer.WriteLine("public override void Up()");
                    writer.WriteLine("{");
                    writer.Indent++;

                    operations
                        .Except(_newTableForeignKeys.Select(t => t.Item2))
                        .Except(_newTableIndexes.Select(t => t.Item2))
                        .Each<dynamic>(o => Generate(o, writer));

                    writer.Indent--;
                    writer.WriteLine("}");

                    writer.WriteLine();

                    writer.WriteLine("public override void Down()");
                    writer.WriteLine("{");
                    writer.Indent++;

                    operations
                        .Select(o => o.Inverse)
                        .Where(o => o != null)
                        .Reverse()
                        .Each<dynamic>(o => Generate(o, writer));

                    writer.Indent--;
                    writer.WriteLine("}");

                    WriteClassEnd(@namespace, writer);
                }

                return stringWriter.ToString();
            }
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:47,代码来源:CSharpMigrationCodeGenerator.cs

示例6: Generate

        protected override void Generate(ColumnModel column, IndentedTextWriter writer)
        {
            writer.Write(Quote(column.Name));
            writer.Write(" ");
            writer.Write(BuildColumnType(column));

            var collation = TryGetCollation(column.Annotations);
            if (collation != null && column.ClrType == typeof(string))
            {
                writer.Write(" COLLATE " + collation.CollationName + " ");
            }

            if ((column.IsNullable != null)
                && !column.IsNullable.Value)
            {
                writer.Write(" NOT NULL");
            }

            if (column.DefaultValue != null)
            {
                writer.Write(" DEFAULT ");
                writer.Write(Generate((dynamic)column.DefaultValue));
            }
            else if (!string.IsNullOrWhiteSpace(column.DefaultValueSql))
            {
                writer.Write(" DEFAULT ");
                writer.Write(column.DefaultValueSql);
            }
            else if (column.IsIdentity)
            {
                if ((column.Type == PrimitiveTypeKind.Guid)
                    && (column.DefaultValue == null))
                {
                    writer.Write(" DEFAULT " + GuidColumnDefault);
                }
                else
                {
                    writer.Write(" IDENTITY");
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:41,代码来源:SqlServerMigrationSqlGeneratorWtihCollations.cs

示例7: Extreme_indentation_does_not_overflow_buffer_size

        [Fact] // CodePlex 1603
        public void Extreme_indentation_does_not_overflow_buffer_size()
        {
            var output = new StringWriter();
            var writer = new IndentedTextWriter(output, "   ");
            var totalLength = 0;

            // Run once, filling the cache
            for (var i = 0; i < 500; i++)
            {
                writer.Indent = i;
                Assert.Equal(i * 3, writer.CurrentIndentation().Length);

                writer.WriteLine("OhNo!");
                totalLength += i * 3 + 7;
                Assert.Equal(totalLength, output.ToString().Length);
            }

            // Run again, this time using the cache
            for (var i = 0; i < 500; i++)
            {
                writer.Indent = i;
                Assert.Equal(i * 3, writer.CurrentIndentation().Length);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:IndentedTextWriterTests.cs

示例8: GenerateInline

        /// <summary>
        /// Generates code to perform an <see cref="AddPrimaryKeyOperation" /> as part of a <see cref="CreateTableOperation" />.
        /// </summary>
        /// <param name="addPrimaryKeyOperation"> The operation to generate code for. </param>
        /// <param name="writer"> Text writer to add the generated code to. </param>
        protected virtual void GenerateInline(AddPrimaryKeyOperation addPrimaryKeyOperation, IndentedTextWriter writer)
        {
            Check.NotNull(writer, "writer");

            if (addPrimaryKeyOperation != null)
            {
                writer.WriteLine(" _");
                writer.Write(".PrimaryKey(");

                Generate(addPrimaryKeyOperation.Columns, writer);

                if (!addPrimaryKeyOperation.HasDefaultName)
                {
                    writer.Write(", name := ");
                    writer.Write(Quote(addPrimaryKeyOperation.Name));
                }

                if (!addPrimaryKeyOperation.IsClustered)
                {
                    writer.Write(", clustered := False");
                }

                writer.Write(")");
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:30,代码来源:VisualBasicMigrationCodeGenerator.cs

示例9: Generate

        /// <summary>
        /// Generates code to perform a <see cref="CreateTableOperation" />.
        /// </summary>
        /// <param name="createTableOperation"> The operation to generate code for. </param>
        /// <param name="writer"> Text writer to add the generated code to. </param>
        protected virtual void Generate(CreateTableOperation createTableOperation, IndentedTextWriter writer)
        {
            Check.NotNull(createTableOperation, "createTableOperation");
            Check.NotNull(writer, "writer");

            writer.WriteLine("CreateTable(");
            writer.Indent++;
            writer.Write(Quote(createTableOperation.Name));
            writer.WriteLine(",");
            writer.WriteLine("Function(c) New With");
            writer.Indent++;
            writer.WriteLine("{");
            writer.Indent++;

            var columnCount = createTableOperation.Columns.Count();

            createTableOperation.Columns.Each(
                (c, i) =>
                {
                    var scrubbedName = ScrubName(c.Name);

                    writer.Write(".");
                    writer.Write(scrubbedName);
                    writer.Write(" =");
                    Generate(c, writer, !string.Equals(c.Name, scrubbedName, StringComparison.Ordinal));

                    if (i < columnCount - 1)
                    {
                        writer.Write(",");
                    }

                    writer.WriteLine();
                });

            writer.Indent--;
            writer.Write("}");
            writer.Indent--;

            if (createTableOperation.Annotations.Any())
            {
                writer.WriteLine(",");
                writer.Write("annotations := ");
                GenerateAnnotations(createTableOperation.Annotations, writer);
            }

            writer.Write(")");

            GenerateInline(createTableOperation.PrimaryKey, writer);

            _newTableForeignKeys
                .Where(t => t.Item1 == createTableOperation)
                .Each(t => GenerateInline(t.Item2, writer));

            _newTableIndexes
                .Where(t => t.Item1 == createTableOperation)
                .Each(t => GenerateInline(t.Item2, writer));

            writer.WriteLine();
            writer.Indent--;
            writer.WriteLine();
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:66,代码来源:VisualBasicMigrationCodeGenerator.cs


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