Esempio n. 1
0
        internal override void ProcessMainAttributes(IDictionary atts)
        {
            autoEventWireup = GetBool(atts, "AutoEventWireup", autoEventWireup);
            enableViewState = GetBool(atts, "EnableViewState", enableViewState);

            string value = GetString(atts, "CompilationMode", compilationMode.ToString());

            if (!String.IsNullOrEmpty(value))
            {
                try {
                    compilationMode = (CompilationMode)Enum.Parse(typeof(CompilationMode), value, true);
                } catch (Exception ex) {
                    ThrowParseException("Invalid value of the CompilationMode attribute.", ex);
                }
            }

            atts.Remove("TargetSchema");              // Ignored
            value = GetString(atts, "ClientIDMode", null);
            if (!String.IsNullOrEmpty(value))
            {
                try {
                    clientIDMode = (ClientIDMode)Enum.Parse(typeof(ClientIDMode), value, true);
                } catch (Exception ex) {
                    ThrowParseException("Invalid value of the ClientIDMode attribute.", ex);
                }
            }
            base.ProcessMainAttributes(atts);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="urls"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        protected virtual Assembly TryRecompile(string[] urls, CompilationMode mode)
        {
            log.Warn("TryRecompile {0} urls, mode {1}: {2}", urls.Count(), mode.ToString(), string.Join(",", urls));
            var             d0 = DateTime.Now;
            CompilerContext cc = TryCompile(urls, mode == CompilationMode.CheckErrors ? true : false);

            log.Warn("TryRecompile compilation OK {0} urls, mode {1}: {2}", urls.Count(), mode.ToString(), string.Join(",", urls));
            if (cc.GeneratedAssembly == null && (mode == CompilationMode.Compile || mode == CompilationMode.CompileNoReplace))
            {
                throw new Exception("Generated assembly missing");
            }

            if (mode == CompilationMode.Compile)
            {
                List <TypeCacheEntry> ents = new List <TypeCacheEntry>();
                foreach (var url in urls)
                {
                    string tn = _storage.GetTypeNameFromUrl(url);
                    Type   tp = cc.GeneratedAssembly.GetType(tn);
                    if (tp == null)
                    {
                        foreach (var t in cc.GeneratedAssembly.GetTypes())
                        {
                            Console.WriteLine("Type: {0}", t.FullName);
                        }

                        throw new Exception("Type not found for url: " + url + ", type name: " + tn);
                    }
                    TypeCacheEntry tce = new TypeCacheEntry
                    {
                        DslType      = tp,
                        Modified     = false,
                        Url          = url,
                        CompiledDate = DateTime.Now
                    };
                    ents.Add(tce);
                }
                lock (_typeCache)
                {
                    foreach (var ent in ents)
                    {
                        _typeCache.Remove(ent.Url);
                        _typeCache[ent.Url] = ent;
                        log.Warn("TC:{0}=>{1}, CTime: {2}", ent.Url, ent.DslType, DateTime.Now - d0);
                    }
                }
            }

            return(cc.GeneratedAssembly);
        }