2016-08-06 13 views
0

Beispiel des Problems: Image conversationC# Boframework Ketten Schalter

Das Bild unten zeigt an, dass ich die Frage zweimal zu beantworten hatte, bevor die Antwort angezeigt. Irgendwie weiß irgendjemand, was im Code falsch sein kann und wie kann ich das beheben?

public IDialog<IntroForm> BuildChain() 
    { 
     return Chain 
      .From(() => FormDialog.FromForm(BuildIntroForm)) 
      .Switch(
       new Case<IntroForm, IDialog<IntroForm>>((msg) => 
       { 
        return true; //Debug 
       }, (ctx, msg) => 
       { 
        return Chain.From(() => FormDialog.FromForm(BuildPCForm)); 
       }), 
       new DefaultCase<IntroForm, IDialog<IntroForm>>((ctx, msg) => 
       { 
        //Code ... 
       }) 
      ) 
      .Unwrap() 
      .PostToUser(); 
    } 

    private IForm<IntroForm> BuildPCForm() 
    { 
     return new FormBuilder<IntroForm>() 
      .Message("Rozsvítí se nějaké LED, ozve se beeb kód, ozve se zvuk větráčku, jakákoli reakce na spouštěcí tlačítko?") //Czech language 
      .Build(); 
    } 

    private IForm<IntroForm> BuildIntroForm() 
    { 
     return new FormBuilder<IntroForm>() 
      . 
      . //Code .. 
      .Field(new FieldReflector<IntroForm>(nameof(IntroForm.Problem)) 
      .SetPrompt(
        new PromptAttribute(
         "Máte problém s ...? {||}"))) //Form from the image 
      .Build(); 
    } 
+0

nur eine Vermutung: Ich habe eine Rückkehr Kette sehen und dann in ihm verschachtelt einen weiteren Rückkehr Kette. Vielleicht ist das der Grund? –

+0

@GeorgeBirbilis Danke. Aber wie repariert es? –

+0

Warum nicht die innere bei diesem Code entfernen? Ich sehe einen .Schalten Sie dort und eine "Rückkehr wahr". Wird dort "return false" repariert? Höchstwahrscheinlich. Switch wird überhaupt nicht benötigt und Sie müssen nur neue DefaultCase an seiner Stelle verwenden. Nicht vertraut mit dieser API, nur aus der Code-Struktur zu erraten –

Antwort

0

fand ich Lösung

Verwenden FormDialog.FromForm(BuildPCForm,FormOptions.PromptInStart)) hinzufügen FormOptions.PromptInStart

komplette Code

public IDialog<IntroForm> BuildChain() 
{ 
    return Chain 
     .From(() => FormDialog.FromForm(BuildIntroForm)) 
     .Switch(
      new Case<IntroForm, IDialog<IntroForm>>((msg) => 
      { 
       return true; //Debug 
      }, (ctx, msg) => 
      { 
       return Chain.From(() => FormDialog.FromForm(BuildPCForm,FormOptions.PromptInStart)); 
      }), 
      new DefaultCase<IntroForm, IDialog<IntroForm>>((ctx, msg) => 
      { 
       //Code ... 
      }) 
     ) 
     .Unwrap() 
     .PostToUser(); 
} 

private IForm<IntroForm> BuildPCForm() 
{ 
    return new FormBuilder<IntroForm>() 
     .Message("Rozsvítí se nějaké LED, ozve se beeb kód, ozve se zvuk větráčku, jakákoli reakce na spouštěcí tlačítko?") //Czech language 
     .Build(); 
} 

private IForm<IntroForm> BuildIntroForm() 
{ 
    return new FormBuilder<IntroForm>() 
     . 
     . //Code .. 
     .Field(new FieldReflector<IntroForm>(nameof(IntroForm.Problem)) 
     .SetPrompt(
       new PromptAttribute(
        "Máte problém s ...? {||}"))) //Form from the image 
     .Build(); 
}