Ejemplo n.º 1
0
        public static PropertyDescriptorCollection GetObjectProperties(EnumReflectionMemberInfoSelectScope scope, object obj, bool browsableOnly)
        {
            bool includeClient = MethodInfoWebClient.IsWebClientObject(obj);
            bool includeServer = MethodInfoWebClient.IsWebServerObject(obj);
            PropertyDescriptorCollection ps = VPLUtil.GetProperties(obj, scope, false, browsableOnly, true);            // TypeDescriptor.GetProperties(obj, attrs, false);
            List <PropertyDescriptor>    l  = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor p in ps)
            {
                bool include = false;
                if (includeClient)
                {
                    if (WebClientMemberAttribute.IsClientProperty(p))
                    {
                        include = true;
                    }
                }
                if (!include)
                {
                    if (includeServer)
                    {
                        if (WebServerMemberAttribute.IsServerProperty(p))
                        {
                            include = true;
                        }
                    }
                }
                if (!include)
                {
                    if (includeClient)
                    {
                        if (!(obj is Form) && (obj is IWebClientControl))
                        {
                            if (string.CompareOrdinal(p.Name, "Location") != 0)
                            {
                                include = true;
                            }
                        }
                    }
                }
                if (!include)
                {
                    if (includeServer)
                    {
                        if (obj is IWebServerProgrammingSupport)
                        {
                            include = true;
                        }
                    }
                }
                if (include)
                {
                    l.Add(p);
                }
            }
            return(new PropertyDescriptorCollection(l.ToArray()));
        }
Ejemplo n.º 2
0
        public static MethodInfo[] GetWebMethods(bool isStatic, object obj)
        {
            bool includeClient    = MethodInfoWebClient.IsWebClientObject(obj);
            bool includeServer    = MethodInfoWebClient.IsWebServerObject(obj);
            List <MethodInfo> lst = new List <MethodInfo>();
            BindingFlags      flags;

            if (isStatic)
            {
                flags = BindingFlags.Public | BindingFlags.Static;
            }
            else
            {
                flags = BindingFlags.Public | BindingFlags.Instance;
            }
            Type t = obj as Type;

            if (t == null)
            {
                t = obj.GetType();
            }
            bool isPhp = PhpTypeAttribute.IsPhpType(t);
            bool isJs  = JsTypeAttribute.IsJsType(t);

            MethodInfo[] ret = t.GetMethods(flags);
            if (ret != null && ret.Length > 0)
            {
                for (int i = 0; i < ret.Length; i++)
                {
                    if (!ret[i].IsSpecialName)
                    {
                        if (VPLUtil.IsNotForProgramming(ret[i]))
                        {
                            continue;
                        }
                        bool include = false;
                        if (isPhp)
                        {
                            if (WebServerMemberAttribute.IsServerMethod(ret[i]))
                            {
                                lst.Add(ret[i]);
                            }
                            continue;
                        }
                        if (isJs)
                        {
                            if (WebClientMemberAttribute.IsClientMethod(ret[i]))
                            {
                                lst.Add(ret[i]);
                            }
                            continue;
                        }
                        if (includeClient)
                        {
                            object[] objs = ret[i].GetCustomAttributes(typeof(WebClientMemberAttribute), true);
                            if (objs != null && objs.Length > 0)
                            {
                                include = true;
                            }
                        }
                        if (!include)
                        {
                            if (includeServer)
                            {
                                object[] objs = ret[i].GetCustomAttributes(typeof(WebServerMemberAttribute), true);
                                if (objs != null && objs.Length > 0)
                                {
                                    include = true;
                                }
                            }
                        }
                        if (include)
                        {
                            lst.Add(ret[i]);
                        }
                    }
                }
            }
            ret = lst.ToArray();
            return(ret);
        }
Ejemplo n.º 3
0
        public static EventInfo[] GetWebClientEvents(bool isStatic, object obj)
        {
            bool             includeClient = MethodInfoWebClient.IsWebClientObject(obj);
            bool             includeServer = MethodInfoWebClient.IsWebServerObject(obj);
            List <EventInfo> lst           = new List <EventInfo>();
            BindingFlags     flags;

            if (isStatic)
            {
                flags = BindingFlags.Public | BindingFlags.Static;
            }
            else
            {
                flags = BindingFlags.Public | BindingFlags.Instance;
            }
            EventInfo[] ret;
            IWebClientControlCustomEvents wcce = obj as IWebClientControlCustomEvents;

            if (wcce != null)
            {
                ret = wcce.GetWebClientEvents(isStatic);
            }
            else
            {
                ret = obj.GetType().GetEvents(flags);
            }
            if (ret != null && ret.Length > 0)
            {
                for (int i = 0; i < ret.Length; i++)
                {
                    if (!ret[i].IsSpecialName)
                    {
                        bool include = false;
                        if (includeClient)
                        {
                            object[] objs = ret[i].GetCustomAttributes(typeof(WebClientMemberAttribute), true);
                            if (objs != null && objs.Length > 0)
                            {
                                include = true;
                            }
                        }
                        if (!include)
                        {
                            if (includeServer)
                            {
                                object[] objs = ret[i].GetCustomAttributes(typeof(WebServerMemberAttribute), true);
                                if (objs != null && objs.Length > 0)
                                {
                                    include = true;
                                }
                                else
                                {
                                    objs = ret[i].GetCustomAttributes(typeof(WebClientEventByServerObjectAttribute), true);
                                    if (objs != null && objs.Length > 0)
                                    {
                                        include = true;
                                    }
                                }
                            }
                        }
                        if (include)
                        {
                            lst.Add(ret[i]);
                        }
                    }
                }
            }
            ret = lst.ToArray();
            return(ret);
        }