本文整理汇总了C#中IMemberContext.LookupNamespaceOrType方法的典型用法代码示例。如果您正苦于以下问题:C# IMemberContext.LookupNamespaceOrType方法的具体用法?C# IMemberContext.LookupNamespaceOrType怎么用?C# IMemberContext.LookupNamespaceOrType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMemberContext
的用法示例。
在下文中一共展示了IMemberContext.LookupNamespaceOrType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveMemberName
FullNamedExpression ResolveMemberName (IMemberContext context, MemberName mn)
{
if (mn.Left == null)
return context.LookupNamespaceOrType (mn.Name, mn.Arity, LookupMode.Probing, Location.Null);
var left = ResolveMemberName (context, mn.Left);
var ns = left as Namespace;
if (ns != null)
return ns.LookupTypeOrNamespace (context, mn.Name, mn.Arity, LookupMode.Probing, Location.Null);
TypeExpr texpr = left as TypeExpr;
if (texpr != null) {
var found = MemberCache.FindNestedType (texpr.Type, ParsedName.Name, ParsedName.Arity);
if (found != null)
return new TypeExpression (found, Location.Null);
return null;
}
return left;
}
示例2: ResolveAsTypeStep
public override FullNamedExpression ResolveAsTypeStep(IMemberContext ec, bool silent)
{
int errors = ec.Compiler.Report.Errors;
FullNamedExpression fne = ec.LookupNamespaceOrType (Name, Arity, loc, /*ignore_cs0104=*/ false);
if (fne != null) {
if (HasTypeArguments && fne.Type != null && TypeManager.IsGenericType (fne.Type)) {
GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
return ct.ResolveAsTypeStep (ec, false);
}
return fne;
}
if (!HasTypeArguments && Name == "dynamic" &&
RootContext.Version > LanguageVersion.V_3 &&
RootContext.MetadataCompatibilityVersion > MetadataVersion.v2) {
if (!PredefinedAttributes.Get.Dynamic.IsDefined) {
ec.Compiler.Report.Error (1980, Location,
"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?",
PredefinedAttributes.Get.Dynamic.GetSignatureForError ());
}
return new DynamicTypeExpr (loc);
}
if (silent || errors != ec.Compiler.Report.Errors)
return null;
Error_TypeOrNamespaceNotFound (ec);
return null;
}
示例3: Error_TypeOrNamespaceNotFound
protected virtual void Error_TypeOrNamespaceNotFound(IMemberContext ec)
{
if (ec.CurrentType != null) {
if (ec.CurrentMemberDefinition != null) {
MemberCore mc = ec.CurrentMemberDefinition.Parent.GetDefinition (Name);
if (mc != null) {
Error_UnexpectedKind (ec.Compiler.Report, mc, "type", GetMemberType (mc), loc);
return;
}
}
/*
// TODO MemberCache: Implement
string ns = ec.CurrentType.Namespace;
string fullname = (ns.Length > 0) ? ns + "." + Name : Name;
foreach (Assembly a in GlobalRootNamespace.Instance.Assemblies) {
var type = a.GetType (fullname);
if (type != null) {
ec.Compiler.Report.SymbolRelatedToPreviousError (type);
Expression.ErrorIsInaccesible (loc, TypeManager.CSharpName (type), ec.Compiler.Report);
return;
}
}
if (ec.CurrentTypeDefinition != null) {
TypeSpec t = ec.CurrentTypeDefinition.LookupAnyGeneric (Name);
if (t != null) {
Namespace.Error_InvalidNumberOfTypeArguments (ec.Compiler.Report, t, loc);
return;
}
}
*/
}
FullNamedExpression retval = ec.LookupNamespaceOrType (Name, -System.Math.Max (1, Arity), loc, true);
if (retval != null) {
Error_TypeArgumentsCannotBeUsed (ec.Compiler.Report, loc, retval.Type, Arity);
/*
var te = retval as TypeExpr;
if (HasTypeArguments && te != null && !te.Type.IsGeneric)
retval.Error_TypeArgumentsCannotBeUsed (ec.Compiler.Report, loc);
else
Namespace.Error_InvalidNumberOfTypeArguments (ec.Compiler.Report, retval.Type, loc);
*/
return;
}
NamespaceEntry.Error_NamespaceNotFound (loc, Name, ec.Compiler.Report);
}
示例4: IdenticalNameAndTypeName
public bool IdenticalNameAndTypeName(IMemberContext mc, Expression resolved_to, Location loc)
{
if (resolved_to == null || resolved_to.Type == null)
return false;
if (resolved_to.Type is ElementTypeSpec || resolved_to.Type is InternalType)
return false;
return resolved_to.Type.Name == Name &&
(mc.LookupNamespaceOrType (Name, Arity, loc, /* ignore_cs0104 = */ true) != null);
}
示例5: ResolveMemberName
FullNamedExpression ResolveMemberName (IMemberContext context, MemberName mn)
{
// FIXME: Default namespace lookups to C# resolution semantics (for now). Need a way to determine if PlayScript absolute
// namespace lookups should be used here.
bool absolute_ns = false;
if (mn.Left == null)
return context.LookupNamespaceOrType (mn.Name, mn.Arity, LookupMode.Probing, absolute_ns, Location.Null);
var left = ResolveMemberName (context, mn.Left);
var ns = left as Namespace;
if (ns != null)
return ns.LookupTypeOrNamespace (context, mn.Name, mn.Arity, LookupMode.Probing, Location.Null);
TypeExpr texpr = left as TypeExpr;
if (texpr != null) {
var found = MemberCache.FindNestedType (texpr.Type, ParsedName.Name, ParsedName.Arity);
if (found != null)
return new TypeExpression (found, Location.Null);
return null;
}
return left;
}
示例6: Error_TypeOrNamespaceNotFound
protected virtual void Error_TypeOrNamespaceNotFound (IMemberContext ec)
{
if (ec.CurrentType != null) {
if (ec.CurrentTypeDefinition != null) {
MemberCore mc = ec.CurrentTypeDefinition.GetDefinition (Name);
if (mc != null) {
Error_UnexpectedKind (ec.Compiler.Report, mc, "type", GetMemberType (mc), loc);
return;
}
}
string ns = ec.CurrentType.Namespace;
string fullname = (ns.Length > 0) ? ns + "." + Name : Name;
foreach (Assembly a in GlobalRootNamespace.Instance.Assemblies) {
Type type = a.GetType (fullname);
if (type != null) {
ec.Compiler.Report.SymbolRelatedToPreviousError (type);
Expression.ErrorIsInaccesible (loc, TypeManager.CSharpName (type), ec.Compiler.Report);
return;
}
}
if (ec.CurrentTypeDefinition != null) {
Type t = ec.CurrentTypeDefinition.LookupAnyGeneric (Name);
if (t != null) {
Namespace.Error_InvalidNumberOfTypeArguments (t, loc);
return;
}
}
}
if (targs != null) {
FullNamedExpression retval = ec.LookupNamespaceOrType (SimpleName.RemoveGenericArity (Name), loc, true);
if (retval != null) {
Namespace.Error_TypeArgumentsCannotBeUsed (retval, loc);
return;
}
}
NamespaceEntry.Error_NamespaceNotFound (loc, Name, ec.Compiler.Report);
}
示例7: ResolveAsTypeStep
public override FullNamedExpression ResolveAsTypeStep (IMemberContext ec, bool silent)
{
int errors = ec.Compiler.Report.Errors;
FullNamedExpression fne = ec.LookupNamespaceOrType (Name, loc, /*ignore_cs0104=*/ false);
if (fne != null) {
if (fne.Type == null)
return fne;
FullNamedExpression nested = ResolveNested (fne.Type);
if (nested != null)
return nested.ResolveAsTypeStep (ec, false);
if (targs != null) {
if (TypeManager.IsGenericType (fne.Type)) {
GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
return ct.ResolveAsTypeStep (ec, false);
}
Namespace.Error_TypeArgumentsCannotBeUsed (fne, loc);
}
return fne;
}
if (!HasTypeArguments && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3)
return new DynamicTypeExpr (loc);
if (silent || errors != ec.Compiler.Report.Errors)
return null;
Error_TypeOrNamespaceNotFound (ec);
return null;
}
示例8: IdenticalNameAndTypeName
public bool IdenticalNameAndTypeName (IMemberContext mc, Expression resolved_to, Location loc)
{
return resolved_to != null && resolved_to.Type != null &&
resolved_to.Type.Name == Name &&
(mc.LookupNamespaceOrType (Name, loc, /* ignore_cs0104 = */ true) != null);
}