using System;
using System.Runtime.Serialization;
using System.ComponentModel;
using AnticipatingMinds.Genesis.CodeDOM;
namespace AnticipatingMinds.Genesis.KnowledgeManagement{
/// <summary>
/// Summary description for EventApplicabilityScope.
/// </summary>
[Serializable]
public sealed class EventApplicabilityScope : TypeMemberApplicabilityScope, ISerializable,ICloneable
{
#region Instance constructors
public EventApplicabilityScope():base()
{
}
public EventApplicabilityScope(EventApplicabilityScope eventApplicabilityScope) : base(eventApplicabilityScope)
{
if(eventApplicabilityScope.EventType != null)
EventType = ((ICloneable)eventApplicabilityScope.EventType).Clone() as TypeReferenceApplicabilityScope;
}
#endregion Instance constructors
#region ISerializable Implementation
private EventApplicabilityScope(SerializationInfo info, StreamingContext context) : base(info,context)
{
EventType = info.GetValue("EventType",typeof(TypeReferenceApplicabilityScope)) as TypeReferenceApplicabilityScope;
}
public override void GetObjectData(
SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info,context);
info.AddValue("EventType",EventType,typeof(TypeReferenceApplicabilityScope));
}
#endregion
#region ICloneable Members
public override object Clone()
{
return new EventApplicabilityScope(this);
}
#endregion
#region Public instance properties
[Category("Behavior")]
[System.ComponentModel.Editor(typeof(TypeReferenceScopeEditor),typeof(System.Drawing.Design.UITypeEditor))]
[TypeConverter(typeof(ApplicabilityScopeTypeConverter))]
[DefaultValue(null)]
[Description("The type of event being declared.")]
public TypeReferenceApplicabilityScope EventType
{
get
{
return eventType;
}
set
{
eventType = value;
}
}
public override string Title
{
get
{
return "Event Declaration";
}
}
#endregion Public instance properties
#region Protected instance methods
protected override bool DoesElementMatchScopeConditions(CodeElement codeElement)
{
if(!(codeElement is CodeTypeEventDeclaration) && !(codeElement is CodeTypeEventListDeclaration))
return false;
if(EventType != null)
{
CodeTypeReference eventType = null;
if(codeElement is CodeTypeEventDeclaration)
eventType = (codeElement as CodeTypeEventDeclaration).DeclarationType;
else
eventType = (codeElement as CodeTypeEventDeclaration).DeclarationType;
if(!(EventType.IsElementInScope(eventType)))
return false;
}
return base.DoesElementMatchScopeConditions(codeElement);
}
#endregion Protected instance methods
#region Private instance fields
TypeReferenceApplicabilityScope eventType = null;
#endregion Private instance fields
}
}
|