Beispiel #1
0
        public static string[] ToStringArray(nsIUTF8StringEnumerator enumerator)
        {
            List <string> ret = new List <string>();

            while (enumerator.HasMore())
            {
                var value = nsString.Get(enumerator.GetNext);
                ret.Add(value);
            }
            return(ret.ToArray());
        }
Beispiel #2
0
 public void Dispose()
 {
     _enumerator = null;
     _current    = null;
 }
Beispiel #3
0
 internal Utf8StringEnumerator(nsIUTF8StringEnumerator enumerator)
 {
     _enumerator = enumerator;
 }
Beispiel #4
0
        private static void NS_CreateServicesFromCategory(string category, nsISupports origin, string observerTopic)
        {
            nsICategoryManager      catMan      = null;
            nsISimpleEnumerator     enumerator  = null;
            nsIUTF8StringEnumerator senumerator = null;

            try
            {
                catMan = Xpcom.GetService <nsICategoryManager>(Contracts.CategoryManager);
                if (catMan == null)
                {
                    return;
                }

                enumerator = catMan.EnumerateCategory(category);
                if (enumerator == null)
                {
                    return;
                }

                senumerator = Xpcom.QueryInterface <nsIUTF8StringEnumerator>(enumerator);
                if (senumerator == null)
                {
                    return;
                }

                while (senumerator.HasMore())
                {
                    nsISupports serviceInstance = null;
                    nsIObserver observer        = null;
                    try
                    {
                        string entryString = nsString.Get(senumerator.GetNext);
                        string contractID  = catMan.GetCategoryEntry(category, entryString);
                        serviceInstance = Xpcom.GetService <nsISupports>(contractID);
                        if (serviceInstance == null || observerTopic == null)
                        {
                            continue;
                        }

                        observer = Xpcom.QueryInterface <nsIObserver>(serviceInstance);
                        if (observer == null)
                        {
                            continue;
                        }

                        observer.Observe(origin, observerTopic, "");
                    }
                    catch (NotImplementedException) { }
                    catch (OutOfMemoryException) { }
                    catch (COMException) { }
                    finally
                    {
                        Xpcom.FreeComObject(ref serviceInstance);
                        Xpcom.FreeComObject(ref observer);
                    }
                }
            }
            finally
            {
                Xpcom.FreeComObject(ref catMan);
                Xpcom.FreeComObject(ref enumerator);
                Xpcom.FreeComObject(ref senumerator);
            }
        }