public Result.IfSuccess <XamlModificationCollection> Visit(IBindingNode bindingNode, Parameters parameters, Context context) { var result = bindingNode.Visit(this, parameters, context); if (result) { return(Result.Success(new XamlModificationCollection(context.XamlModificationInfos, context.BindingRootTypes))); } return(Result.Error()); }
public Result.IfSuccess <IReadOnlyList <GeneratedBindingContainer> > Visit(IBindingNode bindingNode, Parameters parameters, Context context) { var result = bindingNode.Visit(this, parameters, context); if (result) { var generatedContainers = new List <GeneratedBindingContainer>(); foreach (var bindingContainerInfo in context.BindingContainerInfos) { var bindingContainerBaseType = this.typeResolver.GetType("Sundew.Xaml.Optimizations.BindingConnector`1"); context.ExternAliases.TryAdd(bindingContainerBaseType); var sourceCode = $@"{GetNamespacesAndExternalAliases(this.bindingXamlPlatformInfo.DefaultUsingStatements, bindingContainerInfo.ExternalAliases)} namespace {parameters.Namespace} {{ [global::System.CodeDom.Compiler.GeneratedCode(""Sundew.Xaml.Optimizations.Bindings"", ""{ToolVersion}"")] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public class {bindingContainerInfo.BindingContainerType.TypeName} : {this.typeResolver.GetAliasQualifiedGenericType(bindingContainerBaseType, this.typeResolver.GetType(bindingContainerInfo.NamespaceQualifiedBindingRootType))} {{ protected override void OnConnect() {{ {bindingContainerInfo.CodeBuilder} }} public override object ProvideValue(System.IServiceProvider serviceProvider) {{ return new {bindingContainerInfo.BindingContainerType.TypeName}(); }} }} }}"; generatedContainers.Add(new GeneratedBindingContainer(parameters.OutputPath, bindingContainerInfo.BindingContainerType, sourceCode)); } return(Result.Success((IReadOnlyList <GeneratedBindingContainer>)generatedContainers)); } return(Result.Error()); }
public string Visit(IBindingNode bindingNode, StringBuilder stringBuilder, int indent) { stringBuilder ??= new StringBuilder(); bindingNode.Visit(this, stringBuilder, indent); return(stringBuilder.ToString()); }