本文整理汇总了C#中Serializer类的典型用法代码示例。如果您正苦于以下问题:C# Serializer类的具体用法?C# Serializer怎么用?C# Serializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Serializer类属于命名空间,在下文中一共展示了Serializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YamlManager
/// <summary>
/// Initializes a new instance of the <see cref="GameSystem" /> class.
/// </summary>
/// <param name="game">The game.</param>
public YamlManager(Game game) : base(game)
{
Services.AddService(this);
yamlSettings = new SerializerSettings();
attributeRegistry = yamlSettings.Attributes;
serializer = new Serializer(yamlSettings);
}
示例2: Serialize
public override void Serialize(Serializer serializer)
{
base.Serialize(serializer);
serializer.Serialize(ref delta, "delta");
serializer.Serialize(ref itemDefinition, "itemDefinition");
}
示例3: BuildSerializer
public override ValueSerializer BuildSerializer(Serializer serializer, Type type,
ConcurrentDictionary<Type, ValueSerializer> typeMapping)
{
var x = new ObjectSerializer(type);
typeMapping.TryAdd(type, x);
var elementType = GetEnumerableType(type);
var arrType = elementType.MakeArrayType();
var listModule = type.Assembly.GetType("Microsoft.FSharp.Collections.ListModule");
var ofArray = listModule.GetMethod("OfArray");
var ofArrayConcrete = ofArray.MakeGenericMethod(elementType);
var ofArrayCompiled = CodeGenerator.CompileToDelegate(ofArrayConcrete, arrType);
var toArray = listModule.GetMethod("ToArray");
var toArrayConcrete = toArray.MakeGenericMethod(elementType);
var toArrayCompiled = CodeGenerator.CompileToDelegate(toArrayConcrete, type);
ValueWriter writer = (stream, o, session) =>
{
var arr = toArrayCompiled(o);
var arrSerializer = serializer.GetSerializerByType(arrType);
arrSerializer.WriteValue(stream,arr,session);
};
ValueReader reader = (stream, session) =>
{
var arrSerializer = serializer.GetSerializerByType(arrType);
var items = (Array)arrSerializer.ReadValue(stream, session);
var res = ofArrayCompiled(items);
return res;
};
x.Initialize(reader, writer);
return x;
}
示例4: SyncState
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("block", ref block);
ser.Sync("prg", ref prg);
ser.Sync("mode", ref mode);
}
示例5: SyncState
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("toggle1", ref _toggle1);
ser.Sync("toggle2", ref _toggle2);
ser.Sync("toggle3", ref _toggle3);
}
示例6: SyncState
public override void SyncState(Serializer ser)
{
ser.Sync("bank_4k", ref _bank4K);
ser.Sync("gameTotal", ref _gameTotal);
ser.Sync("currentGame", ref _currentGame);
base.SyncState(ser);
}
示例7: SyncState
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.BeginSection("FDS");
ser.BeginSection("RamAdapter");
diskdrive.SyncState(ser);
ser.EndSection();
ser.BeginSection("audio");
audio.SyncState(ser);
ser.EndSection();
{
// silly little hack
int tmp = currentside != null ? (int)currentside : 1234567;
ser.Sync("currentside", ref tmp);
currentside = tmp == 1234567 ? null : (int?)tmp;
}
for (int i = 0; i < NumSides; i++)
ser.Sync("diskdiffs" + i, ref diskdiffs[i], true);
ser.Sync("_timerirq", ref _timerirq);
ser.Sync("_diskirq", ref _diskirq);
ser.Sync("diskenable", ref diskenable);
ser.Sync("soundenable", ref soundenable);
ser.Sync("reg4026", ref reg4026);
ser.Sync("timerlatch", ref timerlatch);
ser.Sync("timervalue", ref timervalue);
ser.Sync("timerreg", ref timerreg);
ser.EndSection();
SetIRQ();
}
示例8: SyncState
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("reg_addr", ref reg_addr);
ser.Sync("regs", ref regs);
Sync();
}
示例9: Serialize
public override void Serialize(Serializer serializer)
{
base.Serialize(serializer);
serializer.Serialize(ref delta, "delta");
serializer.Serialize(ref soundId, "soundId");
}
示例10: GenXML
public void GenXML()
{
String sourceUri = Server.MapPath("5648.xml");
String xqUri = Server.MapPath("graph.xq");
using (FileStream sXml = File.OpenRead(sourceUri))
{
using (FileStream sXq = File.OpenRead(xqUri))
{
Processor processor = new Processor();
XQueryCompiler compiler = processor.NewXQueryCompiler();
compiler.BaseUri = sourceUri;
XQueryExecutable exp = compiler.Compile(sXq);
XQueryEvaluator eval = exp.Load();
DocumentBuilder loader = processor.NewDocumentBuilder();
loader.BaseUri = new Uri(sourceUri);
XdmNode indoc = loader.Build(new FileStream(sourceUri, FileMode.Open, FileAccess.Read));
eval.ContextItem = indoc;
Serializer qout = new Serializer();
qout.SetOutputProperty(Serializer.METHOD, "xml");
qout.SetOutputProperty(Serializer.INDENT, "yes");
qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
qout.SetOutputWriter(Response.Output);
eval.Run(qout);
}
}
}
示例11: Deserialize
public void Deserialize(System.IO.TextReader rdr, Serializer serializer) {
string name, value;
var parameters = new System.Collections.Specialized.NameValueCollection();
while (rdr.Property(out name, out value, parameters) && !string.IsNullOrEmpty(name)) {
switch (name.ToUpper()) {
case "BEGIN":
switch (value) {
case "VALARM":
var a = serializer.GetService<Alarm>();
a.Deserialize(rdr, serializer);
Alarms.Add(a);
break;
}
break;
case "ATTENDEE":
var contact = new Contact();
contact.Deserialize(value, parameters);
Attendees.Add(contact);
break;
case "CATEGORIES":
Categories = value.SplitEscaped().ToList();
break;
case "CLASS": Class = value.ToEnum<Classes>(); break;
case "CREATED": Created = value.ToDateTime(); break;
case "DESCRIPTION": Description = value; break;
case "DTEND": End = value.ToDateTime(); break;
case "DTSTAMP": DTSTAMP = value.ToDateTime().GetValueOrDefault(); break;
case "DTSTART": Start = value.ToDateTime(); break;
case "LAST-MODIFIED": LastModified = value.ToDateTime(); break;
case "LOCATION": Location = value; break;
case "ORGANIZER":
Organizer = serializer.GetService<Contact>();
Organizer.Deserialize(value, parameters);
break;
case "PRIORITY": Priority = value.ToInt(); break;
case "SEQUENCE": Sequence = value.ToInt(); break;
case "STATUS": Status = value.ToEnum<Statuses>(); break;
case "SUMMARY": Summary = value; break;
case "TRANSP": Transparency = value; break;
case "UID": UID = value; break;
case "URL": Url = value.ToUri(); break;
case "ATTACH":
var attach = value.ToUri();
if (attach != null)
Attachments.Add(attach);
break;
case "RRULE":
var rule = serializer.GetService<Recurrence>();
rule.Deserialize(null, parameters);
Recurrences.Add(rule);
break;
case "END": return;
default:
Properties.Add(Tuple.Create(name, value, parameters));
break;
}
}
IsAllDay = Start == End;
}
示例12: LoadXML
public virtual void LoadXML(string filename)
{
Serializer<List<StringMap>> serializer = new Serializer<List<StringMap>>();
List<StringMap> tmp = serializer.Load(filename);
if (tmp != null)
stringmap = tmp;
}
示例13: SyncState
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("irq_target", ref irq_target);
ser.Sync("irq_counter", ref irq_counter);
ser.Sync("irq_enabled", ref irq_enabled);
ser.Sync("irq_pending", ref irq_pending);
ser.Sync("in_frame", ref in_frame);
ser.Sync("exram_mode", ref exram_mode);
ser.Sync("chr_mode", ref chr_mode);
ser.Sync("prg_mode", ref prg_mode);
ser.Sync("chr_reg_high", ref chr_reg_high);
ser.Sync("ab_mode", ref ab_mode);
ser.Sync("regs_a", ref regs_a);
ser.Sync("regs_b", ref regs_b);
ser.Sync("regs_prg", ref regs_prg);
ser.Sync("nt_modes", ref nt_modes);
ser.Sync("nt_fill_tile", ref nt_fill_tile);
ser.Sync("nt_fill_attrib", ref nt_fill_attrib);
ser.Sync("wram_bank", ref wram_bank);
ser.Sync("last_nt_read", ref last_nt_read);
ser.Sync("EXRAM", ref EXRAM, false);
SyncPRGBanks();
SyncCHRBanks();
SyncMultiplier();
SyncIRQ();
audio.SyncState(ser);
}
示例14: SyncState
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("prg_mode_mapper", ref prg_mode_mapper);
ser.Sync("prg_page", ref prg_page);
ser.Sync("chr_block_or", ref chr_block_or);
}
示例15: Serialize
public override void Serialize(Serializer serializer)
{
base.Serialize(serializer);
serializer.Serialize(ref delta, "delta");
serializer.Serialize(ref damage, "damage");
}