Esempio n. 1
0
        public void TestSettingValue()
        {
            LongText longText = new LongText("test");

            longText.Value = "newtest";
            Assert.IsTrue(longText.Value.Equals("newtest"));
        }
Esempio n. 2
0
        public void TestEquals()
        {
            LongText longText1 = new LongText("test");
            LongText longText2 = new LongText("test");

            Assert.IsTrue(longText1.Equals(longText2));
        }
Esempio n. 3
0
        public object Create()
        {
            if (_generator == null)
            {
                _generator = new LongText();
                _generator.Load();
            }

            return(_generator.Create(Length));
        }
Esempio n. 4
0
        public void Favorite_Validate_ReturnsErrors()
        {
            var favorite = new Favorite();

            favorite.Protocol   = LongText.Substring(0, 11);
            favorite.ServerName = LongText;
            var results = this.validator.Validate(favorite);

            Assert.AreEqual(3, results.Count(), "Some properties arent validated properly for Favorite");
        }
Esempio n. 5
0
        public void TestHashCode()
        {
            LongText longText = new LongText("test");

            if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") == "x86")
            {
                Assert.AreEqual(-354185609, longText.GetHashCode());
            }
            else
            {
                Assert.AreEqual(-871206010, longText.GetHashCode());
            }
        }
Esempio n. 6
0
        public void Generate_Starts_With_Text()
        {
            LongText g = new LongText();

            g.Load();
            string text = "";

            for (int i = 0; i < 100; i++)
            {
                var size = Sampling.GetUniform(140, 1000);
                text = g.Create(size, "super beggining of test");
                Console.WriteLine(String.Format("{0} ({1})\n", text, text.Length));
                Assert.True(text.Length <= size);
            }
        }
Esempio n. 7
0
        public void Test_BOPropGeneralDataMapper_TryParseCustomProperty_InheritedCustomProperty()
        {
            //---------------Set up test pack-------------------
            LongText          longText          = new LongText("test");
            GeneralDataMapper generalDataMapper = new GeneralDataMapper(typeof(CustomProperty));
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object returnValue;

            generalDataMapper.TryParsePropValue(longText, out returnValue);
            //---------------Test Result -----------------------
            Assert.IsNotNull(returnValue);
            Assert.AreSame(longText, returnValue);
        }
Esempio n. 8
0
        public void TestPropertyValue()
        {
            //---------------Set up test pack-------------------
            IBusinessObject bo       = _itsClassDef.CreateNewBusinessObject();
            LongText        longText = new LongText("test");

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bo.SetPropertyValue("TestProp", longText);
            object actualValue = bo.GetPropertyValue("TestProp");

            //---------------Test Result -----------------------
            Assert.IsNotNull(actualValue);
            Assert.IsInstanceOf(typeof(LongText), actualValue);
            Assert.AreSame(longText, actualValue);
        }
Esempio n. 9
0
        public void Test_BOPropGeneralDataMapper_TryParseCustomProperty_StringValue()
        {
            //---------------Set up test pack-------------------
            string            test = "test";
            GeneralDataMapper generalDataMapper = new GeneralDataMapper(typeof(LongText));
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object returnValue;

            generalDataMapper.TryParsePropValue(test, out returnValue);
            //---------------Test Result -----------------------
            Assert.IsNotNull(returnValue);
            Assert.IsInstanceOf(typeof(LongText), returnValue);
            LongText longText = (LongText)returnValue;

            Assert.AreSame(test, longText.Value);
        }
Esempio n. 10
0
        // Sets Text to a substring of LongText based on _placement and _curLen.
        private void CalcText()
        {
            if (LongText == null)
            {
                switch (EllipsisPlacement)
                {
                case EllipsisPlacement.Left:
                case EllipsisPlacement.Center:
                case EllipsisPlacement.Right:
                case EllipsisPlacement.Path:
                    SetText(LongText);
                    break;
                }

                return;
            }

            switch (EllipsisPlacement)
            {
            case EllipsisPlacement.Right:
                SetText(LongText.Substring(0, _curLen) + "\u2026");
                break;

            case EllipsisPlacement.Center:
                int firstLen  = _curLen / 2;
                int secondLen = _curLen - firstLen;
                SetText(LongText.Substring(0, firstLen) + "\u2026" + LongText.Substring(LongText.Length - secondLen));
                break;

            case EllipsisPlacement.Left:
                int start = LongText.Length - _curLen;
                SetText("\u2026" + LongText.Substring(start));
                break;

            case EllipsisPlacement.Path:
                var sb = new StringBuilder(_curLen + 1);
                PathCompactPathEx(sb, LongText, _curLen, 0);
                SetText(sb.ToString());
                break;

            default:
                throw new Exception("Unexpected switch value: " + EllipsisPlacement.ToString());
            }
        }
Esempio n. 11
0
        private ValidationStates ValidateDbFavorite()
        {
            // created dbfavorite is not compleate, only necessary to make validable using IFavorite
            var favorite = new DbFavorite();

            favorite.ExecuteBeforeConnect = new DbBeforeConnectExecute();
            favorite.Security             = new DbSecurityOptions();
            favorite.Details.LoadFieldsFromReferences();

            favorite.Protocol   = LongText.Substring(0, 11);
            favorite.ServerName = LongText;
            favorite.Name       = LongText;
            favorite.Notes      = LongText;

            favorite.ExecuteBeforeConnect.Command          = LongText;
            favorite.ExecuteBeforeConnect.CommandArguments = LongText;
            favorite.ExecuteBeforeConnect.InitialDirectory = LongText;

            return(validator.Validate(favorite));
        }
Esempio n. 12
0
        private System.String GetAttributeValue(DvtkData.Dimse.Attribute attribute)
        {
            System.String attributeValue = System.String.Empty;
            if ((attribute == null) ||
                (attribute.Length == 0))
            {
                return(attributeValue);
            }

            switch (attribute.ValueRepresentation)
            {
            case VR.AE:
            {
                ApplicationEntity applicationEntity = (ApplicationEntity)attribute.DicomValue;
                attributeValue = applicationEntity.Values[0];
                break;
            }

            case VR.AS:
            {
                AgeString ageString = (AgeString)attribute.DicomValue;
                attributeValue = ageString.Values[0];
                break;
            }

            case VR.CS:
            {
                CodeString codeString = (CodeString)attribute.DicomValue;
                attributeValue = codeString.Values[0];
                break;
            }

            case VR.DA:
            {
                Date date = (Date)attribute.DicomValue;
                attributeValue = date.Values[0];
                break;
            }

            case VR.DS:
            {
                DecimalString decimalString = (DecimalString)attribute.DicomValue;
                attributeValue = decimalString.Values[0];
                break;
            }

            case VR.DT:
            {
                DvtkData.Dimse.DateTime dateTime = (DvtkData.Dimse.DateTime)attribute.DicomValue;
                attributeValue = dateTime.Values[0];
                break;
            }

            case VR.IS:
            {
                IntegerString integerString = (IntegerString)attribute.DicomValue;
                attributeValue = integerString.Values[0];
                break;
            }

            case VR.LO:
            {
                LongString longString = (LongString)attribute.DicomValue;
                attributeValue = longString.Values[0];
                break;
            }

            case VR.LT:
            {
                LongText longText = (LongText)attribute.DicomValue;
                attributeValue = longText.Value;
                break;
            }

            case VR.PN:
            {
                PersonName personName = (PersonName)attribute.DicomValue;
                attributeValue = personName.Values[0];
                break;
            }

            case VR.SH:
            {
                ShortString shortString = (ShortString)attribute.DicomValue;
                attributeValue = shortString.Values[0];
                break;
            }

            case VR.SQ:
            {
                // Special case looking for the SOP Class UID
                SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue;
                if ((sequenceOfItems != null) &&
                    (sequenceOfItems.Sequence.Count == 1))
                {
                    // Special case looking for the SOP Class UID
                    SequenceItem item = sequenceOfItems.Sequence[0];
                    attribute      = item.GetAttribute(new Tag(0x0008, 0x1150));
                    attributeValue = GetAttributeValue(attribute);
                }
                break;
            }

            case VR.ST:
            {
                ShortText shortText = (ShortText)attribute.DicomValue;
                attributeValue = shortText.Value;
                break;
            }

            case VR.TM:
            {
                Time time = (Time)attribute.DicomValue;
                attributeValue = time.Values[0];
                break;
            }

            case VR.UI:
            {
                UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                attributeValue = uniqueIdentifier.Values[0];
                break;
            }

            default:
                break;
            }

            return(attributeValue);
        }
Esempio n. 13
0
        private static DICOMElement CreateVRObject(string vr, Constants.EncodeType encType, byte[] data, Tag t, bool isLittleEndian, bool isIndefinite)
        {
            switch (vr)
            {
                case "CS":
                    CodeString cs = new CodeString();
                    cs.ByteData = data;
                    cs.EncodeType = encType;
                    cs.IsLittleEndian = isLittleEndian;
                    cs.Tag = t;
                    return cs;

                case "SH":
                    ShortString sh = new ShortString();
                    sh.ByteData = data;
                    sh.EncodeType = encType;
                    sh.IsLittleEndian = isLittleEndian;
                    sh.Tag = t;
                    return sh;

                case "LO":
                    LongString lo = new LongString();
                    lo.ByteData = data;
                    lo.EncodeType = encType;
                    lo.IsLittleEndian = isLittleEndian;
                    lo.Tag = t;
                    return lo;

                case "ST":
                    ShortText st = new ShortText();
                    st.ByteData = data;
                    st.EncodeType = encType;
                    st.IsLittleEndian = isLittleEndian;
                    st.Tag = t;
                    return st;

                case "LT":
                    LongText lt = new LongText();
                    lt.ByteData = data;
                    lt.EncodeType = encType;
                    lt.IsLittleEndian = isLittleEndian;
                    lt.Tag = t;
                    return lt;

                case "UT":
                    UnlimitedText ut = new UnlimitedText();
                    ut.ByteData = data;
                    ut.EncodeType = encType;
                    ut.IsLittleEndian = isLittleEndian;
                    ut.Tag = t;
                    return ut;

                case "AE":
                    ApplicationEntity ae = new ApplicationEntity();
                    ae.ByteData = data;
                    ae.EncodeType = encType;
                    ae.IsLittleEndian = isLittleEndian;
                    ae.Tag = t;
                    return ae;

                case "PN":
                    PersonsName pn = new PersonsName();
                    pn.ByteData = data;
                    pn.EncodeType = encType;
                    pn.IsLittleEndian = isLittleEndian;
                    pn.Tag = t;
                    return pn;

                case "UI":
                    UniqueIdentifier ui = new UniqueIdentifier();
                    ui.ByteData = data;
                    ui.EncodeType = encType;
                    ui.IsLittleEndian = isLittleEndian;
                    ui.Tag = t;
                    return ui;

                case "DA":
                    DateVR da = new DateVR();
                    da.ByteData = data;
                    da.EncodeType = encType;
                    da.IsLittleEndian = isLittleEndian;
                    da.Tag = t;
                    return da;

                case "TM":
                    TimeVR tm = new TimeVR();
                    tm.ByteData = data;
                    tm.EncodeType = encType;
                    tm.IsLittleEndian = isLittleEndian;
                    tm.Tag = t;
                    return tm;

                case "DT":
                    DateTimeVR dt = new DateTimeVR();
                    dt.ByteData = data;
                    dt.EncodeType = encType;
                    dt.IsLittleEndian = isLittleEndian;
                    dt.Tag = t;
                    return dt;

                case "AS":
                    AgeString aSt = new AgeString();
                    aSt.ByteData = data;
                    aSt.EncodeType = encType;
                    aSt.IsLittleEndian = isLittleEndian;
                    aSt.Tag = t;
                    return aSt;

                case "IS":
                    IntegerString iSt = new IntegerString();
                    iSt.ByteData = data;
                    iSt.EncodeType = encType;
                    iSt.IsLittleEndian = isLittleEndian;
                    iSt.Tag = t;
                    return iSt;

                case "DS":
                    DecimalString ds = new DecimalString();
                    ds.ByteData = data;
                    ds.EncodeType = encType;
                    ds.IsLittleEndian = isLittleEndian;
                    ds.Tag = t;
                    return ds;

                case "SS":
                    SignedShort ss = new SignedShort();
                    ss.ByteData = data;
                    ss.EncodeType = encType;
                    ss.IsLittleEndian = isLittleEndian;
                    ss.Tag = t;
                    return ss;

                case "US":
                    UnsignedShort us = new UnsignedShort();
                    us.ByteData = data;
                    us.EncodeType = encType;
                    us.IsLittleEndian = isLittleEndian;
                    us.Tag = t;
                    return us;

                case "SL":
                    SignedLong sl = new SignedLong();
                    sl.ByteData = data;
                    sl.EncodeType = encType;
                    sl.IsLittleEndian = isLittleEndian;
                    sl.Tag = t;
                    return sl;

                case "UL":
                    UnsignedLong ul = new UnsignedLong();
                    ul.ByteData = data;
                    ul.EncodeType = encType;
                    ul.IsLittleEndian = isLittleEndian;
                    ul.Tag = t;
                    return ul;

                case "AT":
                    AttributeTag at = new AttributeTag();
                    at.ByteData = data;
                    at.EncodeType = encType;
                    at.IsLittleEndian = isLittleEndian;
                    at.Tag = t;
                    return at;

                case "FL":
                    FloatingPointSingle fl = new FloatingPointSingle();
                    fl.ByteData = data;
                    fl.EncodeType = encType;
                    fl.IsLittleEndian = isLittleEndian;
                    fl.Tag = t;
                    return fl;

                case "FD":
                    FloatingPointDouble fd = new FloatingPointDouble();
                    fd.ByteData = data;
                    fd.EncodeType = encType;
                    fd.IsLittleEndian = isLittleEndian;
                    fd.Tag = t;
                    return fd;

                case "OB":
                    if (t.Id == TagHelper.PIXEL_DATA)
                    {
                        PixelData fd1 = new PixelData(data, encType, isLittleEndian, "OB", isIndefinite);
                        fd1.Format = isIndefinite ? FrameDataFormat.ENCAPSULATED : FrameDataFormat.NATIVE;
                        fd1.EncodeType = encType;
                        fd1.IsLittleEndian = isLittleEndian;
                        fd1.Tag = t;
                        return fd1;
                    }
                    else
                    {
                        OtherByteString ob = new OtherByteString();
                        ob.ByteData = data;
                        ob.EncodeType = encType;
                        ob.IsLittleEndian = isLittleEndian;
                        ob.Tag = t;
                        return ob;
                    }
                case "OW":
                    if (t.Id == TagHelper.PIXEL_DATA)
                    {
                        PixelData fd2 = new PixelData(data, encType, isLittleEndian, "OW", isIndefinite);
                        fd2.Format = isIndefinite ? FrameDataFormat.ENCAPSULATED : FrameDataFormat.NATIVE;
                        fd2.EncodeType = encType;
                        fd2.IsLittleEndian = isLittleEndian;
                        fd2.Tag = t;
                        return fd2;
                    }
                    else
                    {
                        OtherWordString ow = new OtherWordString();
                        ow.ByteData = data;
                        ow.EncodeType = encType;
                        ow.IsLittleEndian = isLittleEndian;
                        ow.Tag = t;
                        return ow;
                    }

                case "OF":
                    OtherFloatString of = new OtherFloatString();
                    of.ByteData = data;
                    of.EncodeType = encType;
                    of.IsLittleEndian = isLittleEndian;
                    of.Tag = t;
                    return of;

                case "SQ":
                    Sequence s = new Sequence();
                    s.ByteData = data;
                    s.EncodeType = encType;
                    s.IsLittleEndian = isLittleEndian;
                    s.Tag = t;
                    s.ReadChildren();
                    return s;

                default:
                    //Case for unknown VR
                    DICOMElement dOb = new DICOMElement();
                    dOb.ByteData = data;
                    dOb.EncodeType = encType;
                    dOb.IsLittleEndian = isLittleEndian;
                    dOb.Tag = t;
                    return dOb;
            }
        }
Esempio n. 14
0
        public async Task <int> CreateValueObjectRecipeAsync(IFormCollection form, User creator, String wwwroot)
        {
            if (creator != null)
            {
                //this._id = new Integer(lastID+1);
                _creator              = creator;
                this._creatorID       = new Integer(creator.GetUserID);
                this._creatorUsername = new Text(creator.strUsername);
                this._recipeName      = new Text(form["strRecipeName"]);
                //Ingredients ingredient = new Ingredients(new Text("Hardcoded Recipe.cs line 125"), new Quantity(new Number(10), new MeasuringUnit(new ShortText("idk"))));

                //_ingredientsList.Add(ingredient);
                //this._ingredients = ingredient;
                _ingredientsAsStringInput = new LongText(form["strRawIngredients"].ToString());
                var lines = form["strRawIngredients"].ToString().Split("\r\n");
                for (int i = 0; i < lines.Length; i++)
                {
                    var         ingredientName     = lines[i].Split(' ')[0];
                    var         ingredientQuantity = float.Parse(lines[i].Split(' ')[1]);
                    var         ingredientMeasUnit = lines[i].Split(' ')[2];
                    Ingredients ingredient         = new Ingredients(new Text(ingredientName), new Quantity(new Number(ingredientQuantity), new MeasuringUnit(new ShortText(ingredientMeasUnit))));
                    AddInexistentIngredient(ingredient);
                }
                this._preparation = new LongText(form["strPreparation"]);
                this._price       = new Number(0);
                this._likes       = new Integer(0);
                this._dislikes    = new Integer(0);


                this._tags = new Text(form["strComboBoxTag1"] + "_" + form["strComboBoxTag2"] + "_" + form["strComboBoxTag3"]);



                var allfiles = form.Files;

                string PremiumRequest = form["strPremium"].ToString();


                if (PremiumRequest == "true")
                {
                    this._premiumRequest = true;
                }

                //var filePath = Path.GetTempFileName();
                if (!Directory.Exists(wwwroot + @"images\" + creator.strUsername + @"\" + this._recipeName.GetText))
                {
                    Directory.CreateDirectory(wwwroot + @"images\" + creator.strUsername + @"\" + this._recipeName.GetText + @"\video");
                    Directory.CreateDirectory(wwwroot + @"images\" + creator.strUsername + @"\" + this._recipeName.GetText + @"\image");
                }
                foreach (var file in allfiles)
                {
                    if (video.Contains(Path.GetExtension(file.FileName)))
                    {
                        var filePath = wwwroot + @"/images/" + creator.strUsername + @"/" + this._recipeName.GetText + @"/video" + @"/video" + Path.GetExtension(file.FileName);
                        using (var stream = new FileStream(filePath, FileMode.OpenOrCreate))
                        {
                            var fileName = file.FileName;
                            await file.CopyToAsync(stream);

                            this._videoLocation = new LongText(filePath.Split(wwwroot)[1]);
                        }
                    }
                    else if (image.Contains(Path.GetExtension(file.FileName)))
                    {
                        var filePath = wwwroot + @"/images/" + creator.strUsername + @"/" + this._recipeName.GetText + @"/image" + @"/image" + Path.GetExtension(file.FileName);
                        using (var stream = new FileStream(filePath, FileMode.OpenOrCreate))
                        {
                            var fileName = file.FileName;
                            await file.CopyToAsync(stream);

                            this._imageLocation = new LongText(filePath.Split(wwwroot)[1]);
                        }
                    }
                }
                this._creatorID       = new Integer(creator.GetUserID);
                this._creatorUsername = creator.GetUsername;

                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 15
0
        public void TestLoadingConstructor()
        {
            LongText longText = new LongText("test");

            Assert.IsTrue(longText.Value.Equals("test"));
        }
        /// <summary>
        /// This static function returns the Re-Construted value of the particular Dicom attribute.
        /// </summary>
        /// <param name="attribute">Dicom attribute contains tag vr and value</param>
        /// <returns>Returns the value of the Dicom attribute</returns>
        public static String GetDicomValue(DvtkData.Dimse.Attribute attribute)
        {
            String dumpString = "";

            if (attribute != null && attribute.Length != 0)
            {
                switch (attribute.ValueRepresentation)
                {
                case VR.AE:
                {
                    ApplicationEntity applicationEntity = (ApplicationEntity)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(applicationEntity.Values));
                    break;
                }

                case VR.AS:
                {
                    AgeString ageString = (AgeString)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(ageString.Values));
                    break;
                }

                case VR.AT:
                {
                    AttributeTag attributeTag = (AttributeTag)attribute.DicomValue;
                    Console.WriteLine("{0}", GetValues(attributeTag.Values));
                    break;
                }

                case VR.CS:
                {
                    CodeString codeString = (CodeString)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(codeString.Values));
                    break;
                }

                case VR.DA:
                {
                    Date date = (Date)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(date.Values));
                    break;
                }

                case VR.DS:
                {
                    DecimalString decimalString = (DecimalString)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(decimalString.Values));
                    break;
                }

                case VR.DT:
                {
                    DvtkData.Dimse.DateTime dateTime = (DvtkData.Dimse.DateTime)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(dateTime.Values));
                    break;
                }

                case VR.FD:
                {
                    FloatingPointDouble floatingPointDouble = (FloatingPointDouble)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(floatingPointDouble.Values));
                    break;
                }

                case VR.FL:
                {
                    FloatingPointSingle floatingPointSingle = (FloatingPointSingle)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(floatingPointSingle.Values));
                    break;
                }

                case VR.IS:
                {
                    IntegerString integerString = (IntegerString)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(integerString.Values));
                    break;
                }

                case VR.LO:
                {
                    LongString longString = (LongString)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(longString.Values));
                    break;
                }

                case VR.LT:
                {
                    LongText longText = (LongText)attribute.DicomValue;
                    dumpString += String.Format("{0}", longText.Value);
                    break;
                }

                case VR.OB:
                {
                    OtherByteString otherByteString = (OtherByteString)attribute.DicomValue;
                    dumpString += String.Format("{0}", otherByteString.FileName);
                    break;
                }

                case VR.OF:
                {
                    OtherFloatString otherFloatString = (OtherFloatString)attribute.DicomValue;
                    dumpString += String.Format("{0}", otherFloatString.FileName);
                    break;
                }

                case VR.OW:
                {
                    OtherWordString otherWordString = (OtherWordString)attribute.DicomValue;
                    dumpString += String.Format("{0}", otherWordString.FileName);
                    break;
                }

                case VR.OV:
                {
                    OtherVeryLongString otherVeryLongString = (OtherVeryLongString)attribute.DicomValue;
                    dumpString += String.Format("{0}", otherVeryLongString.FileName);
                    break;
                }

                case VR.PN:
                {
                    PersonName personName = (PersonName)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(personName.Values));
                    break;
                }

                case VR.SH:
                {
                    ShortString shortString = (ShortString)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(shortString.Values));
                    break;
                }

                case VR.SL:
                {
                    SignedLong signedLong = (SignedLong)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(signedLong.Values));
                    break;
                }

                case VR.SQ:
                {
                    //SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue;
                    //int itemNumber = 1;
                    //dumpString += "\r\n";
                    //foreach (SequenceItem item in sequenceOfItems.Sequence)
                    //{
                    //    dumpString += String.Format("> Begin Item: {0}\r\n", itemNumber);
                    //    dumpString += item.Dump(prefix);
                    //    dumpString += prefix + String.Format("> End Item: {0}\r\n", itemNumber++);
                    //}
                    break;
                }

                case VR.SS:
                {
                    SignedShort signedShort = (SignedShort)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(signedShort.Values));
                    break;
                }

                case VR.ST:
                {
                    ShortText shortText = (ShortText)attribute.DicomValue;
                    dumpString += String.Format("{0}", shortText.Value);
                    break;
                }

                case VR.TM:
                {
                    Time time = (Time)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(time.Values));
                    break;
                }

                case VR.UI:
                {
                    UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(uniqueIdentifier.Values));
                    break;
                }

                case VR.UL:
                {
                    UnsignedLong unsignedLong = (UnsignedLong)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(unsignedLong.Values));
                    break;
                }

                case VR.UN:
                {
                    break;
                }

                case VR.US:
                {
                    UnsignedShort unsignedShort = (UnsignedShort)attribute.DicomValue;
                    dumpString += String.Format("{0}", GetValues(unsignedShort.Values));
                    break;
                }

                case VR.UT:
                {
                    break;
                }

                case VR.UR:
                {
                    break;
                }

                case VR.UC:
                {
                    break;
                }

                default:
                    dumpString += String.Format("\'  \'");
                    break;
                }
            }
            else
            {
                dumpString += String.Format("\'  \'");
            }


            return(dumpString);
        }
Esempio n. 17
0
        public static byte[] GetStringBytes(VR vr, IDICOMElement el)
        {
            string data;

            byte[] unpadded;
            switch (vr)
            {
            case VR.AgeString:
                AgeString age = el as AgeString;
                data     = age.DataContainer.SingleValue;
                unpadded = GetASCIIBytes(data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.ApplicationEntity:
                ApplicationEntity ae = el as ApplicationEntity;
                unpadded = GetASCIIBytes(ae.DataContainer.SingleValue);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.CodeString:
                CodeString cs = el as CodeString;
                unpadded = GetASCIIBytes(cs.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.Date:
                Date d = el as Date;
                data     = StringDataComposer.ComposeDate(d.DataContainer.SingleValue);
                unpadded = GetASCIIBytes(data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.DateTime:
                EvilDICOM.Core.Element.DateTime dt = el as EvilDICOM.Core.Element.DateTime;
                data     = StringDataComposer.ComposeDateTime(dt.DataContainer.SingleValue);
                unpadded = GetASCIIBytes(data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.DecimalString:
                DecimalString ds = el as DecimalString;
                data     = StringDataComposer.ComposeDecimalString(ds.DataContainer.MultipicityValue.ToArray());
                unpadded = GetASCIIBytes(data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.IntegerString:
                IntegerString iSt = el as IntegerString;
                data     = StringDataComposer.ComposeIntegerString(iSt.DataContainer.MultipicityValue.ToArray());
                unpadded = GetASCIIBytes(data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.LongString:
                LongString ls = el as LongString;
                unpadded = GetASCIIBytes(ls.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.LongText:
                LongText lt = el as LongText;
                unpadded = GetASCIIBytes(lt.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.PersonName:
                PersonName pn = el as PersonName;
                unpadded = GetASCIIBytes(pn.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.ShortString:
                ShortString ss = el as ShortString;
                unpadded = GetASCIIBytes(ss.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.ShortText:
                ShortText st = el as ShortText;
                unpadded = GetASCIIBytes(st.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.Time:
                Time t = el as Time;
                data     = StringDataComposer.ComposeTime(t.DataContainer.SingleValue);
                unpadded = GetASCIIBytes(data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.UnlimitedText:
                UnlimitedText ut = el as UnlimitedText;
                unpadded = GetASCIIBytes(ut.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            case VR.UniqueIdentifier:
                UniqueIdentifier ui = el as UniqueIdentifier;
                unpadded = GetASCIIBytes(ui.Data);
                return(DataRestriction.EnforceEvenLength(unpadded, vr));

            default: return(null);
            }
        }
Esempio n. 18
0
        public void TestToString()
        {
            LongText longText = new LongText("test");

            Assert.AreEqual("test", longText.ToString());
        }