Exemplo n.º 1
0
        protected ExecutableApplicationFascade(IDataTypeFascade dataTypeFascade,
                                               IAppConfigFascade appConfigFascade,
                                               IReflectionFascade reflectionFascade,
                                               IAssemblyInformationFascade assemblyInformationFascade)
        {
            if ((object)dataTypeFascade == null)
            {
                throw new ArgumentNullException(nameof(dataTypeFascade));
            }

            if ((object)appConfigFascade == null)
            {
                throw new ArgumentNullException(nameof(appConfigFascade));
            }

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            if ((object)assemblyInformationFascade == null)
            {
                throw new ArgumentNullException(nameof(assemblyInformationFascade));
            }

            this.dataTypeFascade            = dataTypeFascade;
            this.appConfigFascade           = appConfigFascade;
            this.reflectionFascade          = reflectionFascade;
            this.assemblyInformationFascade = assemblyInformationFascade;
        }
Exemplo n.º 2
0
 public TextMetalConsoleApplication([DependencyInjection] IDataTypeFascade dataTypeFascade,
                                    [DependencyInjection] IAppConfigFascade appConfigFascade,
                                    [DependencyInjection] IReflectionFascade reflectionFascade,
                                    [DependencyInjection] IAssemblyInformationFascade assemblyInformationFascade)
     : base(dataTypeFascade, appConfigFascade, reflectionFascade, assemblyInformationFascade)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the AdoNetFascade class.
        /// </summary>
        /// <param name="reflectionFascade"> The reflection instance to use. </param>
        public AdoNetYieldingFascade(IReflectionFascade reflectionFascade)
        {
            if ((object)reflectionFascade == null)
                throw new ArgumentNullException("reflectionFascade");

            this.reflectionFascade = reflectionFascade;
        }
        public TextMetalToolHost([DependencyInjection] IReflectionFascade reflectionFascade)
        {
            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            this.reflectionFascade = reflectionFascade;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the AdoNetFascade class.
        /// </summary>
        /// <param name="reflectionFascade"> The reflection instance to use. </param>
        public AdoNetYieldingFascade(IReflectionFascade reflectionFascade)
        {
            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException("reflectionFascade");
            }

            this.reflectionFascade = reflectionFascade;
        }
Exemplo n.º 6
0
        public TransientActivatorAutoWiringDependencyResolution(IReflectionFascade reflectionFascade)
            : base(DependencyLifetime.Transient)
        {
            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            this.reflectionFascade = reflectionFascade;
        }
		public TextMetalToolContext(ITextMetalToolHost toolHost,
			IDataTypeFascade dataTypeFascade,
			IReflectionFascade reflectionFascade,
			Tokenizer tokenizer)
			: base(dataTypeFascade, reflectionFascade, tokenizer)
		{
			if ((object)toolHost == null)
				throw new ArgumentNullException(nameof(toolHost));

			this.toolHost = toolHost;
		}
Exemplo n.º 8
0
        public TextMetalEmailContext(StringWriter stringWriter,
                                     IDataTypeFascade dataTypeFascade,
                                     IReflectionFascade reflectionFascade,
                                     Tokenizer tokenizer)
            : base(dataTypeFascade, reflectionFascade, tokenizer)
        {
            if ((object)stringWriter == null)
            {
                throw new ArgumentNullException(nameof(stringWriter));
            }

            this.stringWriter = stringWriter;
        }
		public ExecutableApplicationFascade(IDataTypeFascade dataTypeFascade, IAppConfigFascade appConfigFascade, IReflectionFascade reflectionFascade, IAssemblyInformationFascade assemblyInformationFascade)
		{
			if ((object)dataTypeFascade == null)
				throw new ArgumentNullException(nameof(dataTypeFascade));

			if ((object)appConfigFascade == null)
				throw new ArgumentNullException(nameof(appConfigFascade));

			if ((object)reflectionFascade == null)
				throw new ArgumentNullException(nameof(reflectionFascade));

			if ((object)assemblyInformationFascade == null)
				throw new ArgumentNullException(nameof(assemblyInformationFascade));

			this.dataTypeFascade = dataTypeFascade;
			this.appConfigFascade = appConfigFascade;
			this.reflectionFascade = reflectionFascade;
			this.assemblyInformationFascade = assemblyInformationFascade;

			Current = this;
		}
Exemplo n.º 10
0
        protected TextMetalContext(IDataTypeFascade dataTypeFascade,
                                   IReflectionFascade reflectionFascade,
                                   Tokenizer tokenizer)
        {
            if ((object)dataTypeFascade == null)
            {
                throw new ArgumentNullException(nameof(dataTypeFascade));
            }

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            if ((object)tokenizer == null)
            {
                throw new ArgumentNullException(nameof(tokenizer));
            }

            this.dataTypeFascade   = dataTypeFascade;
            this.reflectionFascade = reflectionFascade;
            this.tokenizer         = tokenizer;
        }
Exemplo n.º 11
0
        public Tokenizer(IDataTypeFascade dataTypeFascade, IReflectionFascade reflectionFascade,
                         IDictionary <string, ITokenReplacementStrategy> tokenReplacementStrategies, bool strictMatching)
        {
            if ((object)dataTypeFascade == null)
            {
                throw new ArgumentNullException(nameof(dataTypeFascade));
            }

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            if ((object)tokenReplacementStrategies == null)
            {
                throw new ArgumentNullException(nameof(tokenReplacementStrategies));
            }

            this.dataTypeFascade            = dataTypeFascade;
            this.reflectionFascade          = reflectionFascade;
            this.tokenReplacementStrategies = tokenReplacementStrategies;
            this.strictMatching             = strictMatching;
        }
 protected AsyncExecutableApplicationFascade(IDataTypeFascade dataTypeFascade, IAppConfigFascade appConfigFascade, IReflectionFascade reflectionFascade, IAssemblyInformationFascade assemblyInformationFascade)
     : base(dataTypeFascade, appConfigFascade, reflectionFascade, assemblyInformationFascade)
 {
 }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the DynamicWildcardTokenReplacementStrategy class. This overload overrides the default strict setting (true).
        /// </summary>
        /// <param name="dataTypeFascade"> The data type fascade. </param>
        /// <param name="reflectionFascade"> The reflection fascade. </param>
        /// <param name="targets"> The target object instances to evaluate (in linear order) during wildcard token replacement. </param>
        /// <param name="strict"> A value indicating if exceptions are thrown for bad token matches. </param>
        public DynamicWildcardTokenReplacementStrategy(IDataTypeFascade dataTypeFascade, IReflectionFascade reflectionFascade, object[] targets, bool strict)
        {
            if ((object)dataTypeFascade == null)
            {
                throw new ArgumentNullException(nameof(dataTypeFascade));
            }

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            this.dataTypeFascade   = dataTypeFascade;
            this.reflectionFascade = reflectionFascade;
            this.targets           = targets;
            this.strict            = strict;
        }
Exemplo n.º 14
0
		/// <summary>
		/// Initializes a new instance of the AssemblyInformationFascade class.
		/// </summary>
		/// <param name="reflectionFascade"> The reflectionFascade instance to use. </param>
		/// <param name="assembly"> The target assembly to examine for information. </param>
		public AssemblyInformationFascade(IReflectionFascade reflectionFascade, Assembly assembly)
		{
			AssemblyTitleAttribute aTiA;
			//AssemblyVersionAttribute ava;
			AssemblyDescriptionAttribute ada;
			AssemblyProductAttribute apa;
			AssemblyCopyrightAttribute aCopA;
			AssemblyCompanyAttribute aComA;
			AssemblyConfigurationAttribute aConA;
			AssemblyFileVersionAttribute afva;
			AssemblyInformationalVersionAttribute aiva;
			AssemblyTrademarkAttribute aTrA;

			if ((object)reflectionFascade == null)
				throw new ArgumentNullException(nameof(reflectionFascade));

			if ((object)assembly == null)
				throw new ArgumentNullException(nameof(assembly));

			aTiA = reflectionFascade.GetOneAttribute<AssemblyTitleAttribute>(assembly);

			if ((object)aTiA != null)
				this.title = aTiA.Title;

			//ava = reflectionFascade.GetOneAttribute<AssemblyVersionAttribute>(assembly);

			//if ((object)ava != null)
			//    this.ava = ava.ava;

			this.assemblyVersion = assembly.GetName().Version.ToString();

			ada = reflectionFascade.GetOneAttribute<AssemblyDescriptionAttribute>(assembly);

			if ((object)ada != null)
				this.description = ada.Description;

			apa = reflectionFascade.GetOneAttribute<AssemblyProductAttribute>(assembly);

			if ((object)apa != null)
				this.product = apa.Product;

			aCopA = reflectionFascade.GetOneAttribute<AssemblyCopyrightAttribute>(assembly);

			if ((object)aCopA != null)
				this.copyright = aCopA.Copyright;

			aComA = reflectionFascade.GetOneAttribute<AssemblyCompanyAttribute>(assembly);

			if ((object)aComA != null)
				this.company = aComA.Company;

			aConA = reflectionFascade.GetOneAttribute<AssemblyConfigurationAttribute>(assembly);

			if ((object)aConA != null)
				this.configuration = aConA.Configuration;

			afva = reflectionFascade.GetOneAttribute<AssemblyFileVersionAttribute>(assembly);

			if ((object)afva != null)
				this.win32FileVersion = afva.Version;

			aiva = reflectionFascade.GetOneAttribute<AssemblyInformationalVersionAttribute>(assembly);

			if ((object)aiva != null)
				this.informationalVersion = aiva.InformationalVersion;

			aTrA = reflectionFascade.GetOneAttribute<AssemblyTrademarkAttribute>(assembly);

			if ((object)aTrA != null)
				this.trademark = aTrA.Trademark;
		}
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the DynamicValueTokenReplacementStrategy class.
        /// </summary>
        /// <param name="dataTypeFascade"> The data type fascade. </param>
        /// <param name="reflectionFascade"> The reflection fascade. </param>
        /// <param name="method"> The callback method to evaluate during token replacement. </param>
        public DynamicValueTokenReplacementStrategy(IDataTypeFascade dataTypeFascade, IReflectionFascade reflectionFascade, Func <string[], object> method)
        {
            if ((object)dataTypeFascade == null)
            {
                throw new ArgumentNullException(nameof(dataTypeFascade));
            }

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            if ((object)method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            this.dataTypeFascade   = dataTypeFascade;
            this.reflectionFascade = reflectionFascade;
            this.method            = method;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the AssemblyInformationFascade class.
        /// </summary>
        /// <param name="reflectionFascade"> The reflectionFascade instance to use. </param>
        /// <param name="assembly"> The target assembly to examine for information. </param>
        public AssemblyInformationFascade(IReflectionFascade reflectionFascade, Assembly assembly)
        {
            AssemblyTitleAttribute aTiA;
            //AssemblyVersionAttribute ava;
            AssemblyDescriptionAttribute          ada;
            AssemblyProductAttribute              apa;
            AssemblyCopyrightAttribute            aCopA;
            AssemblyCompanyAttribute              aComA;
            AssemblyConfigurationAttribute        aConA;
            AssemblyFileVersionAttribute          afva;
            AssemblyInformationalVersionAttribute aiva;
            AssemblyTrademarkAttribute            aTrA;

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            if ((object)assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            aTiA = reflectionFascade.GetOneAttribute <AssemblyTitleAttribute>(assembly);

            if ((object)aTiA != null)
            {
                this.title = aTiA.Title;
            }

            //ava = reflectionFascade.GetOneAttribute<AssemblyVersionAttribute>(assembly);

            //if ((object)ava != null)
            //    this.ava = ava.ava;

            this.assemblyVersion = assembly.GetName().Version.ToString();

            ada = reflectionFascade.GetOneAttribute <AssemblyDescriptionAttribute>(assembly);

            if ((object)ada != null)
            {
                this.description = ada.Description;
            }

            apa = reflectionFascade.GetOneAttribute <AssemblyProductAttribute>(assembly);

            if ((object)apa != null)
            {
                this.product = apa.Product;
            }

            aCopA = reflectionFascade.GetOneAttribute <AssemblyCopyrightAttribute>(assembly);

            if ((object)aCopA != null)
            {
                this.copyright = aCopA.Copyright;
            }

            aComA = reflectionFascade.GetOneAttribute <AssemblyCompanyAttribute>(assembly);

            if ((object)aComA != null)
            {
                this.company = aComA.Company;
            }

            aConA = reflectionFascade.GetOneAttribute <AssemblyConfigurationAttribute>(assembly);

            if ((object)aConA != null)
            {
                this.configuration = aConA.Configuration;
            }

            afva = reflectionFascade.GetOneAttribute <AssemblyFileVersionAttribute>(assembly);

            if ((object)afva != null)
            {
                this.nativeFileVersion = afva.Version;
            }

            aiva = reflectionFascade.GetOneAttribute <AssemblyInformationalVersionAttribute>(assembly);

            if ((object)aiva != null)
            {
                this.informationalVersion = aiva.InformationalVersion;
            }

            aTrA = reflectionFascade.GetOneAttribute <AssemblyTrademarkAttribute>(assembly);

            if ((object)aTrA != null)
            {
                this.trademark = aTrA.Trademark;
            }

            this.moduleName = assembly.ManifestModule.Name;
        }
Exemplo n.º 17
0
        internal static TResolution AutoWireResolve <TResolution>(IReflectionFascade reflectionFascade, Type activatorType, IDependencyManager dependencyManager, Type resolutionType, string selectorKey)
        {
            ConstructorInfo constructorInfo;

            ConstructorInfo[] constructorInfos;
            ParameterInfo[]   parameterInfos;

            DependencyInjectionAttribute dependencyInjectionAttribute;
            Lazy <TResolution>           lazyConstructorInvokation = null;

            if ((object)reflectionFascade == null)
            {
                throw new ArgumentNullException(nameof(reflectionFascade));
            }

            if ((object)activatorType == null)
            {
                throw new ArgumentNullException(nameof(activatorType));
            }

            if ((object)dependencyManager == null)
            {
                throw new ArgumentNullException(nameof(dependencyManager));
            }

            if ((object)resolutionType == null)
            {
                throw new ArgumentNullException(nameof(resolutionType));
            }

            if ((object)selectorKey == null)
            {
                throw new ArgumentNullException(nameof(selectorKey));
            }

            TypeInfo _activatorTypeInfo = activatorType.GetTypeInfo();

            // TODO
            //if (!resolutionType.IsAssignableFrom(activatorType))
            //;

            // get public, instance .ctors for activation type
            constructorInfos = activatorType.GetConstructors(BindingFlags.Public | BindingFlags.Instance);

            if ((object)constructorInfos != null)
            {
                for (int constructorIndex = 0; constructorIndex < constructorInfos.Length; constructorIndex++)
                {
                    Lazy <object>[] lazyConstructorArguments;

                    constructorInfo = constructorInfos[constructorIndex];

                    // on constructor
                    dependencyInjectionAttribute = reflectionFascade.GetOneAttribute <DependencyInjectionAttribute>(constructorInfo);

                    if ((object)dependencyInjectionAttribute == null)
                    {
                        continue;
                    }

                    if (dependencyInjectionAttribute.SelectorKey != selectorKey)
                    {
                        continue;
                    }

                    if ((object)lazyConstructorInvokation != null)
                    {
                        throw new DependencyException(string.Format("More than one constructor for activator type '{0}' specified the '{1}' with selector key '{2}'.", activatorType.FullName, nameof(DependencyInjectionAttribute), selectorKey));
                    }

                    parameterInfos           = constructorInfo.GetParameters();
                    lazyConstructorArguments = new Lazy <object> [parameterInfos.Length];

                    for (int parameterIndex = 0; parameterIndex < parameterInfos.Length; parameterIndex++)
                    {
                        ParameterInfo parameterInfo;
                        Type          parameterType;
                        Lazy <object> lazyConstructorArgument;
                        DependencyInjectionAttribute parameterDependencyInjectionAttribute;

                        parameterInfo = parameterInfos[parameterIndex];
                        parameterType = parameterInfo.ParameterType;

                        // on parameter
                        parameterDependencyInjectionAttribute = reflectionFascade.GetOneAttribute <DependencyInjectionAttribute>(parameterInfo);

                        if ((object)parameterDependencyInjectionAttribute == null)
                        {
                            throw new DependencyException(string.Format("A constructor for activator type '{0}' specifying the '{1}' with selector key '{2}' had at least one parameter missing the '{1}': index='{3}';name='{4}';type='{5}'.", activatorType.FullName, nameof(DependencyInjectionAttribute), selectorKey, parameterIndex, parameterInfo.Name, parameterInfo.ParameterType.FullName));
                        }

                        lazyConstructorArgument = new Lazy <object>(() =>
                        {
                            // prevent modified closure bug
                            IDependencyManager _dependencyManager = dependencyManager;
                            Type _resolutionType = parameterType;
                            DependencyInjectionAttribute _parameterDependencyInjectionAttribute = parameterDependencyInjectionAttribute;
                            return(_dependencyManager.ResolveDependency(_resolutionType, _parameterDependencyInjectionAttribute.SelectorKey, true));
                        });

                        lazyConstructorArguments[parameterIndex] = lazyConstructorArgument;
                    }

                    lazyConstructorInvokation = new Lazy <TResolution>(() =>
                    {
                        // prevent modified closure bug
                        Type _activatorType = activatorType;
                        Lazy <object>[] _lazyConstructorArguments = lazyConstructorArguments;
                        return((TResolution)Activator.CreateInstance(_activatorType, _lazyConstructorArguments.Select(l => l.Value).ToArray()));
                    });
                }
            }

            if ((object)lazyConstructorInvokation == null)
            {
                throw new DependencyException(string.Format("Cannot find a dependency injection constructor for activator type '{0}' with selector key '{1}'.", activatorType.FullName, selectorKey));
            }

            return(lazyConstructorInvokation.Value);            // lazy loads a cascading chain of Lazy's...
        }
Exemplo n.º 18
0
		public ConsoleApplicationFascade(IDataTypeFascade dataTypeFascade, IAppConfigFascade appConfigFascade, IReflectionFascade reflectionFascade, IAssemblyInformationFascade assemblyInformationFascade)
			: base(dataTypeFascade, appConfigFascade, reflectionFascade, assemblyInformationFascade)
		{
		}