Ejemplo n.º 1
0
        /// <summary>
        /// This is very inneficient. Consider alternatives ...
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="type"></param>
        /// <param name="kp"></param>
        /// <returns></returns>
        public override bool IsApplicable(MInstance instance, MType type, KPsystem kp)
        {
            if (!base.IsApplicable(instance, type, kp))
            {
                return(false);
            }
            foreach (IInstanceIdentifier identifier in TargetRhs.Keys)
            {
                if (identifier is InstanceIdentifier)
                {
                    InstanceIdentifier ii = identifier as InstanceIdentifier;
                    if (ii.Indicator == InstanceIndicator.TYPE)
                    {
                        MType mt = kp[ii.Value];
                        bool  atLeastOneConnection = false;
                        foreach (MInstance connection in instance.Connections)
                        {
                            if (mt.Instances.Contains(connection))
                            {
                                atLeastOneConnection = true;
                                break;
                            }
                        }
                        if (!atLeastOneConnection)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
        public override bool Equals(object obj)
        {
            if (obj is InstanceIdentifier)
            {
                InstanceIdentifier ii = obj as InstanceIdentifier;
                return(ii.Indicator == this.Indicator && ii.Value == this.Value);
            }

            return(false);
        }
 public TargetedMultiset(InstanceIdentifier identifier, Multiset multiset)
 {
     Target   = identifier;
     Multiset = multiset;
 }