using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Runtime.Serialization;
using AnticipatingMinds.Genesis.CodeDOM;
namespace AnticipatingMinds.Genesis.KnowledgeManagement{
/// <summary>
/// Summary description for InterfaceApplicabilityScope.
/// </summary>
[Serializable]
public sealed class InterfaceApplicabilityScope : TypeApplicabilityScope,ICloneable,ISerializable
{
#region Instance constructors
public InterfaceApplicabilityScope():base()
{
}
public InterfaceApplicabilityScope(InterfaceApplicabilityScope interfaceApplicabilityScope):base(interfaceApplicabilityScope)
{
foreach(string inheritedInterface in interfaceApplicabilityScope.inheritedInterfaces)
inheritedInterfaces.Add(inheritedInterface);
}
#endregion Instance constructors
#region ISerializable Implementation
private InterfaceApplicabilityScope(SerializationInfo info, StreamingContext context) : base(info,context)
{
InheritedInterfaces = info.GetValue("InheritedInterfaces",typeof(StringCollection)) as StringCollection;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info,context);
info.AddValue("InheritedInterfaces",InheritedInterfaces,typeof(StringCollection));
}
#endregion
#region ICloneable Implementation
public override object Clone()
{
return new InterfaceApplicabilityScope(this);
}
#endregion
#region Public instance properties
[Category("Behavior")]
[System.ComponentModel.Editor(typeof(StringCollectionEditor),typeof(System.Drawing.Design.UITypeEditor))]
[TypeConverter(typeof(StringCollectionTypeConverter))]
[DefaultValue("(any)")]
[Description("A list of zero or more inherited interfaces. Value must be fully qualified, such as 'System.IDisposable'")]
public StringCollection InheritedInterfaces
{
get
{
return inheritedInterfaces;
}
set
{
inheritedInterfaces = value;
}
}
public override string Title
{
get
{
return "Interface Declaration";
}
}
#endregion Public instance properties
#region Protected instance methods
protected override bool DoesElementMatchScopeConditions(AnticipatingMinds.Genesis.CodeDOM.CodeElement codeElement)
{
if(!(codeElement is CodeInterfaceDeclaration))
return false;
CodeInterfaceDeclaration interfaceDeclaration = codeElement as CodeInterfaceDeclaration;
if(InheritedInterfaces != null && InheritedInterfaces.Count != 0)
{
StringCollection typeInterface = new StringCollection();
foreach(CodeTypeReference inheritedInterface in interfaceDeclaration.Interfaces)
typeInterface.Add(inheritedInterface.TypeInfo != null ? inheritedInterface.TypeInfo.FullName : inheritedInterface.TypeName );
foreach(string requestedInterface in InheritedInterfaces)
if(!typeInterface.Contains(requestedInterface))
return false;
}
return base.DoesElementMatchScopeConditions(codeElement);
}
#endregion Protected instance methods
#region Private instance fields
StringCollection inheritedInterfaces = new StringCollection();
#endregion Private instance fields
}
}
|