public void FieldTest() { DicomAttributeCollection theSet = new DicomAttributeCollection(); TestFields theFields = new TestFields(); SetupMR(theSet); theSet.LoadDicomFields(theFields); Assert.IsTrue(theFields.AccessionNumber.Equals(theSet[DicomTags.AccessionNumber].GetString(0, "")), "Accession Numbers did not match!"); Assert.IsTrue(theFields.SopClassUid.UID.Equals(theSet[DicomTags.SopClassUid].GetString(0, "")), "SOP Class UIDs did not match!"); Assert.IsTrue(theFields.SOPInstanceUID.UID.Equals(theSet[DicomTags.SopInstanceUid].GetString(0, "")), "SOP Class UIDs did not match!"); Assert.IsTrue(theFields.StudyDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture).Equals(theSet[DicomTags.StudyDate].GetString(0, ""))); Assert.IsTrue(theFields.Modality.Equals(theSet[DicomTags.Modality].GetString(0, "")), "Modality did not match!"); Assert.IsTrue(theFields.StudyDescription.Equals(theSet[DicomTags.StudyDescription].GetString(0, "")), "Study Description did not match!"); Assert.IsTrue(theFields.StudyInstanceUID.UID.Equals(theSet[DicomTags.StudyInstanceUid].GetString(0, "")), "Study Instance UIDs did not match!"); Assert.IsTrue(theFields.SeriesInstanceUID.UID.Equals(theSet[DicomTags.SeriesInstanceUid].GetString(0, "")), "Series Instance UIDs did not match!"); Assert.IsTrue(theFields.StudyID.Equals(theSet[DicomTags.StudyId].GetString(0, "")), "StudyID did not match!"); Assert.IsTrue(theFields.PatientsName.Equals(theSet[DicomTags.PatientsName].GetString(0, "")), "PatientsName did not match!"); Assert.IsTrue(theFields.PatientID.Equals(theSet[DicomTags.PatientId].GetString(0, "")), "PatientID did not match!"); Assert.IsTrue(theFields.PatientsBirthDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture).Equals(theSet[DicomTags.PatientsBirthDate].GetString(0, ""))); Assert.IsTrue(theFields.PatientsSex.Equals(theSet[DicomTags.PatientsSex].GetString(0, "")), "PatientsSex did not match!"); Assert.IsTrue(theFields.Rows == theSet[DicomTags.Rows].GetUInt16(0, 0)); Assert.IsTrue(theFields.Columns == theSet[DicomTags.Columns].GetUInt16(0, 0)); float floatValue; theSet[DicomTags.PixelSpacing].TryGetFloat32(0, out floatValue); Assert.IsTrue(theFields.PixelSpacing == floatValue); int intValue; theSet[DicomTags.InstanceNumber].TryGetInt32(0, out intValue); Assert.IsTrue(theFields.InstanceNumber == intValue); //Assert.IsTrue(string.Join("\\", theFields.ImageType).Equals(theSet[DicomTags.ImageType].ToString())); }
public void GetTargetType () { TestFields fields = new TestFields { MaxValue = 1234 }; TypedReference ti = __makeref(fields); Assert.AreEqual (typeof (TestFields), TypedReference.GetTargetType (ti)); }
public void GetTargetType() { TestFields fields = new TestFields { MaxValue = 1234 }; TypedReference ti = __makeref(fields); Assert.AreEqual(typeof(TestFields), TypedReference.GetTargetType(ti)); }
static void Main(string[] args) { var propertyInfo = typeof(TestFields).GetProperty("MaxValue"); var propertySetter = (RefAction <TestFields, int>)Delegate.CreateDelegate(typeof(RefAction <TestFields, int>), propertyInfo.GetSetMethod()); var fields = new TestFields { MaxValue = 1234 }; propertySetter(ref fields, 5678); Console.WriteLine(fields.MaxValue); }
public static void Main() { Fields fields = new Fields(); TestFields obj = new TestFields(); Assert(1, Count); Assert(1, GC.ReferenceCount(obj)); fields.Field = obj; Assert(1, Count); Assert(2, GC.ReferenceCount(obj)); }
public static void Main() { Fields fields = new Fields(); TestFields obj = new TestFields(); Assert( 1, Count ); Assert( 1, GC.ReferenceCount(obj) ); fields.Field = obj; Assert( 1, Count ); Assert( 2, GC.ReferenceCount(obj) ); }
static void Main(string[] args) { var propertyInfo = typeof(TestFields).GetProperty("MaxValueProperty"); var propertySetter = (RefAction <TestFields, int>)Delegate.CreateDelegate(typeof(RefAction <TestFields, int>), propertyInfo.GetSetMethod()); var fieldInfo = typeof(TestFields).GetField("MaxValue"); var dynamicMethod = new DynamicMethod(String.Empty, typeof(void), new Type[] { fieldInfo.ReflectedType.MakeByRefType(), fieldInfo.FieldType }, true); var ilGenerator = dynamicMethod.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Ldarg_1); ilGenerator.Emit(OpCodes.Stfld, fieldInfo); ilGenerator.Emit(OpCodes.Ret); var fieldSetter = (RefAction <TestFields, int>)dynamicMethod.CreateDelegate(typeof(RefAction <TestFields, int>)); var fields = new TestFields { MaxValue = 1234 }; propertySetter(ref fields, 5678); fieldSetter(ref fields, 90); Console.WriteLine(fields.MaxValue); }
public void FieldTest() { DicomAttributeCollection theSet = new DicomAttributeCollection(); TestFields theFields = new TestFields(); SetupMR(theSet); theSet.LoadDicomFields(theFields); Assert.IsTrue(theFields.AccessionNumber.Equals(theSet[DicomTags.AccessionNumber].GetString(0,"")), "Accession Numbers did not match!"); Assert.IsTrue(theFields.SopClassUid.UID.Equals(theSet[DicomTags.SopClassUid].GetString(0, "")), "SOP Class UIDs did not match!"); Assert.IsTrue(theFields.SOPInstanceUID.UID.Equals(theSet[DicomTags.SopInstanceUid].GetString(0, "")), "SOP Class UIDs did not match!"); Assert.IsTrue(theFields.StudyDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture).Equals(theSet[DicomTags.StudyDate].GetString(0, ""))); Assert.IsTrue(theFields.Modality.Equals(theSet[DicomTags.Modality].GetString(0, "")), "Modality did not match!"); Assert.IsTrue(theFields.StudyDescription.Equals(theSet[DicomTags.StudyDescription].GetString(0, "")), "Study Description did not match!"); Assert.IsTrue(theFields.StudyInstanceUID.UID.Equals(theSet[DicomTags.StudyInstanceUid].GetString(0, "")), "Study Instance UIDs did not match!"); Assert.IsTrue(theFields.SeriesInstanceUID.UID.Equals(theSet[DicomTags.SeriesInstanceUid].GetString(0, "")), "Series Instance UIDs did not match!"); Assert.IsTrue(theFields.StudyID.Equals(theSet[DicomTags.StudyId].GetString(0, "")), "StudyID did not match!"); Assert.IsTrue(theFields.PatientsName.Equals(theSet[DicomTags.PatientsName].GetString(0, "")), "PatientsName did not match!"); Assert.IsTrue(theFields.PatientID.Equals(theSet[DicomTags.PatientId].GetString(0, "")), "PatientID did not match!"); Assert.IsTrue(theFields.PatientsBirthDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture).Equals(theSet[DicomTags.PatientsBirthDate].GetString(0, ""))); Assert.IsTrue(theFields.PatientsSex.Equals(theSet[DicomTags.PatientsSex].GetString(0, "")), "PatientsSex did not match!"); Assert.IsTrue(theFields.Rows == theSet[DicomTags.Rows].GetUInt16(0,0)); Assert.IsTrue(theFields.Columns == theSet[DicomTags.Columns].GetUInt16(0,0)); float floatValue; theSet[DicomTags.PixelSpacing].TryGetFloat32(0, out floatValue); Assert.IsTrue(theFields.PixelSpacing == floatValue); int intValue; theSet[DicomTags.InstanceNumber].TryGetInt32(0, out intValue); Assert.IsTrue(theFields.InstanceNumber == intValue); //Assert.IsTrue(string.Join("\\", theFields.ImageType).Equals(theSet[DicomTags.ImageType].ToString())); }
public void SetValueDirect () { TestFields fields = new TestFields { MaxValue = 1234, str = "A" }; FieldInfo info = fields.GetType ().GetField ("MaxValue"); TypedReference reference = __makeref(fields); info.SetValueDirect (reference, 4096); Assert.AreEqual (4096, fields.MaxValue); info = fields.GetType ().GetField ("str"); reference = __makeref(fields); info.SetValueDirect (reference, "B"); Assert.AreEqual ("B", fields.str); }