コード例 #1
0
        /// <summary>
        /// Access to value
        /// </summary>
        public object this[object s]
        {
            set
            {
                if (!table.ContainsKey(s))
                {
                    return;
                    //throw new Exception("Variable does not exist");
                }
                List <object> l = table[s] as List <object>;
                foreach (object x in l)
                {
                    if (x is ElementaryObjectVariable)
                    {
                        ElementaryObjectVariable o = x as ElementaryObjectVariable;
                        o.Value = value;
                        if (value.IsDBNull())
                        {
                            o.Value = null;
                        }
                        continue;
                    }

                    /*                 if (x is ElementaryRealVariable &
                     *                   !value.GetType().FullName.Equals("System.Double"))
                     *               {
                     *                   goto replace;
                     *               }
                     *               {
                     *                   ElementaryRealVariable r = x as ElementaryRealVariable;
                     *                   if (value == null | value is DBNull)
                     *                   {
                     *                       r.Value = null;
                     *                       continue;
                     *                   }
                     *                   r.Value = (double)value;
                     *                   continue;
                     *               }
                     *               return;
                     *           replace:
                     *               char c = (char)s;
                     *               for (int i = 0; i < c; i++)
                     *               {
                     *                   ElementaryObjectVariable v = new ElementaryObjectVariable(c);
                     *                   v.Value = value;
                     *                   l[i] = v;
                     *               }*/
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds tree
 /// </summary>
 /// <param name="tree">Tree to add</param>
 public void Add(ObjectFormulaTree tree)
 {
     /*   if (tree.Operation is ElementaryRealVariable)
      * {
      *     ElementaryRealVariable v = tree.Operation as ElementaryRealVariable;
      *     ArrayList l = null;
      *     object s = v.Symbol;
      *     if (table.ContainsKey(s))
      *     {
      *         l = table[s] as ArrayList;
      *     }
      *     else
      *     {
      *         l = new ArrayList();
      *         table[s] = l;
      *     }
      *     l.Add(v);
      * }*/
     if (tree.Operation is ElementaryObjectVariable)
     {
         ElementaryObjectVariable v = tree.Operation as ElementaryObjectVariable;
         List <object>            l = null;
         object s = v.Symbol;
         if (table.ContainsKey(s))
         {
             l = table[s];
         }
         else
         {
             l        = new List <object>();
             table[s] = l;
         }
         l.Add(v);
     }
     for (int i = 0; i < tree.Count; i++)
     {
         Add(tree[i]);
     }
 }