/// Registers the URI. public static void RegisterUri() { if (!UriParser.IsKnownScheme("rtsp")) { UriParser.Register(new HttpStyleUriParser(), "rtsp", 554); } }
/// <summary> /// Returns a Success HTML page or a simple success message, if the HTML page cannot be /// loaded, to be served back to the user. /// </summary> /// <returns></returns> private static string GetSuccessString() { var result = "Auth Successful. You may now close this page"; try { if (!UriParser.IsKnownScheme("pack")) { new System.Windows.Application(); } var html = Application.GetResourceStream(new Uri("pack://application:,,,/Bitbucket.Authentication;Component/Assets/auth.html", UriKind.Absolute)); if (html != null && html.Stream != null) { using (StreamReader reader = new StreamReader(html.Stream)) { result = reader.ReadToEnd(); } } } catch (Exception e) { Console.WriteLine(e); return(result); } return(result); }
public void Bug496783() { string s = "tcp://csve2.csse.unimelb.edu.au:9090/Aneka"; Uri uri = new Uri(s); // this is not parsed by a known UriParser Assert.IsFalse(UriParser.IsKnownScheme(uri.Scheme), "UriParser"); Uri uri2 = new Uri("tcp://csve2.csse.unimelb.edu.au:9090/"); Assert.IsTrue(uri2.IsBaseOf(uri), "IsBaseOf"); Assert.AreEqual(uri.AbsoluteUri, uri.GetComponents(UriComponents.AbsoluteUri, UriFormat.Unescaped), "AbsoluteUri"); Assert.AreEqual(uri.Fragment, uri.GetComponents(UriComponents.Fragment, UriFormat.Unescaped), "Fragment"); Assert.AreEqual(uri.Host, uri.GetComponents(UriComponents.Host, UriFormat.Unescaped), "Host"); Assert.AreEqual(uri.Authority, uri.GetComponents(UriComponents.HostAndPort, UriFormat.Unescaped), "HostAndPort"); Assert.AreEqual(uri.AbsoluteUri, uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.Unescaped), "HttpRequestUrl"); Assert.AreEqual(String.Empty, uri.GetComponents(UriComponents.KeepDelimiter, UriFormat.Unescaped), "KeepDelimiter"); Assert.AreEqual("Aneka", uri.GetComponents(UriComponents.Path, UriFormat.Unescaped), "Path"); Assert.AreEqual(uri.LocalPath, uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped), "PathAndQuery"); Assert.AreEqual(uri.Port.ToString(), uri.GetComponents(UriComponents.Port, UriFormat.Unescaped), "Port"); Assert.AreEqual(uri.Query, uri.GetComponents(UriComponents.Query, UriFormat.Unescaped), "Query"); Assert.AreEqual(uri.Scheme, uri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped), "Scheme"); Assert.AreEqual("tcp://csve2.csse.unimelb.edu.au:9090", uri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped), "SchemeAndServer"); Assert.AreEqual(uri.OriginalString, uri.GetComponents(UriComponents.SerializationInfoString, UriFormat.Unescaped), "SerializationInfoString"); Assert.AreEqual(uri.Authority, uri.GetComponents(UriComponents.StrongAuthority, UriFormat.Unescaped), "StrongAuthority"); Assert.AreEqual(uri.Port.ToString(), uri.GetComponents(UriComponents.StrongPort, UriFormat.Unescaped), "StrongPort"); Assert.AreEqual(uri.UserInfo, uri.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped), "UserInfo"); }
/// <summary> /// Necessary for unit tests. Accessing PackUriHelper triggers static initialization. /// Without it, creating resource URIs from unit tests would throw UriFormatExceptions. /// </summary> public static void TriggerPackUriSchemeInitialization() { if (!UriParser.IsKnownScheme("pack")) { var _ = System.IO.Packaging.PackUriHelper.UriSchemePack; } }
/// <summary> /// Registers resource handler and maps it to the specified protocol name. /// </summary> /// <remarks> /// <p> /// If the mapping already exists, the existing mapping will be /// silently overwritten with the new mapping. /// </p> /// </remarks> /// <param name="protocolName"> /// The protocol to add (or override). /// </param> /// <param name="handlerType"> /// The concrete implementation of the /// <see cref="Oragon.Spring.Core.IO.IResource"/> interface that will handle /// the specified protocol. /// </param> /// <exception cref="System.ArgumentNullException"> /// If the supplied <paramref name="protocolName"/> is /// <see langword="null"/> or contains only whitespace character(s); or /// if the supplied <paramref name="handlerType"/> is /// <see langword="null"/>. /// </exception> /// <exception cref="System.ArgumentException"> /// If the supplied <paramref name="handlerType"/> is not a /// <see cref="Type"/> that derives from the /// <see cref="Oragon.Spring.Core.IO.IResource"/> interface; or (having passed /// this first check), the supplied <paramref name="handlerType"/> /// does not expose a constructor that takes a single /// <see cref="System.String"/> parameter. /// </exception> public static void RegisterResourceHandler(string protocolName, Type handlerType) { #region Sanity Checks AssertUtils.ArgumentHasText(protocolName, "protocolName"); AssertUtils.ArgumentNotNull(handlerType, "handlerType"); if (!typeof(IResource).IsAssignableFrom(handlerType)) { throw new ArgumentException( string.Format("[{0}] does not implement [{1}] interface (it must).", handlerType.FullName, typeof(IResource).FullName)); } #endregion lock (syncRoot) { //SecurityCritical.ExecutePrivileged( new SecurityPermission(SecurityPermissionFlag.Infrastructure), delegate //{ // register generic uri parser for this scheme if (!UriParser.IsKnownScheme(protocolName)) { UriParser.Register(new TolerantUriParser(), protocolName, 0); } //}); IDynamicConstructor ctor = GetResourceConstructor(handlerType); resourceHandlers[protocolName] = ctor; } }
/// <summary> /// Dynamically load a control style. /// </summary> /// <param name="styleName"></param> /// <returns></returns> public static Style GetControlStyle(string styleName) { if (!UriParser.IsKnownScheme("pack")) { UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1); } ResourceDictionary dict = new ResourceDictionary(); Uri uri = new Uri("/UI/Resources/ControlStyles.xaml", UriKind.Relative); dict.Source = uri; Application.Current.Resources.MergedDictionaries.Add(dict); Style style; try { style = (Style)Application.Current.Resources[styleName]; } catch { throw new ResourceReferenceKeyNotFoundException("Can't find the Style " + styleName, styleName); } return(style); }
public Maybe <ResourceDictionary> GetDictionary(string path) { if (!UriParser.IsKnownScheme("pack")) { UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1); } if (!GetResourceNames().Any(s => s.Equals(path, StringComparison.InvariantCultureIgnoreCase))) { Debug.WriteLine("Unknown resource name " + path); return(Maybe <ResourceDictionary> .None); } try { var dict = new ResourceDictionary(); var uri = new Uri("/" + _assembly.GetName().Name + ";component/" + path.ToLowerInvariant(), UriKind.Relative); dict.Source = uri; return(dict.ToMaybe()); } catch (InvalidOperationException) { Debug.WriteLine(path + " could not be loaded as Resource"); return(Maybe <ResourceDictionary> .None); } }
private static void Initialize() { // // If start application isn't WPF, pack isn't registered by defaultTexFontParser // if (Application.ResourceAssembly == null) { Application.ResourceAssembly = Assembly.GetExecutingAssembly(); if (!UriParser.IsKnownScheme("pack")) { UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1); } } var formulaSettingsParser = new TexPredefinedFormulaSettingsParser(); symbols = formulaSettingsParser.GetSymbolMappings(); delimeters = formulaSettingsParser.GetDelimiterMappings(); textStyles = formulaSettingsParser.GetTextStyles(); var colorParser = new PredefinedColorParser(); colorParser.Parse(predefinedColors); var predefinedFormulasParser = new TexPredefinedFormulaParser(); predefinedFormulasParser.Parse(predefinedFormulas); }
private void ChangeSkin(string skinName) { if (!_skins.ContainsKey(skinName.ToLower())) { return; } if (skinName.ToLower() == _skin.ToLower()) { return; } _skin = skinName; if (!UriParser.IsKnownScheme("pack")) { UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1); } var skinUri = new Uri(_skins[skinName.ToLower()], UriKind.Relative); var skin = new ResourceDictionary { Source = skinUri }; Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.Clear(); Application.Current.Resources.MergedDictionaries.Add(skin); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("/PrismMaterialDesign.Resources;component/Resources.xaml", UriKind.RelativeOrAbsolute) }); }
static PackUriHelper() { if (!UriParser.IsKnownScheme(UriSchemePack)) { UriParser.Register(new PackUriParser(), UriSchemePack, -1); } }
public static void RegisterRtspUri() { if (UriParser.IsKnownScheme("rtsp") == false) { UriParser.Register(new HttpStyleUriParser(), "rtsp", 554); } }
protected PropertyEditorBase(string typeName, string propertyDataTemplateName, string?unconfiguredDataTemplateName, string?configuredDataTemplateName) { TypeName = typeName; if (resources == null) { if (!UriParser.IsKnownScheme("pack")) { UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", defaultPort: -1); } resources = new ResourceDictionary { Source = new Uri("pack://application:,,,/Resources/PropertyTemplates.xaml", UriKind.RelativeOrAbsolute) }; } var propertyDataTemplate = (DataTemplate?)resources[propertyDataTemplateName]; Assumes.NotNull(propertyDataTemplate); PropertyDataTemplate = propertyDataTemplate; if (unconfiguredDataTemplateName != null) { UnconfiguredDataTemplate = (DataTemplate?)resources[unconfiguredDataTemplateName]; } if (configuredDataTemplateName != null) { ConfiguredDataTemplate = (DataTemplate?)resources[configuredDataTemplateName]; } }
public void IsKnownScheme_WellKnown() { // from Uri.UriScheme* fields Assert.IsTrue(UriParser.IsKnownScheme("file"), "file"); Assert.IsTrue(UriParser.IsKnownScheme("ftp"), "ftp"); Assert.IsTrue(UriParser.IsKnownScheme("gopher"), "gopher"); Assert.IsTrue(UriParser.IsKnownScheme("http"), "http"); Assert.IsTrue(UriParser.IsKnownScheme("https"), "https"); Assert.IsTrue(UriParser.IsKnownScheme("mailto"), "mailto"); Assert.IsTrue(UriParser.IsKnownScheme("net.pipe"), "net.pipe"); Assert.IsTrue(UriParser.IsKnownScheme("net.tcp"), "net.tcp"); Assert.IsTrue(UriParser.IsKnownScheme("news"), "news"); Assert.IsTrue(UriParser.IsKnownScheme("nntp"), "nntp"); // inferred from class library Assert.IsTrue(UriParser.IsKnownScheme("ldap"), "ldap"); Assert.IsFalse(UriParser.IsKnownScheme("ldaps"), "ldaps"); // well known for not existing Assert.IsFalse(UriParser.IsKnownScheme("unknown"), "unknown"); // variations - mixed and upper case Assert.IsTrue(UriParser.IsKnownScheme("FiLe"), "FiLe"); Assert.IsTrue(UriParser.IsKnownScheme("FTP"), "ftp"); // see 496783 Assert.IsFalse(UriParser.IsKnownScheme("tcp"), "tcp"); }
public static void PackUriIsRegistered() { if (!UriParser.IsKnownScheme("pack")) { //UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1); var _ = PackUriHelper.UriSchemePack; //NoOp to make the PackUriHelper type run its static ctor/cctor. } }
public static void RegisterPackScheme() { if (!UriParser.IsKnownScheme(PackUriHelper.UriSchemePack)) { UriParser.Register(new GenericUriParser (GenericUriParserOptions.GenericAuthority), PackUriHelper.UriSchemePack, -1); } }
public SpotifyHelperTest() { //Register uri scheme "pack" if (!UriParser.IsKnownScheme("pack")) { var app = new Application(); } }
private static void EnsurePackSchemeRegistered() { if (!UriParser.IsKnownScheme(UriSchemePack)) { // Indicate that we want a default hierarchical parser with a registry based authority UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), UriSchemePack, -1); } }
public void Setup() { // Required to register bourgeoise XAML URI schemes if (!UriParser.IsKnownScheme("pack")) { new Application(); } }
public ResourceService() { if (!UriParser.IsKnownScheme("pack")) { //Initialize pack:// Uri scheme string packUriScheme = System.IO.Packaging.PackUriHelper.UriSchemePack; } }
public static void RegisterPack() { if (!UriParser.IsKnownScheme(UriSchemePack)) { UriParser parser = new GenericUriParser(GenericUriParserOptions.GenericAuthority); UriParser.Register(parser, UriSchemePack, -1); } }
public void Initialize() { // Required to register bourgeoise XAML URI schemes if (!UriParser.IsKnownScheme("pack")) { new Application(); } _accent = ThemeManager.TryGetAccent("Blue"); }
//------------------------------------------------------ // // Internal Events // //------------------------------------------------------ // None //------------------------------------------------------ // // Private Constructors // //------------------------------------------------------ #region Private Constructor static PackUriHelper() { // indicate that we want "basic" parsing if (!UriParser.IsKnownScheme(System.IO.Packaging.PackUriHelper.UriSchemePack)) { // Indicate that we want a default hierarchical parser with a registry based authority UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), System.IO.Packaging.PackUriHelper.UriSchemePack, -1); } }
public static void RegisterPackUriParser() { if (UriParser.IsKnownScheme(PackUriScheme)) { return; } UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), PackUriScheme, -1); }
public void TestInit() { if (!UriParser.IsKnownScheme("pack")) { // ReSharper disable ObjectCreationAsStatement new System.Windows.Application(); } // ReSharper restore ObjectCreationAsStatement }
public void FixtureSetup() { if (!UriParser.IsKnownScheme("pack")) { new System.Windows.Application(); } this.tester = new ServiceTester <DirectoryWatch>(); }
public void Setup() { if (!UriParser.IsKnownScheme("pack")) { new System.Windows.Application(); } this.iconProvider = new IconProvider(); this.testFileName = Path.GetTempFileName(); File.Create(testFileName).Close(); }
public static Uri ToPackUri(string url) { if (!UriParser.IsKnownScheme("pack")) { // Register the pack scheme. new Application(); } return(new Uri(url)); }
public void InitializeAndValidate() { Assert.IsTrue(UriParser.IsKnownScheme("httpx"), "premise1"); Uri uri = new Uri("httpx://localhost"); UriFormatException error; parser._InitializeAndValidate(uri, out error); Assert.AreEqual(null, error); }
private EquipmentData(Options options) { if (!UriParser.IsKnownScheme("pack")) { // Necessary for unit tests. Accessing PackUriHelper triggers static initialization. // Without it, creating resource URIs from unit tests would throw UriFormatExceptions. var _ = System.IO.Packaging.PackUriHelper.UriSchemePack; } _itemImageService = new ItemImageService(options); }
public static IEnumerable <CoapOption> DecomposeCoapUri(this Uri resource) { List <CoapOption> options = new List <CoapOption>(); GenericUriParser gup = new GenericUriParser(GenericUriParserOptions.NoFragment); if (!UriParser.IsKnownScheme("coap")) { UriParser.Register(gup, "coap", -1); } if (!resource.IsWellFormedOriginalString()) { throw new UriFormatException("Not well formed URI."); } if (!resource.IsAbsoluteUri) { throw new UriFormatException("Not absolute URI."); } if (resource.Scheme != "coap" && resource.Scheme != "coaps") { throw new UriFormatException(String.Format("Invalid scheme '{0}'", resource.Scheme)); } options.Add(new CoapOption(OptionType.UriHost, resource.Host)); if (resource.Port > 0) { options.Add(new CoapOption(OptionType.UriPort, (uint)resource.Port)); } if (resource.AbsolutePath != "/") { string[] parts = resource.AbsolutePath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { options.Add(new CoapOption(OptionType.UriPath, part)); } } if (!string.IsNullOrEmpty(resource.Query)) { NameValueCollection nvc = HttpUtility.ParseQueryString(resource.Query); int index = 0; while (index < nvc.Count) { options.Add(new CoapOption(OptionType.UriQuery, nvc.GetKey(index) + "=" + nvc[index])); index++; } } return(options.ToArray()); }