Example #1
0
        protected void Validate(CReal cReal)
        {
            this.ValidateBase((CPrimitive)cReal);

            Invariant(cReal.List != null ^ cReal.Range != null, CommonStrings.CRealListXorRange);

            if (cReal.Range != null)
            {
                this.Validate(cReal.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
        /// <summary>
        /// Get a brush descriptor
        /// </summary>
        public IBrushDescriptor GetBrushDescriptor(CSequence operands, Matrix matrix, double alpha)
        {
            CSequence newSequence       = new CSequence();
            var       numberColorValues = baseColorSpace.GetNumberOfValuesPerColor();
            int       index             = LimitIndexToBoundaries(PdfUtilities.GetInteger(operands[0])) * numberColorValues;

            for (int i = 0; i < numberColorValues; i++)
            {
                var real = new CReal();
                real.Value = lookup[index + i];
                newSequence.Add(real);
            }

            var brushDescriptor = baseColorSpace.GetBrushDescriptor(newSequence, matrix, alpha);

            return(new IndexedBrushDescriptor(brushDescriptor));
        }
Example #4
0
        private static CReal Map(this C_REAL model)
        {
            var primitive = new CReal
            {
                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);
        }
        /// <summary>
        /// Set the initial color space and color
        /// </summary>
        private void InitColor()
        {
            var seq  = new CSequence();
            var real = new CReal {
                Value = 0.0
            };

            seq.Add(real);

            currentGraphicsState.ColorSpace = colorSpaceManager.GetColorSpace(PdfKeys.DeviceGray);
            currentGraphicsState.FillBrush  =
                currentGraphicsState.ColorSpace.GetBrushDescriptor(seq,
                                                                   currentGraphicsState.CurrentTransformationMatrix,
                                                                   currentGraphicsState.FillAlpha.Current);
            currentGraphicsState.StrokeBrush =
                currentGraphicsState.ColorSpace.GetBrushDescriptor(seq,
                                                                   currentGraphicsState.CurrentTransformationMatrix,
                                                                   currentGraphicsState.FillAlpha.Current);
        }
Example #6
0
        /// <summary>
        /// Get a brush descriptor
        /// </summary>
        public IBrushDescriptor GetBrushDescriptor(CSequence operands, Matrix matrix, double alpha)
        {
            IBrushDescriptor altColorSpaceDescriptor = null;

            var values = PdfUtilities.CreateDoubleArray(operands);
            var altColorSpaceValues = function.Calculate(values);

            if (altColorSpaceValues != null)
            {
                var altColorOperands = new CSequence();

                foreach (var val in altColorSpaceValues)
                {
                    var real = new CReal();
                    real.Value = val;
                    altColorOperands.Add(real);
                }

                altColorSpaceDescriptor = alternateColorSpace.GetBrushDescriptor(altColorOperands, matrix, alpha);
            }

            return(new DeviceNBrushDescriptor(altColorSpaceDescriptor));
        }
Example #7
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 #8
0
 private static void Write(CReal obj)
 {
     Console.Write("real:{0}", obj.Value);
 }
Example #9
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 #10
0
 private static void ExtractText(CReal obj, StringBuilder target) { /* nothing */ }
Example #11
0
 public void IsValidValueThrowsException()
 {
     var instance = new CReal();
     instance.IsValidValue(0);
 }
Example #12
0
        public void IsValidValueThrowsException()
        {
            var instance = new CReal();

            instance.IsValidValue(0);
        }