public void ProcessReferenceType <T>(IWriteOnlyExactValueDescriptor <T> descriptor) where T : class { Type type; if (TryReadReferenceType(descriptor, out type)) { // Do not create instance when predefined type, Just route to it. if (BinaryReaderWriterExtensions.IsPredefinedType(type)) { descriptor.Route( new BinaryStateMember (new MyCustomStateMember((IReflectionStateMember)descriptor.StateMember, type), true, true), descriptor.Owner, true); return; } T instance = (T)Activator.CreateInstance(type); _objects.Add(instance); descriptor.Set(instance); descriptor.Climb(); } }
public bool Visited(object obj) { if (_visitedHash.ContainsKey(obj)) { return(true); } if (BinaryReaderWriterExtensions.IsPredefinedType(obj.GetType())) { return(false); } _visitedHash[obj] = _visitedHash.Count; return(false); }