本文整理汇总了C#中GLyra.Dota2.Repositories.Dota2Entities类的典型用法代码示例。如果您正苦于以下问题:C# Dota2Entities类的具体用法?C# Dota2Entities怎么用?C# Dota2Entities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dota2Entities类属于GLyra.Dota2.Repositories命名空间,在下文中一共展示了Dota2Entities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkIfSkillNameExists
/// <summary>
/// Checks if the description of the skill exists
/// </summary>
protected SkillEffectName checkIfSkillNameExists(string name, string heroName, string skillName)
{
SkillEffectName skillEffectName = new SkillEffectName();
using (Dota2Entities ctx = new Dota2Entities())
{
//get SkillId
SkillCreator.SelectByName(skillName)
if (skill != null)
{
try
{
if (ctx.SkillEffectName.Any(x =>
x.Name == name &&
x.Skill.Hero.Name == heroName))
{
Console.WriteLine("Skill " + name + " Already exists...");
return true;
}
else
{
return null;
}
}
catch (Exception e)
{
//TODO implementar log de erro
throw e;
}
}
}
}
示例2: insertSkillEffectName
public SkillEffectName insertSkillEffectName(string name, string heroName, string skillName,
List<string> skillEffectValues, string skillDescription)
{
SkillEffectName skillEffectName = new SkillEffectName();
Skill skill = SkillCreator.SelectByName(skillName);
skillEffectName.Name = name.Trim();
skillEffectName = checkIfSkillNameExists(name, skill, skillDescription);
if (skillEffectName == null)
{
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
skillEffectName = ctx.SkillEffectName.Add(skillEffectName);
ctx.SaveChanges();
Console.WriteLine("Skill " + name + " Created");
}
catch (Exception e)
{
throw e;
}
}
}
return skillEffectName;
}
示例3: AttributesCreator
public AttributesCreator(int heroId, Dictionary<string, string> primaryStats)
{
attribute = new Attributes();
attribute.HeroId = heroId;
attribute.Intelligence = primaryStats["Intelligence"];
attribute.Agility = primaryStats["Agility"];
attribute.Strength = primaryStats["Strength"];
attribute.Damage = primaryStats["Damage"];
attribute.MoveSpeed = primaryStats["Movespeed"];
attribute.Armor = primaryStats["Armor"];
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
ctx.Attributes.Add(this.attribute);
ctx.SaveChanges();
Console.WriteLine("Primary Stats Created ");
}
catch (Exception e)
{
//TODO Adicionar ao log
throw e;
}
}
}
示例4: InsertSkillImage
public SkillImage InsertSkillImage(int skillId, string imageUrl)
{
SkillImage skillImage = new SkillImage();
try
{
using (Dota2Entities ctx = new Dota2Entities())
{
//Check if the image exists
if (!ctx.SkillImage.Any(si => si.Url == imageUrl))
{
skillImage.SkillId = skillId;
skillImage.Url = imageUrl;
ctx.SkillImage.Add(skillImage);
ctx.SaveChanges();
}
else
{
skillImage = ctx.SkillImage.Where(si => si.Url == imageUrl).FirstOrDefault();
Console.WriteLine("SkillImage Already exists");
}
}
}
catch (Exception)
{
//TODO implementar log
throw;
}
return skillImage;
}
示例5: checkIfSkillNameExists
/// <summary>
/// Checks if the description of the skill exists
/// </summary>
protected SkillEffectName checkIfSkillNameExists(string name, Skill skill, string skillDescription)
{
SkillEffectName skillEffectName = new SkillEffectName();
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
ctx.Configuration.LazyLoadingEnabled = true;
if(ctx.SkillEffectName.Any(s => s.Name == name))
{
skillEffectName = ctx.SkillEffectName.Where(x =>
x.Name == name).First();
skillEffectName = ctx.SkillEffectName.Where(x =>
x.Name == name &&
x.Skill.Hero.Name == skill.Hero.Name &&
skillDescription == skill.Description).First();
Console.WriteLine("Skill " + name + " Already exists...");
return skillEffectName;
}
else
{
return null;
}
}
catch (Exception e)
{
//TODO implementar log de erro
throw e;
}
}
}
示例6: createHero
public Hero createHero(string heroName, string biography)
{
this.hero = new Hero();
this.hero.Name = heroName;
this.hero.Biography = biography;
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
ctx.Hero.Add(this.hero);
ctx.SaveChanges();
Console.WriteLine("*************************** " + heroName + " Created(Hero)" + "***************************");
}
catch (Exception e)
{
//TODO Adicionar ao log
throw e;
}
}
return this.hero;
}
示例7: InsertSkillEffectName
public SkillEffectName InsertSkillEffectName(string name, string heroName, Skill skill, List<string> skillEffectValues)
{
SkillEffectName skillEffectName;
Skill completeSkill = SkillCreator.SelectByName(skill.Name);
bool exists = checkIfSkillNameExists(name, completeSkill, completeSkill.Description, out skillEffectName);
if (!exists)
{
skillEffectName.Name = name.Trim();
skillEffectName.SkillId = completeSkill.ID;
skillEffectName.ValueLv1 = int.Parse(skillEffectValues.First());
skillEffectName.ValueLv2 = int.Parse(skillEffectValues.ElementAt(1));
skillEffectName.ValueLv3 = int.Parse(skillEffectValues.ElementAt(2));
skillEffectName.ValueLv4 = int.Parse(skillEffectValues.ElementAt(3));
skillEffectName.ValueScepter = int.Parse(skillEffectValues.Last());
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
skillEffectName = ctx.SkillEffectName.Add(skillEffectName);
ctx.SaveChanges();
Console.WriteLine("Skill " + name + " Created");
}
catch (Exception e)
{
throw e;
}
}
}
return skillEffectName;
}
示例8: checkIfSkillNameExists
/// <summary>
/// Checks if the description of the skill exists
/// </summary>
protected SkillEffectName checkIfSkillNameExists(string name, string heroName, string skillId)
{
SkillEffectName skillEffectName = new SkillEffectName();
using(Dota2Entities ctx = new Dota2Entities())
{
//get SkillId
//if (skill != null)
//{
// try
// {
// if (ctx.SkillEffectName.Any(x =>
// x.Name == name &&
// x.Skill.Hero.Name == heroName))
// {
// Console.WriteLine("Skill " + name + " Already exists...");
// return true;
// }
// else
// {
// return null;
// }
// }
// catch (Exception e)
// {
// //TODO implementar log de erro
// throw e;
// }
//}
}
}
示例9: InsertHeroPortrait
public HeroPortrait InsertHeroPortrait(int heroId, string imageUrl)
{
HeroPortrait HeroPortrait = new HeroPortrait();
try
{
using (Dota2Entities ctx = new Dota2Entities())
{
//Check if the image exists
if (!ctx.HeroPortrait.Any(si => si.Url == imageUrl))
{
HeroPortrait.HeroId = heroId;
HeroPortrait.Url = imageUrl;
ctx.HeroPortrait.Add(HeroPortrait);
ctx.SaveChanges();
Console.WriteLine("Image " + HeroPortrait.Url + " Added");
}
else
{
HeroPortrait = ctx.HeroPortrait.Where(si => si.Url == imageUrl).FirstOrDefault();
Console.WriteLine("HeroPortrait Already exists");
}
}
}
catch (Exception)
{
//TODO implementar log
throw;
}
return HeroPortrait;
}
示例10: createHero
public Hero createHero(string name, List<string> primaryStats, string biography)
{
this.hero = new Hero();
this.hero.Name = name;
this.hero.Biography = biography;
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
ctx.Hero.Add(this.hero);
ctx.SaveChanges();
}
catch(Exception e)
{
//TODO Adicionar ao log
throw e.Message;
}
return this.hero;
}
}
示例11: checkIfSkillNameExists
/// <summary>
/// Checks if the description of the skill exists
/// </summary>
protected SkillEffectName checkIfSkillNameExists(string name, Skill skill, string skillDescription)
{
SkillEffectName skillEffectName = new SkillEffectName();
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
skillEffectName = ctx.SkillEffectName.Where(x =>
x.Name == name &&
x.Skill.Hero.Name == skill.Hero.Name &&
skillDescription == skill.Description).First();
if(skillEffectName.ID != null)
{
Console.WriteLine("Skill " + name + " Already exists...");
return skillEffectName;
}
else
{
return null;
}
}
catch (Exception e)
{
//TODO implementar log de erro
throw e;
}
}
}
示例12: insert
public SkillAbilityTypes insert(int skillId, int abilityTypeId, out bool success)
{
skillAbilityType = new SkillAbilityTypes();
using (Dota2Entities ctx = new Dota2Entities())
{
try
{
skillAbilityType.SkillId = skillId;
skillAbilityType.AbilityTypeId = abilityTypeId;
ctx.SkillAbilityTypes.Add(skillAbilityType);
ctx.SaveChanges();
success = true;
}
catch (Exception e)
{
success = false;
throw e;
}
}
return skillAbilityType;
}
示例13: checkIfSkillNameExists
/// <summary>
/// Checks if the description of the skill exists, in negative case call the insertSkillDesc
/// </summary>
public SkillEffectName checkIfSkillNameExists(string name)
{
SkillEffectName skillEffectName = new SkillEffectName();
using(Dota2Entities ctx = new Dota2Entities())
{
try
{
if (ctx.SkillEffectName.Any(x => x.Name == name))
{
Console.WriteLine("Skill " + name + " Already exists...");
}
else
{
skillEffectName = insertSkillEffectName(name);
}
}
catch (Exception e)
{
//TODO implementar log de erro
throw e;
}
}
return skillEffectName;
}
示例14: setAbilityCastType
void setAbilityCastType(string abilityCastTypeString)
{
using(Dota2Entities ctx = new Dota2Entities())
{
var abilityType = (from e in ctx.AbilityType
where e.Name == abilityCastTypeString);
}
}
示例15: getHeroByName
public Hero getHeroByName(string heroName)
{
Hero hero = new Hero();
using (Dota2Entities ctx = new Dota2Entities())
{
hero = ctx.Hero.Where(h => h.Name == heroName).FirstOrDefault();
}
return hero;
}