Пример #1
0
        private void WriteFile(WindowsAccessBridgeModel model)
        {
            using (var writer = File.CreateText(_options.PublicClassesOutputFileName)) {
                using (var sourceWriter = new SourceCodeWriter(writer, model)) {
                    WriteSourceFileHeader(sourceWriter);

                    sourceWriter.StartNamespace("WindowsAccessBridgeInterop");
                    WriteApplicationFunctionsInterface(model, sourceWriter);
                    WriteApplicationEventsInterface(model, sourceWriter);
                    WriteApplicationEventHandlerTypes(model, sourceWriter);
                    WriteApplicationEnums(model, writer, sourceWriter);
                    WriteApplicationStructs(model, sourceWriter, writer);
                    WriteApplicationClasses(model, writer, sourceWriter);
                    sourceWriter.EndNamespace();
                }
            }

            foreach (var legacy in new[] { false, true })
            {
                using (var writer = File.CreateText(legacy ? _options.InternalLegacyClassesOutputFileName : _options.InternalClassesOutputFileName)) {
                    using (var sourceWriter = new SourceCodeWriter(writer, model)) {
                        sourceWriter.IsLegacy = legacy;
                        WriteSourceFileHeader(sourceWriter);

                        sourceWriter.StartNamespace("WindowsAccessBridgeInterop");
                        WriteApplicationFunctionsClass(model, sourceWriter);
                        WriteApplicationEventsClass(model, sourceWriter);

                        sourceWriter.IsNativeTypes = true;
                        WriteEntryPointsClass(model, sourceWriter);
                        WriteLibraryStructs(model, sourceWriter, writer);
                        WriteLibraryClasses(model, writer, sourceWriter);
                        sourceWriter.EndNamespace();
                    }
                }
            }
        }