本文整理汇总了C#中MonoDevelop.Projects.Dom.Parser.ProjectDom.GetInheritanceTree方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectDom.GetInheritanceTree方法的具体用法?C# ProjectDom.GetInheritanceTree怎么用?C# ProjectDom.GetInheritanceTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Projects.Dom.Parser.ProjectDom
的用法示例。
在下文中一共展示了ProjectDom.GetInheritanceTree方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTypeMembers
void UpdateTypeMembers (ProjectDom dom, NSObjectTypeInfo info, IType type)
{
info.Actions.Clear ();
info.Outlets.Clear ();
foreach (var prop in type.Properties) {
foreach (var att in prop.Attributes) {
bool isIBOutlet = att.AttributeType.FullName == iboutletAttType.FullName;
if (!isIBOutlet) {
if (att.AttributeType.FullName != connectAttType.FullName)
continue;
}
string name = null;
if (att.PositionalArguments.Count == 1)
name = (string)((System.CodeDom.CodePrimitiveExpression)att.PositionalArguments[0]).Value;
if (string.IsNullOrEmpty (name))
name = prop.Name;
// HACK: Work around bug #1586 in the least obtrusive way possible. Strip out any outlet
// with the name 'view' on subclasses of MonoTouch.UIKit.UIViewController to avoid
// conflicts with the view property mapped there
if (name == "view")
if (dom.GetInheritanceTree (type).Any (p => p.FullName == "MonoTouch.UIKit.UIViewController"))
continue;
var ol = new IBOutlet (name, prop.Name, null, prop.ReturnType.FullName);
if (MonoDevelop.DesignerSupport.CodeBehind.IsDesignerFile (prop.DeclaringType.CompilationUnit.FileName))
ol.IsDesigner = true;
info.Outlets.Add (ol);
break;
}
}
foreach (var meth in type.Methods) {
foreach (var att in meth.Attributes) {
bool isIBAction = att.AttributeType.FullName == ibactionAttType.FullName;
if (!isIBAction) {
if (att.AttributeType.FullName != exportAttType.FullName)
continue;
}
bool isDesigner = MonoDevelop.DesignerSupport.CodeBehind.IsDesignerFile (
meth.DeclaringType.CompilationUnit.FileName);
//only support Export from old designer files, user code must be IBAction
if (!isDesigner && !isIBAction)
continue;
string[] name = null;
if (att.PositionalArguments.Count == 1) {
var n = (string)((System.CodeDom.CodePrimitiveExpression)att.PositionalArguments[0]).Value;
if (!string.IsNullOrEmpty (n))
name = n.Split (colonChar);
}
var action = new IBAction (name != null? name [0] : meth.Name, meth.Name);
int i = 1;
foreach (var param in meth.Parameters) {
string label = name != null && i < name.Length? name[i] : null;
if (label != null && label.Length == 0)
label = null;
action.Parameters.Add (new IBActionParameter (label, param.Name, null, param.ReturnType.FullName));
}
if (MonoDevelop.DesignerSupport.CodeBehind.IsDesignerFile (meth.DeclaringType.CompilationUnit.FileName))
action.IsDesigner = true;
info.Actions.Add (action);
break;
}
}
}
示例2: AddType
internal static void AddType (ProjectDom dom, List<object> result, IType type, IMember callingMember, bool showStatic, Func<IMember, bool> filter)
{
// System.Console.WriteLine("Add Type:" + type);
if (type == null)
return;
if (showStatic && type.ClassType == ClassType.Enum) {
foreach (IMember member in type.Fields) {
result.Add (member);
}
return;
}
List<IType> accessibleStaticTypes = null;
if (callingMember != null && callingMember.DeclaringType != null)
accessibleStaticTypes = DomType.GetAccessibleExtensionTypes (dom, callingMember.DeclaringType.CompilationUnit);
/* TODO: Typed extension methods
IList<IReturnType> genericParameters = null;
if (type is InstantiatedType)
genericParameters = ((InstantiatedType)type).GenericParameters;*/
bool includeProtected = callingMember != null ? DomType.IncludeProtected (dom, type, callingMember.DeclaringType) : false;
if (accessibleStaticTypes != null) {
foreach (IMethod extensionMethod in type.GetAllExtensionMethods (accessibleStaticTypes))
result.Add (extensionMethod);
}
foreach (IType curType in dom.GetInheritanceTree (type)) {
if (curType.ClassType == ClassType.Interface && type.ClassType != ClassType.Interface && !(type is InstantiatedParameterType))
continue;
foreach (IMember member in curType.Members) {
if (callingMember != null && !member.IsAccessibleFrom (dom, type, callingMember, includeProtected))
continue;
// handled by member.IsAccessibleFrom
// if (member.IsProtected && !includeProtected)
// continue;
if (member is IMethod && (((IMethod)member).IsConstructor || ((IMethod)member).IsFinalizer))
continue;
if (!showStatic && member is IType)
continue;
if (filter != null && filter (member))
continue;
if (member is IType || !(showStatic ^ (member.IsStatic || member.IsConst))) {
result.Add (member);
}
}
// if (showStatic)
// break;
}
}
示例3: CollectMembers
internal static IEnumerable<INode> CollectMembers (ProjectDom dom, IMember member)
{
if (member is IMethod && ((IMethod)member).IsConstructor) {
yield return member;
} else {
bool isOverrideable = member.DeclaringType.ClassType == ClassType.Interface || member.IsOverride || member.IsVirtual || member.IsAbstract;
bool isLastMember = false;
// for members we need to collect the whole 'class' of members (overloads & implementing types)
HashSet<string> alreadyVisitedTypes = new HashSet<string> ();
foreach (IType type in dom.GetInheritanceTree (member.DeclaringType)) {
if (type.ClassType == ClassType.Interface || isOverrideable || type.DecoratedFullName == member.DeclaringType.DecoratedFullName) {
// search in the class for the member
foreach (IMember interfaceMember in type.SearchMember (member.Name, true)) {
if (interfaceMember.MemberType == member.MemberType)
yield return interfaceMember;
}
// now search in all subclasses of this class for the member
isLastMember = !member.IsOverride;
foreach (IType implementingType in dom.GetSubclasses (type)) {
string name = implementingType.DecoratedFullName;
if (alreadyVisitedTypes.Contains (name))
continue;
alreadyVisitedTypes.Add (name);
foreach (IMember typeMember in implementingType.SearchMember (member.Name, true)) {
if (typeMember.MemberType == member.MemberType) {
isLastMember = type.ClassType != ClassType.Interface && (typeMember.IsVirtual || typeMember.IsAbstract || !typeMember.IsOverride);
yield return typeMember;
}
}
if (!isOverrideable)
break;
}
if (isLastMember)
break;
}
}
}
}
示例4: IdentifierExistsInClass
public static bool IdentifierExistsInClass (ProjectDom parserContext, IType cls, string identifier)
{
foreach (IMember member in cls.Members)
if (member.Name == identifier)
return true;
return VisibleIdentifierExistsInBaseClasses (parserContext.GetInheritanceTree (cls), identifier);
}
示例5: GetCompatibleMethodsInClass
//TODO: check accessibility
public static IEnumerable<IMethod> GetCompatibleMethodsInClass (ProjectDom ctx, IType cls, IMethod matchMeth)
{
IList<IType>[] pars = new IList<IType>[matchMeth.Parameters.Count];
for (int i = 0; i < matchMeth.Parameters.Count; i++) {
IType t = ctx.GetType (matchMeth.Parameters[i].ReturnType);
if (t != null)
pars[i] = new List<IType> (ctx.GetInheritanceTree (t));
else
pars[i] = new IType[0];
}
foreach (IType type in ctx.GetInheritanceTree (cls)) {
if (type.ClassType != ClassType.Class)
continue;
foreach (IMethod method in type.Methods) {
if (method.IsPrivate || method.Parameters.Count != pars.Length || method.ReturnType.FullName != matchMeth.ReturnType.FullName
|| method.IsInternal)
continue;
bool allCompatible = true;
//compare each parameter
for (int i = 0; i < pars.Length; i++) {
bool parCompatible = false;
foreach (IType t in pars[i]) {
if (t.FullName == method.Parameters[i].ReturnType.FullName) {
parCompatible = true;
break;
}
}
if (!parCompatible) {
allCompatible = false;
break;
}
}
if (allCompatible)
yield return method;
}
}
}
示例6: ResolveTypes
void ResolveTypes (ProjectDom dom, NSObjectTypeInfo type)
{
NSObjectTypeInfo resolved;
if (type.BaseObjCType == null && type.BaseCliType != null) {
if (cliTypes.TryGetValue (type.BaseCliType, out resolved)) {
if (resolved.IsModel)
type.BaseIsModel = true;
type.BaseObjCType = resolved.ObjCName;
if (resolved.IsUserType)
type.UserTypeReferences.Add (resolved.ObjCName);
} else {
//managed classes many have implicitly registered base classes with a name not
//expressible in obj-c. In this case, the best we can do is walk down the
//hierarchy until we find a valid base class
foreach (var bt in dom.GetInheritanceTree (dom.GetType (type.BaseCliType))) {
if (cliTypes.TryGetValue (bt.FullName, out resolved)) {
if (resolved.IsModel)
type.BaseIsModel = true;
type.BaseObjCType = resolved.ObjCName;
if (resolved.IsUserType)
type.UserTypeReferences.Add (resolved.ObjCName);
break;
}
}
if (type.BaseObjCType == null)
Console.WriteLine ("Could not resolve CLI type '{0}'", type.BaseCliType);
}
}
if (type.BaseCliType == null && type.BaseObjCType != null) {
if (objcTypes.TryGetValue (type.BaseObjCType, out resolved))
type.BaseCliType = resolved.CliName;
}
foreach (var outlet in type.Outlets) {
if (outlet.ObjCType == null) {
if (cliTypes.TryGetValue (outlet.CliType, out resolved)) {
outlet.ObjCType = resolved.ObjCName;
if (resolved.IsUserType)
type.UserTypeReferences.Add (resolved.ObjCName);
}
}
if (outlet.CliType == null) {
if (objcTypes.TryGetValue (outlet.ObjCType, out resolved))
outlet.CliType = resolved.CliName;
}
}
foreach (var action in type.Actions) {
foreach (var param in action.Parameters) {
if (param.ObjCType == null) {
if (cliTypes.TryGetValue (param.CliType, out resolved)) {
param.ObjCType = resolved.ObjCName;
if (resolved.IsUserType)
type.UserTypeReferences.Add (resolved.ObjCName);
}
}
if (param.CliType == null) {
if (objcTypes.TryGetValue (param.ObjCType, out resolved))
param.CliType = resolved.CliName;
}
}
}
}