本文整理汇总了C#中Microsoft.Practices.Composite.Modularity.ModuleInfo类的典型用法代码示例。如果您正苦于以下问题:C# ModuleInfo类的具体用法?C# ModuleInfo怎么用?C# ModuleInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleInfo类属于Microsoft.Practices.Composite.Modularity命名空间,在下文中一共展示了ModuleInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanRetrieveWithCorrectRef
public void CanRetrieveWithCorrectRef()
{
var retriever = new FileModuleTypeLoader();
var moduleInfo = new ModuleInfo() { Ref = "file://somefile" };
Assert.IsTrue(retriever.CanLoadModuleType(moduleInfo));
}
开发者ID:eslahi,项目名称:prism,代码行数:7,代码来源:FileModuleRetrieverFixture.Desktop.cs
示例2: CannotRetrieveWithIncorrectRef
public void CannotRetrieveWithIncorrectRef()
{
var retriever = new FileModuleTypeLoader();
var moduleInfo = new ModuleInfo() { Ref = "NotForLocalRetrieval" };
Assert.IsFalse(retriever.CanLoadModuleType(moduleInfo));
}
开发者ID:eslahi,项目名称:prism,代码行数:7,代码来源:FileModuleRetrieverFixture.Desktop.cs
示例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));
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:27,代码来源:XapModuleTypeLoaderFixture.cs
示例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;
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:16,代码来源:StaticModuleEnumerator.cs
示例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));
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:10,代码来源:ModuleCatalogFixture.cs
示例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);
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:11,代码来源:ModuleInfoGroupFixture.cs
示例7: BeginLoadModuleType
public void BeginLoadModuleType(ModuleInfo moduleInfo, ModuleTypeLoadedCallback callback)
{
Thread retrieverThread = new Thread(() =>
{
Thread.Sleep(SleepTimeOut);
callback(moduleInfo, CallbackArgumentError);
callbackEvent.Set();
});
retrieverThread.Start();
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:11,代码来源:MockAsyncModuleTypeLoader.cs
示例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 });
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:12,代码来源:ModuleLoaderFixture.cs
示例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);
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:12,代码来源:XapModuleTypeLoaderFixture.cs
示例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);
}
开发者ID:eslahi,项目名称:prism,代码行数:14,代码来源:FileModuleTypeLoader.Desktop.cs
示例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;
}
开发者ID:andyb,项目名称:Silverlight-Modules,代码行数:15,代码来源:Bootstrapper.cs
示例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;
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:24,代码来源:ModuleInfoGroupExtensions.cs
示例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);
}
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:16,代码来源:ModuleInitializer.cs
示例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);
}
}
}
开发者ID:eslahi,项目名称:prism,代码行数:21,代码来源:ModuleLoader.cs
示例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));
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:21,代码来源:XapModuleTypeLoaderFixture.cs
示例16: HandleModuleInitializationError
/// <summary>
/// Handles any exception ocurred in the module Initialization process,
/// logs the error using the <seealso cref="ILoggerFacade"/> and throws a <seealso cref="ModuleInitializeException"/>.
/// This method can be overriden to provide a different behavior.
/// </summary>
/// <param name="moduleInfo">The module metadata where the error happenened.</param>
/// <param name="assemblyName">The assembly name.</param>
/// <param name="exception">The exception thrown that is the cause of the current error.</param>
/// <exception cref="ModuleInitializeException"></exception>
public virtual void HandleModuleInitializationError(ModuleInfo moduleInfo, string assemblyName, Exception exception)
{
Exception moduleException;
if (exception is ModuleInitializeException)
{
moduleException = exception;
}
else
{
if (!string.IsNullOrEmpty(assemblyName))
{
moduleException = new ModuleInitializeException(moduleInfo.ModuleName, assemblyName, exception.Message, exception);
}
else
{
moduleException = new ModuleInitializeException(moduleInfo.ModuleName, exception.Message, exception);
}
}
this.loggerFacade.Log(moduleException.ToString(), Category.Exception, Priority.High);
throw moduleException;
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:33,代码来源:ModuleInitializer.cs
示例17: CreateModuleInfo
private static ModuleInfo CreateModuleInfo(Type type, InitializationMode initializationMode, params string[] dependsOn)
{
ModuleInfo moduleInfo = new ModuleInfo(type.Name, type.AssemblyQualifiedName);
moduleInfo.InitializationMode = initializationMode;
moduleInfo.DependsOn.AddRange(dependsOn);
return moduleInfo;
}
开发者ID:eslahi,项目名称:prism,代码行数:7,代码来源:ModuleManagerFixture.cs
示例18: ShouldResolveModuleAndInitializeSingleModule
public void ShouldResolveModuleAndInitializeSingleModule()
{
IContainerFacade containerFacade = new MockContainerAdapter();
var service = new ModuleLoader(containerFacade, new MockLogger());
FirstTestModule.wasInitializedOnce = false;
var info = new ModuleInfo(typeof(FirstTestModule).Assembly.Location, typeof(FirstTestModule).FullName, "FirstTestModule");
service.Initialize(new[] { info });
Assert.IsTrue(FirstTestModule.wasInitializedOnce);
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:9,代码来源:ModuleLoaderFixture.cs
示例19: FailWhenDependingOnMissingModule
public void FailWhenDependingOnMissingModule()
{
string assembly = CompilerHelper.GenerateDynamicModule("ModuleK", null, "ModuleL");
ModuleInfo module = new ModuleInfo(assembly, "ModuleK.TestsModules.ModuleKClass", "ModuleK", "ModuleL");
ModuleLoader loader = new ModuleLoader(new MockContainerAdapter(), new MockLogger());
loader.Initialize(new[] { module });
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:8,代码来源:ModuleLoaderFixture.cs
示例20: HandleModuleLoadError
public override void HandleModuleLoadError(ModuleInfo moduleInfo, string assemblyName, Exception exception)
{
HandleModuleLoadErrorCalled = true;
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:4,代码来源:ModuleLoaderFixture.cs
注:本文中的Microsoft.Practices.Composite.Modularity.ModuleInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论