コード例 #1
0
        private void ValidateState(ValidationContext context)
        {
            AbstractFeature af = GetParentFeature();

            if (IsConnectedToRootFeature())
            {
                if (af != null)
                {
                    if (af.GetType() == typeof(Feature) || af.GetType() == typeof(RootFeature))
                    {
                        if (this.Kind == FeatureKind.FeatureSetFeature)
                        {
                            context.LogError(string.Format("{0}: Invalid 'Kind' property state", this.Name), "myError", this);
                        }
                    }
                    else if (af.GetType() == typeof(FeatureSet) || af.GetType() == typeof(RootFeature))
                    {
                        if (this.Kind != FeatureKind.FeatureSetFeature)
                        {
                            context.LogError(string.Format("{0}: Invalid 'Kind' property state", this.Name), "myError", this);
                        }
                    }
                }
            }
            else
            {
                if (HasParent() == false)
                {
                    context.LogWarning(string.Format("{0}: No parent feature", this.Name), "myError", this);
                    if (this.Kind == FeatureKind.FeatureSetFeature)
                    {
                        context.LogWarning(string.Format("{0}: Invalid 'Kind' property state", this.Name), "myError", this);
                    }
                }

                if (af != null)
                {
                    if (af.GetType() == typeof(Feature))
                    {
                        if (this.Kind == FeatureKind.FeatureSetFeature)
                        {
                            context.LogWarning(string.Format("{0}: Invalid 'Kind' property state", this.Name), "myError", this);
                        }
                    }
                    else if (af.GetType() == typeof(FeatureSet))
                    {
                        if (this.Kind != FeatureKind.FeatureSetFeature)
                        {
                            context.LogWarning(string.Format("{0}: Invalid 'Kind' property state", this.Name), "myError", this);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private bool IsConnectedToRootFeature()
        {
            AbstractFeature af = GetParentFeature(this);

            if (af == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
 private AbstractFeature GetParentFeature()
 {
     foreach (object o in this.GetElementLinks())
     {
         if (o.GetType() == typeof(RelationshipFeatureSet))
         {
             AbstractFeature roletarget = ((RelationshipFeatureSet)o).ObjectTransitionTo;
             if (this == roletarget)
             {
                 return(((RelationshipFeatureSet)o).ObjectTransitionFrom);
             }
         }
         else if (o.GetType() == typeof(RelationshipFeature))
         {
             AbstractFeature roletarget = ((RelationshipFeature)o).TransitionTo;
             if (this == roletarget)
             {
                 return(((RelationshipFeature)o).TransitionFrom);
             }
         }
     }
     return(null);
 }
コード例 #4
0
 private bool HasParent()
 {
     foreach (object o in this.GetElementLinks())
     {
         if (o.GetType() == typeof(RelationshipFeatureSet))
         {
             AbstractFeature roletarget = ((RelationshipFeatureSet)o).ObjectTransitionTo;
             if (this == roletarget)
             {
                 return(true);
             }
         }
         else if (o.GetType() == typeof(RelationshipFeature))
         {
             AbstractFeature roletarget = ((RelationshipFeature)o).TransitionTo;
             if (this == roletarget)
             {
                 return(true);
             }
         }
     }
     return(false);
 }