本文整理汇总了C#中INamespace.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# INamespace.Resolve方法的具体用法?C# INamespace.Resolve怎么用?C# INamespace.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamespace
的用法示例。
在下文中一共展示了INamespace.Resolve方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadNMeta
public void LoadNMeta()
{
EPackage package;
package = EcoreInterop.LoadPackageFromFile("NMeta.ecore");
Assert.IsNotNull(package);
metaNamespace = EcoreInterop.Transform2Meta(package);
var boolean = metaNamespace.Resolve(new Uri("Boolean", UriKind.Relative));
var isInterface = metaNamespace.Resolve(new Uri("Class/IsInterface", UriKind.Relative)) as IAttribute;
//var serializer = new ModelSerializer();
//serializer.RootPrefix = "nmeta";
//using (var sw = new FileStream(@"C:\Projekte\NMF\NMeta.nmf", FileMode.OpenOrCreate))
//{
// serializer.Serialize(metaNamespace.Model, sw);
//}
Assert.IsNotNull(metaNamespace);
Assert.AreEqual(20, metaNamespace.Types.OfType<IClass>().Count());
type = GetClass("Type");
@class = GetClass("Class");
structuredType = GetClass("StructuredType");
typedElement = GetClass("ITypedElement");
metaElement = GetClass("MetaElement");
attribute = GetClass("Attribute");
reference = GetClass("Reference");
referenceType = GetClass("ReferenceType");
dataType = GetClass("DataType");
primitiveType = GetClass("PrimitiveType");
@namespace = GetClass("Namespace");
extension = GetClass("Extension");
@event = GetClass("Event");
operation = GetClass("Operation");
parameter = GetClass("Parameter");
enumeration = GetClass("Enumeration");
literal = GetClass("Literal");
modelElement = GetClass("ModelElement");
direction = metaNamespace.Types.OfType<IEnumeration>().FirstOrDefault(en => en.Name == "Direction");
Assert.IsNotNull(direction);
direction.Literals.Select(l => l.Name).AssertSequence("In", "Out", "InOut");
AssertBaseTypes();
AssertProperties();
var model = metaNamespace.Model;
Assert.IsNotNull(model);
Assert.AreSame(type, model.Resolve("#//Type"));
Assert.AreSame(@class, model.Resolve("#//Class"));
Assert.AreSame(structuredType, model.Resolve("#//StructuredType"));
}
示例2: ResolveSingle
public static IEntity ResolveSingle(INamespace root, string name)
{
var resolved = new List<IEntity>();
Assert.IsTrue(root.Resolve(resolved, name, EntityType.Any), "Failed to resolve '{0}' against '{1}'", name, root);
Assert.AreEqual(1, resolved.Count);
return resolved[0];
}
示例3: ResolveCoalescingNamespaces
public static bool ResolveCoalescingNamespaces(INamespace parent, INamespace namespaceToResolveAgainst, string name, EntityType typesToConsider, ICollection<IEntity> resultingSet)
{
var resolved = new Set<IEntity>();
if (!namespaceToResolveAgainst.Resolve(resolved, name, typesToConsider))
return false;
return CoalesceResolved(resolved, parent, name, resultingSet);
}
示例4: SelectiveImportFor
private INamespace SelectiveImportFor(INamespace ns, MethodInvocationExpression selectiveImportSpec)
{
var importedNames = selectiveImportSpec.Arguments;
var entities = new List<IEntity>(importedNames.Count);
foreach (ReferenceExpression nameExpression in importedNames)
{
var name = nameExpression.Name;
if (!ns.Resolve(entities, name, EntityType.Any))
Errors.Add(
CompilerErrorFactory.MemberNotFound(
nameExpression, name, ns, NameResolutionService.GetMostSimilarMemberName(ns, name, EntityType.Any)));
}
return new SimpleNamespace(null, entities);
}
示例5: ResolveCoalescingNamespaces
public static bool ResolveCoalescingNamespaces(INamespace parent, INamespace namespaceToResolveAgainst, string name, EntityType typesToConsider, ICollection<IEntity> resultingSet)
{
var resolved = AcquireSet();
try {
if (!namespaceToResolveAgainst.Resolve(resolved, name, typesToConsider))
return false;
return CoalesceResolved(resolved, parent, name, resultingSet);
}
finally {
ReleaseSet(resolved);
}
}
示例6: SelectiveImportFor
private INamespace SelectiveImportFor(INamespace ns, MethodInvocationExpression selectiveImportSpec)
{
var importedNames = selectiveImportSpec.Arguments;
var entities = new List<IEntity>(importedNames.Count);
var aliases = new Dictionary<string,string>(importedNames.Count);
foreach (Expression nameExpression in importedNames)
{
string name;
if (nameExpression is ReferenceExpression) {
name = (nameExpression as ReferenceExpression).Name;
aliases[name] = name;
} else {
var tce = nameExpression as TryCastExpression;
var alias = (tce.Type as SimpleTypeReference).Name;
name = (tce.Target as ReferenceExpression).Name;
aliases[alias] = name;
// Remove the trycast expression, otherwise it gets processed in later steps
tce.Target.Annotate("alias", alias);
importedNames.Replace(nameExpression, tce.Target);
}
if (!ns.Resolve(entities, name, EntityType.Any))
Errors.Add(
CompilerErrorFactory.MemberNotFound(
nameExpression, name, ns, NameResolutionService.GetMostSimilarMemberName(ns, name, EntityType.Any)));
}
return new SimpleNamespace(null, entities, aliases);
}
示例7: ResolveExtensionForType
private IEntity ResolveExtensionForType(INamespace ns, IType type, string name)
{
_buffer.Clear();
if (!ns.Resolve(_buffer, name, EntityType.Method|EntityType.Property)) return null;
_buffer.RemoveAll(new Predicate(new IsNotExtensionOf(type).Match));
return GetEntityFromBuffer();
}
示例8: Resolve
public IEntity Resolve(INamespace ns, string name, EntityType elementType)
{
_buffer.Clear();
ns.Resolve(_buffer, name, elementType);
return GetEntityFromList(_buffer);
}