Zetbox.Generator.ResourceBasedGenerationHost.CallTemplateToContext C# (CSharp) Method

CallTemplateToContext() private method

private CallTemplateToContext ( string templateClass ) : void
templateClass string
return void
        private void CallTemplateToContext(string templateClass, params object[] parameters)
        {
            var providerName = String.Format(
                "{0}.{1}, {2}",
                this.Settings["providertemplatenamespace"],
                templateClass,
                this.Settings["providertemplateassembly"]);

            Type t = Type.GetType(providerName);
            if (t == null)
            {
                var defaultName = String.Format("{0}.{1}", this.Settings["basetemplatepath"], templateClass);
                t = Type.GetType(defaultName);

                if (t == null)
                {
                    Log.InfoFormat("provided template [{0}] not found", providerName);
                    throw new ArgumentOutOfRangeException("templateClass", String.Format("No class found for {0}", templateClass));
                }
                else
                {
                    Log.InfoFormat("provided template [{0}] not found, using [{1}] instead", providerName, defaultName);
                }
            }

            var fullParams = new object[] { this }.Concat(parameters).ToArray();
            ResourceTemplate template = null;
            try
            {
                template = (ResourceTemplate)Activator.CreateInstance(t, fullParams);
            }
            catch (MissingMethodException ex)
            {
                var msg = String.Format("Failed to find Constructor for {0} with signature:\n\t{1}",
                        t.FullName,
                        String.Join(",\n\t", fullParams.Select(p => p == null ? "(null)" : p.GetType().FullName).ToArray()));
                Log.Error(msg, ex);
                throw new ApplicationException(msg, ex);
            }
            template.Generate();
        }