private object ReadEntityComponent() { var referenceId = Reader.ReadInt32(); var componentTypeGuid = (EntityComponent.GUID)Read(); var type = EntityComponent.GetComponentTypeByGUID(componentTypeGuid); if (type == null) { ReadObjectMembers(null, null, false); return(null); } object obj = null; try { obj = type != null?Activator.CreateInstance(type) : null; } catch (MissingMethodException) { throw new MissingMethodException(string.Format(MissingMethodText, type.Name, nameof(EntityComponent))); } catch (MissingMemberException) { // Same error as MissingMethodException, but required for certain platforms. throw new MissingMemberException(string.Format(MissingMethodText, type.Name, nameof(EntityComponent))); } catch (MethodAccessException) { throw new MethodAccessException(string.Format(MethodAccessText, type.Name, nameof(EntityComponent))); } catch (MemberAccessException) { // Same error as MethodAccessException, but required for certain platforms. throw new MemberAccessException(string.Format(MethodAccessText, type.Name, nameof(EntityComponent))); } catch (Exception ex) { throw (ex); } if (type != null) { AddReference(type, obj, referenceId); } ReadObjectMembers(obj, type, true); return(obj); }
object ReadEntityComponent() { var referenceId = Reader.ReadInt32(); var componentTypeGuid = (EntityComponent.GUID)Read(); var type = EntityComponent.GetComponentTypeByGUID(componentTypeGuid); var obj = type != null?FormatterServices.GetUninitializedObject(type) : null; if (type != null) { AddReference(type, obj, referenceId); } ReadObjectMembers(obj, type); return(obj); }