#if NET_2_0
+using System.Configuration;
+using System.Collections.Generic;
+using System.Reflection;
using System.Security.Permissions;
namespace System.CodeDom.Compiler {
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
- public sealed class CompilerInfo {
-
+ public sealed class CompilerInfo
+ {
internal string Languages;
internal string Extensions;
internal string TypeName;
internal int WarningLevel;
internal string CompilerOptions;
+ internal Dictionary <string, string> ProviderOptions;
+
bool inited;
Type type;
}
public Type CodeDomProviderType {
- get { return type; }
+ get {
+ if (type == null) {
+ type = Type.GetType (TypeName, false);
+#if CONFIGURATION_DEP
+ if (type == null)
+ throw new ConfigurationErrorsException ("Unable to locate compiler type '" + TypeName + "'");
+#endif
+ }
+
+ return type;
+ }
}
+
public bool IsCodeDomProviderTypeValid {
get { return type != null; }
}
public CodeDomProvider CreateProvider ()
{
- return (CodeDomProvider) Activator.CreateInstance (type);
+ return CreateProvider (ProviderOptions);
+ }
+
+#if NET_4_0
+ public
+#endif
+ CodeDomProvider CreateProvider (IDictionary<string, string> providerOptions)
+ {
+ Type providerType = CodeDomProviderType;
+ if (providerOptions != null && providerOptions.Count > 0) {
+ ConstructorInfo ctor = providerType.GetConstructor (new [] { typeof (IDictionary <string, string>) });
+ if (ctor != null)
+ return (CodeDomProvider) ctor.Invoke (new object[] { providerOptions });
+ }
+
+ return (CodeDomProvider) Activator.CreateInstance (providerType);
}
public override bool Equals (object o)