Esempio n. 1
0
        public void Deny_Unrestricted()
        {
            Assert.AreEqual(0, coll.Count, "Count");
            Assert.IsTrue(coll.IsReadOnly, "IsReadOnly");
            Assert.IsFalse(coll.IsSynchronized, "IsSynchronized");
            Assert.IsNotNull(coll.SyncRoot, "SyncRoot");

            Assert.IsNotNull(coll.GetEnumerator(), "GetEnumerator");
            Capture[] captures = new Capture[0];
            coll.CopyTo(captures, 0);
        }
Esempio n. 2
0
        private IEnumerable <string> Parse(string value)
        {
            if (_representation == JsonPointerRepresentation.JsonString)
            {
                // TODO: Handle control characters 0x00-0x1F.
                value = value.Replace(@"\\", @"\").Replace(@"\""", @"""");
            }
            else if (_representation == JsonPointerRepresentation.UriFragment)
            {
                if (value[0] != UriFragmentDelimiter)
                {
                    throw new ArgumentException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  Resources.ErrorInvalidFragmentStartCharacter,
                                  value),
                              nameof(value));
                }

                value = Uri.UnescapeDataString(value.Substring(1));
            }

            Match match = s_pointerPattern.Match(value);

            if (match.Success)
            {
                CaptureCollection referenceTokenCaptures = match.Groups["referenceToken"].Captures;
                var captureArray = new Capture[referenceTokenCaptures.Count];
                referenceTokenCaptures.CopyTo(captureArray, 0);
                return(captureArray.Select(c => c.Value));
            }
            else
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              Resources.ErrorInvalidJsonPointer,
                              value),
                          nameof(value));
            }
        }