本文整理汇总了C#中TextGenerator.Outdent方法的典型用法代码示例。如果您正苦于以下问题:C# TextGenerator.Outdent方法的具体用法?C# TextGenerator.Outdent怎么用?C# TextGenerator.Outdent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextGenerator
的用法示例。
在下文中一共展示了TextGenerator.Outdent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSerializationCode
public void GenerateSerializationCode(TextGenerator writer)
{
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
if (Descriptor.IsPacked) {
writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
writer.WriteLine(" output.Write{0}NoTag(element);", CapitalizedTypeName);
writer.WriteLine("}");
} else {
writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
writer.WriteLine(" output.Write{0}({1}, element);", CapitalizedTypeName, Number);
writer.WriteLine("}");
}
writer.Outdent();
writer.WriteLine("}");
}
示例2: GenerateSerializedSizeCode
public void GenerateSerializedSizeCode(TextGenerator writer)
{
writer.WriteLine("{");
writer.Indent();
writer.WriteLine("int dataSize = 0;");
if (FixedSize == -1) {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
writer.WriteLine(" dataSize += pb::CodedOutputStream.Compute{0}SizeNoTag(element);", CapitalizedTypeName, Number);
writer.WriteLine("}");
} else {
writer.WriteLine("dataSize = {0} * {1}_.Count;", FixedSize, Name);
}
writer.WriteLine("size += dataSize;");
int tagSize = CodedOutputStream.ComputeTagSize(Descriptor.FieldNumber);
if (Descriptor.IsPacked) {
writer.WriteLine("size += {0};", tagSize);
writer.WriteLine("size += pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);");
} else {
writer.WriteLine("size += {0} * {1}_.Count;", tagSize, Name);
}
// cache the data size for packed fields.
if (Descriptor.IsPacked) {
writer.WriteLine("{0}MemoizedSerializedSize = dataSize;", Name);
}
writer.Outdent();
writer.WriteLine("}");
}
示例3: GenerateSerializedSizeCode
public void GenerateSerializedSizeCode(TextGenerator writer)
{
writer.WriteLine("{");
writer.Indent();
writer.WriteLine("int dataSize = 0;");
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
writer.WriteLine(" dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element);");
writer.WriteLine("}");
writer.WriteLine("size += dataSize;");
int tagSize = CodedOutputStream.ComputeTagSize(Descriptor.FieldNumber);
if (Descriptor.IsPacked) {
writer.WriteLine("size += {0};", tagSize);
writer.WriteLine("size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);");
} else {
writer.WriteLine("size += {0} * {1}_.Count;", tagSize, Name);
}
writer.Outdent();
writer.WriteLine("}");
// cache the data size for packed fields.
if (Descriptor.IsPacked) {
writer.WriteLine("{0}MemoizedSerializedSize = dataSize;", Name);
}
writer.Outdent();
writer.WriteLine("}");
}
示例4: GenerateParsingCode
public void GenerateParsingCode(TextGenerator writer)
{
// If packed, set up the while loop
if (Descriptor.IsPacked) {
writer.WriteLine("int length = input.ReadInt32();");
writer.WriteLine("int oldLimit = input.PushLimit(length);");
writer.WriteLine("while (!input.ReachedLimit) {");
writer.Indent();
}
// Read and store the enum
// TODO(jonskeet): Make a more efficient way of doing this
writer.WriteLine("int rawValue = input.ReadEnum();");
writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
writer.WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now
writer.WriteLine(" unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
writer.WriteLine(" }");
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
writer.WriteLine("} else {");
writer.WriteLine(" Add{0}(({1}) rawValue);", PropertyName, TypeName);
writer.WriteLine("}");
if (Descriptor.IsPacked) {
writer.Outdent();
writer.WriteLine("}");
writer.WriteLine("input.PopLimit(oldLimit);");
}
}
示例5: GenerateSerializationCode
public void GenerateSerializationCode(TextGenerator writer)
{
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
if (Descriptor.IsPacked)
{
writer.WriteLine("output.WritePacked{0}Array({1}, field_names[{3}], {2}MemoizedSerializedSize, {2}_);",
CapitalizedTypeName, Number, Name, FieldOrdinal, Descriptor.FieldType);
}
else
{
writer.WriteLine("output.Write{0}Array({1}, field_names[{3}], {2}_);", CapitalizedTypeName, Number, Name,
FieldOrdinal, Descriptor.FieldType);
}
writer.Outdent();
writer.WriteLine("}");
}
示例6: GenerateStaticVariableInitializers
internal void GenerateStaticVariableInitializers(TextGenerator writer) {
if (UseLiteRuntime) {
writer.WriteLine("{0}.{1} = ", scope, name);
writer.Indent();
writer.WriteLine("new pb::{0}<{1}, {2}>(", Descriptor.IsRepeated ? "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite", extends, type);
writer.Indent();
writer.WriteLine("\"{0}\",", Descriptor.FullName);
writer.WriteLine("{0}.DefaultInstance,", extends);
if(!Descriptor.IsRepeated)
writer.WriteLine("{0},", Descriptor.HasDefaultValue ? DefaultValue : IsNullableType ? "null" : "default(" + type + ")");
writer.WriteLine("{0},", (Descriptor.MappedType == MappedType.Message) ? type + ".DefaultInstance" : "null");
writer.WriteLine("{0},", (Descriptor.MappedType == MappedType.Enum) ? "new EnumLiteMap<" + type + ">()" : "null");
writer.WriteLine("{0}.{1}FieldNumber,", scope, name);
writer.Write("pbd::FieldType.{0}", Descriptor.FieldType);
if (Descriptor.IsRepeated) {
writer.WriteLine(",");
writer.Write(Descriptor.IsPacked ? "true" : "false");
}
writer.Outdent();
writer.WriteLine(");");
writer.Outdent();
} else if (Descriptor.IsRepeated) {
writer.WriteLine("{0}.{1} = pb::GeneratedRepeatExtension<{2}>.CreateInstance({0}.Descriptor.Extensions[{3}]);", scope, name, type, Descriptor.Index);
} else {
writer.WriteLine("{0}.{1} = pb::GeneratedSingleExtension<{2}>.CreateInstance({0}.Descriptor.Extensions[{3}]);", scope, name, type, Descriptor.Index);
}
}
示例7: GenerateSerializationCode
public void GenerateSerializationCode(TextGenerator writer)
{
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
writer.WriteLine("output.Write{0}Array({1}, field_names[{3}], {2}_);", MessageOrGroup, Number, Name,
FieldOrdinal, Descriptor.FieldType);
writer.Outdent();
writer.WriteLine("}");
}