public TestZoneImpl(String zoneId, String zoneUrl, Agent agent, AgentProperties props,
                   MessageDispatcher dispatcher, IProtocolHandler proto)
     : base(zoneId, zoneUrl, agent, props)
 {
     this.Dispatcher = dispatcher;
      fProtocolHandler = proto;
 }
        public void setUp()
        {
            Adk.Initialize();

            fAgent = new TestAgent();
            fAgent.Initialize();
        }
        public virtual void Setup()
        {
            Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_US, (int)SdoLibraryType.All );
            //uses transportplugin interface , and factory method Createthat
            //returns new instance of class we're looking for
            TransportPlugin tp = new InMemoryTransportPlugin();
            Adk.Install( tp );
            fAgent = new TestAgent();
            fAgent.Initialize();
            fAgent.Properties.TransportProtocol = tp.Protocol;

            //createzone added To ZoneFactoryImpl
            fZone =  (TestZoneImpl)fAgent.ZoneFactory.GetInstance( "test", TEST_URL );
        }
        /// <summary>  Parse the command-line. This method may be called repeatedly, usually
        /// once from the sample agent's <c>main</code> function prior to
        /// initializing the Adk and again from the <c>Agent.initialize</code>
        /// method after initializing the Agent superclass. When called without an
        /// Agent instance, only those options that do not rely on an AgentProperties
        /// object are processed (e.g. the /D option).
        /// <p>
        /// *
        /// If a file named 'agent.rsp' exists in the current directory, any command
        /// line options specified will be appended to the command-line arguments
        /// passed to this method. Each line of the agent.rsp text file may be
        /// comprised of one or more arguments separated by spaces, so that the
        /// entirely set of arguments can be on one line or broken up onto many
        /// lines.<p>
        /// *
        /// </summary>
        /// <param name="agent">An Agent instance that will be updated when certain
        /// command-line options are parsed
        /// </param>
        /// <param name="arguments">The string of arguments provided by the <c>main</code>
        /// function
        /// 
        /// </param>
        public static NameValueCollection parseCL( Agent agent,
                                                   string[] arguments )
        {
            if( sArguments == null )
            {
                sArguments = ReadArgsFromResponseFile( arguments );
            }

            if( agent == null )
            {
                ParseGlobalProperties();
                return null;
            }
            else
            {
                return ParseAgentProperties( agent );
            }
        }
 /// <summary>
 /// Activate the transport for this agent. This mehods is called
 /// when the agent is being initialized
 /// </summary>
 /// <param name="agent"></param>
 public override void Activate( Agent agent )
 {
 }
        private static NameValueCollection ParseAgentProperties( Agent agent )
        {
            //  Parse all other options...
            AgentProperties props = agent.Properties;
            NameValueCollection misc = new NameValueCollection();

            int port = -1;
            string host = null;
            bool useHttps = false;
            string sslCert = null;
            string clientCert = null;
            int clientAuth = 0;

            for( int i = 0; i < sArguments.Length; i++ )
            {
                if( sArguments[ i ].ToUpper().Equals( "/sourceId".ToUpper() ) &&
                     i != sArguments.Length - 1 )
                {
                    agent.Id = sArguments[ ++i ];
                }
                else if( sArguments[ i ].ToUpper().Equals( "/noreg".ToUpper() ) )
                {
                    Reg = false;
                }
                else if( sArguments[ i ].ToUpper().Equals( "/unreg".ToUpper() ) )
                {
                    Unreg = true;
                }
                else if( sArguments[ i ].ToUpper().Equals( "/pull".ToUpper() ) )
                {
                    props.MessagingMode = AgentMessagingMode.Pull;
                }
                else if( sArguments[ i ].ToUpper().Equals( "/push".ToUpper() ) )
                {
                    props.MessagingMode = AgentMessagingMode.Push;
                }
                else if( sArguments[ i ].ToUpper().Equals( "/port".ToUpper() ) &&
                          i != sArguments.Length - 1 )
                {
                    try
                    {
                        port = Int32.Parse( sArguments[ ++i ] );
                    }
                    catch( FormatException )
                    {
                        Console.WriteLine( "Invalid port: " + sArguments[ i - 1 ] );
                    }
                }
                else if( sArguments[ i ].ToUpper().Equals( "/https".ToUpper() ) )
                {
                    useHttps = true;
                }
                else if( sArguments[ i ].ToUpper().Equals( "/sslCert".ToUpper() ) )
                {
                    sslCert = sArguments[ ++i ];
                }
                else if( sArguments[ i ].ToUpper().Equals( "/clientCert".ToUpper() ) )
                {
                    clientCert = sArguments[ ++i ];
                }
                else if( sArguments[ i ].ToUpper().Equals( "/clientAuth".ToUpper() ) )
                {
                    try
                    {
                        clientAuth = int.Parse( sArguments[ ++i ] );
                    }
                    catch( FormatException )
                    {
                        clientAuth = 0;
                    }
                }
                else if( sArguments[ i ].ToUpper().Equals( "/host".ToUpper() ) &&
                          i != sArguments.Length - 1 )
                {
                    host = sArguments[ ++i ];
                }
                else if( sArguments[ i ].ToUpper().Equals( "/timeout".ToUpper() ) &&
                          i != sArguments.Length - 1 )
                {
                    try
                    {
                        props.DefaultTimeout =
                            TimeSpan.FromMilliseconds( Int32.Parse( sArguments[ ++i ] ) );
                    }
                    catch( FormatException )
                    {
                        Console.WriteLine( "Invalid timeout: " + sArguments[ i - 1 ] );
                    }
                }
                else if( sArguments[ i ].ToUpper().Equals( "/freq".ToUpper() ) &&
                          i != sArguments.Length - 1 )
                {
                    try
                    {
                        props.PullFrequency =
                            TimeSpan.FromMilliseconds( int.Parse( sArguments[ ++i ] ) );
                    }
                    catch( FormatException )
                    {
                        Console.WriteLine
                            ( "Invalid pull frequency: " + sArguments[ i - 1 ] );
                    }
                }
                else if( sArguments[ i ].ToUpper().Equals( "/opensif".ToUpper() ) )
                {
                    //  OpenSIF reports attempts to re-subscribe to objects as an
                    //  error instead of a success status code. The Adk would therefore
                    //  throw an exception if it encountered the error, so we can
                    //  disable that behavior here.

                    props.IgnoreProvisioningErrors = true;
                }
                else if( sArguments[ i ][ 0 ] == '/' )
                {
                    if( i == sArguments.Length - 1 ||
                         sArguments[ i + 1 ].StartsWith( "/" ) )
                    {
                        misc[ sArguments[ i ].Substring( 1 ) ] = null;
                    }
                    else
                    {
                        misc[ sArguments[ i ].Substring( 1 ) ] = sArguments[ ++i ];
                    }
                }
            }

            if( useHttps )
            {
                //  Set transport properties (HTTPS)
                HttpsProperties https = agent.DefaultHttpsProperties;
                if( sslCert != null )
                {
                    https.SSLCertName = sslCert;
                }
                if( clientCert != null )
                {
                    https.ClientCertName = clientCert;
                }

                https.ClientAuthLevel = clientAuth;

                if( port != -1 )
                {
                    https.Port = port;
                }
                https.Host = host;

                props.TransportProtocol = "https";
            }
            else
            {
                //  Set transport properties (HTTP)
                HttpProperties http = agent.DefaultHttpProperties;
                if( port != -1 )
                {
                    http.Port = port;
                }
                http.Host = host;

                props.TransportProtocol = "http";
            }

            return misc;
        }
 /// <summary>  Protected constructor called by Agent to create root properties
 /// inherited by all zones
 /// </summary>
 protected internal AdkProperties( Agent agent )
     : this((AdkProperties) null)
 {
     Defaults( agent );
 }
 public TestZoneImpl(String zoneId, String zoneUrl, Agent agent, AgentProperties props)
     : base(zoneId, zoneUrl, agent, props)
 {
 }
 public TestZoneFactory(Agent agent)
     : base(agent)
 {
     // TODO Auto-generated constructor stub
 }
 /// <summary>  Constructor</summary>
 protected internal AgentProperties(Agent agent)
     : base(agent)
 {
 }