本文整理汇总了C#中Answer类的典型用法代码示例。如果您正苦于以下问题:C# Answer类的具体用法?C# Answer怎么用?C# Answer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Answer类属于命名空间,在下文中一共展示了Answer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:RavingRabbit,项目名称:Labs,代码行数:7,代码来源:QuestionTests.cs
示例2: AnswerModel
public AnswerModel(Answer answer)
{
AnswerText = answer.AnswerText;
Note = answer.Note;
DebugInformation = answer.DebugInformation;
UnderstoodQuestion = answer.UnderstoodQuestion;
}
开发者ID:darkosancanin,项目名称:naturaldatetime_web,代码行数:7,代码来源:AnswerModel.cs
示例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;
}
}
}
}
开发者ID:MMetodiew,项目名称:hotdocs-open-sdk,代码行数:29,代码来源:AnswerTest.cs
示例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());
}
}
开发者ID:peddinti,项目名称:WebAnswers,代码行数:33,代码来源:WikiHow.cs
示例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;
}
开发者ID:peddinti,项目名称:WebAnswers,代码行数:35,代码来源:MSDNForum.cs
示例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;
}
开发者ID:peddinti,项目名称:WebAnswers,代码行数:27,代码来源:WikiEncyclopedia.cs
示例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;
}
开发者ID:peddinti,项目名称:WebAnswers,代码行数:30,代码来源:WikiEncyclopedia.cs
示例8: IsPassRequirements
public static bool IsPassRequirements(Answer answer)
{
if (QuestsController.reference.CheckRequirements(answer))
return true;
return false;
}
开发者ID:Gogeen,项目名称:GhostTrainAssets,代码行数:7,代码来源:QuestsController.cs
示例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);
}
开发者ID:jnuYT,项目名称:niudun-PTS,代码行数:30,代码来源:questionEdit.aspx.cs
示例10: Player
public Player(string playerName)
{
this.playerName = playerName;
this.playerID = Player.lastPlayerID + 1;
this.lastAnswer = new Answer();
Player.lastPlayerID++;
}
开发者ID:starrodkirby86,项目名称:better-quiz-app,代码行数:7,代码来源:Player.cs
示例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)
{ }
}
开发者ID:mominbd,项目名称:testing,代码行数:30,代码来源:studentProfile.aspx.cs
示例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);
}
开发者ID:keikan231,项目名称:Vuabep,代码行数:7,代码来源:QuestionsController.cs
示例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";
}
}
开发者ID:SamLyall,项目名称:Online-Examination-System,代码行数:32,代码来源:Questions.aspx.cs
示例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();
}
开发者ID:DerHumpink,项目名称:Godjirra,代码行数:28,代码来源:DialogStageBehaviourEditor.cs
示例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;
}
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:31,代码来源:AnswerDtoMapper.cs
示例16: CheckAnswer
public static bool CheckAnswer(Message.Problem.ProblemData answeredProblemData, Answer answer)
{
bool correct = true;
//get correct answer IDs
Message.Problem.AnswerIdentifier correctIDList = new Message.Problem.AnswerIdentifier ();
foreach(Senseix.Message.Atom.Atom atom in answeredProblemData.answer.answers)
{
correctIDList.uuid.Add(atom.uuid);
}
//bail out if we have the wrong number of answers
List<string> answerIDStrings = new List<string>(answer.GetAnswerIDs ());
if (answerIDStrings.Count != correctIDList.uuid.Count)
return false;
//sort the lists to eliminate order discrepencies
correctIDList.uuid.Sort ();
answerIDStrings.Sort ();
//check given answers against correct answers
for (int i = 0; i < answerIDStrings.Count; i++)
{
correct = correct && (correctIDList.uuid[i] == (string)answerIDStrings[i]);
}
return correct;
}
开发者ID:senseix,项目名称:thinksy_unity_plugin,代码行数:27,代码来源:ProblemKeeper.cs
示例17: ParseResponse
private List<Answer> ParseResponse(string webResponse,string question)
{
List<Answer> answers = new List<Answer>();
Answer answer = new Answer();
XmlDocument responseXmlDoc = new XmlDocument();
responseXmlDoc.LoadXml(webResponse);
XmlNamespaceManager ns = new XmlNamespaceManager(responseXmlDoc.NameTable);
ns.AddNamespace("tk", "http://www.trueknowledge.com/ns/kengine");
XmlNode resultNode = responseXmlDoc.SelectSingleNode("//tk:text_result",ns);
if (resultNode != null && resultNode.InnerText != "")
{
answer.question = question;
answer.topAnswer = resultNode.InnerText;
answer.score = 100;
answer.isStarred = true;
answer.url = responseXmlDoc.SelectSingleNode("//tk:tk_question_url", ns).InnerText;
answer.source = AnswerSource.TrueKnowledge;
answer.type = AnswerType.Text;
ranker.GetFeatures(answer);
answers.Add(answer);
}
//logger.Info("TrueKnowledge Result Count:{0}", answers.Count);
return answers;
}
开发者ID:peddinti,项目名称:WebAnswers,代码行数:25,代码来源:TrueKnowledge.cs
示例18: GetNextQuestion
public Question GetNextQuestion(Question prevQuestion, Answer prevAnswer)
{
int qId = logic.GetQuestionId(prevQuestion, prevAnswer);
Question q = new Question();
q.Id = qId;
return q;
}
开发者ID:nemesek,项目名称:Care,代码行数:7,代码来源:QuestionGenerator.cs
示例19: ParseSearchResult
private List<Answer> ParseSearchResult(IEnumerable<WebResultsWebResult> bingResults, string query)
{
List<Answer> answers = new List<Answer>();
List<Thread> workers = new List<Thread>();
XmlDocument xmlDoc = new XmlDocument();
foreach (WebResultsWebResult result in bingResults)
{
Answer answer = new Answer();
answer.url = result.Url;
Thread worker = new Thread(() => GetWikihowAnswer(answer, answers));
worker.Start();
workers.Add(worker);
}
while (workers.Where(thread => thread.IsAlive).Count() > 0)
{
//List<Thread> remThreads = new List<Thread>();
//foreach (Thread worker in workers)
// if (worker.IsAlive)
// remThreads.Add(worker);
//workers = remThreads;
}
//logger.Info("WikiHow Result Count:{0}", answers.Count);
return answers;
}
开发者ID:peddinti,项目名称:WebAnswers,代码行数:26,代码来源:WikiHow.cs
示例20: LazyTrueloadTest
public void LazyTrueloadTest()
{
Question question;
using (var repo = RepositoryContext.GetRepository())
{
question = new Question() { Name = "question1123", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now };
var addAnswer1 = new Answer() { Name = "answer1", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, Question = question };
var addAnswer2 = new Answer() { Name = "answer2", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, Question = question };
question.Answers.Add(addAnswer1);
question.Answers.Add(addAnswer2);
repo.Add(question);
repo.SaveChanges();
}
using (var repo = RepositoryContext.GetRepository())
{
//SELECT * FROM [Question]
var question1 = repo.GetAll<Question>().FirstOrDefault();
//SELECT * FROM [Answer] answers0_ WHERE answers0_.Question_ID='59B9C112-2A62-4E41-8220-7A518D829449';
var count = question1.Answers.Count;
var beforeLoad = question1.GetAnswersSet();
//Assert.IsTrue(beforeLoad == null || beforeLoad.Count == 0, "组合子实体被立即加载!");
//Assert.AreEqual(question.Answers.Count, 0);
var afterLoad = question1.Answers;
Assert.IsTrue(beforeLoad != null && beforeLoad.Count > 0, "组合子实体未被加载出来!");
}
}
开发者ID:Allen-Zhou,项目名称:AF,代码行数:30,代码来源:QuestionAndAnswer.cs
注:本文中的Answer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论