GenerateSerializers() public method

Generates the serializers using specified assembly file.
Specifying both of includingPattern and excludingPattern indicates AND condition.
public GenerateSerializers ( Assembly sourceAssembly, string includingPattern, string excludingPattern ) : IEnumerable
sourceAssembly System.Reflection.Assembly The source assembly.
includingPattern string The including regex pattern. Omitting indicates all public concrete types are included.
excludingPattern string The excluding regex pattern. Omitting indicates all public concrete types are included.
return IEnumerable
Exemplo n.º 1
0
        private static void GenerateSerializers(
            IList <string> sourceFilePathes,
            string[] referenceAssemblies,
            bool sourceFileIsAssembly,
            string includingPattern,
            string excludingPattern,
            bool treatWarningsAsErrors,
            int warningLevel,
            bool admitNonPublicTypes,
            SerializerCodeGenerationConfiguration configuration
            )
        {
            if (sourceFilePathes == null || sourceFilePathes.Count == 0)
            {
                throw new ArgumentException("Source files or a source assembly is required.");
            }
            var generator = new SerializerCodeGenerator(configuration);

            IEnumerable <string> result;

            if (!sourceFileIsAssembly)
            {
                result =
                    generator.GenerateSerializers(
                        new SerializerTargetCompiler
                {
                    TreatWarningsAsErrors = treatWarningsAsErrors,
                    WarningLevel          = warningLevel
                }.CompileTargetTypeAssembly(
                            sourceFilePathes,
                            referenceAssemblies ?? new string[0]
                            ),
                        includingPattern,
                        excludingPattern,
                        admitNonPublicTypes
                        );
            }
            else
            {
                result =
                    generator.GenerateSerializers(
                        sourceFilePathes[0],
                        includingPattern,
                        excludingPattern,
                        admitNonPublicTypes
                        );
            }

            foreach (var outputFilePath in result)
            {
                Console.WriteLine(outputFilePath);
            }
        }
Exemplo n.º 2
0
		private static void GenerateSerializers(
			IList<string> sourceFilePathes,
			string[] referenceAssemblies,
			bool sourceFileIsAssembly,
			string includingPattern,
			string excludingPattern,
			bool treatWarningsAsErrors,
			int warningLevel,
			SerializerCodeGenerationConfiguration configuration
		)
		{
			if ( sourceFilePathes == null || sourceFilePathes.Count == 0 )
			{
				throw new ArgumentException( "Source files or a source assembly is required." );
			}
			var generator = new SerializerCodeGenerator( configuration );

			IEnumerable<string> result;
			if ( !sourceFileIsAssembly )
			{
				result =
					generator.GenerateSerializers(
						new SerializerTargetCompiler
						{
							TreatWarningsAsErrors = treatWarningsAsErrors,
							WarningLevel = warningLevel
						}.CompileTargetTypeAssembly(
							sourceFilePathes,
							referenceAssemblies ?? new string[ 0 ]
							),
						includingPattern,
						excludingPattern
						);
			}
			else
			{
				result =
					generator.GenerateSerializers(
						sourceFilePathes[ 0 ],
						includingPattern,
						excludingPattern
						);
			}

			foreach ( var outputFilePath in result )
			{
				Console.WriteLine( outputFilePath );
			}
		}