当前位置: 首页>>代码示例>>C#>>正文


C# INamespace.Resolve方法代码示例

本文整理汇总了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"));
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:57,代码来源:LoadNMM.cs

示例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];
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:NamespaceAssert.cs

示例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);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:Namespaces.cs

示例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);
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:14,代码来源:ResolveImports.cs

示例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);
     }
 }
开发者ID:boo-lang,项目名称:boo,代码行数:12,代码来源:Namespaces.cs

示例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);
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:28,代码来源:ResolveImports.cs

示例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();
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:7,代码来源:NameResolutionService.cs

示例8: Resolve

 public IEntity Resolve(INamespace ns, string name, EntityType elementType)
 {
     _buffer.Clear();
     ns.Resolve(_buffer, name, elementType);
     return GetEntityFromList(_buffer);
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:6,代码来源:NameResolutionService.cs


注:本文中的INamespace.Resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。