public void WriteObject <T>(T value) { if (value == null) { Write7BitEncodedInt(0); } else { int typeIndex; ContentTypeWriter typeWriter = xnbWriter.GetTypeWriter(value.GetType(), out typeIndex); // Index to to type writers is 1 based; 0 is NULL Write7BitEncodedInt(typeIndex + 1); if (activeObjects.ContainsKey(value)) { throw new InvalidOperationException("Recursive object graph detected"); } activeObjects.Add(value, true); InvokeWriter <T>(value, typeWriter); activeObjects.Remove(value); } }
public override void Initialize(ContentTypeWriterManager manager) { elementWriter = manager.GetTypeWriter(typeof(T)); }
/// <inheritdoc/> internal override void OnAddedToContentWriter(ContentWriter output) { base.OnAddedToContentWriter(output); _targetWriter = output.GetTypeWriter(typeof(T)); }
/// <inheritdoc/> protected override void Initialize(ContentCompiler compiler) { base.Initialize(compiler); _targetWriter = compiler.GetTypeWriter(typeof(T)); }