本文整理汇总了C#中StreamWriterLevel.Write方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriterLevel.Write方法的具体用法?C# StreamWriterLevel.Write怎么用?C# StreamWriterLevel.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamWriterLevel
的用法示例。
在下文中一共展示了StreamWriterLevel.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintCIsConstraintValid
public static void PrintCIsConstraintValid(Asn1Type pThis, PEREffectiveConstraint cns, StreamWriterLevel c, string errorCode, string typeName, string varName, int lev, int arrayDepth)
{
string varName2 = varName;
if (!varName.Contains("->"))
varName2 = "*" + varName;
if (pThis.m_constraints.Count > 0)
{
c.P(lev); c.Write("if ( !(");
for (int i = 0; i < pThis.m_constraints.Count; i++)
{
string ret = ((ISCConstraint)pThis.m_constraints[i]).PrintCIsConstraintValid(varName2, lev);
c.Write(ret);
if (i != pThis.m_constraints.Count - 1)
c.Write(" && ");
}
c.WriteLine(") ) {");
c.P(lev + 1);
c.WriteLine("*pErrCode = ERR_{0};", C.ID(errorCode));
c.P(lev + 1);
c.WriteLine("return FALSE;");
c.P(lev);
c.WriteLine("}");
}
}
示例2: Print
public static void Print(StreamWriterLevel c, OrderedDictionary<string, CLocalVariable> vars)
{
foreach (CLocalVariable v in vars.Values)
{
c.P(1);
if (v.staticDeclaration)
c.Write("static ");
c.Write("{0} {1}", v.type, v.varName);
if (v.arrayLen > 0)
c.Write("[{0}]",v.arrayLen);
if (v.initVal != "")
c.Write(" = {0}", v.initVal);
c.WriteLine(";");
//if (v.arrayLen == 0)
//{
// c.WriteLine("{0} {1} = {2};", v.type, v.varName, v.initVal);
//}
//else
//{
// c.WriteLine("{0} {1}[{2}];", v.type, v.varName, v.arrayLen);
//}
}
if (vars.Count > 0)
c.WriteLine();
}
示例3: dump
public static void dump(string fileName, string outFileName, bool ignoreExtraBytes, bool handleExtraBytesAsDNA)
{
using (MemoryStream f = new MemoryStream(File.ReadAllBytes(fileName), false))
using (StreamWriterLevel w = new StreamWriterLevel(outFileName))
{
do
{
BERNode root = BERNode.Create(f);
root.dump(w, 0);
} while (!ignoreExtraBytes && handleExtraBytesAsDNA && f.Length>f.Position);
if (!ignoreExtraBytes && !handleExtraBytesAsDNA && f.Position < f.Length)
{
w.WriteLine("File contains {0} extra bytes at the end", f.Length-f.Position);
int rdVal = 0;
int col = 0;
while ((rdVal = f.ReadByte()) != -1)
{
col++;
if (col % 80 == 0)
w.WriteLine();
byte b = (byte)rdVal;
w.Write(b.ToString("X2"));
}
}
}
}
示例4: PrintC
public static void PrintC(ArrayValue pThis, StreamWriterLevel c, int lev)
{
c.WriteLine("{");
lev++;
int cnt = pThis.m_children.Count;
c.P(lev); c.WriteLine("{0},", cnt);
c.P(lev); c.WriteLine("{");
for (int i = 0; i < cnt; i++)
{
c.P(lev + 1);
((ISCCVariable)pThis.m_children[i]).PrintC(c, lev + 1);
if (i != cnt - 1)
c.WriteLine(",");
else
c.WriteLine();
}
c.P(lev); c.WriteLine("}");
lev--;
c.P(lev);
c.Write("}");
}
示例5: PrintAsn1
public override void PrintAsn1(StreamWriterLevel o)
{
if (m_size != null)
{
o.Write("SIZE [");
m_size.m_rootRange.PrintAsn1(o);
if (m_size.Extensible)
o.Write(",...");
if (m_size.m_extRange != null)
{
o.Write(",");
m_size.m_extRange.PrintAsn1(o);
}
o.Write("]");
}
if (m_from != null)
{
o.Write("FROM [\"");
o.Write(m_from.ToString());
o.Write("\"]");
}
}
示例6: PrintExternDeclaration
public void PrintExternDeclaration(StreamWriterLevel h)
{
// h.WriteLine("extern {0} {1};", C.ID(m_type.Name), C.ID(m_name));
h.Write("extern ");
((ISCCType)m_type).PrintHTypeDeclaration(m_type.PEREffectiveConstraint, h, "", "", 0);
h.WriteLine(" {0};", C.ID(m_name));
}
示例7: PrintHTypeDeclaration
public void PrintHTypeDeclaration(PEREffectiveConstraint cns, StreamWriterLevel h, string typeName, string varName, int lev)
{
h.Write("NullType ");
}
示例8: PrintCEncodeItem
public static void PrintCEncodeItem(IA5StringType pThis, PEREffectiveConstraint cns, StreamWriterLevel c, string errorCode, string varName, int lev)
{
PERAlphabetAndSizeEffectiveConstraint cn = (PERAlphabetAndSizeEffectiveConstraint)cns;
CharSet perAlphaCon = cn.m_from;
int min = 0;
int max;
List<char> tmp = null;
if (perAlphaCon != null)
tmp = perAlphaCon.m_set;
else
tmp = new List<char>(pThis.AllowedCharSet);
max = tmp.Count - 1;
if (min == max)
return;
c.P(lev);
c.Write("static byte allowedCharSet[] = {");
for (int i = 0; i < tmp.Count; i++)
{
c.Write("0x{0:X2}", Convert.ToByte(tmp[i]));
if (i == tmp.Count - 1)
c.WriteLine("};");
else
c.Write(",");
if ((i + 1) % 15 == 0)
{
c.WriteLine();
c.P(lev + 7);
}
}
c.P(lev);
c.WriteLine("int charIndex = GetCharIndex({0}, allowedCharSet,{1});", varName, tmp.Count);
c.P(lev);
c.WriteLine("BitStream_EncodeConstraintWholeNumber(pBitStrm, charIndex, {0}, {1});", 0, tmp.Count - 1);
}
示例9: PrintHTypeDeclaration
public static void PrintHTypeDeclaration(SequenceOrSetType pThis, PEREffectiveConstraint cns, StreamWriterLevel h, string typeName, string varName, int lev)
{
h.WriteLine("struct {");
// h.WriteLine("struct {0} {{", typeName);
foreach (SequenceOrSetType.Child ch in pThis.m_children.Values)
{
h.WriteComment(ch.m_comments, lev + 1);
h.P(lev + 1);
((ISCCType)ch.m_type).PrintHTypeDeclaration(ch.m_type.PEREffectiveConstraint, h,
typeName + "_" + C.ID(ch.m_childVarName), C.ID(ch.m_childVarName), lev + 1);
if (!(ch.m_type is IA5StringType))
h.WriteLine(" {0};", C.ID(ch.m_childVarName));
}
if (pThis.GetNumberOfOptionalOrDefaultFields() != 0)
{
h.P(lev + 1);
h.WriteLine("struct {");
foreach (SequenceOrSetType.Child ch in pThis.m_children.Values)
{
if (ch.m_optional || ch.m_defaultValue != null)
{
h.P(lev + 2);
h.WriteLine("unsigned int {0}:1;", C.ID(ch.m_childVarName));
}
}
h.P(lev + 1);
h.WriteLine("} exist;");
}
h.P(lev);
h.Write("}");
}
示例10: PrintAsn1InHtml
public void PrintAsn1InHtml(StreamWriterLevel wr, int lev)
{
//string fname = m_fileName.Substring(m_fileName.LastIndexOf(
wr.WriteLine(" <div style=\"width: 100%\">");
wr.WriteLine(" <h1 >File : {0}</h1>", System.IO.Path.GetFileName(m_fileName));
wr.WriteLine("<div style=\"width: 100%; white-space:pre; font-family:Courier New; font-size:small\">");
wr.Write(getAsn1InHtml());
wr.WriteLine("</div>");
wr.WriteLine(" </div>");
}
示例11: PrintCIsConstraintValidAuxBody
public void PrintCIsConstraintValidAuxBody(StreamWriterLevel c)
{
AuxFunctionID = nCount;
c.WriteLine("flag CheckString{0}(const char* str)", AuxFunctionID);
c.WriteLine("{");
c.P(1); c.WriteLine("size_t i;");
c.P(1); c.WriteLine("size_t n = strlen(str);");
c.P(1);
c.WriteLine("for(i=0;i<n;i++)");
c.P(1); c.WriteLine("{");
c.P(2);
c.Write("if (!");
for (int i = 0; i < allowed_char_set.m_constraints.Count; i++)
{
c.Write(((ISCConstraint)allowed_char_set.m_constraints[i]).PrintCIsConstraintValid("str[i]", 0));
if (i != allowed_char_set.m_constraints.Count - 1)
c.Write(" && ");
}
c.WriteLine(")");
c.P(3);
c.WriteLine("return FALSE;");
c.P(1); c.WriteLine("}");
c.P(1); c.WriteLine("return TRUE;");
c.WriteLine("}");
}
示例12: PrintCIsConstraintValid
public void PrintCIsConstraintValid(PEREffectiveConstraint cns, StreamWriterLevel c, string errorCode, string typeName, string varName, int lev, int arrayDepth)
{
c.P(lev); c.Write("if ( !");
if ((Type is IA5StringType) || !varName.Contains("->"))
c.WriteLine("{0}_IsConstraintValid({1}, pErrCode) )", DefaultBackend.Instance.TypePrefix + C.ID(m_referencedTypeName), varName);
else
c.WriteLine("{0}_IsConstraintValid(&{1}, pErrCode) )", DefaultBackend.Instance.TypePrefix + C.ID(m_referencedTypeName), varName);
c.P(lev);
c.WriteLine("{");
//c.P(lev + 1);
//c.WriteLine("*pErrCode = ERR_{0};", C.ID(errorCode));
c.P(lev + 1);
c.WriteLine("return FALSE;");
c.P(lev);
c.WriteLine("}");
CSSType.PrintCIsConstraintValid(this, cns, c, errorCode, typeName, varName, lev, arrayDepth);
}
示例13: PrintCDecodeItem
public static void PrintCDecodeItem(IA5StringType pThis, PEREffectiveConstraint cns, StreamWriterLevel c, string varName, int lev)
{
PERAlphabetAndSizeEffectiveConstraint cn = (PERAlphabetAndSizeEffectiveConstraint)cns;
CharSet perAlphaCon = cn.m_from;
int min = 0;
int max;
List<char> tmp = null;
if (perAlphaCon != null)
tmp = perAlphaCon.m_set;
else
tmp = new List<char>(pThis.AllowedCharSet);
max = tmp.Count - 1;
if (min == max)
return;
c.P(lev);
c.Write("static byte allowedCharSet[] = {");
for (int i = 0; i < tmp.Count; i++)
{
c.Write("0x{0:X2}", Convert.ToByte(tmp[i]));
if (i == tmp.Count - 1)
c.WriteLine("};");
else
c.Write(",");
if ((i + 1) % 15 == 0)
{
c.WriteLine();
c.P(lev + 7);
}
}
c.P(lev);
c.WriteLine("asn1SccSint charIndex = 0;");
c.P(lev);
c.WriteLine("if (!BitStream_DecodeConstraintWholeNumber(pBitStrm, &charIndex, {0}, {1})) {{", 0, tmp.Count - 1);
c.P(lev + 1);
c.WriteLine("*pErrCode = ERR_INSUFFICIENT_DATA;");
c.P(lev + 1);
c.WriteLine("return FALSE;");
c.P(lev);
c.WriteLine("}");
c.P(lev);
c.WriteLine("{0} = allowedCharSet[charIndex];", varName);
}
示例14: PrintAsn1
public override void PrintAsn1(StreamWriterLevel o, int lev)
{
if (m_tag != null)
m_tag.PrintAsn1(o, lev);
o.Write("SEQUENCE");
PrintAsn1Constraints(o);
o.Write(" OF ");
m_type.PrintAsn1(o, lev);
}
示例15: PrintH
internal void PrintH(StreamWriterLevel h, string uniqueID)
{
////print type declaration
//h.WriteLine("/*");
//h.WriteLine("Definition of :{0}", m_name);
//foreach(string line in m_comments)
// h.WriteLine("{0}", line);
//h.WriteLine("*/");
h.WriteComment(m_comments, 0);
h.Write("typedef ");
((ISCCType)m_type).PrintHTypeDeclaration(m_type.PEREffectiveConstraint, h, uniqueID, "", 0);
if (!(m_type is IA5StringType))
h.WriteLine(" {0};", uniqueID);
h.WriteLine();
//print
h.WriteLine("#define {0}_REQUIRED_BYTES_FOR_ENCODING {1}", uniqueID, m_type.MaxBytesInPER);
h.WriteLine();
((ISCCType)m_type).PrintHConstraintConstant(h, uniqueID);
h.WriteLine();
string star = "";
if (!(m_type is IA5StringType))
star = "*";
h.WriteLine("void {0}_Initialize({0}{1} pVal);", uniqueID, star);
h.WriteLine("flag {0}_IsConstraintValid(const {0}{1} val, int* pErrCode);", uniqueID, star);
h.WriteLine("flag {0}_Encode(const {0}{1} val, BitStream* pBitStrm, int* pErrCode, flag bCheckConstraints);", uniqueID, star);
h.WriteLine("flag {0}_Decode({0}{1} pVal, BitStream* pBitStrm, int* pErrCode);", uniqueID, star);
h.WriteLine();
h.WriteLine();
}