Exemplo n.º 1
0
        private static Dim ReadDim(string[] lines, ref int lineno)
        {
            var dim       = new Dim();
            var firstLine = lines[lineno];

            if (!firstLine.StartsWith("["))
            {
                //Not Title
                throw new ArgumentException("title don't start with [");
            }
            dim.name = ReadNameFromLine(firstLine);
            //删掉[ ]
            dim.name           = dim.name.Substring(1, dim.name.Length - 2);
            dim.attrs          = ReadAttributesFromLine(firstLine);
            dim.items          = new List <DimItem>();
            dim.interval       = 1;
            dim.nameDimItemMap = new Dictionary <string, DimItem>();

            lineno++;
            while (true)
            {
                if (lineno >= lines.Length)
                {
                    break;
                }
                string curLine = lines[lineno];
                if (curLine.StartsWith("["))
                {
                    break;
                }
                if (!curLine.StartsWith("/*"))
                {
                    var dimItem = new DimItem();
                    dimItem.name     = ReadNameFromLine(curLine);
                    dimItem.attrs    = ReadAttributesFromLine(curLine);
                    dimItem.belongTo = dim;
                    dimItem.index    = dim.items.Count;
                    // VERT is calculated based on FREQ
                    if (dimItem.attrs.GetAttr(DimItemAttrNames.Display) != "VERT")
                    {
                        //TODO: how to deal with duplicate key
                        try
                        {
                            dim.nameDimItemMap.Add(dimItem.name, dimItem);
                        }
                        catch (ArgumentException) { }
                    }
                    dim.items.Add(dimItem);
                }
                lineno++;
            }
            return(dim);
        }
Exemplo n.º 2
0
        private IModel  CreateModel()
        {
            IModel     ret  = null;
            IDimension dim  = null;
            IDimItem   item = null;

            ret = new Model();
            for (int i = 1; i <= 5; ++i)
            {
                dim = new Dimension(i);
                for (int j = 1; j <= 10; ++j)
                {
                    item = new DimItem((UInt64)(i * Model.DimItemMax + j));
                    dim.DimItemAdd(item);
                }
                ret.DimensionAdd(dim);
            }
            return(ret);
        }