本文整理汇总了C#中Tools.Serialiser类的典型用法代码示例。如果您正苦于以下问题:C# Serialiser类的具体用法?C# Serialiser怎么用?C# Serialiser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Serialiser类属于Tools命名空间,在下文中一共展示了Serialiser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public void Emit(TextWriter m_outFile)
{
Serialiser b = new Serialiser(m_outFile);
b.VersionCheck();
Console.WriteLine("Serialising the parser");
b.Serialise(m_startSymbol);
b.Serialise(m_accept);
b.Serialise(m_states);
b.Serialise(literals);
b.Serialise(symbolInfo);
b.Serialise(m_concrete);
m_outFile.WriteLine("0};");
}
示例2: EmitDfa
public void EmitDfa(TextWriter outFile)
{
Console.WriteLine("Serializing the lexer");
Serialiser f = new Serialiser(outFile);
f.Serialise(m_encoding);
f.Serialise(toupper);
f.Serialise(cats);
f.Serialise(m_gencat);
f.Serialise(usingEOF);
f.Serialise(starts);
f.Serialise(tokens);
outFile.WriteLine("0};");
}
示例3: Serialise
public static object Serialise(object o,Serialiser s)
{
if (s==null)
return new TokClassDef();
TokClassDef t = (TokClassDef)o;
if (s.Encode)
{
s.Serialise(t.m_name);
return null;
}
t.m_name = (string)s.Deserialise();
return t;
}
示例4: GetDfa
// Deserializing
public void GetDfa()
{
if (tokens.Count>0)
return;
Serialiser f = new Serialiser(arr);
m_encoding = (Encoding)f.Deserialise();
toupper = (bool)f.Deserialise();
cats = (Hashtable)f.Deserialise();
m_gencat = (UnicodeCategory)f.Deserialise();
usingEOF = (bool)f.Deserialise();
starts = (Hashtable)f.Deserialise();
Dfa.SetTokens(this,starts);
tokens = (Hashtable)f.Deserialise();
}
示例5: Serialise
/// <exclude/>
public static object Serialise(object o,Serialiser s)
{
if (s==null)
return new CSymbol();
CSymbol c = (CSymbol)o;
if (s.Encode)
{
s.Serialise(c.yytext);
s.Serialise(c.m_yynum);
s.Serialise((int)c.m_symtype);
return null;
}
c.yytext = (string)s.Deserialise();
c.m_yynum = (int)s.Deserialise();
c.m_symtype = (SymType)s.Deserialise();
return c;
}
示例6: Serialise
/// <exclude/>
public static object Serialise(object o,Serialiser s)
{
if (s==null)
return new Dfa();
Dfa d = (Dfa)o;
if (s.Encode)
{
s.Serialise(d.m_state);
s.Serialise(d.m_map);
s.Serialise(d.m_actions);
s.Serialise(d.m_tokClass);
s.Serialise(d.m_reswds);
return null;
}
d.m_state = (int)s.Deserialise();
d.m_map = (Hashtable)s.Deserialise();
d.m_actions = (Action)s.Deserialise();
d.m_tokClass = (string)s.Deserialise();
d.m_reswds = (int)s.Deserialise();
return d;
}
示例7: Serialise
public new static object Serialise(object o,Serialiser s)
{
if (s==null)
return new ParserOldAction();
ParserOldAction p = (ParserOldAction)o;
if (s.Encode)
{
ParserAction.Serialise(p,s);
s.Serialise(p.m_action);
return null;
}
ParserAction.Serialise(p,s);
p.m_action = (int)s.Deserialise();
return p;
}
示例8: IntSerialise
static object IntSerialise(object o,Serialiser s)
{
if (s.Encode)
{
s._Write((int)o);
return null;
}
return s._Read();
}
示例9: BoolSerialise
static object BoolSerialise(object o,Serialiser s)
{
if (s.Encode)
{
s._Write(((bool)o)?1:0);
return null;
}
int v = s._Read();
return v!=0;
}
示例10: UnicodeCategorySerialise
static object UnicodeCategorySerialise(object o,Serialiser s)
{
if (s.Encode)
{
s._Write((int)o);
return null;
}
return (UnicodeCategory)s._Read();
}
示例11: Serialise
/// <exclude/>
public static object Serialise(object o,Serialiser s)
{
if (s==null)
return new Charset();
Charset c = (Charset)o;
if (s.Encode)
{
s.Serialise((int)c.m_cat);
s.Serialise(c.m_generic);
s.Serialise(c.m_chars);
return null;
}
c.m_cat = (UnicodeCategory)s.Deserialise();
c.m_generic = (char)s.Deserialise();
c.m_chars = (Hashtable)s.Deserialise();
return c;
}
示例12: SymtypeSerialise
static object SymtypeSerialise(object o,Serialiser s)
{
if (s.Encode)
{
s._Write((int)o);
return null;
}
return (CSymbol.SymType)s._Read();
}
示例13: StringSerialise
static object StringSerialise(object o,Serialiser s)
{
if (s==null)
return "";
Encoding e = new UnicodeEncoding();
if (s.Encode)
{
byte[] b = e.GetBytes((string)o);
s._Write(b.Length);
for (int j=0;j<b.Length;j++)
s._Write((int)b[j]);
return null;
}
int ln = s._Read();
byte[] bb = new byte[ln];
for (int k=0;k<ln;k++)
bb[k] = (byte)s._Read();
string r = e.GetString(bb,0,ln);
return r;
}
示例14: NullSerialise
static object NullSerialise(object o,Serialiser s)
{
return null;
}
示例15: EncodingSerialise
static object EncodingSerialise(object o,Serialiser s)
{
if (s.Encode)
{
Encoding e = (Encoding)o;
s.Serialise(e.WebName);
return null;
}
switch((string)s.Deserialise())
{
case "us-ascii": return Encoding.ASCII;
case "utf-16": return Encoding.Unicode;
case "utf-7": return Encoding.UTF7;
case "utf-8": return Encoding.UTF8;
}
throw new Exception("Unknown encoding");
}