Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
QuestionProblem with AForge Neuro RunEpoch Pin
Infovl3-Jun-16 14:36
Infovl3-Jun-16 14:36 
SuggestionRe: Problem with AForge Neuro RunEpoch Pin
Matt T Heffron3-Jun-16 16:48
professionalMatt T Heffron3-Jun-16 16:48 
AnswerRe: Problem with AForge Neuro RunEpoch Pin
Pete O'Hanlon3-Jun-16 20:47
mvePete O'Hanlon3-Jun-16 20:47 
AnswerRe: Problem with AForge Neuro RunEpoch Pin
BillWoodruff4-Jun-16 7:36
professionalBillWoodruff4-Jun-16 7:36 
Questionmake BeginInvoke from a form that is invisble Pin
Member 125150673-Jun-16 8:46
Member 125150673-Jun-16 8:46 
AnswerRe: make BeginInvoke from a form that is invisble Pin
Dave Kreskowiak3-Jun-16 12:11
mveDave Kreskowiak3-Jun-16 12:11 
QuestionTrouble downloading results of http request Pin
Member 101734793-Jun-16 6:12
Member 101734793-Jun-16 6:12 
QuestionCannot Get Any Values From A WCF REST Service Pin
MadDashCoder3-Jun-16 5:56
MadDashCoder3-Jun-16 5:56 
My WCF REST service was created in a class library, hosted in a console app, and consumed in a console app.

Please see code below and my point out why both ID and StartTime are empty when I try to retieve them in my client app.

C#
public class Player
{
    public string ID { get; set; }
    public string StartTime { get; set; }
    public string EndTime { get; set; }

    public Player()
    {
       ID = Guid.NewGuid().ToString();
       StartTime = DateTime.Now.ToString();
    }
}

[DataContract]
public class ChessGame
{   [DataMember]
    public List<Player> Players { get; set; }
    [DataMember]
    public string PlayerId { get; set; }

    public Facility()
    {
        Players = new List<Player>();
        PlayerId = string.Empty;
    }

    public void StartGame()
    {
        Player p = new Player();
        PlayerId = p.ID;
        Players.Add(p);
    }
}


C#
public class GameService:IGameService
{
   ChessGame cg = new ChessGame();
    public void StartGame()
   {
      cg.StartGame();
   }
   public string GetPlayerID()
   {
      return cg.PlayerId
   }
   public string GetStartTime(string id)
   {
      return cg.Players.Find(p => p.ID == id).StartTime;
   }
}

 [ServiceContract]
  public interface IGameService
   {
       [WebInvoke(UriTemplate = "Game/", Method = "POST", ResponseFormat = WebMessageFormat.Xml)]
       [OperationContract]
       void StartGame();

       [WebGet(UriTemplate = "ID/", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml)]
       [OperationContract]
       string GetPlayerID();

       [WebGet(UriTemplate = "Time/{id}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml)]
       [OperationContract]
       string GetStartTime(string id);
    }


C#
static void Main(string[] args)
{
  string ID = string.Empty;

  ChannelFactory<IGameService> channelFactory = new ChannelFactory<IGameService>(new WebHttpBinding(), "http://localhost:8080");
  channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());

  IGameService channel = channelFactory.CreateChannel();

  channel.StartGame();
  ID = channe.GetPlayerID();
  Console.WriteLine("ID is: {0} ", ID);

  Console.WriteLine("Game started at: {0} ", channe.GetStartTime(ID));

  Console.Read();
}


modified 3-Jun-16 19:38pm.

AnswerRe: Cannot Get Any Values From A WCF REST Service Pin
Gerry Schmitz3-Jun-16 8:28
mveGerry Schmitz3-Jun-16 8:28 
GeneralRe: Cannot Get Any Values From A WCF REST Service Pin
MadDashCoder3-Jun-16 13:32
MadDashCoder3-Jun-16 13:32 
GeneralRe: Cannot Get Any Values From A WCF REST Service Pin
Gerry Schmitz3-Jun-16 19:15
mveGerry Schmitz3-Jun-16 19:15 
QuestionMonitor FTP and SFTP folders through FileSystemWatcher class Pin
amjegan2-Jun-16 21:05
amjegan2-Jun-16 21:05 
QuestionRe: Monitor FTP and SFTP folders through FileSystemWatcher class Pin
Richard MacCutchan2-Jun-16 21:41
mveRichard MacCutchan2-Jun-16 21:41 
AnswerRe: Monitor FTP and SFTP folders through FileSystemWatcher class Pin
amjegan2-Jun-16 21:55
amjegan2-Jun-16 21:55 
AnswerRe: Monitor FTP and SFTP folders through FileSystemWatcher class Pin
Garth J Lancaster2-Jun-16 21:52
professionalGarth J Lancaster2-Jun-16 21:52 
GeneralRe: Monitor FTP and SFTP folders through FileSystemWatcher class Pin
amjegan2-Jun-16 22:08
amjegan2-Jun-16 22:08 
GeneralRe: Monitor FTP and SFTP folders through FileSystemWatcher class Pin
Garth J Lancaster2-Jun-16 22:38
professionalGarth J Lancaster2-Jun-16 22:38 
AnswerRe: Monitor FTP and SFTP folders through FileSystemWatcher class Pin
Eddy Vluggen2-Jun-16 23:58
professionalEddy Vluggen2-Jun-16 23:58 
QuestionThe class MediaPlayer of namespace System.Windows.Media can't play music on OS Windows XP Pin
Member 111473382-Jun-16 19:49
Member 111473382-Jun-16 19:49 
AnswerRe: The class MediaPlayer of namespace System.Windows.Media can't play music on OS Windows XP Pin
OriginalGriff2-Jun-16 20:03
mveOriginalGriff2-Jun-16 20:03 
GeneralRe: The class MediaPlayer of namespace System.Windows.Media can't play music on OS Windows XP Pin
Member 111473382-Jun-16 20:16
Member 111473382-Jun-16 20:16 
QuestionSmall question on Finalizers Pin
Foothill2-Jun-16 8:56
professionalFoothill2-Jun-16 8:56 
AnswerRe: Small question on Finalizers Pin
Dave Kreskowiak2-Jun-16 9:07
mveDave Kreskowiak2-Jun-16 9:07 
GeneralRe: Small question on Finalizers Pin
Foothill2-Jun-16 9:55
professionalFoothill2-Jun-16 9:55 
GeneralRe: Small question on Finalizers Pin
Dave Kreskowiak2-Jun-16 10:53
mveDave Kreskowiak2-Jun-16 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.