WEB开发网
开发学院软件开发Shell 搜索C#项目中所有引用的名字空间 阅读

搜索C#项目中所有引用的名字空间

 2012-05-19 07:51:28 来源:WEB开发网   
核心提示:查找名字空间(请保存为cmd文件再运行)@echo offsetlocal ENABLEDELAYEDEXPANSION(for /f "eol= tokens=2* delims=: " %%n in ('FINDSTR /S /C:"using " /D:D:\D

查找名字空间(请保存为cmd文件再运行)

@echo off
setlocal ENABLEDELAYEDEXPANSION
(for /f "eol=  tokens=2* delims=:  " %%n in ('FINDSTR /S /C:"using " /D:D:\Desktop\DiscUtilsSrc-0.10\src *.cs ^| FIND /V "(" ^| FIND /V ")" ^| FIND /V "//" ^| FIND /V "*" ^| FIND /V "#" ^| FIND /V "+" ^| FIND /V "=" ^| FIND /V ","') do echo %%n) > temp
for /f "delims=" %%e in ('FIND /V " using" temp ^| FIND /V "-" ^| sort') do (
if not defined %%e set %%e=Def & >>namespace echo %%e
)

替换命名空间

@echo off
setlocal ENABLEDELAYEDEXPANSION
type nul>DiscUtils.cs
(for /f "eol=  tokens=2* delims=:  " %%n in ('FINDSTR /S /C:"using " /D:D:\Desktop\DiscUtilsSrc-0.10\src *.cs ^| FIND /V "(" ^| FIND /V ")" ^| FIND /V "//" ^| FIND /V "*" ^| FIND /V "#" ^| FIND /V "+" ^| FIND /V "=" ^| FIND /V ","') do echo %%n) > temp
for /f "delims=" %%e in ('FIND /V " using" temp ^| FIND /V "-" ^| sort') do (
if not defined %%e set %%e=Def & >>DiscUtils.cs echo %%e
)
copy /y DiscUtils.cs namespace
FOR /r D:\Desktop\DiscUtilsSrc-0.10\src %%f in (*.cs) do (
	type nul>temp
	for /f "tokens=*" %%i in ('type %%f') do (
	set var=%%i
	set "var=!var: using=AAAAAAAA!"
	echo !var!>>temp
	)
	copy /y temp %%f
	FOR /F "tokens=*" %%w IN ('type namespace') DO (
		type nul>temp
		for /f "tokens=*" %%i in ('type %%f') do (
		set var=%%i
		set "var=!var:%%w=!"
		echo !var!>>temp
		)
		copy /y temp %%f
	)
	type nul>temp
	for /f "tokens=*" %%i in ('type %%f') do (
	set var=%%i
	set "var=!var:AAAAAAA= using!"
	echo !var!>>DiscUtils.cs
	)
)

Tags:搜索 项目 所有

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接