Пример #1
0
		/// <summary>
		/// Creates a type. If type exist in namespace which isn't created yet so it will be created.
		/// </summary>
		/// <param name="module">A module where type will be added</param>
		/// <param name="typeDefinition">TypeDefinition which will used to create a type.</param>
		/// <returns>A new type</returns>
		private Type CreateType(Module module, TypeDefinition typeDefinition)
		{
			var type = new Type
			{
				Name = FormatTypeName(typeDefinition),
				FullName = FormatTypeName(typeDefinition, true),
				IsInterface = typeDefinition.IsInterface,
				IsEnum = typeDefinition.IsEnum,
				IsClass = typeDefinition.IsClass,
				IsSealed = typeDefinition.IsSealed,
				IsAbstract = typeDefinition.IsAbstract,
				IsPublic = typeDefinition.IsPublic,
				IsStruct = typeDefinition.IsValueType && !typeDefinition.IsEnum && typeDefinition.IsSealed,
				IsInternal = typeDefinition.IsNotPublic,
				IsDelegate = (typeDefinition.BaseType != null ?
				              typeDefinition.BaseType.FullName == "System.MulticastDelegate" : false),
				IsNestedPrivate = typeDefinition.IsNestedPrivate,
				IsNestedPublic = typeDefinition.IsNestedPublic,
				IsNestedProtected = (!typeDefinition.IsNestedPrivate && !typeDefinition.IsNestedPublic &&
				                     typeDefinition.IsNestedFamily)
			};

			// try find namespace
			var nsName = GetNamespaceName(typeDefinition);

			var ns = (from n in module.Namespaces
			          where n.Name == nsName
			          select n).SingleOrDefault();

			if (ns == null)
			{
				ns = new Namespace
				{
					Name = nsName,
					Module = module
				};

				module.Namespaces.Add(ns);
			}

			type.Namespace = ns;
			ns.Types.Add(type);
			return type;
		}
Пример #2
0
 public static BitmapSource GetIcon(Namespace ns)
 {
     return Namespace;
 }