Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TypeKindOptions.cs « GenerateType « MonoDevelop.CSharp.Features « CSharpBinding « addins « src « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3bfdc96dfb5fee109cd3e45c16318e87ecaf2503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ICSharpCode.NRefactory6.CSharp.GenerateType
{
	[Flags]
	public enum TypeKindOptions
	{
		None = 0x0,

		Class = 0x1,
		Structure = 0x2,
		Interface = 0x4,
		Enum = 0x8,
		Delegate = 0x10,
		Module = 0x20,

		// Enables class, struct, interface, enum and delegate
		AllOptions = Class | Structure | Interface | Enum | Delegate,

		// Only class is valid with Attribute
		Attribute = Class,

		// Only class, struct and interface are allowed. No Enums
		BaseList = Class | Interface,

		AllOptionsWithModule = AllOptions | Module,

		// Only Interface and Delegate cannot be part of the member access with Namespace as Left expression
		MemberAccessWithNamespace = Class | Structure | Enum | Module,

		// Enum and Modules are incompatible with Generics
		GenericInCompatibleTypes = Enum | Module
	}

	internal class TypeKindOptionsHelper
	{
		public static bool IsClass(TypeKindOptions option)
		{
			return (option & TypeKindOptions.Class) != 0 ? true : false;
		}

		public static bool IsStructure(TypeKindOptions option)
		{
			return (option & TypeKindOptions.Structure) != 0 ? true : false;
		}

		public static bool IsInterface(TypeKindOptions option)
		{
			return (option & TypeKindOptions.Interface) != 0 ? true : false;
		}

		public static bool IsEnum(TypeKindOptions option)
		{
			return (option & TypeKindOptions.Enum) != 0 ? true : false;
		}

		public static bool IsDelegate(TypeKindOptions option)
		{
			return (option & TypeKindOptions.Delegate) != 0 ? true : false;
		}

		public static bool IsModule(TypeKindOptions option)
		{
			return (option & TypeKindOptions.Module) != 0 ? true : false;
		}

		public static TypeKindOptions RemoveOptions(TypeKindOptions fromValue, params TypeKindOptions[] removeValues)
		{
			var tempReturnValue = fromValue;
			foreach (var removeValue in removeValues)
			{
				tempReturnValue = tempReturnValue & ~removeValue;
			}

			return tempReturnValue;
		}

		internal static TypeKindOptions AddOption(TypeKindOptions toValue, TypeKindOptions addValue)
		{
			return toValue | addValue;
		}
	}
}