本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Session.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Set方法的具体用法?C# Session.Set怎么用?C# Session.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Deployment.WindowsInstaller.Session
的用法示例。
在下文中一共展示了Session.Set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckValidPort
public static ActionResult CheckValidPort(Session session)
{
try
{
Log(session, "Start custom action CheckValidPort");
if (!session.CustomActionData.ContainsKey("PORT"))
{
Log(session, "CheckValidPort custom action requires a port variable be passed to it in the from PORT=xxxx");
return ActionResult.Failure;
}
var port = session.CustomActionData["PORT"];
UInt16 portNumber;
if (UInt16.TryParse(port, out portNumber))
{
// Port numbder 49152 and above should not be used http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
if (portNumber < 49152)
{
session.Set("VALID_PORT", "TRUE");
return ActionResult.Success;
}
}
session.Set("VALID_PORT", "FALSE");
return ActionResult.Success;
}
finally
{
Log(session, "End custom action CheckValidPort");
}
}
示例2: CheckServiceControlUrl
public static ActionResult CheckServiceControlUrl(Session session)
{
Log(session, "Begin custom action CheckServiceControlUrl");
var url = session.Get("INST_URI");
session.Set("VALID_CONTROL_URL", UrlIsValid(url,session) ? "TRUE" : "FALSE");
Log(session, "End custom action CheckServiceControlUrl");
return ActionResult.Success;
}
示例3: CheckPulsePort
public static ActionResult CheckPulsePort(Session session)
{
try
{
Log(session, "Start custom action CheckPulsePort");
var port = session.Get("INST_PORT_PULSE");
UInt16 portNumber;
if (UInt16.TryParse(port, out portNumber))
{
// Port number 49152 and above should no be used http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
if (portNumber < 49152)
{
session.Set("VALID_PORT", "TRUE");
return ActionResult.Success;
}
}
session.Set("VALID_PORT", "FALSE");
return ActionResult.Success;
}
finally
{
Log(session, "End custom action CheckPulsePort");
}
}
示例4: ContactServiceControl
public static ActionResult ContactServiceControl(Session session)
{
Log(session, "Begin custom action ContactServiceControl");
// getting URL from property
var url = session.Get("INST_URI");
var connectionSuccessful = false;
try
{
if (url == null)
{
return ActionResult.Success;
}
var request = WebRequest.Create(url);
request.Timeout = 2000;
using (var response = request.GetResponse() as HttpWebResponse)
{
if (response == null)
{
throw new Exception("No response");
}
if (response.StatusCode != HttpStatusCode.OK)
{
throw new Exception(response.StatusDescription);
}
var version = response.Headers["X-Particular-Version"];
if (!string.IsNullOrEmpty(version))
{
session.Set("REPORTED_VERSION", version.Split(' ').First());
}
}
connectionSuccessful = true;
}
catch (Exception ex)
{
Log(session, ex.ToString());
}
session.Set("CONTACT_SERVICECONTROL", connectionSuccessful ? "TRUE" : "FALSE");
Log(session, "End custom action ContactServiceControl");
return ActionResult.Success;
}
示例5: ReadServiceControlUrlFromConfigJS
public static ActionResult ReadServiceControlUrlFromConfigJS(Session session)
{
try
{
Log(session, "Start custom action ReadServiceControlUrlFromConfigJS");
var targetPath = session.Get("APPDIR");
var configJsPath = Path.Combine(targetPath, @"app\config.js");
var uri = @"http://localhost:33333/api/";
if (File.Exists(configJsPath))
{
var pattern = new Regex(@"service_control_url:\s*'(?<sc_uri>.*)'", RegexOptions.IgnoreCase);
var matches = pattern.Match(File.ReadAllText(configJsPath));
if (matches.Success)
{
uri = matches.Groups["sc_uri"].Value;
Log(session, string.Format(@"Extracted {0} from existing config.js", uri));
}
else
{
Log(session, "No URI found - using default");
}
}
else
{
Log(session, string.Format("File not found {0}", configJsPath));
}
session.Set("INST_URI", uri);
return ActionResult.Success;
}
finally
{
Log(session, "End custom action ReadServiceControlUrlFromConfigJS");
}
}
示例6: ReadForwardAuditMessagesFromConfig
public static ActionResult ReadForwardAuditMessagesFromConfig(Session session)
{
try
{
if (session.CustomActionData.Keys.Count != 1)
{
Log(session, "ReadForwardAuditMessagesFromConfig custom action requires a single property name to be passed in the CustomActionData. The result will passed to that property");
return ActionResult.Failure;
}
var outputProperty = session.CustomActionData.Keys.First();
const string ServiceControlRegKey = @"SOFTWARE\ParticularSoftware\ServiceControl";
var targetPath = session.Get("APPDIR");
var configPath = Path.Combine(targetPath, @"ServiceControl.exe.config");
var entryValue = "null";
// Try to get value from existing config
if (File.Exists(configPath))
{
var configDoc = XDocument.Load(configPath);
var entry = configDoc.XPathSelectElement(@"/configuration/appSettings/add[@key='ServiceControl/ForwardAuditMessages']");
entryValue = (entry != null) ? entry.Attribute("value").Value : "null";
}
// Fallback to getting value from registry.
if (!String.IsNullOrWhiteSpace(entryValue))
{
var key = Registry.LocalMachine.OpenSubKey(ServiceControlRegKey, RegistryKeyPermissionCheck.Default);
if (key != null)
{
entryValue = (string) key.GetValue("ForwardAuditMessages", "null");
}
}
entryValue = entryValue.ToLower();
switch (entryValue)
{
case "true" :
case "false" :
session.Set(outputProperty, entryValue);
break;
default:
session.Set(outputProperty,"null");
break;
}
return ActionResult.Success;
}
catch (Exception ex)
{
Log(session, "ReadForwardAuditMessagesFromConfig failed - {0}", ex);
return ActionResult.Failure;
}
}