• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NamespaceDeclaration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NamespaceDeclaration的典型用法代码示例。如果您正苦于以下问题:C# NamespaceDeclaration类的具体用法?C# NamespaceDeclaration怎么用?C# NamespaceDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NamespaceDeclaration类属于命名空间,在下文中一共展示了NamespaceDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VerifyDefaultCtorWithComment

 public void VerifyDefaultCtorWithComment()
 {
     NamespaceDeclaration nsdecl = new NamespaceDeclaration("My.Stuff");
     nsdecl.AddClass("SomeClass")
         .AddConstructor("Initializes a new instance of SomeClass");
     new CodeBuilder().GenerateCode(Console.Out, nsdecl);
 }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:7,代码来源:ConstructorTests.cs


示例2: VerifyDefaultCtor

 public void VerifyDefaultCtor()
 {
     NamespaceDeclaration nsdecl = new NamespaceDeclaration("My.NS");
     nsdecl.AddClass("MyClass").AddConstructor();
     CodeBuilder builder = new CodeBuilder();
     builder.GenerateCode(Console.Out, nsdecl);
 }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:7,代码来源:ConstructorTests.cs


示例3: VisitNamespaceDeclaration

		public override void VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration)
		{
			AddUsings (namespaceDeclaration);
			if (!namespaceDeclaration.RBraceToken.IsNull)
				AddFolding (namespaceDeclaration.LBraceToken.GetPrevNode ().EndLocation, namespaceDeclaration.RBraceToken.EndLocation);
			base.VisitNamespaceDeclaration (namespaceDeclaration);
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:7,代码来源:FoldingVisitor.cs


示例4: Visit

			public override void Visit(ModuleContainer mc)
			{
				bool first = true;
				foreach (var container in mc.Containers) {
					var nspace = container as NamespaceContainer;
					if (nspace == null) {
						container.Accept(this);
						continue;
					}
					NamespaceDeclaration nDecl = null;
					var loc = LocationsBag.GetLocations(nspace);
					
					if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) {
						nDecl = new NamespaceDeclaration ();
						if (loc != null) {
							nDecl.AddChild(new CSharpTokenNode (Convert(loc [0]), Roles.NamespaceKeyword), Roles.NamespaceKeyword);
						}
						ConvertNamespaceName(nspace.RealMemberName, nDecl);
						if (loc != null && loc.Count > 1) {
							nDecl.AddChild(new CSharpTokenNode (Convert(loc [1]), Roles.LBrace), Roles.LBrace);
						}
						AddToNamespace(nDecl);
						namespaceStack.Push(nDecl);
					}
					
					if (nspace.Usings != null) {
						foreach (var us in nspace.Usings) {
							us.Accept(this);
						}
					}
					
					if (first) {
						first = false;
						if (mc.OptAttributes != null) {
							foreach (var attr in mc.OptAttributes.Sections) {
								unit.AddChild (ConvertAttributeSection (attr), SyntaxTree.MemberRole);
							}
						}
					}
					
					if (nspace.Containers != null) {
						foreach (var subContainer in nspace.Containers) {
							subContainer.Accept(this);
						}
					}
					if (nDecl != null) {
						AddAttributeSection (nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
						if (loc != null && loc.Count > 2)
							nDecl.AddChild (new CSharpTokenNode (Convert (loc [2]), Roles.RBrace), Roles.RBrace);
						if (loc != null && loc.Count > 3)
							nDecl.AddChild (new CSharpTokenNode (Convert (loc [3]), Roles.Semicolon), Roles.Semicolon);
						
						namespaceStack.Pop ();
					} else {
						AddAttributeSection (unit, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
					}
				}
				AddAttributeSection (unit, mc.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:59,代码来源:CSharpParser.cs


示例5: VerifySingleArg

        public void VerifySingleArg()
        {
            NamespaceDeclaration nsdecl = new NamespaceDeclaration("My.NS");
            nsdecl.AddClass("MyClass")
                .AddConstructor(typeof(int), "id", "_id");

            CodeBuilder builder = new CodeBuilder();
            builder.GenerateCode(Console.Out, nsdecl);
        }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:9,代码来源:ConstructorTests.cs


示例6: VisitNamespaceDeclaration

		public object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
		{
			if (module.Namespace != null) {
				AddError(namespaceDeclaration, "Only one namespace declaration per file is supported.");
				return null;
			}
			module.Namespace = new B.NamespaceDeclaration(GetLexicalInfo(namespaceDeclaration));
			module.Namespace.Name = namespaceDeclaration.Name;
			return namespaceDeclaration.AcceptChildren(this, data);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:10,代码来源:ConvertVisitorGlobal.cs


示例7: VerifyMultipleArgs

 public void VerifyMultipleArgs()
 {
     NamespaceDeclaration nsdecl = new NamespaceDeclaration("My.Stuff");
     nsdecl.AddClass("SomeClass")
             .AddConstructor("Initializes a new instance of SomeClass",
                 new ConstructorArg(typeof(int), "id", "_id", "ID of the person"),
                 new ConstructorArg(typeof(string), "name", "_name", "Name of the person")
             );
     new CodeBuilder().GenerateCode(Console.Out, nsdecl);
 }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:10,代码来源:ConstructorTests.cs


示例8: WriteNamespace

        private void WriteNamespace(NamespaceDeclaration namespaceDeclarationNode)
        {
            if (Bag.Current.Type != null)
            {
                Bag.PushScope();
            }

            var prefix = namespaceDeclarationNode.Prefix;
            var ns = namespaceDeclarationNode.Namespace;
            xamlTypeRepository.RegisterPrefix(new PrefixRegistration(prefix, ns));
        }
开发者ID:gitter-badger,项目名称:OmniXAML,代码行数:11,代码来源:ObjectAssembler.cs


示例9: ParseExpandedElement

        private IEnumerable<ProtoInstruction> ParseExpandedElement(XamlType xamlType, NamespaceDeclaration namespaceDeclaration, AttributeFeed attributes)
        {
            var element = instructionBuilder.NonEmptyElement(xamlType.UnderlyingType, namespaceDeclaration);
            foreach (var instruction in CommonNodesOfElement(xamlType, element, attributes)) yield return instruction;

            reader.Read();

            foreach (var instruction in ParseInnerTextIfAny()) yield return instruction;
            foreach (var instruction in ParseNestedElements(xamlType)) yield return instruction;

            yield return instructionBuilder.EndTag();
        }
开发者ID:modulexcite,项目名称:OmniXAML,代码行数:12,代码来源:ProtoInstructionParser.cs


示例10: VisitNamespaceDeclaration

        public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
        {
            var old = this.m_CurrentNamespace;
            if (this.m_CurrentNamespace == "")
                this.m_CurrentNamespace = namespaceDeclaration.Name;
            else
                this.m_CurrentNamespace += "." + namespaceDeclaration.Name;

            base.VisitNamespaceDeclaration(namespaceDeclaration);

            this.m_CurrentNamespace = old;
        }
开发者ID:hach-que,项目名称:cscjvm,代码行数:12,代码来源:JavaTypeVisitor.cs


示例11: AddNamespace

 public virtual void AddNamespace(string prefix, string uri)
 {
     if (uri == null)
     {
         throw new ArgumentNullException("uri");
     }
     if (prefix == null)
     {
         throw new ArgumentNullException("prefix");
     }
     prefix = this.nameTable.Add(prefix);
     uri = this.nameTable.Add(uri);
     if (Ref.Equal(this.xml, prefix) && !uri.Equals("http://www.w3.org/XML/1998/namespace"))
     {
         throw new ArgumentException(Res.GetString("Xml_XmlPrefix"));
     }
     if (Ref.Equal(this.xmlNs, prefix))
     {
         throw new ArgumentException(Res.GetString("Xml_XmlnsPrefix"));
     }
     int namespaceDecl = this.LookupNamespaceDecl(prefix);
     int previousNsIndex = -1;
     if (namespaceDecl != -1)
     {
         if (this.nsdecls[namespaceDecl].scopeId == this.scopeId)
         {
             this.nsdecls[namespaceDecl].uri = uri;
             return;
         }
         previousNsIndex = namespaceDecl;
     }
     if (this.lastDecl == (this.nsdecls.Length - 1))
     {
         NamespaceDeclaration[] destinationArray = new NamespaceDeclaration[this.nsdecls.Length * 2];
         Array.Copy(this.nsdecls, 0, destinationArray, 0, this.nsdecls.Length);
         this.nsdecls = destinationArray;
     }
     this.nsdecls[++this.lastDecl].Set(prefix, uri, this.scopeId, previousNsIndex);
     if (this.useHashtable)
     {
         this.hashTable[prefix] = this.lastDecl;
     }
     else if (this.lastDecl >= 0x10)
     {
         this.hashTable = new Dictionary<string, int>(this.lastDecl);
         for (int i = 0; i <= this.lastDecl; i++)
         {
             this.hashTable[this.nsdecls[i].prefix] = i;
         }
         this.useHashtable = true;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:XmlNamespaceManager.cs


示例12: VisitNamespace

		public override bool VisitNamespace(NamespaceDeclaration ns)
		{
			if (!identifierService.IsValidNamespaceName(ns.Name))
			{
				errorReport.Error( "TODOFILENAME", ns.Position, "'{0}' is an invalid namespace name.", ns.Name );

				return false;
			}

			ns.SymbolTable.CurrentNamespace = ns.SymbolTable.TypeGraphView.DefineNamespace(ns.Name);

			return base.VisitNamespace(ns);
		}
开发者ID:ralescano,项目名称:castle,代码行数:13,代码来源:DeclarationBinding.cs


示例13: Execute

		public override async void Execute(EditorRefactoringContext context)
		{
			SyntaxTree st = await context.GetSyntaxTreeAsync().ConfigureAwait(false);
			ICompilation compilation = await context.GetCompilationAsync().ConfigureAwait(false);
			CSharpFullParseInformation info = await context.GetParseInformationAsync().ConfigureAwait(false) as CSharpFullParseInformation;
			EntityDeclaration node = (EntityDeclaration)st.GetNodeAt(context.CaretLocation, n => n is TypeDeclaration || n is DelegateDeclaration);
			IDocument document = context.Editor.Document;
			
			FileName newFileName = FileName.Create(Path.Combine(Path.GetDirectoryName(context.FileName), MakeValidFileName(node.Name)));
			string header = CopyFileHeader(document, info);
			string footer = CopyFileEnd(document, info);
			
			AstNode newNode = node.Clone();
			
			foreach (var ns in node.Ancestors.OfType<NamespaceDeclaration>()) {
				var newNS = new NamespaceDeclaration(ns.Name);
				newNS.Members.AddRange(ns.Children.Where(ch => ch is UsingDeclaration
				                                         || ch is UsingAliasDeclaration
				                                         || ch is ExternAliasDeclaration).Select(usingDecl => usingDecl.Clone()));
				newNS.AddMember(newNode);
				newNode = newNS;
			}
			
			var topLevelUsings = st.Children.Where(ch => ch is UsingDeclaration
			                                       || ch is UsingAliasDeclaration
			                                       || ch is ExternAliasDeclaration);
			StringBuilder newCode = new StringBuilder(header);
			CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(newCode), FormattingOptionsFactory.CreateSharpDevelop());
			
			foreach (var topLevelUsing in topLevelUsings)
				topLevelUsing.AcceptVisitor(visitor);
			
			newNode.AcceptVisitor(visitor);
			
			newCode.AppendLine(footer);
			
			IViewContent viewContent = FileService.NewFile(newFileName, newCode.ToString());
			viewContent.PrimaryFile.SaveToDisk(newFileName);
			// now that the code is saved in the other file, remove it from the original document
			RemoveExtractedNode(context, node);
			
			IProject project = (IProject)compilation.GetProject();
			if (project != null) {
				FileProjectItem projectItem = new FileProjectItem(project, ItemType.Compile);
				projectItem.FileName = newFileName;
				ProjectService.AddProjectItem(project, projectItem);
				FileService.FireFileCreated(newFileName, false);
				project.Save();
				ProjectBrowserPad.RefreshViewAsync();
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:51,代码来源:MoveTypeToFileContextAction.cs


示例14: AddChildTypeDeclaration

        public static void AddChildTypeDeclaration(this AstNode tree, TypeDeclaration newClass,
            NamespaceDeclaration parentNamespace = null)
        {
            if (null != parentNamespace)
            {
                var newNamespaceNode = new NamespaceDeclaration(
                    parentNamespace.Name);

                newNamespaceNode.AddMember(newClass);

                tree.AddChild(newNamespaceNode, SyntaxTree.MemberRole);
            }
            else
            {
                tree.AddChild(newClass, Roles.TypeMemberRole);
            }
        }
开发者ID:prescottadam,项目名称:pMixins,代码行数:17,代码来源:SyntaxTreeExtensions.cs


示例15: VisitNamespaceDeclaration

        public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
        {
            FixOpenBrace(policy.NamespaceBraceStyle, namespaceDeclaration.LBraceToken);
            if (policy.IndentNamespaceBody)
                curIndent.Push(IndentType.Block);

            bool first = true;
            bool startFormat = false;
            VisitChildrenToFormat(namespaceDeclaration, child => {
                if (first) {
                    startFormat = child.StartLocation > namespaceDeclaration.LBraceToken.StartLocation;
                }
                if (child.Role == Roles.LBrace) {
                    var next = child.GetNextSibling(NoWhitespacePredicate);
                    var blankLines = 1;
                    if (next is UsingDeclaration || next is UsingAliasDeclaration) {
                        blankLines += policy.BlankLinesBeforeUsings;
                    } else {
                        blankLines += policy.BlankLinesBeforeFirstDeclaration;
                    }
                    EnsureNewLinesAfter(child, blankLines);
                    startFormat = true;
                    return;
                }
                if (child.Role == Roles.RBrace) {
                    startFormat = false;
                    return;
                }
                if (!startFormat || !NoWhitespacePredicate (child))
                    return;
                if (first && (child is UsingDeclaration || child is UsingAliasDeclaration)) {
                    // TODO: policy.BlankLinesBeforeUsings
                    first = false;
                }
                if (NoWhitespacePredicate(child))
                    FixIndentationForceNewLine(child);
                child.AcceptVisitor(this);
                if (NoWhitespacePredicate(child))
                    EnsureNewLinesAfter(child, GetGlobalNewLinesFor(child));
            });

            if (policy.IndentNamespaceBody)
                curIndent.Pop();

            FixClosingBrace(policy.NamespaceBraceStyle, namespaceDeclaration.RBraceToken);
        }
开发者ID:JoostK,项目名称:NRefactory,代码行数:46,代码来源:FormattingVisitor_Global.cs


示例16: VisitNamespaceDeclaration

        public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
        {
            if (!String.IsNullOrEmpty(this.Namespace))
            {
                throw (EmitterException)this.CreateException(namespaceDeclaration, "Nested namespaces are not supported");
            }

            ValidateNamespace(namespaceDeclaration);

            var prevNamespace = this.Namespace;

            this.Namespace = namespaceDeclaration.Name;

            namespaceDeclaration.AcceptChildren(this);

            this.Namespace = prevNamespace;
        }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:17,代码来源:Inspector.Visitor.cs


示例17: Dynamize

		/// <summary>
		/// Dynamizes a given compile unit.
		/// </summary>
		public CompilationUnit Dynamize(CompilationUnit unit)
		{
			CompilationUnit out_unit = new CompilationUnit();

			// add Phalanger imports
			Utility.AddImport(unit, out_unit, "PHP.Core");
			Utility.AddImport(unit, out_unit, "PHP.Core.Reflection");

			foreach (INode node in unit.Children)
			{
				// add all original imports
				if (node is UsingDeclaration) out_unit.Children.Add(node);

				// process namespaces
				NamespaceDeclaration ns_decl = node as NamespaceDeclaration;
				if (ns_decl != null)
				{
					NamespaceDeclaration out_ns_decl = new NamespaceDeclaration(ns_decl.Name);
					out_unit.Children.Add(out_ns_decl);

					foreach (INode subnode in ns_decl.Children)
					{
						TypeDeclaration type_decl = subnode as TypeDeclaration;
						if (type_decl != null)
						{
							type_decl = Dynamize(type_decl);
							if (type_decl != null) out_ns_decl.Children.Add(type_decl);
						}
					}
				}

				// as well as top-level types without namespaces
				TypeDeclaration bare_type_decl = node as TypeDeclaration;
				if (bare_type_decl != null)
				{
					bare_type_decl = Dynamize(bare_type_decl);
					if (bare_type_decl != null) out_unit.Children.Add(bare_type_decl);
				}
			}

			return out_unit;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:45,代码来源:Dynamizer.cs


示例18: ParseNestedProperty

        private IEnumerable<ProtoInstruction> ParseNestedProperty(XamlType xamlType)
        {
            var propertyLocator = PropertyLocator.Parse(reader.Name);
            var namespaceDeclaration = new NamespaceDeclaration(reader.Namespace, reader.Prefix);

            yield return InjectPropertyInstruction(xamlType, propertyLocator, namespaceDeclaration);

            reader.Read();

            foreach (var p in ParseInnerTextIfAny()) yield return p;

            SkipWhitespaces();

            if (reader.NodeType != XmlNodeType.EndElement)
            {
                foreach (var instruction in ParseChildren()) { yield return instruction; }
            }

            yield return instructionBuilder.EndTag();
        }
开发者ID:modulexcite,项目名称:OmniXAML,代码行数:20,代码来源:ProtoInstructionParser.cs


示例19: ConvertAttributeToNode

        private ProtoXamlNode ConvertAttributeToNode(XamlType containingType, UnprocessedAttribute rawAttribute)
        {
            MutableXamlMember member;

            if (rawAttribute.Locator.IsDotted)
            {
                var ownerName = rawAttribute.Locator.Owner.PropertyName;
                var ownerPrefix = rawAttribute.Locator.Owner.Prefix;

                var owner = wiringContext.TypeContext.GetByPrefix(ownerPrefix, ownerName);

                member = owner.GetAttachableMember(rawAttribute.Locator.PropertyName);
            }
            else
            {
                member = containingType.GetMember(rawAttribute.Locator.PropertyName);
            }

            var namespaceDeclaration = new NamespaceDeclaration(rawAttribute.Locator.Namespace, rawAttribute.Locator.Prefix);
            return nodeBuilder.Attribute(member, rawAttribute.Value, namespaceDeclaration);
        }
开发者ID:danwalmsley,项目名称:OmniXAML,代码行数:21,代码来源:SuperProtoParser.cs


示例20: ConvertAttributeToNode

        // TODO: Refactor this shit.
        private ProtoXamlInstruction ConvertAttributeToNode(XamlType containingType, AttributeAssignment rawAttributeAssignment)
        {
            MutableXamlMember member;

            if (rawAttributeAssignment.Locator.IsDotted)
            {
                member = GetMemberForDottedLocator(rawAttributeAssignment.Locator);
            }
            else
            {
                if (IsNameDirective(rawAttributeAssignment.Locator, containingType))
                {
                    return instructionBuilder.Directive(CoreTypes.Name, rawAttributeAssignment.Value);
                }

                member = containingType.GetMember(rawAttributeAssignment.Locator.PropertyName);
            }

            var namespaceDeclaration = new NamespaceDeclaration(rawAttributeAssignment.Locator.Namespace, rawAttributeAssignment.Locator.Prefix);
            return instructionBuilder.Attribute(member, rawAttributeAssignment.Value, namespaceDeclaration.Prefix);
        }
开发者ID:furesoft,项目名称:OmniXAML,代码行数:22,代码来源:XamlProtoInstructionParser.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NamespaceManager类代码示例发布时间:2022-05-24
下一篇:
C# Namespace类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap