public static bool HasProtocolAttribute(IType type, out string name)
 {
     foreach (var attrs in type.GetDefinition().GetAttributes())
     {
         if (attrs.AttributeType.Name == "ProtocolAttribute" && MonoCSharpCompletionEngine.IsFoundationNamespace(attrs.AttributeType.Namespace))
         {
             foreach (var na in attrs.NamedArguments)
             {
                 if (na.Key.Name != "Name")
                 {
                     continue;
                 }
                 name = na.Value.ConstantValue as string;
                 if (name != null)
                 {
                     return(true);
                 }
             }
         }
     }
     name = null;
     return(false);
 }
            protected override IEnumerable <object> GetValidMembers()
            {
                var type = Options.EnclosingType;

                if (type == null || Options.EnclosingMember != null)
                {
                    yield break;
                }
                foreach (var t in type.DirectBaseTypes)
                {
                    string name;
                    if (!HasProtocolAttribute(t, out name))
                    {
                        continue;
                    }
                    var protocolType = Options.Document.Compilation.FindType(new FullTypeName(new TopLevelTypeName(t.Namespace, name)));
                    if (protocolType == null)
                    {
                        break;
                    }
                    foreach (var member in protocolType.GetMethods(null, GetMemberOptions.IgnoreInheritedMembers))
                    {
                        if (member.ImplementedInterfaceMembers.Any())
                        {
                            continue;
                        }
                        if (!cg.IsValidMember(member))
                        {
                            continue;
                        }
                        if (IsImplemented(type, member))
                        {
                            continue;
                        }
                        if (member.Attributes.Any(a => a.AttributeType.Name == "ExportAttribute" && MonoCSharpCompletionEngine.IsFoundationNamespace(a.AttributeType.Namespace)))
                        {
                            yield return(member);
                        }
                    }
                    foreach (var member in protocolType.GetProperties(null, GetMemberOptions.IgnoreInheritedMembers))
                    {
                        if (member.ImplementedInterfaceMembers.Any())
                        {
                            continue;
                        }
                        if (!cg.IsValidMember(member))
                        {
                            continue;
                        }
                        if (IsImplemented(type, member))
                        {
                            continue;
                        }
                        if (member.CanGet && member.Getter.Attributes.Any(a => a.AttributeType.Name == "ExportAttribute" && MonoCSharpCompletionEngine.IsFoundationNamespace(a.AttributeType.Namespace)) ||
                            member.CanSet && member.Setter.Attributes.Any(a => a.AttributeType.Name == "ExportAttribute" && MonoCSharpCompletionEngine.IsFoundationNamespace(a.AttributeType.Namespace)))
                        {
                            yield return(member);
                        }
                    }
                }
            }
        static string GetProtocol(IMember member)
        {
            var attr = member.Attributes.FirstOrDefault(a => a.AttributeType.Name == "ExportAttribute" && MonoCSharpCompletionEngine.IsFoundationNamespace(a.AttributeType.Namespace));

            if (attr == null || attr.PositionalArguments.Count == 0)
            {
                return(null);
            }
            return(attr.PositionalArguments.First().ConstantValue.ToString());
        }