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


C# CSharp.Namespace类代码示例

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


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

示例1: Namespace

        /// <summary>
        ///   Constructor Takes the current namespace and the
        ///   name.  This is bootstrapped with parent == null
        ///   and name = ""
        /// </summary>
        public Namespace(Namespace parent, string name)
        {
            // Expression members.
            this.eclass = ExprClass.Namespace;
            this.Type = InternalType.FakeInternalType;
            this.loc = Location.Null;

            this.parent = parent;

            if (parent != null)
                this.root = parent.root;
            else
                this.root = this as RootNamespace;

            if (this.root == null)
                throw new InternalErrorException ("Root namespaces must be created using RootNamespace");

            string pname = parent != null ? parent.fullname : "";

            if (pname == "")
                fullname = name;
            else
                fullname = parent.fullname + "." + name;

            if (fullname == null)
                throw new InternalErrorException ("Namespace has a null fullname");

            if (parent != null && parent.MemberName != MemberName.Null)
                MemberName = new MemberName (parent.MemberName, name);
            else if (name.Length == 0)
                MemberName = MemberName.Null;
            else
                MemberName = new MemberName (name);

            namespaces = new Dictionary<string, Namespace> ();
            cached_types = new Dictionary<string, TypeExpr> ();

            root.RegisterNamespace (this);
        }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:44,代码来源:namespace.cs

示例2: RegisterNamespace

 public void RegisterNamespace(Namespace child)
 {
     if (child != this)
         all_namespaces.Add (child.Name, child);
 }
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:5,代码来源:namespace.cs

示例3: ImportTypes

		protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool hasExtensionTypes)
		{
			Namespace ns = targetNamespace;
			string prev_namespace = null;
			foreach (var t in types) {
				if (t == null)
					continue;

				// Be careful not to trigger full parent type loading
				if (t.MemberType == MemberTypes.NestedType)
					continue;

				if (t.Name[0] == '<')
					continue;

				var it = CreateType (t, null, new DynamicTypeReader (t), true);
				if (it == null)
					continue;

				if (prev_namespace != t.Namespace) {
					ns = t.Namespace == null ? targetNamespace : targetNamespace.GetNamespace (t.Namespace, true);
					prev_namespace = t.Namespace;
				}

				ns.AddType (module, it);

				if (it.IsStatic && hasExtensionTypes &&
					HasAttribute (CustomAttributeData.GetCustomAttributes (t), "ExtensionAttribute", CompilerServicesNamespace)) {
					it.SetExtensionMethodContainer ();
				}
			}
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:32,代码来源:import.cs

示例4: ImportTypes

		protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool importExtensionTypes)
		{
			Namespace ns = targetNamespace;
			string prev_namespace = null;
			foreach (var t in types) {
				if (t == null)
					continue;

				// Be careful not to trigger full parent type loading
				if (t.MemberType == MemberTypes.NestedType)
					continue;

				if (t.Name[0] == '<')
					continue;

				var it = CreateType (t, null, new DynamicTypeReader (t), true);
				if (it == null)
					continue;

				if (prev_namespace != t.Namespace) {
					ns = t.Namespace == null ? targetNamespace : targetNamespace.GetNamespace (t.Namespace, true);
					prev_namespace = t.Namespace;
				}

				// Cannot rely on assembly level Extension attribute or static modifier because they
				// are not followed by other compilers (e.g. F#).
				if (it.IsClass && it.Arity == 0 && importExtensionTypes &&
					HasAttribute (CustomAttributeData.GetCustomAttributes (t), "ExtensionAttribute", CompilerServicesNamespace)) {
					it.SetExtensionMethodContainer ();
				}

				ns.AddType (module, it);
			}
		}
开发者ID:frje,项目名称:SharpLang,代码行数:34,代码来源:import.cs

示例5: NamespaceEntry

		private NamespaceEntry (NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
		{
			this.parent = parent;
			this.file = file;
			this.IsImplicit = true;
			this.ns = ns;
			this.SlaveDeclSpace = slave ? new RootDeclSpace (this) : null;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:namespace.cs

示例6: ImportTypes

		void ImportTypes (Type[] types, Namespace targetNamespace, Type extension_type)
		{
			Namespace ns = targetNamespace;
			string prev_namespace = null;
			foreach (var t in types) {
				if (t == null)
					continue;

				// Be careful not to trigger full parent type loading
				if (t.MemberType == MemberTypes.NestedType)
					continue;

				if (t.Name[0] == '<')
					continue;

				var it = CreateType (t, null, t, 0, true);
				if (it == null)
					continue;

				if (prev_namespace != t.Namespace) {
					ns = t.Namespace == null ? targetNamespace : targetNamespace.GetNamespace (t.Namespace, true);
					prev_namespace = t.Namespace;
				}

				ns.AddType (it);

				if (it.IsStatic && extension_type != null && t.IsDefined (extension_type, false)) {
					it.SetExtensionMethodContainer ();
				}
			}
		}
开发者ID:davidwaters,项目名称:mono,代码行数:31,代码来源:import.cs

示例7: NamespaceContainer

        public NamespaceContainer(MemberName name, NamespaceContainer parent)
            : base(parent, name, null, MemberKind.Namespace)
        {
            this.Parent = parent;
            this.ns = parent.NS.AddNamespace (name);

            containers = new List<TypeContainer> ();
        }
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:8,代码来源:namespace.cs

示例8: TryGetNamespace

 public bool TryGetNamespace(string name, out Namespace ns)
 {
     return namespaces.TryGetValue (name, out ns);
 }
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:4,代码来源:namespace.cs

示例9: NamespaceContainer

		public NamespaceContainer (MemberName name, ModuleContainer module, NamespaceContainer parent, CompilationSourceFile sourceFile)
		{
			this.module = module;
			this.parent = parent;
			this.file = sourceFile;
			this.loc = name == null ? Location.Null : name.Location;

			if (parent != null)
				ns = parent.NS.GetNamespace (name.GetName (), true);
			else if (name != null)
				ns = module.GlobalRootNamespace.GetNamespace (name.GetName (), true);
			else
				ns = module.GlobalRootNamespace;

			SlaveDeclSpace = new RootDeclSpace (module, this);
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:16,代码来源:namespace.cs

示例10: NamespaceEntry

		private NamespaceEntry (ModuleContainer ctx, NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
		{
			this.ctx = ctx;
			this.parent = parent;
			this.file = file;
			this.IsImplicit = true;
			this.ns = ns;
			this.SlaveDeclSpace = slave ? new RootDeclSpace (ctx, this) : null;
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:9,代码来源:namespace.cs

示例11: LookupExtensionMethod

		//
		// Extension methods look up for dotted namespace names
		//
		public IList<MethodSpec> LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity, out Namespace scope)
		{
			//
			// Inspect parent namespaces in namespace expression
			//
			scope = this;
			do {
				var candidates = scope.LookupExtensionMethod (invocationContext, extensionType, name, arity);
				if (candidates != null)
					return candidates;

				scope = scope.Parent;
			} while (scope != null);

			return null;
		}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例12: NamespaceContainer

		public NamespaceContainer (MemberName name, NamespaceContainer parent)
			: base (parent, name, null, MemberKind.Namespace)
		{
			this.Parent = parent;
			this.ns = parent.NS.AddNamespace (name);

			containers = new List<TypeContainer> ();

			var topParent = this;
			while (topParent.Parent != null) {
				topParent = topParent.Parent;
			}
			compSourceFile = topParent as CompilationSourceFile;
		}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:14,代码来源:namespace.cs

示例13: AddNamespace

		public Namespace AddNamespace (MemberName name)
		{
			Namespace ns_parent;
			if (name.Left != null) {
				if (parent != null)
					ns_parent = parent.AddNamespace (name.Left);
				else
					ns_parent = AddNamespace (name.Left);
			} else {
				ns_parent = this;
			}

			Namespace ns;
			if (!ns_parent.namespaces.TryGetValue (name.Basename, out ns)) {
				ns = new Namespace (ns_parent, name.Basename);
				ns_parent.namespaces.Add (name.Basename, ns);
			}

			return ns;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:20,代码来源:namespace.cs

示例14: Namespace

        /// <summary>
        ///   Constructor Takes the current namespace and the
        ///   name.  This is bootstrapped with parent == null
        ///   and name = ""
        /// </summary>
        public Namespace(Namespace parent, string name)
            : this()
        {
            if (name == null)
                throw new ArgumentNullException ("name");

            this.parent = parent;

            string pname = parent != null ? parent.fullname : null;

            if (pname == null)
                fullname = name;
            else
                fullname = pname + "." + name;

            while (parent.parent != null)
                parent = parent.parent;

            var root = parent as RootNamespace;
            if (root == null)
                throw new InternalErrorException ("Root namespaces must be created using RootNamespace");

            root.RegisterNamespace (this);
        }
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:29,代码来源:namespace.cs

示例15: GetNamespace

        // TODO: Replace with CreateNamespace where MemberName is created for the method call
        public Namespace GetNamespace(string name, bool create)
        {
            int pos = name.IndexOf ('.');

            Namespace ns;
            string first;
            if (pos >= 0)
                first = name.Substring (0, pos);
            else
                first = name;

            if (!namespaces.TryGetValue (first, out ns)) {
                if (!create)
                    return null;

                ns = new Namespace (this, first);
                namespaces.Add (first, ns);
            }

            if (pos >= 0)
                ns = ns.GetNamespace (name.Substring (pos + 1), create);

            return ns;
        }
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:25,代码来源:namespace.cs


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