public IAuraPropertiesEditor CreateEditor(IAuraModel model) { Guard.ArgumentNotNull(model, nameof(model)); var propertiesType = model.GetType(); if (editorByModelType.TryGetValue(propertiesType, out var editorType)) { return((IAuraPropertiesEditor)container.Resolve(editorType)); } Log.Warn($"Failed to resolve editor for property type {propertiesType}, source: {model} ({model.GetType()})"); return(null); }
private static Type GetPropertiesType(IAuraModel viewModel) { var expectedInterface = typeof(IAuraModel); var genericArgs = viewModel.GetType() .GetInterfaces() .Where(x => x.IsGenericType) .FirstOrDefault(x => expectedInterface.IsAssignableFrom(x.GetGenericTypeDefinition())); if (genericArgs == null) { throw new ModuleTypeLoadingException($"Failed to load settings of type {viewModel.GetType()} - interface {expectedInterface} was not found"); } var configType = genericArgs.GetGenericArguments().First(); return(configType); }