本文整理汇总了C#中Answer类的典型用法代码示例。如果您正苦于以下问题:C# Answer类的具体用法?C# Answer怎么用?C# Answer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Answer类属于命名空间,在下文中一共展示了Answer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAdding
public void TestAdding()
{
var question = new Question("question", new Range<int>(1, 1));
var answer = new Answer("test", true);
Assert.IsTrue(question.AddAnswer(answer));
Assert.IsFalse(question.AddAnswer(answer));
}
示例2: AnswerModel
public AnswerModel(Answer answer)
{
AnswerText = answer.AnswerText;
Note = answer.Note;
DebugInformation = answer.DebugInformation;
UnderstoodQuestion = answer.UnderstoodQuestion;
}
示例3: AnswerValueEnumerator
private void AnswerValueEnumerator(Answer a)
{
foreach (var v in a.IndexedValues)
{
if (v.Answer.Type == Sdk.ValueType.Text)
{
TextValue t = v.GetValue<TextValue>();
string s = t.Value;
}
// or something like
IValue val = v.Value;
if (val.IsAnswered)
{
switch (val.Type)
{
case Sdk.ValueType.Text:
string s = Convert.ToString(val);
break;
case Sdk.ValueType.Number:
double d = Convert.ToDouble(val);
break;
case Sdk.ValueType.Date:
case Sdk.ValueType.TrueFalse:
case Sdk.ValueType.MultipleChoice:
break;
}
}
}
}
示例4: GetWikihowAnswer
private void GetWikihowAnswer(Answer ans, List<Answer> answers)
{
Stream responseStream = Util.MakeWebRequestStream(ans.url);
if (responseStream == null)
return;
HtmlDocument doc = new HtmlDocument();
doc.Load(responseStream);
try
{
string answer = "<ol>";
if (doc.DocumentNode.SelectNodes("//div[@id=\"steps\"]") == null)
{
//logger.Error("Encountered an invalid answer for url:{0}", ans.url);
return;
}
foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//div[@id=\"steps\"]/ol/li/b"))
{
answer += "<li>" + node.InnerHtml + "</li>";
}
answer += "</ol>";
ans.topAnswer = answer;
ans.question = doc.DocumentNode.SelectSingleNode("//h1[@class=\"firstHeading\"]/a").InnerText;
ans.source = AnswerSource.WikiHow;
ans.type = AnswerType.Text;
ranker.GetFeatures(ans);
answers.Add(ans);
}
catch (Exception)
{
//logger.Error("Encountered an an exception parsing url:{0} Exception:{1}", ans.url,e.ToString());
}
}
示例5: ParseAnswer
private Answer ParseAnswer(string answerResponseXml)
{
Answer answer = new Answer();
XmlDocument answerDoc = new XmlDocument();
try
{
answerDoc.LoadXml(answerResponseXml);
// the first result is the question so getting the latest response.
XmlNode answerNode = answerDoc.FirstChild.SelectSingleNode("messages/message[2]");
answer.question = answerDoc.FirstChild.SelectSingleNode("thread/topic").InnerText;
answer.isStarred = (answerNode.SelectSingleNode("answer") != null && answerNode.SelectSingleNode("answer").InnerText == "true");
answer.topAnswer = answerNode.SelectSingleNode("body").InnerText;
answer.url = answerNode.SelectSingleNode("url").InnerText;
answer.source = AnswerSource.MSDN;
answer.type = AnswerType.Text;
Int64.TryParse(answerNode.SelectSingleNode("createdOn").InnerText, out answer.questionFileTime);
DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
answer.questionFileTime = Epoch.AddSeconds(answer.questionFileTime).ToFileTimeUtc();
int.TryParse(answerNode.Attributes["helpfulVotes"].Value, out answer.answerVotes);
foreach(XmlNode node in answerDoc.FirstChild.SelectNodes("message"))
{
int score = 0;
int.TryParse(node.Attributes["helpfulVotes"].Value, out score);
answer.totalVotes += score;
}
}
catch (Exception e)
{
answer = null;
//logger.Error("encountered an exception {0}",e.ToString());
}
ranker.GetFeatures(answer);
return answer;
}
示例6: GetAnswer
public override List<Answer> GetAnswer(BasePage basePage)
{
base.ranker = basePage.Ranker;
// checking for query terms that contain noun forms and adjectives (as they talk about nouns)
string nnQuery = string.Join(" ", ranker.queryWords.Where((w, i) => Ranker.NNTags.Contains(ranker.queryTags.ElementAt(i))));
nnQuery = HttpUtility.UrlPathEncode(nnQuery);
string queryUrl = String.Format(queryTemplate, nnQuery);
List<Answer> answers = new List<Answer>();
if (ranker.queryTags.Exists(tag => Ranker.WHTags.Contains(tag.ToString())))
{
// there is a valid postag in the query. hence triggering this answer
Stream responseHtml = Util.MakeWebRequestStream(queryUrl);
Answer answer = new Answer();
ParseResponse(responseHtml, answer);
if (answer != null && !string.IsNullOrEmpty(answer.topAnswer))
{
answer.isStarred = true;
answer.type = AnswerType.Text;
answer.url = queryUrl;
answer.source = AnswerSource.Wikipedia;
ranker.GetFeatures(answer);
answers.Add(answer);
}
}
BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.Wikipedia.ToString(), AnswerType.Text.ToString(), answers.Count);
return answers;
}
示例7: ParseResponse
private void ParseResponse(Stream htmlStream, Answer answer)
{
if (htmlStream == null)
return;
HtmlDocument doc = new HtmlDocument();
doc.Load(htmlStream);
string responseHtml = "";
try
{
HtmlNode divNode = doc.DocumentNode.SelectSingleNode("//div[@id=\"MainTxt\"]");
answer.question = divNode.SelectSingleNode("span[@class=\"hw\"]").InnerText;
foreach (HtmlNode node in divNode.ChildNodes.Skip(1))
{
if (node.Name == "h2")
break;
if (node.Name == "table" ||
(node.Name=="span" && node.Attributes.Contains("class") && node.Attributes["class"].Value == "hw") ||
(node.Attributes.Contains("style") && node.Attributes["style"].Value == "display: none; visibility: hidden"))
continue;
responseHtml += node.OuterHtml;
}
}
catch
{
}
answer.topAnswer = Util.SanitizeHtmlContent(responseHtml);
return;
}
示例8: IsPassRequirements
public static bool IsPassRequirements(Answer answer)
{
if (QuestsController.reference.CheckRequirements(answer))
return true;
return false;
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
int questionId = Convert.ToInt32(Request.Form["questionId"]);
string question = Request.Form["question"];
string answer1 = Request.Form["answer1"];
string answer2 = Request.Form["answer2"];
string answer3 = Request.Form["answer3"];
string answer4 = Request.Form["answer4"];
int answer1_color = Convert.ToInt32(Request.Form["answer1_color"]);
int answer2_color = Convert.ToInt32(Request.Form["answer2_color"]);
int answer3_color = Convert.ToInt32(Request.Form["answer3_color"]);
int answer4_color = Convert.ToInt32(Request.Form["answer4_color"]);
IList<Answer> answerList = new List<Answer>();
Answer obj1 = new Answer();
obj1.Answer1 = answer1; obj1.Color = answer1_color; obj1.Priority = 1; answerList.Add(obj1);
Answer obj2 = new Answer();
obj2.Answer1 = answer2; obj2.Color = answer2_color; obj2.Priority = 2; answerList.Add(obj2);
Answer obj3 = new Answer();
obj3.Answer1 = answer3; obj3.Color = answer3_color; obj3.Priority = 3; answerList.Add(obj3);
Answer obj4 = new Answer();
obj4.Answer1 = answer4; obj4.Color = answer4_color; obj4.Priority = 4; answerList.Add(obj4);
BaseDao.editQuestion(questionId, question, answerList);
string jsonData = "{\"message\":\"问题修改成功\",\"statusCode\":\"200\",\"callbackType\":\"closeCurrent\",\"navTabId\":\"questionIndexPage\",\"forwardUrl\":\"\"}";
Response.Write(jsonData);
}
示例10: Player
public Player(string playerName)
{
this.playerName = playerName;
this.playerID = Player.lastPlayerID + 1;
this.lastAnswer = new Answer();
Player.lastPlayerID++;
}
示例11: ddlAssesment_SelectedIndexChanged
protected void ddlAssesment_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
int stdOID = Convert.ToInt32(ViewState["STDOID"]);
int stuOID = Convert.ToInt32(Session["STUOID"]);
//string stdOID = (string)ViewState["STDOID"];
string strSectionName = null;
strSectionName = ddlAssesment.SelectedItem.ToString();
//PopulateSection(strSectionName, stdOID);
//PopulateSectionNoScore(ddlAssesment.Text.ToString(), stdOID);
PopulateSection(strSectionName, lblID.Text);
PopulateSectionNoScore(ddlAssesment.Text.ToString(), lblID.Text);
//This Code for Risk Calculation
int AOID = new Sections().GetAssessmentOIDByAssessmentName(strSectionName);
this.BindRiskCalculation(AOID, stdOID);
Answer ans = new Answer();
ans = ans.CheckBannerID_Answer(lblID.Text, AOID);
if (ans.CreatedDate != null)
{
lblDate.Text = ans.CreatedDate.ToShortDateString();
}
}
catch (Exception ex)
{ }
}
示例12: DeleteAnswer
public ActionResult DeleteAnswer(int id)
{
var a = new Answer { Id = id, UpdatedById = CurrentUser.UserInfo.Id };
var feedback = _aRepo.DeleteAnswer(a);
return Json(feedback);
}
示例13: nextButton_Click
protected void nextButton_Click(object sender, EventArgs e)
{
System.Data.DataRowView dr = (System.Data.DataRowView)questionDetails.DataItem;
Answer a = new Answer();
a.QuestionID = dr["QuestionOrder"].ToString();
a.CorrectAnswer = dr["CorrectAnswer"].ToString();
a.UserAnswer = ddlAnswer.SelectedValue.ToString();
ArrayList al = (ArrayList)Session["AnswerList"];
al.Add(a);
Session.Add("AnswerList", al);
if (questionDetails.PageIndex == questionDetails.PageCount - 1)
{
Response.Redirect("Results.aspx");
}
else
{
questionDetails.PageIndex++;
}
if (questionDetails.PageIndex == questionDetails.PageCount - 1)
{
btnNext.Text = "Finished";
}
}
示例14: InspectAnswer
private void InspectAnswer(Answer answer, DialogStage stage)
{
GUILayout.BeginHorizontal();
GUILayout.Label("----------------ANSWER--------------", EditorStyles.boldLabel);
GUI.color = new Color(0.9f, 0.7f, 0.7f);
if (GUILayout.Button("X", GUILayout.Width(25)))
{
stage.Answers.Remove(answer);
return;
}
GUILayout.EndHorizontal();
EditorGUI.indentLevel++;
GUI.color = new Color(0.6f, 0.9f, 0.6f);
answer.Text = EditorGUILayout.TextField(answer.Text);
EditorGUI.indentLevel++;
//Display Ispectors for Conditions, Effects and the next scene of the answer
DisplayConditions(answer);
DisplayEffects(answer);
SelectNextScene(answer, stage);
GUI.color = Color.white;
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
示例15: Map
public AnswerDto Map(Answer entity)
{
AnswerDto dto = null;
if(entity == null)
{
return null;
}
if (entity.Self as PersonalAnswer != null)
{
dto = new PersonalAnswerDto();
var personalAnswer = entity.Self as PersonalAnswer;
var personalAnswertDto = dto as PersonalAnswerDto;
personalAnswertDto.BooleanResponse = personalAnswer.BooleanResponse;
}
if(entity.Self as FireAnswer != null)
{
dto = new FireAnswerDto();
var fireAnswer = entity.Self as FireAnswer;
var fireAnswerDto = dto as FireAnswerDto;
fireAnswerDto.YesNoNotApplicableResponse = fireAnswer.YesNoNotApplicableResponse;
}
dto.Id = entity.Id;
dto.Question = new QuestionDtoMapper().Map(entity.Question);
dto.AdditionalInfo = entity.AdditionalInfo;
return dto;
}