本文整理汇总了C#中IUser.RaiseYesNoDialog方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.RaiseYesNoDialog方法的具体用法?C# IUser.RaiseYesNoDialog怎么用?C# IUser.RaiseYesNoDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUser
的用法示例。
在下文中一共展示了IUser.RaiseYesNoDialog方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterURLHandler
public static void RegisterURLHandler(Configuration config, IUser user)
{
try
{
if (Platform.IsUnix)
{
RegisterURLHandler_Linux();
}
else if(Platform.IsWindows)
{
try
{
RegisterURLHandler_Win32();
}
catch (UnauthorizedAccessException)
{
if (config.URLHandlerNoNag)
{
return;
}
if (user.RaiseYesNoDialog(@"CKAN requires permission to add a handler for ckan:// URLs.
Do you want to allow CKAN to do this? If you click no you won't see this message again."))
{
// we need elevation to write to the registry
ProcessStartInfo startInfo = new ProcessStartInfo(System.Reflection.Assembly.GetEntryAssembly().Location);
startInfo.Verb = "runas"; // trigger a UAC prompt (if UAC is enabled)
startInfo.Arguments = "gui " + UrlRegistrationArgument;
Process.Start(startInfo);
}
else
{
config.URLHandlerNoNag = true;
config.Save();
}
throw;
}
} else if (Platform.IsMac) {
//TODO
}
}
catch (Exception ex)
{
log.ErrorFormat("There was an error while registering the URL handler for ckan:// - {0}", ex.Message);
log.ErrorFormat("{0}", ex.StackTrace);
}
}
示例2: UpdateRegistry
//.........这里部分代码省略.........
log.InfoFormat("UpdateRegistry, module {0}, version {1} not in repository ({2})", identifier, installedVersion, repo);
continue;
}
if (!registry.available_modules[identifier].module_version.ContainsKey(installedVersion))
{
continue;
}
// if the mod is installed and the metadata is different we have to reinstall it
var metadata = registry.available_modules[identifier].module_version[installedVersion];
if (!old_available.ContainsKey(identifier) ||
!old_available[identifier].module_version.ContainsKey(installedVersion))
{
continue;
}
var oldMetadata = old_available[identifier].module_version[installedVersion];
bool same = true;
if ((metadata.install == null) != (oldMetadata.install == null) ||
(metadata.install != null && metadata.install.Length != oldMetadata.install.Length))
{
same = false;
}
else
{
if(metadata.install != null)
for (int i = 0; i < metadata.install.Length; i++)
{
if (metadata.install[i].file != oldMetadata.install[i].file)
{
same = false;
break;
}
if (metadata.install[i].install_to != oldMetadata.install[i].install_to)
{
same = false;
break;
}
if ((metadata.install[i].filter == null) != (oldMetadata.install[i].filter == null))
{
same = false;
break;
}
if(metadata.install[i].filter != null)
if (!metadata.install[i].filter.SequenceEqual(oldMetadata.install[i].filter))
{
same = false;
break;
}
if ((metadata.install[i].filter_regexp == null) != (oldMetadata.install[i].filter_regexp == null))
{
same = false;
break;
}
if(metadata.install[i].filter_regexp != null)
if (!metadata.install[i].filter_regexp.SequenceEqual(oldMetadata.install[i].filter_regexp))
{
same = false;
break;
}
}
}
if (!same)
{
metadataChanges.Add(registry.available_modules[identifier].module_version[installedVersion]);
}
}
}
if (metadataChanges.Any())
{
string mods = "";
for (int i = 0; i < metadataChanges.Count; i++)
{
mods += metadataChanges[i].identifier + " "
+ metadataChanges[i].version.ToString() + ((i < metadataChanges.Count-1) ? ", " : "");
}
if(user.RaiseYesNoDialog(String.Format(
@"The following mods have had their metadata changed since last update - {0}.
It is advisable that you reinstall them in order to preserve consistency with the repository. Do you wish to reinstall now?", mods)))
{
ModuleInstaller installer = ModuleInstaller.GetInstance(ksp, new NullUser());
installer.Upgrade(metadataChanges, new NetAsyncDownloader(new NullUser()));
}
}
// Remove our downloaded meta-data now we've processed it.
// Seems weird to do this as part of a transaction, but Net.Download uses them, so let's be consistent.
file_transaction.Delete(repo_file);
}
示例3: UpdateRegistry
//.........这里部分代码省略.........
if (!metadata.install[i].filter.SequenceEqual(oldMetadata.install[i].filter))
{
same = false;
break;
}
if ((metadata.install[i].filter_regexp == null) != (oldMetadata.install[i].filter_regexp == null))
{
same = false;
break;
}
if(metadata.install[i].filter_regexp != null)
if (!metadata.install[i].filter_regexp.SequenceEqual(oldMetadata.install[i].filter_regexp))
{
same = false;
break;
}
}
}
if (!RelationshipsAreEquivalent(metadata.conflicts, oldMetadata.conflicts))
same = false;
if (!RelationshipsAreEquivalent(metadata.depends, oldMetadata.depends))
same = false;
if (!RelationshipsAreEquivalent(metadata.recommends, oldMetadata.recommends))
same = false;
if (metadata.provides != oldMetadata.provides)
{
if (metadata.provides == null || oldMetadata.provides == null)
same = false;
else if (!metadata.provides.OrderBy(i => i).SequenceEqual(oldMetadata.provides.OrderBy(i => i)))
same = false;
}
if (!same)
{
metadataChanges.Add(registry.available_modules[identifier].module_version[installedVersion]);
}
}
if (metadataChanges.Any())
{
var sb = new StringBuilder();
for (var i = 0; i < metadataChanges.Count; i++)
{
var module = metadataChanges[i];
sb.AppendLine(string.Format("- {0} {1}", module.identifier, module.version));
}
if(user.RaiseYesNoDialog(string.Format(@"The following mods have had their metadata changed since last update:
{0}
You should reinstall them in order to preserve consistency with the repository.
Do you wish to reinstall now?", sb)))
{
ModuleInstaller installer = ModuleInstaller.GetInstance(ksp, new NullUser());
// New upstream metadata may break the consistency of already installed modules
// e.g. if user installs modules A and B and then later up A is made to conflict with B
// This is perfectly normal and shouldn't produce an error, therefore we skip enforcing
// consistency. However, we will show the user any inconsistencies later on.
// Use the identifiers so we use the overload that actually resolves relationships
// Do each changed module one at a time so a failure of one doesn't cause all the others to fail
foreach (var changedIdentifier in metadataChanges.Select(i => i.identifier))
{
try
{
installer.Upgrade(
new[] { changedIdentifier },
new NetAsyncModulesDownloader(new NullUser()),
enforceConsistency: false
);
}
// Thrown when a dependency couldn't be satisfied
catch(ModuleNotFoundKraken)
{
log.WarnFormat("Skipping installation of {0} due to relationship error.", changedIdentifier);
user.RaiseMessage("Skipping installation of {0} due to relationship error.", changedIdentifier);
}
// Thrown when a conflicts relationship is violated
catch (InconsistentKraken)
{
log.WarnFormat("Skipping installation of {0} due to relationship error.", changedIdentifier);
user.RaiseMessage("Skipping installation of {0} due to relationship error.", changedIdentifier);
}
}
}
}
// Remove our downloaded meta-data now we've processed it.
// Seems weird to do this as part of a transaction, but Net.Download uses them, so let's be consistent.
file_transaction.Delete(repo_file);
}