internal static TypeInfo[] FindBaseTypesAndInterfaces(TypeInfo type) { TypeInfo currentTypeInfo = type; TypeInfo objectType = new TypeInfo(typeof(Object)); List <TypeInfo> infos = new List <TypeInfo>(); try { //we walk up the hierarchy as far as we can until we can't //get the types anymore... while (!currentTypeInfo.Equals(objectType)) { // To get the base type and interfaces, we will need to resolve a TypeRef to a TypeDef first currentTypeInfo = currentTypeInfo.TryGetTypeDef(); if (currentTypeInfo != null) { TypeInfo[] interfaces = currentTypeInfo.GetInterfaces(); if (interfaces != null) { infos.AddRange(interfaces); } TypeInfo baseType = currentTypeInfo.BaseType; infos.Add(baseType); currentTypeInfo = baseType; } else { // we have reached the limit of what we can resolve in the addin/hostadapter's folder break; } } } catch (GenericsNotImplementedException) { // Since GetInterfaces() ignores all generic interfaces, we'll only come here if we encounter a generic base class. // We'll ignore the generic base class and return whatever bases we found earlier. } return(infos.ToArray()); }
internal bool CanDirectConnectTo(TypeInfo havTypeInfo) { bool result = false; if(havTypeInfo.Equals(TypeInfo)) { // Check the add-in base's type info. result = true; } else if(_activatableAs != null) { // Check the ActivatableAs types. for(int i = 0; i < _activatableAs.Length && result == false; i++) { if(_activatableAs[i].Equals(havTypeInfo)) { result = true; } } } return result; }
internal bool CanDirectConnectTo(TypeInfo havTypeInfo) { bool result = false; if (havTypeInfo.Equals(TypeInfo)) { // Check the add-in base's type info. result = true; } else if (_activatableAs != null) { // Check the ActivatableAs types. for (int i = 0; i < _activatableAs.Length && result == false; i++) { if (_activatableAs[i].Equals(havTypeInfo)) { result = true; } } } return(result); }