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


C# NamespaceDeclaration类代码示例

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


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


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