WPF solution template creation methods, devices, computer equipment, and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-13
- Publication Date
- 2026-08-14
AI Technical Summary
现有技术中并没有一种能够现成/通用/普及的解决方案模板的技术方案,而用户如果需要实现,则通常是直接复制旧的解决方案,并在其基础上直接进行修改,而这一修改过程需要进行多个手动操作和调整的步骤才可以实现,因此这种方式存在过程繁杂且无法复用等缺陷
[0014]本发明实施例提供了一种WPF解决方案模板创建方法、装置、计算机设备及存储介质,该方法包括:获取WPF解决方案模板原型,并对所述WPF解决方案模板原型中的所有程序集导出对应的第一项目模板;对所述WPF解决方案模板原型中的非程序集进行文件和目录配置,并导出得到对应的第二项目模板;基于所述第一项目模板和第二项目模板创建具有多项目的目标WPF解决方案模板,并通过VSIX插件为所述目标WPF解决方案模板配置项目信息,得到最终的WPF解决方案模板。本发明实施例通过WPF解决方案模板原型来获取导出程序集对应的第一项目模板和非程序集对应的第二项目模板,然后以此创建目标WPF解决方案模板,并对该目标WPF解决方案模板进行配置,从而得到最终的WPF解决方案模板,如此便可以实现WPF解决方案模板的的创建,并将创建的WPF解决方案模板集成到Visual Stdio开发工具中,从而达到快速简便地创建WPF解决方案模板的效果,且该WPF解决方案模板具有高效且可复用等优势。
Smart Images

Figure CN117724698B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and in particular to a method, apparatus, computer device, and storage medium for creating WPF solution templates. Background Technology
[0002] While Visual Studio allows the creation of WPF (Windows Presentation Foundation, a Windows-based user interface framework) project templates, it currently lacks templates that provide WPF solutions. A solution is a project unit within Visual Studio; it's the top-level file / project unit, while a project is the next level unit within a solution. A solution consists of at least one project. Visual Studio can create, edit, and compile various solutions, including those for C++, C#, and VB.Net. WPF solutions are a type of C# solution that uses the WPF framework as its interface. Currently, there is no readily available / universal / widely applicable solution template. Users typically copy existing solutions and modify them, a process requiring multiple manual steps and adjustments, resulting in complexity and lack of reusability. Furthermore, existing technologies only support templates for single or multiple projects at the assembly level, lacking the ability to configure solutions and solution file directory structures within project templates, or customize non-compile-related configurations such as packaging settings. Therefore, how to implement a solution template that can be directly reused in Visual Studio is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0003] This invention provides a method, apparatus, computer device, and storage medium for creating WPF solution templates, aiming to provide a reusable WPF solution template.
[0004] In a first aspect, embodiments of the present invention provide a method for creating a WPF solution template, including:
[0005] Obtain the WPF solution template prototype and export the corresponding first project template for all assemblies in the WPF solution template prototype;
[0006] Configure the files and directories of the non-assemblies in the WPF solution template prototype, and export them to obtain the corresponding second project template;
[0007] Based on the first project template and the second project template, a target WPF solution template with multiple projects is created, and the project information is configured for the target WPF solution template through the VSIX plugin to obtain the final WPF solution template.
[0008] Secondly, embodiments of the present invention provide a WPF solution template creation apparatus, comprising:
[0009] The prototype acquisition unit is used to acquire the WPF solution template prototype and export the corresponding first project template for all assemblies in the WPF solution template prototype.
[0010] The project export unit is used to configure the files and directories of the non-assemblies in the WPF solution template prototype and export them to obtain the corresponding second project template.
[0011] A configuration unit is created to create a target WPF solution template with multiple projects based on the first project template and the second project template, and the project information is configured for the target WPF solution template through the VSIX plugin to obtain the final WPF solution template.
[0012] Thirdly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the WPF solution template creation method as described in the first aspect.
[0013] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the WPF solution template creation method as described in the first aspect.
[0014] This invention provides a method, apparatus, computer device, and storage medium for creating WPF solution templates. The method includes: obtaining a WPF solution template prototype and exporting corresponding first project templates for all assemblies in the WPF solution template prototype; configuring files and directories for non-assemblies in the WPF solution template prototype and exporting corresponding second project templates; creating a target WPF solution template with multiple projects based on the first and second project templates, and configuring project information for the target WPF solution template through a VSIX plugin to obtain the final WPF solution template. This invention uses a WPF solution template prototype to obtain and export the first project template corresponding to the assemblies and the second project template corresponding to the non-assemblies, then uses these to create a target WPF solution template and configures it to obtain the final WPF solution template. This allows for the creation of WPF solution templates, which can then be integrated into the Visual Studio development tool, achieving the effect of quickly and easily creating WPF solution templates. Furthermore, this WPF solution template has advantages such as high efficiency and reusability. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart illustrating a WPF solution template creation method provided in an embodiment of the present invention;
[0017] Figure 2 A schematic block diagram of a WPF solution template creation device provided in an embodiment of the present invention;
[0018] Figure 3 This is a schematic diagram of a multi-project directory structure in a WPF solution template creation method provided in an embodiment of the present invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0021] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0022] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0023] Please see below. Figure 1 , Figure 1 The flowchart of a WPF solution template creation method provided in this embodiment of the invention specifically includes steps S101 to S103.
[0024] S101. Obtain the WPF solution template prototype and export the corresponding first project template for all assemblies in the WPF solution template prototype.
[0025] S102. Configure the files and directories of the non-assemblies in the WPF solution template prototype, and export them to obtain the corresponding second project template;
[0026] S103. Create a target WPF solution template with multiple projects based on the first project template and the second project template, and configure the project information for the target WPF solution template through the VSIX plugin to obtain the final WPF solution template.
[0027] In this embodiment, since a WPF solution template typically contains more than one assembly, and each assembly can be independently exported as a project template, the first project template corresponding to the exported assembly and the second project template corresponding to the non-assemblies are first obtained through the WPF solution template prototype. Then, the target WPF solution template is created using this prototype and configured to obtain the final WPF solution template. This allows for the creation of a WPF solution template, which is then integrated into the Visual Studio development tool, achieving the effect of quickly and easily creating WPF solution templates. Furthermore, this WPF solution template has advantages such as high efficiency and reusability.
[0028] While existing technologies can create project-level templates, they cannot directly create solutions with multiple projects from these templates. The method provided in this embodiment, however, can directly create WPF solution templates with multiple projects, for example... Figure 3 As shown in the image. This embodiment utilizes a VSIX plugin to directly configure the WPF solution template, offering simplicity and speed. Furthermore, the WPF solution template provided in this embodiment is reusable, allowing the same WPF solution template to be reused in Visual Studio development environments on different devices. Of course, different WPF solution template prototypes can also be reused using the methods provided in this embodiment. It should also be noted that the creation method provided in this embodiment is not only applicable to WPF solutions but also to other solutions within the Visual Studio development tool.
[0029] In one embodiment, the step of creating a target WPF solution template with multiple projects based on the first project template and the second project template, and configuring project information for the target WPF solution template through a VSIX plugin to obtain the final WPF solution template includes:
[0030] Install the target WPF solution template to the configuration path of the project template in the Visual Studio program;
[0031] Launch the Visual Studio program to determine if the target WPF solution template has been installed successfully.
[0032] Once the target WPF solution template is successfully installed, install the VSIX plugin and use the VSIX plugin to configure project information.
[0033] Specifically, configuring project information using the VSIX plugin includes:
[0034] The compilation configuration of the target WPF solution template is adjusted using the VSIX plugin, and all assemblies in the target WPF solution template are uninstalled. Then the WPF solution template is closed.
[0035] Adaptively adjust the Sln files and all assembly directory structure in the target WPF solution template, and then restart the target WPF solution template;
[0036] Load and save the uninstalled assemblies to the target WPF solution template after restarting.
[0037] When adjusting the compilation configuration of the target WPF solution template using the VSIX plugin, the specific steps involve calling the Visual Studio integrated environment interface in the VSIX plugin code and modifying the compilation configuration of the target WPF solution template. The compilation configuration parameters include the name of the compilation configuration, the platform, and the project deployment switch.
[0038] Furthermore, prior to the step of adjusting the compilation configuration of the WPF solution template using the VSIX plugin, the following steps are included:
[0039] Select the Sln node of the target WPF solution template using the Solution Explorer in the Visual Studio program, and initialize the target WPF solution template based on the Sln node.
[0040] In this embodiment, after creating the target WPF solution template based on the first and second project templates, the target WPF solution template is configured. First, the target WPF solution template is copied to the configuration path of the Visual Studio project template, thus completing the installation of the project template within the target WPF solution template. Then, Visual Studio is opened, and the successful installation of the target WPF solution template is confirmed. After confirming successful installation, Visual Studio is closed, and the VSIX configuration plugin is installed. Visual Studio is then reopened, and the target WPF solution template is created / opened. Subsequently, the solution Sln node is selected in the Solution Explorer view of Visual Studio. The pop-up menu of the corresponding Sln node is used to select "Initialize Target WPF Solution Template." Then, the VSIX plugin is controlled to start. After starting, the VSIX plugin automatically adjusts the compilation configuration of the target WPF solution template. Specifically, the VSIX plugin code calls some interfaces of the Visual Studio integrated environment and modifies the target WPF solution template currently loaded by Visual Studio to modify the solution's compilation configuration, such as changing the compilation configuration name, platform, and project deployment switch parameters. After completing the compilation and configuration, uninstall all assemblies from the target WPF solution template. This is because the directory structure of the target WPF solution template (files with the .sln extension) needs to be adjusted; without uninstalling all assemblies, the file paths cannot be moved. Next, close the target WPF solution template and adjust the directory structure of the solution .sln file and all assemblies. Then reopen the target WPF solution template and load all assemblies, which are the assemblies uninstalled in the previous steps. Finally, save the solution changes to complete the configuration of the target WPF solution template, and the VSIX plugin execution will end.
[0041] In one embodiment, after the step of exporting the corresponding first project template for all assemblies in the WPF solution template prototype, the following steps are included:
[0042] Unzip all of the first project templates;
[0043] Group the first project template after decompression into the same directory structure.
[0044] In this embodiment, after the first project template is exported, it will be decompressed and combined so that all the first project templates are located in the same directory structure, thus realizing the templating of the directory structure in the WPF solution template.
[0045] In one embodiment, configuring files and directories for non-assemblies in the WPF solution template prototype and exporting them to obtain the corresponding second project template includes:
[0046] Get the file hierarchy and directory information of non-assemblies;
[0047] Configure the non-assemblies according to the file hierarchy and directory information.
[0048] In this embodiment, when exporting a second project template from a non-assembly, some files and directories outside the assembly are configured, such as packaging script files, configuration information files, and external dependency tools. Specifically, this involves configuring the compilation scheme and adjusting the solution's file directory structure, which mainly refers to the file / directory structure at the solution level.
[0049] Figure 2 This is a schematic block diagram of a WPF solution template creation device 200 provided in an embodiment of the present invention. The device 200 includes:
[0050] The prototype acquisition unit 201 is used to acquire a WPF solution template prototype and export the corresponding first project template for all assemblies in the WPF solution template prototype.
[0051] Project export unit 202 is used to configure files and directories in the non-assemblies in the WPF solution template prototype and export them to obtain the corresponding second project template.
[0052] A configuration unit 203 is created to create a target WPF solution template with multiple projects based on the first project template and the second project template, and to configure project information for the target WPF solution template through a VSIX plugin to obtain the final WPF solution template.
[0053] In one embodiment, the configuration creation unit 203 includes:
[0054] The template installation unit is used to install the target WPF solution template to the configuration path of the project template in the Visual Studio program;
[0055] The installation check unit is used to launch the Visual Studio program to determine whether the target WPF solution template has been installed successfully.
[0056] The plugin installation unit is used to install the VSIX plugin when the target WPF solution template is successfully installed, and to configure project information using the VSIX plugin.
[0057] In one embodiment, the plug-in installation unit includes:
[0058] The assembly unloading unit is used to adjust the compilation configuration of the target WPF solution template using the VSIX plugin, unload all assemblies in the target WPF solution template, and then close the WPF solution template.
[0059] The adaptive adjustment unit is used to adaptively adjust the Sln files and all assembly directory structures in the target WPF solution template, and then restart the target WPF solution template.
[0060] The Assembly Loading Unit is used to load and save unloaded assemblies to the target WPF solution template after a restart.
[0061] In one embodiment, the assembly unloading unit includes:
[0062] The build configuration unit is used to call the Visual Studio integrated environment interface in the VSIX plugin code and modify the build configuration of the target WPF solution template; the build configuration parameters include the build configuration name, platform, and project deployment switch.
[0063] In one embodiment, the configuration creation unit 203 further includes:
[0064] The template initialization unit is used to select the Sln node of the target WPF solution template through the Solution Explorer of the Visual Studio program, and to initialize the target WPF solution template based on the Sln node.
[0065] In one embodiment, the WPF solution template creation apparatus 200 further includes:
[0066] The project decompression unit is used to decompress all of the first project templates;
[0067] The project combination unit is used to combine the unzipped first project templates into the same directory structure.
[0068] In one embodiment, the project export unit 202 includes:
[0069] The non-assembly acquisition unit is used to acquire the file level and directory information of non-assemblies;
[0070] The non-assembly configuration unit is used to configure the non-assembly according to the file hierarchy and directory information.
[0071] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0072] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0073] This invention also provides a computer device, which may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the computer device may also include various network interfaces, power supplies, and other components.
[0074] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0075] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for creating a WPF solution template, characterized in that, include: Obtain the WPF solution template prototype and export the corresponding first project template for all assemblies in the WPF solution template prototype; Configure the files and directories of the non-assemblies in the WPF solution template prototype, and export them to obtain the corresponding second project template; A target WPF solution template with multiple projects is created based on the first project template and the second project template, and project information is configured for the target WPF solution template through the VSIX plugin to obtain the final WPF solution template. The process of creating a target WPF solution template with multiple projects based on the first and second project templates, and configuring project information for the target WPF solution template through a VSIX plugin to obtain the final WPF solution template includes: Install the target WPF solution template to the configuration path of the project template in the Visual Studio program; Launch the Visual Studio program to determine if the target WPF solution template has been installed successfully. Once the target WPF solution template is successfully installed, install the VSIX plugin and use the VSIX plugin to configure project information. The process of configuring project information using the VSIX plugin includes: The compilation configuration of the target WPF solution template is adjusted using the VSIX plugin, and all assemblies in the target WPF solution template are uninstalled. Then the WPF solution template is closed. Adaptively adjust the Sln files and all assembly directory structure in the target WPF solution template, and then restart the target WPF solution template; Load and save the uninstalled assemblies to the target WPF solution template after restarting.
2. The WPF solution template creation method according to claim 1, characterized in that, The adjustment of the compilation configuration of the target WPF solution template using the VSIX plugin includes: The VSIX plugin code calls the Visual Studio integrated environment interface and modifies the compilation configuration of the target WPF solution template; the compilation configuration parameters include the name of the compilation configuration, the platform, and the project deployment switch.
3. The WPF solution template creation method according to claim 1, characterized in that, Before the step of adjusting the compilation configuration of the WPF solution template using the VSIX plugin, the following steps are included: Select the Sln node of the target WPF solution template using the Solution Explorer in the Visual Studio program, and initialize the target WPF solution template based on the Sln node.
4. The WPF solution template creation method according to claim 1, characterized in that, After the step of exporting the corresponding first project template for all assemblies in the WPF solution template prototype, the following steps are included: Unzip all of the first project templates; Group the first project template after decompression into the same directory structure.
5. The WPF solution template creation method according to claim 1, characterized in that, The step of configuring files and directories for non-assemblies in the WPF solution template prototype and exporting them to obtain the corresponding second project template includes: Get the file hierarchy and directory information of non-assemblies; Configure the non-assemblies according to the file hierarchy and directory information.
6. A WPF solution template creation device, characterized in that, include: The prototype acquisition unit is used to acquire the WPF solution template prototype and export the corresponding first project template for all assemblies in the WPF solution template prototype. The project export unit is used to configure the files and directories of the non-assemblies in the WPF solution template prototype and export them to obtain the corresponding second project template. Create a configuration unit to create a target WPF solution template with multiple projects based on the first project template and the second project template, and configure project information for the target WPF solution template through the VSIX plugin to obtain the final WPF solution template; The configuration creation unit includes: The template installation unit is used to install the target WPF solution template to the configuration path of the project template in the Visual Studio program; The installation check unit is used to launch the Visual Studio program to determine whether the target WPF solution template has been installed successfully. The plugin installation unit is used to install the VSIX plugin when the target WPF solution template is successfully installed, and to use the VSIX plugin to configure project information. The plug-in installation unit includes: The assembly unloading unit is used to adjust the compilation configuration of the target WPF solution template using the VSIX plugin, unload all assemblies in the target WPF solution template, and then close the WPF solution template. The adaptive adjustment unit is used to adaptively adjust the Sln files and all assembly directory structures in the target WPF solution template, and then restart the target WPF solution template. The Assembly Loading Unit is used to load and save unloaded assemblies to the target WPF solution template after a restart.
7. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the WPF solution template creation method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the WPF solution template creation method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Visual Studio-based rapid development method
CN112416305A
Multi-version development method based on AutoCAD.NET
CN114356394A