ClassApplicabilityScope.cs :  » Development » devAdvantage » AnticipatingMinds » Genesis » KnowledgeManagement » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » devAdvantage 
devAdvantage » AnticipatingMinds » Genesis » KnowledgeManagement » ClassApplicabilityScope.cs
using System;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using AnticipatingMinds.Genesis.CodeDOM;

namespace AnticipatingMinds.Genesis.KnowledgeManagement{
  [Serializable]
  public sealed class ClassApplicabilityScope : TypeApplicabilityScope, ICloneable,ISerializable
  {
    #region Instance constructors
    public ClassApplicabilityScope():base()
    {
    }

    public ClassApplicabilityScope(ClassApplicabilityScope classApplicabilityScope):base(classApplicabilityScope)
    {
      SubClassOf = classApplicabilityScope.SubClassOf;
      
      foreach(string implementedInterface in classApplicabilityScope.implementedInterfaces)
        implementedInterfaces.Add(implementedInterface);
    }

    #endregion Instance constructors
    #region ISerializable Implementation
    private ClassApplicabilityScope(SerializationInfo info, StreamingContext context) : base(info,context)
    {
      SubClassOf = info.GetString("SubClassOf");
      implementedInterfaces = info.GetValue("ImplementedInterfaces",typeof(StringCollection)) as StringCollection;
    }
    
    public override void GetObjectData(
      SerializationInfo info, StreamingContext context) 
    {
      base.GetObjectData(info,context);
      info.AddValue("SubClassOf",SubClassOf);
      info.AddValue("ImplementedInterfaces",implementedInterfaces,typeof(StringCollection));
    }

    #endregion
    #region Public instance properties
    [Category("Behavior")]
    [DefaultValue(null)]
    [Description("A class type that the type declaration must inherit from (directly or indirectly). Value must be fully qualified, such as 'System.Windows.Forms.Form'")]
    public string SubClassOf
    {
      get
      {
        return subClassOf;
      }
      set
      {
        subClassOf = value;
      }
    }
    [Category("Behavior")]
    [System.ComponentModel.Editor(typeof(StringCollectionEditor),typeof(System.Drawing.Design.UITypeEditor))]
    [TypeConverter(typeof(StringCollectionTypeConverter))]
    [DefaultValue("(any)")]
    [Description("A list of zero or more interfaces that the type implements. Value must be fully qualified, such as 'System.IDisposable'")]
    public StringCollection ImplementedInterfaces
    {
      get
      {
        return implementedInterfaces;
      }
      set
      {
        implementedInterfaces = value;
      }
    }
    
    public override string Title
    {
      get
      {
        return "Class Declaration";
      }
    }
    #endregion Public instance properties
    #region Public instance methods
    protected override bool DoesElementMatchScopeConditions(AnticipatingMinds.Genesis.CodeDOM.CodeElement codeElement)
    {
      if(!(codeElement is CodeClassDeclaration))
        return false;

      if(!base.DoesElementMatchScopeConditions(codeElement))
        return false;

      CodeClassDeclaration classDeclaration = codeElement as CodeClassDeclaration;
      if(SubClassOf != null && SubClassOf.Length != 0)
      {
        if(codeElement.GetAssemblyTypeManager()!= null && !codeElement.GetAssemblyTypeManager().IsTypeSubclassOf(classDeclaration.FullName,SubClassOf))
          return false;
      }

      if(ImplementedInterfaces != null && ImplementedInterfaces.Count != 0)
      {
        StringCollection typeInterface = new StringCollection();
        
        foreach(CodeTypeReference baseType in classDeclaration.BaseTypes)
          typeInterface.Add(baseType.TypeInfo != null ? baseType.TypeInfo.FullName : baseType.TypeName );

        foreach(string requestedInterface in ImplementedInterfaces)
          if(!typeInterface.Contains(requestedInterface))
            return false;
      }

      return true;
    }
    #region ICloneable Members
    public override object Clone()
    {
      return new ClassApplicabilityScope(this);
    }
    #endregion
    #endregion Public instance methods
    #region Private instance fields
    private string subClassOf = null;
    private StringCollection implementedInterfaces = new StringCollection();
    #endregion Private instance fields
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.