public void OnMessage(Apache.NMS.IMessage message)
        {
            try
            {
                var text = (ITextMessage)message;

                MyDto dto = null;
                // with ServiceReference (WCF)
                var serializer = new DataContractSerializer(typeof(MyDto));
                using(var stream = new MemoryStream(Encoding.UTF8.GetBytes(text.Text)))
                {
                    dto = (MyDto)serializer.ReadObject(stream);
                }
                // with WebReference:
                //var serializer = new XmlSerializer(typeof(MyDto));
                //using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text.Text)))
                //{
                //    dto = (MyDto)serializer.Deserialize(stream);
                //}

                if (OnNewMessage != null)
                    OnNewMessage(this, new MyDtoEventArgs(dto));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Example #2
0
 /// <summary>
 /// Creates a new ActiveMQConnection instance with the specified underlying IConnection and optionally specifying the default acknowledgement
 /// mode for new sessions.
 /// </summary>
 /// <param name="connection">The IConnection instance which this ActiveMQConnection should wrap.</param>
 /// <param name="acknowledgementMode">Optionally specify the default acknowledgement mode for new sessions.</param>
 internal NmsConnection(IConnection connection, Apache.NMS.AcknowledgementMode acknowledgementMode)
 {
     this.connection = connection;
     this.id = idCounter++;
     this.acknowledgementMode = acknowledgementMode;
     this.WireUpEvents();
 }
		public Apache.Cassandra.ColumnOrSuperColumn get(CassandraObject key, CassandraColumnPath column_path, Apache.Cassandra.ConsistencyLevel consistency_level)
		{
			return _client.get(
				key.TryToBigEndian(),
				Helper.CreateColumnPath(column_path),
				consistency_level);
		}
        private static void ServiceFileRequest(String wwwroot, HttpListenerRequest request, HttpListenerResponse response)
        {
            var relativePath = request.Url.AbsolutePath.Substring(1);

            relativePath = relativePath.Replace("/", Path.DirectorySeparatorChar.ToString());
            var absolutePath = Path.Combine(wwwroot, relativePath);

            if (File.Exists(absolutePath))
            {
                var extension = Path.GetExtension(absolutePath);
                response.ContentType = Apache.GetMime(extension);
                response.StatusCode  = 200; // HTTP 200 - SUCCESS

                // Open file, read bytes into buffer and write them to the output stream.
                using (FileStream fileReader = File.OpenRead(absolutePath))
                {
                    byte[] buffer = new byte[4096];
                    int    read;
                    while ((read = fileReader.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        response.OutputStream.Write(buffer, 0, read);
                    }
                }
            }
            else
            {
                String body = String.Format("No resource is available at the specified filepath: {0}", absolutePath);

                IResponseFormatter notFoundResponseFormatter = new PlainTextResponseFormatter(body, HttpStatusCode.NotFound);
                notFoundResponseFormatter.WriteContent(response);
            }
        }
        public void SendFile(HttpRequest request, String absolutePath)
        {
            Log($"Sending file: {absolutePath}");

            try {
                var extension   = Path.GetExtension(absolutePath);
                var contentType = Apache.GetMime(extension);
                var resp        = new HttpResponse(request.stream);
                if (contentType != null)
                {
                    resp.AddHeader("Content-Type", contentType);
                }

                using (FileStream fileReader = File.OpenRead(absolutePath)) {
                    byte[] buffer = new byte[4096];
                    int    read;
                    while ((read = fileReader.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        resp.SendPartialBody(buffer, 0, read);
                    }
                }
                Log($"Done sending file: {absolutePath}");
            }
            catch (System.IO.FileNotFoundException) {
                Log($"Not found: '{absolutePath}'");
                SendErrorResponse(HttpStatusCode.NotFound);
            }
            catch (Exception ex) {
                Log($"Error sending '{absolutePath}': {ex}");
                SendErrorResponse(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
Example #6
0
 public void MoveBomb(char[,] playGround, List <FlyingObjects> flyingObjects, List <Base> bases, ref bool hit, ref BigInteger score)
 {
     if (y < 39)
     {
         Console.ForegroundColor = ConsoleColor.Yellow;
         if (playGround[y + 1, x] != ' ')
         {
             if (playGround[y + 1, x] == '^')
             {
                 for (int i = 0; i < bases.Count; i++)
                 {
                     if ((y + 1 == bases[i].y - 2 && x == bases[i].x - 1) || (y + 1 == bases[i].y - 2 && x == bases[i].x) || (y + 1 == bases[i].y - 2 && x == bases[i].x + 1))
                     {
                         bases[i].delete(playGround);
                         bases.RemoveAt(i);
                         this.delete(playGround);
                         hit    = true;
                         score *= 2;
                         Apache.ScoreUpdate(score);
                     }
                 }
             }
             else if (playGround[y + 1, x] == '#')
             {
                 for (int i = 0; i < flyingObjects.Count; i++)
                 {
                     if ((y + 1 == flyingObjects[i].y && x == flyingObjects[i].x - 1) || (y + 1 == flyingObjects[i].y && x == flyingObjects[i].x + 1) || (y + 1 == flyingObjects[i].y - 1 && x == flyingObjects[i].x))
                     {
                         flyingObjects[i].delete(playGround);
                         flyingObjects.RemoveAt(i);
                         this.delete(playGround);
                         hit    = true;
                         score += 5;
                         Apache.ScoreUpdate(score);
                     }
                 }
             }
             else
             {
                 this.delete(playGround);
                 hit = true;
             }
         }
         else
         {
             this.delete(playGround);
             y++;
             playGround[y, x] = '*';
             Console.SetCursorPosition(x, y + 5);
             Console.Write('*');
             hit = false;
         }
     }
     else
     {
         this.delete(playGround);
         hit = true;
     }
 }
 public void add(CassandraObject key, CassandraColumnParent column_parent, CassandraCounterColumn column, Apache.Cassandra.ConsistencyLevel consistency_level)
 {
     _client.add(
         key.TryToBigEndian(),
         Helper.CreateColumnParent(column_parent),
         Helper.CreateCounterColumn(column),
         consistency_level);
 }
		public List<Apache.Cassandra.KeySlice> get_indexed_slices(CassandraColumnParent column_parent, CassandraIndexClause index_clause, CassandraSlicePredicate column_predicate, Apache.Cassandra.ConsistencyLevel consistency_level)
		{
			return _client.get_indexed_slices(
				Helper.CreateColumnParent(column_parent),
				Helper.CreateIndexClause(index_clause),
				Helper.CreateSlicePredicate(column_predicate),
				consistency_level);
		}
		public List<Apache.Cassandra.KeySlice> get_range_slices(CassandraColumnParent column_parent, CassandraSlicePredicate predicate, CassandraKeyRange range, Apache.Cassandra.ConsistencyLevel consistency_level)
		{
			return _client.get_range_slices(
				Helper.CreateColumnParent(column_parent),
				Helper.CreateSlicePredicate(predicate),
				Helper.CreateKeyRange(range),
				consistency_level);
		}
		public Dictionary<byte[], int> multiget_count(List<CassandraObject> keys, CassandraColumnParent column_parent, CassandraSlicePredicate predicate, Apache.Cassandra.ConsistencyLevel consistency_level)
		{
			return _client.multiget_count(
				Helper.ToByteArrayList(keys),
				Helper.CreateColumnParent(column_parent),
				Helper.CreateSlicePredicate(predicate),
				consistency_level);
		}
		public int get_count(CassandraObject key, CassandraColumnParent column_parent, CassandraSlicePredicate predicate, Apache.Cassandra.ConsistencyLevel consistency_level)
		{
			return _client.get_count(
				key.TryToBigEndian(),
				Helper.CreateColumnParent(column_parent),
				Helper.CreateSlicePredicate(predicate),
				consistency_level);
		}
Example #12
0
 public NmsConnection(Uri uri, Apache.NMS.AcknowledgementMode acknowledgementMode, NmsCredentials credentials, params object[] connectionFactoryConstructorParameters)
 {
     var factory = NMSConnectionFactory.CreateConnectionFactory(uri, connectionFactoryConstructorParameters);
     this.connection = (credentials == null)
         ? factory.CreateConnection()
         : factory.CreateConnection(credentials.Username, credentials.Password);
     this.id = idCounter++;
     this.WireUpEvents();
 }
Example #13
0
 public NmsConnection(IConnectionFactory connectionFactory, Apache.NMS.AcknowledgementMode acknowledgementMode, NmsCredentials credentials)
 {
     this.connection = (credentials == null)
         ? connectionFactory.CreateConnection()
         : connectionFactory.CreateConnection(credentials.Username, credentials.Password);
     this.acknowledgementMode = acknowledgementMode;
     this.id = idCounter++;
     this.WireUpEvents();
 }
Example #14
0
        public void OnMessage(Apache.NMS.IMessage message)
        {
            Console.WriteLine("OnMessage");
            //ITextMessage textMessage = message as ITextMessage;

            //if (textMessage == null) Console.WriteLine("Message is NULL or EMPTY");
            //else
            //Console.WriteLine("You have got the Message : " + textMessage.Text);
        }
Example #15
0
 public void MoveMissile(char[,] playGround, List <FlyingObjects> flyingObjects, List <FireBomb> bomb, ref bool hit, ref BigInteger score)
 {
     if (x < 119)
     {
         Console.ForegroundColor = ConsoleColor.Yellow;
         if (playGround[y, x + 1] != ' ')
         {
             if (playGround[y, x + 1] == '*')
             {
                 playGround[y, x]     = ' ';
                 playGround[y, x + 1] = ' ';
                 this.delete(playGround);
                 bomb[0].delete(playGround);
                 bomb.Remove(bomb[0]);
                 hit = true;
             }
             else
             {
                 if (playGround[y, x + 1] == '#')
                 {
                     this.delete(playGround);
                     hit = true;
                     foreach (var flyingObject in flyingObjects)
                     {
                         if (((x + 1) == flyingObject.x && y == (flyingObject.y + 1)) || ((x + 1) == (flyingObject.x - 1) && y == flyingObject.y) || ((x + 1) == flyingObject.x && y == (flyingObject.y - 1)))
                         {
                             score += 5;
                             Apache.ScoreUpdate(score);
                             flyingObject.delete(playGround);
                             flyingObjects.Remove(flyingObject);
                             break;
                         }
                     }
                 }
                 else
                 {
                     this.delete(playGround);
                     hit = true;
                 }
             }
         }
         else
         {
             playGround[y, x]     = ' ';
             playGround[y, x + 1] = '-';
             x++;
             Console.SetCursorPosition(x - 1, y + 5);
             Console.Write(" -");
             hit = false;
         }
     }
     else
     {
         this.delete(playGround);
         hit = true;
     }
 }
 /// <summary>
 /// Adds an
 /// <see cref="Apache.Http.Cookie.Cookie">HTTP cookie</see>
 /// , replacing any existing equivalent cookies.
 /// If the given cookie has already expired it will not be added, but existing
 /// values will still be removed.
 /// </summary>
 /// <param name="cookie">
 /// the
 /// <see cref="Apache.Http.Cookie.Cookie">cookie</see>
 /// to be added
 /// </param>
 /// <seealso cref="AddCookies(Apache.Http.Cookie.Cookie[])">AddCookies(Apache.Http.Cookie.Cookie[])
 ///     </seealso>
 public virtual void AddCookie(Apache.Http.Cookie.Cookie cookie)
 {
     lock (this)
     {
         if (cookie != null)
         {
             // first remove any old cookie that is equivalent
             cookies.Remove(cookie);
             if (!cookie.IsExpired(new DateTime()))
             {
                 cookies.AddItem(cookie);
             }
         }
     }
 }
Example #17
0
        private static void Callff()
        {
            Console.WriteLine("What should we call in?");
            Console.WriteLine("1. Mortars");
            Console.WriteLine("2. Apache");

            int callff = Convert.ToInt32(Console.ReadLine());

            if (callff == 1)
            {
                Mortar newMortar = new Mortar();
                Console.WriteLine("Mortars are being loaded");
                newMortar.Load();
                Console.ReadLine();
                Console.WriteLine("Firing...");
                newMortar.Fire();
                Console.WriteLine("Shots missed...\n");
                newMortar.ReLoad();
                Console.WriteLine("Target hit, press enter to fire for effect\n");
                Console.ReadLine();
                newMortar.Fireforeffect();
                Console.ReadLine();
                ReturntoBase();
            }

            else if (callff == 2)
            {
                Apache newApache = new Apache();
                Console.WriteLine("Apache inbound\n");
                Console.ReadLine();
                newApache.Load();
                Console.WriteLine("Rounds incoming\n");
                newApache.Fire();
                Console.WriteLine("Target almost destroyed, need to do another pass\n");
                Console.WriteLine("Press enter to have the apache re-engage and destroy the target");
                Console.ReadLine();
                newApache.ReLoad();
                newApache.Fireforeffect();
                Console.ReadLine();
                ReturntoBase();
            }
            else
            {
                Console.WriteLine("Mission Complete");
            }
        }
Example #18
0
            public override void WriteContent(HttpListenerResponse response)
            {
                var extension = Path.GetExtension(this.filePath);

                response.ContentType = Apache.GetMime(extension);
                response.StatusCode  = 200; // HTTP 200 - SUCCESS

                // Open file, read bytes into buffer and write them to the output stream.
                using (FileStream fileReader = File.OpenRead(this.filePath))
                {
                    byte[] buffer = new byte[4096];
                    int    read;
                    while ((read = fileReader.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        response.OutputStream.Write(buffer, 0, read);
                    }
                }
            }
        public void ProcessMessage(Apache.NMS.IMessage amqMessage, IMessageProducer errorMessageProducer)
        {
            try
            {
                var amqTextMessage = (ITextMessage)amqMessage;
                this.messageHandler.ProcessMessage(amqTextMessage);
            }
            catch (Exception e)
            {
                ActiveMQMessage errorMessage = (ActiveMQMessage)((ActiveMQMessage)amqMessage).Clone();
                errorMessage.ReadOnlyProperties = false;
                errorMessage.Properties["Bridge.Error.Message"] = e.ToString();
                errorMessage.Properties["Bridge.Error.OriginalDestination"] = amqMessage.NMSDestination.ToString();
                errorMessage.Properties["Bridge.Error.OriginalTimestamp"] = amqMessage.NMSTimestamp.ToString(CultureInfo.InvariantCulture);
                errorMessage.Properties["Bridge.Error.OriginalMessageId"] = amqMessage.NMSMessageId;

                errorMessageProducer.Send(errorMessage);
            }
        }
 /// <summary>
 /// Executes a "describe_keyspace" over the connection.
 /// 
 /// Note: This command is not yet finished.
 /// </summary>
 /// <param name="cassandraClient">opened Thrift client</param>
 public void Execute(Apache.Cassandra.Cassandra.Client cassandraClient)
 {
     Dictionary<string, Dictionary<string,string>> keySpaceDescription = cassandraClient.describe_keyspace(this.KeySpace);
     if (keySpaceDescription != null)
     {
         AquilesColumnFamily columnFamily = null;
         Dictionary<string, AquilesColumnFamily> columnFamilies = new Dictionary<string, AquilesColumnFamily>();
         Dictionary<string, Dictionary<string, string>>.Enumerator keySpaceEnumerator = keySpaceDescription.GetEnumerator();
         while (keySpaceEnumerator.MoveNext())
         {
             columnFamily = this.Translate(keySpaceEnumerator.Current.Key, keySpaceEnumerator.Current.Value);
             columnFamilies.Add(columnFamily.Name, columnFamily);
         }
         this.ColumnFamilies = columnFamilies;
     }
     else
     {
         this.ColumnFamilies = null;
     }
 }
        private void ComponentWrap(IComponentModel model, String key, IHandler handler, Apache.Avalon.Castle.MicroKernel.Interceptor.IInterceptedComponent interceptedComponent)
        {
            AssertNotNull( model );
            AssertNotNull( key );
            AssertNotNull( handler );

            m_wrap = true;
        }
Example #22
0
        /// <summary>
        /// This function is a callback function received whenever an ActiveMQ message is received from the server.  It processes the message and passes it on to the client via
        /// the MessageEvent handler.
        /// </summary>
        /// <param name="msg">ActiveMQ message received from the server</param>
        protected void OnMessage(Apache.NMS.IMessage msg)
        {
            string message = "";
             //string elements  = null ;
             string temp = null;
             //string holder = null ;
             //StringTokenizer st = null;
             //int index = 0 ;

             //System.out.println("onMessage(): " + ((TextMessage)msg).getText() );

             //if ( msg instanceof TextMessage )
             {
            Apache.NMS.ActiveMQ.Commands.ActiveMQTextMessage txtMsg = (Apache.NMS.ActiveMQ.Commands.ActiveMQTextMessage)msg;
            temp = txtMsg.Text;

            temp = HttpUtility.UrlDecode(temp);

            temp = temp.Trim();

            /*
            // Strip off first char of args if it is a "
            if( temp.substring(0,1).compareToIgnoreCase("\"") == 0 )
            {
               temp = (temp.substring( 1, temp.length())).trim() ;
               if( temp.substring(0,1).compareToIgnoreCase("\"") == 0 )
               {
                  // if 2 double quotes at end, take one double quote off
                  message += temp.substring( 0, temp.length()-1 );
               }
               else
               {
                  message += "\"" + temp ;
               }
            }
            else
            {
               message += temp ;
            }
            */
            message = temp;

            Dictionary<string, string> properties = new Dictionary<string, string>();
            foreach (string key in txtMsg.Properties.Keys)
            {
                object data = txtMsg.Properties[key];
                string sData = data as string;
                if (sData != null)
                {
                    properties[key] = HttpUtility.UrlDecode(sData).Trim();
                }
            }

            Message args = new Message(message, properties);

            if (m_immediateMethod)
            {
               MessageEvent(this, args);
            }
            else
            {
               lock (m_messageLock)
               {
                  m_messages.Add(args);
               }

               // signal the other thread that we've received a message (only used in WaitAndPoll() )
               lock (m_waitLock)
               {
                  m_waitCondition.Set();
               }
            }
             }
        }
 public Apache.Cassandra.CqlResult execute_cql_query(byte[] query, Apache.Cassandra.Compression compression)
 {
     return _client.execute_cql_query(query, compression);
 }
 public void batch_mutate(Dictionary<byte[], Dictionary<string, List<Apache.Cassandra.Mutation>>> mutation_map, Apache.Cassandra.ConsistencyLevel consistency_level)
 {
     _client.batch_mutate(mutation_map, consistency_level);
 }
Example #25
0
        public async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            BlobHelper Container = new BlobHelper();

            DocumentDBRepository.Initialize();
            string contentType = Request.Content.Headers.ContentType.MediaType; //ContentDisposition.DispositionType;
            string extension   = Apache.getExtension(contentType);

            if (extension.Length == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
            }
            string         fname     = System.Guid.NewGuid().ToString();
            String         blobId    = String.Format("{0}/{1}.{2}", formID, fname, extension);
            CloudBlockBlob blockBlob = Container.GetBlockBlobReference(blobId);
            await blockBlob.UploadFromStreamAsync(await Request.Content.ReadAsStreamAsync());

            Attachment att = new Attachment {
                MediaLink = blockBlob.Uri.ToString(), ContentType = contentType, Id = fname,
            };

            att.SetPropertyValue("blobId", blobId);
            await DocumentDBRepository.CreateAttachmentAsync(formID, att);

            //set contetn type to return json
            var response = new HttpResponseMessage();

            response = Request.CreateResponse(HttpStatusCode.OK, att);
            response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            return(response);

            //BlobHelper Container = new BlobHelper();
            //DocumentDBRepository.Initialize();
            //var response = new HttpResponseMessage();
            ////TODO CHange refernce to reflect media type by using the prefix fo content type header

            //var streamProvider = new MultipartMemoryStreamProvider();

            //await Request.Content.ReadAsMultipartAsync(streamProvider);
            //List<Attachment> attList= new List<Attachment>();
            //foreach (HttpContent fileContent in streamProvider.Contents) {

            //    //var fname = fileContent.Headers.ContentDisposition.FileName;
            //    //if (fileCon.IsFaulted || t.IsCanceled)
            //    //{
            //    //    throw new HttpResponseException(HttpStatusCode.InternalServerError);
            //    //}
            //    string fname = System.Guid.NewGuid().ToString();
            //    string contentType = fileContent.Headers.ContentDisposition.DispositionType;
            //    string extension = Apache.getExtension(contentType);
            //    CloudBlockBlob blockBlob = Container.GetBlockBlobReference(String.Format("{0}/{1}.{2}", formID, fname, extension));
            //    await blockBlob.UploadFromStreamAsync(await fileContent.ReadAsStreamAsync());

            //    Attachment att = new Attachment { MediaLink = blockBlob.Uri.ToString(), ContentType = contentType };
            //    attList.Add(att);
            //    await DocumentDBRepository.CreateAttachmentAsync(formID, att);
            //              //int imageId = DatabaseCode(stream);
            //              //return imageId;
            //    };
            ////var baseUri = string.Format("{0}://{1}:{2}", Request.RequestUri.Scheme, Request.RequestUri.Host, Request.RequestUri.Port);
            ////response.Headers.Location = new Uri(string.Format("{0}/images/{1}", baseUri, ImageId));

            ////set contetn type to return json
            //response = Request.CreateResponse(HttpStatusCode.OK, attList);
            //response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            //return response;
        }
Example #26
0
    public static void _EndGameScreen(BigInteger score)
    {
        Console.Clear();
        Console.ForegroundColor = ConsoleColor.DarkYellow;
        Console.SetCursorPosition(40, 20);

        Console.WriteLine("Your score is {0}", score);
        Console.SetCursorPosition(40, 22);
        Console.BackgroundColor = ConsoleColor.Cyan;
        Console.WriteLine("Retry");
        Console.BackgroundColor = ConsoleColor.Black;
        Console.SetCursorPosition(40, 24);
        Console.WriteLine("Exit");

        bool choise = false;
        int  row    = 0;

        while (!choise)
        {
            if (Console.KeyAvailable)
            {
                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.Enter:
                {
                    if (row == 0)
                    {
                        Apache.PlayApacheCombat();
                    }
                    else
                    {
                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                    }
                }
                break;

                case ConsoleKey.UpArrow:
                {
                    if (row == 1)
                    {
                        row--;
                        Console.SetCursorPosition(40, 22);
                        Console.BackgroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Retry");
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.SetCursorPosition(40, 24);
                        Console.WriteLine("Exit");
                    }
                }
                break;

                case ConsoleKey.DownArrow:
                {
                    if (row == 0)
                    {
                        row++;
                        Console.SetCursorPosition(40, 22);
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.WriteLine("Retry");
                        Console.BackgroundColor = ConsoleColor.Cyan;
                        Console.SetCursorPosition(40, 24);
                        Console.WriteLine("Exit");
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                }
                break;

                default:
                {
                    Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write(' ');
                    Console.SetCursorPosition(0, Console.CursorTop);
                }
                break;
                }
            }
        }
    }
 public CassandraClientWrapper(Apache.Cassandra.Cassandra.Iface client)
 {
     _client = client;
 }
 public void remove_counter(CassandraObject key, CassandraColumnPath path, Apache.Cassandra.ConsistencyLevel consistency_level)
 {
     _client.remove_counter(
         key.TryToBigEndian(),
         Helper.CreateColumnPath(path),
         consistency_level);
 }
 public void remove(CassandraObject key, CassandraColumnPath column_path, long timestamp, Apache.Cassandra.ConsistencyLevel consistency_level)
 {
     _client.remove(
         key.TryToBigEndian(),
         Helper.CreateColumnPath(column_path),
         timestamp,
         consistency_level);
 }
 public void login(Apache.Cassandra.AuthenticationRequest auth_request)
 {
     _client.login(auth_request);
 }
Example #31
0
    public static void Main()
    {
        Console.TreatControlCAsInput = true;
        string[] menu = new string[] { "1. Play game", "2. How to play", "3.Exit" };

        Console.SetWindowSize(120, 47);
        Console.BackgroundColor = ConsoleColor.Black;
        Console.Clear();

        StreamReader reader = new StreamReader("01-StartScreen.txt");

        using (reader)
        {
            string line;
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine(line = reader.ReadLine());
            }

            Console.ForegroundColor = ConsoleColor.DarkRed;
            for (int i = 7; i < 41; i++)
            {
                Console.WriteLine(line = reader.ReadLine());
            }
        }

        Console.ForegroundColor = ConsoleColor.DarkYellow;
        bool choise = false;
        int  row    = 0;

        Console.BackgroundColor = ConsoleColor.Cyan;
        Console.WriteLine(menu[0]);
        Console.BackgroundColor = ConsoleColor.Black;
        Console.WriteLine("\n" + menu[1]);
        Console.WriteLine("\n" + menu[2]);

        while (!choise)
        {
            if (Console.KeyAvailable)
            {
                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.Enter:
                {
                    choise = true;
                    if (row == 0)
                    {
                        Apache.PlayApacheCombat();
                    }
                    else if (row == 1)
                    {
                        HowToPlay._HowToPlay();
                    }
                    else
                    {
                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                    }
                }
                break;

                case ConsoleKey.UpArrow:
                {
                    if (row == 1 || row == 2)
                    {
                        if (row == 1)
                        {
                            row--;
                            Console.SetCursorPosition(0, Console.CursorTop - 5);
                            Console.BackgroundColor = ConsoleColor.Cyan;
                            Console.WriteLine(menu[0]);
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.WriteLine("\n" + menu[1]);
                            Console.WriteLine("\n" + menu[2]);
                        }
                        else
                        {
                            row--;
                            Console.SetCursorPosition(0, Console.CursorTop - 5);
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.WriteLine(menu[0]);
                            Console.BackgroundColor = ConsoleColor.Cyan;
                            Console.WriteLine("\n" + menu[1]);
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.WriteLine("\n" + menu[2]);
                        }
                    }
                }
                break;

                case ConsoleKey.DownArrow:
                {
                    if (row == 0 || row == 1)
                    {
                        if (row == 0)
                        {
                            row++;
                            Console.SetCursorPosition(0, Console.CursorTop - 5);
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.WriteLine(menu[0]);
                            Console.BackgroundColor = ConsoleColor.Cyan;
                            Console.WriteLine("\n" + menu[1]);
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.WriteLine("\n" + menu[2]);
                        }
                        else
                        {
                            row++;
                            Console.SetCursorPosition(0, Console.CursorTop - 5);
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.WriteLine(menu[0]);
                            Console.WriteLine("\n" + menu[1]);
                            Console.BackgroundColor = ConsoleColor.Cyan;
                            Console.WriteLine("\n" + menu[2]);

                            Console.BackgroundColor = ConsoleColor.Black;
                        }
                    }
                }
                break;

                default:
                {
                    Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write(' ');
                    Console.SetCursorPosition(0, Console.CursorTop);
                }
                break;
                }
            }
        }
    }
Example #32
0
 internal CassandraClient(Apache.Cassandra.Cassandra.Iface thriftClient, KeyspaceFactory keyspaceFactory, Endpoint endpoint, IKeyedObjectPool<Endpoint, ICassandraClient> pool)
     : this(keyspaceFactory, endpoint, pool)
 {
     cassandra = thriftClient;
 }
 public void AddChangeStateListener(Apache.Avalon.Castle.MicroKernel.ChangeStateListenerDelegate changeStateDelegate)
 {
 }
 public string system_update_column_family(Apache.Cassandra.CfDef cf_def)
 {
     return _client.system_update_column_family(cf_def);
 }
 /// <summary>
 /// Adds an array of
 /// <see cref="Apache.Http.Cookie.Cookie">HTTP cookies</see>
 /// . Cookies are added individually and
 /// in the given array order. If any of the given cookies has already expired it will
 /// not be added, but existing values will still be removed.
 /// </summary>
 /// <param name="cookies">
 /// the
 /// <see cref="Apache.Http.Cookie.Cookie">cookies</see>
 /// to be added
 /// </param>
 /// <seealso cref="AddCookie(Apache.Http.Cookie.Cookie)">AddCookie(Apache.Http.Cookie.Cookie)
 ///     </seealso>
 public virtual void AddCookies(Apache.Http.Cookie.Cookie[] cookies)
 {
     lock (this)
     {
         if (cookies != null)
         {
             foreach (Apache.Http.Cookie.Cookie cooky in cookies)
             {
                 this.AddCookie(cooky);
             }
         }
     }
 }
 public string system_update_keyspace(Apache.Cassandra.KsDef ks_def)
 {
     return _client.system_update_keyspace(ks_def);
 }
 /// <summary>
 /// Convert from a NMS Message to a .NET object.
 /// </summary>
 /// <param name="nmsMessage">the message to convert</param>
 /// <returns>the converted .NET object</returns>
 /// <throws>MessageConversionException in case of conversion failure </throws>
 public object FromMessage(Apache.NMS.IMessage nmsMessage)
 {
     MessageBuilder builder = null;
     if (extractNmsMessageBody)
     {
         object conversionResult = converter.FromMessage(nmsMessage);
         if (conversionResult == null)
         {
             return null;
         }
         if (conversionResult is Spring.Integration.Core.IMessage)
         {
             builder = MessageBuilder.FromMessage((Spring.Integration.Core.IMessage)conversionResult);
         } else
         {
             builder = MessageBuilder.WithPayload(conversionResult);
         }
     } else
     {
         builder = MessageBuilder.WithPayload(nmsMessage);
     }
     IDictionary<string, object> headers = headerMapper.ToHeaders(nmsMessage);
     Spring.Integration.Core.IMessage message = builder.CopyHeadersIfAbsent(headers).Build();
     if (logger.IsDebugEnabled)
     {
         logger.Debug("Converted NMS Message [" + nmsMessage + "] to integration message [" + message + "]");
     }
     return message;
 }
Example #38
0
 /// <summary>
 /// This function is a callback function received whenever an ActiveMQ message is received from the server.  It ignores the message and returns immediately.
 /// </summary>
 /// <param name="msg">ActiveMQ message received from the server</param>
 protected void OnMessageIgnore(Apache.NMS.IMessage msg)
 {
     return;
 }
        private void ErrorMessageShouldBeSent(Apache.NMS.IMessage message, Func<string, bool> errorMessageVerification, string expectedDestination)
        {
            A.CallTo(() => this.errorMessageProducer.Send(A.Dummy<Apache.NMS.IMessage>()))
                .WhenArgumentsMatch(
                    args =>
                        {
                            var sentMessage = (Apache.NMS.IMessage)args[0];
                            if (!sentMessage.Properties.Contains("Bridge.Error.Message")
                                || !sentMessage.Properties.Contains("Bridge.Error.OriginalDestination")
                                || !sentMessage.Properties.Contains("Bridge.Error.OriginalTimestamp")
                                || !sentMessage.Properties.Contains("Bridge.Error.OriginalMessageId"))
                            {
                                return false;
                            }

                            return errorMessageVerification((string)sentMessage.Properties["Bridge.Error.Message"]) &&
                                   sentMessage.Properties["Bridge.Error.OriginalDestination"].Equals(expectedDestination) &&
                                   sentMessage.Properties["Bridge.Error.OriginalTimestamp"].Equals(message.NMSTimestamp.ToString(CultureInfo.InvariantCulture)) &&
                                   sentMessage.Properties["Bridge.Error.OriginalMessageId"].Equals(message.NMSMessageId);
                        })
                .MustHaveHappened();
        }
Example #40
0
    public void MoveFlyingObjects(char[,] playGround, List <FireMissile> missle, List <FireBomb> bomb, ref bool endGame, ref bool delete, ref bool canAdd, ref BigInteger playerScore)
    {
        Console.ForegroundColor = ConsoleColor.Magenta;
        if (x - 2 >= 0)
        {
            if (playGround[y, x - 2] != ' ' || playGround[y + 1, x - 1] != ' ' || playGround[y - 1, x - 1] != ' ')
            {
                if (playGround[y, x - 2] == '@' || playGround[y + 1, x - 1] == '@' || playGround[y - 1, x - 1] == '@' || playGround[y, x - 2] == '_' || playGround[y + 1, x - 1] == '_' || playGround[y - 1, x - 1] == '_')
                {
                    endGame = true;
                }
                else if (playGround[y, x - 2] == '-' || playGround[y + 1, x - 1] == '-' || playGround[y - 1, x - 1] == '-')
                {
                    if (missle.Count > 0)
                    {
                        missle[0].delete(playGround);
                    }

                    missle.RemoveAt(0);
                    playerScore += 5;
                    delete       = true;
                    this.delete(playGround);
                    Apache.ScoreUpdate(playerScore);
                }
                else
                {
                    bomb[0].delete(playGround);
                    playerScore += 5;
                    delete       = true;
                    this.delete(playGround);
                    Apache.ScoreUpdate(playerScore);
                }
            }
            else
            {
                playGround[y, x + 1] = ' ';
                playGround[y - 1, x] = ' ';
                playGround[y + 1, x] = ' ';

                x--;

                playGround[y, x - 1] = '#';
                playGround[y - 1, x] = '#';
                playGround[y + 1, x] = '#';

                if (x - 1 < 120 && x - 1 >= 0)
                {
                    Console.SetCursorPosition(x - 1, y + 5);
                    Console.WriteLine('#');
                }
                if (x < 120 && x >= 0)
                {
                    Console.SetCursorPosition(x, y + 4);
                    Console.WriteLine('#');
                    Console.SetCursorPosition(x, y + 6);
                    Console.WriteLine('#');
                }
                if (x + 1 < 120 && x + 1 >= 0)
                {
                    canAdd = true;
                    Console.SetCursorPosition(x + 1, y + 4);
                    Console.WriteLine(' ');
                    Console.SetCursorPosition(x + 1, y + 5);
                    Console.WriteLine('#');
                    Console.SetCursorPosition(x + 1, y + 6);
                    Console.WriteLine(' ');
                }
                if (x + 2 < 120 && x + 2 >= 0)
                {
                    Console.SetCursorPosition(x + 2, y + 5);
                    Console.WriteLine(' ');
                }
            }
        }
        else
        {
            if (x - 1 == 0)
            {
                playGround[y, x + 1] = ' ';
                playGround[y + 1, x] = ' ';
                playGround[y - 1, x] = ' ';

                x--;

                playGround[y - 1, x] = '#';
                playGround[y + 1, x] = '#';

                Console.SetCursorPosition(0, y + 4);
                Console.Write("# ");
                Console.SetCursorPosition(0, y + 5);
                Console.Write("## ");
                Console.SetCursorPosition(0, y + 6);
                Console.Write("# ");
            }
            else if (x == 0)
            {
                playGround[y, x + 1] = ' ';
                playGround[y + 1, x] = ' ';
                playGround[y - 1, x] = ' ';

                x--;

                Console.SetCursorPosition(0, y + 4);
                Console.Write(" ");
                Console.SetCursorPosition(0, y + 5);
                Console.Write("# ");
                Console.SetCursorPosition(0, y + 6);
                Console.Write("  ");
            }
            else if (x + 1 == 0)
            {
                playGround[y, x + 1] = ' ';

                Console.SetCursorPosition(0, y + 5);
                Console.Write(' ');
                delete = true;
            }
        }
    }