コード例 #1
0
        protected override ExportAttribute GetExportAttribute(MethodBase method)
        {
            MethodInfo minfo = method as MethodInfo;

            if (minfo != null)
            {
                return(SharedDynamic.GetOneAttribute <ExportAttribute> (minfo.GetBaseDefinition()));
            }

            ConstructorInfo cinfo = method as ConstructorInfo;

            if (cinfo != null)
            {
                return(SharedDynamic.GetOneAttribute <ExportAttribute> (cinfo));
            }

            return(null);
        }
コード例 #2
0
        protected override BindAsAttribute GetBindAsAttribute(MethodBase method, int parameter_index)
        {
            ICustomAttributeProvider provider;

            if (method == null)
            {
                return(null);
            }

            var minfo = method as MethodInfo;

            if (minfo != null)
            {
                minfo = minfo.GetBaseDefinition();
                if (parameter_index == -1)
                {
                    provider = minfo.ReturnTypeCustomAttributes;
                }
                else
                {
                    provider = minfo.GetParameters() [parameter_index];
                }
            }
            else
            {
                var cinfo = method as ConstructorInfo;
                if (parameter_index == -1)
                {
                    throw ErrorHelper.CreateError(99, $"Internal error: can't get the BindAs attribute for the return value of a constructor ({GetDescriptiveMethodName (method)}). Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new).");
                }
                else
                {
                    provider = cinfo.GetParameters() [parameter_index];
                }
            }

            return(SharedDynamic.GetOneAttribute <BindAsAttribute> (provider));
        }
コード例 #3
0
        public static Dictionary <MethodBase, List <MethodBase> > PrepareInterfaceMethodMapping(Type type)
        {
            Dictionary <MethodBase, List <MethodBase> > rv = null;
            var ifaces = type.FindInterfaces((v, o) =>
            {
                var attribs = v.GetCustomAttributes(typeof(ProtocolAttribute), true);
                return(attribs != null && attribs.Length > 0);
            }, null);

            foreach (var iface in ifaces)
            {
                var map = type.GetInterfaceMap(iface);
                for (int i = 0; i < map.InterfaceMethods.Length; i++)
                {
                    var ifaceMethod = map.InterfaceMethods [i];
                    var impl        = map.TargetMethods [i];

                    if (SharedDynamic.GetOneAttribute <ExportAttribute> (ifaceMethod) == null)
                    {
                        continue;
                    }

                    List <MethodBase> list;
                    if (rv == null)
                    {
                        rv        = new Dictionary <MethodBase, List <MethodBase> > ();
                        rv [impl] = list = new List <MethodBase> ();
                    }
                    else if (!rv.TryGetValue(impl, out list))
                    {
                        rv [impl] = list = new List <MethodBase> ();
                    }
                    list.Add(ifaceMethod);
                }
            }

            return(rv);
        }
コード例 #4
0
        protected override Type GetProtocolAttributeWrapperType(Type type)
        {
            var attr = SharedDynamic.GetOneAttribute <ProtocolAttribute> (type);

            return(attr == null ? null : attr.WrapperType);
        }
コード例 #5
0
 protected override CategoryAttribute GetCategoryAttribute(Type type)
 {
     return(SharedDynamic.GetOneAttribute <CategoryAttribute> (type));
 }
コード例 #6
0
 public override ProtocolAttribute GetProtocolAttribute(Type type)
 {
     return(SharedDynamic.GetOneAttribute <ProtocolAttribute> (type));
 }
コード例 #7
0
 public override RegisterAttribute GetRegisterAttribute(Type type)
 {
     return(SharedDynamic.GetOneAttribute <RegisterAttribute> (type));
 }
コード例 #8
0
 protected override ExportAttribute GetExportAttribute(PropertyInfo property)
 {
     return(SharedDynamic.GetOneAttribute <ExportAttribute> (GetBasePropertyInTypeHierarchy(property) ?? property));
 }
コード例 #9
0
 protected override Dictionary <MethodBase, List <MethodBase> > PrepareMethodMapping(Type type)
 {
     return(SharedDynamic.PrepareInterfaceMethodMapping(type));
 }
コード例 #10
0
 protected override ConnectAttribute GetConnectAttribute(PropertyInfo property)
 {
     return(SharedDynamic.GetOneAttribute <ConnectAttribute> (property));
 }