本文整理汇总了C#中Microsoft.Practices.Prism.Modularity.ModuleInfo.GetPackageName方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleInfo.GetPackageName方法的具体用法?C# ModuleInfo.GetPackageName怎么用?C# ModuleInfo.GetPackageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.Prism.Modularity.ModuleInfo
的用法示例。
在下文中一共展示了ModuleInfo.GetPackageName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadModuleType
/// <summary>
/// Load the module type.
/// </summary>
/// <param name="moduleInfo">The module Info.</param>
/// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
public void LoadModuleType(ModuleInfo moduleInfo)
{
// ReSharper disable once ImplicitlyCapturedClosure
Argument.IsNotNull(() => moduleInfo);
Dispatcher currentDispatcher = DispatcherHelper.CurrentDispatcher;
Log.Debug("Loading module type '{0}' from package '{1}'", moduleInfo.ModuleType, moduleInfo.Ref);
new Thread(() =>
{
InstallPackageRequest installPackageRequest;
var packageName = moduleInfo.GetPackageName();
if (packageName != null && this.TryCreateInstallPackageRequest(moduleInfo, out installPackageRequest))
{
currentDispatcher.BeginInvoke(() => OnModuleDownloadProgressChanged(new ModuleDownloadProgressChangedEventArgs(moduleInfo, 0, 1)));
bool installed = false;
try
{
installPackageRequest.Execute();
installed = true;
}
catch (Exception e)
{
currentDispatcher.BeginInvoke(() => OnLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, e)));
}
if (installed)
{
var fileModuleTypeLoader = new FileModuleTypeLoader();
var fileModuleInfo = new ModuleInfo(moduleInfo.ModuleName, moduleInfo.ModuleType)
{
Ref = installPackageRequest.AssemblyFileRef,
InitializationMode = moduleInfo.InitializationMode,
DependsOn = moduleInfo.DependsOn
};
fileModuleTypeLoader.ModuleDownloadProgressChanged += (sender, args) =>
{
moduleInfo.State = args.ModuleInfo.State;
currentDispatcher.BeginInvoke(() => OnModuleDownloadProgressChanged(new ModuleDownloadProgressChangedEventArgs(moduleInfo, args.BytesReceived, args.TotalBytesToReceive)));
};
fileModuleTypeLoader.LoadModuleCompleted += (sender, args) =>
{
moduleInfo.State = args.ModuleInfo.State;
currentDispatcher.BeginInvoke(() => OnLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, args.Error)));
};
fileModuleTypeLoader.LoadModuleType(fileModuleInfo);
}
}
else
{
currentDispatcher.BeginInvoke(() => OnLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, new ModuleNotFoundException(moduleInfo.ModuleName, string.Format(CultureInfo.InvariantCulture, "The package '{0}' for module '{1}' was not found", moduleInfo.Ref, moduleInfo.ModuleName)))));
}
}).Start();
}
示例2: Returns_The_PackageName_With_Version_As_Null_If_The_Version_Number_Is_Not_Specified_In_The_Ref_ModuleInfo_Property
public void Returns_The_PackageName_With_Version_As_Null_If_The_Version_Number_Is_Not_Specified_In_The_Ref_ModuleInfo_Property()
{
var moduleInfo = new ModuleInfo { Ref = PackageId };
var packageName = moduleInfo.GetPackageName();
Assert.IsNull(packageName.Version);
}
示例3: CanLoadModuleType
/// <summary>
/// Can load module type.
/// </summary>
/// <param name="moduleInfo">The module Info.</param>
/// <returns>The <see cref="bool" />.</returns>
/// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
/// <exception cref="System.InvalidOperationException">The <see cref="ModuleInfo.ModuleType" /> property of <paramref name="moduleInfo" /> parameter doesn't speciefied usign qualified name pattern.</exception>
public bool CanLoadModuleType(ModuleInfo moduleInfo)
{
Argument.IsNotNull(() => moduleInfo);
return moduleInfo.GetPackageName() != null;
}
示例4: Returns_The_PackageName_With_The_Version_Specified_On_The_Ref_ModuleInfo_Property
public void Returns_The_PackageName_With_The_Version_Specified_On_The_Ref_ModuleInfo_Property()
{
var moduleInfo = new ModuleInfo { Ref = string.Format("{0}, {1}", PackageId, Version) };
var packageName = moduleInfo.GetPackageName();
Assert.AreEqual(packageName.Version.ToString(), Version);
}
示例5: Returns_Null_If_The_Ref_Value_Is_Empty
public void Returns_Null_If_The_Ref_Value_Is_Empty()
{
var moduleInfo = new ModuleInfo { Ref = string.Empty };
var packageName = moduleInfo.GetPackageName();
Assert.IsNull(packageName);
}
示例6: Returns_Null_If_The_Version_Number_Is_Specified_Incorrectly
public void Returns_Null_If_The_Version_Number_Is_Specified_Incorrectly()
{
var moduleInfo = new ModuleInfo { Ref = "&#$%2435.234.5, asdfhalksdfhas" };
var packageName = moduleInfo.GetPackageName();
Assert.IsNull(packageName);
}
示例7: Returns_The_PackageName_With_The_Id_Specified_On_The_Ref_ModuleInfo_Property
public void Returns_The_PackageName_With_The_Id_Specified_On_The_Ref_ModuleInfo_Property()
{
var moduleInfo = new ModuleInfo { Ref = PackageId };
var packageName = moduleInfo.GetPackageName();
Assert.AreEqual(packageName.Id, PackageId);
}
示例8: Returns_The_PackageName_If_A_Valid_Ref_Value_Is_Specified_On_ModuleInfo_Property
public void Returns_The_PackageName_If_A_Valid_Ref_Value_Is_Specified_On_ModuleInfo_Property()
{
var moduleInfo = new ModuleInfo { Ref = PackageId };
var packageName = moduleInfo.GetPackageName();
Assert.IsNotNull(packageName);
}