示例#1
0
        public void OnChange(string virtualPath)
        {
            if (IsIgnore(virtualPath))
            {
                return;
            }

            lock (_syncObject)
            {
                try
                {
                    var htmlVirtualPath = MapHtmlVirtualPath(virtualPath);
                    XPCAssembly.Delete(htmlVirtualPath);//删除程序集
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    //清空缓存
                    XamlUtil.RecoverMemory();
                }
            }
        }
示例#2
0
 public void OnChange(string virtualPath)
 {
     lock (_syncObject)
     {
         try
         {
             var coder = XPCCoder.Create(virtualPath);
             if (coder == null)
             {
                 return;
             }
             coder.Generate();
             XPCAssembly.Delete(coder.VirtualPath);//删除程序集
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             //清空缓存
             XamlUtil.RecoverMemory();
         }
     }
 }
示例#3
0
        internal static void Generate(string virtualPath)
        {
            XPCCoder coder = XPCCoder.Create(virtualPath);

            if (coder == null)
            {
                return;
            }
            coder.Generate();//生成代码
            if (!IsIgnore(coder))
            {
                if (WriteCode(coder) || !XPCAssembly.Exists(coder))
                {
                    try
                    {
                        //重新生成程序集
                        XPCAssembly.Compile(coder);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
        /// <summary>
        /// 获得xaml页面组件的类型
        /// 所谓xaml页面组件,指的是站点自己创建的,与某个xaml页面相关的组件
        /// 该组件一般会基于一个xaml组件做扩展
        /// </summary>
        /// <returns></returns>
        private static Type GetXamlPageComponentType(HtmlNode node, string virtualPath)
        {
            var className = node.GetAttributeValue("x:Class", XPCCoder.GetClassName(virtualPath));

            //var className = XPCCoder.GetClassName(virtualPath);
            if (string.IsNullOrEmpty(className))
            {
                return(null);
            }
            if (className.IndexOf(".") == -1)
            {
                className = string.Format("App_Code.{0}", className);                               //没有指定命名空间,那么默认为App_Code的命名空间
            }
            var assembly = XPCAssembly.Load(virtualPath);

            if (assembly == null)
            {
                return(null);
            }
            return(assembly.GetType(className, false, true));
            //className = string.Format("{0},{1}", className, XPCCoder.App_CodeAssemblyName);
            //return Type.GetType(className, false, true);
        }