示例#1
0
 public BindingContainerCodeGeneratorTests()
 {
     this.xamlPlatformInfo        = XamlPlatformInfoProvider.GetXamlPlatformInfo(XamlPlatform.WPF);
     this.bindingXamlPlatformInfo = new BindingXamlPlatformInfo(this.xamlPlatformInfo,
                                                                new BindingCompilerSettings(
                                                                    new Dictionary <string, IReadOnlyDictionary <string, ReadOnlyDependencyPropertyToNotificationEvent> >(),
                                                                    new Dictionary <string, IReadOnlyDictionary <string, Namespace> >(),
                                                                    new Dictionary <string, IReadOnlyCollection <string> >(),
                                                                    false));
     this.fileSystem = Substitute.For <IFileSystem>();
     this.bindingContainerXamlModificationCollector = new BindingContainerXamlModificationCollector();
     this.bindingOptimizationWriter = new BindingOptimizationWriter(new DirectoryInfo(@"c:\temp\sxo"), xamlPlatformInfo, this.fileSystem);
     this.fileSystem.File.ReadAllText(Arg.Any <string>()).Returns(info => ReadResourceStreamToEnd(info.Arg <string>()));
 }
        internal BindingCompilerOptimization(XamlPlatformInfo xamlPlatformInfo, ProjectInfo projectInfo, BindingCompilerSettings bindingCompilerSettings, IFileSystem fileSystem)
        {
            this.xamlPlatformInfo        = xamlPlatformInfo;
            this.projectInfo             = projectInfo;
            this.useSourceGenerator      = bindingCompilerSettings.UseSourceGenerator;
            this.bindingXamlPlatformInfo = new BindingXamlPlatformInfo(xamlPlatformInfo, bindingCompilerSettings);
            this.bindingTreeParser       = new BindingTreeParser(
                this.bindingXamlPlatformInfo,
                new BindingMarkupExtensionParser(new BindingPathParser(new BindingPathLexicalAnalyzer())),
                bindingCompilerSettings.OptInToOptimizations);
            var codeAnalyzer = new CodeAnalyzer(
                this.projectInfo.AssemblyName,
                this.projectInfo.Compiles,
                this.projectInfo.AssemblyReferences,
                fileSystem.File,
                new XamlTypeBaseTypeSourceCodeGenerator(
                    this.projectInfo.XDocumentProvider,
                    this.bindingXamlPlatformInfo.XClassName,
                    this.projectInfo.AssemblyName,
                    this.projectInfo.AssemblyReferences,
                    this.bindingXamlPlatformInfo.XamlTypeToSourceCodeNamespaces),
                !bindingCompilerSettings.UseSourceGenerator);

            this.typeResolver = new TypeResolver(codeAnalyzer);
            this.bindingOptimizationWriter = new BindingOptimizationWriter(this.projectInfo.IntermediateDirectory, xamlPlatformInfo, fileSystem);
            this.bindingContainerXamlModificationCollector = new BindingContainerXamlModificationCollector();
            this.bindingContainerCodeGenerator             = new BindingContainerCodeGenerator(
                new BindingPathCodeGenerator(
                    this.typeResolver,
                    this.bindingXamlPlatformInfo,
                    new ReadOnlyDependencyPropertyToNotificationEventResolver(codeAnalyzer, this.bindingXamlPlatformInfo.ReadOnlyDependencyPropertyNotificationEvents),
                    new BindingModeResolver(this.bindingXamlPlatformInfo.OneWayBindingProperties, codeAnalyzer, xamlPlatformInfo.XamlPlatform),
                    new TypeAssignmentCompatibilityAssessor(codeAnalyzer)),
                this.bindingXamlPlatformInfo,
                this.typeResolver);
        }