public static string UriToLocalPath(Uri uri) { if (!uri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase)) { throw new ArgumentException("Must start with \"file:///\"", "uri"); } Util.GetBPSOrException(); var ret = navigator_invoke_uri_to_local_path(uri.ToString()); if (ret == IntPtr.Zero) { return(null); } using (var str = new BPSString(ret)) { return(str.Value); } }
public static Uri LocalPathToUri(string localPath) { if (!localPath.StartsWith("/")) { throw new ArgumentException("Must start with \"/\"", "localPath"); } Util.GetBPSOrException(); var ret = navigator_invoke_local_path_to_uri(localPath); if (ret == IntPtr.Zero) { return(null); } using (var str = new BPSString(ret)) { return(new Uri(str.Value)); } }
public static bool ExtendStartupTimeout(TimeSpan extension, bool throwExceptionOnFailure = false) { Util.GetBPSOrException(); if (extension.TotalMilliseconds < 0) { throw new ArgumentOutOfRangeException("extension", extension, "Extension cannot be negative."); } if (extension.TotalMilliseconds == 0) { return true; } var err = IntPtr.Zero; var success = navigator_extend_timeout((int)extension.TotalMilliseconds, ref err) == BPS.BPS_SUCCESS; if (!success) { if (throwExceptionOnFailure) { string errorStr; using (var error = new BPSString(err)) { errorStr = error.Value; } throw new InvalidOperationException(errorStr); } else { BPS.bps_free(err); } } return success; }
public static bool AddUri(string iconPath, string iconLabel, string category, Uri applicationUrl, bool throwExceptionOnFailure = false) { Util.GetBPSOrException(); var err = IntPtr.Zero; var success = navigator_add_uri(iconPath, iconLabel, category, applicationUrl.ToString(), ref err) == BPS.BPS_SUCCESS; if (!success) { if (throwExceptionOnFailure) { string errorStr; using (var error = new BPSString(err)) { errorStr = error.Value; } throw new InvalidOperationException(errorStr); } else { BPS.bps_free(err); } } return success; }
public static string SetOrientation(OrientationMode mode) { if (!mode.IsValidValue()) { throw new ArgumentException("not a valid orientation mode.", "mode"); } var id = IntPtr.Zero; var success = navigator_set_orientation_mode(mode, ref id) == BPS.BPS_SUCCESS; if (success) { using (var str = new BPSString(id)) { return str.Value; } } else { BPS.bps_free(id); } return null; }
public static string UriToLocalPath(Uri uri) { if (!uri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase)) { throw new ArgumentException("Must start with \"file:///\"", "uri"); } Util.GetBPSOrException(); var ret = navigator_invoke_uri_to_local_path(uri.ToString()); if (ret == IntPtr.Zero) { return null; } using (var str = new BPSString(ret)) { return str.Value; } }
public static Uri LocalPathToUri(string localPath) { if (!localPath.StartsWith("/")) { throw new ArgumentException("Must start with \"/\"", "localPath"); } Util.GetBPSOrException(); var ret = navigator_invoke_local_path_to_uri(localPath); if (ret == IntPtr.Zero) { return null; } using (var str = new BPSString(ret)) { return new Uri(str.Value); } }