/// <summary> /// Executes the <see cref="CortexWeaver"/>. /// </summary> public override void Execute() { IDictionary<string, TypeReference> cortexNetTypes; IDictionary<string, TypeReference> cortexNetBlazorTypes; try { cortexNetTypes = new TypeResolverDictionary(this.ModuleDefinition, new Dictionary<string, string>() { { "Cortex.Net.ISharedState", "Cortex.Net" }, { "Cortex.Net.Api.ActionAttribute", "Cortex.Net" }, { "Cortex.Net.IReactiveObject", "Cortex.Net" }, { "Cortex.Net.Api.ActionExtensions", "Cortex.Net" }, { "Cortex.Net.Api.ComputedAttribute", "Cortex.Net" }, { "Cortex.Net.Types.DeepEnhancer", "Cortex.Net" }, { "Cortex.Net.Types.ObservableObject", "Cortex.Net" }, { "Cortex.Net.ComputedValueOptions`1", "Cortex.Net" }, { "Cortex.Net.Types.ObservableCollection`1", "Cortex.Net" }, { "Cortex.Net.Api.ObservableAttribute", "Cortex.Net" }, { "Cortex.Net.Core.ActionExtensions", "Cortex.Net" }, }); } catch { throw new WeavingException(string.Format(CultureInfo.CurrentCulture, Resources.AssemblyOrTypeNotFound, "Cortex.Net")); } var reactiveObjectInterfaceWeaver = new ReactiveObjectInterfaceWeaver(this, cortexNetTypes); var enumerableWeaver = new EnumerableInterfaceWeaver(this, reactiveObjectInterfaceWeaver, cortexNetTypes); var actionWeaver = new ActionWeaver(this, reactiveObjectInterfaceWeaver, cortexNetTypes); var observableWeaver = new ObservableWeaver(this, enumerableWeaver, reactiveObjectInterfaceWeaver, cortexNetTypes); var computedWeaver = new ComputedWeaver(this, reactiveObjectInterfaceWeaver, cortexNetTypes); actionWeaver.Execute(); observableWeaver.Execute(); computedWeaver.Execute(); if (this.ModuleDefinition.AssemblyReferences.Any(x => x.Name == "Cortex.Net.Blazor")) { try { cortexNetBlazorTypes = new TypeResolverDictionary(this.ModuleDefinition, new Dictionary<string, string>() { { "Cortex.Net.Blazor.ObserverAttribute", "Cortex.Net.Blazor" }, { "Cortex.Net.Blazor.ObserverObject", "Cortex.Net.Blazor" }, }); } catch { throw new WeavingException(string.Format(CultureInfo.CurrentCulture, Resources.AssemblyOrTypeNotFound, "Cortex.Net.Blazor")); } var blazorObserverWeaver = new BlazorObserverWeaver(this, reactiveObjectInterfaceWeaver, cortexNetBlazorTypes); blazorObserverWeaver.Execute(); } reactiveObjectInterfaceWeaver.Execute(); }
/// <summary> /// Executes the <see cref="ModuleWeaver"/>. /// </summary> public override void Execute() { WeavingContext weavingContext = null; try { weavingContext = this.ModuleDefinition.AssemblyReferences.Any(x => x.Name == "Cortex.Net.Blazor") ? new BlazorWeavingContext(this) : new WeavingContext(this); #pragma warning disable CA1031 // Do not catch general exception types } catch #pragma warning restore CA1031 // Do not catch general exception types { this.WriteWarning(Resources.CannotLoadTypes); return; } var reactiveObjectInterfaceWeaver = new ReactiveObjectInterfaceWeaver(this, weavingContext); var enumerableWeaver = new EnumerableInterfaceWeaver(this, reactiveObjectInterfaceWeaver, weavingContext); var actionWeaver = new ActionWeaver(this, reactiveObjectInterfaceWeaver, weavingContext); var observableWeaver = new ObservableWeaver(this, enumerableWeaver, reactiveObjectInterfaceWeaver, weavingContext); var computedWeaver = new ComputedWeaver(this, reactiveObjectInterfaceWeaver, weavingContext); actionWeaver.Execute(); observableWeaver.Execute(); computedWeaver.Execute(); if (this.ModuleDefinition.AssemblyReferences.Any(x => x.Name == "Cortex.Net.Blazor")) { var blazorObserverWeaver = new BlazorObserverWeaver(this, reactiveObjectInterfaceWeaver, (BlazorWeavingContext)weavingContext); blazorObserverWeaver.Execute(); } reactiveObjectInterfaceWeaver.Execute(); }