PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeClass2.cs

https://github.com/ajadex/SharpDevelop
C# | 68 lines | 44 code | 7 blank | 17 comment | 6 complexity | 4bca30fa3ed0dc27f0c3c6c6fccd6abc MD5 | raw file
 1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
 2// 
 3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
 4// software and associated documentation files (the "Software"), to deal in the Software
 5// without restriction, including without limitation the rights to use, copy, modify, merge,
 6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 7// to whom the Software is furnished to do so, subject to the following conditions:
 8// 
 9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11// 
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using System.Linq;
21using ICSharpCode.NRefactory.TypeSystem;
22
23namespace ICSharpCode.PackageManagement.EnvDTE
24{
25	public class CodeClass2 : CodeClass, global::EnvDTE.CodeClass2
26	{
27		public CodeClass2(CodeModelContext context, ITypeDefinition typeDefinition)
28			: base(context, typeDefinition)
29		{
30		}
31		
32		public global::EnvDTE.CodeElements PartialClasses {
33			get {
34				var partialClasses = new CodeElementsList<CodeType>();
35				partialClasses.Add(this);
36				return partialClasses;
37			}
38		}
39		
40		public bool IsGeneric {
41			get { return typeDefinition.FullTypeName.TypeParameterCount > 0; }
42		}
43		
44		public global::EnvDTE.vsCMClassKind ClassKind {
45			get {
46				if (typeDefinition.Parts.First().IsPartial) {
47					return global::EnvDTE.vsCMClassKind.vsCMClassKindPartialClass;
48				}
49				return global::EnvDTE.vsCMClassKind.vsCMClassKindMainClass;
50			}
51			set {
52				if (value == ClassKind) {
53					return;
54				}
55				
56				if (value == global::EnvDTE.vsCMClassKind.vsCMClassKindPartialClass) {
57					context.CodeGenerator.MakePartial(typeDefinition);
58				} else {
59					throw new NotImplementedException();
60				}
61			}
62		}
63		
64		public bool IsAbstract {
65			get { return typeDefinition.IsAbstract; }
66		}
67	}
68}