public void Register(Type gameType, Type apiType, GameObjectCategory category) { if (apiType == null || gameType == null) { return; } if (!typeof(MyObjectBuilder_Base).IsAssignableFrom(gameType)) { return; } if (!typeof(BaseObject).IsAssignableFrom(apiType)) { return; } if (m_typeMap.ContainsKey(gameType)) { return; } if (m_typeMap.ContainsValue(apiType)) { return; } if (!ValidateRegistration(gameType, apiType)) { return; } GuidAttribute guid = (GuidAttribute)Assembly.GetCallingAssembly( ).GetCustomAttributes(typeof(GuidAttribute), true)[0]; Guid guidValue = new Guid(guid.Value); GameObjectTypeEntry entry = new GameObjectTypeEntry( ); entry.source = guidValue; entry.gameType = gameType; entry.apiType = apiType; entry.enabled = true; entry.category = category; m_typeMap.Add(gameType, apiType); if (m_registry.ContainsKey(guidValue)) { HashSet <GameObjectTypeEntry> hashSet = m_registry[guidValue]; hashSet.Add(entry); } else { HashSet <GameObjectTypeEntry> hashSet = new HashSet <GameObjectTypeEntry>( ); hashSet.Add(entry); m_registry.Add(guidValue, hashSet); } }
public void Register(Type gameType, Type apiType, GameObjectCategory category) { if (apiType == null || gameType == null) return; if (!typeof(MyObjectBuilder_Base).IsAssignableFrom(gameType)) return; if (!typeof(BaseObject).IsAssignableFrom(apiType)) return; if (m_typeMap.ContainsKey(gameType)) return; if (m_typeMap.ContainsValue(apiType)) return; if (!ValidateRegistration(gameType, apiType)) return; GuidAttribute guid = (GuidAttribute)Assembly.GetCallingAssembly().GetCustomAttributes(typeof(GuidAttribute), true)[0]; Guid guidValue = new Guid(guid.Value); GameObjectTypeEntry entry = new GameObjectTypeEntry(); entry.source = guidValue; entry.gameType = gameType; entry.apiType = apiType; entry.enabled = true; entry.category = category; m_typeMap.Add(gameType, apiType); if (m_registry.ContainsKey(guidValue)) { HashSet<GameObjectTypeEntry> hashSet = m_registry[guidValue]; hashSet.Add(entry); } else { HashSet<GameObjectTypeEntry> hashSet = new HashSet<GameObjectTypeEntry>(); hashSet.Add(entry); m_registry.Add(guidValue, hashSet); } }