本文整理汇总了C#中Mono.CSharp.MemberAccess.ResolveAsType方法的典型用法代码示例。如果您正苦于以下问题:C# MemberAccess.ResolveAsType方法的具体用法?C# MemberAccess.ResolveAsType怎么用?C# MemberAccess.ResolveAsType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.MemberAccess
的用法示例。
在下文中一共展示了MemberAccess.ResolveAsType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveBaseTypes
/// <summary>
/// This function computes the Base class and also the
/// list of interfaces that the class or struct @c implements.
///
/// The return value is an array (might be null) of
/// interfaces implemented (as Types).
///
/// The @base_class argument is set to the base object or null
/// if this is `System.Object'.
/// </summary>
protected virtual TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class)
{
// PlayScript will default to the "_root.Object" base class.. not null.
if (this.Location.SourceFile != null &&
this.Location.SourceFile.FileType == SourceFileType.PlayScript &&
this is Class && !this.IsStatic) {
base_class = new MemberAccess(new SimpleName(PsConsts.PsRootNamespace, Location), "Object");
base_type = base_class.ResolveAsType (new BaseContext (this));
if (base_type == null)
base_class = null;
} else {
base_class = null;
}
if (type_bases == null)
return null;
int count = type_bases.Count;
TypeSpec[] ifaces = null;
var base_context = new BaseContext (this);
for (int i = 0, j = 0; i < count; i++){
FullNamedExpression fne = type_bases [i];
var fne_resolved = fne.ResolveAsType (base_context);
if (fne_resolved == null)
continue;
if (i == 0 && Kind == MemberKind.Class && !fne_resolved.IsInterface) {
if (fne_resolved.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
Report.Error (1965, Location, "Class `{0}' cannot derive from the dynamic type",
GetSignatureForError ());
continue;
}
base_type = fne_resolved;
base_class = fne;
continue;
}
if (ifaces == null)
ifaces = new TypeSpec [count - i];
if (fne_resolved.IsInterface) {
for (int ii = 0; ii < j; ++ii) {
if (fne_resolved == ifaces [ii]) {
Report.Error (528, Location, "`{0}' is already listed in interface list",
fne_resolved.GetSignatureForError ());
break;
}
}
if (Kind == MemberKind.Interface && !IsAccessibleAs (fne_resolved)) {
Report.Error (61, fne.Location,
"Inconsistent accessibility: base interface `{0}' is less accessible than interface `{1}'",
fne_resolved.GetSignatureForError (), GetSignatureForError ());
}
} else {
Report.SymbolRelatedToPreviousError (fne_resolved);
if (Kind != MemberKind.Class) {
Report.Error (527, fne.Location, "Type `{0}' in interface list is not an interface", fne_resolved.GetSignatureForError ());
} else if (base_class != null)
Report.Error (1721, fne.Location, "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')",
GetSignatureForError (), base_class.GetSignatureForError (), fne_resolved.GetSignatureForError ());
else {
Report.Error (1722, fne.Location, "`{0}': Base class `{1}' must be specified as first",
GetSignatureForError (), fne_resolved.GetSignatureForError ());
}
}
ifaces [j++] = fne_resolved;
}
return ifaces;
}