Ejemplo n.º 1
0
        public void AddVariable(IMark mark)
        {
            var shortname = VariableInfo.GetShortName(mark.Name);

            Dictionary <string, VariableInfo> dictionary = null;

            var mark1 = mark.Mark;

            if (mark1 == Marks.Custom)
            {
                if (mark.Type == "ByteArrayPart")
                {
                    mark1 = Marks.BeginRange;
                }
                if (mark.Type == "bool")
                {
                    mark1 = Marks.Bool;
                }
                if (mark.Type == "int")
                {
                    mark1 = Marks.Decimal;
                }
            }

            switch (mark1)
            {
            case Marks.Custom:
                if (string.IsNullOrEmpty(mark.Type) == false)
                {
                    dictionary = _customs;
                }
                break;

            case Marks.Const:
                AddEnum(mark.Name, mark.Value);
                break;

            case Marks.BeginRange:
                dictionary = _begins1;
                break;

            case Marks.EndRange:
                dictionary = _ends1;
                break;

            case Marks.Count:
                dictionary = _counts1;
                break;

            case Marks.Bool:
            case Marks.BoolEx:
                dictionary = _bools;
                break;

            case Marks.Decimal:
            case Marks.Hex:
                dictionary = _decimals1;
                break;
            }

            if (dictionary != null)
            {
                if (dictionary.ContainsKey(shortname) == false)
                {
                    dictionary.Add(shortname, new VariableInfo(mark));
                }
            }
        }