/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. using System;
  19. using System.Linq;
  20. using ICSharpCode.NRefactory.TypeSystem;
  21. namespace ICSharpCode.PackageManagement.EnvDTE
  22. {
  23. public class CodeClass2 : CodeClass, global::EnvDTE.CodeClass2
  24. {
  25. public CodeClass2(CodeModelContext context, ITypeDefinition typeDefinition)
  26. : base(context, typeDefinition)
  27. {
  28. }
  29. public global::EnvDTE.CodeElements PartialClasses {
  30. get {
  31. var partialClasses = new CodeElementsList<CodeType>();
  32. partialClasses.Add(this);
  33. return partialClasses;
  34. }
  35. }
  36. public bool IsGeneric {
  37. get { return typeDefinition.FullTypeName.TypeParameterCount > 0; }
  38. }
  39. public global::EnvDTE.vsCMClassKind ClassKind {
  40. get {
  41. if (typeDefinition.Parts.First().IsPartial) {
  42. return global::EnvDTE.vsCMClassKind.vsCMClassKindPartialClass;
  43. }
  44. return global::EnvDTE.vsCMClassKind.vsCMClassKindMainClass;
  45. }
  46. set {
  47. if (value == ClassKind) {
  48. return;
  49. }
  50. if (value == global::EnvDTE.vsCMClassKind.vsCMClassKindPartialClass) {
  51. context.CodeGenerator.MakePartial(typeDefinition);
  52. } else {
  53. throw new NotImplementedException();
  54. }
  55. }
  56. }
  57. public bool IsAbstract {
  58. get { return typeDefinition.IsAbstract; }
  59. }
  60. }
  61. }