当前位置: 首页 > news >正文

科技服务公司网站模版如何做视频类网站

科技服务公司网站模版,如何做视频类网站,深圳网站建站公司,网站开发部门工作职责1. 必要条件:安装Java环境、安装Graphviz环境:安装VS Code,在VS Code里安装PlantUML插件、Graphviz Preview插件:编写convert_cs_to_puml.py文件,将其放在与cs文件放在同一个文件夹:import os import redef…

1. 必要条件:

安装Java环境、安装Graphviz环境:

安装VS Code,在VS Code里安装PlantUML插件、Graphviz Preview插件:

编写convert_cs_to_puml.py文件,将其放在与cs文件放在同一个文件夹:

import os
import redef parse_cs_file(content):"""解析单个C#文件的内容,提取类名、字段、属性、方法、继承关系和依赖。支持静态字段、静态方法、属性、方法参数类型依赖、字段初始化、继承关系。"""class_info = {'name': None,'fields': [],'methods': [],'dependencies': set(),'inherits': None  # 基类}# 提取类名及继承class_match = re.search(r'class\s+([A-Za-z0-9_]+)(\s*:\s*([A-Za-z0-9_<>]+))?', content)if not class_match:return Noneclass_info['name'] = class_match.group(1)if class_match.group(3):class_info['inherits'] = class_match.group(3)class_info['dependencies'].add(class_match.group(3))# 提取字段(支持可选 static 和初始化表达式)field_pattern = re.compile(r'\b(public|private|protected)\s+(static\s+)?([A-Za-z0-9_<>?]+)\s+([A-Za-z0-9_]+)(?:\s*=\s*[^;]+)?\s*;')for match in field_pattern.finditer(content):visibility = match.group(1)is_static = match.group(2)data_type = match.group(3)variable_name = match.group(4)# 添加依赖if data_type not in ['int', 'string', 'bool', 'double', 'float', 'void', 'DateTime']:class_info['dependencies'].add(data_type.replace('?', '').replace('[]', ''))puml_symbol = get_puml_symbol(visibility)field_str = f'  {puml_symbol}{variable_name} : {data_type}'if is_static:field_str = '{static} ' + field_strclass_info['fields'].append(field_str)# 提取属性(Property)property_pattern = re.compile(r'\b(public|private|protected)\s+(static\s+)?([A-Za-z0-9_<>?]+)\s+([A-Za-z0-9_]+)\s*\{\s*get;\s*set;\s*\}')for match in property_pattern.finditer(content):visibility = match.group(1)is_static = match.group(2)data_type = match.group(3)property_name = match.group(4)if data_type not in ['int', 'string', 'bool', 'double', 'float', 'void', 'DateTime']:class_info['dependencies'].add(data_type.replace('?', '').replace('[]', ''))puml_symbol = get_puml_symbol(visibility)prop_str = f'  {puml_symbol}{property_name} : {data_type} {{property}}'if is_static:prop_str = '{static} ' + prop_strclass_info['fields'].append(prop_str)# 提取方法及参数类型(支持 static 和多行参数)method_pattern = re.compile(r'\b(public|private|protected)\s+(static\s+)?([A-Za-z0-9_<>?]+)\s+([A-Za-z0-9_]+)\s*\((.*?)\)\s*{?',re.DOTALL)for match in method_pattern.finditer(content):visibility = match.group(1)is_static = match.group(2)return_type = match.group(3)method_name = match.group(4)params = match.group(5).replace('\n',' ').strip()  # 去掉换行# 返回类型依赖if return_type not in ['int', 'string', 'bool', 'double', 'float', 'void', 'DateTime']:class_info['dependencies'].add(return_type.replace('?', '').replace('[]', ''))# 参数类型依赖if params:param_list = [p.strip() for p in params.split(',')]for p in param_list:parts = p.split()if len(parts) >= 2:param_type = parts[0]if param_type not in ['int', 'string', 'bool', 'double', 'float', 'void', 'DateTime']:class_info['dependencies'].add(param_type.replace('?', '').replace('[]', ''))puml_symbol = get_puml_symbol(visibility)method_str = f'  {puml_symbol}{method_name}({params}) : {return_type}'if is_static:method_str = '{static} ' + method_strclass_info['methods'].append(method_str)return class_infodef get_puml_symbol(visibility):if visibility == 'public':return '+'elif visibility == 'private':return '-'elif visibility == 'protected':return '#'return ''def generate_puml_for_single_class(class_info):if not class_info:return Nonepuml_content = ['@startuml', '', 'skinparam classAttributeIconSize 0']# 类成员puml_content.append(f'class {class_info["name"]} {{')puml_content.extend(class_info['fields'])if class_info['fields'] and class_info['methods']:puml_content.append('')puml_content.extend(class_info['methods'])puml_content.append('}')# 继承关系if class_info['inherits']:puml_content.append(f'{class_info["name"]} --|> {class_info["inherits"]}')puml_content.append('')puml_content.append('@enduml')return '\n'.join(puml_content)def process_and_generate_multiple_files():script_dir = os.path.dirname(os.path.abspath(__file__))found_cs_files = Falsefor filename in os.listdir(script_dir):if filename.endswith('.cs'):found_cs_files = Truefile_path = os.path.join(script_dir, filename)print(f"正在解析文件: {filename}")try:with open(file_path, 'r', encoding='utf-8') as f:content = f.read()class_info = parse_cs_file(content)if class_info:puml_content = generate_puml_for_single_class(class_info)puml_filename = filename.replace('.cs', '.puml')output_file_path = os.path.join(script_dir, puml_filename)with open(output_file_path, 'w', encoding='utf-8') as f:f.write(puml_content)print(f"成功生成 UML 图文件: {puml_filename}")else:print(f"文件 {filename} 中未找到有效的 C# 类定义。")except Exception as e:print(f"解析 {filename} 失败: {e}")if not found_cs_files:print("未找到任何C#文件。")if __name__ == '__main__':process_and_generate_multiple_files()

编写完上面这个文件后,假设现在在同级文件夹下添加一个A.cs,文件内容如下:

public class A
{public int a = 1;
}

运行convert_cs_to_puml.py文件,可以在同级文件夹下看到A.puml:

@startumlskinparam classAttributeIconSize 0
class A {+a : int
}@enduml

最后Alt + D,生成UML图:

http://www.dtcms.com/a/465717.html

相关文章:

  • 最小覆盖子串
  • 算法4.0
  • 云网智安一体:中国电信数字安全创新的技术破局与生态构建
  • 制作音乐网站实验报告佛山做外贸网站渠道
  • 企业级数据库实操手册:从架构部署到安全运维的落地指南
  • 网络安全认证培训机构的痛点
  • 网站搜索引擎推广方案做网页设计的网站
  • 国内坚持做正品的网站女人学ui有前途吗
  • centos如何做的时间同步
  • CentOS 7 环境下 RabbitMQ 的部署与 Web 管理界面基本使用指南
  • 【AT指令解析】TencentOS Tiny AT指令解析源码分析1-简介
  • centos/cuos如何开启软件源
  • Java常见业务场景之批处理优化:从稳定性、性能、数据一致性、健壮性、可观测性五大维度,系统提供批处理优化方案
  • 网站建设拟采用的技术路线深圳互联网公司招聘
  • 人工智能学习:逻辑回归
  • 23种设计模式——命令模式(Command Pattern)
  • 网站空间用万网的 域名不在万网gta5 网站正在建设中
  • 枚举单例模式:Java单例实现的终极方案解析
  • 1.单例模式有哪几种常见的实现方式?
  • 安蓉建设总公司网站服装设计官网
  • PyTorch的安装与使用
  • 解决办法:win11连接蓝牙的时候每次连接都是100%的音量
  • foundry创建项目
  • 网站整体地图怎么做招设计师在哪里找
  • C#学习小笔记(完整版)—— Patience
  • 解决MySQL8.0及其更高版本的两个安全问题——及其配置MySQL实现SSL/TLS加密通信、caching_sha2_password通信
  • Node.js性能优化:从事件循环到内存管理
  • Node.js核心模块:fs、path与http详解
  • 企业级UDP文件传输工具如何重塑数据交换格局
  • 在JavaScript / Node.js中,Web服务器参数处理与编码指南