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


C# CodeDom.CodeNamespaceImport类代码示例

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


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

示例1: CodeGenUtil

        private CodeGenUtil()
        {
            NamespaceImports = new CodeNamespaceImport[] {
                new CodeNamespaceImport("System"),
                new CodeNamespaceImport("System.Collections.Generic"),
                new CodeNamespaceImport("System.Text"),
                new CodeNamespaceImport("Avro"),
                new CodeNamespaceImport("Avro.Specific") };

            FileComment = new CodeCommentStatement(
            @"------------------------------------------------------------------------------
             <auto-generated>
            Generated by " + System.AppDomain.CurrentDomain.FriendlyName + ", version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version + @"
            Changes to this file may cause incorrect behavior and will be lost if code
            is regenerated
             </auto-generated>
             ------------------------------------------------------------------------------");

            // Visual Studio 2010 http://msdn.microsoft.com/en-us/library/x53a06bb.aspx
            ReservedKeywords = new HashSet<string>() {
                "abstract","as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class",
                "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event",
                "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if",
                "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new",
                "null", "object", "operator", "out", "override", "params", "private", "protected", "public",
                "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static",
                "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong",
                "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "value", "partial" };
        }
开发者ID:torgebo,项目名称:avro,代码行数:29,代码来源:CodeGenUtil.cs

示例2: BuildProgram

        static CodeNamespace BuildProgram()
        {
            // namespaceの作成
            var ns = new CodeNamespace("MetaWorld");
            // import編成
            var systemImport = new CodeNamespaceImport("System");
            // class作成
            var programClass = new CodeTypeDeclaration("Program");

            // mainメソッドの定義
            var methodMain = new CodeMemberMethod()
            {
                Attributes = MemberAttributes.Static,
                Name = "Main"
            };
            methodMain.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeSnippetExpression("Console"),
                    "WriteLine",
                    new CodePrimitiveExpression("Hello World")
                    )
                );

            // コード構造の編成
            programClass.Members.Add(methodMain);
            ns.Imports.Add(systemImport);
            ns.Types.Add(programClass);
            return ns;
        }
开发者ID:read-only-man,项目名称:Cs,代码行数:29,代码来源:HelloWorldCodeDOM.cs

示例3: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            // Try to find the namespace in the existing imports
            string ns = Namespace;
            if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
            {
                ns = ns.Substring(1);
            }

            CodeNamespaceImport import = context.Namespace
                .Imports
                .OfType<CodeNamespaceImport>()
                .Where(i => String.Equals(i.Namespace, ns.Trim(), StringComparison.Ordinal))
                .FirstOrDefault();

            if (import == null)
            {
                // It doesn't exist, create it
                import = new CodeNamespaceImport(ns);
                context.Namespace.Imports.Add(import);
            }

            // Attach our info to the existing/new import.
            import.LinePragma = context.GenerateLinePragma(target);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:25,代码来源:AddImportCodeGenerator.cs

示例4: Add

 public void Add(CodeNamespaceImport value)
 {
     if (!_keys.ContainsKey(value.Namespace))
     {
         _keys[value.Namespace] = value;
         _data.Add(value);
     }
 }
开发者ID:Corillian,项目名称:corefx,代码行数:8,代码来源:CodeNamespaceImportCollection.cs

示例5: Add

 public void Add(CodeNamespaceImport value)
 {
     if (!this.keys.ContainsKey(value.Namespace))
     {
         this.keys[value.Namespace] = value;
         this.data.Add(value);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:CodeNamespaceImportCollection.cs

示例6: SqlTypesSchemaImporterExtensionHelper

 public SqlTypesSchemaImporterExtensionHelper(string name,
                                               string targetNamespace,
                                               string[] references,
                                               CodeNamespaceImport[] namespaceImports,
                                               string destinationType,
                                               bool direct) {
      Init(name, targetNamespace, references, namespaceImports, destinationType, direct);
  }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:SqlTypesSchemaImporter.cs

示例7: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeNamespaceImport cni = new CodeNamespaceImport ("mono");
			Assert.IsNull (cni.LinePragma, "LinePragma");
			cni.LinePragma = new CodeLinePragma (String.Empty, Int32.MinValue);
			Assert.AreEqual ("mono", cni.Namespace, "Namespace");
			cni.Namespace = String.Empty;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeNamespaceImportCas.cs

示例8: CodeNamespaceImport

 void IXamlFileGenerationData.addImports(CodeNamespace ns)
 {
     CodeNamespaceImport anImport;
     if (this.isRegularWindow)
         anImport = new CodeNamespaceImport("System.Windows");
     else
         anImport = new CodeNamespaceImport("System.Windows.Navigation");
     ns.Imports.Add(anImport);
 }
开发者ID:surak8,项目名称:ProjectGen,代码行数:9,代码来源:WinDataProvider.cs

示例9: AddNamespace

        private static CodeNamespace AddNamespace(CodeCompileUnit compileUnit)
        {
            var codeNamespace = new CodeNamespace("Scripts");

            var systemImport = new CodeNamespaceImport("System");
            codeNamespace.Imports.Add(systemImport);

            compileUnit.Namespaces.Add(codeNamespace);
            return codeNamespace;
        }
开发者ID:andyhebear,项目名称:NScripto,代码行数:10,代码来源:CSharpScriptCompiler.cs

示例10: AddRange

 public void AddRange(CodeNamespaceImport[] value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     foreach (CodeNamespaceImport import in value)
     {
         this.Add(import);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:CodeNamespaceImportCollection.cs

示例11: AddRange

        public void AddRange(CodeNamespaceImport[] value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            foreach (CodeNamespaceImport c in value)
            {
                Add(c);
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:12,代码来源:CodeNamespaceImportCollection.cs

示例12: Constructor1

		public void Constructor1 ()
		{
			string ns = "mono";

			CodeNamespaceImport cni = new CodeNamespaceImport (ns);
			Assert.IsNull (cni.LinePragma, "#1");
			Assert.IsNotNull (cni.Namespace, "#2");
			Assert.AreSame (ns, cni.Namespace, "#3");

			cni = new CodeNamespaceImport ((string) null);
			Assert.IsNotNull (cni.Namespace, "#4");
			Assert.AreEqual (string.Empty, cni.Namespace, "#5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CodeNamespaceImportTest.cs

示例13: GenerateFactoryClass

        public static CodeNamespace GenerateFactoryClass(IClassMap classMap)
        {
            CodeNamespace domainNamespace = new CodeNamespace(classMap.DomainMap.RootNamespace + ".Factories" ) ;
            CodeTypeDeclaration classDecl = new CodeTypeDeclaration(GetFactoryClassName(classMap)) ;

            CodeNamespaceImport import = new CodeNamespaceImport(classMap.GetFullNamespace()) ;
            CodeNamespaceImport importNPersist = new CodeNamespaceImport("Puzzle.NPersist.Framework") ;
            domainNamespace.Imports.Add(import);
            domainNamespace.Imports.Add(importNPersist);

            classDecl.IsClass = true;

            GenerateConstructor(classDecl);
            GenerateContextField(classDecl);
            GenerateFactoryMethods(classMap, classDecl);

            domainNamespace.Types.Add(classDecl);

            return domainNamespace;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:20,代码来源:CodeDomGenerator.cs

示例14: BuildNamespace

		protected virtual void BuildNamespace (CodeNamespace codeNamespace)
		{

			CodeTypeDeclaration codeType = new CodeTypeDeclaration {
            Name = GeneratedTypeName,
            IsClass = true
         };

			foreach (ParsedValue<string> item in this.parser.Namespaces) {
            
				CodeNamespaceImport import = new CodeNamespaceImport (item.Value);

				if (item.FileName != null) 
					import.LinePragma = new CodeLinePragma (item.FileName, item.LineNumber);

				codeNamespace.Imports.Add (import);
			}

			BuildPageClass (codeType);

			codeNamespace.Types.Add (codeType);
		}
开发者ID:nuxleus,项目名称:Nuxleus,代码行数:22,代码来源:BasePageCodeDomTreeGenerator.cs

示例15: AddRange

		public void AddRange ()
		{
			CodeNamespaceImport ni1 = new CodeNamespaceImport ("A");
			CodeNamespaceImport ni2 = new CodeNamespaceImport ("B");
			CodeNamespaceImport ni3 = new CodeNamespaceImport ("b");
			CodeNamespaceImport ni4 = new CodeNamespaceImport ("B");
			CodeNamespaceImport ni5 = new CodeNamespaceImport ("C");

			CodeNamespaceImportCollection coll = new CodeNamespaceImportCollection ();
			coll.AddRange (new CodeNamespaceImport[] {ni1, ni2});
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, ((IList) coll).IndexOf (ni1), "#2");
			Assert.AreEqual (1, ((IList) coll).IndexOf (ni2), "#3");

			coll.AddRange (new CodeNamespaceImport[] { ni3, ni4, ni5 });
			Assert.AreEqual (3, coll.Count, "#4");
			Assert.AreEqual (0, ((IList) coll).IndexOf (ni1), "#5");
			Assert.AreEqual (1, ((IList) coll).IndexOf (ni2), "#6");
			Assert.AreEqual (-1, ((IList) coll).IndexOf (ni3), "#7");
			Assert.AreEqual (-1, ((IList) coll).IndexOf (ni4), "#8");
			Assert.AreEqual (2, ((IList) coll).IndexOf (ni5), "#9");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:CodeNamespaceImportCollectionTest.cs


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