Example #1
0
        protected void Validate(CInteger cInteger)
        {
            this.ValidateBase((CPrimitive)cInteger);

            Invariant(cInteger.List != null ^ cInteger.Range != null, CommonStrings.CIntegerListXorRange);

            if (cInteger.Range != null)
            {
                this.Validate(cInteger.Range);
            }
        }
Example #2
0
        internal static OpenEhr.AM.Archetype.ConstraintModel.Primitive.CPrimitive CPrimitive(string typeName)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName"));

            OpenEhr.AM.Archetype.ConstraintModel.Primitive.CPrimitive cPrimitive = null;
            switch (typeName)
            {
            case "C_BOOLEAN":
                cPrimitive = new CBoolean();
                break;

            case "C_DATE":
                cPrimitive = new CDate();
                break;

            case "C_DATE_TIME":
                cPrimitive = new CDateTime();
                break;

            case "C_DURATION":
                cPrimitive = new CDuration();
                break;

            case "C_TIME":
                cPrimitive = new CTime();
                break;

            case "C_INTEGER":
                cPrimitive = new CInteger();
                break;

            case "C_REAL":
                cPrimitive = new CReal();
                break;

            case "C_STRING":
                cPrimitive = new CString();
                break;

            default:
                throw new NotSupportedException("type not supported: " + typeName);
            }

            DesignByContract.Check.Ensure(cPrimitive != null, "cObject must not be null.");

            return(cPrimitive);
        }
Example #3
0
        private static CInteger Map(this C_INTEGER model)
        {
            var primitive = new CInteger
            {
                Range = model.range.Map()
            };

            if (model.assumed_value.HasValue)
            {
                primitive.AssumedValue = model.assumed_value.Value;
            }
            foreach (int i in model.list)
            {
                primitive.List.Add(i);
            }
            return(primitive);
        }
Example #4
0
        /// <summary>
        /// Parses whatever comes until the specified stop symbol is reached.
        /// </summary>
        void ParseObject(CSequence sequence, CSymbol stop)
        {
            CSymbol symbol;

            while ((symbol = ScanNextToken()) != CSymbol.Eof)
            {
                if (symbol == stop)
                {
                    return;
                }

                CString   s;
                COperator op;
                switch (symbol)
                {
                case CSymbol.Comment:
                    // ignore comments
                    break;

                case CSymbol.Integer:
                    CInteger n = new CInteger();
                    n.Value = _lexer.TokenToInteger;
                    _operands.Add(n);
                    break;

                case CSymbol.Real:
                    CReal r = new CReal();
                    r.Value = _lexer.TokenToReal;
                    _operands.Add(r);
                    break;

                case CSymbol.String:
                case CSymbol.HexString:
                case CSymbol.UnicodeString:
                case CSymbol.UnicodeHexString:
                    s       = new CString();
                    s.Value = _lexer.Token;
                    _operands.Add(s);
                    break;

                case CSymbol.Dictionary:
                    s             = new CString();
                    s.Value       = _lexer.Token;
                    s.CStringType = CStringType.Dictionary;
                    _operands.Add(s);
                    op = CreateOperator(OpCodeName.Dictionary);
                    //_operands.Clear();
                    sequence.Add(op);

                    break;

                case CSymbol.Name:
                    CName name = new CName();
                    name.Name = _lexer.Token;
                    _operands.Add(name);
                    break;

                case CSymbol.Operator:
                    op = CreateOperator();
                    //_operands.Clear();
                    sequence.Add(op);
                    break;

                case CSymbol.BeginArray:
                    CArray array = new CArray();
                    if (_operands.Count != 0)
                    {
                        ContentReaderDiagnostics.ThrowContentReaderException("Array within array...");
                    }

                    ParseObject(array, CSymbol.EndArray);
                    array.Add(_operands);
                    _operands.Clear();
                    _operands.Add((CObject)array);
                    break;

                case CSymbol.EndArray:
                    ContentReaderDiagnostics.HandleUnexpectedCharacter(']');
                    break;

#if DEBUG
                default:
                    Debug.Assert(false);
                    break;
#endif
                }
            }
        }
Example #5
0
 public void ListsAreNotNull()
 {
     var instance = new CInteger();
     Assert.IsNotNull(instance.List);
 }
Example #6
0
 public void IsValidValueThrowsException()
 {
     var instance = new CInteger();
     instance.IsValidValue(0);
 }
Example #7
0
 private static void Write(CInteger obj)
 {
     Console.Write("int:{0}", obj.Value);
 }
Example #8
0
        /// <summary>
        /// Parses whatever comes until the specified stop symbol is reached.
        /// </summary>
        void ParseObject(CSequence sequence, CSymbol stop)
        {
            CSymbol symbol;

            while ((symbol = ScanNextToken()) != CSymbol.Eof)
            {
                if (symbol == stop)
                {
                    return;
                }

                switch (symbol)
                {
                case CSymbol.Comment:
                    // ignore comments
                    break;

                case CSymbol.Integer:
                    CInteger n = new CInteger();
                    n.Value = lexer.TokenToInteger;
                    operands.Add(n);
                    break;

                case CSymbol.Real:
                    CReal r = new CReal();
                    r.Value = lexer.TokenToReal;
                    operands.Add(r);
                    break;

                case CSymbol.String:
                case CSymbol.HexString:
                case CSymbol.UnicodeString:
                case CSymbol.UnicodeHexString:
                    CString s = new CString();
                    s.Value = lexer.Token;
                    operands.Add(s);
                    break;

                case CSymbol.Name:
                    CName name = new CName();
                    name.Name = lexer.Token;
                    operands.Add(name);
                    break;

                case CSymbol.Operator:
                    COperator op = CreateOperator();
                    operands.Clear();
                    sequence.Add(op);
                    break;

                case CSymbol.BeginArray:
                    CArray array = new CArray();
                    Debug.Assert(operands.Count == 0, "Array within array...");
                    ParseObject(array, CSymbol.EndArray);
                    array.Add(operands);
                    operands.Clear();
                    operands.Add((CObject)array);
                    break;

                case CSymbol.EndArray:
                    throw new ContentReaderException("Unexpected: ']'");
                }
            }
        }
Example #9
0
 private static void ExtractText(CInteger obj, StringBuilder target) { /* nothing */ }
Example #10
0
        public void IsValidValueThrowsException()
        {
            var instance = new CInteger();

            instance.IsValidValue(0);
        }
Example #11
0
        public void ListsAreNotNull()
        {
            var instance = new CInteger();

            Assert.IsNotNull(instance.List);
        }