public void RegisterFactory(Type type, string category = "") { if (!type.IsSubclassOf(typeof(Object))) { throw new ArgumentException("Type must be subclass of Object."); } _factoryTypes[StringHash.Calculate(type.Name)] = type; // Find a wrapper base type. var baseType = type.BaseType; while (baseType != null && baseType.Assembly != typeof(Context).Assembly) { baseType = baseType.BaseType; } if (baseType == null) { throw new InvalidOperationException("This type can not be registered as factory."); } Urho3D_Context_RegisterFactory(getCPtr(this), type.Name, StringHash.Calculate("SwigDirector_" + baseType.Name), category); if (type.IsSubclassOf(typeof(Serializable))) { using (var serializable = (Serializable)Activator.CreateInstance(type, new object[] { Context.Instance })) { serializable.RegisterAttributes(); } } }
public void RegisterFactory(Type type, string category = "") { if (!type.IsSubclassOf(typeof(Object))) { throw new ArgumentException("Type must be subclass of Object."); } _factoryTypes[StringHash.Calculate(type.Name)] = type; // Find a wrapper base type. var baseType = type.BaseType; while (baseType != null && baseType.Assembly != typeof(Context).Assembly) { baseType = baseType.BaseType; } if (baseType == null) { throw new InvalidOperationException("This type can not be registered as factory."); } Urho3D_Context_RegisterFactory(getCPtr(this), type.Name, StringHash.Calculate("SwigDirector_" + baseType.Name), category); }