Exemple #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();
                }
            }
        }
Exemple #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();
         }
     }
 }
Exemple #3
0
        private static string GetTemplateCode(object obj, string templatePropertyName)
        {
            var objType = XamlUtil.GetObjectType(obj);
            var factory = _getTemplateCodeFactory(objType)(templatePropertyName);

            return(factory.GetTemplateCode(obj, templatePropertyName));
        }
Exemple #4
0
        private void InitCode()
        {
            this.GICode   = string.Empty;
            this.GCode    = string.Empty;
            this.UserCode = string.Empty;

            if (string.IsNullOrEmpty(this.PageCode))
            {
                return;
            }
            var node = XamlUtil.GetNode(this.PageCode);

            if (node == null)
            {
                this.PageCode = string.Empty;               //没有节点,证明不是xaml文件
            }
            var baseComponentType = node.MapComponentType();

            if (baseComponentType == null)
            {
                return;
            }
            var className = GetClassName(this.VirtualPath);

            var connectedObjects = new List <ConnectedObject>();

            ParseConnectedObjects(node, connectedObjects);

            this.GICode   = GetCode_g_i(connectedObjects, baseComponentType, className, this.VirtualPath);
            this.GCode    = GetCode_g(connectedObjects, baseComponentType, className);
            this.UserCode = GetCode_user(baseComponentType, className);
        }
Exemple #5
0
        public static XPCCoder Create(string virtualPath)
        {
            var code = PageUtil.GetRawCode(virtualPath);

            if (!XamlUtil.IsDeclareXaml(code))
            {
                return(null);
            }
            return(new XPCCoder(virtualPath));
        }
Exemple #6
0
        private bool ProcessProxy()
        {
            var proxy = GetComponent() as PageProxy;

            if (proxy != null)
            {
                proxy.LoadPinned();

                XamlUtil.UsingRender((brush) =>
                {
                    proxy.OnLoad(); //OnLoad的触发,必须在呈现环境初始化之后进行
                    proxy.Process(this.PageContext);
                });
                return(true);
            }
            return(false);
        }
Exemple #7
0
        protected override object CallWebMethod(object[] args)
        {
            //在处理事件之前,先加载固化值
            UIElement component = this.GetComponent() as UIElement;

            if (component == null)
            {
                throw new XamlException("无法处理事件,组件不是" + typeof(UIElement).FullName);
            }
            component.LoadPinned();

            object result = null;

            XamlUtil.UsingRender((brush) =>
            {
                component.OnLoad();
                result = CallWebMethod(component, args);
            });
            return(result);
        }
Exemple #8
0
        private static string GetPageCode(UIElement element, string error)
        {
            //在获取页面代码之前,先加载固化值
            element.LoadPinned();

            if (!string.IsNullOrEmpty(error))
            {
                SetError(element, error);
            }

            var code = string.Empty;

            XamlUtil.UsingRender((brush) =>
            {
                element.OnLoad(); //OnLoad的触发,必须在呈现环境初始化之后进行

                AppendLanguage(brush);
                element.Render(brush);
                code = brush.GetCode();
            });
            return(code);
        }
Exemple #9
0
        public string GetTemplateCode(object obj, string templatePropertyName)
        {
            var objType = XamlUtil.GetObjectType(obj);

            return(_getTemplateCode(objType)(templatePropertyName));
        }