private void EnsureInitialized() { if (configObject == null) return; var npTypes = (string[])configObject["pluginNodeProcessors"]; var tmTypes = (JsDictionary)configObject["pluginTypedMarkupParsers"]; var umTypes = (string[])configObject["pluginUntypedMarkupParsers"]; pluginNodeProcessors = new INodeProcessor[npTypes.Length]; pluginTypedMarkupParsers = new Dictionary<string, ITypedMarkupParserImpl>(); pluginUntypedMarkupParsers = new IUntypedMarkupParserImpl[umTypes.Length]; for (int i = 0; i < npTypes.Length; i++) { pluginNodeProcessors[i] = (INodeProcessor)Container.CreateObjectByTypeName(npTypes[i]); } foreach (var tm in tmTypes) { pluginTypedMarkupParsers[tm.Key] = (ITypedMarkupParserImpl)Container.CreateObjectByTypeName((string)tm.Value); } for (int i = 0; i < umTypes.Length; i++) { pluginUntypedMarkupParsers[i] = (IUntypedMarkupParserImpl)Container.CreateObjectByTypeName(umTypes[i]); } docProcessor = new DocumentProcessor(pluginNodeProcessors, new TypedMarkupParser(pluginTypedMarkupParsers), new UntypedMarkupParser(pluginUntypedMarkupParsers)); configObject = null; }
/// <summary> /// On the server, an easier way to obtain a parser is through the SaltarelleParserFactory class. /// </summary> public SaltarelleParser(INodeProcessor[] pluginNodeProcessors, IDictionary<string, ITypedMarkupParserImpl> pluginTypedMarkupParsers, IUntypedMarkupParserImpl[] pluginUntypedMarkupParsers) { #if CLIENT JsDictionary cfg = JsDictionary.GetDictionary(pluginNodeProcessors); if (!Script.IsNullOrUndefined(cfg) && cfg.ContainsKey("pluginNodeProcessors")) { // We have an [AlternateSignature] constructor which can cause us to be called with a config object instead of real parameters configObject = cfg; return; } #endif docProcessor = new DocumentProcessor(pluginNodeProcessors, new TypedMarkupParser(pluginTypedMarkupParsers), new UntypedMarkupParser(pluginUntypedMarkupParsers)); this.pluginNodeProcessors = pluginNodeProcessors ?? new INodeProcessor[0]; this.pluginTypedMarkupParsers = pluginTypedMarkupParsers ?? new Dictionary<string, ITypedMarkupParserImpl>(); this.pluginUntypedMarkupParsers = pluginUntypedMarkupParsers ?? new IUntypedMarkupParserImpl[0]; }