예제 #1
0
        public virtual bool isInherited(string origin)
        {
            foreach (string frameName in isA)
            {
                if (frameName == origin)
                {
                    return(true);
                }
                else if (CSharpExpertAbstract.getDataFrame(frameName).isInherited(origin))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Returns own slot of frame by the name of own slot
        /// </summary>
        /// <param name="iden">short or full-qualified name of own slot</param>
        /// <exception cref="SlotIsNotFound">throw this exception in case of the slot is not found</exception>
        /// <returns>instance of the class Slot</returns>
        public virtual Slot getSlot(string iden)
        {
            string[] idens  = iden.Split('.');
            Slot     result = null;

            if (idens.Length > 2 || idens.Length == 0)
            {
                throw new SlotIsNotFound();
            }

            if (idens.Length == 1)
            {
                if (!CSharpExpertAbstract.isSlot(getName() + "." + iden))
                {
                    foreach (string frame in isA)
                    {
                        try
                        {
                            result = CSharpExpertAbstract.getDataFrame(frame).getSlot(iden);
                        }
                        catch (SlotIsNotFound) {}

                        if (result != null)
                        {
                            break;
                        }
                    }

                    if (result == null)
                    {
                        throw new SlotIsNotFound();
                    }
                }
                else
                {
                    result = CSharpExpertAbstract.getSlot(getName() + "." + iden);
                }
            }
            else if (idens.Length == 2)
            {
                result = CSharpExpertAbstract.getDataFrame(idens[0]).getSlot(idens[1]);
            }

            return(result);
        }
예제 #3
0
 protected void _initContext()
 {
     this.slots           = new SortedList();
     isContextInitialized = true;
     foreach (ContextParam param in context.Values)
     {
         if (!param.isInstance)
         {
             IDictionary slots = CSharpExpertAbstract.getDataFrame(param.name).getSlots();
             foreach (DictionaryEntry entry in slots)
             {
                 if (this.slots.Contains(entry.Key))
                 {
                     throw new KnowledgeException("Not unique names of slot in the context of the frame \"" + getName() + "\"");
                 }
                 this.slots.Add(entry.Key, entry.Value);
             }
         }
     }
 }
예제 #4
0
        public virtual IDictionary getSlots()
        {
            IDictionary dict = new SortedList();

            foreach (DictionaryEntry entry in CSharpExpertAbstract.getSlots(this.getName()))
            {
                dict.Add(((String)entry.Key).Split(new char[] { '.' })[1], entry.Value);
            }

            foreach (string frameName in this.isA)
            {
                IDictionary slots = CSharpExpertAbstract.getDataFrame(frameName).getSlots();
                foreach (DictionaryEntry entry in slots)
                {
                    if (!dict.Contains(entry.Key))                     // in case of instance slot, the defined value must be used
                    {
                        dict.Add((String)entry.Key, entry.Value);
                    }
                }
            }

            return(dict);
        }