实现简单 c# 编辑器

想法

  • 基于反射机制开发一个小型的c# 编辑器(纯娱乐)

第一步 实现对命名空间的智能提示

  • 效果
输入: using Sy
System.Diagnostics.Tools.dll
System.IO.FileSystem.DriveInfo.dll
System.Buffers.dll
System.Data.DataSetExtensions.dll
System.Diagnostics.StackTrace.dll
System.Net.Http.dll
System.Security.Cryptography.Csp.dll
System.Net.HttpListener.dll
System.Runtime.Handles.dll
libSystem.Security.Cryptography.Native.OpenSsl.so
System.Security.Cryptography.Encoding.dll
输入:  using System.Di
System.Diagnostics.Tools.dll
System.Diagnostics.StackTrace.dll
System.Diagnostics.DiagnosticSource.dll
System.Diagnostics.Contracts.dll
System.Diagnostics.Process.dll
System.Diagnostics.Tracing.dll
System.Diagnostics.TextWriterTraceListener.dll
System.Diagnostics.TraceSource.dll
System.Diagnostics.Debug.dll
System.Diagnostics.FileVersionInfo.dll

实现


using System.IO;
using System.Collections.Generic;
using System.Reflection;
using System;
namespace c_数据结构
{
    class Program
    {
        static void Main(string[] args)
        {
            
             Edit editobj=new Edit();
            
             while (true){
                string str=Console.ReadLine();
                if(str=="break")break; 
                foreach(var item in editobj.SetCodeType(str)){
                    System.Console.WriteLine(item);
                }

            }
        }
        
    }
    class Edit{
        private List<string> namespaceList=new List<string>();//保存所有命名空间

        public int codeType=0; 
        public List<string> GetNamepace(string code){
             List<string> NamesList=new List<string>();
            string Namespce="/home/yh/dotnetshred/shared/Microsoft.NETCore.App/5.0.7/"; //填写你自己的sdk路径
            if(Directory.Exists(Namespce))
            {
                 
                string[] nameFile=Directory.GetFiles(Namespce);
                int count=0;
                foreach(string name in nameFile){
                   
                    if(name.Contains(code)){
                            NamesList.Add(name.Replace(Namespce,""));
                           count++;
                    }
                    if(count>10){
                        break;
                    }
                }
                
                
            } 
            else{
                System.Console.WriteLine("路径错误");
            } 
                  return NamesList;
        }
        public List<string> SetCodeType(string code){
             
                if(code.Contains("using")){
             
                    code=code.Replace("using ","");
    
                    return GetNamepace(code);
                }
                else
                {
                        return GetClassName(code);
                }                

        }
        private List<string> GetClassName(string code){
                foreach (string namesp in namespaceList){

                        


                }
                return new List<string>();
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值