示例#1
0
文件: ServiceAgent.cs 项目: xrl/scamp
        protected virtual void ScanAvailableActions(RPCServiceAttribute sattr, List <ActionInfo> ail, Assembly a)
        {
            var    global_priv = new List <Attribute> (Attribute.GetCustomAttributes(a, typeof(RPCPrivilegeRequiredAttribute)));
            string nsremove    = sattr.DotNetNamespacePrefix == null ? "" : sattr.DotNetNamespacePrefix + ".";

            foreach (var type in a.GetExportedTypes())
            {
                var type_priv = new List <Attribute> (Attribute.GetCustomAttributes(type, typeof(RPCPrivilegeRequiredAttribute)));
                type_priv.AddRange(global_priv);
                var nsdefaults = (RPCNamespaceAttribute)Attribute.GetCustomAttribute(type, typeof(RPCNamespaceAttribute)) ?? new RPCNamespaceAttribute();

                var nspace = nsdefaults.Namespace;
                if (nspace == null)
                {
                    if (!type.FullName.StartsWith(nsremove))
                    {
                        continue;
                    }
                    nspace = type.FullName.Substring(nsremove.Length);
                }

                ScanType(ail, type, type_priv, sattr.Sector ?? "main", nspace, nsdefaults.Version != 0 ? nsdefaults.Version : 1);
            }
        }
示例#2
0
        protected virtual void ScanAvailableActions(RPCServiceAttribute sattr, List<ActionInfo> ail, Assembly a)
        {
            var global_priv = new List<Attribute> (Attribute.GetCustomAttributes (a, typeof(RPCPrivilegeRequiredAttribute)));
            string nsremove = sattr.DotNetNamespacePrefix == null ? "" : sattr.DotNetNamespacePrefix + ".";

            foreach (var type in a.GetExportedTypes()) {
                var type_priv = new List<Attribute> (Attribute.GetCustomAttributes (type, typeof(RPCPrivilegeRequiredAttribute)));
                type_priv.AddRange (global_priv);
                var nsdefaults = (RPCNamespaceAttribute)Attribute.GetCustomAttribute (type, typeof(RPCNamespaceAttribute)) ?? new RPCNamespaceAttribute ();

                var nspace = nsdefaults.Namespace;
                if (nspace == null) {
                    if (!type.FullName.StartsWith (nsremove))
                        continue;
                    nspace = type.FullName.Substring (nsremove.Length);
                }

                ScanType (ail, type, type_priv, sattr.Sector ?? "main", nspace, nsdefaults.Version != 0 ? nsdefaults.Version : 1);
            }
        }