using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.Serialization;
using AnticipatingMinds.Genesis.CodeDOM;
namespace AnticipatingMinds.Genesis.KnowledgeManagement{
public enum ApplicabilityScopeType
{
Inclusive,
Exclusive
}
[Serializable]
public abstract class ApplicabilityScope : ISerializable
{
#region Instance constructors
protected ApplicabilityScope()
{
}
protected ApplicabilityScope(ApplicabilityScope applicabilityScope)
{
Description = applicabilityScope.Description;
IsActive = applicabilityScope.IsActive;
ScopeType = applicabilityScope.ScopeType;
ScopeId = applicabilityScope.ScopeId;
}
#endregion Instance constructors
#region ISerializable Implementation
protected ApplicabilityScope(SerializationInfo info, StreamingContext context)
{
Description = info.GetString("Description");
IsActive = info.GetBoolean("IsActive");
ScopeId = info.GetString("ScopeId");
ScopeType = (ApplicabilityScopeType) info.GetValue("ScopeType",typeof(ApplicabilityScopeType));
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Description",Description);
info.AddValue("IsActive",IsActive);
info.AddValue("ScopeId",scopeId);
info.AddValue("ScopeType",ScopeType,typeof(ApplicabilityScopeType));
}
#endregion
#region Public instance properties
[Browsable(false)]
public string ScopeId
{
get
{
return scopeId;
}
set
{
scopeId = value;
}
}
[Browsable(true)]
[Category("Appearance")]
[Description("A brief, informative description of scope definition.")]
public virtual string Description
{
get
{
return description;
}
set
{
description = value;
}
}
[Category("Behavior")]
[Description("A Boolean (True/False) flag indicating whether this scope definition is currently active for the rule.")]
[DefaultValue(true)]
public virtual bool IsActive
{
get
{
return isActive;
}
set
{
isActive = value;
}
}
[Browsable(true)]
[Category("Behavior")]
[Description("Type filter used for the scope definition - values are Inclusive and Exclusive.")]
[DefaultValue(ApplicabilityScopeType.Inclusive)]
public virtual ApplicabilityScopeType ScopeType
{
get
{
return scopeType;
}
set
{
scopeType = value;
}
}
[Browsable(false)]
public abstract string Title
{
get;
}
#endregion Public instance properties
#region Public instance methods
public bool IsElementInScope(CodeElement codeElement)
{
if(!IsActive)
return true;
if(ScopeType == ApplicabilityScopeType.Inclusive)
return DoesElementMatchScopeConditions(codeElement);
else
return !DoesElementMatchScopeConditions(codeElement);
}
#endregion Public instance methods
#region Protected instance methods
protected abstract bool DoesElementMatchScopeConditions(CodeElement codeElement);
#endregion
#region Private instance fields
private string description;
private bool isActive = true;
private ApplicabilityScopeType scopeType = ApplicabilityScopeType.Inclusive;
private string scopeId = Guid.NewGuid().ToString();
#endregion Private instance fields
}
}
|