AssociationFactory.cs :  » Network-Clients » DICOM » org » dicomcs » net » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » DICOM 
DICOM » org » dicomcs » net » AssociationFactory.cs
#region Copyright
// 
// This library is based on dcm4che see http://www.sourceforge.net/projects/dcm4che
// Copyright (c) 2002 by TIANI MEDGRAPH AG. All rights reserved.
//
// Modifications Copyright (C) 2002 Fang Yang. All rights reserved.
// 
// This file is part of dicomcs, see http://www.sourceforge.net/projects/dicom-cs
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.                                 
// 
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Fang Yang (yangfang@email.com)
//
#endregion

namespace org.dicomcs.net{
  using System;
  using org.dicomcs.net;
  using org.dicomcs.util;
  using org.dicomcs.data;
  
  /// <summary>
  /// Association related object factory
  /// </summary>
  public class AssociationFactory
  {
    private static AssociationFactory s_instance = new AssociationFactory();

    public static AssociationFactory Instance
    {
      get
      {
        return s_instance;
      }      
    }
    
    private AssociationFactory()
    {
    }
    
    public virtual AAssociateRQ NewAAssociateRQ()
    {
      return new AAssociateRQ();
    }
    
    public virtual AAssociateAC NewAAssociateAC()
    {
      return new AAssociateAC();
    }
    
    public virtual AAssociateRJ NewAAssociateRJ(int result, int source, int reason)
    {
      return new AAssociateRJ(result, source, reason);
    }
    
    public virtual PDataTF NewPDataTF(int maxLength)
    {
      return new PDataTF(maxLength);
    }
    
    public virtual AReleaseRQ NewAReleaseRQ()
    {
      return AReleaseRQ.Instance;
    }
    
    public virtual AReleaseRP NewAReleaseRP()
    {
      return AReleaseRP.Instance;
    }
    
    public virtual AAbort NewAAbort(int source, int reason)
    {
      return new AAbort(source, reason);
    }
    
    public virtual PresContext NewPresContext(int pcid, String asuid, String[] tsuids)
    {
      return new PresContext(0x020, pcid, 0, StringUtils.CheckUID(asuid), StringUtils.CheckUIDs(tsuids));
    }
    
    public virtual PresContext NewPresContext(int pcid, int result, String tsuid)
    {
      return new PresContext(0x021, pcid, result, null, new String[]{StringUtils.CheckUID(tsuid)});
    }
    
    public virtual AsyncOpsWindow NewAsyncOpsWindow(int maxOpsInvoked, int maxOpsPerfomed)
    {
      return new AsyncOpsWindow(maxOpsInvoked, maxOpsPerfomed);
    }
    
    public virtual RoleSelection NewRoleSelection(String uid, bool scu, bool scp)
    {
      return new RoleSelection(uid, scu, scp);
    }
    
    public virtual ExtNegotiation NewExtNegotiation(String uid, byte[] info)
    {
      return new ExtNegotiation(uid, info);
    }
    
    public virtual PduI readFrom(System.IO.Stream ins, byte[] buf)
    {
      UnparsedPdu raw = new UnparsedPdu(ins, buf);
      switch (raw.GetType())
      {
        case 1: 
          return AAssociateRQ.Parse(raw);
        
        case 2: 
          return AAssociateAC.Parse(raw);
        
        case 3: 
          return AAssociateRJ.Parse(raw);
        
        case 4: 
          return PDataTF.Parse(raw);
        
        case 5: 
          return AReleaseRQ.Parse(raw);
        
        case 6: 
          return AReleaseRP.Parse(raw);
        
        case 7: 
          return AAbort.Parse(raw);
        
        default: 
          throw new PduException("Unrecognized " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNRECOGNIZED_PDU));
        
      }
    }
    
    public virtual Association NewRequestor(System.Net.Sockets.TcpClient s)
    {
      return new Association(s, true);
    }
    
    public virtual Association NewAcceptor(System.Net.Sockets.TcpClient s)
    {
      return new Association(s, false);
    }
    
    public virtual ActiveAssociation NewActiveAssociation(Association assoc, DcmServiceRegistry services)
    {
      return new ActiveAssociation(assoc, services);
    }
    
    public virtual Dimse NewDimse(int pcid, Command cmd)
    {
      return new Dimse(pcid, cmd, null, null);
    }
    
    public virtual Dimse NewDimse(int pcid, Command cmd, Dataset ds)
    {
      return new Dimse(pcid, cmd, ds, null);
    }
    
    public virtual Dimse NewDimse(int pcid, Command cmd, DataSourceI src)
    {
      return new Dimse(pcid, cmd, null, src);
    }
    
    public virtual AcceptorPolicy NewAcceptorPolicy()
    {
      return new AcceptorPolicy();
    }
    
    public virtual DcmServiceRegistry NewDcmServiceRegistry()
    {
      return new DcmServiceRegistry();
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.