Exemplo n.º 1
0
 public CodeDomTemplateTypeBuilder(TemplateOptions options)
 {
     ProviderOptions = new Dictionary <string, string>();
     Options         = options;
     Options.AddReference(GetType().Assembly);
 }
 public CodeDomTemplateTypeBuilder( TemplateOptions options )
 {
     ProviderOptions = new Dictionary<string, string>();
     Options = options;
     Options.AddReference(GetType().Assembly);
 }
Exemplo n.º 3
0
        public static void UpdateTemplateOptions(TemplateOptions options)
        {
            if (options == null)
                throw new ArgumentNullException("options");

            var section = GetSection();

            if (section == null)
            {
                return;
            }

            if (section.IndentSize.HasValue)
            {
                options.IndentSize = section.IndentSize.Value;
            }

            if (section.AutoRecompile.HasValue)
            {
                options.AutoRecompile = section.AutoRecompile.Value;
            }
            else
            {
                options.AutoRecompile = true;
            }

            if (section.UseTabs.HasValue)
            {
                options.UseTabs = section.UseTabs.Value;
            }

            if (!string.IsNullOrEmpty(section.TemplateBaseType))
            {
                options.TemplateBaseType = Type.GetType(section.TemplateBaseType, true, false);
            }

            if (section.EncodeHtml.HasValue)
            {
                options.EncodeHtml = section.EncodeHtml.Value;
            }

            if (section.OutputDebugFiles.HasValue)
            {
                options.OutputDebugFiles = section.OutputDebugFiles.Value;
            }

            if (!string.IsNullOrEmpty(section.TemplateCompiler))
            {
                options.TemplateCompiler = section.CreateTemplateCompiler();
            }

            foreach (var assemblyConfigurationElement in section.Assemblies)
            {
                Assembly assembly;
                var assemblyName = assemblyConfigurationElement.Name;
                try
                {
                    assembly = Assembly.Load(assemblyName);
                }
                catch (Exception exception)
                {
                    var message = string.Format("Coule not load Assembly '{0}'.Did you forget to fully qualify it?eg 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'", assemblyName);
                    throw new Exception(message, exception);
                }
                options.AddReference(assembly.Location);
            }

            foreach (var namespaceConfigurationElement in section.Namespaces)
            {
                options.AddUsing(namespaceConfigurationElement.Name);
            }
        }
Exemplo n.º 4
0
        public static void UpdateTemplateOptions(TemplateOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            var section = GetSection();

            if (section == null)
            {
                return;
            }

            if (section.IndentSize.HasValue)
            {
                options.IndentSize = section.IndentSize.Value;
            }

            if (section.AutoRecompile.HasValue)
            {
                options.AutoRecompile = section.AutoRecompile.Value;
            }
            else
            {
                options.AutoRecompile = true;
            }

            if (section.UseTabs.HasValue)
            {
                options.UseTabs = section.UseTabs.Value;
            }

            if (!string.IsNullOrEmpty(section.TemplateBaseType))
            {
                options.TemplateBaseType = Type.GetType(section.TemplateBaseType, true, false);
            }

            if (section.EncodeHtml.HasValue)
            {
                options.EncodeHtml = section.EncodeHtml.Value;
            }

            if (section.OutputDebugFiles.HasValue)
            {
                options.OutputDebugFiles = section.OutputDebugFiles.Value;
            }



            if (!string.IsNullOrEmpty(section.TemplateCompiler))
            {
                options.TemplateCompiler = section.CreateTemplateCompiler();
            }

            foreach (var assemblyConfigurationElement in section.Assemblies)
            {
                Assembly assembly;
                var      assemblyName = assemblyConfigurationElement.Name;
                try
                {
                    assembly = Assembly.Load(assemblyName);
                }
                catch (Exception exception)
                {
                    var message = string.Format("Coule not load Assembly '{0}'.Did you forget to fully qualify it? For example 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'", assemblyName);
                    throw new Exception(message, exception);
                }
                options.AddReference(assembly.Location);
            }

            foreach (var namespaceConfigurationElement in section.Namespaces)
            {
                options.AddUsing(namespaceConfigurationElement.Name);
            }
        }