Advertisement

Using DotNet to analyze WPF source code notes, methods for creating XAML objects.

阅读量:

在 WPF 框架中,XAML 文件内所定义的对象实例化过程并非完全依赖反射机制完成,框架内部已实施了多项优化措施以提升效率。在 WPF 中,对象的创建将借助 XamlTypeInvoker 类所提供的 CreateInstance 方法实现,而该方法在默认情况下具有如下定义形式

复制代码
        public virtual object CreateInstance(object[] arguments)
        {
            ThrowIfUnknown();
            if (!_xamlType.UnderlyingType.IsValueType && (arguments == null || arguments.Length == 0))
            {
                object result = DefaultCtorXamlActivator.CreateInstance(this);
                if (result != null)
                {
                    return result;
                }
            }
            return CreateInstance

全部评论 (0)

还没有任何评论哟~