public void TestTextAnalysis()
        {
            var m          = new NSMutableData();
            var properties = new SKTextAnalysis()
            {
                StartTermChars = "",
                EndTermChars   = "",
                TermChars      = "\"-_@.'",
                MinTermLength  = 3,
                StopWords      = new NSSet("all", "and", "its", "it's", "the")
            };

            var idx = SKIndex.CreateWithMutableData(m, "indexName", SKIndexType.Inverted, properties);

            Assert.NotNull(idx);
        }
Exemple #2
0
 public static SKIndex CreateWithMutableData(NSMutableData data, string indexName, SKIndexType type, SKTextAnalysis analysisProperties)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (indexName == null)
     {
         throw new ArgumentNullException("indexName");
     }
     using (var cfstr = new NSString(indexName)) {
         var h = SKIndexCreateWithMutableData(data.Handle, cfstr.Handle, type, analysisProperties == null ? IntPtr.Zero : analysisProperties.Dictionary.Handle);
         if (h == IntPtr.Zero)
         {
             return(null);
         }
         return(new SKIndex(h));
     }
 }
Exemple #3
0
        public static SKIndex CreateWithUrl(NSUrl url, string indexName, SKIndexType type, SKTextAnalysis analysisProperties)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            var cfstr = indexName == null ? null : new NSString(indexName);

            var h = SKIndexCreateWithURL(url.Handle, cfstr == null ? IntPtr.Zero : cfstr.Handle, type, analysisProperties == null ? IntPtr.Zero : analysisProperties.Dictionary.Handle);

            cfstr.Dispose();
            if (h == IntPtr.Zero)
            {
                return(null);
            }
            return(new SKIndex(h));
        }
Exemple #4
0
        public static SKIndex?CreateWithMutableData(NSMutableData data, string indexName, SKIndexType type, SKTextAnalysis analysisProperties)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (indexName is null)
            {
                throw new ArgumentNullException(nameof(indexName));
            }
            var indexNameHandle = CFString.CreateNative(indexName);

            try {
                var handle = SKIndexCreateWithMutableData(data.Handle, indexNameHandle, type, analysisProperties.GetHandle());
                if (handle == IntPtr.Zero)
                {
                    return(null);
                }
                return(new SKIndex(handle, true));
            } finally {
                CFString.ReleaseNative(indexNameHandle);
            }
        }
Exemple #5
0
        public static SKIndex CreateWithUrl(NSUrl url, string indexName, SKIndexType type, SKTextAnalysis analysisProperties)
        {
            if (url == null)
                throw new ArgumentNullException ("url");
            var cfstr = indexName == null ? null : new NSString (indexName);

            var h = SKIndexCreateWithURL (url.Handle, cfstr == null ? IntPtr.Zero : cfstr.Handle, type, analysisProperties == null ? IntPtr.Zero : analysisProperties.Dictionary.Handle);
            cfstr.Dispose ();
            if (h == IntPtr.Zero)
                return null;
            return new SKIndex (h);
        }
Exemple #6
0
 public static SKIndex CreateWithMutableData(NSMutableData data, string indexName, SKIndexType type, SKTextAnalysis analysisProperties)
 {
     if (data == null)
         throw new ArgumentNullException ("data");
     if (indexName == null)
         throw new ArgumentNullException ("indexName");
     using (var cfstr = new NSString (indexName)) {
         var h = SKIndexCreateWithMutableData (data.Handle, cfstr.Handle, type, analysisProperties == null ? IntPtr.Zero : analysisProperties.Dictionary.Handle);
         if (h == IntPtr.Zero)
             return null;
         return new SKIndex (h);
     }
 }