Ejemplo n.º 1
0
        private ICollection <T> GetManagementBeans <T>(Type beanInterface)
        {
            beanInterface = typeof(T);
            ICollection <T> result = null;

            if (_support.GetType() != typeof(ManagementSupport) && _beans.Count > 0 && _beans[0] is KernelBean)
            {
                try
                {
                    result = _support.getProxiesFor(beanInterface, ( KernelBean )_beans[0]);
                }
                catch (System.NotSupportedException)
                {
                    // go to fall back
                }
            }
            if (result == null)
            {
                // Fall back: if we cannot create proxy, we can search for instances
                result = new List <T>();
                foreach (Neo4jMBean bean in _beans)
                {
                    if (beanInterface.IsInstanceOfType(bean))
                    {
                        result.Add(beanInterface.cast(bean));
                    }
                }
            }
            return(result);
        }