public ViewFactory Create(String nameSpace, String name) { if (Log.IsDebugEnabled) { Log.Debug(".create Creating view factory, namespace=" + nameSpace + " name=" + name); } Type viewFactoryClass = null; var pair = _viewObjects.Lookup(nameSpace, name); if (pair != null) { if (pair.Second.PluggableType == PluggableObjectType.VIEW) { // Handle named windows in a configuration that always declares a system-wide virtual view factory if (_optionalNamedWindowName != null && _virtualDataWindowViewFactory != null) { return(new VirtualDWViewFactoryImpl(_virtualDataWindowViewFactory, _optionalNamedWindowName, null)); } viewFactoryClass = pair.First; } else if (pair.Second.PluggableType == PluggableObjectType.VIRTUALDW) { if (_optionalNamedWindowName == null) { throw new ViewProcessingException("Virtual data window requires use with a named window in the create-window syntax"); } return(new VirtualDWViewFactoryImpl(pair.First, _optionalNamedWindowName, pair.Second.CustomConfigs)); } else { throw new ViewProcessingException("Invalid object type '" + pair.Second + "' for view '" + name + "'"); } } if (viewFactoryClass == null) { String message = "View name '" + nameSpace + ":" + name + "' is not a known view name"; throw new ViewProcessingException(message); } ViewFactory viewFactory; try { viewFactory = (ViewFactory)Activator.CreateInstance(viewFactoryClass); if (Log.IsDebugEnabled) { Log.Debug(".create Successfully instantiated view"); } } catch (InvalidCastException e) { String message = "Error casting view factory instance to " + typeof(ViewFactory).FullName + " interface for view '" + name + "'"; throw new ViewProcessingException(message, e); } catch (TypeInstantiationException ex) { String message = "Error invoking view factory constructor for view '" + name; message += "' using Activator.CreateInstance"; throw new ViewProcessingException(message, ex); } catch (TargetInvocationException ex) { String message = "Error invoking view factory constructor for view '" + name; message += "' using Activator.CreateInstance"; throw new ViewProcessingException(message, ex); } catch (MethodAccessException ex) { String message = "Error invoking view factory constructor for view '" + name; message += "', no invocation access for Activator.CreateInstance"; throw new ViewProcessingException(message, ex); } catch (MemberAccessException ex) { String message = "Error invoking view factory constructor for view '" + name; message += "', no invocation access for Activator.CreateInstance"; throw new ViewProcessingException(message, ex); } return(viewFactory); }
public ViewFactoryForge Create( string nameSpace, string name, string optionalCreateNamedWindowName) { if (Log.IsDebugEnabled) { Log.Debug(".create Creating view factory, namespace=" + nameSpace + " name=" + name); } Type viewFactoryClass = null; var pair = viewObjects.Lookup(nameSpace, name); if (pair != null) { if (pair.Second.PluggableType == PluggableObjectType.VIEW) { viewFactoryClass = pair.First; } else if (pair.Second.PluggableType == PluggableObjectType.VIRTUALDW) { if (optionalCreateNamedWindowName == null) { throw new ViewProcessingException( "Virtual data window requires use with a named window in the create-window syntax"); } return new VirtualDWViewFactoryForge( pair.First, optionalCreateNamedWindowName, pair.Second.CustomConfigs); } else { throw new ViewProcessingException( "Invalid object type '" + pair.Second + "' for view '" + name + "'"); } } if (viewFactoryClass == null) { var message = nameSpace == null ? "View name '" + name + "' is not a known view name" : "View name '" + nameSpace + ":" + name + "' is not a known view name"; throw new ViewProcessingException(message); } ViewFactoryForge forge; try { forge = TypeHelper.Instantiate<ViewFactoryForge>(viewFactoryClass); if (Log.IsDebugEnabled) { Log.Debug(".create Successfully instantiated view"); } } catch (TypeInstantiationException e) { var message = "Error instantiating view factory instance to " + typeof(ViewFactoryForge).CleanName() + " interface for view '" + name + "'"; throw new ViewProcessingException(message, e); } catch (InvalidCastException e) { var message = "Error casting view factory instance to " + typeof(ViewFactoryForge).CleanName() + " interface for view '" + name + "'"; throw new ViewProcessingException(message, e); } return forge; }