本文整理汇总了C#中Keyword类的典型用法代码示例。如果您正苦于以下问题:C# Keyword类的具体用法?C# Keyword怎么用?C# Keyword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Keyword类属于命名空间,在下文中一共展示了Keyword类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public IHttpActionResult Create(Keyword keyword)
{
var createdKeyword = KeywordLogic.CreateKeyword(keyword);
if (createdKeyword == null)
return Conflict();
return Ok(createdKeyword);
}
示例2: Map
public JsonKeyword Map(Keyword keyword)
{
switch (keyword)
{
case Keyword.Given:
{
return JsonKeyword.Given;
}
case Keyword.When:
{
return JsonKeyword.When;
}
case Keyword.Then:
{
return JsonKeyword.Then;
}
case Keyword.And:
{
return JsonKeyword.And;
}
case Keyword.But:
{
return JsonKeyword.But;
}
default:
throw new ArgumentOutOfRangeException(nameof(keyword), keyword, null);
}
}
示例3: UpdateKeywordIsPersisted
public void UpdateKeywordIsPersisted()
{
using (var businessContext = new BusinessContext())
{
var language = new Language
{
Name = "LanguageName"
};
businessContext.AddNewLanguage(language);
var keyword = new Keyword
{
Name = "KeywordName",
LanguageId = 1,
};
businessContext.AddNewKeyword(keyword);
keyword.Name = "New KeywordName";
businessContext.UpdateKeyword(keyword);
bool updated = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id && k.Name == keyword.Name);
Assert.IsTrue(updated);
}
}
示例4: DeleteKeywordIsPersisted
public void DeleteKeywordIsPersisted()
{
using (var businessContext = new BusinessContext())
{
var language = new Language
{
Name = "LanguageName"
};
businessContext.AddNewLanguage(language);
var keyword = new Keyword
{
Name = "KeywordName",
LanguageId = 1,
};
businessContext.AddNewKeyword(keyword);
//businessContext.DeleteKeyword(keyword);
bool notDeleted = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id);
//Assert.IsFalse(notDeleted);
}
}
示例5: EasyTraceEvent
// EasyTraceEvent
// Checks the keyword and level before emiting the event
static internal void EasyTraceEvent(Keyword keywords, Level level, Event eventID)
{
if (IsEnabled(keywords, level))
{
EventProvider.TraceEvent(eventID, keywords, level);
}
}
示例6: Test
public void Test()
{
IDriver driver = sessions.ConnectionProvider.Driver;
if (!driver.SupportsMultipleQueries)
{
Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName);
}
using (ISession session = sessions.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
_keyword = new Keyword();
session.Save(_keyword);
NodeKeyword nodeKeyword = new NodeKeyword();
nodeKeyword.NodeId = 1;
nodeKeyword.Keyword = _keyword;
session.Save(nodeKeyword);
transaction.Commit();
}
using (ISession session = sessions.OpenSession())
{
//If uncomment the line below the test will pass
//GetResult(session);
IList result = GetResult(session);
Assert.That(result, Has.Count.EqualTo(2));
Assert.That(result[0], Has.Count.EqualTo(1));
Assert.That(result[1], Has.Count.EqualTo(1));
}
}
示例7: Run
/// <summary>
/// Runs the code example.
/// </summary>
/// <param name="user">The AdWords user.</param>
/// <param name="adGroupId">Id of the ad group to which keywords are added.
/// </param>
public void Run(AdWordsUser user, long adGroupId) {
// Get the AdGroupCriterionService.
AdGroupCriterionService adGroupCriterionService =
(AdGroupCriterionService) user.GetService(
AdWordsService.v201509.AdGroupCriterionService);
List<AdGroupCriterionOperation> operations = new List<AdGroupCriterionOperation>();
foreach (string keywordText in KEYWORDS) {
// Create the keyword.
Keyword keyword = new Keyword();
keyword.text = keywordText;
keyword.matchType = KeywordMatchType.BROAD;
// Create the biddable ad group criterion.
BiddableAdGroupCriterion keywordCriterion = new BiddableAdGroupCriterion();
keywordCriterion.adGroupId = adGroupId;
keywordCriterion.criterion = keyword;
// Optional: Set the user status.
keywordCriterion.userStatus = UserStatus.PAUSED;
// Optional: Set the keyword destination url.
keywordCriterion.finalUrls = new UrlList() {
urls = new string[] { "http://example.com/mars/cruise/?kw=" +
HttpUtility.UrlEncode(keywordText) }
};
// Create the operations.
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
[email protected] = Operator.ADD;
operation.operand = keywordCriterion;
operations.Add(operation);
}
try {
// Create the keywords.
AdGroupCriterionReturnValue retVal = adGroupCriterionService.mutate(operations.ToArray());
// Display the results.
if (retVal != null && retVal.value != null) {
foreach (AdGroupCriterion adGroupCriterion in retVal.value) {
// If you are adding multiple type of criteria, then you may need to
// check for
//
// if (adGroupCriterion is Keyword) { ... }
//
// to identify the criterion type.
Console.WriteLine("Keyword with ad group id = '{0}', keyword id = '{1}', text = " +
"'{2}' and match type = '{3}' was created.", adGroupCriterion.adGroupId,
adGroupCriterion.criterion.id, (adGroupCriterion.criterion as Keyword).text,
(adGroupCriterion.criterion as Keyword).matchType);
}
} else {
Console.WriteLine("No keywords were added.");
}
} catch (Exception e) {
throw new System.ApplicationException("Failed to create keywords.", e);
}
}
示例8: TryGetKeyword
public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
{
using (var client = new TridionBrokerServiceClient())
{
string result = client.GetKeywordHierarchy(categoryUriToLookIn, keywordName);
if (!string.IsNullOrEmpty(result))
{
XElement keyWord = XElement.Parse(result);
var tkeyword = new Keyword()
{
Id = keyWord.Element("Uri").Value,
Title = keyWord.Element("KeywordName").Value,
TaxonomyId = keyWord.Element("TaxonomyUri").Value
};
foreach (XElement parentElement in keyWord.Element("ParentKeywords").Elements())
{
tkeyword.ParentKeywords.Add(
new Keyword
{
Id = parentElement.Attribute("Uri").Value,
Title = parentElement.Value,
TaxonomyId = parentElement.Attribute("TaxonomyUri").Value
}
);
}
keyword = tkeyword;
return true;
}
}
keyword = null;
return false;
}
示例9: AddKeywordNode
/// <summary>
/// Adds a new keyword xml node to a <see cref="T:System.Xml.XmlNode" />
/// </summary>
/// <param name="node"><see cref="T:System.Xml.XmlNode" /></param>
/// <param name="name">xml Node Name</param>
/// <param name="value"><see cref="T:Tridion.ContentManager.ContentManagement.Keyword" /></param>
/// <param name="includeLevel">if set to <c>true</c> [include level].</param>
/// <returns>
/// <see cref="T:System.Xml.XmlElement" /> keyword node
/// </returns>
public static XmlElement AddKeywordNode(this XmlNode node, String name, Keyword value, bool includeLevel)
{
if (node != null && !String.IsNullOrEmpty(name) && node.OwnerDocument != null && value != null)
{
XmlElement xElement = node.OwnerDocument.CreateElement(name);
xElement.SetAttribute("uri", value.Id);
if (!String.IsNullOrEmpty(value.Key))
xElement.SetAttribute("key", value.Key);
if (!String.IsNullOrEmpty(value.Description))
xElement.SetAttribute("description", value.Description);
xElement.SetAttribute("root", value.IsRoot.ToString().ToLower());
if (includeLevel)
xElement.SetAttribute("level", value.Level().ToString());
xElement.InnerXml = SecurityElement.Escape(value.Title);
node.AppendChild(xElement);
return xElement;
}
return null;
}
示例10: Test
public void Test()
{
using (var session = sessions.OpenSession())
using (var transaction = session.BeginTransaction())
{
_keyword = new Keyword();
session.Save(_keyword);
var nodeKeyword = new NodeKeyword();
nodeKeyword.NodeId = 1;
nodeKeyword.Keyword = _keyword;
session.Save(nodeKeyword);
transaction.Commit();
}
using (var session = sessions.OpenSession())
{
//If uncomment the line below the test will pass
//GetResult(session);
var result = GetResult(session);
Assert.That(result, Has.Count.EqualTo(2));
Assert.That(result[0], Has.Count.EqualTo(1));
Assert.That(result[1], Has.Count.EqualTo(1));
}
}
示例11: ComputeArticleTfidf
private List<Keyword> ComputeArticleTfidf(string content, int titleLength)
{
var tm = new HashMap<string, Keyword>();
var parse = NlpAnalysis.Parse(content);
foreach (var term in parse)
{
var weight = getWeight(term, content.Length, titleLength);
if (weight == 0)
continue;
var keyword = tm[term.Name];
if (keyword == null)
{
keyword = new Keyword(term.Name, term.Nature.allFrequency, weight);
tm[term.Name] = keyword;
}
else
{
keyword.UpdateWeight(1);
}
}
var treeSet = new SortedSet<Keyword>(tm.Values);
var arrayList = new List<Keyword>(treeSet);
if (treeSet.Count <= _keywordAmount)
{
return arrayList;
}
return arrayList.Take(_keywordAmount).ToList();
}
示例12: CaseExpr
public CaseExpr( IPersistentMap sourceSpan, LocalBindingExpr expr, int shift, int mask, int low, int high, Expr defaultExpr,
SortedDictionary<int, Expr> tests, Dictionary<int, Expr> thens, Keyword switchType, Keyword testType, IPersistentSet skipCheck)
{
_sourceSpan = sourceSpan;
_expr = expr;
_shift = shift;
_mask = mask;
//_low = low;
//_high = high;
_defaultExpr = defaultExpr;
_tests = tests;
_thens = thens;
if (switchType != _compactKey && switchType != _sparseKey)
throw new ArgumentException("Unexpected switch type: " + switchType);
//_switchType = switchType;
if (testType != _intKey && testType != _hashEquivKey && testType != _hashIdentityKey)
throw new ArgumentException("Unexpected test type: " + testType);
_testType = testType;
_skipCheck = skipCheck;
ICollection<Expr> returns = new List<Expr>(thens.Values);
returns.Add(defaultExpr);
_returnType = Compiler.MaybeClrType(returns);
if (RT.count(skipCheck) > 0 && RT.booleanCast(RT.WarnOnReflectionVar.deref()))
{
RT.errPrintWriter().WriteLine("Performance warning, {0}:{1} - hash collision of some case test constants; if selected, those entries will be tested sequentially.",
Compiler.SourcePathVar.deref(),RT.get(sourceSpan,RT.StartLineKey));
}
}
示例13: addEntry
/// <summary>
/// Add a new entry to one of the dropdown tables in the database.
/// </summary>
/// <param name="table">Table to add a new entry to.</param>
/// <param name="entry">
/// DropdownEntry containing the value and code,
/// if exists.
/// </param>
public void addEntry(Constants.DropdownTable table,
DropdownEntry entry)
{
switch (table) {
case Constants.DropdownTable.Keyword:
var kw = new Keyword {
KeywordValue = entry.value
};
_db.Keywords.InsertOnSubmit(kw);
break;
case Constants.DropdownTable.QuestionType:
var qType = new QuestionType {
Code = entry.code,
Value = entry.value
};
_db.QuestionTypes.InsertOnSubmit(qType);
break;
case Constants.DropdownTable.Region:
var region = new Region {
Code = entry.code,
Value = entry.value
};
_db.Regions.InsertOnSubmit(region);
break;
case Constants.DropdownTable.RequestorType:
var rType = new RequestorType {
Code = entry.code,
Value = entry.value
};
_db.RequestorTypes.InsertOnSubmit(rType);
break;
case Constants.DropdownTable.TumourGroup:
var tGroup = new TumourGroup {
Code = entry.code,
Value = entry.value
};
_db.TumourGroups.InsertOnSubmit(tGroup);
break;
case Constants.DropdownTable.UserGroup:
var uGroup = new UserGroup {
Code = entry.code,
Value = entry.value
};
_db.UserGroups.InsertOnSubmit(uGroup);
break;
}
_db.SubmitChanges();
}
示例14: Ongoing
public Ongoing(Keyword keyword, EffectType effect_type, int modifier, int duration)
{
key = keyword;
type = effect_type;
mod = modifier;
dur = duration;
}
示例15: SetKeyword
public void SetKeyword(string keywordText)
{
Keyword keyword;
if (Enum.TryParse<Keyword>(keywordText, out keyword))
{
this.keyword = keyword;
}
}