blob_id
large_stringlengths 40
40
| language
large_stringclasses 1
value | repo_name
large_stringlengths 5
119
| path
large_stringlengths 4
271
| score
float64 2.52
4.84
| int_score
int64 3
5
| text
stringlengths 26
4.09M
|
|---|---|---|---|---|---|---|
4d9988e60458f3e3e59222671588915397b2b1eb
|
C#
|
AIEYear1/IntroToCSharpAssessment
|
/FirstConsoleProgram/RaylibWindow/Input.cs
| 3.21875
| 3
|
using Raylib_cs;
using System;
using static Raylib_cs.Raylib;
namespace RaylibWindowNamespace
{
/// <summary>
/// Gets player input
/// </summary>
public class Input
{
/// <summary>
/// Resets the floats to limit launching the player at the start
/// </summary>
public static void Start()
{
toReturnHorizontal = 0;
toReturnVertical = 0;
}
/// <summary>
/// To Return Values for GetAxis()
/// </summary>
private static float toReturnHorizontal = 0, toReturnVertical = 0;
/// <summary>
/// Gets input axes for player movement
/// </summary>
/// <param name="axis">input axis to get</param>
/// <param name="sensitivity">how easily the player moves up to speed</param>
/// <returns>Returns a float between 1 and -1 for the specified axis</returns>
public static float GetAxis(string axis, float sensitivity = 3)
{
//How small the number has to be to not be registered
float dead = .001f;
//what the axis will try and reach
float target = 0;
switch (axis)
{
//1st case "Vertical", returns between 1 (S key) and -1 (W key)
case "Vertical":
if (IsKeyDown(KeyboardKey.KEY_W))
target = -1;
if (IsKeyDown(KeyboardKey.KEY_S))
target = 1;
toReturnVertical = Utils.Lerp(toReturnVertical, target, sensitivity * GetFrameTime());
return (MathF.Abs(toReturnVertical) < dead) ? 0f : toReturnVertical;
//2nd case "Horizontal", returns between 1 (D key) and -1 (A key)
case "Horizontal":
if (IsKeyDown(KeyboardKey.KEY_D))
target = 1;
if (IsKeyDown(KeyboardKey.KEY_A))
target = -1;
toReturnHorizontal = Utils.Lerp(toReturnHorizontal, target, sensitivity * GetFrameTime());
return (MathF.Abs(toReturnHorizontal) < dead) ? 0f : toReturnHorizontal;
//Overflow
default:
return 0;
}
}
}
}
|
5b9738d3970e9e72a068e39a5cb33fd66d34530a
|
C#
|
poikoak/3
|
/10/ConsoleAppAnalizer/ConsoleAppAnalizer/Program.cs
| 2.984375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Xml.Serialization;
namespace ConsoleAppAnalizer
{
[Serializable]
class Program
{
static void Main(string[] args)
{
Person person = new Person("Alex", "Petrov", 34, 4567);
userInterface ui = new userInterface();
ui.Write(person);
Console.WriteLine();
ui.Read(person);
Console.WriteLine();
ui.Write(person);
Console.Read();
try
{
// бинарная сериализация
BinaryFormatter bf = new BinaryFormatter();
FileStream fstream = new FileStream("student.txt", FileMode.Create, FileAccess.Write, FileShare.None);
bf.Serialize(fstream, person);
fstream.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// десериализация одиночного объекта
FileStream fstream2 = File.OpenRead("student.txt");
BinaryFormatter bf2 = new BinaryFormatter();
Person man2 = (Person)bf2.Deserialize(fstream2);
fstream2.Close();
man2.Print();
Console.Read();
}
}
}
|
43a89a780d0d371cee16fe371e12b71aafc3cf9d
|
C#
|
SosoTughushi/TomTom.Useful
|
/TomTom.Useful/TomTom.Useful.Repositories.Mongo.IntegrationTests/DynamicMongoRepositoryTests.cs
| 2.5625
| 3
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TomTom.Useful.Repositories.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using Xunit;
namespace TomTom.Useful.Repositories.Mongo.IntegrationTests
{
public class DynamicMongoRepositoryTests : MongoRepositoryTestBase
{
private readonly List<MongoPoco> cache;
public DynamicMongoRepositoryTests()
{
// seet
this.cache = Enumerable.Range(0, 100)
.Select(c => new MongoPoco
{
AverageRating = new Random().Next(),
Identity = Guid.NewGuid(),
Timestamp = DateTime.UtcNow,
Name = c.ToString(),
Inner = new MongoPoco.InnerPoco
{
Address = "Tsinamdzgvrishvili " + c,
City = "Tbilisi",
CountryId = c
}
}).ToList();
foreach(var item in this.cache)
{
this.GetWriter().Insert(item).Wait();
}
}
[Fact]
public async Task Should_get_all()
{
// act
var itemsFromDb = await this.provider.GetService<IListProvider<MongoPoco>>().GetAll();
// assert
Assert.Equal(this.cache.Select(c => c.Identity), itemsFromDb.Select(c => c.Identity));
}
[Fact]
public async Task Should_get_ordered()
{
// act
var itemsFromDb = await this.provider
.GetService<ISortedListProvider<MongoPoco>>()
.GetSorted(p => p.AverageRating);
// assert
Assert.Equal(
this.cache.OrderBy(p => p.AverageRating).Select(c => c.Identity),
itemsFromDb.Select(c => c.Identity));
}
[Fact]
public async Task Should_get_ordered_desc()
{
// act
var itemsFromDb = await this.provider
.GetService<ISortedListProvider<MongoPoco>>()
.GetSortedDesc(p => p.AverageRating);
// assert
Assert.Equal(
this.cache.OrderByDescending(p => p.AverageRating).Select(c => c.Identity),
itemsFromDb.Select(c => c.Identity));
}
[Fact]
public async Task Should_get_filtered()
{
// arrange
var midValue = this.cache[this.cache.Count / 2].Inner.CountryId;
// act
var itemsFromDb = await this.provider
.GetService<IFilteredListProvider<MongoPoco>>()
.GetFiltered(c => c.Inner.CountryId > midValue);
// assert
Assert.Equal(
this.cache.Where(c => c.Inner.CountryId > midValue).Select(c => c.Identity),
itemsFromDb.Select(c => c.Identity));
}
[Fact]
public async Task Should_get_filtered_and_sorted()
{
// arrange
var midValue = this.cache[this.cache.Count / 2].Inner.CountryId;
// act
var itemsFromDb = await this.provider
.GetService<IFilteredSortedListProvider<MongoPoco>>()
.GetFilteredSorted(c => c.Inner.CountryId > midValue, c=>c.AverageRating);
// assert
Assert.Equal(
this.cache.Where(c => c.Inner.CountryId > midValue).OrderBy(c=>c.AverageRating).Select(c => c.Identity),
itemsFromDb.Select(c => c.Identity));
}
[Fact]
public async Task Should_get_paged_result()
{
// act
var result = await this.provider
.GetService<IPagedListProvider<MongoPoco>>()
.GetPaged(10, 15);
// assert
Assert.Equal(this.cache.Count, result.TotalSize);
Assert.Equal(10, result.Offset);
Assert.Equal(
this.cache.Skip(10).Take(15).Select(c => c.Identity),
result.Data.Select(c => c.Identity));
}
[Fact]
public async Task Should_get_filtered_sorted_paged_result()
{
// arrange
var midValue = this.cache[this.cache.Count / 2].Inner.CountryId;
// act
var result = await this.provider
.GetService<IPagedFilteredSortedListProvider<MongoPoco>>()
.GetPagedFilteredSorted(c => c.Inner.CountryId > midValue, c => c.AverageRating, 1, 3);
// assert
Assert.Equal(this.cache.Count(c => c.Inner.CountryId > midValue), result.TotalSize);
Assert.Equal(3, result.Data.Count());
Assert.Equal(1, result.Offset);
Assert.Equal(
this.cache
.Where(c => c.Inner.CountryId > midValue)
.OrderBy(c => c.AverageRating)
.Skip(1)
.Take(3)
.Select(c => c.Identity),
result.Data.Select(c => c.Identity));
}
protected override MongoRepositoryConfigurator RegisterRepositories(MongoRepositoryConfigurator builder)
{
return builder.RegisterDynamicRepository((MongoPoco p) => p.Composite);
}
protected override Task Cleanup()
{
return provider.GetService<IPurger<MongoPoco>>().Purge();
}
private IWriter<CompositeIdentity, MongoPoco> GetWriter() =>
this.provider.GetService<IWriter<CompositeIdentity, MongoPoco>>();
private IEntityByKeyProvider<CompositeIdentity, MongoPoco> GetKeyProvider() =>
this.provider.GetService<IEntityByKeyProvider<CompositeIdentity, MongoPoco>>();
}
public class MongoPoco
{
public CompositeIdentity Composite =>
new CompositeIdentity
{
Timestamp = Timestamp,
Id = Identity
};
public DateTime Timestamp { get; set; }
public Guid Identity { get; set; }
public string Name { get; set; }
public InnerPoco Inner { get; set; }
public double AverageRating { get; set; }
public class InnerPoco
{
public string City { get; set; }
public int CountryId { get; set; }
public string Address { get; set; }
}
}
public class CompositeIdentity
{
public Guid Id { get; set; }
public DateTime Timestamp { get; set; }
}
}
|
5c3474704fbcd92987ff2953a4082b4ade2f50ca
|
C#
|
PimentelM/CrystalBot
|
/ClassicBotter/Objects/Container.cs
| 3.03125
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CrystalBot.Objects
{
public class Container
{
private uint address;
private byte number;
public Container(uint address, byte number)
{
this.address = address;
this.number = number;
}
public IEnumerable<Item> GetItems()
{
byte slot = 0;
int numItems = Memory.ReadInt((int)address + Addresses.Container.DistanceAmount);
for (uint i = 0; i < numItems; i++)
{
int itemId = Memory.ReadInt(address + (i * Addresses.Container.StepSlot) + Addresses.Container.DistanceItemId);
if (itemId > 0)
{
yield return new Item((uint)itemId, Memory.ReadByte(address + (i * Addresses.Container.StepSlot) + Addresses.Container.DistanceItemCount), ItemLocation.FromContainer(number, slot));
}
slot++;
}
}
public byte Number
{
get { return number; }
}
public uint Address
{
get { return address; }
}
public int Volume
{
get { return Memory.ReadInt(address + Addresses.Container.DistanceVolume); }
}
public string Name
{
get { return Memory.ReadString(address + Addresses.Container.DistanceName); }
}
public bool IsOpen
{
get { return Convert.ToBoolean(Memory.ReadInt(address + Addresses.Container.DistanceIsOpen)); }
}
public int Amount
{
get { return Memory.ReadInt(address + Addresses.Container.DistanceAmount); }
}
}
}
|
57aa1c8790f755fa762682d67b1124e1c83ffb12
|
C#
|
ReisEdgar/mobileGame
|
/Mario/Assets/Scoore_script.cs
| 2.640625
| 3
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Scoore_script : MonoBehaviour {
//-----DESCRIPTION--------
// Scoore displaying
Rigidbody2D rigidbody;
const float RenderTimer = 0.7f; // Amount of time scoore will be visible
public float renderTimer;
Text text; // Text of scoore
bool executed; // Prevents some part of a code to be run more than once per certain time
public Transform parent { get; set; }
public static int TotalScoore { get; set; }
// Use this for initialization
void Start() {
text = GetComponentInChildren<Text>();
rigidbody = GetComponent<Rigidbody2D>();
text.text = " ";
parent = transform.GetComponentInParent<Transform>();
}
// Update is called once per frame
void Update() {
Movement();
if (renderTimer <= 0 && executed ) // Allowing same scoore to be displayed more than once
{
transform.SetParent(parent);
text.text = " ";
if (parent != null)
transform.position = parent.position;
else
Destroy(gameObject);
rigidbody.velocity = Vector2.zero;
executed = false;
renderTimer = 0;
}
}
// All scoores move up and follows Mario for a short time
public void Movement()
{
if (renderTimer > 0)
{
renderTimer -= Time.deltaTime;
if (gameObject.tag == "Enemy") // Scoore has same tag as it's parent
{
if (Mario_script.VelocityX > 0 && Mario_script.PositionX > transform.position.x)
rigidbody.velocity = new Vector2(Mario_script.VelocityX, 2.5f);
else
rigidbody.velocity = new Vector2(0, 2.5f);
}
else if (gameObject.tag == "QuestionBlock")
{
if (Mario_script.VelocityX > 0 && Mario_script.PositionX - transform.position.x > 2)
rigidbody.velocity = new Vector2(Mario_script.VelocityX * (2 / 3), 2.5f);
else if (Mario_script.VelocityX <= 0)
rigidbody.velocity = new Vector2(0, 2.5f);
}
else if (gameObject.tag == "Player")
rigidbody.velocity = new Vector2(0, 2.5f);
else if (gameObject.tag == "Flag")
{
if (transform.position.y < 9)
rigidbody.velocity = new Vector2(0, 3.5f);
else
rigidbody.velocity = Vector2.zero;
}
}
}
// Scoore is set by it'a parent and becomes visible
public void SetScoore(string scoore)
{
if (!executed)
{
if(gameObject.tag != "Flag")
renderTimer = RenderTimer;
else
renderTimer = RenderTimer*40; // Flag's scoore doesn't dissapear
executed = true;
transform.parent = null; // Prevents premature scoore destruction together with it's parent
text.text = scoore;
int Scoore = 0;
try
{
Scoore = int.Parse(scoore); // For those cases when Mario gets extra live from mushroom and intead of numbers, text is "1UP"
}
catch (System.Exception)
{ }
if (Scoore != 0)
AddTotalScoore(Scoore);
}
}
public static void AddTotalScoore(int scoore)
{
TotalScoore += scoore;
}
}
|
39c6ffbbda482e2a3a4aa9fb6a571c0ad80973e6
|
C#
|
AtsushiYamashita/UnityLibs
|
/Assets/BasicExtends/CS/Test/MessengerTest.cs
| 2.703125
| 3
|
using BasicExtends;
public class MessengerTest: TestComponent {
public string SetTest () {
var msg = new Msg()
.Set("test", "a")
.Set("To", "b");
if (msg.TryGet("test") != "a") { return "正しくセットできていません"; }
if (msg.TryGet("To") != "b") { return "正しくセットできていません"; }
if (msg.TryGet("to") == "b") { return "正しくセットできていません"; }
return Pass();
}
public string MatchTest () {
var msg = new Msg()
.Set("test", "a")
.Set("To", "b");
if (!msg.Match("test", "a")) { return "正しく判定できていません"; }
if (msg.Match("to", "b")) { return "正しく判定できていません"; }
if (msg.Match("To", "a")) { return "正しく判定できていません"; }
return Pass();
}
public string AssignPushTest () {
string n = string.Empty;
Messenger.Assign(( Msg msg ) => {
if (!msg.Match("to", "n")) { return; }
n = msg.TryGet("msg");
});
if (n != string.Empty) { return "ゴミが入っています"; }
//var m = Msg.Gen().To("n").Message("test").Push();
if (n == string.Empty) { return "正しく送信できていません"; }
if (n != "test") { return "正しく送信できていません"; }
return Pass();
}
public string AssignPushTest2 () {
string n = string.Empty;
Messenger.Assign(( Msg msg ) => {
if (!msg.Match("to", "n")) { return; }
n = msg.TryGet("msg");
});
if (n != string.Empty) { return "ゴミが入っています"; }
//var m = Msg.Gen().To("m").Message("test").Push();
if (n != string.Empty) { return "ゴミが入っています"; }
return Pass();
}
public string ToIsTest () {
string n = string.Empty;
int received = 0;
Messenger.Assign(( Msg msg ) => {
received++;
if (!msg.ToIs("n")) { return; }
n = msg.TryGet("msg");
});
if (n != string.Empty) { return "ゴミが入っています"; }
var m = Msg.Gen().Set(Msg.TO,"m").Set(Msg.MSG,"test").Push();
if (n != string.Empty) { return "ゴミが入っています"; }
m.Set(Msg.TO,"n").Push();
if (received != 2) { return "通信回数に異常があります。"; }
if (n != "test") { return "正しく送信できていません"; }
return Pass();
}
}
|
eb9bc4490dff15927cfc70f275b25456f9fb6568
|
C#
|
radomirKrastev/OOP
|
/Test Driven Development/INStock - Skeleton/INStock/Models/Product.cs
| 3.40625
| 3
|
namespace INStock.Models
{
using Contracts;
public class Product : IProduct
{
public Product(string label, decimal price, int quantity)
{
this.Label = label;
this.Price = price;
this.Quantity = quantity;
}
public string Label { get; }
public decimal Price { get; }
public int Quantity { get; }
public int CompareTo(IProduct other)
{
var priceResult = this.Price.CompareTo(other.Price);
if (priceResult == 0)
{
int labelResult = this.Label.CompareTo(other.Label);
if (labelResult == 0)
{
return this.Quantity.CompareTo(other.Quantity);
}
return labelResult;
}
return priceResult;
}
}
}
|
13286d377c73a8c66713ac650e0f34068335f984
|
C#
|
nsswebservices/Nest-Searchify
|
/src/Nest.Searchify/Extensions/StringExtensions.cs
| 2.78125
| 3
|
using System;
using System.Net;
using Nest.Searchify.Abstractions;
using Nest.Searchify.Queries;
namespace Nest.Searchify.Extensions
{
public static class StringExtensions
{
public static string ToUrl(this string input)
{
return WebUtility.UrlEncode(input.Replace(" ", "-").ToLowerInvariant());
}
}
public static class PaginationOptionsExtensions
{
public static Uri GetPageUri<TParameters>(this IPaginationOptions<TParameters> pagination, int page, Uri baseUri) where TParameters : class, IPagingParameters, ISortingParameters, new()
{
var parameters = pagination.ForPage(page);
if (parameters != null)
{
var ub = new UriBuilder(baseUri) { Query = QueryStringParser<TParameters>.ToQueryString(parameters) };
return ub.Uri;
}
return baseUri;
}
public static Uri GetNextPageUri<TParameters>(this IPaginationOptions<TParameters> pagination, Uri baseUri) where TParameters : class, IPagingParameters, ISortingParameters, new()
{
var nextPage = pagination.NextPage();
if (nextPage != null)
{
var ub = new UriBuilder(baseUri) {Query = QueryStringParser<TParameters>.ToQueryString(nextPage)};
return ub.Uri;
}
return baseUri;
}
public static Uri GetPreviousPageUri<TParameters>(this IPaginationOptions<TParameters> pagination, Uri baseUri) where TParameters : class, IPagingParameters, ISortingParameters, new()
{
var previousPage = pagination.PreviousPage();
if (previousPage != null)
{
var ub = new UriBuilder(baseUri)
{
Query = QueryStringParser<TParameters>.ToQueryString(previousPage)
};
return ub.Uri;
}
return baseUri;
}
}
}
|
1c7e4dcc474214b2d4d7f9678d4cb9f31746d68f
|
C#
|
akvgergo/PoeTrade
|
/Filtering/FilterComp/TypeFilter.cs
| 2.640625
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PoeTrade.Filtering {
/// <summary>
/// Represents the basic stats of an item.
/// </summary>
[QueryComponent("type_filters")]
public class TypeFilter : IFilterComponent {
/// <summary>
/// The category of the item.
/// </summary>
[QueryComponent("category")]
public ItemCategory Category { get; set; }
/// <summary>
/// The rarity of the item.
/// </summary>
[QueryComponent("rarity")]
public ItemRarity Rarity { get; set; }
public TypeFilter(
ItemCategory category = ItemCategory.Any,
ItemRarity rarity = ItemRarity.Any
)
{
Category = category;
Rarity = rarity;
}
}
}
|
474ee1c7906eea6e0fa7e93d4764de92a2a8939a
|
C#
|
khushalkhan83/AAA-Indie-RPG
|
/Assets/Malbers Animations/Common/Scripts/UI/ValueToString.cs
| 2.765625
| 3
|
using UnityEngine;
using MalbersAnimations.Events;
namespace MalbersAnimations.Utilities
{
/// <summary>Converts a value to string </summary>
[AddComponentMenu("Malbers/UI/Value to String")]
public class ValueToString : MonoBehaviour
{
public int FloatDecimals = 2;
public string Prefix;
public string Suffix;
public StringEvent toString = new StringEvent();
public virtual void ToString(float value) => toString.Invoke(Prefix + value.ToString("F" + FloatDecimals) + Suffix);
public virtual void ToString(int value) => toString.Invoke(Prefix + value.ToString() + Suffix);
public virtual void ToString(bool value) => toString.Invoke(Prefix + value.ToString() + Suffix);
public virtual void ToString(string value) => toString.Invoke(Prefix + value + Suffix);
public virtual void SetPrefix(string value) => Prefix = value;
public virtual void SetSufix(string value) => Suffix = value;
public virtual void ToString(UnityEngine.Object value) => toString.Invoke(Prefix + value.name.ToString() + Suffix);
public virtual void ToString(Vector3 value) => toString.Invoke(Prefix + value.ToString() + Suffix);
public virtual void ToString(Vector2 value) => toString.Invoke(Prefix + value.ToString() + Suffix);
}
}
|
88ff3c71f5896cb3669db42c0b9fe5713efc1113
|
C#
|
chabiche/ProjetInfoS2
|
/ProjetInfoS2/ProjetInfoS2/Occupation.cs
| 2.921875
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProjetInfoS2
{
class Occupation
{
private DateTime dateDebutOccupee;
public DateTime DateDebutOccupee
{
get { return dateDebutOccupee; }
private set { dateDebutOccupee = value; }
}
private DateTime dateFinOccupee;
public DateTime DateFinOccupee
{
get { return dateFinOccupee; }
private set { dateFinOccupee = value; }
}
public Occupation()
{
DateDebutOccupee = new DateTime();
DateFinOccupee = new DateTime();
}
public Occupation(DateTime datedebut, DateTime datefin)
{
DateDebutOccupee = new DateTime();
DateFinOccupee = new DateTime();
DateDebutOccupee = datedebut;
DateFinOccupee = datefin;
}
public Occupation(DateTime dateDebut, TimeSpan duree)
{
DateDebutOccupee = new DateTime();
DateFinOccupee = new DateTime();
DateDebutOccupee = dateDebut;
DateFinOccupee = dateDebut + duree;
}
public override string ToString()
{
return "- Occupé pour la date suivante: \n:nDate de début : "+DateDebutOccupee+"\nDate de fin : "+DateFinOccupee+"\n";
}
}
}
|
96271d5ef1d970d4843eae3da251c38657bd6b02
|
C#
|
moeh1234/CRAZeCards
|
/CRAZeCards/Models/MonthRepository.cs
| 2.875
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace CRAZeCards.Models
{
public class MonthRepository
{
private CrazEcardsEntities entity;
public MonthRepository()
{
entity = new CrazEcardsEntities();
}
public Month GetMonthFromString(string month)
{
if (month == "January")
{
Month month1 = new Month();
month1.Name = "January";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "January").ToList();
month1.Holidays = holidays;
return month1;
}
if (month == "February")
{
Month month2 = new Month();
month2.Name = "February";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "February").ToList();
month2.Holidays = holidays;
return month2;
}
if (month == "March")
{
Month month3 = new Month();
month3.Name = "March";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "March").ToList();
month3.Holidays = holidays;
return month3;
}
if (month == "April")
{
Month month4 = new Month();
month4.Name = "April";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "April").ToList();
month4.Holidays = holidays;
return month4;
}
if (month == "May")
{
Month month5 = new Month();
month5.Name = "May";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "May").ToList();
month5.Holidays = holidays;
return month5;
}
if (month == "June")
{
Month month6 = new Month();
month6.Name = "june";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "June").ToList();
month6.Holidays = holidays;
return month6;
}
if (month == "July")
{
Month month7 = new Month();
month7.Name = "July";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "July").ToList();
month7.Holidays = holidays;
return month7;
}
if (month == "August")
{
Month month8 = new Month();
month8.Name = "August";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "August").ToList();
month8.Holidays = holidays;
return month8;
}
if (month == "September")
{
Month month9 = new Month();
month9.Name = "September";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "September").ToList();
month9.Holidays = holidays;
return month9;
}
if (month == "October")
{
Month month10 = new Month();
month10.Name = "October";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "October").ToList();
month10.Holidays = holidays;
return month10;
}
if (month == "November")
{
Month month11 = new Month();
month11.Name = "November";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "November").ToList();
month11.Holidays = holidays;
return month11;
}
if (month == "December")
{
Month month12 = new Month();
month12.Name = "December";
List<HOLIDAY> holidays = entity.HOLIDAYS.Where(x => x.Holiday_Month == "December").ToList();
month12.Holidays = holidays;
return month12;
}
return null;
}
}
}
|
6d14ebea5fd849c0dbae369334b934c50280faca
|
C#
|
5l1v3r1/CoopSharp
|
/CoopSharp/CoopSharp.Demo/Program.cs
| 2.515625
| 3
|
using System;
using System.Linq;
using System.Threading.Tasks;
using CoopSharp.Demo.Common;
using CoopSharp.Models;
namespace CoopSharp.Demo
{
internal class Program
{
private static void Main(string[] args)
{
AsyncMain().GetAwaiter().GetResult();
}
private static async Task AsyncMain()
{
var coopClient = new CoopClientFactory().Create();
var restaurants = await coopClient.GetRestaurants();
var menus = await coopClient.GetTodaysMenus(2042);
var restaurants2 = await coopClient.GetRestaurants(new Coordinates(47.48072139766479, 8.20896424100014));
Console.WriteLine(restaurants.Results.Count);
Console.ReadLine();
Console.WriteLine($"{menus.Results.First().Title}, {menus.Results.First().Price}");
Console.ReadLine();
foreach (Restaurant restaurant in restaurants2.Results)
{
Console.WriteLine($"{restaurant.Id} {restaurant.Name}");
}
var baden = await coopClient.GetRestaurants("baden");
Console.WriteLine(baden.Results.First().Name);
if (Environment.OSVersion.IsWindows()) { Console.ReadLine(); }
}
}
}
|
fe3294c213e0dfe4c0492ee585f62f0b16f14abe
|
C#
|
saveenr/VisioAutomation
|
/VisioAutomation_2010/VisioAutomation.Models/Layouts/Box/Box.cs
| 2.984375
| 3
|
using System.Collections.Generic;
namespace VisioAutomation.Models.Layouts.Box
{
public class Box : Node
{
public Box(double w, double h) :
this(new VisioAutomation.Core.Size(w, h) )
{
}
protected Box(VisioAutomation.Core.Size s)
{
this.Size = s;
}
public override VisioAutomation.Core.Size CalculateSize()
{
return this.Size;
}
public override void _place(VisioAutomation.Core.Point origin)
{
this.Rectangle = new VisioAutomation.Core.Rectangle(origin, this.Size);
}
public override IEnumerable<Node> GetChildren()
{
yield break;
}
}
}
|
712f5c0c72e149fa9a0d222f595aead0dc39b68e
|
C#
|
ctsxamarintraining/cts451892
|
/Day6_assignments/collectionquest_4/collectionquest_4/Program.cs
| 3.515625
| 4
|
using System;
using System.Collections.Generic;
namespace collectionquest_4
{
class MainClass
{
public static void Main (string[] args)
{
/* List Operations */
List<int> list = new List<int>();
list.Add (1);
list.Add (2);
list.Add (3);
list.Remove (1);
list.Insert (0, 20);
Console.WriteLine ("before clearing the list {0}",list.Count);
list.Clear ();
Console.WriteLine ("afetr clearing the list {0}",list.Count);
/* Dictionary Operations */
Dictionary<int, string> dictionary = new Dictionary<int, string> ();
dictionary.Add (1, "xxx");
dictionary.Add (2, "yyy");
dictionary.ContainsValue ("yyy");
dictionary.Remove (2);
dictionary.Add (3, "zzz");
Console.WriteLine ("before clearing the dictionary {0}",dictionary.Count);
dictionary.Clear ();
Console.WriteLine ("after clearing the dictionary {0}",dictionary.Count);
}
}
}
|
b28b9f1e69dbdf5c2643154ec8d19d6a15505473
|
C#
|
tukhoi/CurrencyConverter
|
/CC.AppServices/RateFetcher/RateFetcherManager.cs
| 2.75
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CC.AppServices.RateFetcher
{
public class RateFetcherManager
{
private static IDictionary<Provider, IExchangeRateFetcher> _store;
static RateFetcherManager()
{
_store = new Dictionary<Provider, IExchangeRateFetcher>();
}
public static IExchangeRateFetcher GetFetcher(Provider provider)
{
if (!_store.ContainsKey(provider))
_store.Add(provider, CreateFetcher(provider));
return _store[provider];
}
static IExchangeRateFetcher CreateFetcher(Provider provider)
{
IExchangeRateFetcher fetcher = null;
switch (provider)
{
case Provider.YahooFinance:
fetcher = new Yahoo.YahooFetcher();
break;
case Provider.OpenExchangeRates:
fetcher = new OpenExchangeRates.OXRFetcher();
break;
default:
fetcher = new Yahoo.YahooFetcher();
break;
}
return fetcher;
}
}
public enum Provider
{
YahooFinance,
OpenExchangeRates
}
}
|
39d34af33bddde0a5f2d912b2b34ac3217fb7548
|
C#
|
SlimmyJ/ComputerShopForm
|
/ComputerShopForm/GamingPc.cs
| 3.015625
| 3
|
namespace ComputerShopForm
{
public class GamingPc : Computer
{
public string Gpu { get; set; }
public Performance RgbPerformance { get; set; }
public bool CanPlayFortniteOnHigh { get; set; }
public GamingPc(int id, string name, double price, string imagepath, string summary, int stock, int ram, string mobo, string hdd, string cpu, string psu, string gpu, Performance rgbperformance, bool fortnite)
: base(id, name, price, imagepath, summary, stock, ram, mobo, hdd, cpu, psu)
{
Gpu = gpu;
RgbPerformance = rgbperformance;
CanPlayFortniteOnHigh = fortnite;
}
public override string ToString()
{
string fortnite = CanPlayFortniteOnHigh ? "Fortnite(60fps+)" : "Fortnite(30fps+)";
string add = $"Has GPU :{Gpu}, {fortnite}";
return base.ToString() + add;
}
}
}
|
fa6994d86953c4cb974ff2a0f2e887985b54c09d
|
C#
|
shendongnian/download4
|
/latest_version_download2/60946-11060729-146298684-10.cs
| 3.21875
| 3
|
public partial class YourClass
{
private ManualResetEvent _serviceObjectWaitHandle = new ManualResetEvent(false);
private dynamic _serviceObject;
private void Store(dynamic serviceObject)
{
_serviceObject = serviceObject;
//If you need to do some work as soon as _serviceObject is ready...
// then it can be done here, this may still be the thread pool thread.
//If you need to call something like the UI...
// you will need to use BeginInvoke or a similar solution.
_serviceObjectWaitHandle.Set();
}
public void WaitForServiceObject()
{
//You may also expose other overloads, just for convenience.
//This will wait until Store is executed
//When _serviceObjectWaitHandle.Set() is called
// this will let other threads pass.
_serviceObjectWaitHandle.WaitOne();
}
public dynamic ServiceObject
{
get
{
return _serviceObject;
}
}
}
|
a4a976aecb3d5f8f8ae9f78cbe3133245bb27f64
|
C#
|
vardars/EFPatterns
|
/sourceCode/efpatterns/Main/EntityFramework.Patterns/Decorators/AuditableRepository.cs
| 2.765625
| 3
|
using System;
using System.Threading;
using EntityFramework.Patterns.Extensions;
namespace EntityFramework.Patterns.Decorators
{
public class AuditableRepository<T> : RepositoryDecoratorBase<T>
where T : class
{
public AuditableRepository(IRepository<T> surrogate) : base(surrogate) { }
public override void Insert(T entity)
{
IAuditable auditable = entity as IAuditable;
if (auditable != null)
{
auditable.CreatedBy = Thread.CurrentPrincipal.Identity.Name;
auditable.Created = DateTime.Now;
}
base.Insert(entity);
}
public override void Update(T entity)
{
IAuditable auditable = entity as IAuditable;
if (auditable != null)
{
auditable.UpdatedBy = Thread.CurrentPrincipal.Identity.Name;
auditable.Updated = DateTime.Now;
}
base.Update(entity);
}
}
}
|
a3e460aabf4a46ad98d24381576efc3b3aacafff
|
C#
|
jonkeda/Tooling
|
/Tooling.Foundation/Extensions/PointTransform.cs
| 2.8125
| 3
|
using System.Drawing;
using System.Windows;
using System.Windows.Media;
using Point = System.Windows.Point;
namespace Tooling.Extensions
{
public static class PointTransform
{
private static bool _initialized;
public static Matrix TransformFromDevice { get; private set; }
public static Matrix TransformToDevice { get; private set; }
public static void Initialize(System.Windows.Media.Visual visual)
{
if (_initialized)
{
return;
}
_initialized = true;
Set(visual);
}
public static void Set(System.Windows.Media.Visual visual)
{
PresentationSource x = PresentationSource.FromVisual(visual);
if (x?.CompositionTarget != null)
{
TransformFromDevice = x.CompositionTarget.TransformFromDevice;
TransformToDevice = x.CompositionTarget.TransformToDevice;
}
}
public static Point FromDevice(this Point point)
{
if (_initialized)
{
return TransformFromDevice.Transform(point);
}
return point;
}
public static Point ToDevice(this Point point)
{
if (_initialized)
{
return TransformToDevice.Transform(point);
}
return point;
}
//public static System.Drawing.Point ToDevice(this System.Drawing.Point? point)
//{
// if (point.HasValue)
// {
// return point.Value.ToDevice();
// }
// return System.Drawing.Point.Empty;
//}
//public static System.Drawing.Point ToDevice(this System.Drawing.Point point)
//{
// if (_initialized)
// {
// return TransformToDevice.Transform(point.ToPoint()).ToPoint();
// }
// return point;
//}
//public static PointF ToDevice(this PointF point)
//{
// if (_initialized)
// {
// return TransformToDevice.Transform(point.ToPoint()).ToPoint();
// }
// return point;
//}
//public static System.Drawing.Point FromDevice(this System.Drawing.Point point)
//{
// if (_initialized)
// {
// return TransformFromDevice.Transform(point.ToPoint()).ToPoint();
// }
// return point;
//}
//public static System.Drawing.Size FromDevice(this System.Drawing.Size size)
//{
// if (_initialized)
// {
// return TransformFromDevice.Transform(size.ToPoint().ToPoint()).ToSize();
// }
// return size;
//}
//public static Rectangle ToDevice(this Rectangle rectangle)
//{
// if (_initialized)
// {
// System.Drawing.Point location = ToDevice(rectangle.Location);
// System.Drawing.Size size = ToDevice(rectangle.Size.ToPoint()).ToSize();
// return new Rectangle(location, size);
// }
// return rectangle;
//}
//public static RectangleF ToDevice(this RectangleF rectangle)
//{
// if (_initialized)
// {
// PointF location = ToDevice(rectangle.Location);
// SizeF size = ToDevice(rectangle.Size.ToPointF()).ToSizeF();
// return new RectangleF(location, size);
// }
// return rectangle;
//}
//public static System.Drawing.Point Middle(this Rectangle rectangle)
//{
// return new System.Drawing.Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2);
//}
//public static Rectangle FromDevice(this Rectangle rectangle)
//{
// if (_initialized)
// {
// System.Drawing.Point location = FromDevice(rectangle.Location);
// System.Drawing.Size size = FromDevice(rectangle.Size.ToPoint()).ToSize();
// return new Rectangle(location, size);
// }
// return rectangle;
//}
}
}
|
842a106d962ab562f3ada14a9589df5e3b11d264
|
C#
|
PaulMcPhee79/SparrowXNA
|
/SparrowXNA/SPListenerStrong.cs
| 2.546875
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SparrowXNA
{
internal class SPListenerStrong : SPListener
{
public Action<SPEvent> Action { get; private set; }
public SPListenerStrong(Action<SPEvent> handler)
{
Action = handler;
}
public override bool Invoke(SPEvent ev)
{
Action<SPEvent> action = Action;
if (action != null)
{
action.Invoke(ev);
return true;
}
else
return false;
}
public override bool IsListening(object target)
{
return target != null && target == Action.Target;
}
public override bool IsListening(Delegate eventHandler)
{
return eventHandler != null && eventHandler.Target == Action.Target && eventHandler.Method == Action.Method;
}
public override void Cleanup()
{
//Action = null;
}
}
}
|
a16eb268f78b1b899ab63771e9e51686a852077f
|
C#
|
cmckechney/countwords
|
/countwords/Program.cs
| 3.703125
| 4
|
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace countwords
{
internal class Program
{
private static void Main(string[] args)
{
// Get the file's text.
string txt = File.ReadAllText(args[0]);
// Use regular expressions to replace characters
// that are not letters or numbers with spaces.
Regex reg_exp_remove = new Regex("[^a-zA-Z0-9-]");
txt = reg_exp_remove.Replace(txt, " ");
// Split the text into words.
string[] words = txt.Split(
new char[] { ' ' },
StringSplitOptions.RemoveEmptyEntries);
// Use LINQ to get the unique words.
var word_query =
(from string word in words
orderby word
select word).Distinct();
string exp="";
// Filter out matches
if (args.Count() > 1)
{
for (int i = 1; i <= args.Count() -1; i++)
{
if (exp.Length > 0) { exp += "|"; }
exp +=args[i] ;
}
}
else
{
exp = ".";
}
Regex reg_exp_find = new Regex(exp);
var matches_query = (from string match in word_query
where reg_exp_find.IsMatch(match)
select match
);
// Display the result.
string[] result = matches_query.ToArray();
Console.WriteLine(result.ToString());
Console.WriteLine(result.Length + " words");
}
}
}
|
8688c56fc098488bb1b37ace47573a02a28116d8
|
C#
|
kaushik-rohit/code2seq
|
/rawdata/C#/snippets/857.cs
| 2.96875
| 3
|
private static List<CategoryInfo> GetCategoryTree(int parentid, List<CategoryInfo> listcate, int level)
{
var listAll = _categories;//这里面从内存读数据,所以不会遍历查库,暂时查库,要不他会将遍历后的值传给_categories
if (listAll.FindAll(c => !string.IsNullOrEmpty(c.TreeChar)).Count>0) {
_categories = DatabaseProvider.Instance.GetCategoryList();
listAll = _categories;
}
var treelist = new List<CategoryInfo>();
foreach (var cate in listcate)
{
if (cate.ParentId == parentid)
{
cate.Depth = level;
if (level > 0)
{
for (int i = 0; i < level; i++)
{
cate.TreeChar += " └ ";//父类的TreeChar加当前的TreeChar
}
}
else
{
cate.Path = cate.CategoryId.ToString();//当前cateid
cate.TreeChar = "";
}
treelist.Add(cate);
//如果它还有子分类 则继续递归
var childlist = listAll.FindAll(c => c.ParentId == cate.CategoryId);
if (childlist.Count > 0)
{
foreach (var child in GetCategoryTree(cate.CategoryId, childlist, level + 1))
{
treelist.Add(child);
}
}
}
}
return treelist;
}
|
2c6dfd1e7c751d76a82c4e8df41e7234fb268aaa
|
C#
|
KondratievFIT/Laba-2
|
/Завдання3/Завдання3/Program.cs
| 3.515625
| 4
|
using System;
namespace Завдання3
{
class Book
{
static public void Show()
{
Title.Show();
Author.Show();
Content.Show();
}
}
class Title
{
static public string _title;
public string title
{
get
{
return _title;
}
}
public Title()
{
Console.WriteLine("Введіть назву книги:");
_title = Console.ReadLine();
}
static public void Show()
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Назва книги:");
Console.WriteLine(_title);
}
}
class Author
{
static public string _author;
public Author()
{
Console.WriteLine("Введіть імя автора:");
_author = Console.ReadLine();
}
static public void Show()
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Імя автора:");
Console.WriteLine(_author);
}
}
class Content
{
static public string _content;
public Content()
{
Console.WriteLine("Введіть зміст:");
_content = Console.ReadLine();
}
static public void Show()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Зміст книги:");
Console.WriteLine(_content);
}
}
class Program
{
static void Main(string[] args)
{
Title Example = new Title();
Author Example1 = new Author();
Content Example2 = new Content();
Console.OutputEncoding = Console.InputEncoding = System.Text.Encoding.UTF8;
Book.Show();
}
}
}
|
2145d632c484c6db7e2bf0754d33e0eb8f296f03
|
C#
|
StJohnSchruben/MageKnight
|
/ReDefNet/ContractAnnotationAttribute.cs
| 2.984375
| 3
|
using System;
namespace JetBrains.Annotations
{
/// <summary>
/// A ReSharper annotation attribute that aids in code analysis. See ReSharper code annotation documentation for details.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
internal class ContractAnnotationAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="ContractAnnotationAttribute" /> class.
/// </summary>
/// <param name="contract">The contract.</param>
public ContractAnnotationAttribute(string contract)
: this(contract, false)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ContractAnnotationAttribute" /> class.
/// </summary>
/// <param name="contract">The contract.</param>
/// <param name="forceFullStates"><c>true</c>, if full states should be forced; otherwise, <c>false</c>.</param>
public ContractAnnotationAttribute(string contract, bool forceFullStates)
{
this.Contract = contract;
this.ForceFullStates = forceFullStates;
}
/// <summary>
/// Gets the contract.
/// </summary>
/// <value>
/// The contract.
/// </value>
public string Contract { get; }
/// <summary>
/// Gets a value indicating whether full states should be forced.
/// </summary>
/// <value>
/// <c>true</c>, if full states should be forced; otherwise, <c>false</c>.
/// </value>
public bool ForceFullStates { get; }
}
}
|
c537bd186edb401cb24152a199783aa44c7fb337
|
C#
|
Jaibean/Basic-C-Sharp-Projects
|
/DateTime/DateTime/Program.cs
| 3.34375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace DateTimeAssignment
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now);
Console.ReadLine();
Console.WriteLine("Pick a number");
int userInput = Convert.ToInt32(Console.ReadLine());
// Prints to the console the exact time it will be in X hours, X being the number the user entered in step 2.
Console.ReadLine();
DateTime thenAndNow = DateTime.Now.AddHours(userInput);
Console.WriteLine("It will be " + thenAndNow + " in " + userInput + " hours.");
Console.ReadLine();
}
}
}
|
726681103bcda2b8edeeddb7243c6eecb2b71078
|
C#
|
eliasfpaiva/Trabalhos_PUC
|
/Escola de Férias/LinQ/LinQ-Ex1/LinQ-Ex1/Program.cs
| 2.84375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LinQ_Ex1
{
class Program
{
static void Main(string[] args)
{
//int[] Vetor = { 98, 45, 67, 23, 18, 90, 58, 30, 26, 72 };
//foreach (int n in Vetor)
//{
// Console.Write("{0} ", n);
//}
//var Consulta = from Valor in Vetor
// select Valor;
//foreach (int n in Consulta)
//{
// Console.Write("{0} ", n);
//}
//var Consulta = from Valor in Vetor
// orderby Valor select Valor;
//foreach (int n in Consulta)
//{
// Console.Write("{0} ", n);
//}
//var Consulta = from Valor in Vetor
// orderby Valor
// where Valor >= 50
// select Valor;
//foreach (int n in Consulta)
//{
// Console.Write("{0} ", n);
//}
//var Consulta = (from Valor in Vetor
// orderby Valor
// where Valor >= 50
// select Valor).Count();
//Console.WriteLine("Quantidade: {0} ", Consulta);
//var Consulta = (from Valor in Vetor
// select Valor).Average();
//Console.WriteLine("Média: {0} ", Consulta);
//var Consulta = (from Valor in Vetor
// select Valor).Sum();
//Console.WriteLine("Média: {0} ", Consulta);
//var Consulta = (from Valor in Vetor
// select Valor).Max();
//Console.WriteLine("Máximo: {0} ", Consulta);
//var Consulta = (from Valor in Vetor
// select Valor).Min();
//Console.WriteLine("Mínimo: {0} ", Consulta);
//int[] VetorA = { 98, 45, 67, 23, 18, 90, 58, 30, 26, 72 };
//int[] VetorB = { 35, 48, 97, 65, 17, 49, 93, 50, 32, 71 };
//var Consulta = from Valor1 in VetorA
// from Valor2 in VetorB
// where Valor1 < Valor2
// select new { Valor1, Valor2 };
//foreach (var x in Consulta)
//{
// Console.WriteLine("{0} é menor que {1}", x.Valor1, x.Valor2);
//}
//var Consulta = from Valor1 in VetorA
// from Valor2 in VetorB
// where Valor1 < Valor2
// select new { Valor1, Valor2 };
//foreach (var x in Consulta)
//{
// Console.WriteLine("{0} é menor que {1}", x.Valor1, x.Valor2);
//}
//string[] Vetor = { "FiAT", "CheVROleT", "ToYOta", "MitSUBishI", "VolkKSwagEN" };
//var Consulta = from Valor in Vetor
// select new
// {
// Maiusculas = Valor.ToUpper(),
// Minusculas = Valor.ToLower()
// };
//foreach (var x in Consulta)
//{
// Console.WriteLine("{0} / {1}", x.Maiusculas, x.Minusculas);
//}
//string[] Vetor = { "Banana", "Abacate", "Melancia", "Amora", "Caju", "Abacaxi", "Maça" };
//var FrutaLetra = from Fruta in Vetor
// orderby Fruta
// group Fruta by Fruta[0];
//foreach (var GrupoFruta in FrutaLetra)
//{
// Console.WriteLine("\nFrutas que começam com '{0}'", GrupoFruta.Key);
// foreach (var x in GrupoFruta)
// {
// Console.WriteLine("\t{0}", x);
// }
//}
Console.ReadKey();
}
}
}
|
e923b9ac9a3d136970b99b5979de21ff717f0cc8
|
C#
|
marcwittke/DockerComposeVs15Bug
|
/src/WebApplication5.Domain/Class1.cs
| 3.125
| 3
|
using System;
using System.Data.SqlClient;
namespace WebApplication5.Domain
{
using System.Collections.Generic;
using System.Data;
public class Class1
{
public string[] GetDatabases(string masterConnectionString)
{
List<string> databases = new List<string>();
using (SqlConnection connection = new SqlConnection(masterConnectionString))
{
connection.Open();
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "SELECT Name FROM sys.Databases";
var reader = command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
databases.Add(reader.GetString(0));
}
}
}
return databases.ToArray();
}
}
}
|
f2949e7c740ce4c20fe961fe90a906c21958018b
|
C#
|
panda926/BBMessenger
|
/ChatEngine/VideoInfo.cs
| 2.6875
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ChatEngine
{
public class VideoInfo : BaseInfo
{
public string UserId = ""; // 20
public int IsEnd = 0;
public byte[] Data = null;
public byte[] ImgData = null;
public string ImgName = ""; // 20
public VideoInfo()
{
_InfoType = InfoType.Video;
}
override public int GetSize()
{
return base.GetSize() + EncodeCount(UserId) + EncodeCount(IsEnd) + 4 + Data.Length + 4 + ImgData.Length + EncodeCount(ImgName);
}
override public void GetBytes( BinaryWriter bw )
{
try
{
base.GetBytes(bw);
EncodeString(bw, UserId );
EncodeInteger(bw, IsEnd);
EncodeInteger( bw, Data.Length);
bw.Write(Data);
EncodeInteger(bw, ImgData.Length);
bw.Write(ImgData);
EncodeString(bw, ImgName);
}
catch (Exception ex)
{
// Error Handling
}
}
override public void FromBytes(BinaryReader br )
{
base.FromBytes(br);
UserId = DecodeString(br);
IsEnd = DecodeInteger(br);
int length = DecodeInteger(br);
Data = new byte[length];
Data = br.ReadBytes(length);
int imglength = DecodeInteger(br);
ImgData = new byte[imglength];
ImgData = br.ReadBytes(imglength);
ImgName = DecodeString(br);
}
}
}
|
5f86359410abfc0541f52dda2e43f60a317f9295
|
C#
|
llenroc/leetcodeScraper
|
/problems/cs/112.cs
| 3.71875
| 4
|
// Url:https://leetcode.com/problems/path-sum
/*
112. Path Sum
Easy
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
Note: A leaf is a node with no children.
Example:
Given the below binary tree and sum = 22,
5
/ \
4 8
/ / \
11 13 4
/ \ \
7 2 1
return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.
*/
using System;
namespace InterviewPreperationGuide.Core.LeetCode.Solution112
{
/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNode(int x) { val = x; } * } */
public class Solution
{
public void Init() { }
public bool HasPathSum(TreeNode root, int sum) { }
}
}
|
fdc4fe52018549f21b36b224c56f790d3912d6e2
|
C#
|
diazg/runniac
|
/Runniac.ExternalDataExtraction/IMultiExtractor.cs
| 2.859375
| 3
|
using Runniac.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Runniac.ExternalDataExtraction
{
public interface IMultiExtractor
{
/// <summary>
/// Añade una estrategia a la extracción de eventos. Una estrategia es un sitio web
/// del que vamos a intentar extraer eventos.
/// </summary>
/// <param name="strategy">Estrategia a utilizar.</param>
void AddStrategy(IEventsExtractor strategy);
/// <summary>
/// Retorna todos los eventos de las distintas páginas web configuradas.
/// </summary>
/// <returns>La lista de eventos encontrados.</returns>
IEnumerable<Event> GetEvents(string extractor);
/// <summary>
/// Completa la información de un evento. Este método es útil para intentar encontrar
/// información adicional en la página de detalle del evento.
/// </summary>
/// <param name="eventObj">Evento del que se va a intentar completar su información.</param>
/// <returns></returns>
Event GetExtraInfo(Event eventObj, string extractor);
}
}
|
9190db54ef0b935b232889fce34206193570c7fe
|
C#
|
czAksay/KS-MVVM-Chat
|
/ClientServerChat/ChatServer/Program.cs
| 2.84375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClientServerLib.ClientAndServer;
using ClientServerLib.Common;
using SettingsAP;
namespace ChatServer
{
class Program
{
static void Main(string[] args)
{
try
{
Settings st = new Settings(ChatSyntax.SettingsFile, true);
st.SetDefaults("ip:127.0.0.1\r\nport:15000");
String ip = st.GetValue("ip");
ushort port = (ushort)st.GetNumValue("port");
MainServer server = new MainServer(ip, port);
if (server.Start().Result)
{
Console.WriteLine($"Запуск сервера {ip}:{port}.\nСервер начинает работу.");
}
else
{
Console.WriteLine("Ошибка при попытке запуска сервера.");
}
server.onServerInform += (m) => { Console.WriteLine(m); };
}
catch(Exception ex)
{ Console.WriteLine("Ошибка: " + ex.Message); }
while (Console.ReadKey().Key != ConsoleKey.Escape) { }
}
}
}
|
27ae31fe379ba6d233572d1bbe8231d8ff1c913d
|
C#
|
MacSquiggles/XMLWeatherTemplate-new
|
/XMLWeather/Forms and User Controls/MainMenu.cs
| 3.359375
| 3
|
/*Program by Quigley
a weather "app" using xml files
created April 28th 2016 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Xml;
namespace XMLWeather
{
public partial class MainMenu : UserControl
{
//recieves the date for today and the next four days
public static DateTime currentDate = DateTime.Now.AddDays(0);
public static DateTime forecastDate1 = DateTime.Now.AddDays(1);
public static DateTime forecastDate2 = DateTime.Now.AddDays(2);
public static DateTime forecastDate3 = DateTime.Now.AddDays(3);
public static DateTime forecastDate4 = DateTime.Now.AddDays(4);
//A string to hold all of the days in
public static List<string> days = new List<string>(5);
public MainMenu()
{
InitializeComponent();
//gets weather info and imputs it into an xml file
GetData();
}
private void currentButton_Click(object sender, EventArgs e)
{
//Opens the current weather form if the current button is clicked
CurrentForm cf = new CurrentForm();
Form f = this.FindForm();
f.Controls.Remove(this);
cf.Location = new Point((f.Width - cf.Width) / 2, (f.Height - cf.Height) / 2);
f.Controls.Add(cf);
cf.BringToFront();
}
private void futureButton_Click(object sender, EventArgs e)
{
// opens the forecast menu if the button is clicked
ForecastMenu fm = new ForecastMenu();
Form f = this.FindForm();
f.Controls.Remove(this);
fm.Location = new Point((f.Width - fm.Width) / 2, (f.Height - fm.Height) / 2);
f.Controls.Add(fm);
fm.BringToFront();
}
/// <summary>
/// Gets the data from the websites and puts it into an xml file
/// </summary>
private static void GetData()
{
WebClient client = new WebClient();
string currentFile = "http://api.openweathermap.org/data/2.5/weather?q=Stratford,CA&mode=xml&units=metric&appid=3f2e224b815c0ed45524322e145149f0";
string forecastFile = "http://api.openweathermap.org/data/2.5/forecast/daily?q=Stratford,CA&mode=xml&units=metric&cnt=7&appid=3f2e224b815c0ed45524322e145149f0";
client.DownloadFile(currentFile, "WeatherData.xml");
client.DownloadFile(forecastFile, "WeatherData7Day.xml");
//Takes the current date and future dates (for the next 4 days) and puts it into a list (in the format yyyy-mm-dd)
List<string> days1 = Convert.ToString(currentDate).Split(' ').ToList<string>();
List<string> days2 = Convert.ToString(forecastDate1).Split(' ').ToList<string>();
List<string> days3 = Convert.ToString(forecastDate2).Split(' ').ToList<string>();
List<string> days4 = Convert.ToString(forecastDate3).Split(' ').ToList<string>();
List<string> days5 = Convert.ToString(forecastDate4).Split(' ').ToList<string>();
days.InsertRange(days.Count(), new string[] { days1[0], days2[0], days3[0], days4[0], days5[0] });
}
private void exitButton_Click(object sender, EventArgs e)
{
//if the exit button is clicked, the program closes
Application.Exit();
}
}
}
|
77b4087a75205c07dbc2155e95ad420c0c7079c7
|
C#
|
mcseba/MasterMind
|
/MasterMind/GameEngine.cs
| 3.578125
| 4
|
using System;
using System.Collections.Generic;
using System.Text;
namespace MasterMind
{
class GameEngine
{
/// <summary>
/// This field holds the code.
/// </summary>
private char[] code = new char[4];
/// <summary>
/// This field keeps player guess.
/// </summary>
public string playerGuess;
/// <summary>
/// '_liczbaRuchow' holds the value for number of moves, default number of moves that player can make is 9.
/// </summary>
private int _liczbaRuchow = 9;
/// <summary>
/// 'black' field holds the number of colors player guessed correctly.
/// </summary>
private int black;
/// <summary>
/// 'white' field holds the number of colors that appear in code but are not in the correct position.
/// </summary>
private int white;
public int liczbaRuchow
{
get => _liczbaRuchow;
set => _liczbaRuchow = value;
}
/// <summary>
/// wTrakcie - Status when game is in progress.
/// Zakonczona - Games has ended.
/// Poddana - Player surrendered the game.
/// </summary>
public enum StatusGry
{
wTrakcie,
Zakonczona,
Poddana
}
public StatusGry Status
{
get;
private set;
}
public DateTime CzasRozpoczecia { get; private set; }
public DateTime CzasZakonczenia { get; private set; }
/// <summary>
/// Timespan between game start and end.
/// </summary>
public TimeSpan CzasGry => CzasZakonczenia - CzasRozpoczecia;
/// <summary>
/// This list stores information about the game.
/// </summary>
public List<Ruch> listaRuchow = new List<Ruch>();
/// <summary>
/// Method for generating random code with given length of code and colors
/// </summary>
/// <param name="codelength">Length of the code</param>
/// <param name="colors">Given colors</param>
public void GenerateCode(int codelength, string colors)
{
Random rnd = new Random();
for (int i = 0; i < codelength; i++)
{
int index = rnd.Next(colors.Length);
code[i] = colors[index];
}
CzasRozpoczecia = DateTime.Now;
Status = StatusGry.wTrakcie;
}
/// <summary>
/// This method sets the number of moves that player can make.
/// </summary>
/// <param name="number">Represent number of moves that player can make in a single game.</param>
public void MoveNumber(int number)
{
liczbaRuchow = number;
}
public void PlayerGuess (string odpowiedz)
{
if (odpowiedz.Length != this.code.Length)
throw new ArgumentOutOfRangeException(odpowiedz, "Podany kod jest za krótki.");
odpowiedz = odpowiedz.ToLower().Trim();
playerGuess = odpowiedz;
}
/// <summary>
/// Method returns the secret code but only when game has ended.
/// </summary>
public void ShowCode()
{
if (this.Status != StatusGry.wTrakcie)
{
foreach (var el in this.code)
{
Console.Write(el);
}
}
else
Console.WriteLine("Nie możesz jeszcze podejrzeć kodu! Gra jest w trakcie rozgrywki.");
}
/// <summary>
/// GetBlackPins returns how many black pins player could guess and stores it in 'black' field.
/// </summary>
public void GetBlackPins()
{
black = 0;
for (int i = 0; i < code.Length; i++)
{
if (playerGuess[i] == this.code[i])
{
black++;
}
}
if (black == code.Length)
{
Status = StatusGry.Zakonczona;
CzasZakonczenia = DateTime.Now;
listaRuchow.Add(new Ruch(white, black, StatusGry.Zakonczona, playerGuess));
}
Console.WriteLine($"Black pins: {black}");
}
/// <summary>
/// GetWhitePins method returns White pins that player could guess and stores it in 'white' field.
/// </summary>
public void GetWhitePins()
{
white = 0;
char[] pomocniczyKod = new char[code.Length];
char[] pomocniczyPlayerGuess = new char[code.Length];
for (int i = 0; i < code.Length; i++)
{
pomocniczyKod[i] = code[i];
pomocniczyPlayerGuess[i] = playerGuess[i];
}
for (int i = 0; i < code.Length; i++)
{
for (int j = 0; j < code.Length; j++)
{
if (playerGuess[i] == pomocniczyKod[j])
{
pomocniczyKod[j] = '0'; // Zapobiega ponownemu policzeniu danego koloru
pomocniczyPlayerGuess[i] = '0'; //
white++;
}
}
}
white -= black;
Console.WriteLine($"White pins: {white}");
listaRuchow.Add(new Ruch(white, black, StatusGry.wTrakcie, playerGuess));
}
/// <summary>
/// This method Stops the game if needed.
/// </summary>
public void StopGame()
{
if (Status == StatusGry.wTrakcie)
{
Status = StatusGry.Poddana;
CzasZakonczenia = DateTime.Now;
listaRuchow.Add(new Ruch(white, black, StatusGry.Poddana, null));
}
Console.Write($"Twój kod do odgadnięcia to: ");
Console.ForegroundColor = ConsoleColor.Red;
ShowCode();
Console.ResetColor();
}
/// <summary>
/// This class represents the way to store information about the game in the List<Ruch>.
/// </summary>
public class Ruch
{
public int whitePin { get; }
public int blackPin { get; }
public StatusGry status { get; }
public string playerguess { get; }
public DateTime time { get; }
public Ruch(int whitepin, int blackpin, StatusGry status, string playerguess)
{
this.whitePin = whitepin;
this.blackPin = blackpin;
this.status = status;
this.playerguess = playerguess;
this.time = DateTime.Now;
}
public override string ToString()
{
return $"{playerguess}, black pin: {blackPin}, white pin: {whitePin}, {status}, {time}";
}
}
}
}
|
2bdfbdb76bc8878ae10644ace7ff34f8bcabf7cd
|
C#
|
Gdyku/WebApi
|
/Logic/UserLogic.cs
| 2.90625
| 3
|
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Models;
using WebApi.DTOModels;
using AutoMapper;
using WebApi.Interfaces;
using System.Linq;
using System.Threading;
using System;
namespace WebApi.Logic
{
public class UserLogic : IUserLogic
{
private readonly IMapper _mapper;
private readonly DataContext _context;
public UserLogic(DataContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}
public async Task<List<UserDTO>> GetUsers()
{
var users = await _context.Users.Include(p => p.Product).ToListAsync();
var mappedUsers = _mapper.Map<List<User>,List<UserDTO>>(users);
return mappedUsers;
}
public async Task<UserDTO> GetUser(Guid ID)
{
var user = await _context.Users.FirstOrDefaultAsync(u => u.ID == ID);
var mappedUser = _mapper.Map<User, UserDTO>(user);
return mappedUser;
}
public async Task CreateUser(UserDTO user)
{
var mappedUser = _mapper.Map<UserDTO, User>(user);
if (user.Name == "chuj")
throw new Exception("Nie możesz nazywać się chuj");
_context.Users.Add(mappedUser);
await _context.SaveChangesAsync();
}
public async Task EditUser(Guid ID, UserDTO updateuser)
{
var user = await _context.Users.FirstOrDefaultAsync(u => u.ID == ID);
if(user == null)
throw new Exception("Couldn't find user");
user.Name = updateuser.Name ?? user.Name;
user.Password = updateuser.Password ?? user.Password;
await _context.SaveChangesAsync();
}
public async Task DeleteUser(Guid ID)
{
var user = await _context.Users.FirstOrDefaultAsync(u => u.ID == ID);
_context.Remove(user);
await _context.SaveChangesAsync();
}
}
}
|
7618c35c9b286504efd01da6a94a0ecbfadabd4e
|
C#
|
Pregum/20180319Sample
|
/FoodInfoWindow.xaml.cs
| 2.703125
| 3
|
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using UserControl = System.Windows.Controls.UserControl;
namespace _20180319Sample
{
/// <summary>
/// UserControl2.xaml の相互作用ロジック
/// </summary>
public partial class UserControl2 : UserControl
{
/// <summary>
/// 現在表示している食材インデックス
/// </summary>
private int CurrentIndex { get; set; }
public UserControl2()
{
InitializeComponent();
}
/// <summary>
/// 現在表示している食材リストで一つ後の食材を表示します。
/// 現在表示している食材が一番最後の場合、一番最初の食材が表示されます。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void NextButton_Click(object sender, RoutedEventArgs e)
{
if (this.DataContext is ObservableCollection<Food> list)
{
this.CurrentIndex = list.Count > this.CurrentIndex + 1 ? this.CurrentIndex + 1 : 0;
this.Image_FoodIcon.Source = list[this.CurrentIndex].FoodImage;
this.Label_FoodName.Content = list[this.CurrentIndex].Name;
this.Label_Weight.Content = list[this.CurrentIndex].Weight;
this.Label_BoughtDate.Content = list[this.CurrentIndex].BoughtDate.Date;
}
}
/// <summary>
/// DataContextが変更された時、発生します。
/// 値が入っていない場合は発生しません。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Grid_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.DataContext is ObservableCollection<Food> list)
{
if (list.Count > 0)
{
this.Image_FoodIcon.Source = list[0].FoodImage;
this.Label_FoodName.Content = list[0].Name;
this.Label_Weight.Content = list[0].Weight;
this.Label_BoughtDate.Content = list[0].BoughtDate.Date;
}
}
else
{
//// FIXME: 食材が存在しない場合question.pngを表示させるようにする.
var hoge = new BitmapImage(new Uri("Resources/question.png", UriKind.Relative));
this.Image_FoodIcon.Source = hoge;
//this.Image_FoodIcon.SetValue(Image.SourceProperty,
// new BitmapImage(new Uri("Resources/question.png", UriKind.Relative)));
//MessageBox.Show(this.Image_FoodIcon.GetValue(Image.SourceProperty).ToString());
this.Label_FoodName.Content = "???";
this.Label_Weight.Content = "???";
this.Label_BoughtDate.Content = "???";
}
this.CurrentIndex = 0;
}
/// <summary>
/// 現在表示している食材リストで一つ前の食材を表示します。
/// 現在表示している食材が一番最初の場合、一番最後の食材が表示されます。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PreviousButton_Click(object sender, RoutedEventArgs e)
{
if (this.DataContext is ObservableCollection<Food> list)
{
this.CurrentIndex = 0 <= this.CurrentIndex - 1 ? this.CurrentIndex - 1 : list.Count - 1;
this.Image_FoodIcon.Source = list[this.CurrentIndex].FoodImage;
this.Label_FoodName.Content = list[this.CurrentIndex].Name;
this.Label_Weight.Content = list[this.CurrentIndex].Weight;
this.Label_BoughtDate.Content = list[this.CurrentIndex].BoughtDate.Date;
}
}
}
}
|
4dcadbe78597823a31adc4edf379b3d46dda058c
|
C#
|
ShadowMinhja/FBClone
|
/FBClone.Service/Guestcards/QuestionResponseSetService.cs
| 2.5625
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using FBClone.Data;
using FBClone.Data.Infrastructure;
using FBClone.Data.Repositories;
using FBClone.Model;
using System.Linq.Expressions;
using FBClone.Service.Common;
namespace FBClone.Service
{
public interface IQuestionResponseSetService
{
QuestionResponseSet GetById(string Id);
IEnumerable<QuestionResponseSet> GetAll();
IEnumerable<QuestionResponseSet> GetMany(string userName);
IQueryable<QuestionResponseSet> Query(Expression<Func<QuestionResponseSet, bool>> where);
QuestionResponseSet Add(QuestionResponseSet questionResponseSet);
QuestionResponseSet Update(QuestionResponseSet questionResponseSet);
void Delete(string id);
Dictionary<string, double> GetCategoryScores(QuestionResponseSet newQuestionResponseSet);
}
public class QuestionResponseSetService : IQuestionResponseSetService
{
private readonly IUnitOfWork unitOfWork;
private readonly IQuestionResponseSetRepository questionResponseSetRepository;
private readonly IQuestionResponseRepository questionResponseRepository;
private readonly IQuestionService questionService;
private readonly IAnswerService answerService;
public QuestionResponseSetService(IUnitOfWork unitOfWork, IQuestionResponseSetRepository questionResponseSetRepository, IQuestionResponseRepository questionResponseRepository, IQuestionService questionService, IAnswerService answerService)
{
this.unitOfWork = unitOfWork;
this.questionResponseSetRepository = questionResponseSetRepository;
this.questionResponseRepository = questionResponseRepository;
this.questionService = questionService;
this.answerService = answerService;
}
public QuestionResponseSet GetById(string id)
{
return questionResponseSetRepository.GetById(id);
}
public IEnumerable<QuestionResponseSet> GetAll()
{
return questionResponseSetRepository.AllIncluding(x => x.Survey, x => x.QuestionResponses);
}
public IEnumerable<QuestionResponseSet> GetMany(string tableNumber)
{
return questionResponseSetRepository.GetMany(x => x.TableNumber == tableNumber);
}
public IQueryable<QuestionResponseSet> Query(Expression<Func<QuestionResponseSet, bool>> where)
{
return questionResponseSetRepository.Query(where);
}
public QuestionResponseSet Add(QuestionResponseSet questionResponseSet)
{
QuestionResponseSet newQuestionResponseSet = new QuestionResponseSet {
SurveyId = questionResponseSet.SurveyId,
LocationId = questionResponseSet.LocationId,
CustomerName = questionResponseSet.CustomerName,
CustomerEmail = questionResponseSet.CustomerEmail,
IsSubscribe = questionResponseSet.IsSubscribe,
Positivity = questionResponseSet.Positivity,
TotalScore = questionResponseSet.TotalScore,
SessionDuration = questionResponseSet.SessionDuration,
UserId = questionResponseSet.UserId,
CreatedBy = questionResponseSet.CreatedBy,
UpdatedBy = questionResponseSet.UpdatedBy
};
questionResponseSetRepository.Add(newQuestionResponseSet);
foreach (var questionResponse in questionResponseSet.QuestionResponses)
{
questionResponse.QuestionResponseSetId = newQuestionResponseSet.Id;
questionResponse.UserId= newQuestionResponseSet.UserId;
questionResponse.CreatedBy = newQuestionResponseSet.CreatedBy;
questionResponse.UpdatedBy = newQuestionResponseSet.UpdatedBy;
questionResponseRepository.Add(questionResponse);
}
unitOfWork.SaveChanges();
return newQuestionResponseSet;
}
public QuestionResponseSet Update(QuestionResponseSet QuestionResponseSet)
{
questionResponseSetRepository.Update(QuestionResponseSet);
unitOfWork.SaveChanges();
return QuestionResponseSet;
}
public void Delete(string id)
{
var QuestionResponseSet = questionResponseSetRepository.GetById(id);
var QuestionResponseSets = questionResponseSetRepository.GetMany(x => x.Id == id); //<--Anything that has foreign key relationships
foreach (var item in QuestionResponseSets)
{
questionResponseSetRepository.Delete(item);
}
if (QuestionResponseSet != null)
{
questionResponseSetRepository.Delete(QuestionResponseSet);
unitOfWork.SaveChanges();
}
}
public Dictionary<string, double> GetCategoryScores(QuestionResponseSet newQuestionResponseSet)
{
Dictionary<string, double> categoryScores = new Dictionary<string, double>();
List<string> categories = newQuestionResponseSet.QuestionResponses.Select(x => x.Question.Category.Name).Distinct().ToList();
foreach(string category in categories)
{
List<QuestionResponse> questionResponses = newQuestionResponseSet.QuestionResponses.Where(x => x.Question.Category.Name == category).ToList();
double totalScore = Utils.ComputeTotalScore(questionResponses);
categoryScores.Add(category, totalScore);
}
return categoryScores;
}
}
}
|
27f9f955dcb154b9f5eb02e68fafbcd4c7f8525f
|
C#
|
speedhans/ProjectCasual
|
/Assets/Project/Scripts/BehaviorTree/Node/ActionNode/GlobalTimeCheckNode.cs
| 2.71875
| 3
|
using System;
using System.Collections.Generic;
using UnityEngine;
public class GlobalTimeCheckNode : ActionNode
{
public enum E_COMPARE
{
LESS,
LEQUAL,
EQUAL,
GEQUAL,
GREATE,
}
[Serializable]
public struct S_COMPARE
{
public int day;
public int hour;
public int minute;
public E_COMPARE Compare;
}
public S_COMPARE[] m_Compare;
public override bool BehaviorUpdate(Character _Self, float _DeltaTime)
{
for (int i = 0; i < m_Compare.Length; ++i)
{
if (!TimeCheck(i)) return false;
}
return true;
}
public override void TickUpdate(Character _Self, float _DeltaTime)
{
}
bool TimeCheck(int _TableNumber)
{
switch(m_Compare[_TableNumber].Compare)
{
case E_COMPARE.LESS:
{
if (m_Compare[_TableNumber].day < GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.DAY))
return true;
else if (m_Compare[_TableNumber].hour < GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.HOUR))
return true;
else if (m_Compare[_TableNumber].minute < GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.MINUTE))
return true;
}
break;
case E_COMPARE.LEQUAL:
{
if (m_Compare[_TableNumber].day <= GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.DAY))
return true;
else if (m_Compare[_TableNumber].hour <= GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.HOUR))
return true;
else if (m_Compare[_TableNumber].minute <= GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.MINUTE))
return true;
}
break;
case E_COMPARE.EQUAL:
{
if ((m_Compare[_TableNumber].day == GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.DAY)) &&
(m_Compare[_TableNumber].hour == GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.HOUR)) &&
(m_Compare[_TableNumber].minute == GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.MINUTE)))
return true;
}
break;
case E_COMPARE.GEQUAL:
{
if (m_Compare[_TableNumber].day >= GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.DAY))
return true;
else if (m_Compare[_TableNumber].hour >= GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.HOUR))
return true;
else if (m_Compare[_TableNumber].minute >= GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.MINUTE))
return true;
}
break;
case E_COMPARE.GREATE:
{
if (m_Compare[_TableNumber].day > GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.DAY))
return true;
else if (m_Compare[_TableNumber].hour > GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.HOUR))
return true;
else if (m_Compare[_TableNumber].minute > GameManager.Instance.GetWorldTime(GameManager.E_TIMETYPE.MINUTE))
return true;
}
break;
}
return false;
}
}
|
603c8ff9f89db9d44eeee6fed2d47a162e68b879
|
C#
|
rafalohaki/SoftUni
|
/Technology-Fundamentals-C#/Associative-Arrays/Exercise/Count Chars in a String/Program.cs
| 3.625
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Count_Chars_in_a_String
{
class Program
{
static void Main(string[] args)
{
var text = Console.ReadLine().Where(x=>x!=' ').ToArray();
Dictionary<char, int> dic = new Dictionary<char, int>();
for (int i = 0; i < text.Length; i++)
{
if (!dic.ContainsKey(text[i]))
{
dic[text[i]]=0;
}
dic[text[i]]++;
}
foreach (var kvp in dic)
{
Console.WriteLine($"{kvp.Key} -> {kvp.Value}");
}
}
}
}
|
d747982ba9f733ed29ef5aafbac82a457ead2051
|
C#
|
Epi-Info/Epi-Info-Community-Edition
|
/Epi.Data.SqlServer/SqlDatabase.cs
| 2.65625
| 3
|
using System;
using System.Data.SqlClient;
using System.IO;
using System.Xml;
using Epi.Collections;
using System.Collections.Generic;
using System.Data.Common;
using System.Data;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
namespace Epi.Data.SqlServer
{
/// <summary>
/// Concret SQL Server Database Class
/// </summary>
public partial class SqlDatabase : DbDriverBase
{
private bool isBulkOperation;
/// <summary>
/// SQL Database Constructor
/// </summary>
public SqlDatabase() : base() { }
#region Native Driver Implementation
/// <summary>
/// Returns a native equivalent of a DbParameter
/// </summary>
/// <returns>A native equivalent of a DbParameter</returns>
protected virtual SqlParameter ConvertToNativeParameter(QueryParameter parameter)
{
if(parameter.DbType.Equals(DbType.Guid))
{
parameter.Value = new Guid(parameter.Value.ToString());
}
return new SqlParameter(parameter.ParameterName, CovertToNativeDbType(parameter.DbType), parameter.Size, parameter.Direction, parameter.IsNullable, parameter.Precision, parameter.Scale, parameter.SourceColumn, parameter.SourceVersion, parameter.Value);
}
/// <summary>
/// Gets a native connection instance based on current ConnectionString value
/// </summary>
/// <returns>Native connection object</returns>
protected virtual SqlConnection GetNativeConnection()
{
return GetNativeConnection(connectionString);
}
/// <summary>
/// Gets a native connection instance from supplied connection string
/// </summary>
/// <returns>Native connection object</returns>
protected virtual SqlConnection GetNativeConnection(string connectionString)
{
return new SqlConnection(connectionString);
}
/// <summary>
/// Returns a native command object
/// </summary>
/// <param name="transaction">Null is not allowed. </param>
/// <returns></returns>
protected SqlCommand GetNativeCommand(IDbTransaction transaction)
{
SqlTransaction oleDbtransaction = transaction as SqlTransaction;
#region Input Validation
if (oleDbtransaction == null)
{
throw new ArgumentException("Transaction parameter must be a SqlTransaction.", "transaction");
}
#endregion
return new SqlCommand(null, (SqlConnection)transaction.Connection, (SqlTransaction)transaction);
}
/// <summary>
/// Executes a SELECT statement against the database and returns a disconnected data table. NOTE: Use this overload to work with Typed DataSets.
/// </summary>
/// <param name="selectQuery">The query to be executed against the database</param>
/// <param name="dataTable">Table that will contain the result</param>
/// <returns>A data table object</returns>
public override DataTable Select(Query selectQuery, DataTable dataTable)
{
#region Input Validation
if (selectQuery == null)
{
throw new ArgumentNullException("selectQuery");
}
if (dataTable == null)
{
throw new ArgumentNullException("dataTable");
}
#endregion Input Validation
IDbConnection connection = GetConnection();
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)GetCommand(selectQuery.SqlStatement, connection, selectQuery.Parameters);
adapter.SelectCommand.CommandTimeout = 1500;
try
{
adapter.Fill(dataTable);
try
{
adapter.FillSchema(dataTable, SchemaType.Source);
}
catch (ArgumentException ex)
{
// do nothing
}
return dataTable;
}
//SqlException being caught to handle denied permissions for SELECT, but other
// exceptions may occur and will need to be handled. -den4 11/23/2010
catch (System.Data.SqlClient.SqlException ex)
{
throw new System.ApplicationException("Error executing select query against the database.", ex);
/*Epi.Windows.MsgBox.Show("You may not have permission to access the database. \n\n" +
ex.Message,
"Permission Denied",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error);
return dataTable;*/
}
catch (Exception ex)
{
throw new System.ApplicationException("Error executing select query against the database.", ex);
}
}
/// <summary>
/// Warning! This method does not support transactions!
/// </summary>
/// <param name="dataTable"></param>
/// <param name="tableName"></param>
/// <param name="insertQuery"></param>
/// <param name="updateQuery"></param>
public override void Update(DataTable dataTable, string tableName, Query insertQuery, Query updateQuery)
{
#region Input Validation
if (dataTable == null)
{
throw new ArgumentNullException("DataTable");
}
if (string.IsNullOrEmpty(tableName))
{
throw new ArgumentNullException("TableName");
}
if (insertQuery == null)
{
throw new ArgumentNullException("InsertQuery");
}
if (updateQuery == null)
{
throw new ArgumentNullException("UpdateQuery");
}
#endregion Input Validation
IDbConnection connection = GetConnection();
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.InsertCommand = (SqlCommand)GetCommand(insertQuery.SqlStatement, connection, insertQuery.Parameters);
adapter.UpdateCommand = (SqlCommand)GetCommand(updateQuery.SqlStatement, connection, updateQuery.Parameters);
adapter.InsertCommand.CommandTimeout = 1500;
adapter.UpdateCommand.CommandTimeout = 1500;
//Logger.Log(insertQuery);
//Logger.Log(updateQuery);
try
{
adapter.Update(dataTable);
}
catch (Exception ex)
{
throw new System.ApplicationException("Error updating data.", ex);
}
}
/// <summary>
/// Updates the GUIDs of a child table with those of the parent via a uniquekey/fkey relationship
/// </summary>
public override void UpdateGUIDs(string childTableName, string parentTableName)
{
StringBuilder sb = new StringBuilder();
sb.Append("UPDATE ");
sb.Append(childTableName);
sb.Append(" SET FKEY = ");
sb.Append(parentTableName);
sb.Append(".GlobalRecordId from ");
sb.Append(childTableName);
sb.Append(", ");
sb.Append(parentTableName);
sb.Append(" where ");
sb.Append(childTableName);
sb.Append(".OldFKEY = ");
sb.Append(parentTableName);
sb.Append(".OldUniqueKey");
ExecuteNonQuery(CreateQuery(sb.ToString()));
}
/// <summary>
/// Formats a table name to comply with SQL syntax
/// </summary>
/// <param name="tableName">The table name to format</param>
/// <returns>string representing the formatted table name</returns>
private string FormatTableName(string tableName)
{
string formattedTableName = string.Empty;
if (tableName.Contains("."))
{
string[] parts = tableName.Split('.');
foreach (string part in parts)
{
formattedTableName = formattedTableName + InsertInEscape(part) + ".";
}
formattedTableName = formattedTableName.TrimEnd('.');
}
else
{
formattedTableName = InsertInEscape(tableName);
}
return formattedTableName;
}
/// <summary>
/// Updates the foreign and unique keys of a child table with those of the parent via the original keys that existed prior to an import from an Epi Info 3.5.x project.
/// </summary>
public override void UpdateKeys(string childTableName, string parentTableName)
{
StringBuilder sb = new StringBuilder();
//sb.Append("UPDATE ");
//sb.Append(childTableName);
//sb.Append(" SET FKEY = ");
//sb.Append(parentTableName);
//sb.Append(".UniqueKey from ");
//sb.Append(childTableName);
//sb.Append(", ");
//sb.Append(parentTableName);
//sb.Append(" where ");
//sb.Append(childTableName);
//sb.Append(".OldFKEY = ");
//sb.Append(parentTableName);
//sb.Append(".OldUniqueKey");
//ExecuteNonQuery(CreateQuery(sb.ToString()));
}
#endregion
#region Temporary junk pile
/// <summary>
/// Gets or sets the Database name
/// </summary>
public override string DbName // Implements IDbDriver.DbName
{
get
{
return dbName;
}
set
{
dbName = value;
}
} private string dbName = string.Empty;
/// <summary>
/// Returns the full name of the data source
/// </summary>
public override string FullName //Implements DataSource.FullName
{
get
{
return DataSource + "." + DbName;
}
}
private string connectionString;
/// <summary>
/// Gets the database-specific column data type.
/// </summary>
/// <param name="dataType">An extension of the System.Data.DbType that adds StringLong (Text, Memo) data type that Epi Info commonly uses.</param>
/// <returns>Database-specific column data type.</returns>
public override string GetDbSpecificColumnType(GenericDbColumnType dataType)
{
switch (dataType)
{
case GenericDbColumnType.AnsiString:
case GenericDbColumnType.String:
return "nvarchar";
case GenericDbColumnType.AnsiStringFixedLength:
case GenericDbColumnType.StringFixedLength:
return "nchar";
case GenericDbColumnType.Binary:
return "binary";
case GenericDbColumnType.Boolean:
return "bit";
case GenericDbColumnType.Byte:
return "tinyint";
case GenericDbColumnType.Currency:
return "money";
case GenericDbColumnType.Date:
case GenericDbColumnType.DateTime:
case GenericDbColumnType.Time:
return "datetime";
case GenericDbColumnType.Decimal:
return "decimal";
case GenericDbColumnType.Double:
return "float";
case GenericDbColumnType.Guid:
return "uniqueidentifier";
case GenericDbColumnType.Image:
return "image";
case GenericDbColumnType.Int16:
case GenericDbColumnType.UInt16:
return "smallint";
case GenericDbColumnType.Int32:
case GenericDbColumnType.UInt32:
return "int";
case GenericDbColumnType.Int64:
case GenericDbColumnType.UInt64:
return "bigint";
case GenericDbColumnType.Object:
return "binary";
case GenericDbColumnType.SByte:
return "tinyint";
case GenericDbColumnType.Single:
return "real";
case GenericDbColumnType.StringLong:
return "ntext";
case GenericDbColumnType.VarNumeric:
return "decimal";
case GenericDbColumnType.Xml:
return "xml";
default:
throw new GeneralException("genericDbColumnType is unknown");
// return "nvarchar";
}
}
/// <summary>
/// Connection Description Attribute
/// </summary>
public override string ConnectionDescription
{
get { return "Microsoft SQL Server: " + this.DbName; }
}
/// <summary>
/// Data Source Attribute
/// </summary>
public override string DataSource
{
get
{
SqlConnection sqlconn = GetConnection() as SqlConnection;
if (sqlconn != null)
{
return sqlconn.DataSource;
}
else
{
return null;
}
}
}
/// <summary>
/// Returns the maximum number of columns a table can have.
/// </summary>
public override int TableColumnMax
{
get { return 1020; }
}
/// <summary>
/// Connection String Attribute
/// </summary>
public override string ConnectionString
{
get
{
return connectionString;
}
set
{
this.connectionString = value;
try
{
IDbConnection conn = GetConnection();
this.DbName = conn.Database;
}
catch
{
this.connectionString = null;
}
}
}
/// <summary>
/// Gets an OLE-compatible connection string.
/// This is needed by Epi Map, as ESRI does not understand .NET connection strings.
/// </summary>
public override string OleConnectionString
{
get
{
if (!string.IsNullOrEmpty(connectionString))
{
return "Provider=sqloledb;" + connectionString;
}
else
{
return null;
}
}
}
/// <summary>
/// Change the data type of the column in current database
/// </summary>
/// <param name="tableName">name of the table</param>
/// <param name="columnName">name of the column</param>
/// <param name="columnType">new data type of the column</param>
/// <returns>Boolean</returns>
public override bool AlterColumnType(string tableName, string columnName, string columnType)
{
// dpb todo
return false;
}
/// <summary>
/// Adds a column to the table
/// </summary>
/// <param name="tableName">name of the table</param>
/// <param name="column">The column</param>
/// <returns>Boolean</returns>
public override bool AddColumn(string tableName, TableColumn column)
{
StringBuilder sb = new StringBuilder();
sb.Append("ALTER TABLE ");
sb.Append(tableName);
sb.Append(" ADD ");
sb.Append(column.Name);
sb.Append(" ");
sb.Append(GetDbSpecificColumnType(column.DataType));
if (column.Length != null)
{
sb.Append("(");
sb.Append(column.Length.Value.ToString());
sb.Append(") ");
}
ExecuteNonQuery(CreateQuery(sb.ToString()));
return false;
}
/// <summary>
/// Gets the names of all tables in the database
/// </summary>
/// <returns>Names of all tables in the database</returns>
public override List<string> GetTableNames()
{
List<string> tableNames = new List<string>();
DataTable schemaTable = GetTableSchema();
foreach (DataRow row in schemaTable.Rows)
{
if (row[ColumnNames.SCHEMA_NAME].ToString().ToLowerInvariant().Equals("dbo"))
{
tableNames.Add(row[ColumnNames.SCHEMA_TABLE_NAME].ToString());
}
else
{
tableNames.Add((row[ColumnNames.SCHEMA_NAME].ToString() + "." + row[ColumnNames.SCHEMA_TABLE_NAME].ToString()));
}
}
return tableNames;
}
/// <summary>
/// Gets the SQL version of a generic DbType
/// </summary>
/// <returns>SQL version of the generic DbType</returns>
private SqlDbType CovertToNativeDbType(DbType dbType)
{
switch (dbType)
{
case DbType.AnsiString:
return SqlDbType.VarChar;
case DbType.AnsiStringFixedLength:
return SqlDbType.Char;
case DbType.Binary:
return SqlDbType.Binary;
case DbType.Boolean:
return SqlDbType.Bit;
case DbType.Byte:
return SqlDbType.TinyInt;
case DbType.Currency:
return SqlDbType.Money;
case DbType.Date:
return SqlDbType.DateTime;
case DbType.DateTime:
return SqlDbType.DateTime;
case DbType.DateTime2:
return SqlDbType.DateTime2;
case DbType.DateTimeOffset:
return SqlDbType.DateTimeOffset;
case DbType.Decimal:
return SqlDbType.Decimal;
case DbType.Double:
return SqlDbType.Float;
case DbType.Guid:
return SqlDbType.UniqueIdentifier;
case DbType.Int16:
return SqlDbType.SmallInt;
case DbType.Int32:
return SqlDbType.Int;
case DbType.Int64:
return SqlDbType.BigInt;
case DbType.Object:
return SqlDbType.Binary;
case DbType.SByte:
return SqlDbType.TinyInt;
case DbType.Single:
return SqlDbType.Real;
case DbType.String:
return SqlDbType.NVarChar;
case DbType.StringFixedLength:
return SqlDbType.NChar;
case DbType.Time:
return SqlDbType.DateTime;
case DbType.UInt16:
return SqlDbType.SmallInt;
case DbType.UInt32:
return SqlDbType.Int;
case DbType.UInt64:
return SqlDbType.BigInt;
case DbType.VarNumeric:
return SqlDbType.Decimal;
default:
return SqlDbType.VarChar;
}
}
#endregion
#region Schema and DDL Support
public override string SchemaPrefix
{
get
{
return "DBO.";
}
}
public override bool IsBulkOperation
{
get
{
return this.isBulkOperation;
}
set
{
this.isBulkOperation = value;
}
}
/// <summary>
/// Get Table Count
/// </summary>
/// <returns></returns>
public override int GetTableCount()
{
DataTable dtSchema = GetTableSchema();
return dtSchema.Rows.Count;
}
/// <summary>
/// Creates a table with the given columns
/// </summary>
/// <param name="tableName"></param>
/// <param name="columns">List of columns</param>
public override void CreateTable(string tableName, List<TableColumn> columns)
{
StringBuilder sb = new StringBuilder();
sb.Append("create table ");
// force DBO schema if none specified
if (!tableName.Contains("."))
{
sb.Append(SchemaPrefix);
}
sb.Append(tableName);
sb.Append(" ( ");
foreach (TableColumn column in columns)
{
sb.Append("[" + column.Name + "]");
sb.Append(" ");
if (GetDbSpecificColumnType(column.DataType).Equals("nvarchar") && column.Length.HasValue && column.Length.Value > 8000)
{
sb.Append("Nvarchar(max)");
}
else
{
sb.Append(GetDbSpecificColumnType(column.DataType));
}
if (column.Length != null && column.Length.HasValue && column.Length.Value <= 8000 && column.Length.Value > 0)
{
sb.Append("(");
sb.Append(column.Length.Value.ToString());
sb.Append(") ");
}
if (column.AllowNull)
{
sb.Append(" null ");
}
else
{
sb.Append(" NOT null ");
}
if (column.IsIdentity)
{
sb.Append(" identity ");
}
if (column.IsPrimaryKey)
{
sb.Append(" constraint ");
sb.Append(" PK_");
sb.Append(column.Name);
sb.Append("_");
sb.Append(tableName);
sb.Append(" primary key ");
}
if (!string.IsNullOrEmpty(column.ForeignKeyColumnName) && !string.IsNullOrEmpty(column.ForeignKeyTableName))
{
sb.Append(" references ");
sb.Append(column.ForeignKeyTableName);
sb.Append("(");
sb.Append(column.ForeignKeyColumnName);
sb.Append(") ");
if (column.CascadeDelete)
{
sb.Append(" on delete cascade");
}
}
sb.Append(", ");
}
sb.Remove(sb.Length - 2, 2);
sb.Append(") ");
ExecuteNonQuery(CreateQuery(sb.ToString()));
}
/////// <summary>
///////
/////// </summary>
/////// <returns></returns>
////public bool TestConnection()
////{
//// //create a SQLConnection object to connect to the database, passing the connection
//// //string to the constructor
//// SqlConnection mySqlConnection = new SqlConnection(ConnectionString);
//// try
//// {
//// //open the database connection using the
//// //Open() method of the SqlConnection object
//// mySqlConnection.Open();
//// return true;
//// }
//// // catch(Exception ex)
//// // {
//// // throw new Exception(SharedStrings.CONNECTION_NOT_OPEN + ex.ToString());
//// // }
//// finally
//// {
//// mySqlConnection.Close();
//// }
////}
////public DataTable Select(DbQuery selectQuery)
////{
//// try
//// {
//// #region Input Validation
//// if (selectQuery == null)
//// {
//// throw new ArgumentNullException("SelectQuery");
//// }
//// #endregion
//// DataTable table = new DataTable();
//// return Select(selectQuery, table);
//// }
//// // catch (Exception ex)
//// // {
//// // throw new System.ApplicationException("Error executing query against the database.", ex);
//// // }
//// finally
//// {
//// }
////}
/////// <summary>
/////// Executes a select statement against the database and returns a disconnected data table. NOTE: Use this overload to work with Typed DataSets.
/////// </summary>
/////// <param name="selectQuery">The query to be executed against the database</param>
/////// <param name="table">Table that will contain the result</param>
/////// <returns>A data table object</returns>
////public DataTable Select(DbQuery selectQuery, DataTable table)
////{
//// #region Input Validation
//// if (selectQuery == null)
//// {
//// throw new ArgumentNullException("SelectQuery");
//// }
//// if (table == null)
//// {
//// throw new ArgumentNullException("Table");
//// }
//// #endregion Input Validation
//// try
//// {
//// GetSqlDataAdapter(selectQuery.SqlStatement, selectQuery.Parameters).Fill(table);
//// return table;
//// }
//// catch (Exception ex)
//// {
//// throw new System.ApplicationException("Error executing query against the database.", ex);
//// }
//// finally
//// {
//// }
////}
///// <summary>
///// Returns contents of a table.
///// </summary>
///// <param name="tableName"></param>
///// <param name="sortCriteria">Comma delimited string of column names and asc/DESC order</param>
///// <returns></returns>
//public DataTable GetTableData(string tableName, string columnNames, string sortCriteria)
//{
// try
// {
// if (string.IsNullOrEmpty(columnNames))
// {
// columnNames = StringLiterals.STAR;
// }
// string queryString = "select " + columnNames + " from [" + tableName + "]";
// if (!string.IsNullOrEmpty(sortCriteria))
// {
// queryString += " order by " + sortCriteria;
// }
// DbQuery query = this.CreateQuery(queryString);
// return Select(query);
// }
// finally
// {
// }
//}
///// <summary>
/////
///// </summary>
///// <param name="tableName"></param>
///// <returns></returns>
//public IDataReader GetTableDataReader(string tableName)
//{
// DbQuery query = this.CreateQuery("select * from " + tableName);
// return this.ExecuteReader(query);
//}
///// <summary>
///// Executes a query and returns a stream of rows
///// </summary>
///// <param name="selectQuery">The query to be executed against the database</param>
///// <returns>A data reader object</returns>
//public IDataReader ExecuteReader(DbQuery selectQuery)
//{
// try
// {
// #region Input Validation
// if (selectQuery == null)
// {
// throw new ArgumentNullException("SelectQuery");
// }
// #endregion
// return GetSqlCommand(selectQuery.SqlStatement, selectQuery.Parameters).ExecuteReader();
// // return GetSpecializedCommand(selectQuery).ExecuteReader();
// }
// catch (Exception ex)
// {
// throw new System.ApplicationException("Could not execute reader", ex);
// }
//}
///// <summary>
///// Executes a SQL statement that does not return anything. NOTE: The connection needs to be openned before entering this method.
///// </summary>
///// <param name="nonQueryStatement">The query to be executed against the database</param>
//public int ExecuteNonQuery(DbQuery nonQueryStatement)
//{
// #region Input Validation
// if (nonQueryStatement == null)
// {
// throw new ArgumentNullException("NonQueryStatement");
// }
// #endregion
// IDbCommand command = GetSqlCommand(nonQueryStatement.SqlStatement, nonQueryStatement.Parameters);
// int result;
// bool selfContained = false;
// if (this.sqlConnection.State != ConnectionState.Open)
// {
// OpenConnection();
// selfContained = true;
// }
// try
// {
// result = command.ExecuteNonQuery();
// return result;
// }
// catch (System.Data.SqlClient.SqlException ex)
// {
// throw new SqlException(nonQueryStatement.SqlStatement, ex);
// }
// finally
// {
// if (selfContained)
// {
// CloseConnection();
// }
// }
//}
///// <summary>
///// Executes a SQL non-query within a transaction. NOTE: The connection needs to be openned before entering this method.
///// </summary>
///// <param name="nonQueryStatement">The query to be executed against the database</param>
///// <param name="transaction">The transaction object</param>
//public int ExecuteNonQuery(DbQuery nonQueryStatement, IDbTransaction transaction)
//{
// #region Input Validation
// if (nonQueryStatement == null)
// {
// throw new ArgumentNullException("NonQueryStatement");
// }
// if (transaction == null)
// {
// throw new ArgumentNullException("Transaction");
// }
// #endregion
// int result;
// IDbCommand command = GetSqlCommand(nonQueryStatement.SqlStatement, nonQueryStatement.Parameters);
// command.Transaction = transaction;
// result = command.ExecuteNonQuery();
// return result;
//}
///// <summary>
///// Executes a scalar query against the database
///// </summary>
///// <param name="scalarStatement">The query to be executed against the database</param>
///// <returns></returns>
//public object ExecuteScalar(DbQuery scalarStatement)
//{
// #region Input Validation
// if (scalarStatement == null)
// {
// throw new ArgumentNullException("ScalarStatement");
// }
// #endregion
// object result;
// IDbCommand command = GetSqlCommand(scalarStatement.SqlStatement, scalarStatement.Parameters);
// try
// {
// OpenConnection(command.Connection);
// result = command.ExecuteScalar();
// }
// catch
// {
// throw;
// }
// finally
// {
// CloseConnection(command.Connection);
// }
// return result;
//}
///// <summary>
///// Opens a new connection
///// </summary>
//public void OpenConnection()
//{
// try
// {
// if (this.sqlConnection.State != ConnectionState.Open)
// {
// this.sqlConnection.Open();
// }
// }
// catch (Exception ex)
// {
// throw new System.ApplicationException("Error opening connection.", ex);
// }
//}
///// <summary>
///// Closes the current connection
///// </summary>
//public void CloseConnection()
//{
// try
// {
// IDbConnection conn = this.sqlConnection;
// if (conn.State != ConnectionState.Closed)
// {
// conn.Close();
// }
// }
// catch (Exception ex)
// {
// throw new System.ApplicationException("Error closing connection", ex);
// }
//}
///// <summary>
///// Begins a database transaction
///// </summary>
///// <returns>A specialized transaction object based on the current database engine type</returns>
//public IDbTransaction BeginTransaction()
//{
// return this.sqlConnection.BeginTransaction();
//}
///// <summary>
///// Begins a database transaction
///// </summary>
///// <param name="isolationLevel">The transaction locking behavior for the connection</param>
///// <returns>A specialized transaction object based on the current database engine type</returns>
//public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
//{
// return this.sqlConnection.BeginTransaction(isolationLevel);
//}
/// <summary>
/// Delete a specific table in the database
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <returns>Boolean</returns>
public override bool DeleteTable(string tableName)
{
Query query = this.CreateQuery("Drop Table " + tableName);
//QueryParameter qr = new QueryParameter("@Name", DbType.String, tableName);
return (ExecuteNonQuery(query)>0);
}
/// <summary>
/// Delete a specific column in the database
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <param name="columnName">Name of the column</param>
/// <returns>Boolean</returns>
public override bool DeleteColumn(string tableName, string columnName)
{
Query query = this.CreateQuery("ALTER TABLE " + tableName + " DROP COLUMN " + columnName);
return (ExecuteNonQuery(query) > 0);
}
/// <summary>
/// Gets a value indicating whether or not a specific table exists in the database
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <returns>Boolean</returns>
public override bool TableExists(string tableName)
{
try
{
if (tableName.Contains("."))
{
string[] splits = tableName.Split('.');
tableName = splits[splits.Length - 1];
}
}
catch (Exception ex)
{
//
}
Query query = this.CreateQuery("select * from SysObjects O where ObjectProperty(O.ID,'IsUserTable')=1 and O.Name=@Name");
query.Parameters.Add(new QueryParameter("@Name", DbType.String, tableName));
return (Select(query).Rows.Count > 0);
}
/// <summary>
/// Gets a value indicating whether or not a specific column exists for a table in the database
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <param name="columnName">Name of the column</param>
/// <returns>Boolean</returns>
public override bool ColumnExists(string tableName, string columnName)
{
Query query = this.CreateQuery("select * from SysObjects O inner join SysColumns C on O.ID=C.ID where ObjectProperty(O.ID,'IsUserTable')=1 and O.Name=@TableName and C.Name=@ColumnName");
query.Parameters.Add(new QueryParameter("@TableName", DbType.String, tableName));
query.Parameters.Add(new QueryParameter("@ColumnName", DbType.String, columnName));
// TODO: Make sure this query returns only one row. If more than one columns is returned, it is an indication the query is wrong.
return (Select(query).Rows.Count > 0);
}
/// <summary>
/// Compact the database
/// << may only apply to Access databases >>
/// </summary>
public override bool CompactDatabase()
{
return true;
}
/// <summary>
///
/// </summary>
/// <param name="tableName"></param>
/// <returns></returns>
public override List<string> GetTableColumnNames(string tableName)
{
DataTable table = this.GetSchema("COLUMNS", tableName);
List<string> list = new List<string>();
foreach (DataRow row in table.Rows)
{
list.Add(row["COLUMN_NAME"].ToString());
}
return list;
}
/// <summary>
/// </summary>
/// <param name="tableName"></param>
/// <returns></returns>
public override Dictionary<string, int> GetTableColumnNameTypePairs(string tableName)
{
DataTable table = this.GetSchema("COLUMNS", tableName);
Dictionary<string, int> dictionary = new Dictionary<string, int>();
foreach (DataRow row in table.Rows)
{
dictionary.Add((string)row["COLUMN_NAME"], (int)row["DATA_TYPE"]);
}
return dictionary;
}
/// <summary>
/// Return the number of colums in the specified table
/// </summary>
/// <remarks>
/// Originaly intended to be used to keep view tables from getting to wide.
/// </remarks>
/// <param name="tableName"></param>
/// <returns>the number of columns in the </returns>
public override int GetTableColumnCount(string tableName)
{
DataTable table = this.GetSchema("COLUMNS", tableName);
return table.Rows.Count;
}
/// <summary>
/// Gets the selected schema of the table specified in tableName
/// </summary>
/// <param name="collectionName"></param>
/// <param name="tableName"></param>
/// <returns>DataTable with schema information</returns>
///
private DataTable GetSchema(string collectionName, string tableName)
{
SqlConnection conn = this.GetNativeConnection();
try
{
OpenConnection(conn);
return conn.GetSchema(collectionName, new string[] { null, null, tableName });
}
finally
{
CloseConnection(conn);
}
}
/// <summary>
/// Gets the selected schema of the table specified in tableName
/// </summary>
/// <param name="collectionName"></param>
/// <returns>DataTable with schema information</returns>
private DataTable GetSchema(string collectionName)
{
SqlConnection conn = this.GetNativeConnection();
try
{
OpenConnection(conn);
return conn.GetSchema(collectionName, new string[] { null, null, null });
}
finally
{
CloseConnection(conn);
}
}
/// <summary>
/// Gets table schema information
/// </summary>
/// <returns>DataTable with schema information</returns>
public override DataSets.TableSchema.TablesDataTable GetTableSchema()
{
SqlConnection conn = this.GetNativeConnection();
try
{
OpenConnection(conn);
DataTable table = conn.GetSchema("Tables", new string[0]);
DataSets.TableSchema tableSchema = new Epi.DataSets.TableSchema();
tableSchema.Merge(table);
return tableSchema._Tables;
}
finally
{
CloseConnection(conn);
}
}
// dcs0 previous function relied upon OLEDb to get schema from SQL server
// coming up with the appropriate connection string proved problematic
// this is the Micro$oft recommended solution
/// <summary>
/// Gets Primary_Keys schema information about a SQL table
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <returns>DataTable with schema information</returns>
public override DataSets.TableKeysSchema.Primary_KeysDataTable GetTableKeysSchema(string tableName)
{
DataSets.TableKeysSchema schema = new Epi.DataSets.TableKeysSchema();
SqlConnection conn = this.GetNativeConnection();
bool alreadyOpen = (conn.State != ConnectionState.Closed);
try
{
if (!alreadyOpen)
{
OpenConnection(conn);
}
string sql = "select KU.TABLE_CATALOG, KU.TABLE_SCHEMA, KU.TABLE_NAME, COLUMN_NAME, " +
"0 as COLUMN_PROPID, ORDINAL_POSITION as ORDINAL, KU.CONSTRAINT_NAME as PK_NAME " +
"from INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC " +
"inner join " +
"INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU " +
"on TC.CONSTRAINT_TYPE = 'primary key' and " +
"TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME " +
"where KU.TABLE_NAME = '" + tableName +
"' order by KU.ORDINAL_POSITION;";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.Fill(schema.Primary_Keys);
da.Dispose();
}
catch (Exception ex)
{
throw new GeneralException("Unable to obtain primary keys schema.", ex);
}
finally
{
if (!alreadyOpen && conn.State != ConnectionState.Closed)
{
CloseConnection(conn);
}
}
return schema.Primary_Keys;
}
///// <summary>
///// Gets Primary_Keys schema information about a SQL table
///// </summary>
///// <param name="tableName">Name of the table</param>
///// <returns>DataTable with schema information</returns>
//public override DataSets.TableKeysSchema.Primary_KeysDataTable GetTableKeysSchema(string tableName)
//{
// OleDbConnection conn = new OleDbConnection("Provider=SQLOleDb;" + connectionString);
// try
// {
// OpenConnection(conn);
// DataTable t = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new object[] { null, null, tableName });
// DataSets.TableKeysSchema schema = new Epi.DataSets.TableKeysSchema();
// schema.Merge(t);
// return schema.Primary_Keys;
// }
// finally
// {
// CloseConnection(conn);
// }
//}
/// <summary>
/// Gets column schema information about an OLE table
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <returns>DataTable with schema information</returns>
public override DataSets.TableColumnSchema.ColumnsDataTable GetTableColumnSchema(string tableName)
{
try
{
DataTable table = this.GetSchema("Columns", tableName);
// IS_NULLABLE and DATA_TYPE are different data types for non OleDb DataTables.
DataSets.TableColumnSchema tableColumnSchema = new Epi.DataSets.TableColumnSchema();
tableColumnSchema.Merge(table, false, MissingSchemaAction.Ignore);
return tableColumnSchema.Columns;
}
catch (Exception ex)
{
throw new GeneralException("Could not get table column schema for " + tableName + ".", ex);
}
}
/// <summary>
/// Gets column schema information about an OLE table
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <returns>DataTable with schema information</returns>
public override DataSets.ANSI.TableColumnSchema.ColumnsDataTable GetTableColumnSchemaANSI(string tableName)
{
try
{
DataTable table = this.GetSchema("Columns", tableName);
// IS_NULLABLE and DATA_TYPE are different data types for non OleDb DataTables.
DataSets.ANSI.TableColumnSchema tableColumnSchema = new Epi.DataSets.ANSI.TableColumnSchema();
tableColumnSchema.Merge(table, false, MissingSchemaAction.Ignore);
return tableColumnSchema.Columns;
}
catch (Exception ex)
{
throw new GeneralException("Could not get table column schema for " + tableName + ".", ex);
}
}
/// <summary>
/// Get ColumnNames by table name
/// </summary>
/// <param name="tableName">Table Name</param>
/// <returns>DataView</returns>
public override DataView GetTextColumnNames(string tableName)
{
return new DataView(this.GetSchema("Columns", tableName));
// throw new System.ApplicationException("Table column schema can't be retrieved from SQL databases.");
}
/// <summary>
/// Create SQL query object
/// </summary>
/// <param name="sqlStatement"></param>
/// <returns></returns>
public override Query CreateQuery(string sqlStatement)
{
return new SqlQuery(sqlStatement);
}
#endregion
#region Generic IDbTransaction Methods (mirror Epi.Data.Office/Epi.Data.SqlServer)
/// <summary>
/// Tests database connectivity using current ConnnectionString
/// </summary>
/// <returns></returns>
public override bool TestConnection()
{
try
{
return TestConnection(connectionString);
}
catch (Exception ex)
{
throw new GeneralException("Could not connect to data source.", ex);
}
}
/// <summary>
/// Tests database connectivity using supplied connection string
/// </summary>
/// <param name="connectionString"></param>
/// <returns></returns>
protected bool TestConnection(string connectionString)
{
IDbConnection testConnection = GetConnection(connectionString);
try
{
OpenConnection(testConnection);
}
finally
{
CloseConnection(testConnection);
}
return true;
}
/// <summary>
/// Gets an connection instance based on current ConnectionString value
/// </summary>
/// <returns>Connection instance</returns>
public override IDbConnection GetConnection()
{
return GetNativeConnection(connectionString);
}
/// <summary>
/// Gets a connection instance from supplied connection string
/// </summary>
/// <returns>Connection instance</returns>
protected virtual IDbConnection GetConnection(string connectionString)
{
return GetNativeConnection(connectionString);
}
/// <summary>
/// Gets a new command using an existing transaction
/// </summary>
/// <param name="sqlStatement">The query to be executed against the database</param>
/// <param name="transaction"></param>
/// <param name="parameters">parameters">Parameters for the query to be executed</param>
/// <returns>An OleDb command object</returns>
protected virtual IDbCommand GetCommand(string sqlStatement, IDbTransaction transaction, List<QueryParameter> parameters)
{
#region Input Validation
if (string.IsNullOrEmpty(sqlStatement))
{
throw new ArgumentNullException("sqlStatement");
}
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
#endregion
IDbCommand command = this.GetNativeCommand(transaction);
command.CommandText = sqlStatement;
foreach (QueryParameter parameter in parameters)
{
command.Parameters.Add(this.ConvertToNativeParameter(parameter));
}
return command;
}
/// <summary>
/// Gets a new command using an existing connection
/// </summary>
/// <param name="sqlStatement">The query to be executed against the database</param>
/// <param name="connection"></param>
/// <param name="parameters">Parameters for the query to be executed</param>
/// <returns></returns>
protected virtual IDbCommand GetCommand(string sqlStatement, IDbConnection connection, List<QueryParameter> parameters)
{
#region Input Validation
if (string.IsNullOrEmpty(sqlStatement))
{
throw new ArgumentNullException("sqlStatement");
}
if (parameters == null)
{
throw new ArgumentNullException("parameters");
}
#endregion
IDbCommand command = connection.CreateCommand();
command.CommandText = sqlStatement;
foreach (QueryParameter parameter in parameters)
{
command.Parameters.Add(this.ConvertToNativeParameter(parameter));
}
return command;
}
/// <summary>
/// Opens specific connection if state is not already opened
/// </summary>
/// <param name="conn"></param>
protected void OpenConnection(IDbConnection conn)
{
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
}
catch (Exception ex)
{
throw new System.ApplicationException("Error opening connection.", ex);
}
}
/// <summary>
/// Close a specific connection if state is not already closed
/// </summary>
/// <param name="conn"></param>
protected void CloseConnection(IDbConnection conn)
{
try
{
if (conn != null)
{
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
}
}
catch (Exception ex)
{
conn = null;
throw new System.ApplicationException("Error closing connection.", ex);
}
}
/// <summary>
/// Closes a database transaction and associated connection
/// </summary>
public override void CloseTransaction(IDbTransaction transaction)
{
if (transaction == null)
{
throw new ArgumentNullException("Transaction cannot be null.", "transaction");
}
CloseConnection(transaction.Connection);
}
/// <summary>
/// Opens a database connection and begins a new transaction
/// </summary>
/// <returns>A specialized transaction object based on the current database engine type</returns>
public override IDbTransaction OpenTransaction()
{
IDbConnection connection = GetConnection();
OpenConnection(connection);
return connection.BeginTransaction();
}
/// <summary>
/// Opens a database connection and begins a new transaction
/// </summary>
/// <param name="isolationLevel">The transaction locking behavior for the connection</param>
/// <returns>A specialized transaction object based on the current database engine type</returns>
public override IDbTransaction OpenTransaction(IsolationLevel isolationLevel)
{
IDbConnection connection = GetConnection();
OpenConnection(connection);
return connection.BeginTransaction(isolationLevel);
}
/// <summary>
///
/// </summary>
/// <param name="tableName"></param>
/// <returns></returns>
public override IDataReader GetTableDataReader(string tableName)
{
Query query = this.CreateQuery("select * from " + FormatTableName(tableName));
return this.ExecuteReader(query);
}
public override IDataReader GetTableDataReader(string tableName, string sortColumnName)
{
Query query = this.CreateQuery("select * from " + tableName + " ORDER BY " + sortColumnName);
return this.ExecuteReader(query);
}
/// <summary>
/// Creates a new connection and executes a select query
/// </summary>
/// <param name="selectQuery"></param>
/// <returns>Result set</returns>
public override DataTable Select(Query selectQuery)
{
#region Input Validation
if (selectQuery == null)
{
throw new ArgumentNullException("selectQuery");
}
#endregion
DataTable table = new DataTable();
return Select(selectQuery, table);
}
/// <summary>
/// Returns contents of a table.
/// </summary>
/// <param name="tableName"></param>
/// <param name="columnNames"></param>
/// <param name="sortCriteria">Comma delimited string of column names and asc/DESC order</param>
/// <returns></returns>
public override DataTable GetTableData(string tableName, string columnNames, string sortCriteria)
{
try
{
if (string.IsNullOrEmpty(columnNames))
{
columnNames = Epi.StringLiterals.STAR;
}
string queryString = "select " + columnNames + " from " + FormatTableName(tableName);
if (!string.IsNullOrEmpty(sortCriteria))
{
queryString += " order by " + sortCriteria;
}
Query query = this.CreateQuery(queryString);
return Select(query);
}
finally
{
}
}
/// <summary>
/// Returns contents of a table with only the top two rows.
/// </summary>
/// <param name="tableName">The name of the table to query</param>
/// <returns>DataTable</returns>
public override DataTable GetTopTwoTable(string tableName)
{
try
{
string queryString = "select top 2 * from " + FormatTableName(tableName);
Query query = this.CreateQuery(queryString);
return Select(query);
}
finally
{
}
}
/// <summary>
/// Executes a query and returns a stream of rows
/// </summary>
/// <param name="selectQuery">The query to be executed against the database</param>
/// <returns>A data reader object</returns>
public override IDataReader ExecuteReader(Query selectQuery)
{
#region Input Validation
if (selectQuery == null)
{
throw new ArgumentNullException("SelectQuery");
}
#endregion
return ExecuteReader(selectQuery, CommandBehavior.Default);
}
/// <summary>
/// Executes a query and returns a stream of rows
/// </summary>
/// <param name="selectQuery">The query to be executed against the database</param>
/// <returns>A data reader object</returns>
public override IDataReader ExecuteReader(Query selectQuery, CommandBehavior commandBehavior)
{
#region Input Validation
if (selectQuery == null)
{
throw new ArgumentNullException("SelectQuery");
}
#endregion
IDbConnection connection = GetConnection();
try
{
OpenConnection(connection);
IDbCommand command = GetCommand(selectQuery.SqlStatement, connection, selectQuery.Parameters);
return command.ExecuteReader(commandBehavior);
}
catch (Exception ex)
{
throw new System.ApplicationException("Could not execute reader", ex);
}
finally
{
}
}
/// <summary>
/// Executes a scalar query against the database using an existing transaction
/// </summary>
/// <param name="query">The query to be executed against the database</param>
/// <param name="transaction">Null is allowed</param>
/// <returns></returns>
public override object ExecuteScalar(Query query, IDbTransaction transaction)
{
#region Input Validation
if (query == null)
{
throw new ArgumentNullException("query");
}
if (transaction == null)
{
throw new ArgumentNullException("transaction");
}
#endregion
object result;
IDbCommand command = GetCommand(query.SqlStatement, transaction, query.Parameters);
try
{
// do not open connection, we are inside a transaction
result = command.ExecuteScalar();
}
finally
{
// do not close connection, we are inside a transaction
}
return result;
}
/// <summary>
/// Executes a scalar query against the database
/// </summary>
/// <param name="query">The query to be executed against the database</param>
/// <returns></returns>
public override object ExecuteScalar(Query query)
{
#region Input Validation
if (query == null)
{
throw new ArgumentNullException("query");
}
#endregion
object result;
IDbConnection conn = GetConnection();
IDbCommand command = GetCommand(query.SqlStatement, conn, query.Parameters);
try
{
OpenConnection(conn);
result = command.ExecuteScalar();
}
finally
{
CloseConnection(conn);
}
return result;
}
/// <summary>
/// Executes a SQL statement and returns total records affected.
/// </summary>
/// <param name="query">The query to be executed against the database</param>
public override int ExecuteNonQuery(Query query)
{
#region Input Validation
if (query == null)
{
throw new ArgumentNullException("query");
}
#endregion
//Logger.Log(query);
IDbConnection conn = this.GetConnection();
IDbCommand command = GetCommand(query.SqlStatement, conn, query.Parameters);
try
{
OpenConnection(conn);
return command.ExecuteNonQuery();
}
finally
{
CloseConnection(conn);
}
}
/// <summary>
/// Executes a transacted SQL statement and returns total records affected.
/// </summary>
/// <param name="query"></param>
/// <param name="transaction"></param>
/// <returns>returns total records affected.</returns>
public override int ExecuteNonQuery(Query query, IDbTransaction transaction)
{
#region Input Validation
if (query == null)
{
throw new ArgumentNullException("query");
}
if (transaction == null)
{
throw new ArgumentNullException("transaction");
}
#endregion
//Logger.Log(query);
IDbCommand command = GetCommand(query.SqlStatement, transaction, query.Parameters);
command.CommandTimeout = 1500;
//int result;
try
{
// do not try to open connection, we are inside a transaction
return command.ExecuteNonQuery();
}
finally
{
// do not close connection, we are inside a transaction
}
}
///// <summary>
///// Disposes the object
///// </summary>
//public void Dispose()
//{
//}
#endregion
#region Private Methods
#endregion // Private Methods
/// <summary>
/// Determines the level of rights the user has on the SQL database
/// </summary>
public override ProjectPermissions GetPermissions()
{
ProjectPermissions permissions = new ProjectPermissions();
permissions.FullPermissions = false;
Query query = this.CreateQuery("SELECT HAS_PERMS_BY_NAME(QUOTENAME(SCHEMA_NAME(schema_id)) " +
"+ '.' + QUOTENAME(name), 'OBJECT', 'SELECT') AS have_select, name FROM sys.tables");
DataTable selectDt = Select(query);
DataTable permissionsTable = new DataTable();
permissionsTable.Columns.Add("name", typeof(string)); // table name
permissionsTable.Columns.Add("can_select", typeof(bool));
permissionsTable.Columns.Add("can_insert", typeof(bool));
permissionsTable.Columns.Add("can_update", typeof(bool));
permissionsTable.Columns.Add("can_delete", typeof(bool));
permissionsTable.Columns["name"].Unique = true;
DataColumn[] primaryKeyColumns = new DataColumn[1];
primaryKeyColumns[0] = permissionsTable.Columns["name"];
permissionsTable.PrimaryKey = primaryKeyColumns;
List<string> tableNames = new List<string>();
foreach (DataRow row in selectDt.Rows)
{
foreach (DataColumn dc in selectDt.Columns)
{
System.Diagnostics.Debug.Print(dc.ColumnName + " = " + row[dc.ColumnName].ToString());
}
string tableName = row["name"].ToString();
tableNames.Add(tableName);
permissionsTable.Rows.Add(tableName);
System.Diagnostics.Debug.Print("");
}
selectDt = new DataTable();
DataTable insertDt = new DataTable();
DataTable updateDt = new DataTable();
DataTable deleteDt = new DataTable();
foreach (string tableName in tableNames)
{
query = this.CreateQuery("SELECT HAS_PERMS_BY_NAME('" + tableName + "', 'OBJECT', 'INSERT');");
insertDt = Select(query);
string value = insertDt.Rows[0][0].ToString();
DataRow dr = permissionsTable.Rows.Find(tableName);
if (value == "1")
{
permissions.TablesWithInsertPermissions.Add(tableName);
}
#region Debug
foreach (DataRow row in insertDt.Rows)
{
foreach (DataColumn dc in insertDt.Columns)
{
System.Diagnostics.Debug.Print(dc.ColumnName + " = " + row[dc.ColumnName].ToString());
}
}
#endregion // Debug
}
foreach (string tableName in tableNames)
{
query = this.CreateQuery("SELECT HAS_PERMS_BY_NAME('" + tableName + "', 'OBJECT', 'UPDATE');");
updateDt = Select(query);
string value = updateDt.Rows[0][0].ToString();
DataRow dr = permissionsTable.Rows.Find(tableName);
if (value == "1")
{
permissions.TablesWithUpdatePermissions.Add(tableName);
}
#region Debug
foreach (DataRow row in updateDt.Rows)
{
foreach (DataColumn dc in updateDt.Columns)
{
System.Diagnostics.Debug.Print(dc.ColumnName + " = " + row[dc.ColumnName].ToString());
}
}
#endregion // Debug
}
foreach (string tableName in tableNames)
{
query = this.CreateQuery("SELECT HAS_PERMS_BY_NAME('" + tableName + "', 'OBJECT', 'DELETE');");
deleteDt = Select(query);
string value = deleteDt.Rows[0][0].ToString();
DataRow dr = permissionsTable.Rows.Find(tableName);
if (value == "1")
{
permissions.TablesWithDeletePermissions.Add(tableName);
}
#region Debug
foreach (DataRow row in deleteDt.Rows)
{
foreach (DataColumn dc in deleteDt.Columns)
{
System.Diagnostics.Debug.Print(dc.ColumnName + " = " + row[dc.ColumnName].ToString());
}
}
#endregion // Debug
}
foreach (string tableName in tableNames)
{
query = this.CreateQuery("SELECT HAS_PERMS_BY_NAME('" + tableName + "', 'OBJECT', 'SELECT');");
selectDt = Select(query);
string value = selectDt.Rows[0][0].ToString();
DataRow dr = permissionsTable.Rows.Find(tableName);
if (value == "1")
{
permissions.TablesWithSelectPermissions.Add(tableName);
}
#region Debug
foreach (DataRow row in selectDt.Rows)
{
foreach (DataColumn dc in selectDt.Columns)
{
System.Diagnostics.Debug.Print(dc.ColumnName + " = " + row[dc.ColumnName].ToString());
}
}
#endregion // Debug
}
List<string> metaTableNames = new List<string>();
List<string> formDataTableNames = new List<string>();
foreach (string tableName in tableNames)
{
if (tableName.StartsWith("meta"))
{
metaTableNames.Add(tableName);
}
}
permissions.CanDeleteRowsInMetaTables = true;
permissions.CanInsertRowsInMetaTables = true;
permissions.CanSelectRowsInMetaTables = true;
permissions.CanUpdateRowsInMetaTables = true;
foreach (string metaTableName in metaTableNames)
{
DataRow row = permissionsTable.Rows.Find(metaTableName);
if (permissions.CanDeleteRowsInMetaTables)
{
permissions.CanDeleteRowsInMetaTables = permissions.TablesWithDeletePermissions.Contains(metaTableName);
}
if (permissions.CanInsertRowsInMetaTables)
{
permissions.CanInsertRowsInMetaTables = permissions.TablesWithInsertPermissions.Contains(metaTableName);
}
if (permissions.CanSelectRowsInMetaTables)
{
permissions.CanSelectRowsInMetaTables = permissions.TablesWithSelectPermissions.Contains(metaTableName);
}
if (permissions.CanUpdateRowsInMetaTables)
{
permissions.CanUpdateRowsInMetaTables = permissions.TablesWithUpdatePermissions.Contains(metaTableName);
}
}
return permissions;
}
/// <summary>
/// Gets the contents of a table
/// </summary>
/// <param name="tableName">Name of the table</param>
/// <returns>Datatable containing the table data</returns>
public override DataTable GetTableData(string tableName)
{
return GetTableData(tableName, string.Empty, string.Empty);
}
/// <summary>
/// Returns contents of a table.
/// </summary>
/// <param name="tableName"></param>
/// <param name="columnNames">Comma delimited string of column names and asc/DESC order</param>
/// <returns></returns>
public override DataTable GetTableData(string tableName, string columnNames)
{
return GetTableData(tableName, columnNames, string.Empty);
}
internal List<string> GetDatabaseNameList()
{
List<string> databases = new List<string>();
SqlConnection sqlconn = new SqlConnection(ConnectionString);
try
{
OpenConnection(sqlconn);
SqlCommand cmd = sqlconn.CreateCommand();
cmd.CommandText = "sp_databases";
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 1500;
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
databases.Add(reader.GetString(0));
}
}
finally
{
CloseConnection(sqlconn);
}
return databases;
}
/// <summary>
/// Builds a connection string using default parameters given a database name
/// </summary>
/// <remarks>In the case of SQL Server, it is not possible to build a default connection string using just a database name. You also need to provide a default server.</remarks>
/// <param name="databaseName">Name of the database</param>
/// <returns>A connection string</returns>
public static string BuildDefaultConnectionString(string databaseName)
{
return string.Empty;
}
/// <summary>
///
/// </summary>
/// <param name="project"></param>
/// <returns></returns>
public override DataTable GetCodeTableNamesForProject(Project project)
{
List<string> tables = new List<string>(); //dpb//project.GetDataTableList();
DataSets.TableSchema.TablesDataTable codeTables = project.GetCodeTableList();
foreach (DataSets.TableSchema.TablesRow row in codeTables)
{
tables.Add(row.TABLE_NAME);
}
DataView dataView = codeTables.DefaultView;
return codeTables;
}
/// <summary>
///
/// </summary>
/// <param name="db"></param>
/// <returns></returns>
public override Epi.DataSets.TableSchema.TablesDataTable GetCodeTableList(IDbDriver db)
{
Epi.DataSets.TableSchema.TablesDataTable table = db.GetTableSchema();
//remove all databases that do not start with "code"
DataRow[] rowsFiltered = table.Select("TABLE_NAME not like 'code%'");
foreach (DataRow rowFiltered in rowsFiltered)
{
table.Rows.Remove(rowFiltered);
}
return table;
}
/// <summary>
/// Identity MS SQL Server Database
/// </summary>
/// <returns>"SQLSERVER"</returns>
public override string IdentifyDatabase()
{
return "SQLSERVER";
}
/// <summary>
/// Inserts the string in escape characters. [] for SQL server and `` for MySQL etc.
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public override string InsertInEscape(string str)
{
string newString = string.Empty;
if (!str.StartsWith(StringLiterals.LEFT_SQUARE_BRACKET))
{
newString = StringLiterals.LEFT_SQUARE_BRACKET;
}
newString += str;
if (!str.EndsWith(StringLiterals.RIGHT_SQUARE_BRACKET))
{
newString += StringLiterals.RIGHT_SQUARE_BRACKET;
}
return newString;
}
/// <summary>
/// Provides a database frieldly string representation of date.
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public override string FormatTime(DateTime dt) // TODO: Revisit it.
{
return Util.InsertInSingleQuotes(dt.ToString());
}
/// <summary>
/// Convert Query to String format for EnterWebService
/// </summary>
/// <param name="pValue"></param>
/// <returns>Sql query in string form</returns>
private string ConvertQueryToString(Query pValue)
{
string result = pValue.SqlStatement;
foreach (QueryParameter parameter in pValue.Parameters)
{
switch (parameter.DbType)
{
case DbType.Currency:
case DbType.Byte:
case DbType.Decimal:
case DbType.Double:
case DbType.Int16:
case DbType.Int32:
case DbType.Int64:
case DbType.SByte:
case DbType.UInt16:
case DbType.UInt32:
case DbType.UInt64:
//case DbType.Boolean:
result = Regex.Replace(result, parameter.ParameterName, parameter.Value.ToString(), RegexOptions.IgnoreCase);
break;
default:
result = Regex.Replace(result, parameter.ParameterName, "'" + parameter.Value.ToString() + "'", RegexOptions.IgnoreCase);
break;
}
}
return result;
}
public override string SyntaxTrue
{
get { return "'TRUE'"; }
}
public override string SyntaxFalse
{
get { return "'FALSE'"; }
}
public override bool InsertBulkRows(string pSelectSQL, System.Data.Common.DbDataReader pDataReader, SetGadgetStatusHandler pStatusDelegate = null, CheckForCancellationHandler pCancellationDelegate = null)
{
bool result = false;
System.Data.SqlClient.SqlConnection Conn = null;
System.Data.SqlClient.SqlDataAdapter Adapter = null;
System.Data.SqlClient.SqlCommandBuilder builderSQL = null;
System.Data.Common.DbCommand cmdSqL = null;
DataSet dataSet = new DataSet();
DataTable Temp = new DataTable();
try
{
StringBuilder InsertSQL;
StringBuilder ValueSQL;
Conn = new System.Data.SqlClient.SqlConnection(ConnectionString);
Adapter = new System.Data.SqlClient.SqlDataAdapter(pSelectSQL, Conn);
Adapter.FillSchema(dataSet, SchemaType.Source);
builderSQL = new System.Data.SqlClient.SqlCommandBuilder(Adapter);
Conn.Open();
cmdSqL = Conn.CreateCommand();
cmdSqL.CommandTimeout = 1500;
int rowCount = 0;
int skippedRows = 0;
int totalRows = 0;
if (pStatusDelegate != null && dataSet.Tables.Count > 0)
{
totalRows = dataSet.Tables[0].Rows.Count;
}
while (pDataReader.Read())
{
cmdSqL = builderSQL.GetInsertCommand(true);
InsertSQL = new StringBuilder();
ValueSQL = new StringBuilder();
InsertSQL.Append("Insert Into ");
InsertSQL.Append(pSelectSQL.Replace("Select * From ", ""));
InsertSQL.Append(" (");
ValueSQL.Append(" values (");
List<System.Data.SqlClient.SqlParameter> ParameterList = new List<SqlParameter>();
foreach (System.Data.SqlClient.SqlParameter param in cmdSqL.Parameters)
{
string FieldName = param.SourceColumn;
InsertSQL.Append("[");
InsertSQL.Append(FieldName);
InsertSQL.Append("],");
ValueSQL.Append(param.ParameterName);
ValueSQL.Append(",");
param.Value = pDataReader[FieldName];
ParameterList.Add(param);
}
InsertSQL.Length = InsertSQL.Length - 1;
ValueSQL.Length = ValueSQL.Length - 1;
InsertSQL.Append(")");
ValueSQL.Append(")");
InsertSQL.Append(ValueSQL);
cmdSqL = null;
cmdSqL = Conn.CreateCommand();
cmdSqL.CommandText = InsertSQL.ToString();
foreach (System.Data.SqlClient.SqlParameter param in ParameterList)
{
DbParameter p2 = cmdSqL.CreateParameter();
p2.DbType = param.DbType;
p2.Value = pDataReader[param.SourceColumn];
p2.ParameterName = param.ParameterName;
cmdSqL.Parameters.Add(p2);
}
try
{
cmdSqL.ExecuteNonQuery();
rowCount++;
}
catch (Exception ex)
{
skippedRows++;
continue;
}
if (pStatusDelegate != null)
{
pStatusDelegate.Invoke(string.Format(SharedStrings.DASHBOARD_EXPORT_PROGRESS, rowCount.ToString(), totalRows.ToString()), (double)rowCount);
}
if (pCancellationDelegate != null && pCancellationDelegate.Invoke())
{
pStatusDelegate.Invoke(string.Format(SharedStrings.DASHBOARD_EXPORT_CANCELLED, rowCount.ToString()));
break;
}
}
if (pStatusDelegate != null)
{
pStatusDelegate.Invoke(string.Format(SharedStrings.DASHBOARD_EXPORT_SUCCESS, rowCount.ToString()));
}
}
catch (System.Exception ex)
{
Logger.Log(DateTime.Now + ": " + ex.Message);
}
finally
{
if (Conn != null)
{
Conn.Close();
}
}
result = true;
return result;
}
public override bool Insert_1_Row(string pSelectSQL, System.Data.Common.DbDataReader pDataReader)
{
bool result = false;
System.Data.SqlClient.SqlConnection Conn = null;
System.Data.SqlClient.SqlDataAdapter Adapter = null;
System.Data.SqlClient.SqlCommandBuilder builderSQL = null;
System.Data.Common.DbCommand cmdSqL = null;
DataSet dataSet = new DataSet();
DataTable Temp = new DataTable();
try
{
StringBuilder InsertSQL = new StringBuilder();
StringBuilder ValueSQL = new StringBuilder();
Conn = new System.Data.SqlClient.SqlConnection(ConnectionString);
Adapter = new System.Data.SqlClient.SqlDataAdapter(pSelectSQL, Conn);
//Adapter.FillSchema(dataSet, SchemaType.Source, pDestinationTableName);
Adapter.FillSchema(dataSet, SchemaType.Source);
builderSQL = new System.Data.SqlClient.SqlCommandBuilder(Adapter);
Conn.Open();
cmdSqL = Conn.CreateCommand();
cmdSqL = builderSQL.GetInsertCommand(true);
cmdSqL.CommandTimeout = 1500;
InsertSQL.Append("Insert Into ");
InsertSQL.Append(pSelectSQL.Replace("Select * From ", ""));
InsertSQL.Append(" (");
ValueSQL.Append(" values (");
List<System.Data.SqlClient.SqlParameter> ParameterList = new List<SqlParameter>();
foreach (System.Data.SqlClient.SqlParameter param in cmdSqL.Parameters)
{
//string FieldName = param.ParameterName.TrimStart(new char[] { '@' });
string FieldName = param.SourceColumn;
InsertSQL.Append("[");
InsertSQL.Append(FieldName);
InsertSQL.Append("],");
//ValueSQL.Append("@");
ValueSQL.Append(param.ParameterName);
ValueSQL.Append(",");
param.Value = pDataReader[FieldName];
ParameterList.Add(param);
/*
if (pDataReader[FieldName] == DBNull.Value)
{
ValueSQL.Append("null");
}
else
{
switch (pDataReader[FieldName].GetType().ToString())
{
case "System.Boolean":
if (Convert.ToBoolean(pDataReader[FieldName]) == false)
{
ValueSQL.Append("0");
}
else
{
ValueSQL.Append("1");
}
break;
case "System.Int32":
case "System.Decimal":
case "System.Double":
case "System.Single":
case "System.Byte":
ValueSQL.Append(pDataReader[FieldName].ToString().Replace("'", "''"));
break;
default:
ValueSQL.Append("'");
ValueSQL.Append(pDataReader[FieldName].ToString().Replace("'", "''"));
ValueSQL.Append("'");
break;
}
}*/
//ValueSQL.Append(",");
}
InsertSQL.Length = InsertSQL.Length - 1;
ValueSQL.Length = ValueSQL.Length - 1;
InsertSQL.Append(")");
ValueSQL.Append(")");
InsertSQL.Append(ValueSQL);
builderSQL = null;
cmdSqL = null;
cmdSqL = Conn.CreateCommand();
cmdSqL.CommandText = InsertSQL.ToString();
foreach (System.Data.SqlClient.SqlParameter param in ParameterList)
{
DbParameter p2 = cmdSqL.CreateParameter();
p2.DbType = param.DbType;
p2.Value = pDataReader[param.SourceColumn];
p2.ParameterName = param.ParameterName;
cmdSqL.Parameters.Add(p2);
}
//DBReadExecute.ExecuteSQL(pFileString, InsertSQL.ToString());
cmdSqL.ExecuteNonQuery();
}
catch (System.Exception ex)
{
Logger.Log(DateTime.Now + ": " + ex.Message);
}
finally
{
if (Conn != null)
{
Conn.Close();
}
}
result = true;
return result;
}
public override bool Update_1_Row(string pSelectSQL, string pKeyString, DbDataReader pDataReader)
{
bool result = false;
System.Data.SqlClient.SqlConnection Conn = null;
System.Data.SqlClient.SqlDataAdapter Adapter = null;
System.Data.SqlClient.SqlCommandBuilder builderSQL = null;
System.Data.SqlClient.SqlCommand cmdSqL = null;
DataSet dataSet = new DataSet();
DataTable Temp = new DataTable();
try
{
StringBuilder UpdateSQL = new StringBuilder();
Conn = new System.Data.SqlClient.SqlConnection(ConnectionString);
Adapter = new System.Data.SqlClient.SqlDataAdapter(pSelectSQL, Conn);
//Adapter.FillSchema(dataSet, SchemaType.Source, pDestinationTableName);
Adapter.FillSchema(dataSet, SchemaType.Source);
builderSQL = new System.Data.SqlClient.SqlCommandBuilder(Adapter);
Conn.Open();
cmdSqL = Conn.CreateCommand();
cmdSqL = builderSQL.GetInsertCommand();
cmdSqL.CommandTimeout = 1500;
UpdateSQL.Append("Update ");
UpdateSQL.Append(pSelectSQL.Replace("Select * From ", ""));
UpdateSQL.Append(" Set ");
foreach (System.Data.SqlClient.SqlParameter param in cmdSqL.Parameters)
{
//string FieldName = param.ParameterName.TrimStart(new char[] { '@' });
string FieldName = param.SourceColumn;
if (pDataReader[FieldName] != DBNull.Value && !string.IsNullOrEmpty(pDataReader[FieldName].ToString()))
{
UpdateSQL.Append("[");
UpdateSQL.Append(FieldName);
UpdateSQL.Append("]=");
switch (pDataReader[FieldName].GetType().ToString())
{
case "System.Boolean":
if (Convert.ToBoolean(pDataReader[FieldName]) == false)
{
UpdateSQL.Append("0");
}
else
{
UpdateSQL.Append("1");
}
break;
case "System.Int32":
case "System.Decimal":
case "System.Double":
case "System.Single":
case "System.Byte":
UpdateSQL.Append(pDataReader[FieldName].ToString().Replace("'", "''"));
break;
default:
UpdateSQL.Append("'");
UpdateSQL.Append(pDataReader[FieldName].ToString().Replace("'", "''"));
UpdateSQL.Append("'");
break;
}
UpdateSQL.Append(",");
}
}
UpdateSQL.Length = UpdateSQL.Length - 1;
UpdateSQL.Append(" Where ");
UpdateSQL.Append(pKeyString);
//builderOLE = null;
cmdSqL = null;
cmdSqL = Conn.CreateCommand();
cmdSqL.CommandText = UpdateSQL.ToString();
cmdSqL.ExecuteNonQuery();
}
catch (System.Exception ex)
{
Logger.Log(DateTime.Now + ": " + ex.Message);
}
finally
{
if (Conn != null)
{
Conn.Close();
}
}
result = true;
return result;
}
public override DbDataAdapter GetDbAdapter(string pSelectSQL)
{
IDbConnection connection = GetConnection();
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)GetCommand(pSelectSQL, connection,new List<QueryParameter>());
adapter.SelectCommand.CommandTimeout = 1500;
return adapter;
}
public override DbCommand GetCommand(string pKeyString, DataTable pDataTable)
{
System.Data.Common.DbCommand result = null;
System.Data.Common.DbParameter P = null;
string[] KeySet = null;
StringBuilder KeyMatch = new StringBuilder();
result = new System.Data.SqlClient.SqlCommand();
result.CommandTimeout = 1500;
foreach (DataColumn C in pDataTable.Columns)
{
P = new System.Data.SqlClient.SqlParameter();
P.ParameterName = C.ColumnName;
switch (C.DataType.Name)
{
case "Int16":
P.DbType = DbType.Int16;
break;
case "Int32":
P.DbType = DbType.Int32;
break;
case "Date":
case "DateTime":
P.DbType = DbType.DateTime;
break;
case "String":
P.DbType = DbType.String;
break;
default:
P.DbType = DbType.String;
break;
}
result.Parameters.Add(P);
}
KeySet = pKeyString.Split(new string[] { " And " }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < KeySet.Length; i++)
{
string[] temp = KeySet[i].Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
P = new System.Data.SqlClient.SqlParameter();
P.ParameterName = temp[1].Trim();
foreach (DataColumn C in pDataTable.Columns)
{
if (P.ParameterName.ToLowerInvariant() == C.ColumnName.ToLowerInvariant())
{
switch (C.DataType.Name)
{
case "Int16":
P.DbType = DbType.Int16;
break;
case "Int32":
P.DbType = DbType.Int32;
break;
case "Date":
case "DateTime":
P.DbType = DbType.DateTime;
break;
case "String":
P.DbType = DbType.String;
break;
default:
P.DbType = DbType.String;
break;
}
break;
}
}
result.Parameters.Add(P);
}
return result;
}
public override DbCommandBuilder GetDbCommandBuilder(DbDataAdapter Adapter)
{
SqlCommandBuilder builderSQL = new SqlCommandBuilder((SqlDataAdapter)Adapter);
return builderSQL;
}
}
}
|
a51d0aca27fbf459a6741a9ab6f1f5d242192857
|
C#
|
sdgeorge/DirectoryComparer
|
/DirectoryComparer/Models/FileDetails.cs
| 3.203125
| 3
|
using System;
using System.IO;
namespace DirectoryComparer.Models
{
public class FileDetails
{
public string Name { get; set; }
public string Hash { get; set; }
public string Extension { get; set; }
public string Directory { get; set; }
public string AbsolutePath { get; set; }
public string RelativePath { get; set; }
public long Size { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
public DateTime Accessed { get; set; }
public FileDetails(string path, bool read = true, bool hash = true)
{
AbsolutePath = path;
if (read) GetDetails();
else {
Name = Path.GetFileNameWithoutExtension(path);
Extension = Path.GetExtension(path);
Directory = Path.GetDirectoryName(path);
}
if (hash) GetHashCode();
}
public void GetDetails()
{
var info = new FileInfo(AbsolutePath);
if (info != null && info.Exists)
{
Name = info.Name;
Extension = info.Extension;
Directory = info.DirectoryName;
AbsolutePath = info.FullName;
Size = info.Length;
Created = info.CreationTime;
Modified = info.LastWriteTime;
Accessed = info.LastAccessTime;
}
}
public void GetHash()
{
Hash = FileComparer.GetHashCode(AbsolutePath);
}
public bool Compare(FileDetails other) => FileComparer.Compare(this, other);
public override string ToString() => Name;
// TODO - Tidy this
public string GetSize()
{
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB
long bytes = Math.Abs(Size);
if (bytes == 0) return "0 " + suf[0];
int order = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes / Math.Pow(1024, order), 2);
return (Math.Sign(bytes) * num).ToString() + " " + suf[order];
// Adjust the format string to your preferences. For example "{0:0.#}{1}" would
// show a single decimal place, and no space.
//string result = String.Format("{0:0.##} {1}", len, sizes[order]);
}
}
}
|
9f93eebb80b428f12c5512e47197fc64b4df4773
|
C#
|
tezeoffor/BlogApplication
|
/Data/Repository/Repository.cs
| 3
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BlogApplication.Models;
using BlogApplication.Models.Comments;
using Microsoft.EntityFrameworkCore;
namespace BlogApplication.Data.Repository
{
public class Repository : IRepository
{
private AppDbContext _ctx;
public Repository(AppDbContext ctx)
{
_ctx = ctx;
}
//Add post to the repository
public void AddPost(Post post)
{
_ctx.Posts.Add(post);
}
//Get all the post and return the list of post
public List<Post> GetAllPosts()
{
return _ctx.Posts.ToList();
//Get all the post and return according to its category
} public List<Post> GetAllPosts(string category)
{
return _ctx.Posts
.Where(post => post.Category.ToLower().Equals(category.ToLower()))
.ToList();
}
//Take a single post, return the first post if the id equals to the id
public Post GetPost(int id)
{
return _ctx.Posts
.Include(p => p.MainComments)
.ThenInclude(mc => mc.SubComments)
.FirstOrDefault(p => p.id == id);
}
//Removes post with the id
public void RemovePost(int id)
{
_ctx.Posts.Remove(GetPost(id));
}
public void UpdatePost(Post post)
{
_ctx.Posts.Update(post);
}
//This is called when we save changes, if saveChanges is greater than 0 return true
public async Task<bool> SaveChangesAsync()
{
if (await _ctx.SaveChangesAsync() > 0)
{
return true;
}
return false;
}
public void AddSubComment(SubComment comment)
{
_ctx.SubComments.Add(comment);
}
}
}
|
495fe1ac353afa9fd93a54b7313db6cc0dafb99f
|
C#
|
DogeKun/BA-IT-Challange
|
/BA IT challange/baTask3/baTask3/TextOutput.cs
| 3.34375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Globalization;
namespace baTask3
{
class TextOutput
{
List<string> dataOutput;
private int MAX_CHILD_COUNT = 0;
private int MIN_CHILD_COUNT = 9999;
public TextOutput()
{
//Changing decimal seperator to a ,
CultureInfo customCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = customCulture;
dataOutput = new List<string>();
}
public List<string> Splitter(List<SchoolData> SchoolDataList)
{
foreach (SchoolData schooldata in SchoolDataList)
{
if (MAX_CHILD_COUNT < schooldata.CHILD_COUNT)
MAX_CHILD_COUNT = schooldata.CHILD_COUNT;
if (MIN_CHILD_COUNT > schooldata.CHILD_COUNT)
MIN_CHILD_COUNT = schooldata.CHILD_COUNT;
}
foreach (SchoolData schooldata in SchoolDataList)
{
if (schooldata.CHILD_COUNT == MAX_CHILD_COUNT || schooldata.CHILD_COUNT == MIN_CHILD_COUNT)
{
string output = "";
char[] chararray = schooldata.SCHOOL_NAME.Replace("\"", "").ToCharArray();
string tempString = "";
//if(schooldata.SCHOOL_NAME.Split(' ').Count() > 1)
//{
// Console.WriteLine(schooldata.SCHOOL_NAME);
//}
int limit = 2;
for (int i = 0; i <= limit; i++)
{
if (!chararray[i].Equals(' '))
{
tempString += char.ToUpper(chararray[i]);
}
else limit++;
}
output += tempString + "_";
string[] stringarray = schooldata.TYPE_LABEL.Split(' ');
var floatarray = new List<float>();
foreach (string s in stringarray)
{
//Problem with . and ,
//Default is changed to be a .
var replacment = s.Replace(",", ".");
if (float.TryParse(replacment, out var tempFloat))
{
floatarray.Add(tempFloat);
}
}
if (floatarray.Count > 1)
{
output += floatarray[0] + "-";
output += floatarray[1] + "_";
}
else
{
output += stringarray[0] + "-";
output += stringarray[1] + "_";
}
Array.Clear(chararray, 0, chararray.Length);
tempString = "";
chararray = schooldata.LAN_LABEL.ToCharArray();
for (int i = 0; i <= 3; i++)
tempString += chararray[i];
output += tempString;
dataOutput.Add(output);
}
}
return dataOutput;
}
}
}
|
3fbf8e08ae6f5fa636d7fa554169a89ebe05e9dd
|
C#
|
fourtf/chatterino
|
/Chatterino.Common/Emojis.cs
| 2.8125
| 3
|
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Chatterino.Common
{
public static class Emojis
{
static Regex findShortCodes = new Regex(":([-+\\w]+):", RegexOptions.Compiled);
public static ConcurrentDictionary<string, string> ShortCodeToEmoji = new ConcurrentDictionary<string, string>();
public static ConcurrentDictionary<string, string> EmojiToShortCode = new ConcurrentDictionary<string, string>();
public static ConcurrentDictionary<char, ConcurrentDictionary<string, LazyLoadedImage>> FirstEmojiChars = new ConcurrentDictionary<char, ConcurrentDictionary<string, LazyLoadedImage>>();
public static string ReplaceShortCodes(string s)
{
return findShortCodes.Replace(s, m =>
{
string emoji;
if (ShortCodeToEmoji.TryGetValue(m.Groups[1].Value, out emoji))
return emoji;
return m.Value;
});
}
public static int[] ToCodePoints(string str)
{
if (str == null)
throw new ArgumentNullException(nameof(str));
var codePoints = new List<int>(str.Length);
for (var i = 0; i < str.Length; i++)
{
codePoints.Add(char.ConvertToUtf32(str, i));
if (char.IsHighSurrogate(str[i]))
i += 1;
}
return codePoints.ToArray();
}
public static object[] ParseEmojis(string text)
{
var objects = new List<object>();
var lastSlice = 0;
for (var i = 0; i < text.Length; i++)
{
if (!char.IsLowSurrogate(text, i))
{
ConcurrentDictionary<string, LazyLoadedImage> _emojis;
if (FirstEmojiChars.TryGetValue(text[i], out _emojis))
{
for (var j = Math.Min(8, text.Length - i); j > 0; j--)
{
var emoji = text.Substring(i, j);
LazyLoadedImage emote;
if (_emojis.TryGetValue(emoji, out emote))
{
if (emote == null)
{
var codepoints = string.Join("-", ToCodePoints(emoji).Select(n => n.ToString("X").ToLower()));
var url = $"https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.6/assets/png/{codepoints}.png";
_emojis[emoji] = emote = new LazyLoadedImage
{
Url = url,
Tooltip = $":{EmojiToShortCode[emoji]}:\nemoji",
Name = emoji,
LoadAction = () =>
{
object img;
try
{
var request = WebRequest.Create(url);
if (AppSettings.IgnoreSystemProxy)
{
request.Proxy = null;
}
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
img = GuiEngine.Current.ReadImageFromStream(stream);
//img = GuiEngine.Current.ScaleImage(img, 0.35);
GuiEngine.Current.FreezeImage(img);
return img;
}
}
catch
{
img = null;
}
return img;
},
Scale = 0.35,
HasTrailingSpace = false,
IsEmote = true
};
}
if (i - lastSlice != 0)
objects.Add(text.Substring(lastSlice, i - lastSlice));
objects.Add(emote);
i += j - 1;
lastSlice = i + 1;
break;
}
}
}
}
}
if (lastSlice == 0 && objects.Count == 0)
{
return new object[] { text };
}
if (lastSlice < text.Length)
objects.Add(text.Substring(lastSlice));
return objects.ToArray();
}
static Emojis()
{
ShortCodeToEmoji["100"] = "\U0001f4af";
ShortCodeToEmoji["1234"] = "\U0001f522";
ShortCodeToEmoji["grinning"] = "\U0001f600";
ShortCodeToEmoji["grimacing"] = "\U0001f62c";
ShortCodeToEmoji["grin"] = "\U0001f601";
ShortCodeToEmoji["joy"] = "\U0001f602";
ShortCodeToEmoji["smiley"] = "\U0001f603";
ShortCodeToEmoji["smile"] = "\U0001f604";
ShortCodeToEmoji["sweat_smile"] = "\U0001f605";
ShortCodeToEmoji["laughing"] = "\U0001f606";
ShortCodeToEmoji["innocent"] = "\U0001f607";
ShortCodeToEmoji["wink"] = "\U0001f609";
ShortCodeToEmoji["blush"] = "\U0001f60a";
ShortCodeToEmoji["slight_smile"] = "\U0001f642";
ShortCodeToEmoji["upside_down"] = "\U0001f643";
ShortCodeToEmoji["relaxed"] = "\U0000263a";
ShortCodeToEmoji["yum"] = "\U0001f60b";
ShortCodeToEmoji["relieved"] = "\U0001f60c";
ShortCodeToEmoji["heart_eyes"] = "\U0001f60d";
ShortCodeToEmoji["kissing_heart"] = "\U0001f618";
ShortCodeToEmoji["kissing"] = "\U0001f617";
ShortCodeToEmoji["kissing_smiling_eyes"] = "\U0001f619";
ShortCodeToEmoji["kissing_closed_eyes"] = "\U0001f61a";
ShortCodeToEmoji["stuck_out_tongue_winking_eye"] = "\U0001f61c";
ShortCodeToEmoji["stuck_out_tongue_closed_eyes"] = "\U0001f61d";
ShortCodeToEmoji["stuck_out_tongue"] = "\U0001f61b";
ShortCodeToEmoji["money_mouth"] = "\U0001f911";
ShortCodeToEmoji["nerd"] = "\U0001f913";
ShortCodeToEmoji["sunglasses"] = "\U0001f60e";
ShortCodeToEmoji["hugging"] = "\U0001f917";
ShortCodeToEmoji["smirk"] = "\U0001f60f";
ShortCodeToEmoji["no_mouth"] = "\U0001f636";
ShortCodeToEmoji["neutral_face"] = "\U0001f610";
ShortCodeToEmoji["expressionless"] = "\U0001f611";
ShortCodeToEmoji["unamused"] = "\U0001f612";
ShortCodeToEmoji["rolling_eyes"] = "\U0001f644";
ShortCodeToEmoji["thinking"] = "\U0001f914";
ShortCodeToEmoji["flushed"] = "\U0001f633";
ShortCodeToEmoji["disappointed"] = "\U0001f61e";
ShortCodeToEmoji["worried"] = "\U0001f61f";
ShortCodeToEmoji["angry"] = "\U0001f620";
ShortCodeToEmoji["rage"] = "\U0001f621";
ShortCodeToEmoji["pensive"] = "\U0001f614";
ShortCodeToEmoji["confused"] = "\U0001f615";
ShortCodeToEmoji["slight_frown"] = "\U0001f641";
ShortCodeToEmoji["frowning2"] = "\U00002639";
ShortCodeToEmoji["persevere"] = "\U0001f623";
ShortCodeToEmoji["confounded"] = "\U0001f616";
ShortCodeToEmoji["tired_face"] = "\U0001f62b";
ShortCodeToEmoji["weary"] = "\U0001f629";
ShortCodeToEmoji["triumph"] = "\U0001f624";
ShortCodeToEmoji["open_mouth"] = "\U0001f62e";
ShortCodeToEmoji["scream"] = "\U0001f631";
ShortCodeToEmoji["fearful"] = "\U0001f628";
ShortCodeToEmoji["cold_sweat"] = "\U0001f630";
ShortCodeToEmoji["hushed"] = "\U0001f62f";
ShortCodeToEmoji["frowning"] = "\U0001f626";
ShortCodeToEmoji["anguished"] = "\U0001f627";
ShortCodeToEmoji["cry"] = "\U0001f622";
ShortCodeToEmoji["disappointed_relieved"] = "\U0001f625";
ShortCodeToEmoji["sleepy"] = "\U0001f62a";
ShortCodeToEmoji["sweat"] = "\U0001f613";
ShortCodeToEmoji["sob"] = "\U0001f62d";
ShortCodeToEmoji["dizzy_face"] = "\U0001f635";
ShortCodeToEmoji["astonished"] = "\U0001f632";
ShortCodeToEmoji["zipper_mouth"] = "\U0001f910";
ShortCodeToEmoji["mask"] = "\U0001f637";
ShortCodeToEmoji["thermometer_face"] = "\U0001f912";
ShortCodeToEmoji["head_bandage"] = "\U0001f915";
ShortCodeToEmoji["sleeping"] = "\U0001f634";
ShortCodeToEmoji["zzz"] = "\U0001f4a4";
ShortCodeToEmoji["poop"] = "\U0001f4a9";
ShortCodeToEmoji["smiling_imp"] = "\U0001f608";
ShortCodeToEmoji["imp"] = "\U0001f47f";
ShortCodeToEmoji["japanese_ogre"] = "\U0001f479";
ShortCodeToEmoji["japanese_goblin"] = "\U0001f47a";
ShortCodeToEmoji["skull"] = "\U0001f480";
ShortCodeToEmoji["ghost"] = "\U0001f47b";
ShortCodeToEmoji["alien"] = "\U0001f47d";
ShortCodeToEmoji["robot"] = "\U0001f916";
ShortCodeToEmoji["smiley_cat"] = "\U0001f63a";
ShortCodeToEmoji["smile_cat"] = "\U0001f638";
ShortCodeToEmoji["joy_cat"] = "\U0001f639";
ShortCodeToEmoji["heart_eyes_cat"] = "\U0001f63b";
ShortCodeToEmoji["smirk_cat"] = "\U0001f63c";
ShortCodeToEmoji["kissing_cat"] = "\U0001f63d";
ShortCodeToEmoji["scream_cat"] = "\U0001f640";
ShortCodeToEmoji["crying_cat_face"] = "\U0001f63f";
ShortCodeToEmoji["pouting_cat"] = "\U0001f63e";
ShortCodeToEmoji["raised_hands"] = "\U0001f64c";
ShortCodeToEmoji["clap"] = "\U0001f44f";
ShortCodeToEmoji["wave"] = "\U0001f44b";
ShortCodeToEmoji["thumbsup"] = "\U0001f44d";
ShortCodeToEmoji["thumbsdown"] = "\U0001f44e";
ShortCodeToEmoji["punch"] = "\U0001f44a";
ShortCodeToEmoji["fist"] = "\U0000270a";
ShortCodeToEmoji["v"] = "\U0000270c";
ShortCodeToEmoji["ok_hand"] = "\U0001f44c";
ShortCodeToEmoji["raised_hand"] = "\U0000270b";
ShortCodeToEmoji["open_hands"] = "\U0001f450";
ShortCodeToEmoji["muscle"] = "\U0001f4aa";
ShortCodeToEmoji["pray"] = "\U0001f64f";
ShortCodeToEmoji["point_up"] = "\U0000261d";
ShortCodeToEmoji["point_up_2"] = "\U0001f446";
ShortCodeToEmoji["point_down"] = "\U0001f447";
ShortCodeToEmoji["point_left"] = "\U0001f448";
ShortCodeToEmoji["point_right"] = "\U0001f449";
ShortCodeToEmoji["middle_finger"] = "\U0001f595";
ShortCodeToEmoji["hand_splayed"] = "\U0001f590";
ShortCodeToEmoji["metal"] = "\U0001f918";
ShortCodeToEmoji["vulcan"] = "\U0001f596";
ShortCodeToEmoji["writing_hand"] = "\U0000270d";
ShortCodeToEmoji["nail_care"] = "\U0001f485";
ShortCodeToEmoji["lips"] = "\U0001f444";
ShortCodeToEmoji["tongue"] = "\U0001f445";
ShortCodeToEmoji["ear"] = "\U0001f442";
ShortCodeToEmoji["nose"] = "\U0001f443";
ShortCodeToEmoji["eye"] = "\U0001f441";
ShortCodeToEmoji["eyes"] = "\U0001f440";
ShortCodeToEmoji["bust_in_silhouette"] = "\U0001f464";
ShortCodeToEmoji["busts_in_silhouette"] = "\U0001f465";
ShortCodeToEmoji["speaking_head"] = "\U0001f5e3";
ShortCodeToEmoji["baby"] = "\U0001f476";
ShortCodeToEmoji["boy"] = "\U0001f466";
ShortCodeToEmoji["girl"] = "\U0001f467";
ShortCodeToEmoji["man"] = "\U0001f468";
ShortCodeToEmoji["woman"] = "\U0001f469";
ShortCodeToEmoji["person_with_blond_hair"] = "\U0001f471";
ShortCodeToEmoji["older_man"] = "\U0001f474";
ShortCodeToEmoji["older_woman"] = "\U0001f475";
ShortCodeToEmoji["man_with_gua_pi_mao"] = "\U0001f472";
ShortCodeToEmoji["man_with_turban"] = "\U0001f473";
ShortCodeToEmoji["cop"] = "\U0001f46e";
ShortCodeToEmoji["construction_worker"] = "\U0001f477";
ShortCodeToEmoji["guardsman"] = "\U0001f482";
ShortCodeToEmoji["spy"] = "\U0001f575";
ShortCodeToEmoji["santa"] = "\U0001f385";
ShortCodeToEmoji["angel"] = "\U0001f47c";
ShortCodeToEmoji["princess"] = "\U0001f478";
ShortCodeToEmoji["bride_with_veil"] = "\U0001f470";
ShortCodeToEmoji["walking"] = "\U0001f6b6";
ShortCodeToEmoji["runner"] = "\U0001f3c3";
ShortCodeToEmoji["dancer"] = "\U0001f483";
ShortCodeToEmoji["dancers"] = "\U0001f46f";
ShortCodeToEmoji["couple"] = "\U0001f46b";
ShortCodeToEmoji["two_men_holding_hands"] = "\U0001f46c";
ShortCodeToEmoji["two_women_holding_hands"] = "\U0001f46d";
ShortCodeToEmoji["bow"] = "\U0001f647";
ShortCodeToEmoji["information_desk_person"] = "\U0001f481";
ShortCodeToEmoji["no_good"] = "\U0001f645";
ShortCodeToEmoji["ok_woman"] = "\U0001f646";
ShortCodeToEmoji["raising_hand"] = "\U0001f64b";
ShortCodeToEmoji["person_with_pouting_face"] = "\U0001f64e";
ShortCodeToEmoji["person_frowning"] = "\U0001f64d";
ShortCodeToEmoji["haircut"] = "\U0001f487";
ShortCodeToEmoji["massage"] = "\U0001f486";
ShortCodeToEmoji["couple_with_heart"] = "\U0001f491";
ShortCodeToEmoji["couple_ww"] = "\U0001f469\U00002764\U0001f469";
ShortCodeToEmoji["couple_mm"] = "\U0001f468\U00002764\U0001f468";
ShortCodeToEmoji["couplekiss"] = "\U0001f48f";
ShortCodeToEmoji["kiss_ww"] = "\U0001f469\U00002764\U0001f48b\U0001f469";
ShortCodeToEmoji["kiss_mm"] = "\U0001f468\U00002764\U0001f48b\U0001f468";
ShortCodeToEmoji["family"] = "\U0001f46a";
ShortCodeToEmoji["family_mwg"] = "\U0001f468\U0001f469\U0001f467";
ShortCodeToEmoji["family_mwgb"] = "\U0001f468\U0001f469\U0001f467\U0001f466";
ShortCodeToEmoji["family_mwbb"] = "\U0001f468\U0001f469\U0001f466\U0001f466";
ShortCodeToEmoji["family_mwgg"] = "\U0001f468\U0001f469\U0001f467\U0001f467";
ShortCodeToEmoji["family_wwb"] = "\U0001f469\U0001f469\U0001f466";
ShortCodeToEmoji["family_wwg"] = "\U0001f469\U0001f469\U0001f467";
ShortCodeToEmoji["family_wwgb"] = "\U0001f469\U0001f469\U0001f467\U0001f466";
ShortCodeToEmoji["family_wwbb"] = "\U0001f469\U0001f469\U0001f466\U0001f466";
ShortCodeToEmoji["family_wwgg"] = "\U0001f469\U0001f469\U0001f467\U0001f467";
ShortCodeToEmoji["family_mmb"] = "\U0001f468\U0001f468\U0001f466";
ShortCodeToEmoji["family_mmg"] = "\U0001f468\U0001f468\U0001f467";
ShortCodeToEmoji["family_mmgb"] = "\U0001f468\U0001f468\U0001f467\U0001f466";
ShortCodeToEmoji["family_mmbb"] = "\U0001f468\U0001f468\U0001f466\U0001f466";
ShortCodeToEmoji["family_mmgg"] = "\U0001f468\U0001f468\U0001f467\U0001f467";
ShortCodeToEmoji["womans_clothes"] = "\U0001f45a";
ShortCodeToEmoji["shirt"] = "\U0001f455";
ShortCodeToEmoji["jeans"] = "\U0001f456";
ShortCodeToEmoji["necktie"] = "\U0001f454";
ShortCodeToEmoji["dress"] = "\U0001f457";
ShortCodeToEmoji["bikini"] = "\U0001f459";
ShortCodeToEmoji["kimono"] = "\U0001f458";
ShortCodeToEmoji["lipstick"] = "\U0001f484";
ShortCodeToEmoji["kiss"] = "\U0001f48b";
ShortCodeToEmoji["footprints"] = "\U0001f463";
ShortCodeToEmoji["high_heel"] = "\U0001f460";
ShortCodeToEmoji["sandal"] = "\U0001f461";
ShortCodeToEmoji["boot"] = "\U0001f462";
ShortCodeToEmoji["mans_shoe"] = "\U0001f45e";
ShortCodeToEmoji["athletic_shoe"] = "\U0001f45f";
ShortCodeToEmoji["womans_hat"] = "\U0001f452";
ShortCodeToEmoji["tophat"] = "\U0001f3a9";
ShortCodeToEmoji["helmet_with_cross"] = "\U000026d1";
ShortCodeToEmoji["mortar_board"] = "\U0001f393";
ShortCodeToEmoji["crown"] = "\U0001f451";
ShortCodeToEmoji["school_satchel"] = "\U0001f392";
ShortCodeToEmoji["pouch"] = "\U0001f45d";
ShortCodeToEmoji["purse"] = "\U0001f45b";
ShortCodeToEmoji["handbag"] = "\U0001f45c";
ShortCodeToEmoji["briefcase"] = "\U0001f4bc";
ShortCodeToEmoji["eyeglasses"] = "\U0001f453";
ShortCodeToEmoji["dark_sunglasses"] = "\U0001f576";
ShortCodeToEmoji["ring"] = "\U0001f48d";
ShortCodeToEmoji["closed_umbrella"] = "\U0001f302";
ShortCodeToEmoji["dog"] = "\U0001f436";
ShortCodeToEmoji["cat"] = "\U0001f431";
ShortCodeToEmoji["mouse"] = "\U0001f42d";
ShortCodeToEmoji["hamster"] = "\U0001f439";
ShortCodeToEmoji["rabbit"] = "\U0001f430";
ShortCodeToEmoji["bear"] = "\U0001f43b";
ShortCodeToEmoji["panda_face"] = "\U0001f43c";
ShortCodeToEmoji["koala"] = "\U0001f428";
ShortCodeToEmoji["tiger"] = "\U0001f42f";
ShortCodeToEmoji["lion_face"] = "\U0001f981";
ShortCodeToEmoji["cow"] = "\U0001f42e";
ShortCodeToEmoji["pig"] = "\U0001f437";
ShortCodeToEmoji["pig_nose"] = "\U0001f43d";
ShortCodeToEmoji["frog"] = "\U0001f438";
ShortCodeToEmoji["octopus"] = "\U0001f419";
ShortCodeToEmoji["monkey_face"] = "\U0001f435";
ShortCodeToEmoji["see_no_evil"] = "\U0001f648";
ShortCodeToEmoji["hear_no_evil"] = "\U0001f649";
ShortCodeToEmoji["speak_no_evil"] = "\U0001f64a";
ShortCodeToEmoji["monkey"] = "\U0001f412";
ShortCodeToEmoji["chicken"] = "\U0001f414";
ShortCodeToEmoji["penguin"] = "\U0001f427";
ShortCodeToEmoji["bird"] = "\U0001f426";
ShortCodeToEmoji["baby_chick"] = "\U0001f424";
ShortCodeToEmoji["hatching_chick"] = "\U0001f423";
ShortCodeToEmoji["hatched_chick"] = "\U0001f425";
ShortCodeToEmoji["wolf"] = "\U0001f43a";
ShortCodeToEmoji["boar"] = "\U0001f417";
ShortCodeToEmoji["horse"] = "\U0001f434";
ShortCodeToEmoji["unicorn"] = "\U0001f984";
ShortCodeToEmoji["bee"] = "\U0001f41d";
ShortCodeToEmoji["bug"] = "\U0001f41b";
ShortCodeToEmoji["snail"] = "\U0001f40c";
ShortCodeToEmoji["beetle"] = "\U0001f41e";
ShortCodeToEmoji["ant"] = "\U0001f41c";
ShortCodeToEmoji["spider"] = "\U0001f577";
ShortCodeToEmoji["scorpion"] = "\U0001f982";
ShortCodeToEmoji["crab"] = "\U0001f980";
ShortCodeToEmoji["snake"] = "\U0001f40d";
ShortCodeToEmoji["turtle"] = "\U0001f422";
ShortCodeToEmoji["tropical_fish"] = "\U0001f420";
ShortCodeToEmoji["fish"] = "\U0001f41f";
ShortCodeToEmoji["blowfish"] = "\U0001f421";
ShortCodeToEmoji["dolphin"] = "\U0001f42c";
ShortCodeToEmoji["whale"] = "\U0001f433";
ShortCodeToEmoji["whale2"] = "\U0001f40b";
ShortCodeToEmoji["crocodile"] = "\U0001f40a";
ShortCodeToEmoji["leopard"] = "\U0001f406";
ShortCodeToEmoji["tiger2"] = "\U0001f405";
ShortCodeToEmoji["water_buffalo"] = "\U0001f403";
ShortCodeToEmoji["ox"] = "\U0001f402";
ShortCodeToEmoji["cow2"] = "\U0001f404";
ShortCodeToEmoji["dromedary_camel"] = "\U0001f42a";
ShortCodeToEmoji["camel"] = "\U0001f42b";
ShortCodeToEmoji["elephant"] = "\U0001f418";
ShortCodeToEmoji["goat"] = "\U0001f410";
ShortCodeToEmoji["ram"] = "\U0001f40f";
ShortCodeToEmoji["sheep"] = "\U0001f411";
ShortCodeToEmoji["racehorse"] = "\U0001f40e";
ShortCodeToEmoji["pig2"] = "\U0001f416";
ShortCodeToEmoji["rat"] = "\U0001f400";
ShortCodeToEmoji["mouse2"] = "\U0001f401";
ShortCodeToEmoji["rooster"] = "\U0001f413";
ShortCodeToEmoji["turkey"] = "\U0001f983";
ShortCodeToEmoji["dove"] = "\U0001f54a";
ShortCodeToEmoji["dog2"] = "\U0001f415";
ShortCodeToEmoji["poodle"] = "\U0001f429";
ShortCodeToEmoji["cat2"] = "\U0001f408";
ShortCodeToEmoji["rabbit2"] = "\U0001f407";
ShortCodeToEmoji["chipmunk"] = "\U0001f43f";
ShortCodeToEmoji["feet"] = "\U0001f43e";
ShortCodeToEmoji["dragon"] = "\U0001f409";
ShortCodeToEmoji["dragon_face"] = "\U0001f432";
ShortCodeToEmoji["cactus"] = "\U0001f335";
ShortCodeToEmoji["christmas_tree"] = "\U0001f384";
ShortCodeToEmoji["evergreen_tree"] = "\U0001f332";
ShortCodeToEmoji["deciduous_tree"] = "\U0001f333";
ShortCodeToEmoji["palm_tree"] = "\U0001f334";
ShortCodeToEmoji["seedling"] = "\U0001f331";
ShortCodeToEmoji["herb"] = "\U0001f33f";
ShortCodeToEmoji["shamrock"] = "\U00002618";
ShortCodeToEmoji["four_leaf_clover"] = "\U0001f340";
ShortCodeToEmoji["bamboo"] = "\U0001f38d";
ShortCodeToEmoji["tanabata_tree"] = "\U0001f38b";
ShortCodeToEmoji["leaves"] = "\U0001f343";
ShortCodeToEmoji["fallen_leaf"] = "\U0001f342";
ShortCodeToEmoji["maple_leaf"] = "\U0001f341";
ShortCodeToEmoji["ear_of_rice"] = "\U0001f33e";
ShortCodeToEmoji["hibiscus"] = "\U0001f33a";
ShortCodeToEmoji["sunflower"] = "\U0001f33b";
ShortCodeToEmoji["rose"] = "\U0001f339";
ShortCodeToEmoji["tulip"] = "\U0001f337";
ShortCodeToEmoji["blossom"] = "\U0001f33c";
ShortCodeToEmoji["cherry_blossom"] = "\U0001f338";
ShortCodeToEmoji["bouquet"] = "\U0001f490";
ShortCodeToEmoji["mushroom"] = "\U0001f344";
ShortCodeToEmoji["chestnut"] = "\U0001f330";
ShortCodeToEmoji["jack_o_lantern"] = "\U0001f383";
ShortCodeToEmoji["shell"] = "\U0001f41a";
ShortCodeToEmoji["spider_web"] = "\U0001f578";
ShortCodeToEmoji["earth_americas"] = "\U0001f30e";
ShortCodeToEmoji["earth_africa"] = "\U0001f30d";
ShortCodeToEmoji["earth_asia"] = "\U0001f30f";
ShortCodeToEmoji["full_moon"] = "\U0001f315";
ShortCodeToEmoji["waning_gibbous_moon"] = "\U0001f316";
ShortCodeToEmoji["last_quarter_moon"] = "\U0001f317";
ShortCodeToEmoji["waning_crescent_moon"] = "\U0001f318";
ShortCodeToEmoji["new_moon"] = "\U0001f311";
ShortCodeToEmoji["waxing_crescent_moon"] = "\U0001f312";
ShortCodeToEmoji["first_quarter_moon"] = "\U0001f313";
ShortCodeToEmoji["waxing_gibbous_moon"] = "\U0001f314";
ShortCodeToEmoji["new_moon_with_face"] = "\U0001f31a";
ShortCodeToEmoji["full_moon_with_face"] = "\U0001f31d";
ShortCodeToEmoji["first_quarter_moon_with_face"] = "\U0001f31b";
ShortCodeToEmoji["last_quarter_moon_with_face"] = "\U0001f31c";
ShortCodeToEmoji["sun_with_face"] = "\U0001f31e";
ShortCodeToEmoji["crescent_moon"] = "\U0001f319";
ShortCodeToEmoji["star"] = "\U00002b50";
ShortCodeToEmoji["star2"] = "\U0001f31f";
ShortCodeToEmoji["dizzy"] = "\U0001f4ab";
ShortCodeToEmoji["sparkles"] = "\U00002728";
ShortCodeToEmoji["comet"] = "\U00002604";
ShortCodeToEmoji["sunny"] = "\U00002600";
ShortCodeToEmoji["white_sun_small_cloud"] = "\U0001f324";
ShortCodeToEmoji["partly_sunny"] = "\U000026c5";
ShortCodeToEmoji["white_sun_cloud"] = "\U0001f325";
ShortCodeToEmoji["white_sun_rain_cloud"] = "\U0001f326";
ShortCodeToEmoji["cloud"] = "\U00002601";
ShortCodeToEmoji["cloud_rain"] = "\U0001f327";
ShortCodeToEmoji["thunder_cloud_rain"] = "\U000026c8";
ShortCodeToEmoji["cloud_lightning"] = "\U0001f329";
ShortCodeToEmoji["zap"] = "\U000026a1";
ShortCodeToEmoji["fire"] = "\U0001f525";
ShortCodeToEmoji["boom"] = "\U0001f4a5";
ShortCodeToEmoji["snowflake"] = "\U00002744";
ShortCodeToEmoji["cloud_snow"] = "\U0001f328";
ShortCodeToEmoji["snowman2"] = "\U00002603";
ShortCodeToEmoji["snowman"] = "\U000026c4";
ShortCodeToEmoji["wind_blowing_face"] = "\U0001f32c";
ShortCodeToEmoji["dash"] = "\U0001f4a8";
ShortCodeToEmoji["cloud_tornado"] = "\U0001f32a";
ShortCodeToEmoji["fog"] = "\U0001f32b";
ShortCodeToEmoji["umbrella2"] = "\U00002602";
ShortCodeToEmoji["umbrella"] = "\U00002614";
ShortCodeToEmoji["droplet"] = "\U0001f4a7";
ShortCodeToEmoji["sweat_drops"] = "\U0001f4a6";
ShortCodeToEmoji["ocean"] = "\U0001f30a";
ShortCodeToEmoji["green_apple"] = "\U0001f34f";
ShortCodeToEmoji["apple"] = "\U0001f34e";
ShortCodeToEmoji["pear"] = "\U0001f350";
ShortCodeToEmoji["tangerine"] = "\U0001f34a";
ShortCodeToEmoji["lemon"] = "\U0001f34b";
ShortCodeToEmoji["banana"] = "\U0001f34c";
ShortCodeToEmoji["watermelon"] = "\U0001f349";
ShortCodeToEmoji["grapes"] = "\U0001f347";
ShortCodeToEmoji["strawberry"] = "\U0001f353";
ShortCodeToEmoji["melon"] = "\U0001f348";
ShortCodeToEmoji["cherries"] = "\U0001f352";
ShortCodeToEmoji["peach"] = "\U0001f351";
ShortCodeToEmoji["pineapple"] = "\U0001f34d";
ShortCodeToEmoji["tomato"] = "\U0001f345";
ShortCodeToEmoji["eggplant"] = "\U0001f346";
ShortCodeToEmoji["hot_pepper"] = "\U0001f336";
ShortCodeToEmoji["corn"] = "\U0001f33d";
ShortCodeToEmoji["sweet_potato"] = "\U0001f360";
ShortCodeToEmoji["honey_pot"] = "\U0001f36f";
ShortCodeToEmoji["bread"] = "\U0001f35e";
ShortCodeToEmoji["cheese"] = "\U0001f9c0";
ShortCodeToEmoji["poultry_leg"] = "\U0001f357";
ShortCodeToEmoji["meat_on_bone"] = "\U0001f356";
ShortCodeToEmoji["fried_shrimp"] = "\U0001f364";
ShortCodeToEmoji["cooking"] = "\U0001f373";
ShortCodeToEmoji["hamburger"] = "\U0001f354";
ShortCodeToEmoji["fries"] = "\U0001f35f";
ShortCodeToEmoji["hotdog"] = "\U0001f32d";
ShortCodeToEmoji["pizza"] = "\U0001f355";
ShortCodeToEmoji["spaghetti"] = "\U0001f35d";
ShortCodeToEmoji["taco"] = "\U0001f32e";
ShortCodeToEmoji["burrito"] = "\U0001f32f";
ShortCodeToEmoji["ramen"] = "\U0001f35c";
ShortCodeToEmoji["stew"] = "\U0001f372";
ShortCodeToEmoji["fish_cake"] = "\U0001f365";
ShortCodeToEmoji["sushi"] = "\U0001f363";
ShortCodeToEmoji["bento"] = "\U0001f371";
ShortCodeToEmoji["curry"] = "\U0001f35b";
ShortCodeToEmoji["rice_ball"] = "\U0001f359";
ShortCodeToEmoji["rice"] = "\U0001f35a";
ShortCodeToEmoji["rice_cracker"] = "\U0001f358";
ShortCodeToEmoji["oden"] = "\U0001f362";
ShortCodeToEmoji["dango"] = "\U0001f361";
ShortCodeToEmoji["shaved_ice"] = "\U0001f367";
ShortCodeToEmoji["ice_cream"] = "\U0001f368";
ShortCodeToEmoji["icecream"] = "\U0001f366";
ShortCodeToEmoji["cake"] = "\U0001f370";
ShortCodeToEmoji["birthday"] = "\U0001f382";
ShortCodeToEmoji["custard"] = "\U0001f36e";
ShortCodeToEmoji["candy"] = "\U0001f36c";
ShortCodeToEmoji["lollipop"] = "\U0001f36d";
ShortCodeToEmoji["chocolate_bar"] = "\U0001f36b";
ShortCodeToEmoji["popcorn"] = "\U0001f37f";
ShortCodeToEmoji["doughnut"] = "\U0001f369";
ShortCodeToEmoji["cookie"] = "\U0001f36a";
ShortCodeToEmoji["beer"] = "\U0001f37a";
ShortCodeToEmoji["beers"] = "\U0001f37b";
ShortCodeToEmoji["wine_glass"] = "\U0001f377";
ShortCodeToEmoji["cocktail"] = "\U0001f378";
ShortCodeToEmoji["tropical_drink"] = "\U0001f379";
ShortCodeToEmoji["champagne"] = "\U0001f37e";
ShortCodeToEmoji["sake"] = "\U0001f376";
ShortCodeToEmoji["tea"] = "\U0001f375";
ShortCodeToEmoji["coffee"] = "\U00002615";
ShortCodeToEmoji["baby_bottle"] = "\U0001f37c";
ShortCodeToEmoji["fork_and_knife"] = "\U0001f374";
ShortCodeToEmoji["fork_knife_plate"] = "\U0001f37d";
ShortCodeToEmoji["soccer"] = "\U000026bd";
ShortCodeToEmoji["basketball"] = "\U0001f3c0";
ShortCodeToEmoji["football"] = "\U0001f3c8";
ShortCodeToEmoji["baseball"] = "\U000026be";
ShortCodeToEmoji["tennis"] = "\U0001f3be";
ShortCodeToEmoji["volleyball"] = "\U0001f3d0";
ShortCodeToEmoji["rugby_football"] = "\U0001f3c9";
ShortCodeToEmoji["8ball"] = "\U0001f3b1";
ShortCodeToEmoji["golf"] = "\U000026f3";
ShortCodeToEmoji["golfer"] = "\U0001f3cc";
ShortCodeToEmoji["ping_pong"] = "\U0001f3d3";
ShortCodeToEmoji["badminton"] = "\U0001f3f8";
ShortCodeToEmoji["hockey"] = "\U0001f3d2";
ShortCodeToEmoji["field_hockey"] = "\U0001f3d1";
ShortCodeToEmoji["cricket"] = "\U0001f3cf";
ShortCodeToEmoji["ski"] = "\U0001f3bf";
ShortCodeToEmoji["skier"] = "\U000026f7";
ShortCodeToEmoji["snowboarder"] = "\U0001f3c2";
ShortCodeToEmoji["ice_skate"] = "\U000026f8";
ShortCodeToEmoji["bow_and_arrow"] = "\U0001f3f9";
ShortCodeToEmoji["fishing_pole_and_fish"] = "\U0001f3a3";
ShortCodeToEmoji["rowboat"] = "\U0001f6a3";
ShortCodeToEmoji["swimmer"] = "\U0001f3ca";
ShortCodeToEmoji["surfer"] = "\U0001f3c4";
ShortCodeToEmoji["bath"] = "\U0001f6c0";
ShortCodeToEmoji["basketball_player"] = "\U000026f9";
ShortCodeToEmoji["lifter"] = "\U0001f3cb";
ShortCodeToEmoji["bicyclist"] = "\U0001f6b4";
ShortCodeToEmoji["mountain_bicyclist"] = "\U0001f6b5";
ShortCodeToEmoji["horse_racing"] = "\U0001f3c7";
ShortCodeToEmoji["levitate"] = "\U0001f574";
ShortCodeToEmoji["trophy"] = "\U0001f3c6";
ShortCodeToEmoji["running_shirt_with_sash"] = "\U0001f3bd";
ShortCodeToEmoji["medal"] = "\U0001f3c5";
ShortCodeToEmoji["military_medal"] = "\U0001f396";
ShortCodeToEmoji["reminder_ribbon"] = "\U0001f397";
ShortCodeToEmoji["rosette"] = "\U0001f3f5";
ShortCodeToEmoji["ticket"] = "\U0001f3ab";
ShortCodeToEmoji["tickets"] = "\U0001f39f";
ShortCodeToEmoji["performing_arts"] = "\U0001f3ad";
ShortCodeToEmoji["art"] = "\U0001f3a8";
ShortCodeToEmoji["circus_tent"] = "\U0001f3aa";
ShortCodeToEmoji["microphone"] = "\U0001f3a4";
ShortCodeToEmoji["headphones"] = "\U0001f3a7";
ShortCodeToEmoji["musical_score"] = "\U0001f3bc";
ShortCodeToEmoji["musical_keyboard"] = "\U0001f3b9";
ShortCodeToEmoji["saxophone"] = "\U0001f3b7";
ShortCodeToEmoji["trumpet"] = "\U0001f3ba";
ShortCodeToEmoji["guitar"] = "\U0001f3b8";
ShortCodeToEmoji["violin"] = "\U0001f3bb";
ShortCodeToEmoji["clapper"] = "\U0001f3ac";
ShortCodeToEmoji["video_game"] = "\U0001f3ae";
ShortCodeToEmoji["space_invader"] = "\U0001f47e";
ShortCodeToEmoji["dart"] = "\U0001f3af";
ShortCodeToEmoji["game_die"] = "\U0001f3b2";
ShortCodeToEmoji["slot_machine"] = "\U0001f3b0";
ShortCodeToEmoji["bowling"] = "\U0001f3b3";
ShortCodeToEmoji["red_car"] = "\U0001f697";
ShortCodeToEmoji["taxi"] = "\U0001f695";
ShortCodeToEmoji["blue_car"] = "\U0001f699";
ShortCodeToEmoji["bus"] = "\U0001f68c";
ShortCodeToEmoji["trolleybus"] = "\U0001f68e";
ShortCodeToEmoji["race_car"] = "\U0001f3ce";
ShortCodeToEmoji["police_car"] = "\U0001f693";
ShortCodeToEmoji["ambulance"] = "\U0001f691";
ShortCodeToEmoji["fire_engine"] = "\U0001f692";
ShortCodeToEmoji["minibus"] = "\U0001f690";
ShortCodeToEmoji["truck"] = "\U0001f69a";
ShortCodeToEmoji["articulated_lorry"] = "\U0001f69b";
ShortCodeToEmoji["tractor"] = "\U0001f69c";
ShortCodeToEmoji["motorcycle"] = "\U0001f3cd";
ShortCodeToEmoji["bike"] = "\U0001f6b2";
ShortCodeToEmoji["rotating_light"] = "\U0001f6a8";
ShortCodeToEmoji["oncoming_police_car"] = "\U0001f694";
ShortCodeToEmoji["oncoming_bus"] = "\U0001f68d";
ShortCodeToEmoji["oncoming_automobile"] = "\U0001f698";
ShortCodeToEmoji["oncoming_taxi"] = "\U0001f696";
ShortCodeToEmoji["aerial_tramway"] = "\U0001f6a1";
ShortCodeToEmoji["mountain_cableway"] = "\U0001f6a0";
ShortCodeToEmoji["suspension_railway"] = "\U0001f69f";
ShortCodeToEmoji["railway_car"] = "\U0001f683";
ShortCodeToEmoji["train"] = "\U0001f68b";
ShortCodeToEmoji["monorail"] = "\U0001f69d";
ShortCodeToEmoji["bullettrain_side"] = "\U0001f684";
ShortCodeToEmoji["bullettrain_front"] = "\U0001f685";
ShortCodeToEmoji["light_rail"] = "\U0001f688";
ShortCodeToEmoji["mountain_railway"] = "\U0001f69e";
ShortCodeToEmoji["steam_locomotive"] = "\U0001f682";
ShortCodeToEmoji["train2"] = "\U0001f686";
ShortCodeToEmoji["metro"] = "\U0001f687";
ShortCodeToEmoji["tram"] = "\U0001f68a";
ShortCodeToEmoji["station"] = "\U0001f689";
ShortCodeToEmoji["helicopter"] = "\U0001f681";
ShortCodeToEmoji["airplane_small"] = "\U0001f6e9";
ShortCodeToEmoji["airplane"] = "\U00002708";
ShortCodeToEmoji["airplane_departure"] = "\U0001f6eb";
ShortCodeToEmoji["airplane_arriving"] = "\U0001f6ec";
ShortCodeToEmoji["sailboat"] = "\U000026f5";
ShortCodeToEmoji["motorboat"] = "\U0001f6e5";
ShortCodeToEmoji["speedboat"] = "\U0001f6a4";
ShortCodeToEmoji["ferry"] = "\U000026f4";
ShortCodeToEmoji["cruise_ship"] = "\U0001f6f3";
ShortCodeToEmoji["rocket"] = "\U0001f680";
ShortCodeToEmoji["satellite_orbital"] = "\U0001f6f0";
ShortCodeToEmoji["seat"] = "\U0001f4ba";
ShortCodeToEmoji["anchor"] = "\U00002693";
ShortCodeToEmoji["construction"] = "\U0001f6a7";
ShortCodeToEmoji["fuelpump"] = "\U000026fd";
ShortCodeToEmoji["busstop"] = "\U0001f68f";
ShortCodeToEmoji["vertical_traffic_light"] = "\U0001f6a6";
ShortCodeToEmoji["traffic_light"] = "\U0001f6a5";
ShortCodeToEmoji["checkered_flag"] = "\U0001f3c1";
ShortCodeToEmoji["ship"] = "\U0001f6a2";
ShortCodeToEmoji["ferris_wheel"] = "\U0001f3a1";
ShortCodeToEmoji["roller_coaster"] = "\U0001f3a2";
ShortCodeToEmoji["carousel_horse"] = "\U0001f3a0";
ShortCodeToEmoji["construction_site"] = "\U0001f3d7";
ShortCodeToEmoji["foggy"] = "\U0001f301";
ShortCodeToEmoji["tokyo_tower"] = "\U0001f5fc";
ShortCodeToEmoji["factory"] = "\U0001f3ed";
ShortCodeToEmoji["fountain"] = "\U000026f2";
ShortCodeToEmoji["rice_scene"] = "\U0001f391";
ShortCodeToEmoji["mountain"] = "\U000026f0";
ShortCodeToEmoji["mountain_snow"] = "\U0001f3d4";
ShortCodeToEmoji["mount_fuji"] = "\U0001f5fb";
ShortCodeToEmoji["volcano"] = "\U0001f30b";
ShortCodeToEmoji["japan"] = "\U0001f5fe";
ShortCodeToEmoji["camping"] = "\U0001f3d5";
ShortCodeToEmoji["tent"] = "\U000026fa";
ShortCodeToEmoji["park"] = "\U0001f3de";
ShortCodeToEmoji["motorway"] = "\U0001f6e3";
ShortCodeToEmoji["railway_track"] = "\U0001f6e4";
ShortCodeToEmoji["sunrise"] = "\U0001f305";
ShortCodeToEmoji["sunrise_over_mountains"] = "\U0001f304";
ShortCodeToEmoji["desert"] = "\U0001f3dc";
ShortCodeToEmoji["beach"] = "\U0001f3d6";
ShortCodeToEmoji["island"] = "\U0001f3dd";
ShortCodeToEmoji["city_sunset"] = "\U0001f307";
ShortCodeToEmoji["city_dusk"] = "\U0001f306";
ShortCodeToEmoji["cityscape"] = "\U0001f3d9";
ShortCodeToEmoji["night_with_stars"] = "\U0001f303";
ShortCodeToEmoji["bridge_at_night"] = "\U0001f309";
ShortCodeToEmoji["milky_way"] = "\U0001f30c";
ShortCodeToEmoji["stars"] = "\U0001f320";
ShortCodeToEmoji["sparkler"] = "\U0001f387";
ShortCodeToEmoji["fireworks"] = "\U0001f386";
ShortCodeToEmoji["rainbow"] = "\U0001f308";
ShortCodeToEmoji["homes"] = "\U0001f3d8";
ShortCodeToEmoji["european_castle"] = "\U0001f3f0";
ShortCodeToEmoji["japanese_castle"] = "\U0001f3ef";
ShortCodeToEmoji["stadium"] = "\U0001f3df";
ShortCodeToEmoji["statue_of_liberty"] = "\U0001f5fd";
ShortCodeToEmoji["house"] = "\U0001f3e0";
ShortCodeToEmoji["house_with_garden"] = "\U0001f3e1";
ShortCodeToEmoji["house_abandoned"] = "\U0001f3da";
ShortCodeToEmoji["office"] = "\U0001f3e2";
ShortCodeToEmoji["department_store"] = "\U0001f3ec";
ShortCodeToEmoji["post_office"] = "\U0001f3e3";
ShortCodeToEmoji["european_post_office"] = "\U0001f3e4";
ShortCodeToEmoji["hospital"] = "\U0001f3e5";
ShortCodeToEmoji["bank"] = "\U0001f3e6";
ShortCodeToEmoji["hotel"] = "\U0001f3e8";
ShortCodeToEmoji["convenience_store"] = "\U0001f3ea";
ShortCodeToEmoji["school"] = "\U0001f3eb";
ShortCodeToEmoji["love_hotel"] = "\U0001f3e9";
ShortCodeToEmoji["wedding"] = "\U0001f492";
ShortCodeToEmoji["classical_building"] = "\U0001f3db";
ShortCodeToEmoji["church"] = "\U000026ea";
ShortCodeToEmoji["mosque"] = "\U0001f54c";
ShortCodeToEmoji["synagogue"] = "\U0001f54d";
ShortCodeToEmoji["kaaba"] = "\U0001f54b";
ShortCodeToEmoji["shinto_shrine"] = "\U000026e9";
ShortCodeToEmoji["watch"] = "\U0000231a";
ShortCodeToEmoji["iphone"] = "\U0001f4f1";
ShortCodeToEmoji["calling"] = "\U0001f4f2";
ShortCodeToEmoji["computer"] = "\U0001f4bb";
ShortCodeToEmoji["keyboard"] = "\U00002328";
ShortCodeToEmoji["desktop"] = "\U0001f5a5";
ShortCodeToEmoji["printer"] = "\U0001f5a8";
ShortCodeToEmoji["mouse_three_button"] = "\U0001f5b1";
ShortCodeToEmoji["trackball"] = "\U0001f5b2";
ShortCodeToEmoji["joystick"] = "\U0001f579";
ShortCodeToEmoji["compression"] = "\U0001f5dc";
ShortCodeToEmoji["minidisc"] = "\U0001f4bd";
ShortCodeToEmoji["floppy_disk"] = "\U0001f4be";
ShortCodeToEmoji["cd"] = "\U0001f4bf";
ShortCodeToEmoji["dvd"] = "\U0001f4c0";
ShortCodeToEmoji["vhs"] = "\U0001f4fc";
ShortCodeToEmoji["camera"] = "\U0001f4f7";
ShortCodeToEmoji["camera_with_flash"] = "\U0001f4f8";
ShortCodeToEmoji["video_camera"] = "\U0001f4f9";
ShortCodeToEmoji["movie_camera"] = "\U0001f3a5";
ShortCodeToEmoji["projector"] = "\U0001f4fd";
ShortCodeToEmoji["film_frames"] = "\U0001f39e";
ShortCodeToEmoji["telephone_receiver"] = "\U0001f4de";
ShortCodeToEmoji["telephone"] = "\U0000260e";
ShortCodeToEmoji["pager"] = "\U0001f4df";
ShortCodeToEmoji["fax"] = "\U0001f4e0";
ShortCodeToEmoji["tv"] = "\U0001f4fa";
ShortCodeToEmoji["radio"] = "\U0001f4fb";
ShortCodeToEmoji["microphone2"] = "\U0001f399";
ShortCodeToEmoji["level_slider"] = "\U0001f39a";
ShortCodeToEmoji["control_knobs"] = "\U0001f39b";
ShortCodeToEmoji["stopwatch"] = "\U000023f1";
ShortCodeToEmoji["timer"] = "\U000023f2";
ShortCodeToEmoji["alarm_clock"] = "\U000023f0";
ShortCodeToEmoji["clock"] = "\U0001f570";
ShortCodeToEmoji["hourglass_flowing_sand"] = "\U000023f3";
ShortCodeToEmoji["hourglass"] = "\U0000231b";
ShortCodeToEmoji["satellite"] = "\U0001f4e1";
ShortCodeToEmoji["battery"] = "\U0001f50b";
ShortCodeToEmoji["electric_plug"] = "\U0001f50c";
ShortCodeToEmoji["bulb"] = "\U0001f4a1";
ShortCodeToEmoji["flashlight"] = "\U0001f526";
ShortCodeToEmoji["candle"] = "\U0001f56f";
ShortCodeToEmoji["wastebasket"] = "\U0001f5d1";
ShortCodeToEmoji["oil"] = "\U0001f6e2";
ShortCodeToEmoji["money_with_wings"] = "\U0001f4b8";
ShortCodeToEmoji["dollar"] = "\U0001f4b5";
ShortCodeToEmoji["yen"] = "\U0001f4b4";
ShortCodeToEmoji["euro"] = "\U0001f4b6";
ShortCodeToEmoji["pound"] = "\U0001f4b7";
ShortCodeToEmoji["moneybag"] = "\U0001f4b0";
ShortCodeToEmoji["credit_card"] = "\U0001f4b3";
ShortCodeToEmoji["gem"] = "\U0001f48e";
ShortCodeToEmoji["scales"] = "\U00002696";
ShortCodeToEmoji["wrench"] = "\U0001f527";
ShortCodeToEmoji["hammer"] = "\U0001f528";
ShortCodeToEmoji["hammer_pick"] = "\U00002692";
ShortCodeToEmoji["tools"] = "\U0001f6e0";
ShortCodeToEmoji["pick"] = "\U000026cf";
ShortCodeToEmoji["nut_and_bolt"] = "\U0001f529";
ShortCodeToEmoji["gear"] = "\U00002699";
ShortCodeToEmoji["chains"] = "\U000026d3";
ShortCodeToEmoji["gun"] = "\U0001f52b";
ShortCodeToEmoji["bomb"] = "\U0001f4a3";
ShortCodeToEmoji["knife"] = "\U0001f52a";
ShortCodeToEmoji["dagger"] = "\U0001f5e1";
ShortCodeToEmoji["crossed_swords"] = "\U00002694";
ShortCodeToEmoji["shield"] = "\U0001f6e1";
ShortCodeToEmoji["smoking"] = "\U0001f6ac";
ShortCodeToEmoji["skull_crossbones"] = "\U00002620";
ShortCodeToEmoji["coffin"] = "\U000026b0";
ShortCodeToEmoji["urn"] = "\U000026b1";
ShortCodeToEmoji["amphora"] = "\U0001f3fa";
ShortCodeToEmoji["crystal_ball"] = "\U0001f52e";
ShortCodeToEmoji["prayer_beads"] = "\U0001f4ff";
ShortCodeToEmoji["barber"] = "\U0001f488";
ShortCodeToEmoji["alembic"] = "\U00002697";
ShortCodeToEmoji["telescope"] = "\U0001f52d";
ShortCodeToEmoji["microscope"] = "\U0001f52c";
ShortCodeToEmoji["hole"] = "\U0001f573";
ShortCodeToEmoji["pill"] = "\U0001f48a";
ShortCodeToEmoji["syringe"] = "\U0001f489";
ShortCodeToEmoji["thermometer"] = "\U0001f321";
ShortCodeToEmoji["label"] = "\U0001f3f7";
ShortCodeToEmoji["bookmark"] = "\U0001f516";
ShortCodeToEmoji["toilet"] = "\U0001f6bd";
ShortCodeToEmoji["shower"] = "\U0001f6bf";
ShortCodeToEmoji["bathtub"] = "\U0001f6c1";
ShortCodeToEmoji["key"] = "\U0001f511";
ShortCodeToEmoji["key2"] = "\U0001f5dd";
ShortCodeToEmoji["couch"] = "\U0001f6cb";
ShortCodeToEmoji["sleeping_accommodation"] = "\U0001f6cc";
ShortCodeToEmoji["bed"] = "\U0001f6cf";
ShortCodeToEmoji["door"] = "\U0001f6aa";
ShortCodeToEmoji["bellhop"] = "\U0001f6ce";
ShortCodeToEmoji["frame_photo"] = "\U0001f5bc";
ShortCodeToEmoji["map"] = "\U0001f5fa";
ShortCodeToEmoji["beach_umbrella"] = "\U000026f1";
ShortCodeToEmoji["moyai"] = "\U0001f5ff";
ShortCodeToEmoji["shopping_bags"] = "\U0001f6cd";
ShortCodeToEmoji["balloon"] = "\U0001f388";
ShortCodeToEmoji["flags"] = "\U0001f38f";
ShortCodeToEmoji["ribbon"] = "\U0001f380";
ShortCodeToEmoji["gift"] = "\U0001f381";
ShortCodeToEmoji["confetti_ball"] = "\U0001f38a";
ShortCodeToEmoji["tada"] = "\U0001f389";
ShortCodeToEmoji["dolls"] = "\U0001f38e";
ShortCodeToEmoji["wind_chime"] = "\U0001f390";
ShortCodeToEmoji["crossed_flags"] = "\U0001f38c";
ShortCodeToEmoji["izakaya_lantern"] = "\U0001f3ee";
ShortCodeToEmoji["envelope"] = "\U00002709";
ShortCodeToEmoji["envelope_with_arrow"] = "\U0001f4e9";
ShortCodeToEmoji["incoming_envelope"] = "\U0001f4e8";
ShortCodeToEmoji["e-mail"] = "\U0001f4e7";
ShortCodeToEmoji["love_letter"] = "\U0001f48c";
ShortCodeToEmoji["postbox"] = "\U0001f4ee";
ShortCodeToEmoji["mailbox_closed"] = "\U0001f4ea";
ShortCodeToEmoji["mailbox"] = "\U0001f4eb";
ShortCodeToEmoji["mailbox_with_mail"] = "\U0001f4ec";
ShortCodeToEmoji["mailbox_with_no_mail"] = "\U0001f4ed";
ShortCodeToEmoji["package"] = "\U0001f4e6";
ShortCodeToEmoji["postal_horn"] = "\U0001f4ef";
ShortCodeToEmoji["inbox_tray"] = "\U0001f4e5";
ShortCodeToEmoji["outbox_tray"] = "\U0001f4e4";
ShortCodeToEmoji["scroll"] = "\U0001f4dc";
ShortCodeToEmoji["page_with_curl"] = "\U0001f4c3";
ShortCodeToEmoji["bookmark_tabs"] = "\U0001f4d1";
ShortCodeToEmoji["bar_chart"] = "\U0001f4ca";
ShortCodeToEmoji["chart_with_upwards_trend"] = "\U0001f4c8";
ShortCodeToEmoji["chart_with_downwards_trend"] = "\U0001f4c9";
ShortCodeToEmoji["page_facing_up"] = "\U0001f4c4";
ShortCodeToEmoji["date"] = "\U0001f4c5";
ShortCodeToEmoji["calendar"] = "\U0001f4c6";
ShortCodeToEmoji["calendar_spiral"] = "\U0001f5d3";
ShortCodeToEmoji["card_index"] = "\U0001f4c7";
ShortCodeToEmoji["card_box"] = "\U0001f5c3";
ShortCodeToEmoji["ballot_box"] = "\U0001f5f3";
ShortCodeToEmoji["file_cabinet"] = "\U0001f5c4";
ShortCodeToEmoji["clipboard"] = "\U0001f4cb";
ShortCodeToEmoji["notepad_spiral"] = "\U0001f5d2";
ShortCodeToEmoji["file_folder"] = "\U0001f4c1";
ShortCodeToEmoji["open_file_folder"] = "\U0001f4c2";
ShortCodeToEmoji["dividers"] = "\U0001f5c2";
ShortCodeToEmoji["newspaper2"] = "\U0001f5de";
ShortCodeToEmoji["newspaper"] = "\U0001f4f0";
ShortCodeToEmoji["notebook"] = "\U0001f4d3";
ShortCodeToEmoji["closed_book"] = "\U0001f4d5";
ShortCodeToEmoji["green_book"] = "\U0001f4d7";
ShortCodeToEmoji["blue_book"] = "\U0001f4d8";
ShortCodeToEmoji["orange_book"] = "\U0001f4d9";
ShortCodeToEmoji["notebook_with_decorative_cover"] = "\U0001f4d4";
ShortCodeToEmoji["ledger"] = "\U0001f4d2";
ShortCodeToEmoji["books"] = "\U0001f4da";
ShortCodeToEmoji["book"] = "\U0001f4d6";
ShortCodeToEmoji["link"] = "\U0001f517";
ShortCodeToEmoji["paperclip"] = "\U0001f4ce";
ShortCodeToEmoji["paperclips"] = "\U0001f587";
ShortCodeToEmoji["scissors"] = "\U00002702";
ShortCodeToEmoji["triangular_ruler"] = "\U0001f4d0";
ShortCodeToEmoji["straight_ruler"] = "\U0001f4cf";
ShortCodeToEmoji["pushpin"] = "\U0001f4cc";
ShortCodeToEmoji["round_pushpin"] = "\U0001f4cd";
ShortCodeToEmoji["triangular_flag_on_post"] = "\U0001f6a9";
ShortCodeToEmoji["flag_white"] = "\U0001f3f3";
ShortCodeToEmoji["flag_black"] = "\U0001f3f4";
ShortCodeToEmoji["closed_lock_with_key"] = "\U0001f510";
ShortCodeToEmoji["lock"] = "\U0001f512";
ShortCodeToEmoji["unlock"] = "\U0001f513";
ShortCodeToEmoji["lock_with_ink_pen"] = "\U0001f50f";
ShortCodeToEmoji["pen_ballpoint"] = "\U0001f58a";
ShortCodeToEmoji["pen_fountain"] = "\U0001f58b";
ShortCodeToEmoji["black_nib"] = "\U00002712";
ShortCodeToEmoji["pencil"] = "\U0001f4dd";
ShortCodeToEmoji["pencil2"] = "\U0000270f";
ShortCodeToEmoji["crayon"] = "\U0001f58d";
ShortCodeToEmoji["paintbrush"] = "\U0001f58c";
ShortCodeToEmoji["mag"] = "\U0001f50d";
ShortCodeToEmoji["mag_right"] = "\U0001f50e";
ShortCodeToEmoji["heart"] = "\U00002764";
ShortCodeToEmoji["yellow_heart"] = "\U0001f49b";
ShortCodeToEmoji["green_heart"] = "\U0001f49a";
ShortCodeToEmoji["blue_heart"] = "\U0001f499";
ShortCodeToEmoji["purple_heart"] = "\U0001f49c";
ShortCodeToEmoji["broken_heart"] = "\U0001f494";
ShortCodeToEmoji["heart_exclamation"] = "\U00002763";
ShortCodeToEmoji["two_hearts"] = "\U0001f495";
ShortCodeToEmoji["revolving_hearts"] = "\U0001f49e";
ShortCodeToEmoji["heartbeat"] = "\U0001f493";
ShortCodeToEmoji["heartpulse"] = "\U0001f497";
ShortCodeToEmoji["sparkling_heart"] = "\U0001f496";
ShortCodeToEmoji["cupid"] = "\U0001f498";
ShortCodeToEmoji["gift_heart"] = "\U0001f49d";
ShortCodeToEmoji["heart_decoration"] = "\U0001f49f";
ShortCodeToEmoji["peace"] = "\U0000262e";
ShortCodeToEmoji["cross"] = "\U0000271d";
ShortCodeToEmoji["star_and_crescent"] = "\U0000262a";
ShortCodeToEmoji["om_symbol"] = "\U0001f549";
ShortCodeToEmoji["wheel_of_dharma"] = "\U00002638";
ShortCodeToEmoji["star_of_david"] = "\U00002721";
ShortCodeToEmoji["six_pointed_star"] = "\U0001f52f";
ShortCodeToEmoji["menorah"] = "\U0001f54e";
ShortCodeToEmoji["yin_yang"] = "\U0000262f";
ShortCodeToEmoji["orthodox_cross"] = "\U00002626";
ShortCodeToEmoji["place_of_worship"] = "\U0001f6d0";
ShortCodeToEmoji["ophiuchus"] = "\U000026ce";
ShortCodeToEmoji["aries"] = "\U00002648";
ShortCodeToEmoji["taurus"] = "\U00002649";
ShortCodeToEmoji["gemini"] = "\U0000264a";
ShortCodeToEmoji["cancer"] = "\U0000264b";
ShortCodeToEmoji["leo"] = "\U0000264c";
ShortCodeToEmoji["virgo"] = "\U0000264d";
ShortCodeToEmoji["libra"] = "\U0000264e";
ShortCodeToEmoji["scorpius"] = "\U0000264f";
ShortCodeToEmoji["sagittarius"] = "\U00002650";
ShortCodeToEmoji["capricorn"] = "\U00002651";
ShortCodeToEmoji["aquarius"] = "\U00002652";
ShortCodeToEmoji["pisces"] = "\U00002653";
ShortCodeToEmoji["id"] = "\U0001f194";
ShortCodeToEmoji["atom"] = "\U0000269b";
ShortCodeToEmoji["u7a7a"] = "\U0001f233";
ShortCodeToEmoji["u5272"] = "\U0001f239";
ShortCodeToEmoji["radioactive"] = "\U00002622";
ShortCodeToEmoji["biohazard"] = "\U00002623";
ShortCodeToEmoji["mobile_phone_off"] = "\U0001f4f4";
ShortCodeToEmoji["vibration_mode"] = "\U0001f4f3";
ShortCodeToEmoji["u6709"] = "\U0001f236";
ShortCodeToEmoji["u7121"] = "\U0001f21a";
ShortCodeToEmoji["u7533"] = "\U0001f238";
ShortCodeToEmoji["u55b6"] = "\U0001f23a";
ShortCodeToEmoji["u6708"] = "\U0001f237";
ShortCodeToEmoji["eight_pointed_black_star"] = "\U00002734";
ShortCodeToEmoji["vs"] = "\U0001f19a";
ShortCodeToEmoji["accept"] = "\U0001f251";
ShortCodeToEmoji["white_flower"] = "\U0001f4ae";
ShortCodeToEmoji["ideograph_advantage"] = "\U0001f250";
ShortCodeToEmoji["secret"] = "\U00003299";
ShortCodeToEmoji["congratulations"] = "\U00003297";
ShortCodeToEmoji["u5408"] = "\U0001f234";
ShortCodeToEmoji["u6e80"] = "\U0001f235";
ShortCodeToEmoji["u7981"] = "\U0001f232";
ShortCodeToEmoji["a"] = "\U0001f170";
ShortCodeToEmoji["b"] = "\U0001f171";
ShortCodeToEmoji["ab"] = "\U0001f18e";
ShortCodeToEmoji["cl"] = "\U0001f191";
ShortCodeToEmoji["o2"] = "\U0001f17e";
ShortCodeToEmoji["sos"] = "\U0001f198";
ShortCodeToEmoji["no_entry"] = "\U000026d4";
ShortCodeToEmoji["name_badge"] = "\U0001f4db";
ShortCodeToEmoji["no_entry_sign"] = "\U0001f6ab";
ShortCodeToEmoji["x"] = "\U0000274c";
ShortCodeToEmoji["o"] = "\U00002b55";
ShortCodeToEmoji["anger"] = "\U0001f4a2";
ShortCodeToEmoji["hotsprings"] = "\U00002668";
ShortCodeToEmoji["no_pedestrians"] = "\U0001f6b7";
ShortCodeToEmoji["do_not_litter"] = "\U0001f6af";
ShortCodeToEmoji["no_bicycles"] = "\U0001f6b3";
ShortCodeToEmoji["non-potable_water"] = "\U0001f6b1";
ShortCodeToEmoji["underage"] = "\U0001f51e";
ShortCodeToEmoji["no_mobile_phones"] = "\U0001f4f5";
ShortCodeToEmoji["exclamation"] = "\U00002757";
ShortCodeToEmoji["grey_exclamation"] = "\U00002755";
ShortCodeToEmoji["question"] = "\U00002753";
ShortCodeToEmoji["grey_question"] = "\U00002754";
ShortCodeToEmoji["bangbang"] = "\U0000203c";
ShortCodeToEmoji["interrobang"] = "\U00002049";
ShortCodeToEmoji["low_brightness"] = "\U0001f505";
ShortCodeToEmoji["high_brightness"] = "\U0001f506";
ShortCodeToEmoji["trident"] = "\U0001f531";
ShortCodeToEmoji["fleur-de-lis"] = "\U0000269c";
ShortCodeToEmoji["part_alternation_mark"] = "\U0000303d";
ShortCodeToEmoji["warning"] = "\U000026a0";
ShortCodeToEmoji["children_crossing"] = "\U0001f6b8";
ShortCodeToEmoji["beginner"] = "\U0001f530";
ShortCodeToEmoji["recycle"] = "\U0000267b";
ShortCodeToEmoji["u6307"] = "\U0001f22f";
ShortCodeToEmoji["chart"] = "\U0001f4b9";
ShortCodeToEmoji["sparkle"] = "\U00002747";
ShortCodeToEmoji["eight_spoked_asterisk"] = "\U00002733";
ShortCodeToEmoji["negative_squared_cross_mark"] = "\U0000274e";
ShortCodeToEmoji["white_check_mark"] = "\U00002705";
ShortCodeToEmoji["diamond_shape_with_a_dot_inside"] = "\U0001f4a0";
ShortCodeToEmoji["cyclone"] = "\U0001f300";
ShortCodeToEmoji["loop"] = "\U000027bf";
ShortCodeToEmoji["globe_with_meridians"] = "\U0001f310";
ShortCodeToEmoji["m"] = "\U000024c2";
ShortCodeToEmoji["atm"] = "\U0001f3e7";
ShortCodeToEmoji["sa"] = "\U0001f202";
ShortCodeToEmoji["passport_control"] = "\U0001f6c2";
ShortCodeToEmoji["customs"] = "\U0001f6c3";
ShortCodeToEmoji["baggage_claim"] = "\U0001f6c4";
ShortCodeToEmoji["left_luggage"] = "\U0001f6c5";
ShortCodeToEmoji["wheelchair"] = "\U0000267f";
ShortCodeToEmoji["no_smoking"] = "\U0001f6ad";
ShortCodeToEmoji["wc"] = "\U0001f6be";
ShortCodeToEmoji["parking"] = "\U0001f17f";
ShortCodeToEmoji["potable_water"] = "\U0001f6b0";
ShortCodeToEmoji["mens"] = "\U0001f6b9";
ShortCodeToEmoji["womens"] = "\U0001f6ba";
ShortCodeToEmoji["baby_symbol"] = "\U0001f6bc";
ShortCodeToEmoji["restroom"] = "\U0001f6bb";
ShortCodeToEmoji["put_litter_in_its_place"] = "\U0001f6ae";
ShortCodeToEmoji["cinema"] = "\U0001f3a6";
ShortCodeToEmoji["signal_strength"] = "\U0001f4f6";
ShortCodeToEmoji["koko"] = "\U0001f201";
ShortCodeToEmoji["ng"] = "\U0001f196";
ShortCodeToEmoji["ok"] = "\U0001f197";
ShortCodeToEmoji["up"] = "\U0001f199";
ShortCodeToEmoji["cool"] = "\U0001f192";
ShortCodeToEmoji["new"] = "\U0001f195";
ShortCodeToEmoji["free"] = "\U0001f193";
ShortCodeToEmoji["zero"] = "\U00000030\U000020e3";
ShortCodeToEmoji["one"] = "\U00000031\U000020e3";
ShortCodeToEmoji["two"] = "\U00000032\U000020e3";
ShortCodeToEmoji["three"] = "\U00000033\U000020e3";
ShortCodeToEmoji["four"] = "\U00000034\U000020e3";
ShortCodeToEmoji["five"] = "\U00000035\U000020e3";
ShortCodeToEmoji["six"] = "\U00000036\U000020e3";
ShortCodeToEmoji["seven"] = "\U00000037\U000020e3";
ShortCodeToEmoji["eight"] = "\U00000038\U000020e3";
ShortCodeToEmoji["nine"] = "\U00000039\U000020e3";
ShortCodeToEmoji["keycap_ten"] = "\U0001f51f";
ShortCodeToEmoji["arrow_forward"] = "\U000025b6";
ShortCodeToEmoji["pause_button"] = "\U000023f8";
ShortCodeToEmoji["play_pause"] = "\U000023ef";
ShortCodeToEmoji["stop_button"] = "\U000023f9";
ShortCodeToEmoji["record_button"] = "\U000023fa";
ShortCodeToEmoji["track_next"] = "\U000023ed";
ShortCodeToEmoji["track_previous"] = "\U000023ee";
ShortCodeToEmoji["fast_forward"] = "\U000023e9";
ShortCodeToEmoji["rewind"] = "\U000023ea";
ShortCodeToEmoji["twisted_rightwards_arrows"] = "\U0001f500";
ShortCodeToEmoji["repeat"] = "\U0001f501";
ShortCodeToEmoji["repeat_one"] = "\U0001f502";
ShortCodeToEmoji["arrow_backward"] = "\U000025c0";
ShortCodeToEmoji["arrow_up_small"] = "\U0001f53c";
ShortCodeToEmoji["arrow_down_small"] = "\U0001f53d";
ShortCodeToEmoji["arrow_double_up"] = "\U000023eb";
ShortCodeToEmoji["arrow_double_down"] = "\U000023ec";
ShortCodeToEmoji["arrow_right"] = "\U000027a1";
ShortCodeToEmoji["arrow_left"] = "\U00002b05";
ShortCodeToEmoji["arrow_up"] = "\U00002b06";
ShortCodeToEmoji["arrow_down"] = "\U00002b07";
ShortCodeToEmoji["arrow_upper_right"] = "\U00002197";
ShortCodeToEmoji["arrow_lower_right"] = "\U00002198";
ShortCodeToEmoji["arrow_lower_left"] = "\U00002199";
ShortCodeToEmoji["arrow_upper_left"] = "\U00002196";
ShortCodeToEmoji["arrow_up_down"] = "\U00002195";
ShortCodeToEmoji["left_right_arrow"] = "\U00002194";
ShortCodeToEmoji["arrows_counterclockwise"] = "\U0001f504";
ShortCodeToEmoji["arrow_right_hook"] = "\U000021aa";
ShortCodeToEmoji["leftwards_arrow_with_hook"] = "\U000021a9";
ShortCodeToEmoji["arrow_heading_up"] = "\U00002934";
ShortCodeToEmoji["arrow_heading_down"] = "\U00002935";
ShortCodeToEmoji["hash"] = "\U00000023\U000020e3";
ShortCodeToEmoji["asterisk"] = "\U0000002a\U000020e3";
ShortCodeToEmoji["information_source"] = "\U00002139";
ShortCodeToEmoji["abc"] = "\U0001f524";
ShortCodeToEmoji["abcd"] = "\U0001f521";
ShortCodeToEmoji["capital_abcd"] = "\U0001f520";
ShortCodeToEmoji["symbols"] = "\U0001f523";
ShortCodeToEmoji["musical_note"] = "\U0001f3b5";
ShortCodeToEmoji["notes"] = "\U0001f3b6";
ShortCodeToEmoji["wavy_dash"] = "\U00003030";
ShortCodeToEmoji["curly_loop"] = "\U000027b0";
ShortCodeToEmoji["heavy_check_mark"] = "\U00002714";
ShortCodeToEmoji["arrows_clockwise"] = "\U0001f503";
ShortCodeToEmoji["heavy_plus_sign"] = "\U00002795";
ShortCodeToEmoji["heavy_minus_sign"] = "\U00002796";
ShortCodeToEmoji["heavy_division_sign"] = "\U00002797";
ShortCodeToEmoji["heavy_multiplication_x"] = "\U00002716";
ShortCodeToEmoji["heavy_dollar_sign"] = "\U0001f4b2";
ShortCodeToEmoji["currency_exchange"] = "\U0001f4b1";
ShortCodeToEmoji["copyright"] = "\U000000a9";
ShortCodeToEmoji["registered"] = "\U000000ae";
ShortCodeToEmoji["tm"] = "\U00002122";
ShortCodeToEmoji["end"] = "\U0001f51a";
ShortCodeToEmoji["back"] = "\U0001f519";
ShortCodeToEmoji["on"] = "\U0001f51b";
ShortCodeToEmoji["top"] = "\U0001f51d";
ShortCodeToEmoji["soon"] = "\U0001f51c";
ShortCodeToEmoji["ballot_box_with_check"] = "\U00002611";
ShortCodeToEmoji["radio_button"] = "\U0001f518";
ShortCodeToEmoji["white_circle"] = "\U000026aa";
ShortCodeToEmoji["black_circle"] = "\U000026ab";
ShortCodeToEmoji["red_circle"] = "\U0001f534";
ShortCodeToEmoji["large_blue_circle"] = "\U0001f535";
ShortCodeToEmoji["small_orange_diamond"] = "\U0001f538";
ShortCodeToEmoji["small_blue_diamond"] = "\U0001f539";
ShortCodeToEmoji["large_orange_diamond"] = "\U0001f536";
ShortCodeToEmoji["large_blue_diamond"] = "\U0001f537";
ShortCodeToEmoji["small_red_triangle"] = "\U0001f53a";
ShortCodeToEmoji["black_small_square"] = "\U000025aa";
ShortCodeToEmoji["white_small_square"] = "\U000025ab";
ShortCodeToEmoji["black_large_square"] = "\U00002b1b";
ShortCodeToEmoji["white_large_square"] = "\U00002b1c";
ShortCodeToEmoji["small_red_triangle_down"] = "\U0001f53b";
ShortCodeToEmoji["black_medium_square"] = "\U000025fc";
ShortCodeToEmoji["white_medium_square"] = "\U000025fb";
ShortCodeToEmoji["black_medium_small_square"] = "\U000025fe";
ShortCodeToEmoji["white_medium_small_square"] = "\U000025fd";
ShortCodeToEmoji["black_square_button"] = "\U0001f532";
ShortCodeToEmoji["white_square_button"] = "\U0001f533";
ShortCodeToEmoji["speaker"] = "\U0001f508";
ShortCodeToEmoji["sound"] = "\U0001f509";
ShortCodeToEmoji["loud_sound"] = "\U0001f50a";
ShortCodeToEmoji["mute"] = "\U0001f507";
ShortCodeToEmoji["mega"] = "\U0001f4e3";
ShortCodeToEmoji["loudspeaker"] = "\U0001f4e2";
ShortCodeToEmoji["bell"] = "\U0001f514";
ShortCodeToEmoji["no_bell"] = "\U0001f515";
ShortCodeToEmoji["black_joker"] = "\U0001f0cf";
ShortCodeToEmoji["mahjong"] = "\U0001f004";
ShortCodeToEmoji["spades"] = "\U00002660";
ShortCodeToEmoji["clubs"] = "\U00002663";
ShortCodeToEmoji["hearts"] = "\U00002665";
ShortCodeToEmoji["diamonds"] = "\U00002666";
ShortCodeToEmoji["flower_playing_cards"] = "\U0001f3b4";
ShortCodeToEmoji["thought_balloon"] = "\U0001f4ad";
ShortCodeToEmoji["anger_right"] = "\U0001f5ef";
ShortCodeToEmoji["speech_balloon"] = "\U0001f4ac";
ShortCodeToEmoji["clock1"] = "\U0001f550";
ShortCodeToEmoji["clock2"] = "\U0001f551";
ShortCodeToEmoji["clock3"] = "\U0001f552";
ShortCodeToEmoji["clock4"] = "\U0001f553";
ShortCodeToEmoji["clock5"] = "\U0001f554";
ShortCodeToEmoji["clock6"] = "\U0001f555";
ShortCodeToEmoji["clock7"] = "\U0001f556";
ShortCodeToEmoji["clock8"] = "\U0001f557";
ShortCodeToEmoji["clock9"] = "\U0001f558";
ShortCodeToEmoji["clock10"] = "\U0001f559";
ShortCodeToEmoji["clock11"] = "\U0001f55a";
ShortCodeToEmoji["clock12"] = "\U0001f55b";
ShortCodeToEmoji["clock130"] = "\U0001f55c";
ShortCodeToEmoji["clock230"] = "\U0001f55d";
ShortCodeToEmoji["clock330"] = "\U0001f55e";
ShortCodeToEmoji["clock430"] = "\U0001f55f";
ShortCodeToEmoji["clock530"] = "\U0001f560";
ShortCodeToEmoji["clock630"] = "\U0001f561";
ShortCodeToEmoji["clock730"] = "\U0001f562";
ShortCodeToEmoji["clock830"] = "\U0001f563";
ShortCodeToEmoji["clock930"] = "\U0001f564";
ShortCodeToEmoji["clock1030"] = "\U0001f565";
ShortCodeToEmoji["clock1130"] = "\U0001f566";
ShortCodeToEmoji["clock1230"] = "\U0001f567";
ShortCodeToEmoji["eye_in_speech_bubble"] = "\U0001f441\U0001f5e8";
ShortCodeToEmoji["flag_ac"] = "\U0001f1e6\U0001f1e8";
ShortCodeToEmoji["flag_af"] = "\U0001f1e6\U0001f1eb";
ShortCodeToEmoji["flag_al"] = "\U0001f1e6\U0001f1f1";
ShortCodeToEmoji["flag_dz"] = "\U0001f1e9\U0001f1ff";
ShortCodeToEmoji["flag_ad"] = "\U0001f1e6\U0001f1e9";
ShortCodeToEmoji["flag_ao"] = "\U0001f1e6\U0001f1f4";
ShortCodeToEmoji["flag_ai"] = "\U0001f1e6\U0001f1ee";
ShortCodeToEmoji["flag_ag"] = "\U0001f1e6\U0001f1ec";
ShortCodeToEmoji["flag_ar"] = "\U0001f1e6\U0001f1f7";
ShortCodeToEmoji["flag_am"] = "\U0001f1e6\U0001f1f2";
ShortCodeToEmoji["flag_aw"] = "\U0001f1e6\U0001f1fc";
ShortCodeToEmoji["flag_au"] = "\U0001f1e6\U0001f1fa";
ShortCodeToEmoji["flag_at"] = "\U0001f1e6\U0001f1f9";
ShortCodeToEmoji["flag_az"] = "\U0001f1e6\U0001f1ff";
ShortCodeToEmoji["flag_bs"] = "\U0001f1e7\U0001f1f8";
ShortCodeToEmoji["flag_bh"] = "\U0001f1e7\U0001f1ed";
ShortCodeToEmoji["flag_bd"] = "\U0001f1e7\U0001f1e9";
ShortCodeToEmoji["flag_bb"] = "\U0001f1e7\U0001f1e7";
ShortCodeToEmoji["flag_by"] = "\U0001f1e7\U0001f1fe";
ShortCodeToEmoji["flag_be"] = "\U0001f1e7\U0001f1ea";
ShortCodeToEmoji["flag_bz"] = "\U0001f1e7\U0001f1ff";
ShortCodeToEmoji["flag_bj"] = "\U0001f1e7\U0001f1ef";
ShortCodeToEmoji["flag_bm"] = "\U0001f1e7\U0001f1f2";
ShortCodeToEmoji["flag_bt"] = "\U0001f1e7\U0001f1f9";
ShortCodeToEmoji["flag_bo"] = "\U0001f1e7\U0001f1f4";
ShortCodeToEmoji["flag_ba"] = "\U0001f1e7\U0001f1e6";
ShortCodeToEmoji["flag_bw"] = "\U0001f1e7\U0001f1fc";
ShortCodeToEmoji["flag_br"] = "\U0001f1e7\U0001f1f7";
ShortCodeToEmoji["flag_bn"] = "\U0001f1e7\U0001f1f3";
ShortCodeToEmoji["flag_bg"] = "\U0001f1e7\U0001f1ec";
ShortCodeToEmoji["flag_bf"] = "\U0001f1e7\U0001f1eb";
ShortCodeToEmoji["flag_bi"] = "\U0001f1e7\U0001f1ee";
ShortCodeToEmoji["flag_cv"] = "\U0001f1e8\U0001f1fb";
ShortCodeToEmoji["flag_kh"] = "\U0001f1f0\U0001f1ed";
ShortCodeToEmoji["flag_cm"] = "\U0001f1e8\U0001f1f2";
ShortCodeToEmoji["flag_ca"] = "\U0001f1e8\U0001f1e6";
ShortCodeToEmoji["flag_ky"] = "\U0001f1f0\U0001f1fe";
ShortCodeToEmoji["flag_cf"] = "\U0001f1e8\U0001f1eb";
ShortCodeToEmoji["flag_td"] = "\U0001f1f9\U0001f1e9";
ShortCodeToEmoji["flag_cl"] = "\U0001f1e8\U0001f1f1";
ShortCodeToEmoji["flag_cn"] = "\U0001f1e8\U0001f1f3";
ShortCodeToEmoji["flag_co"] = "\U0001f1e8\U0001f1f4";
ShortCodeToEmoji["flag_km"] = "\U0001f1f0\U0001f1f2";
ShortCodeToEmoji["flag_cg"] = "\U0001f1e8\U0001f1ec";
ShortCodeToEmoji["flag_cd"] = "\U0001f1e8\U0001f1e9";
ShortCodeToEmoji["flag_cr"] = "\U0001f1e8\U0001f1f7";
ShortCodeToEmoji["flag_hr"] = "\U0001f1ed\U0001f1f7";
ShortCodeToEmoji["flag_cu"] = "\U0001f1e8\U0001f1fa";
ShortCodeToEmoji["flag_cy"] = "\U0001f1e8\U0001f1fe";
ShortCodeToEmoji["flag_cz"] = "\U0001f1e8\U0001f1ff";
ShortCodeToEmoji["flag_dk"] = "\U0001f1e9\U0001f1f0";
ShortCodeToEmoji["flag_dj"] = "\U0001f1e9\U0001f1ef";
ShortCodeToEmoji["flag_dm"] = "\U0001f1e9\U0001f1f2";
ShortCodeToEmoji["flag_do"] = "\U0001f1e9\U0001f1f4";
ShortCodeToEmoji["flag_ec"] = "\U0001f1ea\U0001f1e8";
ShortCodeToEmoji["flag_eg"] = "\U0001f1ea\U0001f1ec";
ShortCodeToEmoji["flag_sv"] = "\U0001f1f8\U0001f1fb";
ShortCodeToEmoji["flag_gq"] = "\U0001f1ec\U0001f1f6";
ShortCodeToEmoji["flag_er"] = "\U0001f1ea\U0001f1f7";
ShortCodeToEmoji["flag_ee"] = "\U0001f1ea\U0001f1ea";
ShortCodeToEmoji["flag_et"] = "\U0001f1ea\U0001f1f9";
ShortCodeToEmoji["flag_fk"] = "\U0001f1eb\U0001f1f0";
ShortCodeToEmoji["flag_fo"] = "\U0001f1eb\U0001f1f4";
ShortCodeToEmoji["flag_fj"] = "\U0001f1eb\U0001f1ef";
ShortCodeToEmoji["flag_fi"] = "\U0001f1eb\U0001f1ee";
ShortCodeToEmoji["flag_fr"] = "\U0001f1eb\U0001f1f7";
ShortCodeToEmoji["flag_pf"] = "\U0001f1f5\U0001f1eb";
ShortCodeToEmoji["flag_ga"] = "\U0001f1ec\U0001f1e6";
ShortCodeToEmoji["flag_gm"] = "\U0001f1ec\U0001f1f2";
ShortCodeToEmoji["flag_ge"] = "\U0001f1ec\U0001f1ea";
ShortCodeToEmoji["flag_de"] = "\U0001f1e9\U0001f1ea";
ShortCodeToEmoji["flag_gh"] = "\U0001f1ec\U0001f1ed";
ShortCodeToEmoji["flag_gi"] = "\U0001f1ec\U0001f1ee";
ShortCodeToEmoji["flag_gr"] = "\U0001f1ec\U0001f1f7";
ShortCodeToEmoji["flag_gl"] = "\U0001f1ec\U0001f1f1";
ShortCodeToEmoji["flag_gd"] = "\U0001f1ec\U0001f1e9";
ShortCodeToEmoji["flag_gu"] = "\U0001f1ec\U0001f1fa";
ShortCodeToEmoji["flag_gt"] = "\U0001f1ec\U0001f1f9";
ShortCodeToEmoji["flag_gn"] = "\U0001f1ec\U0001f1f3";
ShortCodeToEmoji["flag_gw"] = "\U0001f1ec\U0001f1fc";
ShortCodeToEmoji["flag_gy"] = "\U0001f1ec\U0001f1fe";
ShortCodeToEmoji["flag_ht"] = "\U0001f1ed\U0001f1f9";
ShortCodeToEmoji["flag_hn"] = "\U0001f1ed\U0001f1f3";
ShortCodeToEmoji["flag_hk"] = "\U0001f1ed\U0001f1f0";
ShortCodeToEmoji["flag_hu"] = "\U0001f1ed\U0001f1fa";
ShortCodeToEmoji["flag_is"] = "\U0001f1ee\U0001f1f8";
ShortCodeToEmoji["flag_in"] = "\U0001f1ee\U0001f1f3";
ShortCodeToEmoji["flag_id"] = "\U0001f1ee\U0001f1e9";
ShortCodeToEmoji["flag_ir"] = "\U0001f1ee\U0001f1f7";
ShortCodeToEmoji["flag_iq"] = "\U0001f1ee\U0001f1f6";
ShortCodeToEmoji["flag_ie"] = "\U0001f1ee\U0001f1ea";
ShortCodeToEmoji["flag_il"] = "\U0001f1ee\U0001f1f1";
ShortCodeToEmoji["flag_it"] = "\U0001f1ee\U0001f1f9";
ShortCodeToEmoji["flag_ci"] = "\U0001f1e8\U0001f1ee";
ShortCodeToEmoji["flag_jm"] = "\U0001f1ef\U0001f1f2";
ShortCodeToEmoji["flag_jp"] = "\U0001f1ef\U0001f1f5";
ShortCodeToEmoji["flag_je"] = "\U0001f1ef\U0001f1ea";
ShortCodeToEmoji["flag_jo"] = "\U0001f1ef\U0001f1f4";
ShortCodeToEmoji["flag_kz"] = "\U0001f1f0\U0001f1ff";
ShortCodeToEmoji["flag_ke"] = "\U0001f1f0\U0001f1ea";
ShortCodeToEmoji["flag_ki"] = "\U0001f1f0\U0001f1ee";
ShortCodeToEmoji["flag_xk"] = "\U0001f1fd\U0001f1f0";
ShortCodeToEmoji["flag_kw"] = "\U0001f1f0\U0001f1fc";
ShortCodeToEmoji["flag_kg"] = "\U0001f1f0\U0001f1ec";
ShortCodeToEmoji["flag_la"] = "\U0001f1f1\U0001f1e6";
ShortCodeToEmoji["flag_lv"] = "\U0001f1f1\U0001f1fb";
ShortCodeToEmoji["flag_lb"] = "\U0001f1f1\U0001f1e7";
ShortCodeToEmoji["flag_ls"] = "\U0001f1f1\U0001f1f8";
ShortCodeToEmoji["flag_lr"] = "\U0001f1f1\U0001f1f7";
ShortCodeToEmoji["flag_ly"] = "\U0001f1f1\U0001f1fe";
ShortCodeToEmoji["flag_li"] = "\U0001f1f1\U0001f1ee";
ShortCodeToEmoji["flag_lt"] = "\U0001f1f1\U0001f1f9";
ShortCodeToEmoji["flag_lu"] = "\U0001f1f1\U0001f1fa";
ShortCodeToEmoji["flag_mo"] = "\U0001f1f2\U0001f1f4";
ShortCodeToEmoji["flag_mk"] = "\U0001f1f2\U0001f1f0";
ShortCodeToEmoji["flag_mg"] = "\U0001f1f2\U0001f1ec";
ShortCodeToEmoji["flag_mw"] = "\U0001f1f2\U0001f1fc";
ShortCodeToEmoji["flag_my"] = "\U0001f1f2\U0001f1fe";
ShortCodeToEmoji["flag_mv"] = "\U0001f1f2\U0001f1fb";
ShortCodeToEmoji["flag_ml"] = "\U0001f1f2\U0001f1f1";
ShortCodeToEmoji["flag_mt"] = "\U0001f1f2\U0001f1f9";
ShortCodeToEmoji["flag_mh"] = "\U0001f1f2\U0001f1ed";
ShortCodeToEmoji["flag_mr"] = "\U0001f1f2\U0001f1f7";
ShortCodeToEmoji["flag_mu"] = "\U0001f1f2\U0001f1fa";
ShortCodeToEmoji["flag_mx"] = "\U0001f1f2\U0001f1fd";
ShortCodeToEmoji["flag_fm"] = "\U0001f1eb\U0001f1f2";
ShortCodeToEmoji["flag_md"] = "\U0001f1f2\U0001f1e9";
ShortCodeToEmoji["flag_mc"] = "\U0001f1f2\U0001f1e8";
ShortCodeToEmoji["flag_mn"] = "\U0001f1f2\U0001f1f3";
ShortCodeToEmoji["flag_me"] = "\U0001f1f2\U0001f1ea";
ShortCodeToEmoji["flag_ms"] = "\U0001f1f2\U0001f1f8";
ShortCodeToEmoji["flag_ma"] = "\U0001f1f2\U0001f1e6";
ShortCodeToEmoji["flag_mz"] = "\U0001f1f2\U0001f1ff";
ShortCodeToEmoji["flag_mm"] = "\U0001f1f2\U0001f1f2";
ShortCodeToEmoji["flag_na"] = "\U0001f1f3\U0001f1e6";
ShortCodeToEmoji["flag_nr"] = "\U0001f1f3\U0001f1f7";
ShortCodeToEmoji["flag_np"] = "\U0001f1f3\U0001f1f5";
ShortCodeToEmoji["flag_nl"] = "\U0001f1f3\U0001f1f1";
ShortCodeToEmoji["flag_nc"] = "\U0001f1f3\U0001f1e8";
ShortCodeToEmoji["flag_nz"] = "\U0001f1f3\U0001f1ff";
ShortCodeToEmoji["flag_ni"] = "\U0001f1f3\U0001f1ee";
ShortCodeToEmoji["flag_ne"] = "\U0001f1f3\U0001f1ea";
ShortCodeToEmoji["flag_ng"] = "\U0001f1f3\U0001f1ec";
ShortCodeToEmoji["flag_nu"] = "\U0001f1f3\U0001f1fa";
ShortCodeToEmoji["flag_kp"] = "\U0001f1f0\U0001f1f5";
ShortCodeToEmoji["flag_no"] = "\U0001f1f3\U0001f1f4";
ShortCodeToEmoji["flag_om"] = "\U0001f1f4\U0001f1f2";
ShortCodeToEmoji["flag_pk"] = "\U0001f1f5\U0001f1f0";
ShortCodeToEmoji["flag_pw"] = "\U0001f1f5\U0001f1fc";
ShortCodeToEmoji["flag_ps"] = "\U0001f1f5\U0001f1f8";
ShortCodeToEmoji["flag_pa"] = "\U0001f1f5\U0001f1e6";
ShortCodeToEmoji["flag_pg"] = "\U0001f1f5\U0001f1ec";
ShortCodeToEmoji["flag_py"] = "\U0001f1f5\U0001f1fe";
ShortCodeToEmoji["flag_pe"] = "\U0001f1f5\U0001f1ea";
ShortCodeToEmoji["flag_ph"] = "\U0001f1f5\U0001f1ed";
ShortCodeToEmoji["flag_pl"] = "\U0001f1f5\U0001f1f1";
ShortCodeToEmoji["flag_pt"] = "\U0001f1f5\U0001f1f9";
ShortCodeToEmoji["flag_pr"] = "\U0001f1f5\U0001f1f7";
ShortCodeToEmoji["flag_qa"] = "\U0001f1f6\U0001f1e6";
ShortCodeToEmoji["flag_ro"] = "\U0001f1f7\U0001f1f4";
ShortCodeToEmoji["flag_ru"] = "\U0001f1f7\U0001f1fa";
ShortCodeToEmoji["flag_rw"] = "\U0001f1f7\U0001f1fc";
ShortCodeToEmoji["flag_sh"] = "\U0001f1f8\U0001f1ed";
ShortCodeToEmoji["flag_kn"] = "\U0001f1f0\U0001f1f3";
ShortCodeToEmoji["flag_lc"] = "\U0001f1f1\U0001f1e8";
ShortCodeToEmoji["flag_vc"] = "\U0001f1fb\U0001f1e8";
ShortCodeToEmoji["flag_ws"] = "\U0001f1fc\U0001f1f8";
ShortCodeToEmoji["flag_sm"] = "\U0001f1f8\U0001f1f2";
ShortCodeToEmoji["flag_st"] = "\U0001f1f8\U0001f1f9";
ShortCodeToEmoji["flag_sa"] = "\U0001f1f8\U0001f1e6";
ShortCodeToEmoji["flag_sn"] = "\U0001f1f8\U0001f1f3";
ShortCodeToEmoji["flag_rs"] = "\U0001f1f7\U0001f1f8";
ShortCodeToEmoji["flag_sc"] = "\U0001f1f8\U0001f1e8";
ShortCodeToEmoji["flag_sl"] = "\U0001f1f8\U0001f1f1";
ShortCodeToEmoji["flag_sg"] = "\U0001f1f8\U0001f1ec";
ShortCodeToEmoji["flag_sk"] = "\U0001f1f8\U0001f1f0";
ShortCodeToEmoji["flag_si"] = "\U0001f1f8\U0001f1ee";
ShortCodeToEmoji["flag_sb"] = "\U0001f1f8\U0001f1e7";
ShortCodeToEmoji["flag_so"] = "\U0001f1f8\U0001f1f4";
ShortCodeToEmoji["flag_za"] = "\U0001f1ff\U0001f1e6";
ShortCodeToEmoji["flag_kr"] = "\U0001f1f0\U0001f1f7";
ShortCodeToEmoji["flag_es"] = "\U0001f1ea\U0001f1f8";
ShortCodeToEmoji["flag_lk"] = "\U0001f1f1\U0001f1f0";
ShortCodeToEmoji["flag_sd"] = "\U0001f1f8\U0001f1e9";
ShortCodeToEmoji["flag_sr"] = "\U0001f1f8\U0001f1f7";
ShortCodeToEmoji["flag_sz"] = "\U0001f1f8\U0001f1ff";
ShortCodeToEmoji["flag_se"] = "\U0001f1f8\U0001f1ea";
ShortCodeToEmoji["flag_ch"] = "\U0001f1e8\U0001f1ed";
ShortCodeToEmoji["flag_sy"] = "\U0001f1f8\U0001f1fe";
ShortCodeToEmoji["flag_tw"] = "\U0001f1f9\U0001f1fc";
ShortCodeToEmoji["flag_tj"] = "\U0001f1f9\U0001f1ef";
ShortCodeToEmoji["flag_tz"] = "\U0001f1f9\U0001f1ff";
ShortCodeToEmoji["flag_th"] = "\U0001f1f9\U0001f1ed";
ShortCodeToEmoji["flag_tl"] = "\U0001f1f9\U0001f1f1";
ShortCodeToEmoji["flag_tg"] = "\U0001f1f9\U0001f1ec";
ShortCodeToEmoji["flag_to"] = "\U0001f1f9\U0001f1f4";
ShortCodeToEmoji["flag_tt"] = "\U0001f1f9\U0001f1f9";
ShortCodeToEmoji["flag_tn"] = "\U0001f1f9\U0001f1f3";
ShortCodeToEmoji["flag_tr"] = "\U0001f1f9\U0001f1f7";
ShortCodeToEmoji["flag_tm"] = "\U0001f1f9\U0001f1f2";
ShortCodeToEmoji["flag_tv"] = "\U0001f1f9\U0001f1fb";
ShortCodeToEmoji["flag_ug"] = "\U0001f1fa\U0001f1ec";
ShortCodeToEmoji["flag_ua"] = "\U0001f1fa\U0001f1e6";
ShortCodeToEmoji["flag_ae"] = "\U0001f1e6\U0001f1ea";
ShortCodeToEmoji["flag_gb"] = "\U0001f1ec\U0001f1e7";
ShortCodeToEmoji["flag_us"] = "\U0001f1fa\U0001f1f8";
ShortCodeToEmoji["flag_vi"] = "\U0001f1fb\U0001f1ee";
ShortCodeToEmoji["flag_uy"] = "\U0001f1fa\U0001f1fe";
ShortCodeToEmoji["flag_uz"] = "\U0001f1fa\U0001f1ff";
ShortCodeToEmoji["flag_vu"] = "\U0001f1fb\U0001f1fa";
ShortCodeToEmoji["flag_va"] = "\U0001f1fb\U0001f1e6";
ShortCodeToEmoji["flag_ve"] = "\U0001f1fb\U0001f1ea";
ShortCodeToEmoji["flag_vn"] = "\U0001f1fb\U0001f1f3";
ShortCodeToEmoji["flag_wf"] = "\U0001f1fc\U0001f1eb";
ShortCodeToEmoji["flag_eh"] = "\U0001f1ea\U0001f1ed";
ShortCodeToEmoji["flag_ye"] = "\U0001f1fe\U0001f1ea";
ShortCodeToEmoji["flag_zm"] = "\U0001f1ff\U0001f1f2";
ShortCodeToEmoji["flag_zw"] = "\U0001f1ff\U0001f1fc";
ShortCodeToEmoji["flag_re"] = "\U0001f1f7\U0001f1ea";
ShortCodeToEmoji["flag_ax"] = "\U0001f1e6\U0001f1fd";
ShortCodeToEmoji["flag_ta"] = "\U0001f1f9\U0001f1e6";
ShortCodeToEmoji["flag_io"] = "\U0001f1ee\U0001f1f4";
ShortCodeToEmoji["flag_bq"] = "\U0001f1e7\U0001f1f6";
ShortCodeToEmoji["flag_cx"] = "\U0001f1e8\U0001f1fd";
ShortCodeToEmoji["flag_cc"] = "\U0001f1e8\U0001f1e8";
ShortCodeToEmoji["flag_gg"] = "\U0001f1ec\U0001f1ec";
ShortCodeToEmoji["flag_im"] = "\U0001f1ee\U0001f1f2";
ShortCodeToEmoji["flag_yt"] = "\U0001f1fe\U0001f1f9";
ShortCodeToEmoji["flag_nf"] = "\U0001f1f3\U0001f1eb";
ShortCodeToEmoji["flag_pn"] = "\U0001f1f5\U0001f1f3";
ShortCodeToEmoji["flag_bl"] = "\U0001f1e7\U0001f1f1";
ShortCodeToEmoji["flag_pm"] = "\U0001f1f5\U0001f1f2";
ShortCodeToEmoji["flag_gs"] = "\U0001f1ec\U0001f1f8";
ShortCodeToEmoji["flag_tk"] = "\U0001f1f9\U0001f1f0";
ShortCodeToEmoji["flag_bv"] = "\U0001f1e7\U0001f1fb";
ShortCodeToEmoji["flag_hm"] = "\U0001f1ed\U0001f1f2";
ShortCodeToEmoji["flag_sj"] = "\U0001f1f8\U0001f1ef";
ShortCodeToEmoji["flag_um"] = "\U0001f1fa\U0001f1f2";
ShortCodeToEmoji["flag_ic"] = "\U0001f1ee\U0001f1e8";
ShortCodeToEmoji["flag_ea"] = "\U0001f1ea\U0001f1e6";
ShortCodeToEmoji["flag_cp"] = "\U0001f1e8\U0001f1f5";
ShortCodeToEmoji["flag_dg"] = "\U0001f1e9\U0001f1ec";
ShortCodeToEmoji["flag_as"] = "\U0001f1e6\U0001f1f8";
ShortCodeToEmoji["flag_aq"] = "\U0001f1e6\U0001f1f6";
ShortCodeToEmoji["flag_vg"] = "\U0001f1fb\U0001f1ec";
ShortCodeToEmoji["flag_ck"] = "\U0001f1e8\U0001f1f0";
ShortCodeToEmoji["flag_cw"] = "\U0001f1e8\U0001f1fc";
ShortCodeToEmoji["flag_eu"] = "\U0001f1ea\U0001f1fa";
ShortCodeToEmoji["flag_gf"] = "\U0001f1ec\U0001f1eb";
ShortCodeToEmoji["flag_tf"] = "\U0001f1f9\U0001f1eb";
ShortCodeToEmoji["flag_gp"] = "\U0001f1ec\U0001f1f5";
ShortCodeToEmoji["flag_mq"] = "\U0001f1f2\U0001f1f6";
ShortCodeToEmoji["flag_mp"] = "\U0001f1f2\U0001f1f5";
ShortCodeToEmoji["flag_sx"] = "\U0001f1f8\U0001f1fd";
ShortCodeToEmoji["flag_ss"] = "\U0001f1f8\U0001f1f8";
ShortCodeToEmoji["flag_tc"] = "\U0001f1f9\U0001f1e8";
ShortCodeToEmoji["flag_mf"] = "\U0001f1f2\U0001f1eb";
ShortCodeToEmoji["raised_hands_tone1"] = "\U0001f64c\U0001f3fb";
ShortCodeToEmoji["raised_hands_tone2"] = "\U0001f64c\U0001f3fc";
ShortCodeToEmoji["raised_hands_tone3"] = "\U0001f64c\U0001f3fd";
ShortCodeToEmoji["raised_hands_tone4"] = "\U0001f64c\U0001f3fe";
ShortCodeToEmoji["raised_hands_tone5"] = "\U0001f64c\U0001f3ff";
ShortCodeToEmoji["clap_tone1"] = "\U0001f44f\U0001f3fb";
ShortCodeToEmoji["clap_tone2"] = "\U0001f44f\U0001f3fc";
ShortCodeToEmoji["clap_tone3"] = "\U0001f44f\U0001f3fd";
ShortCodeToEmoji["clap_tone4"] = "\U0001f44f\U0001f3fe";
ShortCodeToEmoji["clap_tone5"] = "\U0001f44f\U0001f3ff";
ShortCodeToEmoji["wave_tone1"] = "\U0001f44b\U0001f3fb";
ShortCodeToEmoji["wave_tone2"] = "\U0001f44b\U0001f3fc";
ShortCodeToEmoji["wave_tone3"] = "\U0001f44b\U0001f3fd";
ShortCodeToEmoji["wave_tone4"] = "\U0001f44b\U0001f3fe";
ShortCodeToEmoji["wave_tone5"] = "\U0001f44b\U0001f3ff";
ShortCodeToEmoji["thumbsup_tone1"] = "\U0001f44d\U0001f3fb";
ShortCodeToEmoji["thumbsup_tone2"] = "\U0001f44d\U0001f3fc";
ShortCodeToEmoji["thumbsup_tone3"] = "\U0001f44d\U0001f3fd";
ShortCodeToEmoji["thumbsup_tone4"] = "\U0001f44d\U0001f3fe";
ShortCodeToEmoji["thumbsup_tone5"] = "\U0001f44d\U0001f3ff";
ShortCodeToEmoji["thumbsdown_tone1"] = "\U0001f44e\U0001f3fb";
ShortCodeToEmoji["thumbsdown_tone2"] = "\U0001f44e\U0001f3fc";
ShortCodeToEmoji["thumbsdown_tone3"] = "\U0001f44e\U0001f3fd";
ShortCodeToEmoji["thumbsdown_tone4"] = "\U0001f44e\U0001f3fe";
ShortCodeToEmoji["thumbsdown_tone5"] = "\U0001f44e\U0001f3ff";
ShortCodeToEmoji["punch_tone1"] = "\U0001f44a\U0001f3fb";
ShortCodeToEmoji["punch_tone2"] = "\U0001f44a\U0001f3fc";
ShortCodeToEmoji["punch_tone3"] = "\U0001f44a\U0001f3fd";
ShortCodeToEmoji["punch_tone4"] = "\U0001f44a\U0001f3fe";
ShortCodeToEmoji["punch_tone5"] = "\U0001f44a\U0001f3ff";
ShortCodeToEmoji["fist_tone1"] = "\U0000270a\U0001f3fb";
ShortCodeToEmoji["fist_tone2"] = "\U0000270a\U0001f3fc";
ShortCodeToEmoji["fist_tone3"] = "\U0000270a\U0001f3fd";
ShortCodeToEmoji["fist_tone4"] = "\U0000270a\U0001f3fe";
ShortCodeToEmoji["fist_tone5"] = "\U0000270a\U0001f3ff";
ShortCodeToEmoji["v_tone1"] = "\U0000270c\U0001f3fb";
ShortCodeToEmoji["v_tone2"] = "\U0000270c\U0001f3fc";
ShortCodeToEmoji["v_tone3"] = "\U0000270c\U0001f3fd";
ShortCodeToEmoji["v_tone4"] = "\U0000270c\U0001f3fe";
ShortCodeToEmoji["v_tone5"] = "\U0000270c\U0001f3ff";
ShortCodeToEmoji["ok_hand_tone1"] = "\U0001f44c\U0001f3fb";
ShortCodeToEmoji["ok_hand_tone2"] = "\U0001f44c\U0001f3fc";
ShortCodeToEmoji["ok_hand_tone3"] = "\U0001f44c\U0001f3fd";
ShortCodeToEmoji["ok_hand_tone4"] = "\U0001f44c\U0001f3fe";
ShortCodeToEmoji["ok_hand_tone5"] = "\U0001f44c\U0001f3ff";
ShortCodeToEmoji["raised_hand_tone1"] = "\U0000270b\U0001f3fb";
ShortCodeToEmoji["raised_hand_tone2"] = "\U0000270b\U0001f3fc";
ShortCodeToEmoji["raised_hand_tone3"] = "\U0000270b\U0001f3fd";
ShortCodeToEmoji["raised_hand_tone4"] = "\U0000270b\U0001f3fe";
ShortCodeToEmoji["raised_hand_tone5"] = "\U0000270b\U0001f3ff";
ShortCodeToEmoji["open_hands_tone1"] = "\U0001f450\U0001f3fb";
ShortCodeToEmoji["open_hands_tone2"] = "\U0001f450\U0001f3fc";
ShortCodeToEmoji["open_hands_tone3"] = "\U0001f450\U0001f3fd";
ShortCodeToEmoji["open_hands_tone4"] = "\U0001f450\U0001f3fe";
ShortCodeToEmoji["open_hands_tone5"] = "\U0001f450\U0001f3ff";
ShortCodeToEmoji["muscle_tone1"] = "\U0001f4aa\U0001f3fb";
ShortCodeToEmoji["muscle_tone2"] = "\U0001f4aa\U0001f3fc";
ShortCodeToEmoji["muscle_tone3"] = "\U0001f4aa\U0001f3fd";
ShortCodeToEmoji["muscle_tone4"] = "\U0001f4aa\U0001f3fe";
ShortCodeToEmoji["muscle_tone5"] = "\U0001f4aa\U0001f3ff";
ShortCodeToEmoji["pray_tone1"] = "\U0001f64f\U0001f3fb";
ShortCodeToEmoji["pray_tone2"] = "\U0001f64f\U0001f3fc";
ShortCodeToEmoji["pray_tone3"] = "\U0001f64f\U0001f3fd";
ShortCodeToEmoji["pray_tone4"] = "\U0001f64f\U0001f3fe";
ShortCodeToEmoji["pray_tone5"] = "\U0001f64f\U0001f3ff";
ShortCodeToEmoji["point_up_tone1"] = "\U0000261d\U0001f3fb";
ShortCodeToEmoji["point_up_tone2"] = "\U0000261d\U0001f3fc";
ShortCodeToEmoji["point_up_tone3"] = "\U0000261d\U0001f3fd";
ShortCodeToEmoji["point_up_tone4"] = "\U0000261d\U0001f3fe";
ShortCodeToEmoji["point_up_tone5"] = "\U0000261d\U0001f3ff";
ShortCodeToEmoji["point_up_2_tone1"] = "\U0001f446\U0001f3fb";
ShortCodeToEmoji["point_up_2_tone2"] = "\U0001f446\U0001f3fc";
ShortCodeToEmoji["point_up_2_tone3"] = "\U0001f446\U0001f3fd";
ShortCodeToEmoji["point_up_2_tone4"] = "\U0001f446\U0001f3fe";
ShortCodeToEmoji["point_up_2_tone5"] = "\U0001f446\U0001f3ff";
ShortCodeToEmoji["point_down_tone1"] = "\U0001f447\U0001f3fb";
ShortCodeToEmoji["point_down_tone2"] = "\U0001f447\U0001f3fc";
ShortCodeToEmoji["point_down_tone3"] = "\U0001f447\U0001f3fd";
ShortCodeToEmoji["point_down_tone4"] = "\U0001f447\U0001f3fe";
ShortCodeToEmoji["point_down_tone5"] = "\U0001f447\U0001f3ff";
ShortCodeToEmoji["point_left_tone1"] = "\U0001f448\U0001f3fb";
ShortCodeToEmoji["point_left_tone2"] = "\U0001f448\U0001f3fc";
ShortCodeToEmoji["point_left_tone3"] = "\U0001f448\U0001f3fd";
ShortCodeToEmoji["point_left_tone4"] = "\U0001f448\U0001f3fe";
ShortCodeToEmoji["point_left_tone5"] = "\U0001f448\U0001f3ff";
ShortCodeToEmoji["point_right_tone1"] = "\U0001f449\U0001f3fb";
ShortCodeToEmoji["point_right_tone2"] = "\U0001f449\U0001f3fc";
ShortCodeToEmoji["point_right_tone3"] = "\U0001f449\U0001f3fd";
ShortCodeToEmoji["point_right_tone4"] = "\U0001f449\U0001f3fe";
ShortCodeToEmoji["point_right_tone5"] = "\U0001f449\U0001f3ff";
ShortCodeToEmoji["middle_finger_tone1"] = "\U0001f595\U0001f3fb";
ShortCodeToEmoji["middle_finger_tone2"] = "\U0001f595\U0001f3fc";
ShortCodeToEmoji["middle_finger_tone3"] = "\U0001f595\U0001f3fd";
ShortCodeToEmoji["middle_finger_tone4"] = "\U0001f595\U0001f3fe";
ShortCodeToEmoji["middle_finger_tone5"] = "\U0001f595\U0001f3ff";
ShortCodeToEmoji["hand_splayed_tone1"] = "\U0001f590\U0001f3fb";
ShortCodeToEmoji["hand_splayed_tone2"] = "\U0001f590\U0001f3fc";
ShortCodeToEmoji["hand_splayed_tone3"] = "\U0001f590\U0001f3fd";
ShortCodeToEmoji["hand_splayed_tone4"] = "\U0001f590\U0001f3fe";
ShortCodeToEmoji["hand_splayed_tone5"] = "\U0001f590\U0001f3ff";
ShortCodeToEmoji["metal_tone1"] = "\U0001f918\U0001f3fb";
ShortCodeToEmoji["metal_tone2"] = "\U0001f918\U0001f3fc";
ShortCodeToEmoji["metal_tone3"] = "\U0001f918\U0001f3fd";
ShortCodeToEmoji["metal_tone4"] = "\U0001f918\U0001f3fe";
ShortCodeToEmoji["metal_tone5"] = "\U0001f918\U0001f3ff";
ShortCodeToEmoji["vulcan_tone1"] = "\U0001f596\U0001f3fb";
ShortCodeToEmoji["vulcan_tone2"] = "\U0001f596\U0001f3fc";
ShortCodeToEmoji["vulcan_tone3"] = "\U0001f596\U0001f3fd";
ShortCodeToEmoji["vulcan_tone4"] = "\U0001f596\U0001f3fe";
ShortCodeToEmoji["vulcan_tone5"] = "\U0001f596\U0001f3ff";
ShortCodeToEmoji["writing_hand_tone1"] = "\U0000270d\U0001f3fb";
ShortCodeToEmoji["writing_hand_tone2"] = "\U0000270d\U0001f3fc";
ShortCodeToEmoji["writing_hand_tone3"] = "\U0000270d\U0001f3fd";
ShortCodeToEmoji["writing_hand_tone4"] = "\U0000270d\U0001f3fe";
ShortCodeToEmoji["writing_hand_tone5"] = "\U0000270d\U0001f3ff";
ShortCodeToEmoji["nail_care_tone1"] = "\U0001f485\U0001f3fb";
ShortCodeToEmoji["nail_care_tone2"] = "\U0001f485\U0001f3fc";
ShortCodeToEmoji["nail_care_tone3"] = "\U0001f485\U0001f3fd";
ShortCodeToEmoji["nail_care_tone4"] = "\U0001f485\U0001f3fe";
ShortCodeToEmoji["nail_care_tone5"] = "\U0001f485\U0001f3ff";
ShortCodeToEmoji["ear_tone1"] = "\U0001f442\U0001f3fb";
ShortCodeToEmoji["ear_tone2"] = "\U0001f442\U0001f3fc";
ShortCodeToEmoji["ear_tone3"] = "\U0001f442\U0001f3fd";
ShortCodeToEmoji["ear_tone4"] = "\U0001f442\U0001f3fe";
ShortCodeToEmoji["ear_tone5"] = "\U0001f442\U0001f3ff";
ShortCodeToEmoji["nose_tone1"] = "\U0001f443\U0001f3fb";
ShortCodeToEmoji["nose_tone2"] = "\U0001f443\U0001f3fc";
ShortCodeToEmoji["nose_tone3"] = "\U0001f443\U0001f3fd";
ShortCodeToEmoji["nose_tone4"] = "\U0001f443\U0001f3fe";
ShortCodeToEmoji["nose_tone5"] = "\U0001f443\U0001f3ff";
ShortCodeToEmoji["baby_tone1"] = "\U0001f476\U0001f3fb";
ShortCodeToEmoji["baby_tone2"] = "\U0001f476\U0001f3fc";
ShortCodeToEmoji["baby_tone3"] = "\U0001f476\U0001f3fd";
ShortCodeToEmoji["baby_tone4"] = "\U0001f476\U0001f3fe";
ShortCodeToEmoji["baby_tone5"] = "\U0001f476\U0001f3ff";
ShortCodeToEmoji["boy_tone1"] = "\U0001f466\U0001f3fb";
ShortCodeToEmoji["boy_tone2"] = "\U0001f466\U0001f3fc";
ShortCodeToEmoji["boy_tone3"] = "\U0001f466\U0001f3fd";
ShortCodeToEmoji["boy_tone4"] = "\U0001f466\U0001f3fe";
ShortCodeToEmoji["boy_tone5"] = "\U0001f466\U0001f3ff";
ShortCodeToEmoji["girl_tone1"] = "\U0001f467\U0001f3fb";
ShortCodeToEmoji["girl_tone2"] = "\U0001f467\U0001f3fc";
ShortCodeToEmoji["girl_tone3"] = "\U0001f467\U0001f3fd";
ShortCodeToEmoji["girl_tone4"] = "\U0001f467\U0001f3fe";
ShortCodeToEmoji["girl_tone5"] = "\U0001f467\U0001f3ff";
ShortCodeToEmoji["man_tone1"] = "\U0001f468\U0001f3fb";
ShortCodeToEmoji["man_tone2"] = "\U0001f468\U0001f3fc";
ShortCodeToEmoji["man_tone3"] = "\U0001f468\U0001f3fd";
ShortCodeToEmoji["man_tone4"] = "\U0001f468\U0001f3fe";
ShortCodeToEmoji["man_tone5"] = "\U0001f468\U0001f3ff";
ShortCodeToEmoji["woman_tone1"] = "\U0001f469\U0001f3fb";
ShortCodeToEmoji["woman_tone2"] = "\U0001f469\U0001f3fc";
ShortCodeToEmoji["woman_tone3"] = "\U0001f469\U0001f3fd";
ShortCodeToEmoji["woman_tone4"] = "\U0001f469\U0001f3fe";
ShortCodeToEmoji["woman_tone5"] = "\U0001f469\U0001f3ff";
ShortCodeToEmoji["person_with_blond_hair_tone1"] = "\U0001f471\U0001f3fb";
ShortCodeToEmoji["person_with_blond_hair_tone2"] = "\U0001f471\U0001f3fc";
ShortCodeToEmoji["person_with_blond_hair_tone3"] = "\U0001f471\U0001f3fd";
ShortCodeToEmoji["person_with_blond_hair_tone4"] = "\U0001f471\U0001f3fe";
ShortCodeToEmoji["person_with_blond_hair_tone5"] = "\U0001f471\U0001f3ff";
ShortCodeToEmoji["older_man_tone1"] = "\U0001f474\U0001f3fb";
ShortCodeToEmoji["older_man_tone2"] = "\U0001f474\U0001f3fc";
ShortCodeToEmoji["older_man_tone3"] = "\U0001f474\U0001f3fd";
ShortCodeToEmoji["older_man_tone4"] = "\U0001f474\U0001f3fe";
ShortCodeToEmoji["older_man_tone5"] = "\U0001f474\U0001f3ff";
ShortCodeToEmoji["older_woman_tone1"] = "\U0001f475\U0001f3fb";
ShortCodeToEmoji["older_woman_tone2"] = "\U0001f475\U0001f3fc";
ShortCodeToEmoji["older_woman_tone3"] = "\U0001f475\U0001f3fd";
ShortCodeToEmoji["older_woman_tone4"] = "\U0001f475\U0001f3fe";
ShortCodeToEmoji["older_woman_tone5"] = "\U0001f475\U0001f3ff";
ShortCodeToEmoji["man_with_gua_pi_mao_tone1"] = "\U0001f472\U0001f3fb";
ShortCodeToEmoji["man_with_gua_pi_mao_tone2"] = "\U0001f472\U0001f3fc";
ShortCodeToEmoji["man_with_gua_pi_mao_tone3"] = "\U0001f472\U0001f3fd";
ShortCodeToEmoji["man_with_gua_pi_mao_tone4"] = "\U0001f472\U0001f3fe";
ShortCodeToEmoji["man_with_gua_pi_mao_tone5"] = "\U0001f472\U0001f3ff";
ShortCodeToEmoji["man_with_turban_tone1"] = "\U0001f473\U0001f3fb";
ShortCodeToEmoji["man_with_turban_tone2"] = "\U0001f473\U0001f3fc";
ShortCodeToEmoji["man_with_turban_tone3"] = "\U0001f473\U0001f3fd";
ShortCodeToEmoji["man_with_turban_tone4"] = "\U0001f473\U0001f3fe";
ShortCodeToEmoji["man_with_turban_tone5"] = "\U0001f473\U0001f3ff";
ShortCodeToEmoji["cop_tone1"] = "\U0001f46e\U0001f3fb";
ShortCodeToEmoji["cop_tone2"] = "\U0001f46e\U0001f3fc";
ShortCodeToEmoji["cop_tone3"] = "\U0001f46e\U0001f3fd";
ShortCodeToEmoji["cop_tone4"] = "\U0001f46e\U0001f3fe";
ShortCodeToEmoji["cop_tone5"] = "\U0001f46e\U0001f3ff";
ShortCodeToEmoji["construction_worker_tone1"] = "\U0001f477\U0001f3fb";
ShortCodeToEmoji["construction_worker_tone2"] = "\U0001f477\U0001f3fc";
ShortCodeToEmoji["construction_worker_tone3"] = "\U0001f477\U0001f3fd";
ShortCodeToEmoji["construction_worker_tone4"] = "\U0001f477\U0001f3fe";
ShortCodeToEmoji["construction_worker_tone5"] = "\U0001f477\U0001f3ff";
ShortCodeToEmoji["guardsman_tone1"] = "\U0001f482\U0001f3fb";
ShortCodeToEmoji["guardsman_tone2"] = "\U0001f482\U0001f3fc";
ShortCodeToEmoji["guardsman_tone3"] = "\U0001f482\U0001f3fd";
ShortCodeToEmoji["guardsman_tone4"] = "\U0001f482\U0001f3fe";
ShortCodeToEmoji["guardsman_tone5"] = "\U0001f482\U0001f3ff";
ShortCodeToEmoji["santa_tone1"] = "\U0001f385\U0001f3fb";
ShortCodeToEmoji["santa_tone2"] = "\U0001f385\U0001f3fc";
ShortCodeToEmoji["santa_tone3"] = "\U0001f385\U0001f3fd";
ShortCodeToEmoji["santa_tone4"] = "\U0001f385\U0001f3fe";
ShortCodeToEmoji["santa_tone5"] = "\U0001f385\U0001f3ff";
ShortCodeToEmoji["angel_tone1"] = "\U0001f47c\U0001f3fb";
ShortCodeToEmoji["angel_tone2"] = "\U0001f47c\U0001f3fc";
ShortCodeToEmoji["angel_tone3"] = "\U0001f47c\U0001f3fd";
ShortCodeToEmoji["angel_tone4"] = "\U0001f47c\U0001f3fe";
ShortCodeToEmoji["angel_tone5"] = "\U0001f47c\U0001f3ff";
ShortCodeToEmoji["princess_tone1"] = "\U0001f478\U0001f3fb";
ShortCodeToEmoji["princess_tone2"] = "\U0001f478\U0001f3fc";
ShortCodeToEmoji["princess_tone3"] = "\U0001f478\U0001f3fd";
ShortCodeToEmoji["princess_tone4"] = "\U0001f478\U0001f3fe";
ShortCodeToEmoji["princess_tone5"] = "\U0001f478\U0001f3ff";
ShortCodeToEmoji["bride_with_veil_tone1"] = "\U0001f470\U0001f3fb";
ShortCodeToEmoji["bride_with_veil_tone2"] = "\U0001f470\U0001f3fc";
ShortCodeToEmoji["bride_with_veil_tone3"] = "\U0001f470\U0001f3fd";
ShortCodeToEmoji["bride_with_veil_tone4"] = "\U0001f470\U0001f3fe";
ShortCodeToEmoji["bride_with_veil_tone5"] = "\U0001f470\U0001f3ff";
ShortCodeToEmoji["walking_tone1"] = "\U0001f6b6\U0001f3fb";
ShortCodeToEmoji["walking_tone2"] = "\U0001f6b6\U0001f3fc";
ShortCodeToEmoji["walking_tone3"] = "\U0001f6b6\U0001f3fd";
ShortCodeToEmoji["walking_tone4"] = "\U0001f6b6\U0001f3fe";
ShortCodeToEmoji["walking_tone5"] = "\U0001f6b6\U0001f3ff";
ShortCodeToEmoji["runner_tone1"] = "\U0001f3c3\U0001f3fb";
ShortCodeToEmoji["runner_tone2"] = "\U0001f3c3\U0001f3fc";
ShortCodeToEmoji["runner_tone3"] = "\U0001f3c3\U0001f3fd";
ShortCodeToEmoji["runner_tone4"] = "\U0001f3c3\U0001f3fe";
ShortCodeToEmoji["runner_tone5"] = "\U0001f3c3\U0001f3ff";
ShortCodeToEmoji["dancer_tone1"] = "\U0001f483\U0001f3fb";
ShortCodeToEmoji["dancer_tone2"] = "\U0001f483\U0001f3fc";
ShortCodeToEmoji["dancer_tone3"] = "\U0001f483\U0001f3fd";
ShortCodeToEmoji["dancer_tone4"] = "\U0001f483\U0001f3fe";
ShortCodeToEmoji["dancer_tone5"] = "\U0001f483\U0001f3ff";
ShortCodeToEmoji["bow_tone1"] = "\U0001f647\U0001f3fb";
ShortCodeToEmoji["bow_tone2"] = "\U0001f647\U0001f3fc";
ShortCodeToEmoji["bow_tone3"] = "\U0001f647\U0001f3fd";
ShortCodeToEmoji["bow_tone4"] = "\U0001f647\U0001f3fe";
ShortCodeToEmoji["bow_tone5"] = "\U0001f647\U0001f3ff";
ShortCodeToEmoji["information_desk_person_tone1"] = "\U0001f481\U0001f3fb";
ShortCodeToEmoji["information_desk_person_tone2"] = "\U0001f481\U0001f3fc";
ShortCodeToEmoji["information_desk_person_tone3"] = "\U0001f481\U0001f3fd";
ShortCodeToEmoji["information_desk_person_tone4"] = "\U0001f481\U0001f3fe";
ShortCodeToEmoji["information_desk_person_tone5"] = "\U0001f481\U0001f3ff";
ShortCodeToEmoji["no_good_tone1"] = "\U0001f645\U0001f3fb";
ShortCodeToEmoji["no_good_tone2"] = "\U0001f645\U0001f3fc";
ShortCodeToEmoji["no_good_tone3"] = "\U0001f645\U0001f3fd";
ShortCodeToEmoji["no_good_tone4"] = "\U0001f645\U0001f3fe";
ShortCodeToEmoji["no_good_tone5"] = "\U0001f645\U0001f3ff";
ShortCodeToEmoji["ok_woman_tone1"] = "\U0001f646\U0001f3fb";
ShortCodeToEmoji["ok_woman_tone2"] = "\U0001f646\U0001f3fc";
ShortCodeToEmoji["ok_woman_tone3"] = "\U0001f646\U0001f3fd";
ShortCodeToEmoji["ok_woman_tone4"] = "\U0001f646\U0001f3fe";
ShortCodeToEmoji["ok_woman_tone5"] = "\U0001f646\U0001f3ff";
ShortCodeToEmoji["raising_hand_tone1"] = "\U0001f64b\U0001f3fb";
ShortCodeToEmoji["raising_hand_tone2"] = "\U0001f64b\U0001f3fc";
ShortCodeToEmoji["raising_hand_tone3"] = "\U0001f64b\U0001f3fd";
ShortCodeToEmoji["raising_hand_tone4"] = "\U0001f64b\U0001f3fe";
ShortCodeToEmoji["raising_hand_tone5"] = "\U0001f64b\U0001f3ff";
ShortCodeToEmoji["person_with_pouting_face_tone1"] = "\U0001f64e\U0001f3fb";
ShortCodeToEmoji["person_with_pouting_face_tone2"] = "\U0001f64e\U0001f3fc";
ShortCodeToEmoji["person_with_pouting_face_tone3"] = "\U0001f64e\U0001f3fd";
ShortCodeToEmoji["person_with_pouting_face_tone4"] = "\U0001f64e\U0001f3fe";
ShortCodeToEmoji["person_with_pouting_face_tone5"] = "\U0001f64e\U0001f3ff";
ShortCodeToEmoji["person_frowning_tone1"] = "\U0001f64d\U0001f3fb";
ShortCodeToEmoji["person_frowning_tone2"] = "\U0001f64d\U0001f3fc";
ShortCodeToEmoji["person_frowning_tone3"] = "\U0001f64d\U0001f3fd";
ShortCodeToEmoji["person_frowning_tone4"] = "\U0001f64d\U0001f3fe";
ShortCodeToEmoji["person_frowning_tone5"] = "\U0001f64d\U0001f3ff";
ShortCodeToEmoji["haircut_tone1"] = "\U0001f487\U0001f3fb";
ShortCodeToEmoji["haircut_tone2"] = "\U0001f487\U0001f3fc";
ShortCodeToEmoji["haircut_tone3"] = "\U0001f487\U0001f3fd";
ShortCodeToEmoji["haircut_tone4"] = "\U0001f487\U0001f3fe";
ShortCodeToEmoji["haircut_tone5"] = "\U0001f487\U0001f3ff";
ShortCodeToEmoji["massage_tone1"] = "\U0001f486\U0001f3fb";
ShortCodeToEmoji["massage_tone2"] = "\U0001f486\U0001f3fc";
ShortCodeToEmoji["massage_tone3"] = "\U0001f486\U0001f3fd";
ShortCodeToEmoji["massage_tone4"] = "\U0001f486\U0001f3fe";
ShortCodeToEmoji["massage_tone5"] = "\U0001f486\U0001f3ff";
ShortCodeToEmoji["rowboat_tone1"] = "\U0001f6a3\U0001f3fb";
ShortCodeToEmoji["rowboat_tone2"] = "\U0001f6a3\U0001f3fc";
ShortCodeToEmoji["rowboat_tone3"] = "\U0001f6a3\U0001f3fd";
ShortCodeToEmoji["rowboat_tone4"] = "\U0001f6a3\U0001f3fe";
ShortCodeToEmoji["rowboat_tone5"] = "\U0001f6a3\U0001f3ff";
ShortCodeToEmoji["swimmer_tone1"] = "\U0001f3ca\U0001f3fb";
ShortCodeToEmoji["swimmer_tone2"] = "\U0001f3ca\U0001f3fc";
ShortCodeToEmoji["swimmer_tone3"] = "\U0001f3ca\U0001f3fd";
ShortCodeToEmoji["swimmer_tone4"] = "\U0001f3ca\U0001f3fe";
ShortCodeToEmoji["swimmer_tone5"] = "\U0001f3ca\U0001f3ff";
ShortCodeToEmoji["surfer_tone1"] = "\U0001f3c4\U0001f3fb";
ShortCodeToEmoji["surfer_tone2"] = "\U0001f3c4\U0001f3fc";
ShortCodeToEmoji["surfer_tone3"] = "\U0001f3c4\U0001f3fd";
ShortCodeToEmoji["surfer_tone4"] = "\U0001f3c4\U0001f3fe";
ShortCodeToEmoji["surfer_tone5"] = "\U0001f3c4\U0001f3ff";
ShortCodeToEmoji["bath_tone1"] = "\U0001f6c0\U0001f3fb";
ShortCodeToEmoji["bath_tone2"] = "\U0001f6c0\U0001f3fc";
ShortCodeToEmoji["bath_tone3"] = "\U0001f6c0\U0001f3fd";
ShortCodeToEmoji["bath_tone4"] = "\U0001f6c0\U0001f3fe";
ShortCodeToEmoji["bath_tone5"] = "\U0001f6c0\U0001f3ff";
ShortCodeToEmoji["basketball_player_tone1"] = "\U000026f9\U0001f3fb";
ShortCodeToEmoji["basketball_player_tone2"] = "\U000026f9\U0001f3fc";
ShortCodeToEmoji["basketball_player_tone3"] = "\U000026f9\U0001f3fd";
ShortCodeToEmoji["basketball_player_tone4"] = "\U000026f9\U0001f3fe";
ShortCodeToEmoji["basketball_player_tone5"] = "\U000026f9\U0001f3ff";
ShortCodeToEmoji["lifter_tone1"] = "\U0001f3cb\U0001f3fb";
ShortCodeToEmoji["lifter_tone2"] = "\U0001f3cb\U0001f3fc";
ShortCodeToEmoji["lifter_tone3"] = "\U0001f3cb\U0001f3fd";
ShortCodeToEmoji["lifter_tone4"] = "\U0001f3cb\U0001f3fe";
ShortCodeToEmoji["lifter_tone5"] = "\U0001f3cb\U0001f3ff";
ShortCodeToEmoji["bicyclist_tone1"] = "\U0001f6b4\U0001f3fb";
ShortCodeToEmoji["bicyclist_tone2"] = "\U0001f6b4\U0001f3fc";
ShortCodeToEmoji["bicyclist_tone3"] = "\U0001f6b4\U0001f3fd";
ShortCodeToEmoji["bicyclist_tone4"] = "\U0001f6b4\U0001f3fe";
ShortCodeToEmoji["bicyclist_tone5"] = "\U0001f6b4\U0001f3ff";
ShortCodeToEmoji["mountain_bicyclist_tone1"] = "\U0001f6b5\U0001f3fb";
ShortCodeToEmoji["mountain_bicyclist_tone2"] = "\U0001f6b5\U0001f3fc";
ShortCodeToEmoji["mountain_bicyclist_tone3"] = "\U0001f6b5\U0001f3fd";
ShortCodeToEmoji["mountain_bicyclist_tone4"] = "\U0001f6b5\U0001f3fe";
ShortCodeToEmoji["mountain_bicyclist_tone5"] = "\U0001f6b5\U0001f3ff";
ShortCodeToEmoji["horse_racing_tone1"] = "\U0001f3c7\U0001f3fb";
ShortCodeToEmoji["horse_racing_tone2"] = "\U0001f3c7\U0001f3fc";
ShortCodeToEmoji["horse_racing_tone3"] = "\U0001f3c7\U0001f3fd";
ShortCodeToEmoji["horse_racing_tone4"] = "\U0001f3c7\U0001f3fe";
ShortCodeToEmoji["horse_racing_tone5"] = "\U0001f3c7\U0001f3ff";
ShortCodeToEmoji["spy_tone1"] = "\U0001f575\U0001f3fb";
ShortCodeToEmoji["spy_tone2"] = "\U0001f575\U0001f3fc";
ShortCodeToEmoji["spy_tone3"] = "\U0001f575\U0001f3fd";
ShortCodeToEmoji["spy_tone4"] = "\U0001f575\U0001f3fe";
ShortCodeToEmoji["spy_tone5"] = "\U0001f575\U0001f3ff";
ShortCodeToEmoji["tone1"] = "\U0001f3fb";
ShortCodeToEmoji["tone2"] = "\U0001f3fc";
ShortCodeToEmoji["tone3"] = "\U0001f3fd";
ShortCodeToEmoji["tone4"] = "\U0001f3fe";
ShortCodeToEmoji["tone5"] = "\U0001f3ff";
ShortCodeToEmoji["prince_tone1"] = "\U0001f934\U0001f3fb";
ShortCodeToEmoji["prince_tone2"] = "\U0001f934\U0001f3fc";
ShortCodeToEmoji["prince_tone3"] = "\U0001f934\U0001f3fd";
ShortCodeToEmoji["prince_tone4"] = "\U0001f934\U0001f3fe";
ShortCodeToEmoji["prince_tone5"] = "\U0001f934\U0001f3ff";
ShortCodeToEmoji["mrs_claus_tone1"] = "\U0001f936\U0001f3fb";
ShortCodeToEmoji["mrs_claus_tone2"] = "\U0001f936\U0001f3fc";
ShortCodeToEmoji["mrs_claus_tone3"] = "\U0001f936\U0001f3fd";
ShortCodeToEmoji["mrs_claus_tone4"] = "\U0001f936\U0001f3fe";
ShortCodeToEmoji["mrs_claus_tone5"] = "\U0001f936\U0001f3ff";
ShortCodeToEmoji["man_in_tuxedo_tone1"] = "\U0001f935\U0001f3fb";
ShortCodeToEmoji["man_in_tuxedo_tone2"] = "\U0001f935\U0001f3fc";
ShortCodeToEmoji["man_in_tuxedo_tone3"] = "\U0001f935\U0001f3fd";
ShortCodeToEmoji["man_in_tuxedo_tone4"] = "\U0001f935\U0001f3fe";
ShortCodeToEmoji["man_in_tuxedo_tone5"] = "\U0001f935\U0001f3ff";
ShortCodeToEmoji["shrug_tone1"] = "\U0001f937\U0001f3fb";
ShortCodeToEmoji["shrug_tone2"] = "\U0001f937\U0001f3fc";
ShortCodeToEmoji["shrug_tone3"] = "\U0001f937\U0001f3fd";
ShortCodeToEmoji["shrug_tone4"] = "\U0001f937\U0001f3fe";
ShortCodeToEmoji["shrug_tone5"] = "\U0001f937\U0001f3ff";
ShortCodeToEmoji["face_palm_tone1"] = "\U0001f926\U0001f3fb";
ShortCodeToEmoji["face_palm_tone2"] = "\U0001f926\U0001f3fc";
ShortCodeToEmoji["face_palm_tone3"] = "\U0001f926\U0001f3fd";
ShortCodeToEmoji["face_palm_tone4"] = "\U0001f926\U0001f3fe";
ShortCodeToEmoji["face_palm_tone5"] = "\U0001f926\U0001f3ff";
ShortCodeToEmoji["pregnant_woman_tone1"] = "\U0001f930\U0001f3fb";
ShortCodeToEmoji["pregnant_woman_tone2"] = "\U0001f930\U0001f3fc";
ShortCodeToEmoji["pregnant_woman_tone3"] = "\U0001f930\U0001f3fd";
ShortCodeToEmoji["pregnant_woman_tone4"] = "\U0001f930\U0001f3fe";
ShortCodeToEmoji["pregnant_woman_tone5"] = "\U0001f930\U0001f3ff";
ShortCodeToEmoji["man_dancing_tone1"] = "\U0001f57a\U0001f3fb";
ShortCodeToEmoji["man_dancing_tone2"] = "\U0001f57a\U0001f3fc";
ShortCodeToEmoji["man_dancing_tone3"] = "\U0001f57a\U0001f3fd";
ShortCodeToEmoji["man_dancing_tone4"] = "\U0001f57a\U0001f3fe";
ShortCodeToEmoji["man_dancing_tone5"] = "\U0001f57a\U0001f3ff";
ShortCodeToEmoji["selfie_tone1"] = "\U0001f933\U0001f3fb";
ShortCodeToEmoji["selfie_tone2"] = "\U0001f933\U0001f3fc";
ShortCodeToEmoji["selfie_tone3"] = "\U0001f933\U0001f3fd";
ShortCodeToEmoji["selfie_tone4"] = "\U0001f933\U0001f3fe";
ShortCodeToEmoji["selfie_tone5"] = "\U0001f933\U0001f3ff";
ShortCodeToEmoji["fingers_crossed_tone1"] = "\U0001f91e\U0001f3fb";
ShortCodeToEmoji["fingers_crossed_tone2"] = "\U0001f91e\U0001f3fc";
ShortCodeToEmoji["fingers_crossed_tone3"] = "\U0001f91e\U0001f3fd";
ShortCodeToEmoji["fingers_crossed_tone4"] = "\U0001f91e\U0001f3fe";
ShortCodeToEmoji["fingers_crossed_tone5"] = "\U0001f91e\U0001f3ff";
ShortCodeToEmoji["call_me_tone1"] = "\U0001f919\U0001f3fb";
ShortCodeToEmoji["call_me_tone2"] = "\U0001f919\U0001f3fc";
ShortCodeToEmoji["call_me_tone3"] = "\U0001f919\U0001f3fd";
ShortCodeToEmoji["call_me_tone4"] = "\U0001f919\U0001f3fe";
ShortCodeToEmoji["call_me_tone5"] = "\U0001f919\U0001f3ff";
ShortCodeToEmoji["left_facing_fist_tone1"] = "\U0001f91b\U0001f3fb";
ShortCodeToEmoji["left_facing_fist_tone2"] = "\U0001f91b\U0001f3fc";
ShortCodeToEmoji["left_facing_fist_tone3"] = "\U0001f91b\U0001f3fd";
ShortCodeToEmoji["left_facing_fist_tone4"] = "\U0001f91b\U0001f3fe";
ShortCodeToEmoji["left_facing_fist_tone5"] = "\U0001f91b\U0001f3ff";
ShortCodeToEmoji["right_facing_fist_tone1"] = "\U0001f91c\U0001f3fb";
ShortCodeToEmoji["right_facing_fist_tone2"] = "\U0001f91c\U0001f3fc";
ShortCodeToEmoji["right_facing_fist_tone3"] = "\U0001f91c\U0001f3fd";
ShortCodeToEmoji["right_facing_fist_tone4"] = "\U0001f91c\U0001f3fe";
ShortCodeToEmoji["right_facing_fist_tone5"] = "\U0001f91c\U0001f3ff";
ShortCodeToEmoji["raised_back_of_hand_tone1"] = "\U0001f91a\U0001f3fb";
ShortCodeToEmoji["raised_back_of_hand_tone2"] = "\U0001f91a\U0001f3fc";
ShortCodeToEmoji["raised_back_of_hand_tone3"] = "\U0001f91a\U0001f3fd";
ShortCodeToEmoji["raised_back_of_hand_tone4"] = "\U0001f91a\U0001f3fe";
ShortCodeToEmoji["raised_back_of_hand_tone5"] = "\U0001f91a\U0001f3ff";
ShortCodeToEmoji["handshake_tone1"] = "\U0001f91d\U0001f3fb";
ShortCodeToEmoji["handshake_tone2"] = "\U0001f91d\U0001f3fc";
ShortCodeToEmoji["handshake_tone3"] = "\U0001f91d\U0001f3fd";
ShortCodeToEmoji["handshake_tone4"] = "\U0001f91d\U0001f3fe";
ShortCodeToEmoji["handshake_tone5"] = "\U0001f91d\U0001f3ff";
ShortCodeToEmoji["cartwheel_tone1"] = "\U0001f938\U0001f3fb";
ShortCodeToEmoji["cartwheel_tone2"] = "\U0001f938\U0001f3fc";
ShortCodeToEmoji["cartwheel_tone3"] = "\U0001f938\U0001f3fd";
ShortCodeToEmoji["cartwheel_tone4"] = "\U0001f938\U0001f3fe";
ShortCodeToEmoji["cartwheel_tone5"] = "\U0001f938\U0001f3ff";
ShortCodeToEmoji["wrestlers_tone1"] = "\U0001f93c\U0001f3fb";
ShortCodeToEmoji["wrestlers_tone2"] = "\U0001f93c\U0001f3fc";
ShortCodeToEmoji["wrestlers_tone3"] = "\U0001f93c\U0001f3fd";
ShortCodeToEmoji["wrestlers_tone4"] = "\U0001f93c\U0001f3fe";
ShortCodeToEmoji["wrestlers_tone5"] = "\U0001f93c\U0001f3ff";
ShortCodeToEmoji["water_polo_tone1"] = "\U0001f93d\U0001f3fb";
ShortCodeToEmoji["water_polo_tone2"] = "\U0001f93d\U0001f3fc";
ShortCodeToEmoji["water_polo_tone3"] = "\U0001f93d\U0001f3fd";
ShortCodeToEmoji["water_polo_tone4"] = "\U0001f93d\U0001f3fe";
ShortCodeToEmoji["water_polo_tone5"] = "\U0001f93d\U0001f3ff";
ShortCodeToEmoji["handball_tone1"] = "\U0001f93e\U0001f3fb";
ShortCodeToEmoji["handball_tone2"] = "\U0001f93e\U0001f3fc";
ShortCodeToEmoji["handball_tone3"] = "\U0001f93e\U0001f3fd";
ShortCodeToEmoji["handball_tone4"] = "\U0001f93e\U0001f3fe";
ShortCodeToEmoji["handball_tone5"] = "\U0001f93e\U0001f3ff";
ShortCodeToEmoji["juggling_tone1"] = "\U0001f939\U0001f3fb";
ShortCodeToEmoji["juggling_tone2"] = "\U0001f939\U0001f3fc";
ShortCodeToEmoji["juggling_tone3"] = "\U0001f939\U0001f3fd";
ShortCodeToEmoji["juggling_tone4"] = "\U0001f939\U0001f3fe";
ShortCodeToEmoji["juggling_tone5"] = "\U0001f939\U0001f3ff";
ShortCodeToEmoji["speech_left"] = "\U0001f5e8";
ShortCodeToEmoji["eject"] = "\U000023cf";
ShortCodeToEmoji["gay_pride_flag"] = "\U0001f3f3\U0001f308";
ShortCodeToEmoji["cowboy"] = "\U0001f920";
ShortCodeToEmoji["clown"] = "\U0001f921";
ShortCodeToEmoji["nauseated_face"] = "\U0001f922";
ShortCodeToEmoji["rofl"] = "\U0001f923";
ShortCodeToEmoji["drooling_face"] = "\U0001f924";
ShortCodeToEmoji["lying_face"] = "\U0001f925";
ShortCodeToEmoji["sneezing_face"] = "\U0001f927";
ShortCodeToEmoji["prince"] = "\U0001f934";
ShortCodeToEmoji["man_in_tuxedo"] = "\U0001f935";
ShortCodeToEmoji["mrs_claus"] = "\U0001f936";
ShortCodeToEmoji["face_palm"] = "\U0001f926";
ShortCodeToEmoji["shrug"] = "\U0001f937";
ShortCodeToEmoji["pregnant_woman"] = "\U0001f930";
ShortCodeToEmoji["selfie"] = "\U0001f933";
ShortCodeToEmoji["man_dancing"] = "\U0001f57a";
ShortCodeToEmoji["call_me"] = "\U0001f919";
ShortCodeToEmoji["raised_back_of_hand"] = "\U0001f91a";
ShortCodeToEmoji["left_facing_fist"] = "\U0001f91b";
ShortCodeToEmoji["right_facing_fist"] = "\U0001f91c";
ShortCodeToEmoji["handshake"] = "\U0001f91d";
ShortCodeToEmoji["fingers_crossed"] = "\U0001f91e";
ShortCodeToEmoji["black_heart"] = "\U0001f5a4";
ShortCodeToEmoji["eagle"] = "\U0001f985";
ShortCodeToEmoji["duck"] = "\U0001f986";
ShortCodeToEmoji["bat"] = "\U0001f987";
ShortCodeToEmoji["shark"] = "\U0001f988";
ShortCodeToEmoji["owl"] = "\U0001f989";
ShortCodeToEmoji["fox"] = "\U0001f98a";
ShortCodeToEmoji["butterfly"] = "\U0001f98b";
ShortCodeToEmoji["deer"] = "\U0001f98c";
ShortCodeToEmoji["gorilla"] = "\U0001f98d";
ShortCodeToEmoji["lizard"] = "\U0001f98e";
ShortCodeToEmoji["rhino"] = "\U0001f98f";
ShortCodeToEmoji["wilted_rose"] = "\U0001f940";
ShortCodeToEmoji["croissant"] = "\U0001f950";
ShortCodeToEmoji["avocado"] = "\U0001f951";
ShortCodeToEmoji["cucumber"] = "\U0001f952";
ShortCodeToEmoji["bacon"] = "\U0001f953";
ShortCodeToEmoji["potato"] = "\U0001f954";
ShortCodeToEmoji["carrot"] = "\U0001f955";
ShortCodeToEmoji["french_bread"] = "\U0001f956";
ShortCodeToEmoji["salad"] = "\U0001f957";
ShortCodeToEmoji["shallow_pan_of_food"] = "\U0001f958";
ShortCodeToEmoji["stuffed_flatbread"] = "\U0001f959";
ShortCodeToEmoji["champagne_glass"] = "\U0001f942";
ShortCodeToEmoji["tumbler_glass"] = "\U0001f943";
ShortCodeToEmoji["spoon"] = "\U0001f944";
ShortCodeToEmoji["octagonal_sign"] = "\U0001f6d1";
ShortCodeToEmoji["shopping_cart"] = "\U0001f6d2";
ShortCodeToEmoji["scooter"] = "\U0001f6f4";
ShortCodeToEmoji["motor_scooter"] = "\U0001f6f5";
ShortCodeToEmoji["canoe"] = "\U0001f6f6";
ShortCodeToEmoji["cartwheel"] = "\U0001f938";
ShortCodeToEmoji["juggling"] = "\U0001f939";
ShortCodeToEmoji["wrestlers"] = "\U0001f93c";
ShortCodeToEmoji["boxing_glove"] = "\U0001f94a";
ShortCodeToEmoji["martial_arts_uniform"] = "\U0001f94b";
ShortCodeToEmoji["water_polo"] = "\U0001f93d";
ShortCodeToEmoji["handball"] = "\U0001f93e";
ShortCodeToEmoji["goal"] = "\U0001f945";
ShortCodeToEmoji["fencer"] = "\U0001f93a";
ShortCodeToEmoji["first_place"] = "\U0001f947";
ShortCodeToEmoji["second_place"] = "\U0001f948";
ShortCodeToEmoji["third_place"] = "\U0001f949";
ShortCodeToEmoji["drum"] = "\U0001f941";
ShortCodeToEmoji["shrimp"] = "\U0001f990";
ShortCodeToEmoji["squid"] = "\U0001f991";
ShortCodeToEmoji["egg"] = "\U0001f95a";
ShortCodeToEmoji["milk"] = "\U0001f95b";
ShortCodeToEmoji["peanuts"] = "\U0001f95c";
ShortCodeToEmoji["kiwi"] = "\U0001f95d";
ShortCodeToEmoji["pancakes"] = "\U0001f95e";
ShortCodeToEmoji["regional_indicator_z"] = "\U0001f1ff";
ShortCodeToEmoji["regional_indicator_y"] = "\U0001f1fe";
ShortCodeToEmoji["regional_indicator_x"] = "\U0001f1fd";
ShortCodeToEmoji["regional_indicator_w"] = "\U0001f1fc";
ShortCodeToEmoji["regional_indicator_v"] = "\U0001f1fb";
ShortCodeToEmoji["regional_indicator_u"] = "\U0001f1fa";
ShortCodeToEmoji["regional_indicator_t"] = "\U0001f1f9";
ShortCodeToEmoji["regional_indicator_s"] = "\U0001f1f8";
ShortCodeToEmoji["regional_indicator_r"] = "\U0001f1f7";
ShortCodeToEmoji["regional_indicator_q"] = "\U0001f1f6";
ShortCodeToEmoji["regional_indicator_p"] = "\U0001f1f5";
ShortCodeToEmoji["regional_indicator_o"] = "\U0001f1f4";
ShortCodeToEmoji["regional_indicator_n"] = "\U0001f1f3";
ShortCodeToEmoji["regional_indicator_m"] = "\U0001f1f2";
ShortCodeToEmoji["regional_indicator_l"] = "\U0001f1f1";
ShortCodeToEmoji["regional_indicator_k"] = "\U0001f1f0";
ShortCodeToEmoji["regional_indicator_j"] = "\U0001f1ef";
ShortCodeToEmoji["regional_indicator_i"] = "\U0001f1ee";
ShortCodeToEmoji["regional_indicator_h"] = "\U0001f1ed";
ShortCodeToEmoji["regional_indicator_g"] = "\U0001f1ec";
ShortCodeToEmoji["regional_indicator_f"] = "\U0001f1eb";
ShortCodeToEmoji["regional_indicator_e"] = "\U0001f1ea";
ShortCodeToEmoji["regional_indicator_d"] = "\U0001f1e9";
ShortCodeToEmoji["regional_indicator_c"] = "\U0001f1e8";
ShortCodeToEmoji["regional_indicator_b"] = "\U0001f1e7";
ShortCodeToEmoji["regional_indicator_a"] = "\U0001f1e6";
foreach (var emoji in ShortCodeToEmoji)
{
EmojiToShortCode[emoji.Value] = emoji.Key;
}
foreach (var emoji in ShortCodeToEmoji.Values)
{
FirstEmojiChars.GetOrAdd(emoji[0], c => new ConcurrentDictionary<string, LazyLoadedImage>())[emoji] = null;
}
}
}
}
|
b2200652c9e0dca82da03c14cd8aceb3ed10b403
|
C#
|
TrickyCat/lens
|
/Lens/SyntaxTree/NodeBase.cs
| 2.515625
| 3
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Lens.Compiler;
using Lens.Translations;
using Lens.Utils;
namespace Lens.SyntaxTree
{
/// <summary>
/// The base class for all syntax tree nodes.
/// </summary>
internal abstract class NodeBase : LocationEntity
{
/// <summary>
/// Checks if the current node is a constant.
/// </summary>
public virtual bool IsConstant { get { return false; } }
public virtual dynamic ConstantValue { get { throw new InvalidOperationException("Not a constant!"); } }
/// <summary>
/// The cached expression type.
/// </summary>
private Type m_ExpressionType;
/// <summary>
/// Calculates the type of expression represented by current node.
/// </summary>
[DebuggerStepThrough]
public Type GetExpressionType(Context ctx, bool mustReturn = true)
{
if (m_ExpressionType == null)
{
m_ExpressionType = resolveExpressionType(ctx, mustReturn);
SafeModeCheckType(ctx, m_ExpressionType);
}
return m_ExpressionType;
}
protected virtual Type resolveExpressionType(Context ctx, bool mustReturn = true)
{
return typeof (Unit);
}
/// <summary>
/// Generates the IL for this node.
/// </summary>
/// <param name="ctx">Pointer to current context.</param>
/// <param name="mustReturn">Flag indicating the node should return a value.</param>
[DebuggerStepThrough]
public void Compile(Context ctx, bool mustReturn)
{
GetExpressionType(ctx, mustReturn);
if (IsConstant && ctx.Options.UnrollConstants)
{
if(mustReturn)
emitConstant(ctx);
}
else
{
compile(ctx, mustReturn);
}
}
protected abstract void compile(Context ctx, bool mustReturn);
/// <summary>
/// Emit the value of current node as a constant.
/// </summary>
private void emitConstant(Context ctx)
{
var gen = ctx.CurrentILGenerator;
var value = ConstantValue;
if (value is bool)
gen.EmitConstant((bool)value);
else if (value is int)
gen.EmitConstant((int)value);
else if (value is long)
gen.EmitConstant((long)value);
else if (value is double)
gen.EmitConstant((double)value);
else if (value is string)
gen.EmitConstant((string)value);
else
compile(ctx, true);
}
/// <summary>
/// Gets the list of child nodes.
/// </summary>
public virtual IEnumerable<NodeBase> GetChildNodes()
{
return new NodeBase[0];
}
/// <summary>
/// Processes closures.
/// </summary>
public virtual void ProcessClosures(Context ctx)
{
foreach(var child in GetChildNodes())
if(child != null)
child.ProcessClosures(ctx);
}
/// <summary>
/// Reports an error to the compiler.
/// </summary>
/// <param name="message">Error message.</param>
/// <param name="args">Optional error arguments.</param>
[ContractAnnotation("=> halt")]
[DebuggerStepThrough]
public void Error(string message, params object[] args)
{
Error(this, message, args);
}
/// <summary>
/// Reports an error to the compiler.
/// </summary>
/// <param name="message">Error message.</param>
/// <param name="args">Optional error arguments.</param>
[ContractAnnotation("=> halt")]
[DebuggerStepThrough]
public void Error(LocationEntity entity, string message, params object[] args)
{
var msg = string.Format(message, args);
throw new LensCompilerException(msg, entity);
}
/// <summary>
/// Throws an error that the current type is not alowed in safe mode.
/// </summary>
protected void SafeModeCheckType(Context ctx, Type type)
{
if(!ctx.IsTypeAllowed(type))
Error(CompilerMessages.SafeModeIllegalType, type.FullName);
}
}
}
|
95b3240e501af116c55bbbfbfeeb8fabedae51b5
|
C#
|
shendongnian/download4
|
/code2/209332-4039200-8494700-4.cs
| 3.4375
| 3
|
void func1(List<something> arg)
{
Type t = typeof(something);
}
void func2<T>(List<T> arg)
{
Type t = typeof(T);
}
void func3(object arg)
{
// assuming arg is a List<T>
Type t = arg.GetType().GetGenericArguments()[0];
}
void func4(object arg)
{
// assuming arg is an IList<T>
Type t;
// this assumes that arg implements exactly 1 IList<> interface;
// if not it throws an exception indicating that IList<> is ambiguous
t = arg.GetType().GetInterface(typeof(IList<>).Name).GetGenericArguments()[0];
// if you expect multiple instances of IList<>, it gets more complicated;
// we'll take just the first one we find
t = arg.GetType().GetInterfaces().Where(
i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))
.First().GetGenericArguments()[0];
}
|
c375cc8c00ed019a66e258137d9c2d9236aab511
|
C#
|
ExtemtedGold1/zadania01.04
|
/seq1/Program.cs
| 3.390625
| 3
|
using System;
namespace seq1 {
class Program {
static void Main() {
sbyte n1 = sbyte.Parse(Console.ReadLine());
string input = Console.ReadLine();
sbyte[] numbers1 = Array.ConvertAll<string, sbyte>(input.Split(" "), sbyte.Parse);
sbyte n2 = sbyte.Parse(Console.ReadLine());
input = Console.ReadLine();
sbyte[] numbers2 = Array.ConvertAll<string, sbyte>(input.Split(" "), sbyte.Parse);
for (int i = 0; i < n1; i++) {
for (int j = 0; j < n2; j++) {
if (numbers1[i] == numbers2[j]) {
break;
}
if (j == n2 - 1) {
Console.Write(numbers1[i]);
Console.Write(' ');
}
}
}
}
}
}
|
4a4e19490136c0a156ae9a9729b516dca09ba270
|
C#
|
Chewieez/Bangazon-Command-Line-Application
|
/bangazon-cli/Data/DatabaseInterface.cs
| 3.546875
| 4
|
using System;
using Microsoft.Data.Sqlite;
namespace bangazon_cli
{
/*
Author: Dre Randaci
Purpose: Methods to access SQL data in a locally saved database file
To allow for both a development and testing database, the constructor
requires a database path.
Example access method:
public class ExampleClass
{
private DatabaseInterface db;
db.Query(
$@"select ProductId
From Product
Where CustomerId = '{Id}';",
(SqliteDataReader reader) =>
{
while (reader.Read ()) {
ProductId = reader.GetInt32(0);
}
}
);
}
*/
public class DatabaseInterface
{
// Variable to store the path to the local DB file
private string _connectionString;
// Variable to store the connection to the database. Passes _connectionString as an argument
private SqliteConnection _connection;
// Method to extract the developers environment variable holding the BANGAZON_CLI_APP_DB.db filepath
public DatabaseInterface(string path)
{
try {
_connectionString = $"Data Source={path}";
_connection = new SqliteConnection(_connectionString);
Console.Write("Connected...");
// If the filepath cannot be found, throw an exception message
} catch (Exception err) {
Console.WriteLine("ERROR: Not connected to db " + err.Data);
Console.ReadLine();
}
}
public string GetConnectionString() {
return _connectionString;
}
// Method to query any table in the database. Takes a string SQL command when called
public void Query(string command, Action<SqliteDataReader> handler)
{
using (_connection)
{
// Creates a connection to the database and passes the SQL command in as the CommandText
_connection.Open ();
SqliteCommand dbcmd = _connection.CreateCommand ();
dbcmd.CommandText = command;
using (SqliteDataReader dataReader = dbcmd.ExecuteReader())
{
handler (dataReader);
}
dbcmd.Dispose ();
}
}
// Method to update tables in the database
public void Update(string command)
{
using (_connection)
{
// Creates a connection to the database and passes the SQL command in as the CommandText
_connection.Open ();
SqliteCommand dbcmd = _connection.CreateCommand ();
dbcmd.CommandText = command;
dbcmd.ExecuteNonQuery ();
dbcmd.Dispose ();
}
}
// Method to delete all tables in the database
public void DeleteTables()
{
string SQLDelete = $@"
DELETE FROM OrderProduct;
DELETE FROM `Order`;
DELETE FROM Product;
DELETE FROM PaymentType;
DELETE FROM Customer;
";
this.Update(SQLDelete);
}
// Method to insert new rows into the database
public int Insert(string command)
{
// Initializes an ID variable used to hold the returned inserted item ID
int insertedItemId = 0;
using (_connection)
{
// Creates a connection to the database and passes the SQL command in as the CommandText
_connection.Open ();
SqliteCommand dbcmd = _connection.CreateCommand ();
dbcmd.CommandText = command;
dbcmd.ExecuteNonQuery ();
// Accesses the Query method within this class and passes a SQL command
this.Query("select last_insert_rowid()",
(SqliteDataReader reader) => {
while (reader.Read ())
{
// Loop runs once and assigns the inserted items ID to the initialized insertedItemId variable
insertedItemId = reader.GetInt32(0);
}
}
);
dbcmd.Dispose ();
}
// Returns the inserted item ID
return insertedItemId;
}
}
}
|
6e59805d9da6b350a05109f950af61afda1d8df3
|
C#
|
tflynt91/TcpDirectorySyncronizer
|
/TCPSharpFileSync/LocalWorks/FileWorks/Filer.cs
| 3.109375
| 3
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TCPSharpFileSync
{
public class Filer
{
public string rootPath { get; private set; }
private List<string> filePathes;
private List<string> relativeFilePathes;
public Filer(string pathToDir)
{
rootPath = pathToDir;
filePathes = Directory.GetFiles(pathToDir, "*.*", SearchOption.AllDirectories).ToList();
FillCuttedPathes();
}
public List<string> GetLocalFiles()
{
return filePathes;
}
public List<string> GetRelativeFiles()
{
return relativeFilePathes;
}
private void FillCuttedPathes()
{
relativeFilePathes = new List<string>();
for (int i = 0; i < filePathes.Count; i++)
{
string s = filePathes[i].Replace(rootPath, "");
relativeFilePathes.Add(s);
}
}
public string GetRelativeFromLocal(string loc)
{
return relativeFilePathes[filePathes.FindIndex(x => x == loc)];
}
public string GetLocalFromRelative(string rel)
{
rel.Replace("?", "");
return filePathes[relativeFilePathes.FindIndex(x => x == rel)];
}
public bool CheckFileExistanceFromRelative(string rel)
{
return relativeFilePathes.FindIndex(x => x == rel) != -1;
}
public FileInfo GetLocalFileInfoFromRelative(string rel)
{
FileInfo fi = new FileInfo(GetLocalFromRelative(rel));
return fi;
}
}
}
|
a0ad94b0a62667ecabc4e53b75fc62a6d5b54759
|
C#
|
itplamen/Telerik-Academy
|
/Programming with C#/1. C# Fundamentals I/6.Loops/09-10.CatalanNumbers/CatalanNumbers.cs
| 4.15625
| 4
|
//9.In the combinatorial mathematics, the Catalan numbers are calculated by the following formula:
// (2*n)! / (n + 1)! * n!
//10.Write a program to calculate the Nth Catalan number by given N.
using System;
class CatalanNumbers
{
static void Main(string[] args)
{
Console.Write("Enter N: ");
double n = double.Parse(Console.ReadLine());
double factorialN = 1;
double factoraialMultipleByTwo = 1;
double factorialPlusOne = 1;
for (int i = 1; i <= n; i++)
{
factorialN *= i;
}
for (int i = 1; i <= 2 * n; i++)
{
factoraialMultipleByTwo *= i;
}
for (int i = 1; i <= n + 1; i++)
{
factorialPlusOne *= i;
}
Console.WriteLine("(2*n)! / (n + 1)! * n!");
Console.WriteLine("The result is: " + factoraialMultipleByTwo / (factorialPlusOne * factorialN));
}
}
|
9dd8fef78df3e2ddeb60012d3838ed3de5b27c87
|
C#
|
noc7c9/code-red-II
|
/Assets/Game/Scripts/World/RoomGenerator.cs
| 2.8125
| 3
|
using System.Collections.Generic;
using UnityEngine;
namespace Noc7c9.TheDigitalFrontier {
/* The class responsible for the generation of randomized rooms, given a set
* of parameters.
*/
public static class RoomGenerator {
// variables for one generation of a room
// static so that they are shared with helper methods
static Room room;
static RoomSettings settings;
static System.Random prng;
static FisherYates.ShuffleList<Coord> openCoords;
public static Room Generate(RoomSettings settings) {
RoomGenerator.settings = settings;
room = new Room(settings);
prng = new System.Random(settings.seed);
openCoords = new FisherYates.ShuffleList<Coord>(room.tileCount, prng);
// fill coord array and initialize room with empty tiles
for (int x = 0; x < settings.width; x++) {
for (int y = 0; y < settings.height; y++) {
Coord c = new Coord(x, y);
InsertEmpty(c);
openCoords.Add(c);
}
}
// place Warps
foreach (RoomSettings.WarpSettings warp in settings.warps) {
InsertWarp(warp.position, warp.target);
}
PlaceRandomObstacles();
PlaceEnemySpawnPoints();
return room;
}
static void InsertEmpty(Coord c) {
room.SetTile(c, new EmptyTile(c));
}
static void InsertObstacle(Coord c) {
float height = Mathf.Lerp(
settings.minObstacleHeight, settings.maxObstacleHeight,
(float) prng.NextDouble());
Color color = Color.Lerp(
settings.foregroundColor, settings.backgroundColor,
c.y / (float)room.size.y);
ObstacleTile obs = new ObstacleTile(c, height, color);
room.SetTile(c, obs);
}
static void InsertWarp(Coord c, int target) {
room.SetTile(c, new WarpTile(c, target));
}
static void PlaceRandomObstacles() {
int targetCount = (int)(room.tileCount * settings.obstaclePercent);
int currentCount = 0;
bool[,] obstacleMap = new bool[room.size.x, room.size.y];
for (int i = 0; i < targetCount; i++) {
Coord randomCoord = openCoords.Next();
obstacleMap[randomCoord.x, randomCoord.y] = true;
currentCount++;
if (randomCoord != room.center && (room.tileCount - currentCount)
== GetAccessibleCount(room.center, obstacleMap)) {
InsertObstacle(randomCoord);
openCoords.Remove(randomCoord);
} else {
obstacleMap[randomCoord.x, randomCoord.y] = false;
currentCount--;
}
}
}
static void PlaceEnemySpawnPoints() {
for (int i = 0; i < settings.numberOfEnemies; i++) {
room.SetEnemySpawnPoint(openCoords.Next());
}
}
static int GetAccessibleCount(Coord start, bool[,] blockedMap) {
int roomWidth = room.size.x;
int roomHeight = room.size.y;
bool[,] visited = new bool[roomWidth, roomHeight];
Queue<Coord> queue = new Queue<Coord>(roomWidth * roomHeight);
// starting point
queue.Enqueue(start);
visited[start.x, start.y] = true;
int accessibleCount = 1;
while (queue.Count > 0) {
Coord current = queue.Dequeue();
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
// ignore diagonals
if (x != 0 && y != 0) {
continue;
}
int neighbourX = current.x + x;
int neighbourY = current.y + y;
// ignore out of bound tiles
if (neighbourX < 0 || neighbourX >= roomWidth
|| neighbourY < 0 || neighbourY >= roomHeight) {
continue;
}
// ignore visited
if (visited[neighbourX, neighbourY]) {
continue;
}
// ignore blocked tiles
if (blockedMap[neighbourX, neighbourY]) {
continue;
}
// otherwise
visited[neighbourX, neighbourY] = true;
queue.Enqueue(new Coord(neighbourX, neighbourY));
accessibleCount++;
}
}
}
return accessibleCount;
}
}
}
|
4f1471c320a282842d9df57dbe74a0b1d97fa887
|
C#
|
ClausJohansen/XamarinImageConverter
|
/ImageConverter/Entities/ImageConversion.cs
| 2.859375
| 3
|
using ImageConverter.Enms;
using System.IO;
namespace ImageConverter.Entities
{
/// <summary>
/// Entity class: Holds information about a single image in the processing queue.
/// </summary>
public class ImageConversion
{
public FileInfo SourceFile { get; }
public string TargetName { get; set; }
public ImageConversionOptions ResizeBy { get; set; }
public int TargetWidth { get; set; }
public int TargetHeight { get; set; }
public TargetResolutionOptions TargetResolution { get; set; }
public bool Crop { get; internal set; }
public int CropSize { get; set; }
/// <summary>
/// Constructor: Create a new ImageConversion instance.
/// </summary>
/// <param name="file">Information about the source file of the image</param>
public ImageConversion(FileInfo sourceFile)
{
this.SourceFile = sourceFile;
ResizeBy = ImageConversionOptions.Width;
}
/// <summary>
/// The filename of the image.
/// </summary>
public override string ToString()
{
return SourceFile.Name;
}
}
}
|
697ad9f5948f5b2a0dab6da83b9a3d1cdff697e3
|
C#
|
shendongnian/download4
|
/code10/1815184-53482646-186588358-4.cs
| 3.25
| 3
|
public static IEnumerable<CostCenter> TakeWhileAndOneAfter
(IEnumerable<CostCenter> source, DateTime splitDate )
{
DateTime? earliestDate = null;
bool earliestFound = false;
foreach (CostCenter element in source)
{
if (!earliestFound && !(element.start > splitDate))
{
earliestFound = true;
earliestDate = element.start;
}
if (earliestFound)
{
if (element.start < earliestDate)
{
break;
}
else
{
element.start = splitDate;
}
}
yield return element;
}
}
|
57b292505741685e2cf6fa6c4fc16adf2b57cd41
|
C#
|
dncep/Woofer
|
/Woofer/Systems/Physics/CollisionBoxConverter.cs
| 2.578125
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EntityComponentSystem.Components;
using EntityComponentSystem.ComponentSystems;
using EntityComponentSystem.Entities;
using EntityComponentSystem.Events;
using EntityComponentSystem.Saves.Json;
using EntityComponentSystem.Saves.Json.Converter;
using EntityComponentSystem.Saves.Json.Objects;
namespace WooferGame.Systems.Physics
{
class CollisionBoxConverter : ITagConverter
{
public Type GetWorkingType() => typeof(CollisionBox);
public T FromJson<T>(TagMaster json, ITag value)
{
TagCompound obj = value as TagCompound;
CollisionBox box = new CollisionBox();
TagList bounds = obj.Get<TagList>("bounds");
box.X = (bounds[0] as TagDouble).Value;
box.Y = (bounds[1] as TagDouble).Value;
box.Width = (bounds[2] as TagDouble).Value;
box.Height = (bounds[3] as TagDouble).Value;
TagList faces = obj.Get<TagList>("faces");
box.TopFaceProperties = FaceFromJson(faces[0] as TagCompound);
box.RightFaceProperties = FaceFromJson(faces[1] as TagCompound);
box.BottomFaceProperties= FaceFromJson(faces[2] as TagCompound);
box.LeftFaceProperties = FaceFromJson(faces[3] as TagCompound);
return (T)Convert.ChangeType(box, typeof(T));
}
private CollisionFaceProperties FaceFromJson(TagCompound obj)
{
return new CollisionFaceProperties()
{
Enabled = obj.Get<TagBoolean>("enabled").Value,
Friction = obj.Get<TagDouble>("friction").Value,
Snap = obj.Get<TagBoolean>("snap").Value
};
}
public ITag ToJson(TagMaster json, object rawBox)
{
CollisionBox box = (CollisionBox)rawBox;
TagCompound obj = new TagCompound();
TagList rect = new TagList();
obj.AddProperty("bounds", rect);
rect.Add(box.X);
rect.Add(box.Y);
rect.Add(box.Width);
rect.Add(box.Height);
TagList faces = new TagList();
obj.AddProperty("faces", faces);
foreach(CollisionFaceProperties face in box.GetFaceProperties())
{
TagCompound faceObj = new TagCompound();
faces.Add(faceObj);
faceObj.AddProperty("enabled", face.Enabled);
faceObj.AddProperty("friction", face.Friction);
faceObj.AddProperty("snap", face.Snap);
}
return obj;
}
}
}
|
fc1affb4be1341f0e5df475799c0cda330d0a7e8
|
C#
|
ssjogedal/Contemporary_Software_Development_Lab2
|
/Contemporary_Software_Dev_Lab2_V3/Contemporary_Software_Dev_Lab2/Circle.cs
| 3.875
| 4
|
using System;
namespace Contemporary_Software_Dev_Lab2
{
// Circle class inherits from Shape class with the additional attribute "Radious", used to calculate Area.
public class Circle : Shape
{
double Radious { get; set; }
// Radious is calculated by dividing the circles circumference(Length) with 2*Pi
public Circle(int xCoordinate, int yCoordinate, int length, int points) : base(xCoordinate, yCoordinate, length, points)
{
this.Radious = this.Length / (2*Math.PI);
}
// GetArea() will return the area of the Circle by multiplying Pi with Radious^2
public override double GetArea()
{
return Math.PI * (Math.Pow(this.Radious, 2));
}
// IsInside() will return true if Point p is inside the Circle. We calculate this by:
// (Subtracting the Circles x value from the points x value)^2 and (Subtracting the Circles y value from the points y value)^2
// Add these togheter and check if the value is less than the Circles Radius^2.
public override bool IsInside(Point p)
{
return ((Math.Pow((p.XPoint - this.XCoordinate), 2) + Math.Pow((p.YPoint - this.YCoordinate), 2)) < Math.Pow(this.Radious, 2));
}
// GetTypePoint() return the shape-specific score
public override int GetTypePoint()
{
return 2;
}
}
}
|
47df4dd5ed1d696ff49d29b06e0052254afcadb5
|
C#
|
ghostmanexp/octalforty-brushie
|
/octalforty.Brushie.Text/Authoring/Textile/TextileAuthoringEngine.cs
| 3.015625
| 3
|
using System;
using octalforty.Brushie.Text.Authoring.Dom;
namespace octalforty.Brushie.Text.Authoring.Textile
{
/// <summary>
/// Authoring engine which parses Textile markup.
/// </summary>
/// <remarks>
/// Textile Quick Reference is available at http://hobix.com/textile/quick.html. More extensive one
/// can be found at http://www.textism.com/tools/textile/.<para />
/// <b>Block modifier syntax:</b><para />
/// <list type="bullet">
/// <item>
/// Heading: <c>h(1-6).</c><br />
/// Paragraphs beginning with <c>'hn. '</c> (where n is 1-6) are parsed into <see cref="Heading"/> objects.<br />
/// Example: <code>h1. Header...</code>
/// </item>
/// <item>
/// Paragraph: <c>p.</c> (also applied by default)<br />
/// Paragraphs are parsed into <see cref="Paragraph"/> objects.<br />
/// Example: <code>p. Text</code>
/// </item>
/// <item>
/// Blockquote: <c>bq.</c><br />
/// Blockquotes are parsed into <see cref="Blockquote"/> objects.<br />
/// Example: <code>Example: bq. Block quotation...</code>
/// </item>
/// <item>
/// Blockquote with citation: <c>bq.:http://citation.url</c><br />
/// Blockquotes with citations are parsed into <see cref="Blockquote"/> objects.<br />
/// Example: <code>bq.:http://textism.com/ Text...</code>
/// </item>
/// <item>
/// Footnote: <c>fn(1-100).</c><br />
/// Footnotes are parsed into <see cref="Footnote"/> objects.<br />
/// Example: <code>fn1. Footnote...</code>
/// </item>
/// <item>
/// Numeric list: <c>#</c>, <c>##</c><br />
/// Consecutive paragraphs beginning with <c>#</c> are parsed into <see cref="OrderedList"/>
/// and <see cref="ListItem"/> objects.<br />
/// Example:
/// <code>
/// # This is
/// # An ordered
/// ## List
/// </code>
/// </item>
/// <item>
/// Bulleted list: <c>*</c>, <c>**</c><br />
/// Consecutive paragraphs beginning with <c>*</c> are parsed into <see cref="UnorderedList"/>
/// and <see cref="ListItem"/> objects.<br />
/// Example:
/// <code>
/// * This is
/// * An unordered
/// ** List
/// </code>
/// </item>
/// </list>
/// <b>Phrase modifier syntax:</b><br />
/// <list type="table">
/// <listheader>
/// <term>Text block of this pattern...</term>
/// <description>
/// ...are parsed into <see cref="TextBlock"/> objects with this <see cref="TextBlockFormatting"/>
/// </description>
/// </listheader>
/// <item>
/// <term><c>_emphasis_</c></term>
/// <description><see cref="TextBlockFormatting.Emphasis"/></description>
/// </item>
/// <item>
/// <term><c>__italic__</c></term>
/// <description><see cref="TextBlockFormatting.Italics"/></description>
/// </item>
/// <item>
/// <term><c>*strong*</c></term>
/// <description><see cref="TextBlockFormatting.StrongEmphasis"/></description>
/// </item>
/// <item>
/// <term><c>**bold**</c></term>
/// <description><see cref="TextBlockFormatting.Bold"/></description>
/// </item>
/// <item>
/// <term><c>??citation??</c></term>
/// <description><see cref="TextBlockFormatting.Citation"/></description>
/// </item>
/// <item>
/// <term><c>-deleted text-</c></term>
/// <description><see cref="TextBlockFormatting.Deleted"/></description>
/// </item>
/// <item>
/// <term><c>+inserted text+</c></term>
/// <description><see cref="TextBlockFormatting.Inserted"/></description>
/// </item>
/// <item>
/// <term><c>^superscript^</c></term>
/// <description><see cref="TextBlockFormatting.Superscript"/></description>
/// </item>
/// <item>
/// <term><c>~subscript~</c></term>
/// <description><see cref="TextBlockFormatting.Subscript"/></description>
/// </item>
/// <item>
/// <term><c>@code@</c></term>
/// <description><see cref="TextBlockFormatting.Code"/></description>
/// </item>
/// <item>
/// <term><c>%(bob)span%</c></term>
/// <description>
/// All styles are applied, <see cref="TextBlock.Formatting"/> equals
/// <see cref="TextBlockFormatting.Span"/>
/// </description>
/// </item>
/// <item>
/// <term><c>==notextile==</c></term>
/// <description>
/// The text is parsed into <see cref="TextBlock"/> and left without further parsing
/// with <see cref="TextBlock.Formatting"/> set to <see cref="TextBlockFormatting.Unknown"/>
/// </description>
/// </item>
/// </list>
/// <b>Hyperlinks</b><br />
/// Hyperlink: <c>"Hyperlink text(Optional title)":Url</c><br />
/// Hyperlinks are parsed into <see cref="Hyperlink"/> objects.<br />
/// <b>Images</b><br />
/// Image: <c>!ImageUrl(Optional alternate text)!</c><br />
/// Images are parsed into <see cref="Image"/> objects.<br />
/// <b>Acronyms</b><br />
/// Acronym: <c>ABC(Always Be Closing)</c><br />
/// Acronyms are parsed into <see cref="Acronym"/> objects.<br />
/// <b>Tables</b><br />
/// Simple tables:
/// <code>
/// |a|simple|table|row|
/// |And|Another|table|row|
/// </code>
/// <code>
/// |_. A|_. table|_. header|_.row|
/// |A|simple|table|row|
/// </code>
/// Tables with attributes:
/// <code>
/// table{border:1px solid black}.
/// {background:#ddd;color:red}. |{}| | | |
/// </code>
/// <b>Applying Attributes</b><br />
/// Most anywhere Textile code is used, attributes such as arbitrary css style, CSS classes, and ids can be applied.
/// The syntax is fairly consistent.<para />
/// The following characters quickly alter the alignment of block elements:
/// <list type="table">
/// <item>
/// <term><c><</c></term>
/// <description>
/// <see cref="BlockElementAlignment.Left"/>.<br />
/// Example: <c>p<. Text</c> - left-aligned paragraph.
/// </description>
/// </item>
/// <item>
/// <term><c>></c></term>
/// <description>
/// <see cref="BlockElementAlignment.Right"/>.<br />
/// Example: <c>h3>. Heading</c> - right-aligned heading 3.
/// </description>
/// </item>
/// <item>
/// <term><c>=</c></term>
/// <description>
/// <see cref="BlockElementAlignment.Center"/>.<br />
/// Example: <c>p=. Text</c> - centered-aligned paragraph.
/// </description>
/// </item>
/// <item>
/// <term><c><></c></term>
/// <description>
/// <see cref="BlockElementAlignment.Justify"/>.<br />
/// Example: <c>p<>. Text</c> - justified paragraph.
/// </description>
/// </item>
/// </list>
/// These will change vertical alignment in table cells:
/// <list type="table">
/// <item>
/// <term><c>^</c></term>
/// <description>
/// <see cref="TableCellAlignment.Top"/>.<br />
/// Example: <c>|^. top-aligned table cell|</c>
/// </description>
/// </item>
/// <item>
/// <term><c>-</c></term>
/// <description>
/// <see cref="TableCellAlignment.Middle"/>.<br />
/// Example: <c>|-. middle-aligned table cell|</c>
/// </description>
/// </item>
/// <item>
/// <term><c>~</c></term>
/// <description>
/// <see cref="TableCellAlignment.Bottom"/>.<br />
/// Example: <c>|~. bottom-aligned table cell|</c>
/// </description>
/// </item>
/// </list>
/// Plain <c>(parentheses)</c> inserted between block syntax and the closing dot-space
/// indicate CSS classes and ids, which are parsed into <see cref="InlineElementAttributes.CssClass"/>
/// and <see cref="InlineElementAttributes.ID"/>, respecively.
/// <list type="table">
/// <item>
/// <term><c>p(hector). paragraph</c></term>
/// <description>
/// <see cref="Paragraph"/>'s <see cref="InlineElementAttributes.CssClass"/> equals <c>hector</c>.
/// </description>
/// </item>
/// <item>
/// <term><c>p(#fluid). paragraph</c></term>
/// <description>
/// <see cref="Paragraph"/>'s <see cref="InlineElementAttributes.ID"/> equals <c>fluid</c>.
/// </description>
/// </item>
/// <item>
/// <term><c>p(hector#fluid). paragraph</c></term>
/// <description>
/// CSS classes and ids can be combined. In this case, <see cref="Paragraph"/>'s
/// <see cref="InlineElementAttributes.ID"/> equals <c>fluid</c> and
/// <see cref="InlineElementAttributes.CssClass"/> equals <c>hector</c>.
/// </description>
/// </item>
/// </list>
/// Curly <c>{brackets}</c> insert arbitrary CSS styles, which are parsed into
/// <see cref="InlineElementAttributes.Style"/>.<br />
/// Examples:
/// <code>
/// p{line-height:18px}. paragraph
/// h3{color:red}. header 3
/// </code>
/// Square <c>[brackets]</c> insert language attributes, which are parsed into
/// <see cref="InlineElementAttributes.Language"/>.<br />
/// Examples:
/// <code>
/// p[no]. paragraph
/// %[fr]phrase%
///</code>
/// Usually Textile block element syntax requires a dot and space before the block
/// begins, but since lists don't, they can be styled just using braces:
/// <code>
/// #{color:blue} one
/// # big
/// # list
/// </code>
/// Using the <c>%</c> tag to style a phrase:
/// <code>
/// It goes like this, %{color:red}the fourth the fifth%.
/// </code>
/// </remarks>
public class TextileAuthoringEngine : AuthoringEngineBase
{
/// <summary>
/// Initializes a new instance of <see cref="TextileAuthoringEngine"/>.
/// </summary>
public TextileAuthoringEngine()
{
}
/// <summary>
/// Performs parsing of <paramref name="text"/> and converts it to HTML
/// using <see cref="HtmlAuthoringDomElementVisitor"/>.
/// </summary>
/// <param name="text"></param>
public String Author(String text)
{
DomDocument document = Parse(text);
HtmlAuthoringDomElementVisitor htmlAuthoringDomElementVisitor = new HtmlAuthoringDomElementVisitor();
document.Accept(htmlAuthoringDomElementVisitor);
return htmlAuthoringDomElementVisitor.Html;
}
}
}
|
675d60aa95be628f87842320a4311f2d5ebbdb0e
|
C#
|
Tommysvarva/get-academy-stuff
|
/C-sharp-objectorientering/C-sharp-objectorientering/Place.cs
| 3.609375
| 4
|
namespace C_sharp_objectorientering
{
class Place
{
public string PlaceName { get; private set; }
public string Municipality { get; private set; }
public string Region { get; private set; }
public Place(string placeName, string municipality, string region)
{
PlaceName = placeName;
Municipality = municipality;
Region = region;
}
public void ShowPlace()
{
var LabelWidth = 8;
GetLineSeperation(LabelWidth);
ShowFieldNameAndValue("Sted", LabelWidth, PlaceName);
ShowFieldNameAndValue("Kommune", LabelWidth, Municipality);
ShowFieldNameAndValue("Fylke", LabelWidth, Region);
GetLineSeperation(LabelWidth);
}
private void GetLineSeperation(int count)
{
count += 12;
System.Console.WriteLine(string.Empty.PadLeft(count, '*'));
}
private void ShowFieldNameAndValue(string label, int labelWidth, string fieldValue)
{
labelWidth -= label.Length;
System.Console.WriteLine($"{label}:{string.Empty.PadLeft(labelWidth, ' ')} {fieldValue}");
}
}
}
|
1b614b0bd6040f47fd041fd4958a2fd6b902588f
|
C#
|
ggrachdev/TDD_lessons
|
/003_Тестирование с использованием Mock/Mocks/013_EventRelatedTests/Presenter.cs
| 2.5625
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _013_EventRelatedTests
{
class Presenter
{
IModel model = null;
IView window = null;
public Presenter(IView window, IModel model)
{
this.model = model;
this.window = window;
this.window.Load += new EventHandler(View_Load);
}
void View_Load(object sender, System.EventArgs e)
{
throw new NotImplementedException();
}
}
}
|
3c5049f6ae66876d03ccc88416ef23c24f974087
|
C#
|
Nonobis/SimpleExtension
|
/test/SimpleExtension.Core.Tests/UrlExtensionsTest.cs
| 2.8125
| 3
|
using System.Threading.Tasks;
using Xunit;
namespace SimpleExtension.Core.Tests
{
/// <summary>
/// Unit Test on Url Extensions
/// </summary>
public class UrlExtensionsTest
{
/// <summary>When get server certificate asynchronous is returned asynchronous.</summary>
/// <param name="url">URL of the resource.</param>
/// <returns>A Task.</returns>
[Theory]
[InlineData("https://www.google.fr")]
public async Task WhenGetServerCertificateAsyncIsReturnedAsync(string url)
{
var DownloadedCertificate = await url.GetServerCertificateAsync();
Assert.NotNull(DownloadedCertificate);
}
/// <summary>
/// When get server certificate public key asynchronous is returned asynchronous.
/// </summary>
/// <param name="url"> URL of the resource.</param>
/// <returns>A Task.</returns>
[Theory]
[InlineData("https://www.google.fr")]
public async Task WhenGetServerCertificatePublicKeyAsyncIsReturnedAsync(string url)
{
var DownloadedCertificate = await url.GetServerCertificateAsync();
Assert.NotNull(DownloadedCertificate);
string? publicKey = await url.GetServerCertificatePublicKeyAsync();
Assert.NotNull(publicKey);
Assert.Equal(publicKey, DownloadedCertificate?.GetPublicKeyString());
}
}
}
|
b3595efe58718530c373e1ae4b0b4202f889c9cd
|
C#
|
c-rblake/Personalregister
|
/Employee.cs
| 3.546875
| 4
|
namespace Personalregister
{
public class Employee
{
//public List<string> names = new(); //STATE, inte bra Public Field.
//public List<float> salaries = new();
// List<float> salaries = new(); NOT ACCESSIBLE, default is private
public string Name { get; } // Set with constructor
public float Salary { get; }
public SalaryLevel SalaryLevel => Salary < 25000 ? SalaryLevel.junior : SalaryLevel.senior;
// SAMMA som
//public SalaryLevel SalaryLevel2
//{
// get
// {
// if (Salary < 25000)
// return SalaryLevel.Junior;
// else
// return SalaryLevel.Senior;
// }
//}
public Employee(string name, int salary)
{
this.Name = name;
this.Salary = salary;
}
public override string ToString()
{
return $"Namn: {this.Name} Lön: {this.Salary}";
}
//public void AddName(string name) // BEHAVIOR
//{
// names.Add(name);
//}
//public void AddSalary(float salary)
//{
// salaries.Add(salary);
//}
}
}
|
6a080ec0f8b5549b1aab83900209cfb859bcd82f
|
C#
|
hockeygoalie78/ktaneDaylightDirections
|
/Assets/Scripts/DaylightDirections.cs
| 2.546875
| 3
|
using System;
using System.Collections;
using System.Linq;
using UnityEngine;
using KModkit;
using Random = UnityEngine.Random;
/// <summary>
/// Module made by hockeygoalie78
/// Based on the condition of the bomb and the day, determine which way to travel.
/// </summary>
public class DaylightDirections : MonoBehaviour {
public KMBombInfo bombInfo;
public KMAudio bombAudio;
public GameObject arrowModel;
public GameObject leftSun;
public GameObject rightSun;
public KMSelectable clockwiseButton;
public KMSelectable counterClockwiseButton;
public KMSelectable submitButton;
public Material[] arrowMaterials;
public Sprite activeSun;
public Sprite deactiveSun;
private KMBombModule bombModule;
private int materialNumber; //0 is red, 1 is blue, 2 is yellow, 3 is green, 4 is purple
private int rotation; //0 is directly to the right
private Vector3 rotationVector;
private int rightSunActive;
private string serialNumber;
private bool serialLastDigitEven;
private bool serialVowel;
private bool serialLetterSpecial; //4 letters in the serial number
private int litIndicatorCount;
private int aaBatteryCount;
private int dBatteryCount;
private int batteryCount;
private bool containsSpecificPorts; //Contains Serial/DVI-D port but no Parallel ports
private bool containsDuplicatePort;
private int solutionRotation;
private static int moduleIdCounter = 1;
private int moduleId;
void Start ()
{
//Set module ID
moduleId = moduleIdCounter++;
//Delegates for button interactions
clockwiseButton.OnInteract += delegate { Rotate(true); return false; };
counterClockwiseButton.OnInteract += delegate { Rotate(false); return false; };
submitButton.OnInteract += delegate { CheckSolution(); return false; };
//Set the color of the arrow
materialNumber = Random.Range(0, 5);
arrowModel.GetComponent<Renderer>().material = arrowMaterials[materialNumber];
//Set the initial rotation of the arrow
rotation = Random.Range(0, 8) * 45;
rotationVector = new Vector3(0, rotation, 0);
arrowModel.transform.Rotate(rotationVector);
rotationVector.y = 45;
Debug.LogFormat(@"[Daylight Directions #{0}] Starting rotation is {1} degrees. 0 degrees will point to the right.", moduleId, 360 - rotation);
//Set which sun is active
rightSunActive = Random.Range(0, 2);
if(rightSunActive == 1)
{
rightSun.GetComponent<SpriteRenderer>().sprite = activeSun;
leftSun.GetComponent<SpriteRenderer>().sprite = deactiveSun;
}
else
{
rightSun.GetComponent<SpriteRenderer>().sprite = deactiveSun;
leftSun.GetComponent<SpriteRenderer>().sprite = activeSun;
}
//Serial number
serialNumber = bombInfo.GetSerialNumber();
serialLastDigitEven = int.Parse(serialNumber.Substring(5)) % 2 == 0;
serialVowel = serialNumber.Any("AEIOU".Contains);
serialLetterSpecial = bombInfo.GetSerialNumberLetters().Count() >= 4;
//Lit indicators
litIndicatorCount = bombInfo.GetOnIndicators().Count();
//Battery counts
aaBatteryCount = bombInfo.GetBatteryCount(2) + bombInfo.GetBatteryCount(3) + bombInfo.GetBatteryCount(4);
dBatteryCount = bombInfo.GetBatteryCount(1);
batteryCount = aaBatteryCount + dBatteryCount;
//Contains Serial/DVI-D port but no Parallel ports
containsSpecificPorts = (bombInfo.IsPortPresent("Serial") || bombInfo.IsPortPresent("DVI")) && !bombInfo.IsPortPresent("Parallel");
//Contains duplicate ports
containsDuplicatePort = bombInfo.IsDuplicatePortPresent();
//Other variables as needed
bombModule = GetComponent<KMBombModule>();
//Calculate solution
CalculateSolution();
}
/// <summary>
/// Helper method to rotate the arrow when one of the rotation buttons is pressed
/// </summary>
/// <param name="clockwise">True if the button is the clockwise button; false otherwise</param>
private void Rotate(bool clockwise)
{
if(clockwise)
{
arrowModel.transform.Rotate(rotationVector);
rotation = (rotation + 45) % 360;
clockwiseButton.AddInteractionPunch(.2f);
bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
Debug.LogFormat(@"[Daylight Directions #{0}] Rotated arrow clockwise. Rotation is now {1} degrees.", moduleId, (360 - rotation) % 360);
}
else
{
arrowModel.transform.Rotate(-rotationVector);
rotation = (rotation + 315) % 360;
counterClockwiseButton.AddInteractionPunch(.2f);
bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
Debug.LogFormat(@"[Daylight Directions #{0}] Rotated arrow counterclockwise. Rotation is now {1} degrees.", moduleId, (360 - rotation) % 360);
}
}
/// <summary>
/// Calculates the solution of the module
/// </summary>
private void CalculateSolution()
{
//Direction calculation
//If the bomb has at least two of the same port, the direction is east
if(containsDuplicatePort)
{
solutionRotation = 0;
Debug.LogFormat(@"[Daylight Directions #{0}] Duplicate port present. Starting solution rotation is 0 degrees.", moduleId);
}
//If the bomb has a Serial or DVI-D port but no Parallel ports, the direction is southwest., the direction is southwest
else if(containsSpecificPorts)
{
solutionRotation = 135;
Debug.LogFormat(@"[Daylight Directions #{0}] Bomb has a Serial or DVI-D port but no Parallel ports. Starting solution rotation is 225 degrees.", moduleId);
}
//If the serial number has four letters, the direction is southeast
else if(serialLetterSpecial)
{
solutionRotation = 45;
Debug.LogFormat(@"[Daylight Directions #{0}] Serial number has 4 letters. Starting solution rotation is 315 degrees.", moduleId);
}
//If the bomb has at least two lit indicators, the direction is northwest
else if(litIndicatorCount >= 2)
{
solutionRotation = 225;
Debug.LogFormat(@"[Daylight Directions #{0}] At least two lit indicators present. Starting solution rotation is 135 degrees.", moduleId);
}
//If the bomb has a D battery, the direction is north
else if(dBatteryCount >= 1)
{
solutionRotation = 270;
Debug.LogFormat(@"[Daylight Directions #{0}] Bomb has a D battery. Starting solution rotation is 90 degrees.", moduleId);
}
//If the serial number has a vowel, the direction is west
else if(serialVowel)
{
solutionRotation = 180;
Debug.LogFormat(@"[Daylight Directions #{0}] Serial number has a vowel. Starting solution rotation is 180 degrees.", moduleId);
}
//If the bomb has more than four batteries, the direction is south
else if(batteryCount > 4)
{
solutionRotation = 90;
Debug.LogFormat(@"[Daylight Directions #{0}] Bomb has more than four batteries. Starting solution rotation is 270 degrees.", moduleId);
}
//Otherwise, the direction is northeast
else
{
solutionRotation = 315;
Debug.LogFormat(@"[Daylight Directions #{0}] None of the conditions met. Starting solution rotation is 45 degrees.", moduleId);
}
//Sun consideration
if ((rightSunActive == 1 && !serialLastDigitEven) || (rightSunActive == 0 && serialLastDigitEven))
{
solutionRotation += 180;
Debug.LogFormat(@"[Daylight Directions #{0}] Sun conditions have flipped the orientation. Solution rotation is now {1} degrees.", moduleId, 360 - (solutionRotation % 360));
}
//Material adjustments
//If the compass arrow is blue, rotate the direction 180 degrees
if (materialNumber == 1)
{
solutionRotation += 180;
Debug.LogFormat(@"[Daylight Directions #{0}] Arrow is blue, so it rotates 180 degrees. Final solution rotation is {1} degrees.", moduleId, 360 - (solutionRotation % 360));
}
//If the compass arrow is purple, rotate the direction 45 degrees clockwise
else if (materialNumber == 4)
{
solutionRotation += 45;
Debug.LogFormat(@"[Daylight Directions #{0}] Arrow is purple, so it rotates 45 degrees clockwise. Final solution rotation is {1} degrees.", moduleId, 360 - (solutionRotation % 360));
}
//If the compass arrow is green, rotate the direction 135 degrees counterclockwise
else if (materialNumber == 3)
{
solutionRotation += 225; //225 clockwise = 135 counterclockwise
Debug.LogFormat(@"[Daylight Directions #{0}] Arrow is green, so it rotates 135 degrees counterclockwise. Final solution rotation is {1} degrees.", moduleId, 360 - (solutionRotation % 360));
}
//If the compass arrow is yellow, rotate the direction 90 degrees clockwise
else if (materialNumber == 2)
{
solutionRotation += 90;
Debug.LogFormat(@"[Daylight Directions #{0}] Arrow is yellow, so it rotates 90 degrees clockwise. Final solution rotation is {1} degrees.", moduleId, 360 - (solutionRotation % 360));
}
//Otherwise, don't adjust the direction at all
else
{
Debug.LogFormat(@"[Daylight Directions #{0}] Arrow is red, so no changes occur. Final solution rotation is {1} degrees.", moduleId, 360 - (solutionRotation % 360));
}
solutionRotation %= 360;
}
/// <summary>
/// Checks to see if the submitted direction is correct and handles the pass or strike accordingly
/// </summary>
private void CheckSolution()
{
submitButton.AddInteractionPunch(.5f);
bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
//Handle solution comparison to submission
if(rotation == solutionRotation)
{
bombModule.HandlePass();
Debug.LogFormat(@"[Daylight Directions #{0}] Submitted rotation is correct. Module passed.", moduleId);
}
else
{
bombModule.HandleStrike();
Debug.LogFormat(@"[Daylight Directions #{0}] Submitted rotation is incorrect. Strike occurred.", moduleId);
}
}
void NullableParse(string str, out int? i)
{
int n;
i = int.TryParse(str, out n) ? (int?)n : null;
}
/// <summary>
/// Twitch plays support created by Qkrisi
/// </summary>
private string TwitchHelpMessage = "Use '!{0} <button> <n>' to press a button n times! Button can be: cw, clockwise, ccw, counterclockwise, submit. By default, n is 1, maximum is 8.";
IEnumerator ProcessTwitchCommand(string command)
{
var options = command.ToLowerInvariant().Split(' ');
string button = null;
int? t = null;
try
{
button = options[0];
NullableParse(options[1], out t);
}
catch(IndexOutOfRangeException) { }
if(t!=null && (t<1 || t>8))
{
yield return null;
yield return "sendtochaterror Number out of range";
yield break;
}
KMSelectable btn = null;
switch(button)
{
case "cw":
case "clockwise":
btn = clockwiseButton;
break;
case "ccw":
case "counterclockwise":
btn = counterClockwiseButton;
break;
case "submit":
btn = submitButton;
t = 1;
break;
default:
yield return null;
yield return "sendtochaterror Invalid button";
yield break;
}
for(int i = 0;i < (t == null ? 1 : t);i++)
{
yield return null;
btn.OnInteract();
}
}
}
|
d27a3633e500508584c71c8091adf777217f5382
|
C#
|
yudaitomida/CESA2019
|
/PlanetCleaner/Assets/script/CreateCube/InHole.cs
| 2.515625
| 3
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InHole : MonoBehaviour
{
public int speed;
[SerializeField]
GameObject Target;
bool ThroughCollider;
float time;
int player_state;
// Start is called before the first frame update
void Start()
{
speed = 7;
player_state = 0;
ThroughCollider = false;
}
// Update is called once per frame
void Update()
{
this.gameObject.transform.Rotate(new Vector3(0.0f, 0.0f, speed));
if(ThroughCollider == true)
{
time += Time.deltaTime;
}
if(time >= 1.0f)
{
Target.gameObject.GetComponent<SphereCollider>().enabled = true;
ThroughCollider = false;
time = 0.0f;
}
}
void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag == "Player")
{
Target.gameObject.GetComponent<SphereCollider>().enabled = false;
ThroughCollider = true;
col.gameObject.transform.position = Target.gameObject.transform.position;
player_state = (player_state + 1) % 2;
}
}
public int PlayerState()
{
return player_state;
}
}
|
1f2e034044789a2898ac4d7b4c9e0a2f95e844ce
|
C#
|
rdgnunes/Vimaponto-Avaliacao
|
/VimapontoTest.Controller/Data/TipoData.cs
| 2.640625
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VimapontoTest.Model;
using System.Data;
using System.Data.SqlClient;
namespace VimapontoTest.Controller.Data
{
public class TipoData : AppGlobal
{
public List<Tipo> ListarTodos()
{
using (var cmd = DbConnection().CreateCommand())
{
cmd.CommandText = "SELECT TipoId, Descricao " +
"FROM Tipo ";
dtAdapter = new SqlDataAdapter(cmd.CommandText, DbConnection());
dtAdapter.Fill(dsGlobal, "Tipo");
}
dtTable = dsGlobal.Tables["Tipo"];
var oTipos = new List<Tipo>();
for (int i = 0; i < dtTable.Rows.Count; i++)
{
Tipo oTipo = new Tipo();
oTipo.TipoId = int.Parse(dtTable.Rows[i]["TipoId"].ToString());
oTipo.Descricao = dtTable.Rows[i]["Descricao"].ToString();
oTipos.Add(oTipo);
}
return oTipos;
}
public Tipo CarregarPorId(int pTipoId)
{
using (var cmd = DbConnection().CreateCommand())
{
cmd.CommandText = string.Format("SELECT TipoId, Descricao " +
"FROM Tipo " +
"WHERE TipoId = '{0}'", pTipoId.ToString());
dtAdapter = new SqlDataAdapter(cmd.CommandText, DbConnection());
dtAdapter.Fill(dsGlobal, "Tipo");
}
dtTable = dsGlobal.Tables["Tipo"];
Tipo oTipo = new Tipo();
if (dtTable.Rows.Count > 0)
{
oTipo.TipoId = int.Parse(dtTable.Rows[0]["TipoId"].ToString());
oTipo.Descricao = dtTable.Rows[0]["Descricao"].ToString();
}
return oTipo;
}
public void Inserir(Tipo oTipo)
{
using (var cmd = DbConnection().CreateCommand())
{
cmd.CommandText = string.Format("INSERT INTO Tipo (Descricao) " +
"VALUES('{0}'", oTipo.Descricao);
dtAdapter = new SqlDataAdapter(cmd.CommandText, DbConnection());
dtAdapter.Fill(dsGlobal, "Tipo");
}
}
public void Alterar(Tipo oTipo)
{
using (var cmd = DbConnection().CreateCommand())
{
cmd.CommandText = string.Format("UPDATE Tipo SET Descricao = '{0}' " +
"WHERE TipoId = '{1}' ", oTipo.Descricao, oTipo.TipoId);
dtAdapter = new SqlDataAdapter(cmd.CommandText, DbConnection());
dtAdapter.Fill(dsGlobal, "Tipo");
}
}
public void Excluir(Tipo oTipo)
{
using (var cmd = DbConnection().CreateCommand())
{
cmd.CommandText = string.Format("DELETE Tipo " +
"WHERE TipoId = '{0}' ", oTipo.TipoId);
dtAdapter = new SqlDataAdapter(cmd.CommandText, DbConnection());
dtAdapter.Fill(dsGlobal, "Tipo");
}
}
}
}
|
7e86fec6ea02f14d544bd89badee0d0c036c9831
|
C#
|
Amatsugu/Sandbox
|
/FakkuMetaScraper/Models/EntryInfo.cs
| 2.59375
| 3
|
using Flurl;
using Superpower;
using Superpower.Parsers;
using Superpower.Tokenizers;
using System.Text;
namespace FakkuMetaScraper.Models;
public class EntryInfo
{
public string Filepath { get; }
public List<string> Tags { get; set; } = new List<string>();
public string Name { get; }
public string Artist { get; }
public string Collection { get; }
public string Description { get; set; }
private static readonly TextParser<string> _artistParser = from open in Character.EqualTo('[')
from artist in Character.Except(']').Many()
from close in Span.EqualTo("] ")
select new string(artist);
private static readonly TextParser<string> _collectionNameParser = from open in Character.EqualTo('(')
from collection in Character.ExceptIn('(', ')').Many()
from close in Span.EqualTo(").zip").AtEnd()
select new string(collection);
private static readonly TextParser<char> _nameParser = from open in Character.LetterOrDigit
from rest in Character.AnyChar
select open;
private static readonly Tokenizer<TitleTokenType> _titleTokenzier = new TokenizerBuilder<TitleTokenType>()
.Match(_artistParser, TitleTokenType.Artist)
.Match(_collectionNameParser, TitleTokenType.Collection)
.Match(Character.AnyChar, TitleTokenType.Name)
.Build();
//public EntryInfo(string name, string artist, string collection)
//{
// Name = name;
// Artist = artist;
// Collection = collection;
// File
//}
public EntryInfo(string filepath)
{
Filepath = filepath;
var filename = Path.GetFileName(filepath);
(Name, Artist, Collection) = ParseFilename(filename);
Description = string.Empty;
}
public static (string name, string artist, string collection) ParseFilename(string filename)
{
var tokens = _titleTokenzier.Tokenize(filename);
var artist = _artistParser.Parse(tokens.First(t => t.Kind == TitleTokenType.Artist).ToStringValue());
var colleciton = _collectionNameParser.Parse(tokens.First(t => t.Kind == TitleTokenType.Collection).ToStringValue());
var name = string.Join("", tokens.Where(t => t.Kind == TitleTokenType.Name)
.Select(t => t.ToStringValue())
.ToList()).Trim();
return (name, artist, colleciton);
}
public string GetEntryUrl()
{
return "https://fakku.net/hentai/".AppendPathSegment(PrepareUrlName());
}
private string PrepareUrlName()
{
var specialParser = from c in Character.Matching(c => c > 122, "")
select c;
var tokenizer = new TokenizerBuilder<TokenType>()
.Ignore(Character.In('(', ')', '!', '?', '.', ':', ',', ';', '/', '\\', '_', '#', '$', '@', '~', '&', '^', '%', '\''))
.Match(specialParser, TokenType.Special)
.Match(Character.AnyChar, TokenType.Letter)
.Build();
var tokens = tokenizer.Tokenize(Name.ToLowerInvariant());
var sb = new StringBuilder();
foreach (var token in tokens)
{
switch(token.Kind)
{
case TokenType.Letter:
var str = token.ToStringValue()
.Replace(' ', '-')
.Replace("★", "bzb")
.Replace("(", "")
.Replace(")", "");
if (sb.Length > 1 && str == "-" && sb[^1] == '-')
continue;
sb.Append(str);
break;
case TokenType.Special:
var sp = token.ToStringValue()
.Replace("★", "bzb");
sb.Append(sp);
break;
}
}
sb.Append("-english");
if (sb[0] == '-')
return sb.ToString()[1..];
return sb.ToString();
}
private enum TitleTokenType
{
Artist,
Collection,
Name
}
private enum TokenType
{
Letter,
Special,
}
public static string GetReplacement(char c)
{
return c switch
{
' ' => "-",
',' => "",
'-' => "-",
'\'' => "-",
_ => c.ToString()
};
}
public static Dictionary<char, string> REPLACEMENTS = new Dictionary<char, string>()
{
{ ' ', "-" },
{ ',', "" },
{ '-', "-" },
{ '★', "" }
};
}
|
f5e77adf4c3fccbd50776e208da5c81a31a817eb
|
C#
|
anushrostomyan/BestBuyProject
|
/BusinessLayer/Entity/Branch.cs
| 2.765625
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DataAccessLayer.DataAccess;
using BusinessLayer.Enums;
namespace BusinessLayer.Entity
{
public class Branch
{
public int? ID { get; private set; }
public double? X_Coordinate { get; private set; }
public double? Y_Coordinate { get; private set; }
public string Address { get; private set; }
public string Name { get; private set; }
public string PhoneNumber { get; private set; }
public string WorkingHours { get; private set; }
public string District { get; private set; }
public Status? Status { get; private set; }
//public int? ID { get; set; }
//public double? X_Coordinate { get; set; }
//public double? Y_Coordinate { get; set; }
//public string Address { get; set; }
//public string Name { get; set; }
//public string PhoneNumber { get; set; }
//public string WorkingHours { get; set; }
//public string District { get; set; }
//public Status? Status { get; set; }
public Branch()
{
}
public Branch(int? Id = null,
string address = null,
string name = null,
string phoneNumber = null,
string workingHours = null,
string district = null,
Status? status = null,
float? xCoordinate = null,
float? yCoordinate = null)
{
this.ID = Id;
this.Address = address;
this.Name = name;
this.PhoneNumber = phoneNumber;
this.WorkingHours = workingHours;
this.District = district;
this.Status = status;
this.X_Coordinate = xCoordinate;
this.Y_Coordinate = yCoordinate;
}
private Branch(Dictionary<string, object> element)
{
this.ID = (int?)element["ID"];
this.Address = (string)element["Adress"];
this.Name = (string)element["Name"];
this.PhoneNumber = (string)element["PhoneNumber"];
this.WorkingHours = (string)element["WorkingHours"];
this.District = (string)element["District"];
this.Status = (Status)(byte?)element["Status"];
this.X_Coordinate = (double?)element["X_Coordinate"];
this.Y_Coordinate = (double?)element["Y_Coordinate"];
}
public List<Branch> GetAllBranches()
{
try
{
DbDataAccess db = new DbDataAccess();
List<Branch> BranchesList = null;
List<Dictionary<string, object>> result = db.ExecuteStoredProcedure("GetAllBranches", new List<SPParam>());
if (result != null && result.Count != 0)
{
BranchesList = new List<Branch>(result.Count);
foreach (Dictionary<string,object> branch in result)
{
Branch _branches = new Branch(branch);
BranchesList.Add(_branches);
}
}
return BranchesList;
}
catch (Exception ex)
{
return null;
}
}
}
}
|
f8e247c9f0b9f66a466ce705faa913f32c18275a
|
C#
|
christinebittle/crud_essentials
|
/HTTP5101_School_System/NewStudent.aspx.cs
| 2.578125
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace HTTP5101_School_System
{
public partial class NewStudent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Add_Student(object sender, EventArgs e)
{
//create connection
StudentController db = new StudentController();
//create a new particular student
Student new_student = new Student();
//set that student data
new_student.SetFname(student_fname.Text);
new_student.SetLname(student_lname.Text);
new_student.SetNumber(student_number.Text);
new_student.SetEnrolDate(DateTime.Now);
//add the student to the database
db.AddStudent(new_student);
Response.Redirect("ListStudents.aspx");
}
}
}
|
0902a631bc8130b395021494abe28ce237c51f25
|
C#
|
SCCapstone/RogueGames
|
/Assets/Scripts/Menu and UI/Health.cs
| 2.59375
| 3
|
using UnityEngine;
using UnityEngine.UI;
public class Health : MonoBehaviour {
public int health;
public int numberOfHearts;
public bool audioHasPlayed;
public Image[] hearts;
public Sprite fullHeart;
public Sprite emptyHeart;
public GameObject deathPopUp;
public GameObject pauseCV;
public AudioSource playerAudio;
public AudioClip deathSFX;
void Start() {
audioHasPlayed = false;
GetComponent<Player>().enabled = true;
pauseCV.GetComponent<PauseMenu>().enabled = true;
deathPopUp.SetActive(false);
}
void Update() {
for (int i = 0; i < hearts.Length; i++) {
//Makes sure player health doesn't exceed the max number of hearts available.
if (health > numberOfHearts) {
health = numberOfHearts;
}
// Checks for current player health, denotes full if good, empty if bad.
if (i < health) {
hearts[i].sprite = fullHeart;
} else {
hearts[i].sprite = emptyHeart;
}
// Determines the number of max heart containers.
// In this prototype, the absolute max is 5 hearts. Can reduce in Unity to 4,3,etc.
if (i < numberOfHearts) {
hearts[i].enabled = true;
} else {
hearts[i].enabled = false;
}
// Player has died, prompt them to restart.
if (health == 0) {
if (!audioHasPlayed) {
playerAudio.PlayOneShot(deathSFX, 0.25f);
audioHasPlayed = true;
}
//playerAudio.clip = deathSFX;
//playerAudio.Play();
GetComponent<Player>().enabled = false;
pauseCV.GetComponent<PauseMenu>().enabled = false;
deathPopUp.SetActive(true);
}
}
}
}
|
08dfb596782eef4cb50bf758cd4e7dea3914bb68
|
C#
|
Olverine/Xamarin-space-game
|
/App1/Vector.cs
| 2.890625
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace App1
{
public class Vector
{
public float x;
public float y;
public float z;
public Vector(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
public Vector(float x, float y)
{
this.x = x;
this.y = y;
this.z = 0;
}
public static Vector operator +(Vector v1, Vector v2)
{
return new Vector(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
public static Vector operator -(Vector v1, Vector v2)
{
return new Vector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
public static Vector operator *(Vector v1, Vector v2)
{
return new Vector(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
}
public static Vector operator *(Vector v1, float f)
{
return new Vector(v1.x * f, v1.y * f, v1.z * f);
}
}
}
|
8a540345f26647a8e004911cd63ef51d1209914e
|
C#
|
dkasavetova/TelerikAcademy
|
/1.Programming/3.OOP/1.Defining-Classes-Part-I/DefiningClassesPartOne/GSMTestApp/GSMTest.cs
| 2.765625
| 3
|
using System;
class GSMTest
{
static void Main()
{
GSM[] gsmArray = new GSM[4]
{
new GSM("Galaxy S3", "Samsung"),
new GSM("Lumia 620", "Nokia", 324M),
new GSM("Z10", "Blackberry", 869.70M, "John Doe", new Battery("bbb", 312, 10, BatteryType.LiIon), null),
new GSM("One", "HTC", 479M, "Pesho", new Battery("someBattery"), new Display(4.7, 16000000))
};
foreach (var gsm in gsmArray)
{
Console.WriteLine(gsm);
}
Console.WriteLine(GSM.IPhone4S);
}
}
|
1c5d5a2083ad90d49297d8077117736cfb37e3c9
|
C#
|
MahmoudSabra1/MonsterGo-VR-game
|
/Assets/DataFiles/Scripts/RandomForest.cs
| 2.546875
| 3
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomForest : MonoBehaviour
{
public GameObject[] trees;
public GameObject[] rockgrass;
void Start()
{
for (int i = 0; i < Random.Range(700, 800); i++)
{
treecount();
}
for (int i = 0; i < Random.Range(200, 300); i++)
{
rockgrasscount();
}
}
// Update is called once per frame
void Update()
{
}
void treecount()
{
int treeindex = Random.Range(0, trees.Length);
GameObject rforest = Instantiate(trees[treeindex]);
rforest.transform.parent = transform;
rforest.transform.localPosition = new Vector3(Random.Range(-90, 90), 0.0f, Random.Range(-90, 90));
}
void rockgrasscount()
{
int rockgrassindex = Random.Range(0, rockgrass.Length);
GameObject rrocckgrass = Instantiate(rockgrass[rockgrassindex]);
rrocckgrass.transform.parent = transform;
rrocckgrass.transform.localPosition = new Vector3(Random.Range(-90, 90), 0.0f, Random.Range(-90, 90));
}
}
|
00c8b20903a79301173cf0be62966c6a9b068e40
|
C#
|
RobThree/EF_Stringlength_Bug
|
/EF_Stringlength_Bug/Customer.cs
| 2.65625
| 3
|
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace EF_Stringlength_Bug
{
[Index(nameof(CustomerRecord.Name), IsUnique = true)]
public record CustomerRecord(
int Id,
[MaxLength(50)]
//[StringLength(50)]
string Name
);
[Index(nameof(CustomerClass.Name), IsUnique = true)]
public class CustomerClass
{
public int Id { get; init; }
[MaxLength(50)]
//[StringLength(50)]
public string Name { get; init; }
}
}
|
bf497c2bece2948e7aa3536babb46ef0f5355e7a
|
C#
|
student195756/technologie-programowania
|
/zadanie1/zadanie1/BazaDanych.cs
| 2.578125
| 3
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace zadanie1
{
[Serializable()]
public class BazaDanych : ISerializable
{
public List<Klient> wykazKlientow = new List<Klient>();
public KatalogGier katalogGier = new KatalogGier();
public ObservableCollection<Zdarzenie> zdarzenia = new ObservableCollection<Zdarzenie>();
public List<StanGry> stanGier = new List<StanGry>();
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("wykaz klientow", wykazKlientow);
info.AddValue("katalog gier", katalogGier);
info.AddValue("zdarzenia", zdarzenia);
info.AddValue("stanGier", stanGier);
}
public BazaDanych() { }
public BazaDanych(SerializationInfo info, StreamingContext context)
{
wykazKlientow = ( List<Klient>) info.GetValue("wykaz klientow", typeof(List<Klient>) );
katalogGier = (KatalogGier) info.GetValue( "katalog gier", typeof(KatalogGier) );
zdarzenia = (ObservableCollection<Zdarzenie>) info.GetValue( "zdarzenia", typeof(ObservableCollection<Zdarzenie>) );
stanGier = (List<StanGry>) info.GetValue( "stanGier", typeof(List<StanGry>) );
}
}
}
|
cb39aa19ddd5bab73327f0db1aa02e1aa73b215f
|
C#
|
hasanfurkanfidan/UdemySignalR
|
/UdemySignalR.Server/Hubs/MyHub.cs
| 2.625
| 3
|
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace UdemySignalR.Server.Hubs
{
public class MyHub:Hub
{
public static List<string> Names { get; set; } = new List<string>();
//static olması lazım çünkü her istekte listin boşalmaması önemli
public async Task SendName(string name)
{
Names.Add(name);
await Clients.All.SendAsync("ReceiveName",name);
}
public async Task GetNames()
{
await Clients.All.SendAsync("RecieveNames", Names);
}
}
}
|
f991f2d01afd08add8d226beca0fceb4718019d1
|
C#
|
lukaselmer/student-thesis-flip
|
/code/tags/20111223_SP7_snapshot/ProjectFlip/ProjectFlip.Services.Interfaces/IProjectNote.cs
| 2.640625
| 3
|
#region
using System;
using System.Collections.Generic;
using System.Windows.Documents;
using System.Windows.Media.Imaging;
#endregion
namespace ProjectFlip.Services.Interfaces
{
/// <summary>
/// Interface for a project note. A project note is a project reference
/// for realized projects. For example, if a successful project has been
/// finished whith the customer "Credit Suisse", programmed in "Java", the
/// project note will show some more details. It is always availible as
/// an A4 PDF paper print.
/// </summary>
/// <remarks></remarks>
public interface IProjectNote
{
// ReSharper does not analyze the xaml files correctly,
// so it thinks that these attributes are never used.
// ReSharper disable UnusedMemberInSuper.Global
// ReSharper disable ReturnTypeCanBeEnumerable.Global
// ReSharper disable UnusedMember.Global
/// <summary>
/// Gets the id.
/// </summary>
int Id { get; }
/// <summary>
/// Gets the title.
/// </summary>
string Title { get; }
/// <summary>
/// Gets the text (short description).
/// </summary>
string Text { get; }
/// <summary>
/// Gets the metadata.
/// </summary>
IDictionary<IMetadataType, ICollection<IMetadata>> Metadata { get; }
/// <summary>
/// Gets the date of the publication.
/// </summary>
DateTime Published { get; }
/// <summary>
/// Gets the filename.
/// </summary>
string Filename { get; }
/// <summary>
/// Gets the filepath of the PDF document.
/// </summary>
string FilepathPdf { get; }
/// <summary>
/// Gets the filepath of the XPS document.
/// </summary>
string FilepathXps { get; }
/// <summary>
/// Gets the filepath of the image.
/// </summary>
string FilepathImage { get; }
/// <summary>
/// Gets the URL.
/// </summary>
string Url { get; }
/// <summary>
/// Initializes the Project Note with an array of strings
/// </summary>
/// <value>
/// The line.
/// </value>
IList<string> Line { set; }
/// <summary>
/// Gets the image.
/// </summary>
BitmapImage Image { get; }
/// <summary>
/// Gets or sets the document.
/// </summary>
IDocumentPaginatorSource Document { get; }
/// <summary>
/// Preloads the XPS document of this project note.
/// </summary>
void Preload();
}
}
|
6700aee7dff723da5714d7bdd2384ba541eda0f0
|
C#
|
longptal/Intern.FPT.ESHOP
|
/sourceC# - Visual Studio/Workspaces/ESHOP/EShop/EModels/Country.cs
| 2.71875
| 3
|
using EShop.Entities;
using System;
using System.Collections.Generic;
namespace EShop.Models
{
public partial class Country : Base
{
public Country (CountryEntity CountryEntity) : base(CountryEntity)
{
if (CountryEntity.CityEntities != null)
{
this.Cities = new HashSet<City>();
foreach (CityEntity CityEntity in CountryEntity.CityEntities)
{
CityEntity.CountryId = CountryEntity.Id;
this.Cities.Add(new City(CityEntity));
}
}
if (CountryEntity.ShipmentDetailEntities != null)
{
this.ShipmentDetails = new HashSet<ShipmentDetail>();
foreach (ShipmentDetailEntity ShipmentDetailEntity in CountryEntity.ShipmentDetailEntities)
{
ShipmentDetailEntity.CountryId = CountryEntity.Id;
this.ShipmentDetails.Add(new ShipmentDetail(ShipmentDetailEntity));
}
}
if (CountryEntity.TaxEntities != null)
{
this.Taxes = new HashSet<Tax>();
foreach (TaxEntity TaxEntity in CountryEntity.TaxEntities)
{
TaxEntity.CountryId = CountryEntity.Id;
this.Taxes.Add(new Tax(TaxEntity));
}
}
}
public override bool Equals(Base other)
{
if (other == null) return false;
if (other is Country Country)
{
return Id.Equals(Country.Id);
}
return false;
}
}
}
|
72fccc6ee8f63b1f57a7e3c268822ffc65dbb60d
|
C#
|
ivanandriska/PNBTest
|
/CaseBusiness/Framework/Mail/Processo/Email.cs
| 2.796875
| 3
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.IO;
using System.Collections;
using CaseBusiness.Framework.Mail.Entidade;
using System.Threading;
namespace CaseBusiness.Framework.Mail.Processo
{
public class Email
{
SmtpClient smtpClient;
public Email()
{
smtpClient = new SmtpClient(Entidade.Smtp.ProtocoloSmtp, Entidade.Smtp.Porta);
smtpClient.EnableSsl = Entidade.Smtp.Ssl;
smtpClient.Credentials = new NetworkCredential(Entidade.Smtp.Login, Entidade.Smtp.Senha);
}
public void Enviar(CaseBusiness.Framework.Mail.Entidade.Email configuraEmail)
{
try
{
MailMessage message = new MailMessage();
MailAddress enderecoDe = new MailAddress(Entidade.Smtp.EmailDe, Entidade.Smtp.Nome);
MailAddress enderecoPara = new MailAddress(configuraEmail.Para, configuraEmail.ParaNome);
//Parametros
message.Headers.Add(Entidade.Smtp.EmailDe, Entidade.Smtp.Nome);
message.From = enderecoDe;
message.To.Add(enderecoPara);
message.Priority = configuraEmail.Prioridade;
message.Subject = configuraEmail.Assunto;
message.IsBodyHtml = configuraEmail.EnableHTML;
if (configuraEmail.EnableHTML)
message.Body = configuraEmail.CorpoHTML;
else
message.Body = configuraEmail.Corpo;
//Verfica se existe anexo
if (configuraEmail.Anexo.Length > 0)
{
Attachment att = new Attachment(configuraEmail.Anexo);
message.Attachments.Add(att);
}
smtpClient.Send(message);
Thread.Sleep(3000);
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
|
60e9e020e744e5ee6e4143ef8d86bf1f3bc73c79
|
C#
|
wightzhang/SalaryPayment
|
/SalaryPayment/SalesReceiptTransaction.cs
| 3.109375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SalaryPayment
{
public class SalesReceiptTransaction:Transaction
{
private readonly DateTime date;
private readonly double amount;
private readonly int empId;
public SalesReceiptTransaction(
DateTime date, double amount, int empId)
{
this.date = date;
this.amount = amount;
this.empId = empId;
}
public void Execute()
{
Employee e = PayrollDatabase.GetEmployee(empId);
if (e != null)
{
CommissionClassification cc =
e.Classfication as CommissionClassification;
if (cc != null)
cc.AddSalesReceipt(new SalesReceipt(date, amount));
else
throw new Exception(
"Tried to add sales receipt to " +
"non-commissioned employee");
}
else
throw new ApplicationException(
"No such employee.");
}
public override string ToString()
{
return String.Format("{0} id:{1} time:{2} amount:{3}",
GetType().Name, empId, date.ToString("yyyy-MM-dd"), amount);
}
}
}
|
dacd535b9cbdecd4357a5583092845b74d82bc29
|
C#
|
cvakarna/servicebus_issue
|
/ServicebusSample/Program.cs
| 2.75
| 3
|
using Azure.Messaging.ServiceBus;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ServicebusSample
{
class Program
{
static async Task Main(string[] args)
{
Program p = new Program();
Console.WriteLine("Hello World!");
using var logger = AzureEventSourceListener.CreateConsoleLogger(EventLevel.Verbose);
await p.CreateConsumer();
await Task.Delay(Timeout.Infinite);
}
public async Task CreateConsumer()
{
//var client = new ServiceBusClient("fullyQualifiedNamespace", new DefaultAzureCredential());
var client = new ServiceBusClient("connectionString");
//lock duration configured to 5 min for the queue
var proc = client.CreateProcessor("managedQueue", options: new ServiceBusProcessorOptions
{
MaxConcurrentCalls = 2,
AutoCompleteMessages = false,
MaxAutoLockRenewalDuration = new TimeSpan(0, 20, 0),//max auto renew 20 min
});
proc.ProcessMessageAsync += MessageHandler;
proc.ProcessErrorAsync += ErrorHandler;
Console.WriteLine("Max auto lock renew :" + proc.MaxAutoLockRenewalDuration);
// start processing
await proc.StartProcessingAsync();
}
async Task MessageHandler(ProcessMessageEventArgs args)
{
try
{
string body = args.Message.Body.ToString();
Console.WriteLine($"Received: {body}");
await Task.Delay(480000);//8 min long running job message should auto renew after
//5min so that not access by other consumer since we configured concurrent calls 2
// complete the message after processing. messages is deleted from the queue.
await args.CompleteMessageAsync(args.Message);
}
catch (Exception ex)
{
Console.WriteLine("Exception In Handler:" + ex);
}
}
// handle any errors when receiving messages
Task ErrorHandler(ProcessErrorEventArgs args)
{
Console.WriteLine(args.Exception.ToString());
return Task.CompletedTask;
}
}
}
|
0bf35781adef73785465eea4adb8a035e3718283
|
C#
|
JasonBSteele/Alexa-Smart-Home
|
/RKon.Alexa.NET/JsonObjects/CameraStream.cs
| 2.71875
| 3
|
using Newtonsoft.Json;
using RKon.Alexa.NET.Types;
namespace RKon.Alexa.NET.JsonObjects
{
/// <summary>
/// Camera stream for an endpoint.
/// </summary>
public class CameraStream
{
/// <summary>
/// Protocol for the stream such as RTSP
/// </summary>
[JsonProperty("protocol")]
public CameraProtocols Protocol { get; set; }
/// <summary>
/// A resolution object that describes the the resolution of the stream. Contains width and height properties.
/// </summary>
[JsonProperty("resolution")]
public Resolution Resolution { get; set; }
/// <summary>
/// Describes the authorization type. Possible values are “BASIC”, DIGEST”, or “NONE”
/// </summary>
[JsonProperty("authorizationType")]
public CameraAuthorizationTypes AuthorizationType { get; set; }
/// <summary>
/// The video codec for the stream. Possible values are “H264”, “MPEG2”, “MJPEG”, or “JPG”.
/// </summary>
[JsonProperty("videoCodec")]
public VideoCodecs VideoCodec { get; set; }
/// <summary>
/// The audio code for the stream. Possible values are “G711”, “AAC”, or “NONE”.
/// </summary>
[JsonProperty("audioCodec")]
public AudioCodecs AudioCodec { get; set; }
/// <summary>
/// Standartconstructor
/// </summary>
public CameraStream()
{
}
/// <summary>
/// Initilializes Camerastream
/// </summary>
/// <param name="protocol"></param>
/// <param name="resolution"></param>
/// <param name="authorizationType"></param>
/// <param name="videoCodec"></param>
/// <param name="audioCodec"></param>
public CameraStream(CameraProtocols protocol, Resolution resolution, CameraAuthorizationTypes authorizationType, VideoCodecs videoCodec, AudioCodecs audioCodec)
{
Protocol = protocol;
Resolution = resolution;
AuthorizationType = authorizationType;
VideoCodec = videoCodec;
AudioCodec = audioCodec;
}
}
}
|
696a8b9a6d523e99167385220b31ae798e7fbe20
|
C#
|
AlexWanderer/Reborn-Stealer-2021-SOURCE
|
/Reborn/Global/Zip/Zip.Shared/ZipFile.AddUpdate.cs
| 2.5625
| 3
|
using System;
using System.IO;
using System.Collections.Generic;
namespace Ionic.Zip
{
public partial class ZipFile
{
public ZipEntry AddFile(string fileName, String directoryPathInArchive)
{
string nameInArchive = ZipEntry.NameInArchive(fileName, directoryPathInArchive);
ZipEntry ze = ZipEntry.CreateFromFile(fileName, nameInArchive);
if (Verbose) StatusMessageTextWriter.WriteLine("adding {0}...", fileName);
return _InternalAddEntry(ze);
}
public ZipEntry UpdateFile(string fileName, String directoryPathInArchive)
{
// ideally this would all be transactional!
var key = ZipEntry.NameInArchive(fileName, directoryPathInArchive);
if (this[key] != null)
this.RemoveEntry(key);
return this.AddFile(fileName, directoryPathInArchive);
}
public ZipEntry AddEntry(string entryName, Stream stream)
{
ZipEntry ze = ZipEntry.CreateForStream(entryName, stream);
ze.SetEntryTimes(DateTime.Now,DateTime.Now,DateTime.Now);
if (Verbose) StatusMessageTextWriter.WriteLine("adding {0}...", entryName);
return _InternalAddEntry(ze);
}
private ZipEntry _InternalAddEntry(ZipEntry ze)
{
// stamp all the props onto the entry
ze._container = new ZipContainer(this);
ze.CompressionMethod = this.CompressionMethod;
ze.CompressionLevel = this.CompressionLevel;
ze.ZipErrorAction = this.ZipErrorAction;
ze.SetCompression = this.SetCompression;
ze.AlternateEncoding = this.AlternateEncoding;
ze.AlternateEncodingUsage = this.AlternateEncodingUsage;
ze.Password = this._Password;
ze.Encryption = this.Encryption;
ze.EmitTimesInWindowsFormatWhenSaving = this._emitNtfsTimes;
ze.EmitTimesInUnixFormatWhenSaving = this._emitUnixTimes;
//string key = DictionaryKeyForEntry(ze);
InternalAddEntry(ze.FileName,ze);
AfterAddEntry(ze);
return ze;
}
public ZipEntry AddDirectory(string directoryName)
{
return AddDirectory(directoryName, null);
}
public ZipEntry AddDirectory(string directoryName, string directoryPathInArchive)
{
return AddOrUpdateDirectoryImpl(directoryName, directoryPathInArchive, AddOrUpdateAction.AddOnly);
}
private ZipEntry AddOrUpdateDirectoryImpl(string directoryName,
string rootDirectoryPathInArchive,
AddOrUpdateAction action)
{
if (rootDirectoryPathInArchive == null)
{
rootDirectoryPathInArchive = "";
}
return AddOrUpdateDirectoryImpl(directoryName, rootDirectoryPathInArchive, action, true, 0);
}
internal void InternalAddEntry(String name, ZipEntry entry)
{
_entries.Add(name, entry);
if (!_entriesInsensitive.ContainsKey(name))
_entriesInsensitive.Add(name, entry);
_contentsChanged = true;
}
private ZipEntry AddOrUpdateDirectoryImpl(string directoryName,
string rootDirectoryPathInArchive,
AddOrUpdateAction action,
bool recurse,
int level)
{
if (Verbose)
StatusMessageTextWriter.WriteLine("{0} {1}...",
(action == AddOrUpdateAction.AddOnly) ? "adding" : "Adding or updating",
directoryName);
if (level == 0)
{
_addOperationCanceled = false;
OnAddStarted();
}
// workitem 13371
if (_addOperationCanceled)
return null;
string dirForEntries = rootDirectoryPathInArchive;
ZipEntry baseDir = null;
if (level > 0)
{
int f = directoryName.Length;
for (int i = level; i > 0; i--)
f = directoryName.LastIndexOfAny("/\\".ToCharArray(), f - 1, f - 1);
dirForEntries = directoryName.Substring(f + 1);
dirForEntries = Path.Combine(rootDirectoryPathInArchive, dirForEntries);
}
// if not top level, or if the root is non-empty, then explicitly add the directory
if (level > 0 || rootDirectoryPathInArchive != "")
{
baseDir = ZipEntry.CreateFromFile(directoryName, dirForEntries);
baseDir._container = new ZipContainer(this);
baseDir.AlternateEncoding = this.AlternateEncoding; // workitem 6410
baseDir.AlternateEncodingUsage = this.AlternateEncodingUsage;
baseDir.MarkAsDirectory();
baseDir.EmitTimesInWindowsFormatWhenSaving = _emitNtfsTimes;
baseDir.EmitTimesInUnixFormatWhenSaving = _emitUnixTimes;
// add the directory only if it does not exist.
// It's not an error if it already exists.
if (!_entries.ContainsKey(baseDir.FileName))
{
InternalAddEntry(baseDir.FileName,baseDir);
AfterAddEntry(baseDir);
}
dirForEntries = baseDir.FileName;
}
if (!_addOperationCanceled)
{
String[] filenames = Directory.GetFiles(directoryName);
if (recurse)
{
// add the files:
foreach (String filename in filenames)
{
if (_addOperationCanceled) break;
if (action == AddOrUpdateAction.AddOnly)
AddFile(filename, dirForEntries);
else
UpdateFile(filename, dirForEntries);
}
if (!_addOperationCanceled)
{
// add the subdirectories:
String[] dirnames = Directory.GetDirectories(directoryName);
foreach (String dir in dirnames)
{
// workitem 8617: Optionally traverse reparse points
FileAttributes fileAttrs = System.IO.File.GetAttributes(dir);
if (this.AddDirectoryWillTraverseReparsePoints
|| ((fileAttrs & FileAttributes.ReparsePoint) == 0)
)
AddOrUpdateDirectoryImpl(dir, rootDirectoryPathInArchive, action, recurse, level + 1);
}
}
}
}
if (level == 0)
OnAddCompleted();
return baseDir;
}
}
}
|
3abfa2f00a89ba4e0dbb5ae164cfefafc7dad35c
|
C#
|
xardison/DAL.NH
|
/src/DAL.NH/Extensions/StringExtension.cs
| 2.609375
| 3
|
namespace DAL.NH.Extensions
{
internal static class StringExtension
{
public static string ReplaceStr(this string text, string oldValue, string newValue)
{
return text == null ? null : text.Replace(oldValue, newValue);
}
}
}
|
83e909f97377518505859c3c8a566cd783795021
|
C#
|
maayanAn/mnoRecipies
|
/Recepies/Recepies/Migrations/Configuration.cs
| 2.640625
| 3
|
using Recepies.Models;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
namespace Recepies.Migrations
{
internal sealed class Configuration : DbMigrationsConfiguration<DbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
}
protected override void Seed(Recepies.Models.DbContext context)
{
var dataUs = (from n in context.Users select n);
context.Users.RemoveRange(dataUs);
var dataIn = (from n in context.Ingredients select n);
context.Ingredients.RemoveRange(dataIn);
var data = (from n in context.Recipies select n);
context.Recipies.RemoveRange(data);
context.SaveChanges();
context.Users.Add(new User() { Id = 1, FullName = "omri vardi", IsManager = false, Password = "123" });
context.Users.Add(new User() { Id = 2, FullName = "noam etzion", IsManager = true, Password = "123" });
context.Users.Add(new User() { Id = 3, FullName = "maayan angel", IsManager = true, Password = "123" });
context.Ingredients.Add(new Ingredient() {Id = 1, Name = "Tomato", Calories = 12, Iron = 14,Protein =15, sugar=40 });
context.Ingredients.Add(new Ingredient() {Id = 2, Name = "Salt", Calories = 12, Iron = 14,Protein =15, sugar=40 });
context.Ingredients.Add(new Ingredient() {Id = 3, Name = "Orange", Calories = 12, Iron = 14,Protein =15, sugar=40 });
context.Ingredients.Add(new Ingredient() {Id = 4, Name = "Water", Calories = 12, Iron = 14,Protein =15, sugar=40 });
context.Ingredients.Add(new Ingredient() {Id = 5, Name = "Milk", Calories = 10, Iron = 14,Protein =15, sugar=40 });
context.Ingredients.Add(new Ingredient() {Id = 6, Name = "Choclate", Calories = 10, Iron = 14,Protein =15, sugar=40 });
context.Ingredients.Add(new Ingredient() {Id = 7, Name = "Sugar", Calories = 8, Iron = 14,Protein =15, sugar=40 });
context.Recipies.Add(new Recipe() { Id = 1, Name = "Spagetti", Context = "Cook all the ingredients together", Difficulty = Difficulty.Normal, Ingredients = new List<Ingredient> { context.Ingredients.Find(1), context.Ingredients.Find(2) }, PreparationTimeInMinutes = 10, User = context.Users.Find(1)});
context.Recipies.Add(new Recipe() { Id = 2, Name = "Pasta", Context = "Cook the dry ingrediants first", Difficulty = Difficulty.Hard, Ingredients = new List<Ingredient> { context.Ingredients.Find(1), context.Ingredients.Find(2) }, PreparationTimeInMinutes = 80, User = context.Users.Find(2)});
context.Recipies.Add(new Recipe() { Id = 3, Name = "Salad", Context = "Cook all the ingredients together", Difficulty = Difficulty.Simple, Ingredients = new List<Ingredient> { context.Ingredients.Find(5), context.Ingredients.Find(3) }, PreparationTimeInMinutes = 10, User = context.Users.Find(3)});
context.Recipies.Add(new Recipe() { Id = 4, Name = "Hot Dog", Context = "Cook all the ingredients together", Difficulty = Difficulty.Simple, Ingredients = new List<Ingredient> { context.Ingredients.Find(1), context.Ingredients.Find(2) }, PreparationTimeInMinutes = 10, User = context.Users.Find(1)});
context.Recipies.Add(new Recipe() { Id = 5, Name = "Fish & chips", Context = "Cook all the ingredients together", Difficulty = Difficulty.Simple, Ingredients = new List<Ingredient> { context.Ingredients.Find(1), context.Ingredients.Find(6) }, PreparationTimeInMinutes = 45, User = context.Users.Find(1)});
context.Recipies.Add(new Recipe() { Id = 6, Name = "Sushi", Context = "Cook all the ingredients together", Difficulty = Difficulty.Simple, Ingredients = new List<Ingredient> { context.Ingredients.Find(1), context.Ingredients.Find(2) }, PreparationTimeInMinutes = 10, User = context.Users.Find(1)});
context.Recipies.Add(new Recipe() { Id = 7, Name = "Rice", Context = "Cook all the ingredients together", Difficulty = Difficulty.Chefs, Ingredients = new List<Ingredient> { context.Ingredients.Find(7), context.Ingredients.Find(2) }, PreparationTimeInMinutes = 30, User = context.Users.Find(3)});
context.Recipies.Add(new Recipe() { Id = 8, Name = "Pizza", Context = "Cook all the ingredients together", Difficulty = Difficulty.Normal, Ingredients = new List<Ingredient> { context.Ingredients.Find(5), context.Ingredients.Find(4) }, PreparationTimeInMinutes = 20, User = context.Users.Find(2)});
context.SaveChanges();
}
}
}
|
2322bfbc3eb40a16b8860d821832007383c23583
|
C#
|
adf789/Last_Survivor
|
/Assets/02.Scripts/Monster/csStateMachine.cs
| 3.046875
| 3
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class csStateMachine <T>{
private T monster;
private csFSMstate<T> curState;
private csFSMstate<T> prevState;
void Awake(){
curState = null;
prevState = null;
}
// 현재 상태 변경
public void ChangeState(csFSMstate<T> newState){
// 현재 상태가 새로운 상태와 같다면 그대로 종료한다.
if (curState == newState)
return;
// 이전 상태에 현재 상태를 저장한다.
prevState = curState;
// 현재 상태가 있다면 상태종료를 호출한다.
if (curState != null) {
curState.ExitState (monster);
}
// 현재 상태에 새로운 상태를 저장한다.
curState = newState;
// 새로운 상태가 있다면 상태시작을 호출한다.
if (curState != null) {
curState.EnterState (monster);
}
}
// 첫 상태를 초기화한다.
public void Init(T monster, csFSMstate<T> initState){
this.monster = monster;
ChangeState (initState);
}
public void Update(){
// 현재 상태가 있다면 상태 업데이트를 호출한다.
if (curState != null) {
curState.UpdateState (monster);
}
}
// 이전 상태로 돌아간다.
public void PrevRestore(){
if (prevState != null) {
ChangeState (prevState);
}
}
}
|
6d347e68291381dc8437e622ce006d081bd192d1
|
C#
|
AdrienTorris/Annihilation
|
/Annihilation/Config/Value.cs
| 2.9375
| 3
|
using System.Runtime.InteropServices;
namespace Annihilation
{
public enum ValueType : byte
{
Unknown,
Uint8,
Uint16,
Uint32,
Uint64,
Int8,
Int16,
Int32,
Int64,
Float,
Double,
Bool,
String
}
[StructLayout(LayoutKind.Explicit)]
public unsafe struct Value
{
[FieldOffset(0)] public ValueType Type;
[FieldOffset(1)] public byte Uint8;
[FieldOffset(1)] public ushort Uint16;
[FieldOffset(1)] public uint Uint32;
[FieldOffset(1)] public ulong Uint64;
[FieldOffset(1)] public sbyte Int8;
[FieldOffset(1)] public short Int16;
[FieldOffset(1)] public int Int32;
[FieldOffset(1)] public long Int64;
[FieldOffset(1)] public float Float;
[FieldOffset(1)] public double Double;
[FieldOffset(1)] public bool Bool;
[FieldOffset(1)] public char* String;
public override string ToString()
{
switch (Type)
{
case ValueType.Uint8: return Uint8.ToString();
case ValueType.Uint16: return Uint16.ToString();
case ValueType.Uint32: return Uint32.ToString();
case ValueType.Uint64: return Uint64.ToString();
case ValueType.Int8: return Int8.ToString();
case ValueType.Int16: return Int16.ToString();
case ValueType.Int32: return Int32.ToString();
case ValueType.Int64: return Int64.ToString();
case ValueType.Float: return Float.ToString();
case ValueType.Double: return Double.ToString();
case ValueType.Bool: return Bool.ToString();
case ValueType.String: return new string(String);
default: return "";
}
}
public Value(byte value)
{
this = default(Value);
Type = ValueType.Uint8;
Uint8 = value;
}
public Value(ushort value)
{
this = default(Value);
Type = ValueType.Uint16;
Uint16 = value;
}
public Value(uint value)
{
this = default(Value);
Type = ValueType.Uint32;
Uint32 = value;
}
public Value(ulong value)
{
this = default(Value);
Type = ValueType.Uint64;
Uint64 = value;
}
public Value(sbyte value)
{
this = default(Value);
Type = ValueType.Int8;
Int8 = value;
}
public Value(short value)
{
this = default(Value);
Type = ValueType.Int16;
Int16 = value;
}
public Value(int value)
{
this = default(Value);
Type = ValueType.Int32;
Int32 = value;
}
public Value(long value)
{
this = default(Value);
Type = ValueType.Int64;
Int64 = value;
}
public Value(float value)
{
this = default(Value);
Type = ValueType.Float;
Float = value;
}
public Value(double value)
{
this = default(Value);
Type = ValueType.Double;
Double = value;
}
public Value(bool value)
{
this = default(Value);
Type = ValueType.Bool;
Bool = value;
}
public Value(char* value)
{
this = default(Value);
Type = ValueType.String;
String = value;
}
public Value(string value)
{
this = default(Value);
Type = ValueType.String;
fixed (char* pointer = value)
{
String = pointer;
}
}
}
}
|
c57bde67d8b292e17738440b0af394ce45beef96
|
C#
|
jslicer/elasticsearch-net
|
/src/Tests/ClientConcepts/HighLevel/Serialization/CustomSerialization.doc.cs
| 2.53125
| 3
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Elasticsearch.Net;
using Nest;
using Nest.JsonNetSerializer;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Tests.ClientConcepts.HighLevel.Serialization
{
/**[[custom-serialization]]
* == Custom Serialization
*
* Starting with 6.0 NEST ships with a shaded Json.NET dependency. Meaning we merged it into Nest's dll
* internalized all Json.NET's types and changed their namespace from `Newtonsoft.Json` to `Nest.Json`.
*
* NEST has always isolated Json.NET as best as it could but this meant that we had to mandate some things.
* For instance NEST heavily relied on the fact that the `ContractConverter` was an instance of `ElasticContractConverter`
*
* If you wanted to deserialize your `_source` or `_fields` using your own `ContractConverter` you were out of luck.
*
* So what did we do in 6.x and how does it affect you?
*
* The `NEST` nuget package from 6.0.0 onwards on its own will use the internal Json.NET serializer and will in affect behave the same
* as it did in previous releases.
*
* If you previously configured a custom Json.NET serializer with custom `JsonSerializerSettings`, `ContractConverter` things
* will change a bit, but for the better!
*
*
*/
public class GettingStarted
{
/**[float]
* === Injecting a new serializer
*
* Starting with NEST 6.x you can inject a serializer that is isolated to only be called
* for the (de)serialization of `_source` `_fields` and where ever a user provided value is expected
* to be written and returned.
*
* Internally we call this the `RequestResponseSerializer` and the `SourceSerializer`
*
* If left unconfigured the internal `RequestResponseSerializer` is the `SourceSerializer` as well.
*
* Implementing `IElasticsearchSerializer` is technically enough to inject your own `SourceSerialzier`
*/
public class VanillaSerializer : IElasticsearchSerializer
{
public T Deserialize<T>(Stream stream) => throw new NotImplementedException();
public object Deserialize(Type type, Stream stream) => throw new NotImplementedException();
public Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) =>
throw new NotImplementedException();
public Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default(CancellationToken)) =>
throw new NotImplementedException();
public void Serialize<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.Indented) =>
throw new NotImplementedException();
public Task SerializeAsync<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.Indented,
CancellationToken cancellationToken = default(CancellationToken)) =>
throw new NotImplementedException();
}
public void TheNewContract()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings =
new ConnectionSettings(pool, sourceSerializer: (settings, builtin) => new VanillaSerializer()); // <1> what the Func?
var client = new ElasticClient(connectionSettings);
}
/**
* If implementing `IElasticsearchSerializer` is enough why do we need to provide its instance wrapped in a factory `Func`?
*
* There are various cases where you need to provide a `_source` with `Nest` data type as part of that `_source`.
*
* An example if you want to use percolation you need to store queries on your document which means you need to have something like
* this:
*/
public class MyPercolationDocument
{
public QueryContainer Query { get; set; }
public string Category { get; set; }
}
/**[float]
* === JsonNetSerializer
*
* A custom `SourceSerializer` would not know how to serialize `QueryContainer` or other NEST types that could appear as part of
* the source. Therefor we ship a separate `NEST.JsonNetSerializer` package that helps in composing a custom `SourceSerializer`
* using `Json.NET` that is smart enough to hand back the (de)serialization of known NEST types back to the builtin
* `RequestResponseSerializer`. This package is also useful if you want to control how your documents and values are stored
* and retreived from elasticsearch using `Json.NET` without intervering with the way NEST uses `Json.NET` internally.
*
* The easiest way to hook this custom source serializer is as followed:
*/
public void DefaultJsonNetSerializer()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings =
new ConnectionSettings(pool, sourceSerializer: JsonNetSerializer.Default);
var client = new ElasticClient(connectionSettings);
}
/**
* `JsonNetSerializer.Default` is just syntactic helper which is equivalent to doing:
*/
public void DefaultJsonNetSerializerUnsugared()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings =
new ConnectionSettings(pool, sourceSerializer: (b, s) => new JsonNetSerializer(b, s));
var client = new ElasticClient(connectionSettings);
}
/**
* `JsonNetSerializer`'s constructor takes several methods that allow you to control the `JsonSerializerSettings` and modify
* the contract resolver from `Json.NET`.
*/
public void DefaultJsonNetSerializerFactoryMethods()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings =
new ConnectionSettings(pool, sourceSerializer: (b, s) => new JsonNetSerializer(
b, s,
() => new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include },
(resolver) => resolver.NamingStrategy = new SnakeCaseNamingStrategy()
));
var client = new ElasticClient(connectionSettings);
}
/**
* You can also subclass `ConnectionAwareSerializerBase` for a more explicit implementation.
*
* Using this `MyCustomJsonNetSerializer` we can (de)serialize using a `NamingStrategy` that snake cases and `JsonSerializerSettings`
* that include null properties, without affecting how NEST's own types are serialized.
*
* Furthermore because this serializer is aware of the builtin serializer we can automatically inject a `JsonConverter` to handle
* known NEST types that could appear as part of the source such as the afformentioned `QueryContainer`.
*/
public class MyCustomJsonNetSerializer : ConnectionSettingsAwareSerializerBase
{
public MyCustomJsonNetSerializer(IElasticsearchSerializer builtinSerializer, IConnectionSettingsValues connectionSettings)
: base(builtinSerializer, connectionSettings) { }
protected override IEnumerable<JsonConverter> CreateJsonConverters() => Enumerable.Empty<JsonConverter>();
protected override JsonSerializerSettings CreateJsonSerializerSettings() => new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Include
};
protected override void ModifyContractResolver(ConnectionSettingsAwareContractResolver resolver)
{
resolver.NamingStrategy = new SnakeCaseNamingStrategy();
}
}
public void UsingJsonNetSerializer()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings =
new ConnectionSettings(pool, sourceSerializer: (builtin, settings) => new MyCustomJsonNetSerializer(builtin, settings));
var client = new ElasticClient(connectionSettings);
}
/**
* Using this `MyCustomJsonNetSerializer` we can (de)serialize using a `NamingStrategy` that snake cases and `JsonSerializerSettings`
* that include null properties, without affecting how NEST's own types are serialized.
*
*/
}
}
|
3888f6c3e85fc69776db0cbf4c2d66c9ecafc393
|
C#
|
SurgicalSteel/Competitive-Programming
|
/Kattis-Solutions/Accounting.cs
| 3.203125
| 3
|
using System;
using System.Collections.Generic;
namespace Accounting
{
class Program
{
static void Main(string[] args)
{
int np,nq,p,m;
string action;
string[] arr = Console.ReadLine().Split(" ");
np = int.Parse(arr[0]);
nq = int.Parse(arr[1]);
Dictionary<int, int> d = new Dictionary<int, int>();
int defaultV = 0;
for(int i = 0; i < nq; i++)
{
arr = Console.ReadLine().Split(" ");
switch (arr[0])
{
case "SET":
p = int.Parse(arr[1]);
m = int.Parse(arr[2]);
if (d.ContainsKey(p))
{
d.Remove(p);
}
d.Add(p, m);
break;
case "PRINT":
p = int.Parse(arr[1]);
if (d.ContainsKey(p))
{
Console.WriteLine(d[p]);
}
else
{
Console.WriteLine(defaultV);
}
break;
case "RESTART":
m = int.Parse(arr[1]);
defaultV = m;
d.Clear();
break;
default:
break;
}
}
}
}
}
|
6e62fdf81ca3c54f62d7d02ae27029f662db6a0f
|
C#
|
ACubed/1HP-Dungeon
|
/Assets/Scripts/Player/Movement.cs
| 2.8125
| 3
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour{
[Header("Components")]
[SerializeField] private Rigidbody2D rb2d; //the characters actual body
[Header("Speed Variables")]
[SerializeField] private float velocity; //the velocity
[SerializeField] private float speedModifier; //this allows for us to increase speed, without velocity
[Header("Dash Variables")]
[SerializeField] private bool isDashing; //determines if we are dashing, this can be used for invulnerable
[SerializeField] private bool canDash; //determines if we can dash or not
[SerializeField] private float dashLength; //the cooldown on the dash represents the amount of time the dash takes to PERFORM
[SerializeField] private float dashCD; //the cooldown on the dash represents the amount of time the dash takes to PERFORM
[SerializeField] private float dashTimer; //the current timer on the dash. 0 means ready to use.
[SerializeField] private float dashForce; //how fast we get to the point of the end of the dash
[SerializeField] private GameObject dash; //how fast we get to the point of the end of the dash
/**************************************************************
* Start
*
* called at the beginning of every "play"
**************************************************************/
void Start(){
rb2d = GetComponent<Rigidbody2D>();
velocity = 6.5f;
speedModifier = 1f;
isDashing = false;
canDash = true;
dashCD = 1.6f;
dashTimer = 0f;
dashLength = .08f;
dashForce = 5f;
} //end of start
/**************************************************************
* Update
*
* called at every cycle
**************************************************************/
void Update(){
//continually check for:
//if the character needs to rotate towards the mouse
if(Time.timeScale == 1) Rotate();
//check for player movement
if(!isDashing) //we cannot move if we dash
Move();
//check if the player dashes
Dash();
} //end of Update
/**************************************************************
* Rotate
*
* Rotate the character towards the mouse based on the mouse.x and mouse y
**************************************************************/
void Rotate(){
//get the mouse position
Vector3 mousePos = Input.mousePosition;
//get the object position in the world
Vector3 objectPos = Camera.main.WorldToScreenPoint(transform.position);
//get the delta X and Y. Keep z as 0 since we are 2D boys
mousePos.z = 0; mousePos.x = mousePos.x - objectPos.x; mousePos.y = mousePos.y - objectPos.y;
//get the angle to point to the mouse
float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
//angle -= 90; //this is required for 360 movement, as opposed to 180 movement
//rotate the character.
transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, angle));
} //end of rotate
/**************************************************************
* Move
*
* This method handles movement; vertical and horizontal.
**************************************************************/
void Move(){
//the horizontal and vertical axis's(?)
float moveX = Input.GetAxis("Horizontal");
float moveY = Input.GetAxis("Vertical");
//set the velocity to a constant value. This prevents crazy acceleration
// if we are not dashing, we want a consistent speed.
rb2d.velocity = new Vector2(moveX*velocity, moveY*velocity)*speedModifier;
//get the movement vector. (i.e., direction.)
Vector2 movement = new Vector2(moveX,moveY);
//do the actual move
rb2d.AddForce(movement*velocity);
} //end of movement
/**************************************************************
* Dash
*
* Performs a dash, or sudden increase in speed for a short moment.
**************************************************************/
void Dash(){
// rb2d velocity is essentially the direction we are going in
// so for when we want to add a force, we add it in the same direction as velocity
if(Input.GetKeyDown(KeyCode.LeftShift) && dashTimer <= 0 && !isDashing && canDash){
//we are performing a dash
//a normalized vector changes all the values that are not 0 to 1. was WANT this.
Instantiate(dash, transform.position, Quaternion.Euler(new Vector3(0f, 0f, rb2d.rotation)));
rb2d.AddForce(rb2d.velocity*dashForce, ForceMode2D.Impulse);
//let the world know we are dashing
dashTimer = dashLength; //this represents how long the dash takes to perform
isDashing = true; //we can use this for invulnerability when that happens
StartCoroutine(DashAgain());
} else if(dashTimer > 0) //only decrement if we need to.
dashTimer -= Time.deltaTime;
else if(dashTimer <= 0)
isDashing = false;
//end of if-else statements.
} //end of method dash
IEnumerator DashAgain(){
canDash = false;
yield return new WaitForSeconds(dashCD);
canDash = true;
} //end dash again
} //end of class Movement
|
2f9306486d8aaaca42d1b8d74c64f8ec0095f37c
|
C#
|
dyslexicanaboko/dyslexic-code
|
/Algorithms/AlgorithmProofs/LinqPadDumpExtension.cs
| 2.671875
| 3
|
using System;
namespace AlgorithmProofs
{
public static class LinqPadDumpExtension
{
public static void Dump(this object target)
{
Console.WriteLine(target);
}
public static void Dump(this int[] target)
{
foreach (var e in target)
{
Console.WriteLine(e);
}
}
}
}
|
cf1cea12007e49c9788ec0ac00347bbf734c7e70
|
C#
|
LimingJu/XSerivces
|
/Shared/SharedModel/CustomMetaTableAttributes/AddOnlyAttribute.cs
| 2.703125
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SharedModel.CustomMetaTableAttributes
{
/// <summary>
/// Indicate this Table only allow adding. Updating, removing is not allowed.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class AddOnlyAttribute : Attribute
{
public AddOnlyAttribute(bool enable)
{
this.Enabled = enable;
}
public bool Enabled { get; } = false;
}
}
|
3f5d27f4da7e3c9d68c8c18b7d808b2d56197a28
|
C#
|
JanRajnoha/ISUF
|
/src/ISUF.Interface/Storage/IStorageModuleItemAccess.cs
| 2.671875
| 3
|
using ISUF.Base.Template;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
namespace ISUF.Interface.Storage
{
/// <summary>
/// Storage module item access interface
/// </summary>
public interface IStorageModuleItemAccess
{
/// <summary>
/// Set Database access
/// </summary>
/// <param name="dbAccess"></param>
void SetDbAccess(IDatabaseAccess dbAccess);
/// <summary>
/// Get item by id for item type
/// </summary>
/// <typeparam name="T">Item type</typeparam>
/// <param name="id">Item index</param>
/// <returns>Item by index</returns>
T GetItemById<T>(int id) where T : AtomicItem;
/// <summary>
/// Add item for item type
/// </summary>
/// <typeparam name="T">Item type</typeparam>
/// <param name="newItem">New item values</param>
/// <param name="ignoreLinkedTableUpdate">Ignore updates for linked tables</param>
/// <returns>Success of task</returns>
bool AddItem<T>(T newItem, bool ignoreLinkedTableUpdate = false) where T : AtomicItem;
/// <summary>
/// Remove item by id for item type
/// </summary>
/// <typeparam name="T">Item type</typeparam>
/// <param name="id">Item index</param>
/// <returns>Success of task</returns>
bool RemoveItemById<T>(int id) where T : AtomicItem;
/// <summary>
/// Remove item by id with async
/// </summary>
/// <typeparam name="T">Item type</typeparam>
/// <param name="id">Item id</param>
/// <returns>Success of task</returns>
Task<bool> RemoveItemByIdAsync<T>(int id) where T : AtomicItem;
/// <summary>
/// Get all items fot item type
/// </summary>
/// <typeparam name="T">Itme type</typeparam>
/// <returns>All items</returns>
List<T> GetAllItems<T>() where T : AtomicItem;
/// <summary>
/// Edit item for item type
/// </summary>
/// <typeparam name="T">Item type</typeparam>
/// <param name="editedItem">Edited item</param>
/// <returns>Success of task</returns>
bool EditItem<T>(T editedItem) where T : AtomicItem;
/// <summary>
/// Remove database table
/// </summary>
void RemoveDatabaseTable();
/// <summary>
/// Create database table
/// </summary>
void CreateDatabaseTable();
/// <summary>
/// Update database table
/// </summary>
void UpdateDatabaseTable();
}
}
|
e8343f8ec741edf5046b960d708141bae9946c71
|
C#
|
arevee/chat
|
/source/Chat/Chat.Logging/Interfaces/ILog.cs
| 2.65625
| 3
|
namespace Chat.Logging.Interfaces
{
/// <summary>
/// Log Interface
/// </summary>
public interface ILog
{
/// <summary>
/// Log Info message
/// </summary>
/// <param name="message">Message to log</param>
void LogInfo(string message);
/// <summary>
/// Log Info message
/// </summary>
/// <param name="message">Message to log</param>
void LogError(string message);
}
}
|
77c6475b430c229f59465450b086e4adef2ac89a
|
C#
|
BeTheBase/KernModuleGameDev
|
/BubbleTroubleTwist#17/Assets/Scripts/Weapons/Weapon.cs
| 2.828125
| 3
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Data class that stores each weapon data
/// </summary>
[System.Serializable]
public class WeaponData
{
[SerializeField] private GameObject projectileGameObject;
public GameObject ProjectileGameObject { get => projectileGameObject; set => projectileGameObject = value; }
[SerializeField] private Transform firePoint;
public Transform FirePoint { get => firePoint; set => firePoint = value; }
[SerializeField] private int damage;
public int Damage { get => damage; set => damage = value; }
[SerializeField]private float amount;
public float Amount { get => amount; set => amount = value; }
[SerializeField] private float height = 50f;
public float Height { get => height; set => value = height; }
[SerializeField] private float shootSpeed = 5f;
public float ShootSpeed { get => shootSpeed; set => value = shootSpeed; }
}
/// <summary>
/// Weapon class with all weapon functionality
/// </summary>
public class Weapon
{
public WeaponData ThisWeaponData { get; set; }
public bool ready = true;
private float amount = 10;
public Weapon(WeaponData _thisWeaponData)
{
ThisWeaponData = _thisWeaponData;
}
public void FireWeapon()
{
GameObject projectile = ObjectPoolerLearning.Instance.SpawnFromPool<Projectile>(ThisWeaponData.FirePoint.position, Quaternion.identity).gameObject;
if (projectile != null)
{
projectile.transform.LerpTransform(projectile.GetComponent<MonoBehaviour>(), projectile.transform.position + Vector3.up * ThisWeaponData.Height, ThisWeaponData.ShootSpeed);
projectile.gameObject.GetComponent<Projectile>().SetDamage(ThisWeaponData.Damage);
}
}
public IEnumerator WaitForCooldown(float _time, float _timeBetween)
{
amount = ThisWeaponData.Amount;
ready = false;
while (amount > 1)
{
FireWeapon();
yield return new WaitForSeconds(_timeBetween);
amount--;
}
yield return new WaitForSeconds(_time);
ready = true;
amount = ThisWeaponData.Amount;
}
public bool WeaponReady()
{
return ready;
}
}
|
919e5c2335b42031c760c55d35c0d395be319dd2
|
C#
|
adamaclp92/CSharp-learning
|
/OOP/Ferivelgyak/Person.cs
| 2.84375
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ferivelgyak
{
class Person
{
private string _VezezekNev;
public string VezetekNev
{
get { return _VezezekNev; }
set { _VezezekNev = value; }
}
private string _KeresztNev;
public string KeresztNev
{
get { return _KeresztNev; }
set { _KeresztNev = value; }
}
private int _SzulEv;
public int SzulEv
{
get { return _SzulEv; }
set { _SzulEv = value; }
}
private int _Eletkor;
public int Eletkor
{
get
{
if (DateTime.Now.Year - SzulEv < 18)
throw new Exception("Túl fiatal.");
return DateTime.Now.Year - SzulEv;
}
set
{
_Eletkor = value;
}
}
private Hajszinek _Hajszin;
public Hajszinek Hajszin
{
get { return _Hajszin; }
set { _Hajszin = value; }
}
public Person(string vezeteknev, string keresztnev, int szulev, Hajszinek hajszin)
{
this.VezetekNev = vezeteknev;
this.KeresztNev = keresztnev;
this.SzulEv = szulev;
this.Hajszin = hajszin;
}
public override string ToString()
{
return string.Format("Neve: {0} {1} életkora: {2}, hajszíne: {3}", VezetekNev, KeresztNev, Eletkor, Hajszin);
}
}
}
|
dbf909cd351a80f10de6f8d9cc459ae507bb4543
|
C#
|
step-up-labs/firebase-authentication-dotnet
|
/src/Auth/Requests/Converters/JavaScriptDateTimeConverter.cs
| 2.875
| 3
|
using Newtonsoft.Json;
using System;
namespace Firebase.Auth.Requests.Converters
{
internal class JavaScriptDateTimeConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(DateTime);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var t = long.Parse((string)reader.Value);
var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return dt.AddMilliseconds(t);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
}
|
c6043257abfe2c011e4ea8004bd6a689c62a2bcd
|
C#
|
Zarnosch/Cloud-Captain
|
/Cloud-Captain/Assets/Scripts/OutputCollision.cs
| 2.671875
| 3
|
using UnityEngine;
using System.Collections;
public class OutputCollision : MonoBehaviour {
void OnTriggerEnter(Collider collider)
{
Debug.Log("OnTrigger");
Debug.Log(GetText(this.gameObject, collider.gameObject));
}
void OnCollisionEnter(Collision collision)
{
Debug.Log("OnCollision");
Debug.Log(GetText(this.gameObject, collision.collider.gameObject));
}
private string GetText(GameObject left, GameObject right)
{
return string.Concat(left.name, " on Layer:", LayerMask.LayerToName(left.layer), " collided with: ", right.name, " on layer: ", LayerMask.LayerToName(right.layer));
}
}
|
14e28efa8676396badca8cc0311907ac116e3ed6
|
C#
|
jchristian/code_katas
|
/data_munging/ui.console/Program.cs
| 2.90625
| 3
|
using System;
using source.football;
using source.weather;
namespace ui.console
{
class Program
{
static void Main(string[] args)
{
var weatherQuery = new GetTheSmallestTempuratureSpread(new WeatherInformationRepository());
var footballQuery = new GetTheTeamWithTheSmallestPointSpread(new FootballInformationRepository());
Console.WriteLine(string.Format("The smallest tempurature spread was for June {0}", weatherQuery.Fetch()));
Console.WriteLine(string.Format("The team with the smallest point spread was {0}", footballQuery.Fetch().Name));
Console.ReadLine();
}
}
}
|
16f4136fdfb8f9546d17f90c3c1737a9e050915d
|
C#
|
ccesarrod/FuzzyMicrosrvices
|
/fuzzyMicroservice/ServicesAPI/Order/OrderApi.cs
| 2.8125
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using DataCore.Entities;
using DataCore.Repositories;
using ServicesAPI.CustomerAPI;
namespace ServicesAPI.OrderAPI
{
public class OrderAPI: IOrderAPI
{
private readonly IOrderRepository _orderRepository;
private readonly ICustomerService _customerService;
public OrderAPI(IOrderRepository orderRepository, ICustomerService customerService)
{
_orderRepository = orderRepository;
this._customerService = customerService;
}
public Order AddOrder(Order order, string customerEmail)
{
var customer = _customerService.getByEmail(customerEmail);
order.CustomerID = customer.CustomerID;
order.Customer = customer;
_orderRepository.Add(order);
_orderRepository.Save();
return order;
}
public Order GetById(int id)
{
return _orderRepository.Find(x => x.OrderID == id).SingleOrDefault();
}
public List<OrderDetail> GetOrderDetails(string OrderId)
{
throw new NotImplementedException();
}
public void Update(Order order)
{
_orderRepository.Update(order);
_orderRepository.Save();
}
}
}
|
68d2e2fe8d40906dabbf77c6c7144b7d3505064c
|
C#
|
concurrentdevelopment/SubstituteQueryable
|
/SubstituteQueryable/FutureEnumerable`1.cs
| 2.84375
| 3
|
namespace SubstituteQueryable
{
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using NHibernate;
class FutureEnumerable<T> : IFutureEnumerable<T>
{
readonly IEnumerable<T> _items;
public FutureEnumerable(IEnumerable<T> items)
{
_items = items;
}
public IEnumerable<T> GetEnumerable()
{
return _items;
}
public Task<IEnumerable<T>> GetEnumerableAsync(CancellationToken cancellationToken = default)
{
return Task.FromResult(_items);
}
public IEnumerator<T> GetEnumerator()
{
return _items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}
|
96cd81aa9266c6a27c28d8e969e5181bea6476ce
|
C#
|
iShamSLam/Shamsutdinov_Rishat_11-708
|
/2017/FALL 2017/PS/PS_2/PS_2_Number3.cs
| 3.640625
| 4
|
using System;
using System.Threading;
namespace PS_2_Number_3
{
// Работу выполнил : Шамсутдинов Ришат 11-708
class Exersize_3
{
static double Function(double x)
{
return Math.Cos(Math.Sin(x));
}
static void Main(string[] args)
{
Console.WriteLine("Введите первую координату участка определения");
double a = double.Parse(Console.ReadLine());
Console.WriteLine("Введите последнюю координату участка определения");
double b = double.Parse(Console.ReadLine());
Console.WriteLine("Введите кол-во равномерно распределеннных точек N");
int n = int.Parse(Console.ReadLine());
if (n <= 0)
Console.WriteLine("При заданном количестве точек решение невозможно");
else
{
Console.WriteLine("Оценка интеграла методом Монте-Карло равна " + Monte_Carlo(a, b, n));
Console.WriteLine("Оценка интеграла методом Левых прямоугольников равна " + LeftRectangle_Method(n, b, a));
Console.WriteLine("Оценка интеграла методом Правых прямоугольников равна " + RightRectangle_Method(n, a, b));
Console.WriteLine("Оценка итеграла методом Трапеций равна " + Trapezoid_Method(n, a, b));
Console.WriteLine("Оценка интеграла Составной формулой Котеса-Симпсона " + Kotes_Simpson_Method(n, a, b));
Console.WriteLine("Оценка интеграла формулой Симпсона " + Simpson_Method(a, b));
}
}
private static double LeftRectangle_Method(int n, double b, double a)
{
double result = 0;
double x = 0;
double h = (b - a) / n;
for (int i = 0; i < n; i++)
{
x = a + (i * h);
result += Function(x);
}
return result * h;
}
public static double Monte_Carlo(double a, double b, int n)
{
double u, sum = 0;
double basis = (b - a) / n;
for (int i = 1; i <= n; i++)
{
// Можно добавить Thread.Sleep(1) для того чтобы все значения были рандомными и точность повысилась
// Но это очень сильно бьёт по скорости работы
Random random = new Random();
u = random.NextDouble() * (b - a) + a;
// Console.WriteLine(u);
sum += Function(u);
}
return (sum * basis);
}
private static double RightRectangle_Method(int n, double a, double b)
{
double result = 0;
double x = 0;
double h = (b - a) / n;
for (int i = 1; i <= n; i++)
{
x = a + i * h;
result += Function(x);
}
return result * h;
}
private static double Trapezoid_Method(int n, double a, double b)
{
double result = 0;
double x = 0;
double h = (b - a) / n;
for (int i = 1; i < n; i++)
{
x = a + i * h;
result += Function(x);
}
result += Function(a) / 2;
result += Function(b) / 2;
return result * h;
}
private static double Kotes_Simpson_Method(int n, double a, double b)
{
double result = 0;
double h = (b - a) / (2 * n);
double x = 0;
result += Function(a);
result += Function(b);
result += 4 * Function(XFinderBySimspon(a, 2 * n - 1, h));
for (int i = 1; i <= n; i++)
{
x = XFinderBySimspon(a, 2 * i - 1, h);
result += 4 * Function(x);
x = XFinderBySimspon(a, 2 * i, h);
result += 2 * Function(x);
}
return result * h / 3;
}
private static double XFinderBySimspon(double a, int number, double h)
{
return a + (number) * h;
}
private static double Simpson_Method(double a, double b)
{
return ((b - a) / 6) * (Function(a) + 4 * Function((a + b) / 2) + Function(b));
}
}
}
|
f4288249b8274676ea6f047fe13198a2a464fd96
|
C#
|
MohamedAhmed2926/JICCRIME
|
/JIC.Utilities/Helpers/DownloadHelper.cs
| 2.609375
| 3
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using JIC.Base;
namespace JIC.Utilities.Helpers
{
public class DownloadHelper
{
/// <summary>
/// Use this method to download an existing physical file.
/// </summary>
/// <param name="FilePath"></param>
public static void DownLoadFile(string FilePath)
{
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo myfile = new FileInfo(FilePath);
// Clear the content of the response
HttpContext.Current.Response.ClearContent();
// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + myfile.Name + "\"");
// Add the file size into the response header
HttpContext.Current.Response.AddHeader("Content-Length", myfile.Length.ToString());
// Set the ContentType
HttpContext.Current.Response.ContentType = GetMIMEType(myfile.Extension.ToLower());
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
HttpContext.Current.Response.TransmitFile(myfile.FullName);
// End the response
HttpContext.Current.Response.End();
}
/// <summary>
/// Use this method to download an existing physical file.
/// </summary>
/// <param name="FilePath"></param>
public static void DownLoadFile(string FilePath, string FileName)
{
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo myfile = new FileInfo(FilePath);
// Clear the content of the response
HttpContext.Current.Response.ClearContent();
// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + FileName + "\"");
// Add the file size into the response header
HttpContext.Current.Response.AddHeader("Content-Length", myfile.Length.ToString());
// Set the ContentType
HttpContext.Current.Response.ContentType = GetMIMEType(Path.GetExtension(FilePath));
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
HttpContext.Current.Response.TransmitFile(myfile.FullName);
// End the response
HttpContext.Current.Response.End();
}
/// <summary>
/// Use this method to write binary data to response.
/// </summary>
/// <param name="FileName"></param>
/// <param name="FileContent"></param>
public static void DownloadFile(string FileName, byte[] FileContent)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = string.Empty;
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (HttpContext.Current.Request.Browser.IsBrowser("IE"))
{
FileName = HttpContext.Current.Server.UrlEncode(FileName);
}
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + FileName + "\"");
HttpContext.Current.Response.AppendHeader("Content-Length", FileContent.Length.ToString());
HttpContext.Current.Response.BinaryWrite(FileContent);
HttpContext.Current.Response.End();
}
public static string GetMIMEType(string FileExtension)
{
switch (FileExtension)
{
case ".htm":
case ".html":
case ".log":
return "text/HTML";
case ".txt":
return "text/plain";
case ".doc":
return "application/ms-word";
case ".tiff":
case ".tif":
return "image/tiff";
case ".asf":
return "video/x-ms-asf";
case ".avi":
return "video/avi";
case ".zip":
return "application/zip";
case ".xls":
case ".csv":
return "application/vnd.ms-excel";
case ".gif":
return "image/gif";
case ".jpg":
case "jpeg":
return "image/jpeg";
case ".bmp":
return "image/bmp";
case ".wav":
return "audio/wav";
case ".mp3":
return "audio/mpeg3";
case ".mpg":
case "mpeg":
return "video/mpeg";
case ".rtf":
return "application/rtf";
case ".asp":
return "text/asp";
case ".pdf":
return "application/pdf";
case ".fdf":
return "application/vnd.fdf";
case ".ppt":
return "application/mspowerpoint";
case ".dwg":
return "image/vnd.dwg";
case ".msg":
return "application/msoutlook";
case ".xml":
case ".sdxl":
return "application/xml";
case ".xdp":
return "application/vnd.adobe.xdp+xml";
default:
return "application/octet-stream";
}
}
}
}
|