GetNamespace() public méthode

public GetNamespace ( string name, bool create ) : Namespace
name string
create bool
Résultat Namespace
Exemple #1
0
		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);
			}
		}
Exemple #2
0
		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 ();
				}
			}
		}
Exemple #3
0
		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 ();
				}
			}
		}