コード例 #1
0
        private static ServerDirectoryEntry FromDeviceToServerDirectoryEntry(Device theDevice)
        {
            var entry = new ServerDirectoryEntry(new ApplicationEntity
            {
                AETitle       = theDevice.AeTitle,
                Description   = theDevice.Description,
                Name          = theDevice.Name,
                ScpParameters =
                    new ScpParameters(theDevice.IpAddress, theDevice.Port)
            });

            return(entry);
        }
コード例 #2
0
        public void TestExtensionDataSerialization()
        {
            var entry = new ServerDirectoryEntry();

            entry.Data["test1"] = new TestValue {
                Value = "value1"
            };
            entry.Data["test2"] = new TestValue2 {
                Value = "value2"
            };

            var serialized   = Serializer.SerializeServerExtensionData(entry.Data);
            var deserialized = Serializer.DeserializeServerExtensionData(serialized);

            Assert.AreEqual(2, deserialized.Count);
            Assert.AreEqual(deserialized["test1"], new TestValue {
                Value = "value1"
            });
            Assert.AreEqual(deserialized["test2"], new TestValue2 {
                Value = "value2"
            });

            var serializer = new DataContractSerializer(typeof(ServerDirectoryEntry), ServerDirectoryEntry.GetKnownTypes());

            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, entry);
                stream.Position = 0;
                var deserializedEntry = serializer.ReadObject(stream) as ServerDirectoryEntry;
                deserialized = deserializedEntry.Data;

                Assert.AreEqual(2, deserialized.Count);
                Assert.AreEqual(deserialized["test1"], new TestValue {
                    Value = "value1"
                });
                Assert.AreEqual(deserialized["test2"], new TestValue2 {
                    Value = "value2"
                });
            }
        }
コード例 #3
0
        public static Device ToDevice(this ServerDirectoryEntry serverDirectoryEntry)
        {
            Platform.CheckForNullReference(serverDirectoryEntry, "serverDirectoryEntry");
            Platform.CheckMemberIsSet(serverDirectoryEntry.Server, "Server");
            Platform.CheckMemberIsSet(serverDirectoryEntry.Server.ScpParameters, "ScpParameters");

            int?streamingHeaderPort = null;
            int?streamingImagePort  = null;

            if (serverDirectoryEntry.Server.StreamingParameters != null)
            {
                streamingHeaderPort = serverDirectoryEntry.Server.StreamingParameters.HeaderServicePort;
                streamingImagePort  = serverDirectoryEntry.Server.StreamingParameters.WadoServicePort;
            }

            string extensionData = null;

            if (serverDirectoryEntry.Data != null)
            {
                extensionData = Serializer.SerializeServerExtensionData(serverDirectoryEntry.Data);
            }

            return(new Device
            {
                Name = serverDirectoryEntry.Server.Name,
                AETitle = serverDirectoryEntry.Server.AETitle,
                HostName = serverDirectoryEntry.Server.ScpParameters.HostName,
                Port = serverDirectoryEntry.Server.ScpParameters.Port,
                Location = serverDirectoryEntry.Server.Location,
                Description = serverDirectoryEntry.Server.Description,
                StreamingHeaderPort = streamingHeaderPort,
                StreamingImagePort = streamingImagePort,
                IsPriorsServer = serverDirectoryEntry.IsPriorsServer,
                ExtensionData = extensionData
            });
        }
コード例 #4
0
ファイル: ServerDirectoryTests.cs プロジェクト: nhannd/Xian
        public void TestExtensionDataSerialization()
        {
            var entry = new ServerDirectoryEntry();
            entry.Data["test1"] = new TestValue {Value = "value1"};
            entry.Data["test2"] = new TestValue2 { Value = "value2" };

            var serialized = Serializer.SerializeServerExtensionData(entry.Data);
            var deserialized = Serializer.DeserializeServerExtensionData(serialized);

            Assert.AreEqual(2, deserialized.Count);
            Assert.AreEqual(deserialized["test1"], new TestValue{Value = "value1"});
            Assert.AreEqual(deserialized["test2"], new TestValue2 { Value = "value2" });

            var serializer = new DataContractSerializer(typeof(ServerDirectoryEntry), ServerDirectoryEntry.GetKnownTypes()); 
            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, entry);
                stream.Position = 0;
                var deserializedEntry = serializer.ReadObject(stream) as ServerDirectoryEntry;
                deserialized = deserializedEntry.Data;

                Assert.AreEqual(2, deserialized.Count);
                Assert.AreEqual(deserialized["test1"], new TestValue { Value = "value1" });
                Assert.AreEqual(deserialized["test2"], new TestValue2 { Value = "value2" });
            }
        }
コード例 #5
0
ファイル: ServiceNode.cs プロジェクト: hksonngan/Xian
 public static IDicomServiceNode ToServiceNode(this ServerDirectoryEntry directoryEntry)
 {
     Platform.CheckForNullReference(directoryEntry, "directoryEntry");
     return(new DicomServiceNode(directoryEntry));
 }
コード例 #6
0
        private static ServerDirectoryEntry FromDeviceToServerDirectoryEntry(Device theDevice)
        {
            var entry = new ServerDirectoryEntry(new ApplicationEntity
                                                     {
                                                         AETitle = theDevice.AeTitle,
                                                         Description = theDevice.Description,
                                                         Name = theDevice.Name,
                                                         ScpParameters =
                                                             new ScpParameters(theDevice.IpAddress, theDevice.Port)
                                                     });

            return entry;
        }