Example #1
0
        public void RenderCommodity(Amount amt)
        {
            Commodity comm = amt.Commodity;

            int  id;
            bool newlyAdded = false;

            if (!Comms.TryGetValue(comm, out id))
            {
                id         = NextCommID++;
                newlyAdded = true;
                Comms.Add(comm, id);
            }

            StringBuilder buf = new StringBuilder();

            do
            {
                buf.Append((char)('A' + (id % 26)));
                id /= 26;
            } while (id > 0);

            if (amt.HasAnnotation)
            {
                amt.SetCommodity(CommodityPool.Current.FindOrCreate(buf.ToString(), amt.Annotation));
            }
            else
            {
                amt.SetCommodity(CommodityPool.Current.FindOrCreate(buf.ToString()));
            }

            if (newlyAdded)
            {
                amt.Commodity.Flags    |= comm.Flags;
                amt.Commodity.Precision = comm.Precision;
            }
        }