コード例 #1
0
        //------------------------------------------------------
        //
        //  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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Registers the URI.
        /// </summary>
        public static void RegisterUri()
        {
            if (!UriParser.IsKnownScheme("rtsp"))
            {
                UriParser.Register(new HttpStyleUriParser(), "rtsp", 554);
            }

            UriParser.Register(new HttpStyleUriParser(), "rtsp", 8080);
        }
コード例 #3
0
ファイル: DynamicUriParser.cs プロジェクト: tvoyle/nxkit
        /// <summary>
        /// Ensures the <see cref="UriParser"/> is registered.
        /// </summary>
        public static void Register()
        {
            if (!registered)
            {
                UriParser.Register(new DynamicUriParser(), DynamicUriHelper.UriSchemeDynamic, -1);
                registered = true;
            }

            DynamicWebRequestFactory.Register();
        }
コード例 #4
0
        public void SendTest()
        {
            Publication pub = storageManager.getEntityByID <Publication>(11);

            Assert.IsNotNull(pub);

            UriParser.Register(new GoogleDocsUriParser(), "gdocs", -1);

            Assert.IsTrue(serviceManager.Send(pub));
        }
コード例 #5
0
 public void DontCheckHostWithCustomParsers()
 {
     UriParser.Register(new TolerantUriParser(), "assembly", 0);
     try {
         new Uri("assembly://Spring.Core, Version=1.2.0.20001, Culture=neutral, "
                 + "PublicKeyToken=null/Spring.Objects.Factory.Xml/spring-objects-1.1.xsd");
     } catch (UriFormatException) {
         Assert.Fail("Spring Uri is expected to work.");
     }
 }
コード例 #6
0
        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());
        }
コード例 #7
0
ファイル: UriParserTest.cs プロジェクト: yfakariya/mono
        public void ReRegister()
        {
            string scheme = prefix + "re.register.mono";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, scheme, 2005);
            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
            UriParser.Register(p, scheme, 2006);
        }
        private void RegisterPackScheme()
        {
            if (UriParser.IsKnownScheme("pack"))
            {
                return;
            }

            var packParser = new PackParser();

            UriParser.Register(packParser, "pack", 0);
        }
コード例 #9
0
        /// <summary>
        /// Ensures that the pack URI is allowed. Sometimes, when no application object is instantiated
        /// yet, the pack URI is not allowed. This method takes care of that.
        /// </summary>
        internal static void EnsurePackUriIsAllowed()
        {
#if !NETFX_CORE
            if (!UriParser.IsKnownScheme("pack"))
            {
                Log.Debug("Pack uri is not yet allowed, adding it as known scheme");

                UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1);
            }
#endif
        }
コード例 #10
0
        public static void ReRegister()
        {
            string scheme = Prefix + "re.register.mono";

            Assert.False(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            TestUriParser parser = new TestUriParser();

            UriParser.Register(parser, scheme, 2005);
            Assert.True(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
            Assert.Throws <InvalidOperationException>(() => UriParser.Register(parser, scheme, 2006));
        }
コード例 #11
0
        /// <summary>
        /// Registers the parsers.
        /// </summary>
        public static void RegisterParsers()
        {
            if (!UriParser.IsKnownScheme(SvnUri.UriSchemeSvn))
            {
                UriParser.Register(new SvnUriParser(), SvnUri.UriSchemeSvn, 3980);
            }

            if (!UriParser.IsKnownScheme(SvnUri.UriSchemeSvnSsh))
            {
                UriParser.Register(new SvnUriParser(), SvnUri.UriSchemeSvnSsh, 22);
            }
        }
コード例 #12
0
 public static void RegisterResUriParsers()
 {
     if (!UriParser.IsKnownScheme("avares"))
     {
         UriParser.Register(new GenericUriParser(
                                GenericUriParserOptions.GenericAuthority |
                                GenericUriParserOptions.NoUserInfo |
                                GenericUriParserOptions.NoPort |
                                GenericUriParserOptions.NoQuery |
                                GenericUriParserOptions.NoFragment), "avares", -1);
     }
 }
コード例 #13
0
        public void FixtureSetUp()
        {
            parser = new UnitTestNewsStyleUriParser();
            // unit tests are being reused in CAS tests
            if (!UriParser.IsKnownScheme("newsx"))
            {
                UriParser.Register(parser, "newsx", 2);
            }

            Assert.IsTrue(UnitTestNewsStyleUriParser.Registered, "Registered");
            // our parser code was called
        }
コード例 #14
0
ファイル: SipMessage.cs プロジェクト: acinep/net7mma-1
        static SipMessage()
        {
            if (false == UriParser.IsKnownScheme(SipMessage.TransportScheme))
            {
                UriParser.Register(new HttpStyleUriParser(), SipMessage.TransportScheme, SipMessage.TransportDefaultPort);
            }

            if (false == UriParser.IsKnownScheme(SipMessage.SecureTransportScheme))
            {
                UriParser.Register(new HttpStyleUriParser(), SipMessage.SecureTransportScheme, SipMessage.SecureTransportDefaultPort);
            }
        }
コード例 #15
0
ファイル: UriParserTest.cs プロジェクト: yuekunge/corefx
        public static void ReRegister()
        {
            prefix = "unit.test.";
            string scheme = prefix + "re.register.mono";

            Assert.False(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            TestUriParser parser = new TestUriParser();

            UriParser.Register(parser, scheme, 2005);
            Assert.True(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
            Assert.Throws <System.InvalidOperationException>(() => { UriParser.Register(parser, scheme, 2006); });
        }
コード例 #16
0
        public void FixtureSetUp()
        {
            parser = new UnitTestGenericUriParser();
            // unit tests are being reused in CAS tests
            if (!UriParser.IsKnownScheme("generic"))
            {
                UriParser.Register(parser, "generic", 1);
            }

            Assert.IsTrue(UnitTestGenericUriParser.Registered, "Registered");
            // our parser code was called
        }
コード例 #17
0
        public static void AnyValidPort_CanBeRegistered()
        {
            for (int i = -1; i <= 65535; i++)
            {
                string scheme = $"custom-port-scheme-{i:X2}";
                UriParser.Register(new HttpStyleUriParser(), scheme, defaultPort: i);
                var uri = new Uri($"{scheme}://host/path");
                Assert.Equal(i, uri.Port);
            }

            Assert.Throws <ArgumentOutOfRangeException>(() => UriParser.Register(new HttpStyleUriParser(), "invalid-port", -2));
            Assert.Throws <ArgumentOutOfRangeException>(() => UriParser.Register(new HttpStyleUriParser(), "invalid-port", 65536));
        }
コード例 #18
0
        private void AddResouces()
        {
            if (!UriParser.IsKnownScheme("pack"))
            {
                UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1);
            }


            //Datagrid
            if (!Resources.MergedDictionaries.Contains(_datagridStyle))
            {
                Resources.MergedDictionaries.Add(_datagridStyle);
            }
        }
コード例 #19
0
        public static void Register()
        {
            string scheme = Prefix + "register.mono";

            Assert.False(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");

            TestUriParser parser = new TestUriParser();

            UriParser.Register(parser, scheme, 2005);
            Assert.Equal(scheme, parser.SchemeName);
            Assert.Equal(2005, parser.DefaultPort);

            Assert.True(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
コード例 #20
0
ファイル: UriParserTest.cs プロジェクト: yfakariya/mono
        public void Register()
        {
            string scheme = prefix + "register.mono";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");

            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, scheme, 2005);
            Assert.AreEqual(scheme, p.SchemeName, "SchemeName");
            Assert.AreEqual(2005, p.DefaultPort, "DefaultPort");

            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
コード例 #21
0
        public void SendTestGdocs()
        {
            if (!UriParser.IsKnownScheme("gdocs"))
            {
                UriParser.Register(new GoogleDocsUriParser(), "gdocs", -1);
            }
            Publication res2 = storageManager.getEntityByID <Publication>(485);

            Assert.IsNotNull(res2);

            res2.URIUpload = "gdocs:asfalto:oh";

            Assert.IsTrue(serviceManager.Send(res2));
        }
コード例 #22
0
ファイル: UriParserTest.cs プロジェクト: yfakariya/mono
        public void OnNewUri()
        {
            string scheme = prefix + "on.new.uri";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");

            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, scheme, 1999);

            Assert.IsFalse(p.OnNewUriCalled, "!Called");
            Uri uri = new Uri(scheme + "://www.mono-project.com");

            Assert.IsTrue(p.OnNewUriCalled, "Called");
        }
コード例 #23
0
ファイル: UriParserTest.cs プロジェクト: yfakariya/mono
        public void OnRegister()
        {
            string scheme = prefix + "onregister";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            UnitTestUriParser p = new UnitTestUriParser();

            try {
                UriParser.Register(p, scheme, 2005);
            }
            catch (NotSupportedException) {
                // special case / ordering
            }
            // if true then the registration is done before calling OnRegister
            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
コード例 #24
0
ファイル: UriTests.cs プロジェクト: wilfriedb/runtime
        public static void Uri_CombineUsesNewUriString()
        {
            // Tests that internal Uri fields were properly reset during a Combine operation
            // Otherwise, the wrong Uri string would be used if the relative Uri contains non-ascii characters
            // This will only affect parsers without the IriParsing flag - only custom parsers
            UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "combine-scheme", -1);

            const string BaseUriString     = "combine-scheme://foo";
            const string RelativeUriString = "/relative/uri/with/non/ascii/\u00FC";
            const string Combined          = BaseUriString + "/relative/uri/with/non/ascii/%C3%BC";

            var baseUri     = new Uri(BaseUriString, UriKind.Absolute);
            var relativeUri = new Uri(RelativeUriString, UriKind.Relative);

            Assert.Equal(Combined, new Uri(baseUri, relativeUri).AbsoluteUri);
            Assert.Equal(Combined, new Uri(baseUri, RelativeUriString).AbsoluteUri);
        }
コード例 #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AlienbrainUri"/> class.
        /// </summary>
        /// <param name="url">The URL.</param>
        public AlienbrainUri(string url) : base(url)
        {
            if (!UriParser.IsKnownScheme(AlienbrainUri.UriSchemeAlienbrainShort))
            {
                UriParser.Register(new AlienbrainUriParser( ), AlienbrainUri.UriSchemeAlienbrainShort, 8318);
            }

            if (!UriParser.IsKnownScheme(AlienbrainUri.UriSchemeAlienbrainLong))
            {
                UriParser.Register(new AlienbrainUriParser( ), AlienbrainUri.UriSchemeAlienbrainLong, 8318);
            }

            if (string.Compare(this.Scheme, "ab", true) != 0 && string.Compare(this.Scheme, "alienbrain", true) != 0)
            {
                throw new UriFormatException("Only \"ab\" and \"alienbrain\" schemes are allowed.");
            }
        }
コード例 #26
0
        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // enable "Code Uri" usage
            if (!UriParser.IsKnownScheme("code"))
            {
                UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "code", -1);
            }

            // Register a handler for Drop event
            LayoutRoot.Drop += LayoutRoot_Drop;
            DownloadIndicator.DataContext = _busyContext;

            ApplicationModel.Current.AssemblyCache.AssemblyAdded   += AssemblyCache_AssemblyAdded;
            ApplicationModel.Current.AssemblyCache.AssemblyRemoved += AssemblyCache_AssemblyRemoved;
            DecompilerManager.CodeDisassemblyRequested             += OnCodeDisassemblyRequested;
            ApplicationModel.Current.CurrentLanguageChanged        += OnCurrentLanguageChanged;
        }
コード例 #27
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public ServiceLocator()
        {
            if (!UriParser.IsKnownScheme("gdocs"))
            {
                UriParser.Register(new GoogleDocsUriParser(), "gdocs", -1);
            }
            schemes = new Dictionary <string, ServiceType>();
            schemes.Add("mailto", new ServiceType("Email", "mailto"));
            schemes.Add("rss", new ServiceType("RSS Feed", "rss"));
            schemes.Add("ftp", new ServiceType("Ftp Server", "ftp"));
            schemes.Add("gdocs", new ServiceType("Google Docs", "gdocs"));

            services = new Dictionary <ServiceType, IService>();
            services.Add(new ServiceType("Email", "mailto"), new MailService());
            services.Add(new ServiceType("RSS Feed", "rss"), new RssService());
            services.Add(new ServiceType("Ftp Server", "ftp"), new FtpService());
            services.Add(new ServiceType("Google Docs", "gdocs"), new GoogleDocsService());
        }
        public static bool DataSetToXLSXFast(DataSet ds, string sWBName)
        {
            bool bRetVal = false;

            try
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");

                var wb = new XLWorkbook();

                try
                {
                    // might not really need this since no hyperlinks anyway...
                    UriParser.Register(new PWUriParser(GenericUriParserOptions.AllowEmptyAuthority |
                                                       GenericUriParserOptions.DontCompressPath | GenericUriParserOptions.DontConvertPathBackslashes |
                                                       GenericUriParserOptions.DontUnescapePathDotsAndSlashes | GenericUriParserOptions.GenericAuthority |
                                                       GenericUriParserOptions.NoFragment), "pw", 5800);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Error: {0}\n{1}", ex.Message, ex.StackTrace));
                }

                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.TableName.Length > 30)
                    {
                        dt.TableName = dt.TableName.Substring(0, 30);
                    }
                }

                wb.Worksheets.Add(ds);

                wb.SaveAs(sWBName);

                bRetVal = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"Error: {ex.Message}\n{ex.StackTrace}");
            }

            return(bRetVal);
        }
コード例 #29
0
ファイル: UriParserTest.cs プロジェクト: yuekunge/corefx
        public static void OnRegister()
        {
            prefix = "unit.test.";
            string scheme = prefix + "onregister";

            Assert.False(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            TestUriParser parser = new TestUriParser();

            try
            {
                UriParser.Register(parser, scheme, 2005);
            }
            catch (NotSupportedException)
            {
                // special case / ordering
            }
            // if true then the registration is done before calling OnRegister
            Assert.True(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
コード例 #30
0
        //------------------------------------------------------
        //
        //  Internal Events
        //
        //------------------------------------------------------
        // None
        //------------------------------------------------------
        //
        //  Private Constructors
        //
        //------------------------------------------------------

        #region Private Constructor

        static PackUriHelper()
        {
            // indicate that we want "basic" parsing
            if (!UriParser.IsKnownScheme(System.IO.Packaging.PackUriHelper.UriSchemePack))
            {
                try
                {
                    SecurityPermission permobj = new SecurityPermission(SecurityPermissionFlag.Infrastructure);
                    permobj.Assert(); //BlessedAssert:

                    // 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);
                }
                finally
                {
                    SecurityPermission.RevertAssert();
                }
            }
        }