private static void InitializeOptionsIfNeeded()
        {
            OptionsLocker.AcquireReaderLock(Timeout.Infinite);
            if (options != null)
            {
                OptionsLocker.ReleaseReaderLock();
                return;
            }

            OptionsLocker.UpgradeToWriterLock(Timeout.Infinite);
            if (options != null)
            {
                OptionsLocker.ReleaseWriterLock();
                return;
            }

            try
            {
                var optionsBuilder = new AspViewOptionsBuilder();
                InitializeProgrammaticConfig(optionsBuilder);

                var appSettingsOptions = GetAppSettingsOptions();
                if (appSettingsOptions != null)
                {
                    optionsBuilder.ApplyConfigurableOverrides(appSettingsOptions);
                }

                options = optionsBuilder.BuildOptions();
            }
            finally
            {
                OptionsLocker.ReleaseWriterLock();
            }
        }
Exemple #2
0
 private static void InitializeConfig()
 {
     InitializeConfig("aspView");
     if (options == null)
     {
         InitializeConfig("aspview");
     }
     if (options == null)
     {
         options = new AspViewEngineOptions();
     }
 }
        public object Create(object parent, object configContext, XmlNode section)
        {
			bool? debug = null;
			bool? inMemory = null;
			bool? autoRecompilation = null;
			string temporarySourceFilesDirectory = null;
			bool? saveFiles = null;
        	string referencesPath = null;
        	string generatedAssemblyName = null;
			List<ReferencedAssembly> references = new List<ReferencedAssembly>();
			string actionExtension = null;

			if (section.Attributes["debug"] != null)
				debug = bool.Parse(section.Attributes["debug"].Value);
			if (section.Attributes["inMemory"] != null)
				inMemory = bool.Parse(section.Attributes["inMemory"].Value);
			if (section.Attributes["autoRecompilation"] != null)
				autoRecompilation = bool.Parse(section.Attributes["autoRecompilation"].Value);
			if (section.Attributes["temporarySourceFilesDirectory"] != null)
				temporarySourceFilesDirectory = section.Attributes["temporarySourceFilesDirectory"].Value;
			if (section.Attributes["saveFiles"] != null)
				saveFiles = bool.Parse(section.Attributes["saveFiles"].Value);
			if (section.Attributes["referencesPath"] != null)
				referencesPath = section.Attributes["referencesPath"].Value;
			if (section.Attributes["generatedAssemblyNamePrefix"] != null)
				generatedAssemblyName = section.Attributes["generatedAssemblyNamePrefix"].Value;

			foreach (XmlNode reference in section.SelectNodes("reference"))
			{
				string name = reference.Attributes["assembly"].Value;
				ReferencedAssembly.AssemblySource source = ReferencedAssembly.AssemblySource.BinDirectory;
				if (reference.Attributes["isFromGac"] != null)
					if (reference.Attributes["isFromGac"].Value.Equals("true", StringComparison.InvariantCultureIgnoreCase))
						source = ReferencedAssembly.AssemblySource.GlobalAssemblyCache;
				references.Add(new ReferencedAssembly(name, source));
			}

			AspViewCompilerOptions compilerOptions = new AspViewCompilerOptions(
				debug, inMemory, autoRecompilation, temporarySourceFilesDirectory, saveFiles, referencesPath, generatedAssemblyName, references);

			if (section.Attributes["actionExtension"] != null)
			{
				actionExtension = section.Attributes["actionExtension"].Value;
				if (actionExtension[0] != '.')
					actionExtension = "." + actionExtension;
			}

			AspViewEngineOptions options = new AspViewEngineOptions(actionExtension, compilerOptions);

            return options;
        }
		public object Create(object parent, object configContext, XmlNode section)
		{
			if (section == null)
				throw new AspViewException("AspView config section is missing or not found");

			IEnumerable<ReferencedAssembly> references = GetReferencesFrom(section);

			IDictionary<Type, Type> providers = GetProviders(section);

			AspViewCompilerOptions compilerOptions = GetCompilerOptionsFrom(section, references, providers);

			AspViewEngineOptions options = new AspViewEngineOptions(compilerOptions);

			return options;
		}
Exemple #5
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
            {
                throw new AspViewException("AspView config section is missing or not found");
            }

            IEnumerable <ReferencedAssembly> references = GetReferencesFrom(section);

            IDictionary <Type, Type> providers = GetProviders(section);

            AspViewCompilerOptions compilerOptions = GetCompilerOptionsFrom(section, references, providers);

            AspViewEngineOptions options = new AspViewEngineOptions(compilerOptions);

            return(options);
        }
Exemple #6
0
 private static void InitializeConfig(string configName)
 {
     options = (AspViewEngineOptions)ConfigurationManager.GetSection(configName);
 }
Exemple #7
0
 public void Initialize(AspViewEngineOptions newOptions)
 {
     options = newOptions;
     Initialize();
 }
Exemple #8
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
            {
                throw new ApplicationException("AspView config section is missing or not found");
            }

            bool?  debug                         = null;
            bool?  inMemory                      = null;
            bool?  autoRecompilation             = null;
            bool?  allowPartiallyTrustedCallers  = null;
            string temporarySourceFilesDirectory = null;
            bool?  saveFiles                     = null;
            List <ReferencedAssembly> references = new List <ReferencedAssembly>();
            string actionExtension               = null;

            if (section.Attributes["debug"] != null)
            {
                debug = bool.Parse(section.Attributes["debug"].Value);
            }
            if (section.Attributes["inMemory"] != null)
            {
                inMemory = bool.Parse(section.Attributes["inMemory"].Value);
            }
            if (section.Attributes["autoRecompilation"] != null)
            {
                autoRecompilation = bool.Parse(section.Attributes["autoRecompilation"].Value);
            }
            if (section.Attributes["allowPartiallyTrustedCallers"] != null)
            {
                allowPartiallyTrustedCallers = bool.Parse(section.Attributes["allowPartiallyTrustedCallers"].Value);
            }
            if (section.Attributes["temporarySourceFilesDirectory"] != null)
            {
                temporarySourceFilesDirectory = section.Attributes["temporarySourceFilesDirectory"].Value;
            }
            if (section.Attributes["saveFiles"] != null)
            {
                saveFiles = bool.Parse(section.Attributes["saveFiles"].Value);
            }
            foreach (XmlNode reference in section.SelectNodes("reference"))
            {
                string name = reference.Attributes["assembly"].Value;
                ReferencedAssembly.AssemblySource source = ReferencedAssembly.AssemblySource.BinDirectory;
                if (reference.Attributes["isFromGac"] != null)
                {
                    if (reference.Attributes["isFromGac"].Value.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                    {
                        source = ReferencedAssembly.AssemblySource.GlobalAssemblyCache;
                    }
                }
                references.Add(new ReferencedAssembly(name, source));
            }

            AspViewCompilerOptions compilerOptions = new AspViewCompilerOptions(
                debug, inMemory, autoRecompilation, allowPartiallyTrustedCallers, temporarySourceFilesDirectory, saveFiles, references);

            if (section.Attributes["actionExtension"] != null)
            {
                actionExtension = section.Attributes["actionExtension"].Value;
                if (actionExtension[0] != '.')
                {
                    actionExtension = "." + actionExtension;
                }
            }

            AspViewEngineOptions options = new AspViewEngineOptions(actionExtension, compilerOptions);

            return(options);
        }
Exemple #9
0
		private static void InitializeConfig(string configName)
		{
			string path = Path.Combine(siteRoot, "web.config");

			if (!File.Exists(path))
			{
				path = Path.Combine(siteRoot, "app.config");

				if (!File.Exists(path))
				{
					Console.WriteLine("Cannot locate web.config or app.config" + Environment.NewLine + "VCompile is normally run from the bin directory of the website");
					Environment.Exit(1);
				}
			}
					
			XmlNode aspViewNode = null;
			using (XmlTextReader reader = new XmlTextReader(path))
			{
				reader.Namespaces = false;
				XmlDocument xml = new XmlDocument();
				xml.Load(reader);
				aspViewNode = xml.SelectSingleNode("/configuration/aspview");
			}

			AspViewConfigurationSection section = new AspViewConfigurationSection();
			options = (AspViewEngineOptions)section.Create(null, null, aspViewNode);
			if (options != null)
				Console.WriteLine(options.CompilerOptions.Debug ? "Compiling in DEBUG mode" : "");
		}
		private static void InitializeConfig()
		{
			InitializeConfig("aspView");
			if (options == null)
				InitializeConfig("aspview");
			if (options == null)
				options = new AspViewEngineOptions();
		}
		private static void InitializeConfig(string configName)
		{
			options = (AspViewEngineOptions)ConfigurationManager.GetSection(configName);
		}
		private static void InitializeOptionsIfNeeded()
		{
			OptionsLocker.AcquireReaderLock(Timeout.Infinite);
			if (options != null)
			{
				OptionsLocker.ReleaseReaderLock();
				return;
			}

			OptionsLocker.UpgradeToWriterLock(Timeout.Infinite);
			if (options != null)
			{
				OptionsLocker.ReleaseWriterLock();
				return;
			}

			try
			{
				var optionsBuilder = new AspViewOptionsBuilder();
				InitializeProgrammaticConfig(optionsBuilder);

				var appSettingsOptions = GetAppSettingsOptions();
				if (appSettingsOptions != null)
					optionsBuilder.ApplyConfigurableOverrides(appSettingsOptions);

				options = optionsBuilder.BuildOptions();
			}
			finally
			{
				OptionsLocker.ReleaseWriterLock();
			}
		}
		public void Initialize(List<ICompilationContext> contexts, AspViewEngineOptions newOptions)
		{
			options = newOptions;
			compilationContexts = contexts;
			Initialize();
		}
Exemple #14
0
 public void Initialize(ICompilationContext context, AspViewEngineOptions newOptions)
 {
     options            = newOptions;
     compilationContext = context;
     Initialize();
 }
		public void Initialize(AspViewEngineOptions newOptions)
		{
			options = newOptions;
			Initialize();
		}
		public void Initialize(ICompilationContext context, AspViewEngineOptions newOptions)
		{
			options = newOptions;
			compilationContext = context;
			Initialize();
		}
 void IAspViewEngineTestAccess.SetOptions(AspViewEngineOptions newOptions)
 {
     options = newOptions;
 }
		void IAspViewEngineTestAccess.SetOptions(AspViewEngineOptions newOptions)
		{
			options = newOptions;
		}