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); }
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); }
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://bugzilla.xamarin.com)."); } else { provider = cinfo.GetParameters() [parameter_index]; } } return(SharedDynamic.GetOneAttribute <BindAsAttribute> (provider)); }
protected override Type GetProtocolAttributeWrapperType(Type type) { var attr = SharedDynamic.GetOneAttribute <ProtocolAttribute> (type); return(attr == null ? null : attr.WrapperType); }
protected override CategoryAttribute GetCategoryAttribute(Type type) { return(SharedDynamic.GetOneAttribute <CategoryAttribute> (type)); }
protected override ProtocolAttribute GetProtocolAttribute(Type type) { return(SharedDynamic.GetOneAttribute <ProtocolAttribute> (type)); }
protected override RegisterAttribute GetRegisterAttribute(Type type) { return(SharedDynamic.GetOneAttribute <RegisterAttribute> (type)); }
protected override ExportAttribute GetExportAttribute(PropertyInfo property) { return(SharedDynamic.GetOneAttribute <ExportAttribute> (GetBasePropertyInTypeHierarchy(property) ?? property)); }
protected override ConnectAttribute GetConnectAttribute(PropertyInfo property) { return(SharedDynamic.GetOneAttribute <ConnectAttribute> (property)); }