本文整理汇总了C#中Microsoft.Practices.Composite.Modularity.ModuleInfo类的典型用法代码示例。如果您正苦于以下问题:C# ModuleInfo类的具体用法?C# ModuleInfo怎么用?C# ModuleInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleInfo类属于Microsoft.Practices.Composite.Modularity命名空间,在下文中一共展示了ModuleInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanRetrieveWithCorrectRef
public void CanRetrieveWithCorrectRef()
{
var retriever = new FileModuleTypeLoader();
var moduleInfo = new ModuleInfo() { Ref = "file://somefile" };
Assert.IsTrue(retriever.CanLoadModuleType(moduleInfo));
}
示例2: CannotRetrieveWithIncorrectRef
public void CannotRetrieveWithIncorrectRef()
{
var retriever = new FileModuleTypeLoader();
var moduleInfo = new ModuleInfo() { Ref = "NotForLocalRetrieval" };
Assert.IsFalse(retriever.CanLoadModuleType(moduleInfo));
}
示例3: ShouldLoadDownloadedAssemblies
public void ShouldLoadDownloadedAssemblies()
{
// NOTE: This test method uses a resource that is built in a pre-build event when building the project. The resource is a
// dynamically generated XAP file that is built with the Mocks/Modules/createXap.bat batch file.
// If this test is failing unexpectedly, it may be that the batch file is not working correctly in the current environment.
var mockFileDownloader = new MockFileDownloader();
const string moduleTypeName = "Microsoft.Practices.Composite.Tests.Mocks.Modules.RemoteModule, RemoteModuleA, Version=0.0.0.0";
var remoteModuleUri = "http://MyModule.xap";
var moduleInfo = new ModuleInfo() { Ref = remoteModuleUri };
XapModuleTypeLoader typeLoader = new TestableXapModuleTypeLoader(mockFileDownloader);
ManualResetEvent callbackEvent = new ManualResetEvent(false);
typeLoader.BeginLoadModuleType(
moduleInfo,
delegate
{
callbackEvent.Set();
});
Assert.IsNull(Type.GetType(moduleTypeName));
Stream xapStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Microsoft.Practices.Composite.Tests.Mocks.Modules.RemoteModules.xap");
mockFileDownloader.InvokeOpenReadCompleted(new DownloadCompletedEventArgs(xapStream, null, false, mockFileDownloader.DownloadAsyncArgumentUserToken));
Assert.IsTrue(callbackEvent.WaitOne(500));
Assert.IsNotNull(Type.GetType(moduleTypeName));
}
示例4: AddModule
/// <summary>
/// Registers a module with the <see cref="StaticModuleEnumerator" />.
/// </summary>
/// <param name="moduleType">The module type. This class should implement <see cref="IModule"/>.</param>
/// <param name="dependsOn">The names of the modules that this module depends on, if any.</param>
/// <returns>The same instance of <see cref="StaticModuleEnumerator"/>.</returns>
/// <remarks>The module name will be the Name of the type specified in <paramref name="moduleType"/>.</remarks>
public StaticModuleEnumerator AddModule(Type moduleType, params string[] dependsOn)
{
ModuleInfo moduleInfo = new ModuleInfo(moduleType.Assembly.FullName
, moduleType.FullName
, moduleType.Name
, dependsOn);
_modules.Add(moduleInfo);
return this;
}
示例5: CanCreateCatalogFromList
public void CanCreateCatalogFromList()
{
var moduleInfo = new ModuleInfo("MockModule", "type");
List<ModuleInfo> moduleInfos = new List<ModuleInfo> { moduleInfo };
var moduleCatalog = new ModuleCatalog(moduleInfos);
Assert.AreEqual(1, moduleCatalog.Modules.Count());
Assert.AreEqual(moduleInfo, moduleCatalog.Modules.ElementAt(0));
}
示例6: ShouldForwardValuesToModuleInfo
public void ShouldForwardValuesToModuleInfo()
{
ModuleInfoGroup group = new ModuleInfoGroup();
group.Ref = "MyCustomGroupRef";
ModuleInfo moduleInfo = new ModuleInfo();
Assert.IsNull(moduleInfo.Ref);
group.Add(moduleInfo);
Assert.AreEqual(group.Ref, moduleInfo.Ref);
}
示例7: BeginLoadModuleType
public void BeginLoadModuleType(ModuleInfo moduleInfo, ModuleTypeLoadedCallback callback)
{
Thread retrieverThread = new Thread(() =>
{
Thread.Sleep(SleepTimeOut);
callback(moduleInfo, CallbackArgumentError);
callbackEvent.Set();
});
retrieverThread.Start();
}
示例8: InitializationExceptionsAreWrapped
public void InitializationExceptionsAreWrapped()
{
Assembly asm = CompilerHelper.CompileFileAndLoadAssembly("Microsoft.Practices.Composite.Tests.Mocks.Modules.MockModuleThrowingException.cs",
@".\MocksModulesThwrowing\MockModuleThrowingException.dll");
ModuleLoader loader = new ModuleLoader(new MockContainerAdapter(), new MockLogger());
ModuleInfo info = new ModuleInfo(asm.CodeBase.Replace(@"file:///", ""),
"Microsoft.Practices.Composite.Tests.Mocks.Modules.MockModuleThrowingException", "MockModuleThrowingException");
loader.Initialize(new[] { info });
}
示例9: ShouldCallDownloadAsync
public void ShouldCallDownloadAsync()
{
var mockFileDownloader = new MockFileDownloader();
var remoteModuleUri = "http://MyModule.xap";
var moduleInfo = new ModuleInfo() { Ref = remoteModuleUri };
XapModuleTypeLoader typeLoader = new TestableXapModuleTypeLoader(mockFileDownloader);
typeLoader.BeginLoadModuleType(moduleInfo, delegate { });
Assert.IsTrue(mockFileDownloader.DownloadAsyncCalled);
Assert.AreEqual(remoteModuleUri, mockFileDownloader.downloadAsyncArgumentUri.OriginalString);
}
示例10: BeginLoadModuleType
public void BeginLoadModuleType(ModuleInfo moduleInfo, ModuleTypeLoadedCallback callback)
{
Exception error = null;
try
{
this.assemblyResolver.LoadAssemblyFrom(moduleInfo.Ref);
}
catch (Exception ex)
{
error = ex;
}
callback(moduleInfo, error);
}
示例11: GetModuleCatalog
protected override IModuleCatalog GetModuleCatalog()
{
string query = App.Current.Host.Source.Query;
var level1 = new ModuleInfo(ModuleNames.level1, string.Format("{0}.Level1Module, {0}, Version=1.0.0.0", ModuleNames.level1)) { InitializationMode = InitializationMode.OnDemand, Ref = ModuleNames.level1 + ".xap" };
var level2 = new ModuleInfo(ModuleNames.level2, string.Format("{0}.Level2Module, {0}, Version=1.0.0.0",ModuleNames.level2)) { InitializationMode = InitializationMode.OnDemand, Ref = ModuleNames.level2 + ".xap" };
var level3 = new ModuleInfo(ModuleNames.level3, string.Format("{0}.Level3Module, {0}, Version=1.0.0.0", ModuleNames.level3)) { InitializationMode = InitializationMode.OnDemand, Ref = ModuleNames.level3 + ".xap" };
var level4 = new ModuleInfo(ModuleNames.level4, string.Format("{0}.Level4Module, {0}, Version=1.0.0.0", ModuleNames.level4)) { InitializationMode = InitializationMode.OnDemand, Ref = ModuleNames.level4 + ".xap" };
ModuleCatalog cat = new ModuleCatalog();
cat.AddModule(level1);
cat.AddModule(level2);
cat.AddModule(level3);
cat.AddModule(level4);
return cat;
}
示例12: AddModule
/// <summary>
/// Adds a new module that is statically referenced to the specified module info group.
/// </summary>
/// <param name="moduleInfoGroup">The group where to add the module info in.</param>
/// <param name="moduleName">The name for the module.</param>
/// <param name="moduleType">The type for the module. This type should be a descendant of <see cref="IModule"/>.</param>
/// <param name="dependsOn">The names for the modules that this module depends on.</param>
/// <returns>Returns the instance of the passed in module info group, to provide a fluid interface.</returns>
public static ModuleInfoGroup AddModule(
this ModuleInfoGroup moduleInfoGroup,
string moduleName,
Type moduleType,
params string[] dependsOn)
{
if (moduleType == null)
{
throw new ArgumentNullException("moduleType");
}
ModuleInfo moduleInfo = new ModuleInfo(moduleName, moduleType.AssemblyQualifiedName);
moduleInfo.DependsOn.AddRange(dependsOn);
moduleInfoGroup.Add(moduleInfo);
return moduleInfoGroup;
}
示例13: Initialize
public void Initialize(ModuleInfo moduleInfo)
{
IModule moduleInstance = null;
try
{
moduleInstance = this.CreateModule(moduleInfo.ModuleType);
moduleInstance.Initialize();
}
catch (Exception ex)
{
this.HandleModuleInitializationError(
moduleInfo,
moduleInstance != null ? moduleInstance.GetType().Assembly.FullName : null,
ex);
}
}
示例14: Initialize
public void Initialize(ModuleInfo[] moduleInfos)
{
List<ModuleInfo> modules = GetModulesLoadOrder(moduleInfos);
IEnumerable<ModuleInfo> newModules = LoadAssembliesAndTypes(modules);
foreach (ModuleInfo moduleInfo in newModules)
{
Type type = initializedModules[moduleInfo.ModuleType];
try
{
IModule module = CreateModule(type);
module.Initialize();
}
catch (Exception e)
{
HandleModuleLoadError(moduleInfo, type.Assembly.FullName, e);
}
}
}
示例15: ShouldReturnErrorIfDownloadFails
public void ShouldReturnErrorIfDownloadFails()
{
var mockFileDownloader = new MockFileDownloader();
var remoteModuleUri = "http://MyModule.xap";
var moduleInfo = new ModuleInfo() { Ref = remoteModuleUri };
XapModuleTypeLoader typeLoader = new TestableXapModuleTypeLoader(mockFileDownloader);
ManualResetEvent callbackEvent = new ManualResetEvent(false);
Exception error = null;
typeLoader.BeginLoadModuleType(
moduleInfo,
delegate(ModuleInfo callbackModuleInfo, Exception moduleError)
{
error = moduleError;
callbackEvent.Set();
});
mockFileDownloader.InvokeOpenReadCompleted(new DownloadCompletedEventArgs(null, new InvalidOperationException("Mock Ex"), false, mockFileDownloader.DownloadAsyncArgumentUserToken));
Assert.IsTrue(callbackEvent.WaitOne(500));
Assert.IsNotNull(error);
Assert.IsInstanceOfType(error, typeof(InvalidOperationException));
}