在加载模块后再增加模块,转载文章HERE
The following sequence diagram shows us that the InitializeModules() method is the last process run http://global-webnet.net/UML/prism.htm
Examining the baseclass code we find that the following is what actually loads the modules; suggesting that it is safe to run again because of the statement in bold:
private void LoadModuleTypes(IEnumerable<ModuleInfo> moduleInfos)
{
if (moduleInfos == null)
{
return;
}
foreach (ModuleInfo moduleInfo in moduleInfos)
{
if (moduleInfo.State == ModuleState.NotStarted)
{
if (this.ModuleNeedsRetrieval(moduleInfo))
{
this.BeginRetrievingModule(moduleInfo);
}
else
{
moduleInfo.State = ModuleState.ReadyForInitialization;
}
}
}
this.LoadModulesThatAreReadyForLoad();
}
I did a quick Proof of Concept with the StockTraderRI application to see if it was as easy as what was suggested to add a module after the BootStrapper process; I added the line in bold below to the App() class
namespace StockTraderRI
{
public partial class App : Application
{
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
//this.RootVisual = new Shell();
var bootstrapper = new StockTraderRIBootstrapper();
bootstrapper.Run();
// Watch module will not load without this line
bootstrapper.PostCatalogProcessing();
}
I then updated the StockTraderRIBootstrapper as follows.
namespace StockTraderRI
{
public partial class StockTraderRIBootstrapper : UnityBootstrapper
{
protected override IModuleCatalog GetModuleCatalog()
{
var catalog = new ModuleCatalog();
catalog.AddModule(typeof(MarketModule))
.AddModule(typeof(PositionModule), "MarketModule");
//.AddModule(typeof(WatchModule), "MarketModule"); <= remarked out
//.AddModule(typeof(NewsModule)); <= remarked out
return catalog;
}
public void PostCatalogProcessing()
{
ModuleCatalog catalog = (ModuleCatalog)Container.Resolve<IModuleCatalog>();
catalog.AddModule(typeof(WatchModule), "MarketModule");
catalog.AddModule(typeof(NewsModule));
InitializeModules();
}
见园子里有介绍office live 的文章,这两天试了下,总的感觉不错,与live Id团队或者朋友实现文件共享,在线查看word,excel或ppt等文件,还具有修改编辑回存等方便的网络操作功能,不论你到哪里工作就到哪,非常适合我们这样的懒人,但在使用过程中发现想将上传的文件发给其他人,如果是有live id的人并注册了office live 是很方便,通过共享就可以了,但在任何邮箱的朋友,想通过发邮件已附件的形式发给对方就不方便了,得先将文件下载下来再按正常发邮件附件的形式发邮件,这样个人感觉非常繁琐,如果能够在office live 菜单里有一个发选定文件的发邮件给其他人的菜单项就更好了,这种应用还是很多的,不知园子里有其他朋友有什么好的方法请共享出来。
(无法显示隐藏文件以及无法双击打开分区)
用杀毒软件杀毒,所有驱动盘上的文件夹表现为不可见,实际为文件夹隐藏了。
如何判断是中了该种病毒,可以通过在命令行下键入:
cd C:"
dir /ah
如果有fun.xls.exe,再遵循以下的步骤即可.
fun.xls.exe 是 tel.xls.exe 的变种
症状:
1.鼠标右键点盘符出现"Auto"字样
2.无法显示隐藏文件
杀毒方法:(切记:在操作过程中使用“右键->打开”,不可双击。)
1.结束注册表中的fun.xls.exe的进程(建议选中fun.xls.exe->右键->转到进程,查找到“algsrvs.exe” 单击它,再选择“结束进程”)
2.删除文件:
C:"WINDOWS"system32"algsrvs.exe
C:"WINDOWS"system32"msfun80.exe
C:"WINDOWS"system32"msime82.exe
C:"WINDOWS"ufdata2000.log
3.打开注册表编辑器(“开始”-“运行”-输入“regedit”),删除注册表中的所有包含:fun.xls.exe的键值。用搜索!!
4.运行CMD,在每个驱动盘下使用如下命令:
先用dir/a命令看在每个分区下的根目录下是否存在这两个文件autorun.inf、fun.xls.exe,如果存在用如下命令取消隐藏。
Attrib –s –r –h autorun.inf
Attrib –s –r –h fun.xls.exe
5. 删除每个盘符下的隐藏文件:不要双击打开,点击右键选择打开
AUTORUN.INF
fun.xls.exe
6.重起电脑!
7.将隐藏的文件夹取消隐藏属性
在cmd下用命令dir/a知道每个分区的隐藏文件夹
再用命令:attrib –s –r –h 文件夹名取消所有的隐藏文件夹。
转发,试过了效果一级棒。大家快下下去研究研究。
终于解决了一个困扰许久的关于DWG文件的难题,还没完善,欢迎批评,高分相送
为了找一个合适的预览DWG文件的控件,不知道搜索了多少次,都没有满意的结果,R2002自带的控件无法预览R2004格式的文件,最近花了几天时间,终于解决了这个困扰好久了难题,直接从DWG文件中提取位图放在PictureBox中预览。唯一留下的遗憾是当文件被其它进程打开时,会导致程序返回速度太慢,不知道各位是否有好的方法解决这一问题(或是有什么办法可以强行打开正被其它进程打开的文件)。现将代码及注释贴出来,要知道我是刚学VB.Net的,而且纯属业余爱好。
Private Structure BITMAPFILEHEADER
Dim bfType As Short
Dim bfSize As Integer
Dim bfReserved1 As Short
Dim bfReserved2 As Short
Dim bfOffBits As Integer
End Structure
Public Function GetDwgImage(ByVal FileName As String) As Image
If Not File.Exists(FileName) Then Exit Function
Dim DwgF As FileStream '文件流
Dim PosSentinel As Integer '文件描述块的位置
Dim br As BinaryReader '读取二进制文件
Dim TypePreview As Integer '缩略图格式
Dim PosBMP As Integer '缩略图位置
Dim LenBMP As Integer '缩略图大小
Dim biBitCount As Short '缩略图比特深度
Dim biH As BITMAPFILEHEADER 'BMP文件头,DWG文件中不包含位图文件头,要自行加上去
Dim BMPInfo() As Byte '包含在DWG文件中的BMP文件体
Dim BMPF As New MemoryStream '保存位图的内存文件流
Dim bmpr As New BinaryWriter(BMPF) '写二进制文件类
Dim myImg As Image
Try
DwgF = New FileStream(FileName, FileMode.Open, FileAccess.Read) '文件流
br = New BinaryReader(DwgF)
DwgF.Seek(13, SeekOrigin.Begin) '从第十三字节开始读取
PosSentinel = br.ReadInt32 '第13到17字节指示缩略图描述块的位置
DwgF.Seek(PosSentinel + 30, SeekOrigin.Begin) '将指针移到缩略图描述块的第31字节
TypePreview = br.ReadByte '第31字节为缩略图格式信息,2 为BMP格式,3为WMF格式
Select Case TypePreview
Case 1
Case 2, 3
PosBMP = br.ReadInt32 'DWG文件保存的位图所在位置
LenBMP = br.ReadInt32 '位图的大小
DwgF.Seek(PosBMP + 14, SeekOrigin.Begin) '移动指针到位图块
biBitCount = br.ReadInt16 '读取比特深度
DwgF.Seek(PosBMP, SeekOrigin.Begin) '从位图块开始处读取全部位图内容备用
BMPInfo = br.ReadBytes(LenBMP) '不包含文件头的位图信息
br.Close()
DwgF.Close()
With biH '建立位图文件头
.bfType = &H4D42
If biBitCount < 9 Then .bfSize = 54 + 4 * (2 ^ biBitCount) + LenBMP Else .bfSize = 54 + LenBMP
.bfReserved1 = 0 '保留字节
.bfReserved2 = 0 '保留字节
.bfOffBits = 14 + &H28 + 1024 '图像数据偏移
End With
'以下开始写入位图文件头
bmpr.Write(biH.bfType) '文件类型
bmpr.Write(biH.bfSize) '文件大小
bmpr.Write(biH.bfReserved1) '0
bmpr.Write(biH.bfReserved2) '0
bmpr.Write(biH.bfOffBits) '图像数据偏移
bmpr.Write(BMPInfo) '写入位图
BMPF.Seek(0, SeekOrigin.Begin) '指针移到文件开始处
myImg = Image.FromStream(BMPF) '创建位图文件对象
Return myImg
bmpr.Close()
BMPF.Close()
End Select
Catch ex As Exception
Return Nothing
End Try
End Function
这个程序涉及到了DWG文件的内部格式。编出来的人很了不起。