content
stringlengths
23
1.05M
using Xamarin.Essentials; namespace App1 { public class Settings { private const string _stewardNameSettings = "stewardName"; public static string StewardName { get{ return Preferences.Get(_stewardNameSettings, "steward1"); } set{ Preferences.Set(_stewardNameSettings, value); } } } }
using ClangSharp.Interop; namespace ClangSharp.Abstractions { public struct EnumDesc { public AccessSpecifier AccessSpecifier { get; set; } public string TypeName { get; set; } public string EscapedName { get; set; } public string NativeType { get; set; } public CXSourceLocation? Location { get; set; } public EnumFlags Flags { get; set; } public bool IsNested { get { return (Flags & EnumFlags.Nested) != 0; } set { Flags = value ? Flags | EnumFlags.Nested : Flags & ~EnumFlags.Nested; } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; namespace PizzaStoreAPI.Service.Controllers { public class CheesesController : ApiController { ApplicationLogic processedData = new ApplicationLogic(); [HttpGet] public HttpResponseMessage GetAllCheeses() { return Request.CreateResponse(HttpStatusCode.OK, processedData.GetCheeseTypes(), "application/json"); } } }
using System; namespace Svetomech.Todo { [Serializable] public struct TodoItem { public string PlainText { get; set; } public override string ToString() => PlainText; } }
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using MySerialList.Model.Review; using MySerialList.Service.Interfaces; using System.Collections.Generic; using System.Threading.Tasks; namespace MySerialList.WebApi.Controllers { [Route("api/[controller]")] [ApiController] public class ReviewFilmProductionController : ControllerBase { private readonly IReviewFilmProductionService _reviewFilmProductionService; public ReviewFilmProductionController(IReviewFilmProductionService reviewService) { _reviewFilmProductionService = reviewService; } [HttpPost("add_review")] [Authorize] public async Task<ActionResult> AddOrUpdateReviewAsync([FromBody]AddReviewFilmProductionModel addReviewModel) { await _reviewFilmProductionService.AddOrUpdateReviewAsync(addReviewModel, User.Identity.Name); return Ok(); } [HttpGet("get_review")] [Authorize] public async Task<ActionResult<int?>> GetUserReviewAsync(int filmProductionId) { return Ok(await _reviewFilmProductionService.GetUserReviewAsync(filmProductionId, User.Identity.Name)); } [HttpPost("add_comment")] [Authorize] public async Task<ActionResult> AddCommentAsync([FromBody]AddCommentModel addCommentModel) { await _reviewFilmProductionService.AddCommentAsync(addCommentModel, User.Identity.Name); return Ok(); } [HttpPut("edit_comment/{id}")] [Authorize] public async Task<ActionResult> EditCommentAsync([FromBody]AddCommentModel addCommentModel, int id) { await _reviewFilmProductionService.EditCommentAsync(addCommentModel, id, User.Identity.Name); return Ok(); } [AllowAnonymous] [HttpGet("get_comments/{filmProductionId}")] public async Task<ActionResult<IEnumerable<CommentModel>>> GetCommentsAsync(int filmProductionId) { return Ok(await _reviewFilmProductionService.GetCommentsAsync(filmProductionId, User.Identity.Name)); } [AllowAnonymous] [HttpGet("get_rating/{filmProductionId}")] public async Task<ActionResult<RatingModel>> GetRatingAsync(int filmProductionId) { return Ok(await _reviewFilmProductionService.GetRatingAsync(filmProductionId)); } } }
using Microsoft.Extensions.FileProviders; namespace DeveloperExceptionText { public sealed class DeveloperExceptionTextOptions { public int SourceCodeLineCount { get; set; } = 6; public IFileProvider FileProvider { get; set; } } }
namespace VaporStore.Data.Models.Enums { public enum CardType { Debit=0, Credit=1 } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Chunks; using Microsoft.AspNetCore.Razor.CodeGenerators; using Microsoft.AspNetCore.Razor.Parser; using Microsoft.AspNetCore.Razor.Runtime.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.FileProviders; using RazorLight.Host.Directives; namespace RazorLight.Host { public class RazorLightHost : RazorEngineHost { #region "Fields" private const string BaseType = "RazorLight.TemplatePage"; private const string HtmlHelperPropertyName = "Html"; private string _defaultModel = "dynamic"; private string _defaultClassName = "__RazorLightTemplate"; private string _defaultNamespace = "RazorLight.GeneratedTemplates"; private static readonly string[] _defaultNamespaces = new[] { "System", "System.Linq", "System.Collections.Generic", "RazorLight.Internal" }; private static readonly Chunk[] _defaultInheritedChunks = new Chunk[] { new SetBaseTypeChunk { TypeName = $"{BaseType}<{ChunkHelper.TModelToken}>", Start = SourceLocation.Undefined } }; private ChunkInheritanceUtility _chunkInheritanceUtility; private readonly IFileProvider _viewsFileProvider; #endregion /// <summary> /// Initialies LightRazorHost with a specified fileprovider /// </summary> public RazorLightHost(IFileProvider viewsFileProvider) : base(new CSharpRazorCodeLanguage()) { this._viewsFileProvider = viewsFileProvider; DefaultClassName = _defaultClassName; DefaultNamespace = _defaultNamespace; DefaultBaseClass = $"{BaseType}<{ChunkHelper.TModelToken}>"; EnableInstrumentation = false; //This should not be true, unsell you want your code to work :) GeneratedClassContext = new GeneratedClassContext( executeMethodName: "ExecuteAsync", writeMethodName: "Write", writeLiteralMethodName: "WriteLiteral", writeToMethodName: "WriteTo", writeLiteralToMethodName: "WriteLiteralTo", templateTypeName: "Microsoft.AspNetCore.Mvc.Razor.HelperResult", defineSectionMethodName: "DefineSection", generatedTagHelperContext: new GeneratedTagHelperContext { ExecutionContextTypeName = typeof(TagHelperExecutionContext).FullName, ExecutionContextAddMethodName = nameof(TagHelperExecutionContext.Add), ExecutionContextAddTagHelperAttributeMethodName = nameof(TagHelperExecutionContext.AddTagHelperAttribute), ExecutionContextAddHtmlAttributeMethodName = nameof(TagHelperExecutionContext.AddHtmlAttribute), ExecutionContextOutputPropertyName = nameof(TagHelperExecutionContext.Output), RunnerTypeName = typeof(TagHelperRunner).FullName, RunnerRunAsyncMethodName = nameof(TagHelperRunner.RunAsync), ScopeManagerTypeName = typeof(TagHelperScopeManager).FullName, ScopeManagerBeginMethodName = nameof(TagHelperScopeManager.Begin), ScopeManagerEndMethodName = nameof(TagHelperScopeManager.End), TagHelperContentTypeName = typeof(TagHelperContent).FullName, // Can't use nameof because RazorPage is not accessible here. CreateTagHelperMethodName = "CreateTagHelper", FormatInvalidIndexerAssignmentMethodName = "InvalidTagHelperIndexerAssignment", StartTagHelperWritingScopeMethodName = "StartTagHelperWritingScope", EndTagHelperWritingScopeMethodName = "EndTagHelperWritingScope", BeginWriteTagHelperAttributeMethodName = "BeginWriteTagHelperAttribute", EndWriteTagHelperAttributeMethodName = "EndWriteTagHelperAttribute", // Can't use nameof because IHtmlHelper is (also) not accessible here. MarkAsHtmlEncodedMethodName = HtmlHelperPropertyName + ".Raw", BeginAddHtmlAttributeValuesMethodName = "BeginAddHtmlAttributeValues", EndAddHtmlAttributeValuesMethodName = "EndAddHtmlAttributeValues", AddHtmlAttributeValueMethodName = "AddHtmlAttributeValue", HtmlEncoderPropertyName = "HtmlEncoder", TagHelperContentGetContentMethodName = nameof(TagHelperContent.GetContent), TagHelperOutputIsContentModifiedPropertyName = nameof(TagHelperOutput.IsContentModified), TagHelperOutputContentPropertyName = nameof(TagHelperOutput.Content), ExecutionContextSetOutputContentAsyncMethodName = nameof(TagHelperExecutionContext.SetOutputContentAsync), TagHelperAttributeValuePropertyName = nameof(TagHelperAttribute.Value), }) { BeginContextMethodName = "BeginContext", EndContextMethodName = "EndContext" }; foreach (var ns in _defaultNamespaces) { NamespaceImports.Add(ns); } } /// <summary> /// Gets the model type used by default when no model is specified. /// </summary> /// <remarks>This value is used as the generic type argument for the base type </remarks> public virtual string DefaultModel { get { return _defaultModel; } set { _defaultModel = value; } } /// <summary> /// Gets or sets the name attribute that is used to decorate properties that are injected and need to be /// activated. /// </summary> public virtual string InjectAttribute { get { return "RazorLight.Host.Internal.RazorInjectAttribute"; } } public virtual IReadOnlyList<Chunk> DefaultInheritedChunks { get { return _defaultInheritedChunks; } } internal ChunkInheritanceUtility ChunkInheritanceUtility { get { if (_chunkInheritanceUtility == null) { // This needs to be lazily evaluated to support DefaultInheritedChunks being virtual. _chunkInheritanceUtility = new ChunkInheritanceUtility( this, DefaultInheritedChunks, new DefaultChunkTreeCache(_viewsFileProvider)); } return _chunkInheritanceUtility; } set { _chunkInheritanceUtility = value; } } public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser) { if (incomingCodeParser == null) { throw new ArgumentNullException(nameof(incomingCodeParser)); } return new RazorLightCodeParser(); } /// <inheritdoc /> public override CodeGenerator DecorateCodeGenerator( CodeGenerator incomingGenerator, CodeGeneratorContext context) { if (incomingGenerator == null) { throw new ArgumentNullException(nameof(incomingGenerator)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } IReadOnlyList<ChunkTree> inheritedChunkTrees = new List<ChunkTree>(); //TODO: add support for viewimports //Evaluate inherited chunks only for physycal files. //If context.SourceFile is null - we are parsing a string //and ViewImports will not be applied if (!string.IsNullOrEmpty(context.SourceFile) && this._viewsFileProvider != null) { inheritedChunkTrees = ChunkInheritanceUtility .GetInheritedChunkTreeResults(context.SourceFile) .Select(result => result.ChunkTree) .ToList(); } ChunkInheritanceUtility.MergeInheritedChunkTrees( context.ChunkTreeBuilder.Root, inheritedChunkTrees, DefaultModel); return new RazorLightCSharpCodeGenerator( context, DefaultModel, InjectAttribute); } } }
using System; using System.Linq; using System.Threading; using Microsoft.Extensions.Logging; using StackExchange.Redis; using SummerBoot.Core; namespace SummerBoot.Cache { public class RedisCacheWriter : IRedisCacheWriter { /// <summary> /// 实际操作redis的组件 /// </summary> private IConnectionMultiplexer ConnectionMultiplexer { set; get; } /// <summary> /// 两次锁定请求尝试之间的睡眠时间,不可为null,如果要禁用,请使用timeSpan.zero /// </summary> private TimeSpan SleepTime { set; get; } private ILogger<RedisCacheWriter> logger { set; get; } = new LoggerFactory().CreateLogger<RedisCacheWriter>(); public RedisCacheWriter(IConnectionMultiplexer connectionMultiplexer, TimeSpan sleepTime) { SbAssert.NotNull(connectionMultiplexer, "ConnectionMultiplexer不能为null"); SbAssert.NotNull(sleepTime, "sleepTime不能为null"); this.ConnectionMultiplexer = connectionMultiplexer; this.SleepTime = sleepTime; } public RedisCacheWriter(IConnectionMultiplexer connectionMultiplexer) : this(connectionMultiplexer, TimeSpan.Zero) { } public byte[] Get(string name, byte[] key) { SbAssert.NotNull(name, "Name must not be null!"); SbAssert.NotNull(key, "Key must not be null!"); return Execute(name, database => database.StringGet(key)); } public void Put(string name, byte[] key, byte[] value, TimeSpan ttl) { SbAssert.NotNull(name, "Name must not be null!"); SbAssert.NotNull(key, "Key must not be null!"); SbAssert.NotNull(value, "Value must not be null!"); Execute(name, database => { if (ShouldExpireWithin(ttl)) { database.StringSet(key, value, ttl); } else { database.StringSet(key, value); } return "ok"; }); } public byte[] PutIfAbsent(string name, byte[] key, byte[] value, TimeSpan ttl) { SbAssert.NotNull(name, "Name must not be null!"); SbAssert.NotNull(key, "Key must not be null!"); SbAssert.NotNull(value, "Value must not be null!"); return Execute<byte[]>(name, database => { if (IsLockingCacheWriter()) { DoLock(name, database); } try { if (database.StringSet(key, value, when: When.NotExists)) { if (ShouldExpireWithin(ttl)) { database.KeyExpire(key, ttl); } return null; } return database.StringGet(key); } finally { if (IsLockingCacheWriter()) { DoUnlock(name, database); } } }); } public void Remove(string name, byte[] key) { SbAssert.NotNull(name, "Name must not be null!"); SbAssert.NotNull(key, "Key must not be null!"); Execute(name, database => database.KeyDelete(key)); } public void Clean(string name, byte[] pattern) { SbAssert.NotNull(name, "Name must not be null!"); Execute(name, database => { bool wasLocked = false; try { if (IsLockingCacheWriter()) { DoLock(name, database); wasLocked = true; } var endpoints = ConnectionMultiplexer.GetEndPoints(true); foreach (var endpoint in endpoints) { var server = ConnectionMultiplexer.GetServer(endpoint); var keys = server.Keys(pattern: pattern).ToArray(); database.KeyDelete(keys); } } finally { if (wasLocked && IsLockingCacheWriter()) { DoUnlock(name, database); } } return "OK"; }); } private T Execute<T>(string name, Func<IDatabase, T> callBack) { var dataBase = ConnectionMultiplexer.GetDatabase(); try { CheckAndPotentiallyWaitUntilUnlocked(name, dataBase); return callBack(dataBase); } catch (Exception e) { logger.LogError(e.Message); } finally { } return default; } /// <summary> /// 是否开启锁,判断标准就是sleepTime>0 /// </summary> /// <returns></returns> private bool IsLockingCacheWriter() { return !SleepTime.IsZero() && !SleepTime.IsNegative(); } private void ExecuteLockFree(Action<IDatabase> callBack) { var dataBase = ConnectionMultiplexer.GetDatabase(); try { callBack(dataBase); } catch (Exception e) { Console.WriteLine(e); throw; } finally { } } /// <summary> /// 检查并可能等待解锁 /// </summary> /// <param name="name"></param> /// <param name="database"></param> private void CheckAndPotentiallyWaitUntilUnlocked(string name, IDatabase database) { //没有开启锁定,即sleepTime为0,直接返回 if (!IsLockingCacheWriter()) { return; } //如果锁存在就会阻塞等待 try { while (DoCheckLock(name, database)) { Thread.Sleep((int)SleepTime.TotalMilliseconds); } } catch (ThreadInterruptedException ex) { // Re-interrupt current thread, to allow other participants to react. Thread.CurrentThread.Interrupt(); throw new Exception(string.Format("Interrupted while waiting to unlock cache %s", name), ex); } } /// <summary> /// 判断是否有锁定时间 /// </summary> /// <param name="ttl"></param> /// <returns></returns> private static bool ShouldExpireWithin(TimeSpan ttl) { return ttl != null && !ttl.IsZero() && !ttl.IsNegative(); } /// <summary> /// 获得key的加锁表示 /// </summary> /// <param name="name"></param> /// <returns></returns> private static byte[] CreateCacheLockKey(string name) { return (name + "~lock").GetBytes(); } /// <summary> /// Explicitly set a write lock on a cache /// 给缓存上锁 /// </summary> /// <param name="name"></param> private void Lock(string name) { Execute(name, (database) => DoLock(name, database)); } /// <summary> /// 给缓存解锁 /// </summary> /// <param name="name"></param> private void Unlock(string name) { ExecuteLockFree(database => DoUnlock(name, database)); } private bool DoLock(string name, IDatabase database) { return database.StringSet(CreateCacheLockKey(name), new byte[0], null, When.NotExists, CommandFlags.None); } private bool DoUnlock(string name, IDatabase database) { return database.KeyDelete(CreateCacheLockKey(name)); } private bool DoCheckLock(string name, IDatabase database) { return database.KeyExists(CreateCacheLockKey(name)); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace keeperScoreboard.XAML.Controls { /// <summary> /// Interaction logic for ToasterNotification.xaml /// </summary> public partial class ToasterNotification : UserControl { public enum ErrorType { Error = 1, Log, Exception, Normal }; public string MyText { get; set; } public ToasterNotification(string header, string message, ErrorType type = 0) { InitializeComponent(); MyText = String.Format( message); lblText.Content = header; lblSubMessage.Text = message; if(type == ErrorType.Error) { bgColor.Background = Brushes.Red; } if(type == ErrorType.Log) { bgColor.Background = Brushes.Yellow; } if(type == ErrorType.Exception) { bgColor.Background = Brushes.OrangeRed; } if(type == ErrorType.Normal) { bgColor.Background = Brushes.Green; } } } }
using System; namespace Roggle.Core { /// <summary> /// Base class to create a Roggle log system. /// </summary> public abstract class BaseRoggle : IRoggle { public RoggleLogLevel AcceptedLogLevels { get; set; } public BaseRoggle(RoggleLogLevel acceptedLogLevels) { AcceptedLogLevels = acceptedLogLevels; } // Write a message log to roggle system public abstract void Write(string message, RoggleLogLevel level); public void Write(Exception e, RoggleLogLevel level) { Write(e.ToString(), level); } public void Write(string message, Exception e, RoggleLogLevel level) { Write($"{message}{Environment.NewLine}{e.ToString()}", level); } // Called when an unhandled exception is thrown public virtual void UnhandledException(object sender, UnhandledExceptionEventArgs args) { // Cast object to Exception Exception e = (Exception)args.ExceptionObject; // Write unhandled error in Roggles Write("Unhandled exception thrown.", e, RoggleLogLevel.Error); } } }
using System.Collections.Generic; using System.Threading.Tasks; using AngleSharp.Html.Dom; using Statiq.Common; using Statiq.Html; namespace Grynwald.Extensions.Statiq.DocsTemplate.Modules { /// <summary> /// Adds Bootstrap table classes to all HTML table elements. /// </summary> /// <seealso href="https://getbootstrap.com/docs/4.5/content/tables/">Tables (Bootstrap Documentation)</seealso> public sealed class UseBootstrapTables : Module { private BootstrapTableOptions m_TableOptions = BootstrapTableOptions.None; /// <summary> /// Set <see cref="BootstrapTableOptions"/> to use for processing tables /// </summary> public UseBootstrapTables WithTableOptions(BootstrapTableOptions tableOptions) { m_TableOptions = tableOptions; return this; } protected override async Task<IEnumerable<IDocument>> ExecuteContextAsync(IExecutionContext context) { return await context.ExecuteModulesAsync(new ModuleList() { new ProcessHtml("table", element => { if(element is IHtmlTableElement tableElement) { tableElement.ClassList.Add("table"); if(m_TableOptions.HasFlag(BootstrapTableOptions.Striped)) tableElement.ClassList.Add("table-striped"); if(m_TableOptions.HasFlag(BootstrapTableOptions.Bordered)) tableElement.ClassList.Add("table-bordered"); if(m_TableOptions.HasFlag(BootstrapTableOptions.Small)) tableElement.ClassList.Add("table-sm"); } }) }, context.Inputs); } } }
using FakeItEasy; using MoulinTDD; using MoulinTDD.Exceptions; using NFluent; using Xunit; namespace MoulinTDD_UnitTests { public class PawnUnitTests { [Theory] [InlineData(Color.Black, Color.Black)] [InlineData(Color.White, Color.White)] public void Pawn_HasValidColor(Color color, Color expectedResult) { var pawn = new Pawn(color); Check.That(pawn.Color).Equals(expectedResult); } [Fact] public void Owner_NotSetYet_Throws() { var pawn = new Pawn(); Check.ThatCode(() => pawn.Owner).Throws<InvalidPawnOwnerException>(); } [Fact] public void Owner_SetWhitePlayerForBlackPawn_Throws() { //Arrange var fakePlayer = A.Fake<IPlayer>(); A.CallTo(() => fakePlayer.Color).Returns(Color.White); var pawn = new Pawn(Color.Black); //Act Check.ThatCode(() => pawn.Owner = fakePlayer).Throws<InvalidPawnOwnerException>(); } } }
using System; using UniRx; namespace kameffee.unity1week202104.View { public interface IBaseCampView { int BaseCampId { get; } IObservable<IBaseCampConsumer> OnEnterArea(); IObservable<IBaseCampConsumer> OnExitArea(); void Action(); IObservable<Unit> OnAction(); } }
namespace Essential.Core.Event.Interfaces { public interface ITaskCompleteHandler { void OnComplete(); } }
using System; namespace CodingChallenge { public class Solution { public static int[] RunningSum(int[] nums) { int[] runningSum=new int[nums.Length]; runningSum[0]=nums[0]; for(int i=1;i<nums.Length;i++) { runningSum[i] = nums[i]+runningSum[i-1]; } return runningSum; } public static void Main(String[] args) { int[] nums = {3,1,2,10,1}; int[] runningSum = RunningSum(nums); for(int i=0;i<runningSum.Length;i++) { Console.WriteLine(runningSum[i]); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AskTheCode.ControlFlowGraphs.Cli.TypeModels { // TODO: Add means to display structured values to the user (e.g. tree view for the control flow display) public interface IValueModel : ITypeModel { string ValueText { get; } } }
@using Microsoft.AspNetCore.Identity @using SimpleWebAPIApp.Areas.Identity @using SimpleWebAPIApp.Areas.Identity.Models @namespace SimpleWebAPIApp.Areas.Identity.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
using System; using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using MvcContrib.TestHelper; using NuSurvey.Core.Domain; using NuSurvey.Tests.Core.Helpers; using NuSurvey.Web.Controllers; namespace NuSurvey.Tests.ControllerTests.SurveyControllerTests { public partial class SurveyControllerTests { #region Index Tests [TestMethod] public void TestIndexReturnsView() { #region Arrange new FakeSurveys(3, SurveyRepository); #endregion Arrange #region Act var result = Controller.Index() .AssertViewRendered() .WithViewData<IEnumerable<Survey>>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.AreEqual(3, result.Count()); #endregion Assert } #endregion Index Tests #region Details Tests [TestMethod] public void TestDetailsRedirectsToIndexWhenSurvyNotFound1() { #region Arrange new FakeSurveys(3, SurveyRepository); #endregion Arrange #region Act Controller.Details(4, null, null) .AssertActionRedirect() .ToAction<SurveyController>(a => a.Index()); #endregion Act #region Assert #endregion Assert } [TestMethod] public void TestDetailsRedirectsToIndexWhenSurvyNotFound2() { #region Arrange new FakeSurveys(3, SurveyRepository); #endregion Arrange #region Act Controller.Details(4, new DateTime(2011,01,01), new DateTime(2011,02,01)) .AssertActionRedirect() .ToAction<SurveyController>(a => a.Index()); #endregion Act #region Assert #endregion Assert } [TestMethod] public void TestDetailReturnsView1() { #region Arrange SetupData1(); #endregion Arrange #region Act var result = Controller.Details(1, null, null) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(5, result.SurveyResponses.Count()); Assert.AreEqual("Name1", result.Survey.Name); Assert.IsNull(result.FilterBeginDate); Assert.IsNull(result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView2() { #region Arrange SetupData1(); #endregion Arrange #region Act var result = Controller.Details(1, new DateTime(2011,01,03), null) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(3, result.SurveyResponses.Count()); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(new DateTime(2011, 01, 03), result.FilterBeginDate); Assert.IsNull(result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView3() { #region Arrange SetupData1(); #endregion Arrange #region Act var result = Controller.Details(1, new DateTime(2011, 01, 03), new DateTime(2011, 01, 03)) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(1, result.SurveyResponses.Count()); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(new DateTime(2011, 01, 03), result.FilterBeginDate); Assert.AreEqual(new DateTime(2011, 01, 03), result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView4() { #region Arrange SetupData1(); #endregion Arrange #region Act var result = Controller.Details(1, null, new DateTime(2011, 01, 03)) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(3, result.SurveyResponses.Count()); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(null, result.FilterBeginDate); Assert.AreEqual(new DateTime(2011, 01, 03), result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView5() { #region Arrange SetupData1(); var singleDate = new DateTime(2011, 01, 01); #endregion Arrange #region Act var result = Controller.Details(1, singleDate, singleDate) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(1, result.SurveyResponses.Count()); Assert.AreEqual(singleDate, result.SurveyResponses.ElementAtOrDefault(0).DateTaken.Date); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(singleDate, result.FilterBeginDate); Assert.AreEqual(singleDate, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView6() { #region Arrange SetupData1(); var singleDate = new DateTime(2011, 01, 02); #endregion Arrange #region Act var result = Controller.Details(1, singleDate, singleDate) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(1, result.SurveyResponses.Count()); Assert.AreEqual(singleDate, result.SurveyResponses.ElementAtOrDefault(0).DateTaken.Date); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(singleDate, result.FilterBeginDate); Assert.AreEqual(singleDate, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView7() { #region Arrange SetupData1(); var singleDate = new DateTime(2011, 01, 03); #endregion Arrange #region Act var result = Controller.Details(1, singleDate, singleDate) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(1, result.SurveyResponses.Count()); Assert.AreEqual(singleDate, result.SurveyResponses.ElementAtOrDefault(0).DateTaken.Date); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(singleDate, result.FilterBeginDate); Assert.AreEqual(singleDate, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView8() { #region Arrange SetupData1(); var singleDate = new DateTime(2011, 01, 04); #endregion Arrange #region Act var result = Controller.Details(1, singleDate, singleDate) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(1, result.SurveyResponses.Count()); Assert.AreEqual(singleDate, result.SurveyResponses.ElementAtOrDefault(0).DateTaken.Date); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(singleDate, result.FilterBeginDate); Assert.AreEqual(singleDate, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView9() { #region Arrange SetupData1(); var singleDate = new DateTime(2011, 01, 05); #endregion Arrange #region Act var result = Controller.Details(1, singleDate, singleDate) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsFalse(result.HasPendingResponses); Assert.AreEqual(1, result.SurveyResponses.Count()); Assert.AreEqual(singleDate, result.SurveyResponses.ElementAtOrDefault(0).DateTaken.Date); Assert.AreEqual("Name1", result.Survey.Name); Assert.AreEqual(singleDate, result.FilterBeginDate); Assert.AreEqual(singleDate, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView10() { #region Arrange SetupData1(); #endregion Arrange #region Act var result = Controller.Details(2, null, null) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsTrue(result.HasPendingResponses); Assert.AreEqual(2, result.SurveyResponses.Count()); Assert.IsFalse(result.SurveyResponses.ElementAtOrDefault(0).IsPending); Assert.IsFalse(result.SurveyResponses.ElementAtOrDefault(1).IsPending); Assert.AreEqual("Name2", result.Survey.Name); Assert.AreEqual(null, result.FilterBeginDate); Assert.AreEqual(null, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView11() { #region Arrange SetupData1(); #endregion Arrange #region Act var result = Controller.Details(3, null, null) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsTrue(result.HasPendingResponses); Assert.AreEqual(3, result.SurveyResponses.Count()); Assert.IsFalse(result.SurveyResponses.ElementAtOrDefault(0).IsPending); Assert.IsFalse(result.SurveyResponses.ElementAtOrDefault(1).IsPending); Assert.AreEqual("Name3", result.Survey.Name); Assert.AreEqual(null, result.FilterBeginDate); Assert.AreEqual(null, result.FilterEndDate); #endregion Assert } [TestMethod] public void TestDetailReturnsView12() { #region Arrange SetupData1(); var singleDate = new DateTime(2011, 05, 01); #endregion Arrange #region Act var result = Controller.Details(3, singleDate, singleDate) .AssertViewRendered() .WithViewData<SurveyResponseDetailViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsTrue(result.HasPendingResponses); Assert.AreEqual(3, result.SurveyResponses.Count()); Assert.IsFalse(result.SurveyResponses.ElementAtOrDefault(0).IsPending); Assert.IsFalse(result.SurveyResponses.ElementAtOrDefault(1).IsPending); Assert.AreEqual("Name3", result.Survey.Name); Assert.AreEqual(singleDate, result.FilterBeginDate); Assert.AreEqual(singleDate, result.FilterEndDate); #endregion Assert } #endregion Details Tests } }
using System; using UnityUtility.Async; namespace UnityUtility.SaveLoad { public interface ISaver { bool StorageLoaded { get; } bool ProfileCreated { get; } void Set(string key, object value); object Get(string key, object defaltValue); object Get(string key, Type type); T Get<T>(string key); bool HasKey(string key); void DeleteKey(string key); void Clear(); bool CreateProfile(); bool DeleteProfile(); void SaveVersion(string version); TaskInfo SaveVersionAsync(string version, int keysPerFrame); bool LoadVersion(string version); bool DeleteVersion(string version); } public interface IKeyGenerator { string Generate(Type objectType, string fieldName, string objectID); } }
using Lucene.Net.Analysis.Phonetic.Language; using Lucene.Net.Analysis.Util; using Lucene.Net.Support; using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; namespace Lucene.Net.Analysis.Phonetic { /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class TestPhoneticFilterFactory : BaseTokenStreamTestCase { /** * Case: default */ [Test] public void TestFactoryDefaults() { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put(PhoneticFilterFactory.ENCODER, "Metaphone"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); assertTrue(factory.GetEncoder() is Metaphone); assertTrue(factory.inject); // default } [Test] public void TestInjectFalse() { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put(PhoneticFilterFactory.ENCODER, "Metaphone"); args.Put(PhoneticFilterFactory.INJECT, "false"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); assertFalse(factory.inject); } [Test] public void TestMaxCodeLength() { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put(PhoneticFilterFactory.ENCODER, "Metaphone"); args.Put(PhoneticFilterFactory.MAX_CODE_LENGTH, "2"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); assertEquals(2, ((Metaphone)factory.GetEncoder()).MaxCodeLen); } /** * Case: Failures and Exceptions */ [Test] public void TestMissingEncoder() { try { new PhoneticFilterFactory(new Dictionary<String, String>()); fail(); } catch (ArgumentException expected) { assertTrue(expected.Message.Contains("Configuration Error: missing parameter 'encoder'")); } } [Test] public void TestUnknownEncoder() { try { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put("encoder", "XXX"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); fail(); } catch (ArgumentException expected) { assertTrue(expected.Message.Contains("Error loading encoder")); } } [Test] public void TestUnknownEncoderReflection() { try { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put("encoder", "org.apache.commons.codec.language.NonExistence"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); fail(); } catch (ArgumentException expected) { assertTrue(expected.Message.Contains("Error loading encoder")); } } /** * Case: Reflection */ [Test] public void TestFactoryReflection() { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put(PhoneticFilterFactory.ENCODER, "Metaphone"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); assertTrue(factory.GetEncoder() is Metaphone); assertTrue(factory.inject); // default } /** * we use "Caverphone2" as it is registered in the REGISTRY as Caverphone, * so this effectively tests reflection without package name */ [Test] public void TestFactoryReflectionCaverphone2() { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put(PhoneticFilterFactory.ENCODER, "Caverphone2"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); assertTrue(factory.GetEncoder() is Caverphone2); assertTrue(factory.inject); // default } [Test] public void TestFactoryReflectionCaverphone() { IDictionary<String, String> args = new Dictionary<String, String>(); args.Put(PhoneticFilterFactory.ENCODER, "Caverphone"); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); assertTrue(factory.GetEncoder() is Caverphone2); assertTrue(factory.inject); // default } [Test] public void TestAlgorithms() { assertAlgorithm("Metaphone", "true", "aaa bbb ccc easgasg", new String[] { "A", "aaa", "B", "bbb", "KKK", "ccc", "ESKS", "easgasg" }); assertAlgorithm("Metaphone", "false", "aaa bbb ccc easgasg", new String[] { "A", "B", "KKK", "ESKS" }); assertAlgorithm("DoubleMetaphone", "true", "aaa bbb ccc easgasg", new String[] { "A", "aaa", "PP", "bbb", "KK", "ccc", "ASKS", "easgasg" }); assertAlgorithm("DoubleMetaphone", "false", "aaa bbb ccc easgasg", new String[] { "A", "PP", "KK", "ASKS" }); assertAlgorithm("Soundex", "true", "aaa bbb ccc easgasg", new String[] { "A000", "aaa", "B000", "bbb", "C000", "ccc", "E220", "easgasg" }); assertAlgorithm("Soundex", "false", "aaa bbb ccc easgasg", new String[] { "A000", "B000", "C000", "E220" }); assertAlgorithm("RefinedSoundex", "true", "aaa bbb ccc easgasg", new String[] { "A0", "aaa", "B1", "bbb", "C3", "ccc", "E034034", "easgasg" }); assertAlgorithm("RefinedSoundex", "false", "aaa bbb ccc easgasg", new String[] { "A0", "B1", "C3", "E034034" }); assertAlgorithm("Caverphone", "true", "Darda Karleen Datha Carlene", new String[] { "TTA1111111", "Darda", "KLN1111111", "Karleen", "TTA1111111", "Datha", "KLN1111111", "Carlene" }); assertAlgorithm("Caverphone", "false", "Darda Karleen Datha Carlene", new String[] { "TTA1111111", "KLN1111111", "TTA1111111", "KLN1111111" }); assertAlgorithm("ColognePhonetic", "true", "Meier Schmitt Meir Schmidt", new String[] { "67", "Meier", "862", "Schmitt", "67", "Meir", "862", "Schmidt" }); assertAlgorithm("ColognePhonetic", "false", "Meier Schmitt Meir Schmidt", new String[] { "67", "862", "67", "862" }); } /** Test that bogus arguments result in exception */ [Test] public void TestBogusArguments() { try { new PhoneticFilterFactory(new Dictionary<String, String>() { { "encoder", "Metaphone" }, { "bogusArg", "bogusValue" } }); fail(); } catch (ArgumentException expected) { assertTrue(expected.Message.Contains("Unknown parameters")); } } internal static void assertAlgorithm(String algName, String inject, String input, String[] expected) { Tokenizer tokenizer = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false); IDictionary<String, String> args = new Dictionary<String, String>(); args.Put("encoder", algName); args.Put("inject", inject); PhoneticFilterFactory factory = new PhoneticFilterFactory(args); factory.Inform(new ClasspathResourceLoader(factory.GetType())); TokenStream stream = factory.Create(tokenizer); AssertTokenStreamContents(stream, expected); } } }
using Newtonsoft.Json; namespace BoxManagementService.Models.Repositories { public class Sku { /// <summary> /// CosmosDBで必要なID /// </summary> [JsonProperty(PropertyName = "id")] public string Id { get; set; } /// <summary> /// 法人コード /// </summary> [JsonProperty(PropertyName = "companyCode")] public string CompanyCode { get; set; } /// <summary> /// 店舗コード /// </summary> [JsonProperty(PropertyName = "storeCode")] public string StoreCode { get; set; } /// <summary> /// SKUコード /// </summary> [JsonProperty(PropertyName = "skuCode")] public string SkuCode { get; set; } /// <summary> /// 商品コード /// </summary> [JsonProperty(PropertyName = "itemCode")] public string ItemCode { get; set; } } }
using System.Threading.Tasks; using SampleMVVM.Wpf.Models.State.DataActions; using NetRx.Store.Effects; namespace SampleMVVM.Wpf.Models.State.Effects { public class SendingFailedMessageEffect : Effect<DataActions.SendItemResult> { public override Task Invoke(SendItemResult action) { return action.Payload.Id > 0 ? App.ShowMessge("Data item has been sent") : App.ShowMessge("Data item sending failed", true); } } public class DataLoadingFailedMessageEffect : Effect<DataActions.LoadDataResult> { public override Task Invoke(LoadDataResult action) { return action.Payload.Count > 0 ? App.ShowMessge($"Loaded {action.Payload.Count} items") : App.ShowMessge("Loading failed", true); } } public static class MessageEffects { public static Effect[] GetAll() { return new Effect[] { new SendingFailedMessageEffect(), new DataLoadingFailedMessageEffect() }; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace Reflection_Tests { public class MethodInfoPacketHandlerRegistry : PacketHandlerRegistry<MethodInfo, MethodInfo> { #region Overrides of PacketHandlerRegistry<MethodInfo,MethodInfo> protected override IEnumerable<MethodInfo> FindHandlers(Assembly assembly) { var assemblyTypes = assembly.GetTypes(); var methodInfos = assemblyTypes.SelectMany(assemblyType => assemblyType.GetMethods().Where(methodInfo => Attribute.IsDefined(methodInfo, typeof(PacketHandlerMethodAttribute)) && PacketHandlerMethodAttribute.IsValidPacketHandlerMethod(methodInfo))); return methodInfos; } protected override KeyValuePair<Type, MethodInfo> ExtractHandler(MethodInfo handlerMetaType) { var packetType = PacketHandlerMethodAttribute.GetPacketParameterType(handlerMetaType); return new KeyValuePair<Type, MethodInfo>(packetType, handlerMetaType); } protected override bool Invoke(MethodInfo handler, PacketSender packetSender, IPacket packet) => (bool) handler.Invoke(null, new object[] {packetSender, packet}); #endregion } }
using Mondop.Templates.Model; namespace Mondop.Templates.Processing { internal class LiteralTextProcessor: ElementProcessor<LiteralText> { protected override void _Process(LiteralText element, ProcessData processData) { base._Process(element, processData); processData.OutputWriter.Write(element.Text); } } }
using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine; public class DymekController : MonoBehaviour { int Tekst; public GameObject child; // public GameObject gonciu; public GameObject ReklamaGener; Text tresc; // Use this for initialization void Start () { Tekst = Random.Range (1, 11); tresc = child.gameObject.GetComponent<Text> (); } // Update is called once per frame void Update () { if (Tekst == 8 && gameObject.activeSelf == true) { ReklamaGener.gameObject.SetActive (true); } if (Tekst == 1) { tresc.text = "Dziaba dziaba dziaba!"; } else if (Tekst == 2) { tresc.text = "Bumcfksz!"; } else if (Tekst == 3) { tresc.text = "Brykiety, brykiety."; } else if (Tekst == 4) { tresc.text = "BO MOGE!"; } else if (Tekst == 5) { tresc.text = "Eszelegeszelekk!"; } else if (Tekst == 6) { tresc.text = "Poka bydlaka smierdziela!"; } else if (Tekst == 7) { tresc.text = "Fraszki beczki"; } else if (Tekst == 8) { tresc.text = "Chamska reklama!!!"; } else if (Tekst == 9) { tresc.text = "Lubisz maslo?"; } else if (Tekst == 10) { tresc.text = "Co zrobisz? Nic nie zrobisz."; } else if (Tekst == 11) { tresc.text = "DO SPOWIEDZI!"; } } void OnDisable(){ tresc.text = ""; Tekst = Random.Range (1, 11); } }
using TMDbLib.Objects.Search; namespace Moodflix.Models; public class MoviesBySentimentResponse { public List<SearchMovie> Movies { get; set; } public double AverageSentiment { get; set; } public List<MovieKeywords> MovieKeywords { get; set; } = new List<MovieKeywords>(); public List<Review> Reviews { get; set; } = new List<Review>(); } public class MovieKeywords { public int MovieId { get; set; } public List<string> Keywords { get; set; } = new List<string>(); } public class Review { public int MovieId { get; set; } public string Author { get; set; } public string AuthorAvatar { get; set; } public string Content { get; set; } public string Sentiment { get; set; } public ConfidentScores ConfidentScores { get; set; } = new ConfidentScores(); } public class ConfidentScores { public double Negative { get; set; } public double Neutral { get; set; } public double Positive { get; set; } }
namespace Sitecore.Foundation.Search.Models.Index { using System; using System.Collections.Generic; using Sitecore.ContentSearch; public class StoreIndex : PageViewsIndex { [IndexField("store_name")] public string StoreName { get; set; } [IndexField("phone_number")] public string PhoneNumber { get; set; } [IndexField("new_date")] public DateTime NewDate { get; set; } [IndexField("store_next_three_months_new_date")] public DateTime NextThreeMonthsNewDate { get; set; } [IndexField("post_date")] public DateTime PostDate { get; set; } [IndexField("store_expired_date")] public DateTime ExpiryDate { get; set; } [IndexField("store_has_upcoming_or_new_date")] public bool StoreHasUpcomingOrNewDate { get; set; } [IndexField("store_categories")] public IList<string> Categories { get; set; } [IndexField("description")] public string Description { get; set; } [IndexField("unit_no")] public string UnitNo { get; set; } [IndexField("contact")] public string Contact { get; set; } [IndexField("opening_hours")] public string OpeningHours { get; set; } [IndexField("store_offers")] public IList<string> StoreOffers { get; set; } [IndexField("brands")] public string Brands { get; set; } [IndexField("keywords")] public string Keywords { get; set; } [IndexField("wing")] public string Wing { get; set; } [IndexField("store_mall_site")] public string MallSite { get; set; } } }
namespace Volunteers.Areas.Admin.Controllers { using Microsoft.AspNetCore.Mvc; using Volunteers.Services.Projects; using Volunteers.Services.Stats; public class ProjectsController : AdminController { private readonly IProjectService projects; public ProjectsController(IStatsService stats, IProjectService projects) : base(stats) { this.projects = projects; } public IActionResult Index() { return View(projects.ListProjectsAdmin()); } } }
// Copyright 2017 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. using Google.Api.Gax; using Google.Api.Gax.Grpc; using Google.Api.Gax.Testing; using Google.Cloud.Spanner.Common.V1; using Google.Cloud.Spanner.V1; using Google.Cloud.Spanner.V1.Internal.Logging; using Google.Cloud.Spanner.V1.Tests; using Google.Protobuf.Collections; using Google.Protobuf.WellKnownTypes; using Grpc.Core; using Moq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Transactions; using Xunit; namespace Google.Cloud.Spanner.Data.Tests { public class SpannerCommandTests { [Fact] public void CommandTypeSupportsOnlyCommandText() { var command = new SpannerCommand(); Assert.Throws<NotSupportedException>(() => command.CommandType = CommandType.StoredProcedure); Assert.Throws<NotSupportedException>(() => command.CommandType = CommandType.TableDirect); command.CommandType = CommandType.Text; Assert.Equal(CommandType.Text, command.CommandType); } [Fact] public void UpdateRowSourceNotSupported() { var command = new SpannerCommand(); Assert.Throws<NotSupportedException>(() => command.UpdatedRowSource = UpdateRowSource.Both); Assert.Throws<NotSupportedException>(() => command.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord); Assert.Throws<NotSupportedException>(() => command.UpdatedRowSource = UpdateRowSource.OutputParameters); command.UpdatedRowSource = UpdateRowSource.None; Assert.Equal(UpdateRowSource.None, command.UpdatedRowSource); } [Fact] public void PrepareNoop() { var command = new SpannerCommand(); command.Prepare(); } [Fact] public void CreatesSpannerParameter() { var command = new SpannerCommand(); Assert.IsType<SpannerParameter>(command.CreateParameter()); } [Fact] public void CloneQuery() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); var command2 = (SpannerCommand)command.Clone(); Assert.Same(command.SpannerConnection, command2.SpannerConnection); Assert.Equal(command.CommandText, command2.CommandText); } [Fact] public void CloneUpdateWithParameters() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateUpdateCommand( "T", new SpannerParameterCollection { {"P1", SpannerDbType.String}, {"P2", SpannerDbType.Float64} }); var command2 = (SpannerCommand)command.Clone(); Assert.Same(command.SpannerConnection, command2.SpannerConnection); Assert.Equal(command.CommandText, command2.CommandText); Assert.Equal(command.Parameters.Count, command2.Parameters.Count); Assert.NotSame(command.Parameters, command2.Parameters); Assert.True(command.Parameters.SequenceEqual(command2.Parameters, new SpannerParameterEqualityComparer())); } [Fact] public void CloneWithQueryOptions() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.QueryOptions = QueryOptions.Empty .WithOptimizerVersion("1") .WithOptimizerStatisticsPackage("auto_20191128_14_47_22UTC"); var command2 = (SpannerCommand)command.Clone(); Assert.Same(command.SpannerConnection, command2.SpannerConnection); Assert.Equal(command.CommandText, command2.CommandText); Assert.Equal(command.QueryOptions, command2.QueryOptions); } [Fact] public void CommandHasConnectionQueryOptions() { const string connOptimizerVersion = "1"; const string connOptimizerStatisticsPackage = "stats_package_1"; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); connection.QueryOptions = QueryOptions.Empty .WithOptimizerVersion(connOptimizerVersion) .WithOptimizerStatisticsPackage(connOptimizerStatisticsPackage); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.QueryOptions.OptimizerVersion == connOptimizerVersion && request.QueryOptions.OptimizerStatisticsPackage == connOptimizerStatisticsPackage), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CommandHasQueryOptionsFromEnvironment() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); const string envOptimizerVersion = "2"; const string envOptimizerStatisticsPackage = "stats_package_2"; RunActionWithEnvQueryOptions(() => { // Optimizer version set through environment variable has higher // precedence than version set through connection. const string connOptimizerVersion = "1"; const string connOptimizerStatisticsPackage = "stats_package_1"; SpannerConnection connection = BuildSpannerConnection(spannerClientMock); connection.QueryOptions = QueryOptions.Empty .WithOptimizerVersion(connOptimizerVersion) .WithOptimizerStatisticsPackage(connOptimizerStatisticsPackage); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } }, envOptimizerVersion, envOptimizerStatisticsPackage); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.QueryOptions.OptimizerVersion == envOptimizerVersion && request.QueryOptions.OptimizerStatisticsPackage == envOptimizerStatisticsPackage), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CommandHasQueryOptionsSetOnCommand() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); const string cmdOptimizerVersion = "3"; const string cmdOptimizerStatisticsPackage = "stats_package_3"; const string envOptimizerVersion = "2"; const string envOptimizerStatisticsPackage = "stats_package_2"; RunActionWithEnvQueryOptions(() => { const string connOptimizerVersion = "1"; const string connOptimizerStatisticsPackage = "stats_package_1"; SpannerConnection connection = BuildSpannerConnection(spannerClientMock); connection.QueryOptions = QueryOptions.Empty .WithOptimizerVersion(connOptimizerVersion) .WithOptimizerStatisticsPackage(connOptimizerStatisticsPackage); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.QueryOptions = QueryOptions.Empty .WithOptimizerVersion(cmdOptimizerVersion) .WithOptimizerStatisticsPackage(cmdOptimizerStatisticsPackage); using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } }, envOptimizerVersion, envOptimizerStatisticsPackage); // Optimizer version set at a command level has higher precedence // than version set through the connection or the environment // variable. spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.QueryOptions.OptimizerVersion == cmdOptimizerVersion && request.QueryOptions.OptimizerStatisticsPackage == cmdOptimizerStatisticsPackage), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CloneWithPriority() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Priority = Priority.Low; var command2 = (SpannerCommand)command.Clone(); Assert.Same(command.SpannerConnection, command2.SpannerConnection); Assert.Equal(command.CommandText, command2.CommandText); Assert.Equal(command.Priority, command2.Priority); } [Fact] public void CommandPriorityDefaultsToUnspecified() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); Assert.Equal(Priority.Unspecified, command.Priority); } [Fact] public void CommitPriorityDefaultsToUnspecified() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); Assert.Equal(Priority.Unspecified, transaction.CommitPriority); } [Fact] public void CommandIncludesPriority() { var priority = Priority.High; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Priority = priority; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(priority)), It.IsAny<CallSettings>())); } [Fact] public void CommitIncludesPriority() { var commitPriority = Priority.Medium; var commandPriority = Priority.High; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); transaction.CommitPriority = commitPriority; var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Transaction = transaction; command.Priority = commandPriority; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } transaction.Commit(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(commandPriority)), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(commitPriority)), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CommitPriorityCanBeSetAfterCommandExecution() { var priority = Priority.Medium; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); // Execute a command on the transaction. var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Transaction = transaction; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } // Verify that we can set the commit priority after a command has been executed. transaction.CommitPriority = priority; transaction.Commit(); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(priority)), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CommitPriorityCannotBeSetForReadOnlyTransaction() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginReadOnlyTransaction(); Assert.Throws<InvalidOperationException>(() => transaction.CommitPriority = Priority.High); } [Fact] public void PriorityCanBeSetToUnspecified() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); transaction.CommitPriority = Priority.Unspecified; var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Transaction = transaction; command.Priority = Priority.Unspecified; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } transaction.Commit(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.Priority == RequestOptions.Types.Priority.Unspecified), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.Priority == RequestOptions.Types.Priority.Unspecified), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void RunWithRetryableTransactionWithCommitPriority() { var priority = Priority.Low; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync_Fails(1, StatusCode.Aborted, exceptionRetryDelay: TimeSpan.FromMilliseconds(0)) .SetupRollbackAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); connection.Builder.SessionPoolManager.SpannerSettings.Scheduler = new NoOpScheduler(); connection.RunWithRetriableTransaction(tx => { tx.CommitPriority = priority; var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Transaction = tx; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } }); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.Priority == RequestOptions.Types.Priority.Unspecified), It.IsAny<CallSettings>()), Times.Exactly(2)); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(priority)), It.IsAny<CallSettings>()), Times.Exactly(2)); } [Fact] public void MutationCommandIncludesPriority() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateInsertCommand("FOO"); command.Priority = Priority.High; command.ExecuteNonQuery(); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.Priority == RequestOptions.Types.Priority.High), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void PdmlCommandIncludesPriority() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSqlForDml(ResultSetStats.RowCountOneofCase.RowCountLowerBound); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateDmlCommand("DELETE FROM Users WHERE Active=False"); command.Priority = Priority.Low; command.ExecutePartitionedUpdate(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.Priority == RequestOptions.Types.Priority.Low), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void EphemeralTransactionIncludesPriorityOnDmlCommandAndCommit() { var priority = Priority.Medium; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSqlForDml(ResultSetStats.RowCountOneofCase.RowCountExact) .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateDmlCommand("UPDATE FOO SET BAR=1 WHERE ID=1"); command.Priority = priority; command.ExecuteNonQuery(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(priority)), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.Priority == PriorityConverter.ToProto(priority)), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CloneWithTags() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Tag = "tag-1"; var command2 = (SpannerCommand)command.Clone(); Assert.Same(command.SpannerConnection, command2.SpannerConnection); Assert.Equal(command.CommandText, command2.CommandText); Assert.Equal(command.Tag, command2.Tag); } [Fact] public void CommandIncludesRequestTag() { var tag = "tag-1"; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Tag = tag; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.RequestTag == tag && request.RequestOptions.TransactionTag == ""), It.IsAny<CallSettings>())); } [Fact] public void CommandIncludesRequestAndTransactionTag() { var requestTag1 = "request-tag-1"; var requestTag2 = "request-tag-2"; var transactionTag = "transaction-tag-1"; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); transaction.Tag = transactionTag; var command1 = connection.CreateSelectCommand("SELECT * FROM FOO"); command1.Transaction = transaction; command1.Tag = requestTag1; using (var reader = command1.ExecuteReader()) { Assert.True(reader.HasRows); } var command2 = connection.CreateSelectCommand("SELECT * FROM FOO"); command2.Transaction = transaction; command2.Tag = requestTag2; using (var reader = command2.ExecuteReader()) { Assert.True(reader.HasRows); } // Execute a statement without a request tag on the same transaction. var command3 = connection.CreateSelectCommand("SELECT * FROM FOO"); command3.Transaction = transaction; using (var reader = command3.ExecuteReader()) { Assert.True(reader.HasRows); } transaction.Commit(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.RequestTag == requestTag1 && request.RequestOptions.TransactionTag == transactionTag), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.RequestTag == requestTag2 && request.RequestOptions.TransactionTag == transactionTag), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.RequestTag == "" && request.RequestOptions.TransactionTag == transactionTag), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.RequestTag == "" && request.RequestOptions.TransactionTag == transactionTag), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void TransactionTagCannotBeSetAfterCommandExecution() { var transactionTag = "transaction-tag-1"; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); // Execute a command on the transaction without a transaction tag. var command1 = connection.CreateSelectCommand("SELECT * FROM FOO"); command1.Transaction = transaction; using (var reader = command1.ExecuteReader()) { Assert.True(reader.HasRows); } Assert.Throws<InvalidOperationException>(() => transaction.Tag = transactionTag); transaction.Commit(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.RequestTag == "" && request.RequestOptions.TransactionTag == ""), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.RequestTag == "" && request.RequestOptions.TransactionTag == ""), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void TransactionTagCannotBeSetForReadOnlyTransaction() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginReadOnlyTransaction(); Assert.Throws<InvalidOperationException>(() => transaction.Tag = "transaction-tag-1"); } [Fact] public void TagsCanBeSetToNull() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); SpannerTransaction transaction = connection.BeginTransaction(); transaction.Tag = null; var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Transaction = transaction; command.Tag = null; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } transaction.Commit(); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.RequestTag == "" && request.RequestOptions.TransactionTag == ""), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.RequestTag == "" && request.RequestOptions.TransactionTag == ""), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void RunWithRetryableTransactionWithTransactionTag() { var transactionTag = "retryable-tx-tag"; Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSql() .SetupCommitAsync_Fails(1, StatusCode.Aborted, exceptionRetryDelay: TimeSpan.FromMilliseconds(0)) .SetupRollbackAsync(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); connection.Builder.SessionPoolManager.SpannerSettings.Scheduler = new NoOpScheduler(); connection.RunWithRetriableTransaction(tx => { tx.Tag = transactionTag; var command = connection.CreateSelectCommand("SELECT * FROM FOO"); command.Transaction = tx; command.Tag = null; using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } }); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.Is<ExecuteSqlRequest>(request => request.RequestOptions.TransactionTag == transactionTag), It.IsAny<CallSettings>()), Times.Exactly(2)); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.RequestOptions.TransactionTag == transactionTag), It.IsAny<CallSettings>()), Times.Exactly(2)); } [Fact] public void ClientCreatedWithEmulatorDetection() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); var spannerClient = spannerClientMock.Object; var sessionPoolOptions = new SessionPoolOptions { MaintenanceLoopDelay = TimeSpan.Zero }; var sessionPoolManager = new SessionPoolManager( sessionPoolOptions, spannerClient.Settings, spannerClient.Settings.Logger, (_o, _s, _l) => { Assert.True(_o.UsesEmulator); return Task.FromResult(spannerClient); }); SpannerConnectionStringBuilder builder = new SpannerConnectionStringBuilder { DataSource = DatabaseName.Format(SpannerClientHelpers.ProjectId, SpannerClientHelpers.Instance, SpannerClientHelpers.Database), SessionPoolManager = sessionPoolManager, EmulatorDetection = EmulatorDetection.EmulatorOrProduction, EnvironmentVariableProvider = key => key == "SPANNER_EMULATOR_HOST" ? "localhost" : null }; var connection = new SpannerConnection(builder); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.IsAny<ExecuteSqlRequest>(), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void ExecuteReaderHasResourceHeader() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupExecuteStreamingSql(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateSelectCommand("SELECT * FROM FOO"); using (var reader = command.ExecuteReader()) { Assert.True(reader.HasRows); } spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.IsAny<ExecuteSqlRequest>(), It.Is<CallSettings>(settings => HasResourcePrefixHeader(settings))), Times.Once()); } [Fact] public void PdmlRetriedOnEosError() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupExecuteStreamingSqlForDmlThrowingEosError(); SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateDmlCommand("UPDATE abc SET xyz = 1 WHERE Id > 1"); long rowCount = command.ExecutePartitionedUpdate(); Assert.True(rowCount > 0); spannerClientMock.Verify(client => client.ExecuteStreamingSql( It.IsAny<ExecuteSqlRequest>(), It.IsAny<CallSettings>()), Times.Exactly(3)); } [Fact] public async Task ParallelMutationCommandsOnAmbientTransaction_OnlyCreateOneSpannerTransactionAsync() { Mock<SpannerClient> spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupCommitAsync(); using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { SpannerConnection connection = BuildSpannerConnection(spannerClientMock); var tables = new string[] { "TAB1", "TAB2", "TAB3" }; await Task.WhenAll(tables.Select(table => { using var cmd = connection.CreateInsertCommand(table); return cmd.ExecuteNonQueryAsync(); })); scope.Complete(); } spannerClientMock.Verify(client => client.CommitAsync( It.IsAny<CommitRequest>(), It.IsAny<CallSettings>()), Times.Once()); spannerClientMock.Verify(client => client.CommitAsync( It.Is<CommitRequest>(request => request.Mutations.Count == 3), It.IsAny<CallSettings>()), Times.Once()); } [Fact] public void CanCreateReadCommand() { var connection = new SpannerConnection("Data Source=projects/p/instances/i/databases/d"); var command = connection.CreateReadCommand( "Foo", ReadOptions.FromColumns("Col1", "Col2"), KeySet.FromParameters(new SpannerParameterCollection { {"key1", SpannerDbType.String, "test"}, {"key2", SpannerDbType.Int64, 10} })); Assert.Equal("Foo", command.SpannerCommandTextBuilder.TargetTable); Assert.Equal(new List<string> { "Col1", "Col2" }, command.SpannerCommandTextBuilder.ReadOptions?.Columns); } [Fact] public async Task CanExecuteReadCommand() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateReadCommand( "Foo", ReadOptions.FromColumns(new List<string> { "Col1", "Col2" }), KeySet.FromParameters(new SpannerParameterCollection { {"string", SpannerDbType.String, "test"}, {"bytes", SpannerDbType.Bytes, new byte[] {1, 2, 3}}, {"int64", SpannerDbType.Int64, "10"}, {"float64", SpannerDbType.Float64, 3.14}, {"numeric", SpannerDbType.Numeric, SpannerNumeric.Parse("6.626")}, {"date", SpannerDbType.Date, new DateTime(2021, 9, 8, 0, 0, 0, DateTimeKind.Utc)}, {"timestamp", SpannerDbType.Timestamp, new DateTime(2021, 9, 8, 15, 22, 59, DateTimeKind.Utc)}, {"bool", SpannerDbType.Bool, true}, })); using var reader = await command.ExecuteReaderAsync(); Assert.True(reader.HasRows); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.Table == "Foo"), It.IsAny<CallSettings>())); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.Columns.Equals(new RepeatedField<string> { "Col1", "Col2" })), It.IsAny<CallSettings>())); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.KeySet.Equals(new V1.KeySet { Keys = { new ListValue{ Values = { new Value { StringValue = "test"}, new Value { StringValue = Convert.ToBase64String(new byte[] {1, 2, 3})}, new Value { StringValue = "10" }, new Value { NumberValue = 3.14 }, new Value { StringValue = "6.626" }, new Value { StringValue = "2021-09-08" }, new Value { StringValue = "2021-09-08T15:22:59Z" }, new Value { BoolValue = true }, } } } })), It.IsAny<CallSettings>())); } [Fact] public async Task CanExecuteReadAllCommand() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateReadCommand("Foo", ReadOptions.FromColumns("Col1", "Col2"), KeySet.All); using var reader = await command.ExecuteReaderAsync(); Assert.True(reader.HasRows); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.KeySet.Equals(new V1.KeySet { All = true })), It.IsAny<CallSettings>())); } [Fact] public async Task CanExecuteReadCommandWithKeyRange() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateReadCommand( "Foo", ReadOptions.FromColumns("Col1", "Col2"), KeySet.FromRanges(KeyRange.ClosedOpen(new Key("test_begin"), new Key("test_end")))); using var reader = await command.ExecuteReaderAsync(); Assert.True(reader.HasRows); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.KeySet.Equals(new V1.KeySet { Ranges = { new [] { new V1.KeyRange { StartClosed = new ListValue { Values = { new Value { StringValue = "test_begin" } } }, EndOpen = new ListValue { Values = { new Value { StringValue = "test_end" } } } } } } } )), It.IsAny<CallSettings>())); } [Fact] public async Task CanExecuteReadCommandWithKeyCollection() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateReadCommand( "Foo", ReadOptions.FromColumns("Col1", "Col2"), KeySet.FromKeys(new Key("key1"), new Key("key2"), new Key("key3"))); using var reader = await command.ExecuteReaderAsync(); Assert.True(reader.HasRows); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.KeySet.Equals(new V1.KeySet { Keys = { new ListValue { Values = { new Value { StringValue = "key1" } } }, new ListValue { Values = { new Value { StringValue = "key2" } } }, new ListValue { Values = { new Value { StringValue = "key3" } } }, } } )), It.IsAny<CallSettings>())); } [Fact] public async Task CanExecuteReadCommandWithIndex() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateReadCommand("Foo", ReadOptions.FromColumns("Col1", "Col2").WithIndexName("IdxBar"), KeySet.All); using var reader = await command.ExecuteReaderAsync(); Assert.True(reader.HasRows); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.Index == "IdxBar"), It.IsAny<CallSettings>())); } [Fact] public async Task CanExecuteReadCommandWithLimit() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var command = connection.CreateReadCommand("Foo", ReadOptions.FromColumns("Col1", "Col2").WithLimit(10), KeySet.All); using var reader = await command.ExecuteReaderAsync(); Assert.True(reader.HasRows); spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => request.Limit == 10), It.IsAny<CallSettings>())); } [Fact] public async Task CanExecuteReadPartitionedReadCommand() { var spannerClientMock = SpannerClientHelpers .CreateMockClient(Logger.DefaultLogger); spannerClientMock .SetupBatchCreateSessionsAsync() .SetupBeginTransactionAsync() .SetupPartitionAsync() .SetupStreamingRead(); var connection = BuildSpannerConnection(spannerClientMock); var transaction = await connection.BeginReadOnlyTransactionAsync(); var command = connection.CreateReadCommand("Foo", ReadOptions.FromColumns("Col1", "Col2").WithLimit(10), KeySet.All); command.Transaction = transaction; var partitions = await command.GetReaderPartitionsAsync(0, 10); foreach (var partition in partitions) { // Normally we would send this information to another client to read, but we are just simulating it here // by serializing and deserializing the information locally. var tx = connection.BeginReadOnlyTransaction(TransactionId.FromBase64String(transaction.TransactionId.ToBase64String())); var cmd = connection.CreateCommandWithPartition(CommandPartition.FromBase64String(partition.ToBase64String()), tx); var reader = await cmd.ExecuteReaderAsync(); Assert.True(reader.HasRows); } spannerClientMock.Verify(client => client.StreamingRead( It.Is<ReadRequest>(request => !request.PartitionToken.IsEmpty && object.Equals(request.Transaction.Id.ToBase64(), transaction.TransactionId.Id)), It.IsAny<CallSettings>()), Times.Exactly(10)); } internal static SpannerConnection BuildSpannerConnection(Mock<SpannerClient> spannerClientMock) { var spannerClient = spannerClientMock.Object; var sessionPoolOptions = new SessionPoolOptions { MaintenanceLoopDelay = TimeSpan.Zero }; var sessionPoolManager = new SessionPoolManager(sessionPoolOptions, spannerClient.Settings, spannerClient.Settings.Logger, (_o, _s, _l) => Task.FromResult(spannerClient)); sessionPoolManager.SpannerSettings.Scheduler = spannerClient.Settings.Scheduler; sessionPoolManager.SpannerSettings.Clock = spannerClient.Settings.Clock; SpannerConnectionStringBuilder builder = new SpannerConnectionStringBuilder { DataSource = DatabaseName.Format(SpannerClientHelpers.ProjectId, SpannerClientHelpers.Instance, SpannerClientHelpers.Database), SessionPoolManager = sessionPoolManager }; return new SpannerConnection(builder); } private void RunActionWithEnvQueryOptions(Action action, string envOptimizerVersion, string envOptimizerStatisticsPackage) { // Save existing value of environment variable. const string optimizerVersionVariable = "SPANNER_OPTIMIZER_VERSION"; const string optimizerStatisticsPackageVariable = "SPANNER_OPTIMIZER_STATISTICS_PACKAGE"; string savedOptimizerVersion = Environment.GetEnvironmentVariable(optimizerVersionVariable); string savedOptimizerStatisticsPackage = Environment.GetEnvironmentVariable(optimizerStatisticsPackageVariable); Environment.SetEnvironmentVariable(optimizerVersionVariable, envOptimizerVersion); Environment.SetEnvironmentVariable(optimizerStatisticsPackageVariable, envOptimizerStatisticsPackage); try { action(); } finally { // Set the environment back. Environment.SetEnvironmentVariable(optimizerVersionVariable, savedOptimizerVersion); Environment.SetEnvironmentVariable(optimizerStatisticsPackageVariable, savedOptimizerStatisticsPackage); } } private bool HasResourcePrefixHeader(CallSettings callSettings) { var expectedDatabaseName = DatabaseName.FromProjectInstanceDatabase( SpannerClientHelpers.ProjectId, SpannerClientHelpers.Instance, SpannerClientHelpers.Database); var metadata = new Metadata(); callSettings.HeaderMutation?.Invoke(metadata); Metadata.Entry entry = Assert.Single(metadata, e => e.Key == SpannerClientImpl.ResourcePrefixHeader); return expectedDatabaseName.ToString() == entry.Value; } } }
namespace LessPaper.Shared.Interfaces.General { public interface ISearchResult { /// <summary> /// Search query /// </summary> string SearchQuery { get; } /// <summary> /// Found files /// </summary> IFileMetadata[] Files { get; } /// <summary> /// Found directories /// </summary> IMinimalDirectoryMetadata[] Directories { get; } } }
namespace ServicebusMessageHandler { public interface IWidget { void DoSomething(string message); } }
using UnityEngine; namespace Kadinche.Kassets.Variable { [CreateAssetMenu(fileName = "ByteVariable", menuName = MenuHelper.DefaultVariableMenu + "Byte")] public class ByteVariable : VariableCore<byte> { } }
using System.Collections.Generic; using AutoMapper; using PaliCanon.Contracts.Chapter; using PaliCanon.Contracts.Quote; using PaliCanon.Contracts.Verse; using PaliCanon.Model; namespace PaliCanon.Services { public class ChapterService<T, U>: IChapterService where T : class, IChapterEntity where U: class, IVerseEntity { private readonly IChapterRepository<T> _chapterRepository; private readonly IQuoteRepository<T, U> _quoteRepository; private readonly IMapper _mapper; public ChapterService(IChapterRepository<T> chapterRepository, IQuoteRepository<T, U> quoteRepository, IMapper mapper) { _chapterRepository = chapterRepository; _quoteRepository = quoteRepository; _mapper = mapper; } public void Insert(Chapter record) { _chapterRepository.Insert(_mapper.Map<T>(record)); } public Chapter Get(string bookCode, int chapter, int? verse) { return _mapper.Map<Chapter>(_chapterRepository.Get(bookCode, chapter, verse)); } public Quote Quote(string bookCode = null, int? maxLength = null) { return _mapper.Map<Quote>(_quoteRepository.Quote(bookCode, maxLength)); } public List<Quote> Quotes(int numberOfQuotes, int? maxLength = null) { return _mapper.Map<List<Quote>>(_quoteRepository.Quotes(numberOfQuotes, maxLength:maxLength)); } public List<Quote> Search(string searchTerm, int? pageSize, int? pageNumber = 1) { return _mapper.Map<List<Quote>>(_quoteRepository.Search(searchTerm, pageSize, pageNumber)); } public Chapter Next(string bookCode, int verse) { return _mapper.Map<Chapter>(_chapterRepository.Next(bookCode, verse)); } public Chapter First(string bookCode) { return _mapper.Map<Chapter>(_chapterRepository.First(bookCode)); } public Chapter Last(string bookCode) { return _mapper.Map<Chapter>(_chapterRepository.Last(bookCode)); } } }
using Assets.GameManagement; using UnityEngine; using System; using UnityEditor; namespace Assets.MapObject.Vehicle { public class PlayerBehaviour : MonoBehaviour, IKillable { public Vehicle vehicle; private float velocity; private bool canRotate; private bool pointerInside; private enum PlayerState { Preparing, Running, Stop, Off } private PlayerState playerState; void Start() { vehicle.Load(this); pointerInside = false; velocity = 0.0f; canRotate = true; playerState = PlayerState.Preparing; GameplayController.Play += StartVehicle; GameplayController.Stop += StopVehicle; } void Update() { if (canRotate) transform.up = GameplayController.instance.GetMoveDirection(transform.position); float deltaDistance = Time.unscaledDeltaTime * velocity; transform.position = (Vector2)transform.position + (Vector2)transform.up.normalized * deltaDistance; } private void OnMouseEnter() { pointerInside = true; if (playerState == PlayerState.Running) TurnOffEngines(); } private void OnMouseExit() { pointerInside = false; } private void OnDestroy() { GameplayController.Play -= StartVehicle; GameplayController.Stop -= StopVehicle; } #if UNITY_EDITOR private void OnDrawGizmos() { if (EditorApplication.isPlaying) return; Gizmos.color = Color.red; Gizmos.DrawSphere(transform.position, 1); } #endif public void StartVehicle() { switch (playerState) { case PlayerState.Preparing: if (pointerInside) break; velocity = vehicle.maxVelocity; canRotate = true; playerState = PlayerState.Running; StartCoroutine(vehicle.TurnOn(this)); break; case PlayerState.Off: if (pointerInside) { GameplayController.instance.PlayerOff(); break; } TurnOnEngines(); break; case PlayerState.Running: break; default: throw new NotImplementedException("Start Vehicle case."); } } public void StopVehicle() { canRotate = false; velocity = 0.0f; if(playerState == PlayerState.Running) StartCoroutine(vehicle.TurnOff(this)); playerState = PlayerState.Stop; } public void TurnOffEngines() { canRotate = false; StartCoroutine(vehicle.TurnOff(this)); GameplayController.instance.PlayerOff(); playerState = PlayerState.Off; } public void TurnOnEngines() { canRotate = true; StartCoroutine(vehicle.TurnOn(this)); playerState = PlayerState.Running; } public void Die() { Collider2D[] colliders = gameObject.GetComponentsInChildren<Collider2D>(); foreach (Collider2D collider in colliders) { collider.enabled = false; } StopVehicle(); StartCoroutine(vehicle.explosion.Explode(gameObject)); GameplayController.instance.EndScreen(false); } } }
using System; namespace Menu { enum MenuOptions { User = '1', Admin = '2', Exit = '3' } enum UserOptions { ViewPostWithId = '1', LikePostWithId = '2', Exit = '3' } enum AdminOptions { ShowAllPosts = '1', AddPost = '2', RemovePost = '3', ShowAllNotifications = '4', Exit = '5' } }
// MonoGame - Copyright (C) The MonoGame Team // This file is subject to the terms and conditions defined in // file 'LICENSE.txt', which is part of this source code package. using MonoGame.OpenGL; namespace Microsoft.Xna.Framework.Graphics { public sealed partial class TextureCollection { private TextureTarget[] _targets; void PlatformInit() { _targets = new TextureTarget[_textures.Length]; } void PlatformClear() { for (var i = 0; i < _targets.Length; i++) _targets[i] = 0; } void PlatformSetTextures(GraphicsDevice device) { // Skip out if nothing has changed. if (_dirty == 0) return; for (var i = 0; i < _textures.Length; i++) { var mask = 1 << i; if ((_dirty & mask) == 0) continue; var tex = _textures[i]; GL.ActiveTexture(TextureUnit.Texture0 + i); GraphicsExtensions.CheckGLError(); // Clear the previous binding if the // target is different from the new one. if (_targets[i] != 0 && (tex == null || _targets[i] != tex.glTarget)) { GL.BindTexture(_targets[i], 0); _targets[i] = 0; GraphicsExtensions.CheckGLError(); } if (tex != null) { _targets[i] = tex.glTarget; GL.BindTexture(tex.glTarget, tex.glTexture); GraphicsExtensions.CheckGLError(); unchecked { _graphicsDevice._graphicsMetrics._textureCount++; } } _dirty &= ~mask; if (_dirty == 0) break; } _dirty = 0; } } }
using System; namespace Socket.Newtonsoft.Json.Serialization { public class ErrorContext { internal ErrorContext(object originalObject, object member, string path, Exception error) { this.OriginalObject = originalObject; this.Member = member; this.Error = error; this.Path = path; } internal bool Traced { get; set; } public Exception Error { get; } public object OriginalObject { get; } public object Member { get; } public string Path { get; } public bool Handled { get; set; } } }
@model BlockExplorer.Models.Transaction[] @{ ViewData["Title"] = "_Transactions"; } <h2>_Transactions</h2> @Model.Length
using System.Threading.Tasks; using Microsoft.AspNetCore.Http; namespace AngularDotnetPlatform.Platform.AspNetCore.Middleware.Abstracts { public interface IPlatformMiddleware { public Task InvokeAsync(HttpContext context); } public abstract class PlatformMiddleware : IPlatformMiddleware { protected readonly RequestDelegate Next; public PlatformMiddleware(RequestDelegate next) { Next = next; } public Task InvokeAsync(HttpContext context) { return InternalInvokeAsync(context); } protected abstract Task InternalInvokeAsync(HttpContext context); } }
using System; using System.Threading.Tasks; namespace taskplay { public class Program { static async Task Main(string[] args) { var program = new Program(); Console.WriteLine("Started..."); // Comment & uncomment the one you want to try... // They both do the same thing, but in different async style //await new SampleAsyncAwait().RunAsync(); await new SampleTPL().RunAsync(); Console.WriteLine("Ended..."); } } }
using System; using System.Collections.Generic; class Program { static void Main() // 100/100 { int n = int.Parse(Console.ReadLine()); List<int> list = new List<int>(); for (int i = 0; i < n; i++) { list.Add(int.Parse(Console.ReadLine())); } list.Reverse(); foreach (var number in list) { Console.WriteLine(number); } } }
using System; namespace ConsoleInteractive.InputConverter { /// <summary> /// Convert a string to and from a object /// </summary> public interface IStringConverter { Type Target { get; } object ToObject(string value); string ToString(object value); } public interface IStringConverter<T> : IStringConverter { new T ToObject(string value); string ToString(T value); } }
using size_t = BrotliSharpLib.Brotli.SizeT; namespace BrotliSharpLib { public static partial class Brotli { private static readonly byte[] kDefaultCommandDepths = { 0, 4, 4, 5, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 0, 0, 0, 4, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 10, 10, 10, 10, 10, 10, 0, 4, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, }; private static readonly ushort[] kDefaultCommandBits = { 0, 0, 8, 9, 3, 35, 7, 71, 39, 103, 23, 47, 175, 111, 239, 31, 0, 0, 0, 4, 12, 2, 10, 6, 13, 29, 11, 43, 27, 59, 87, 55, 15, 79, 319, 831, 191, 703, 447, 959, 0, 14, 1, 25, 5, 21, 19, 51, 119, 159, 95, 223, 479, 991, 63, 575, 127, 639, 383, 895, 255, 767, 511, 1023, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 59, 7, 39, 23, 55, 30, 1, 17, 9, 25, 5, 0, 8, 4, 12, 2, 10, 6, 21, 13, 29, 3, 19, 11, 15, 47, 31, 95, 63, 127, 255, 767, 2815, 1791, 3839, 511, 2559, 1535, 3583, 1023, 3071, 2047, 4095, }; private static readonly byte[] kDefaultCommandCode = { 0xff, 0x77, 0xd5, 0xbf, 0xe7, 0xde, 0xea, 0x9e, 0x51, 0x5d, 0xde, 0xc6, 0x70, 0x57, 0xbc, 0x58, 0x58, 0x58, 0xd8, 0xd8, 0x58, 0xd5, 0xcb, 0x8c, 0xea, 0xe0, 0xc3, 0x87, 0x1f, 0x83, 0xc1, 0x60, 0x1c, 0x67, 0xb2, 0xaa, 0x06, 0x83, 0xc1, 0x60, 0x30, 0x18, 0xcc, 0xa1, 0xce, 0x88, 0x54, 0x94, 0x46, 0xe1, 0xb0, 0xd0, 0x4e, 0xb2, 0xf7, 0x04, 0x00, }; private static readonly size_t kDefaultCommandCodeNumBits = 448; private static readonly byte[] kCodeLengthDepth = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 0, 4, 4, }; private static readonly byte[] kCodeLengthBits = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 15, 31, 0, 11, 7, }; private static readonly ulong[] kZeroRepsBits = { 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000017, 0x00000027, 0x00000037, 0x00000047, 0x00000057, 0x00000067, 0x00000077, 0x00000770, 0x00000b87, 0x00001387, 0x00001b87, 0x00002387, 0x00002b87, 0x00003387, 0x00003b87, 0x00000397, 0x00000b97, 0x00001397, 0x00001b97, 0x00002397, 0x00002b97, 0x00003397, 0x00003b97, 0x000003a7, 0x00000ba7, 0x000013a7, 0x00001ba7, 0x000023a7, 0x00002ba7, 0x000033a7, 0x00003ba7, 0x000003b7, 0x00000bb7, 0x000013b7, 0x00001bb7, 0x000023b7, 0x00002bb7, 0x000033b7, 0x00003bb7, 0x000003c7, 0x00000bc7, 0x000013c7, 0x00001bc7, 0x000023c7, 0x00002bc7, 0x000033c7, 0x00003bc7, 0x000003d7, 0x00000bd7, 0x000013d7, 0x00001bd7, 0x000023d7, 0x00002bd7, 0x000033d7, 0x00003bd7, 0x000003e7, 0x00000be7, 0x000013e7, 0x00001be7, 0x000023e7, 0x00002be7, 0x000033e7, 0x00003be7, 0x000003f7, 0x00000bf7, 0x000013f7, 0x00001bf7, 0x000023f7, 0x00002bf7, 0x000033f7, 0x00003bf7, 0x0001c387, 0x0005c387, 0x0009c387, 0x000dc387, 0x0011c387, 0x0015c387, 0x0019c387, 0x001dc387, 0x0001cb87, 0x0005cb87, 0x0009cb87, 0x000dcb87, 0x0011cb87, 0x0015cb87, 0x0019cb87, 0x001dcb87, 0x0001d387, 0x0005d387, 0x0009d387, 0x000dd387, 0x0011d387, 0x0015d387, 0x0019d387, 0x001dd387, 0x0001db87, 0x0005db87, 0x0009db87, 0x000ddb87, 0x0011db87, 0x0015db87, 0x0019db87, 0x001ddb87, 0x0001e387, 0x0005e387, 0x0009e387, 0x000de387, 0x0011e387, 0x0015e387, 0x0019e387, 0x001de387, 0x0001eb87, 0x0005eb87, 0x0009eb87, 0x000deb87, 0x0011eb87, 0x0015eb87, 0x0019eb87, 0x001deb87, 0x0001f387, 0x0005f387, 0x0009f387, 0x000df387, 0x0011f387, 0x0015f387, 0x0019f387, 0x001df387, 0x0001fb87, 0x0005fb87, 0x0009fb87, 0x000dfb87, 0x0011fb87, 0x0015fb87, 0x0019fb87, 0x001dfb87, 0x0001c397, 0x0005c397, 0x0009c397, 0x000dc397, 0x0011c397, 0x0015c397, 0x0019c397, 0x001dc397, 0x0001cb97, 0x0005cb97, 0x0009cb97, 0x000dcb97, 0x0011cb97, 0x0015cb97, 0x0019cb97, 0x001dcb97, 0x0001d397, 0x0005d397, 0x0009d397, 0x000dd397, 0x0011d397, 0x0015d397, 0x0019d397, 0x001dd397, 0x0001db97, 0x0005db97, 0x0009db97, 0x000ddb97, 0x0011db97, 0x0015db97, 0x0019db97, 0x001ddb97, 0x0001e397, 0x0005e397, 0x0009e397, 0x000de397, 0x0011e397, 0x0015e397, 0x0019e397, 0x001de397, 0x0001eb97, 0x0005eb97, 0x0009eb97, 0x000deb97, 0x0011eb97, 0x0015eb97, 0x0019eb97, 0x001deb97, 0x0001f397, 0x0005f397, 0x0009f397, 0x000df397, 0x0011f397, 0x0015f397, 0x0019f397, 0x001df397, 0x0001fb97, 0x0005fb97, 0x0009fb97, 0x000dfb97, 0x0011fb97, 0x0015fb97, 0x0019fb97, 0x001dfb97, 0x0001c3a7, 0x0005c3a7, 0x0009c3a7, 0x000dc3a7, 0x0011c3a7, 0x0015c3a7, 0x0019c3a7, 0x001dc3a7, 0x0001cba7, 0x0005cba7, 0x0009cba7, 0x000dcba7, 0x0011cba7, 0x0015cba7, 0x0019cba7, 0x001dcba7, 0x0001d3a7, 0x0005d3a7, 0x0009d3a7, 0x000dd3a7, 0x0011d3a7, 0x0015d3a7, 0x0019d3a7, 0x001dd3a7, 0x0001dba7, 0x0005dba7, 0x0009dba7, 0x000ddba7, 0x0011dba7, 0x0015dba7, 0x0019dba7, 0x001ddba7, 0x0001e3a7, 0x0005e3a7, 0x0009e3a7, 0x000de3a7, 0x0011e3a7, 0x0015e3a7, 0x0019e3a7, 0x001de3a7, 0x0001eba7, 0x0005eba7, 0x0009eba7, 0x000deba7, 0x0011eba7, 0x0015eba7, 0x0019eba7, 0x001deba7, 0x0001f3a7, 0x0005f3a7, 0x0009f3a7, 0x000df3a7, 0x0011f3a7, 0x0015f3a7, 0x0019f3a7, 0x001df3a7, 0x0001fba7, 0x0005fba7, 0x0009fba7, 0x000dfba7, 0x0011fba7, 0x0015fba7, 0x0019fba7, 0x001dfba7, 0x0001c3b7, 0x0005c3b7, 0x0009c3b7, 0x000dc3b7, 0x0011c3b7, 0x0015c3b7, 0x0019c3b7, 0x001dc3b7, 0x0001cbb7, 0x0005cbb7, 0x0009cbb7, 0x000dcbb7, 0x0011cbb7, 0x0015cbb7, 0x0019cbb7, 0x001dcbb7, 0x0001d3b7, 0x0005d3b7, 0x0009d3b7, 0x000dd3b7, 0x0011d3b7, 0x0015d3b7, 0x0019d3b7, 0x001dd3b7, 0x0001dbb7, 0x0005dbb7, 0x0009dbb7, 0x000ddbb7, 0x0011dbb7, 0x0015dbb7, 0x0019dbb7, 0x001ddbb7, 0x0001e3b7, 0x0005e3b7, 0x0009e3b7, 0x000de3b7, 0x0011e3b7, 0x0015e3b7, 0x0019e3b7, 0x001de3b7, 0x0001ebb7, 0x0005ebb7, 0x0009ebb7, 0x000debb7, 0x0011ebb7, 0x0015ebb7, 0x0019ebb7, 0x001debb7, 0x0001f3b7, 0x0005f3b7, 0x0009f3b7, 0x000df3b7, 0x0011f3b7, 0x0015f3b7, 0x0019f3b7, 0x001df3b7, 0x0001fbb7, 0x0005fbb7, 0x0009fbb7, 0x000dfbb7, 0x0011fbb7, 0x0015fbb7, 0x0019fbb7, 0x001dfbb7, 0x0001c3c7, 0x0005c3c7, 0x0009c3c7, 0x000dc3c7, 0x0011c3c7, 0x0015c3c7, 0x0019c3c7, 0x001dc3c7, 0x0001cbc7, 0x0005cbc7, 0x0009cbc7, 0x000dcbc7, 0x0011cbc7, 0x0015cbc7, 0x0019cbc7, 0x001dcbc7, 0x0001d3c7, 0x0005d3c7, 0x0009d3c7, 0x000dd3c7, 0x0011d3c7, 0x0015d3c7, 0x0019d3c7, 0x001dd3c7, 0x0001dbc7, 0x0005dbc7, 0x0009dbc7, 0x000ddbc7, 0x0011dbc7, 0x0015dbc7, 0x0019dbc7, 0x001ddbc7, 0x0001e3c7, 0x0005e3c7, 0x0009e3c7, 0x000de3c7, 0x0011e3c7, 0x0015e3c7, 0x0019e3c7, 0x001de3c7, 0x0001ebc7, 0x0005ebc7, 0x0009ebc7, 0x000debc7, 0x0011ebc7, 0x0015ebc7, 0x0019ebc7, 0x001debc7, 0x0001f3c7, 0x0005f3c7, 0x0009f3c7, 0x000df3c7, 0x0011f3c7, 0x0015f3c7, 0x0019f3c7, 0x001df3c7, 0x0001fbc7, 0x0005fbc7, 0x0009fbc7, 0x000dfbc7, 0x0011fbc7, 0x0015fbc7, 0x0019fbc7, 0x001dfbc7, 0x0001c3d7, 0x0005c3d7, 0x0009c3d7, 0x000dc3d7, 0x0011c3d7, 0x0015c3d7, 0x0019c3d7, 0x001dc3d7, 0x0001cbd7, 0x0005cbd7, 0x0009cbd7, 0x000dcbd7, 0x0011cbd7, 0x0015cbd7, 0x0019cbd7, 0x001dcbd7, 0x0001d3d7, 0x0005d3d7, 0x0009d3d7, 0x000dd3d7, 0x0011d3d7, 0x0015d3d7, 0x0019d3d7, 0x001dd3d7, 0x0001dbd7, 0x0005dbd7, 0x0009dbd7, 0x000ddbd7, 0x0011dbd7, 0x0015dbd7, 0x0019dbd7, 0x001ddbd7, 0x0001e3d7, 0x0005e3d7, 0x0009e3d7, 0x000de3d7, 0x0011e3d7, 0x0015e3d7, 0x0019e3d7, 0x001de3d7, 0x0001ebd7, 0x0005ebd7, 0x0009ebd7, 0x000debd7, 0x0011ebd7, 0x0015ebd7, 0x0019ebd7, 0x001debd7, 0x0001f3d7, 0x0005f3d7, 0x0009f3d7, 0x000df3d7, 0x0011f3d7, 0x0015f3d7, 0x0019f3d7, 0x001df3d7, 0x0001fbd7, 0x0005fbd7, 0x0009fbd7, 0x000dfbd7, 0x0011fbd7, 0x0015fbd7, 0x0019fbd7, 0x001dfbd7, 0x0001c3e7, 0x0005c3e7, 0x0009c3e7, 0x000dc3e7, 0x0011c3e7, 0x0015c3e7, 0x0019c3e7, 0x001dc3e7, 0x0001cbe7, 0x0005cbe7, 0x0009cbe7, 0x000dcbe7, 0x0011cbe7, 0x0015cbe7, 0x0019cbe7, 0x001dcbe7, 0x0001d3e7, 0x0005d3e7, 0x0009d3e7, 0x000dd3e7, 0x0011d3e7, 0x0015d3e7, 0x0019d3e7, 0x001dd3e7, 0x0001dbe7, 0x0005dbe7, 0x0009dbe7, 0x000ddbe7, 0x0011dbe7, 0x0015dbe7, 0x0019dbe7, 0x001ddbe7, 0x0001e3e7, 0x0005e3e7, 0x0009e3e7, 0x000de3e7, 0x0011e3e7, 0x0015e3e7, 0x0019e3e7, 0x001de3e7, 0x0001ebe7, 0x0005ebe7, 0x0009ebe7, 0x000debe7, 0x0011ebe7, 0x0015ebe7, 0x0019ebe7, 0x001debe7, 0x0001f3e7, 0x0005f3e7, 0x0009f3e7, 0x000df3e7, 0x0011f3e7, 0x0015f3e7, 0x0019f3e7, 0x001df3e7, 0x0001fbe7, 0x0005fbe7, 0x0009fbe7, 0x000dfbe7, 0x0011fbe7, 0x0015fbe7, 0x0019fbe7, 0x001dfbe7, 0x0001c3f7, 0x0005c3f7, 0x0009c3f7, 0x000dc3f7, 0x0011c3f7, 0x0015c3f7, 0x0019c3f7, 0x001dc3f7, 0x0001cbf7, 0x0005cbf7, 0x0009cbf7, 0x000dcbf7, 0x0011cbf7, 0x0015cbf7, 0x0019cbf7, 0x001dcbf7, 0x0001d3f7, 0x0005d3f7, 0x0009d3f7, 0x000dd3f7, 0x0011d3f7, 0x0015d3f7, 0x0019d3f7, 0x001dd3f7, 0x0001dbf7, 0x0005dbf7, 0x0009dbf7, 0x000ddbf7, 0x0011dbf7, 0x0015dbf7, 0x0019dbf7, 0x001ddbf7, 0x0001e3f7, 0x0005e3f7, 0x0009e3f7, 0x000de3f7, 0x0011e3f7, 0x0015e3f7, 0x0019e3f7, 0x001de3f7, 0x0001ebf7, 0x0005ebf7, 0x0009ebf7, 0x000debf7, 0x0011ebf7, 0x0015ebf7, 0x0019ebf7, 0x001debf7, 0x0001f3f7, 0x0005f3f7, 0x0009f3f7, 0x000df3f7, 0x0011f3f7, 0x0015f3f7, 0x0019f3f7, 0x001df3f7, 0x0001fbf7, 0x0005fbf7, 0x0009fbf7, 0x000dfbf7, 0x0011fbf7, 0x0015fbf7, 0x0019fbf7, 0x001dfbf7, 0x00e1c387, 0x02e1c387, 0x04e1c387, 0x06e1c387, 0x08e1c387, 0x0ae1c387, 0x0ce1c387, 0x0ee1c387, 0x00e5c387, 0x02e5c387, 0x04e5c387, 0x06e5c387, 0x08e5c387, 0x0ae5c387, 0x0ce5c387, 0x0ee5c387, 0x00e9c387, 0x02e9c387, 0x04e9c387, 0x06e9c387, 0x08e9c387, 0x0ae9c387, 0x0ce9c387, 0x0ee9c387, 0x00edc387, 0x02edc387, 0x04edc387, 0x06edc387, 0x08edc387, 0x0aedc387, 0x0cedc387, 0x0eedc387, 0x00f1c387, 0x02f1c387, 0x04f1c387, 0x06f1c387, 0x08f1c387, 0x0af1c387, 0x0cf1c387, 0x0ef1c387, 0x00f5c387, 0x02f5c387, 0x04f5c387, 0x06f5c387, 0x08f5c387, 0x0af5c387, 0x0cf5c387, 0x0ef5c387, 0x00f9c387, 0x02f9c387, 0x04f9c387, 0x06f9c387, 0x08f9c387, 0x0af9c387, 0x0cf9c387, 0x0ef9c387, 0x00fdc387, 0x02fdc387, 0x04fdc387, 0x06fdc387, 0x08fdc387, 0x0afdc387, 0x0cfdc387, 0x0efdc387, 0x00e1cb87, 0x02e1cb87, 0x04e1cb87, 0x06e1cb87, 0x08e1cb87, 0x0ae1cb87, 0x0ce1cb87, 0x0ee1cb87, 0x00e5cb87, 0x02e5cb87, 0x04e5cb87, 0x06e5cb87, 0x08e5cb87, 0x0ae5cb87, 0x0ce5cb87, 0x0ee5cb87, 0x00e9cb87, 0x02e9cb87, 0x04e9cb87, 0x06e9cb87, 0x08e9cb87, 0x0ae9cb87, 0x0ce9cb87, 0x0ee9cb87, 0x00edcb87, 0x02edcb87, 0x04edcb87, 0x06edcb87, 0x08edcb87, 0x0aedcb87, 0x0cedcb87, 0x0eedcb87, 0x00f1cb87, 0x02f1cb87, 0x04f1cb87, 0x06f1cb87, 0x08f1cb87, 0x0af1cb87, 0x0cf1cb87, 0x0ef1cb87, 0x00f5cb87, 0x02f5cb87, 0x04f5cb87, 0x06f5cb87, 0x08f5cb87, 0x0af5cb87, 0x0cf5cb87, 0x0ef5cb87, 0x00f9cb87, 0x02f9cb87, 0x04f9cb87, 0x06f9cb87, 0x08f9cb87, }; private static readonly uint[] kZeroRepsDepth = { 0, 4, 8, 7, 7, 7, 7, 7, 7, 7, 7, 11, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, }; private static ulong[] kNonZeroRepsBits = { 0x0000000b, 0x0000001b, 0x0000002b, 0x0000003b, 0x000002cb, 0x000006cb, 0x00000acb, 0x00000ecb, 0x000002db, 0x000006db, 0x00000adb, 0x00000edb, 0x000002eb, 0x000006eb, 0x00000aeb, 0x00000eeb, 0x000002fb, 0x000006fb, 0x00000afb, 0x00000efb, 0x0000b2cb, 0x0001b2cb, 0x0002b2cb, 0x0003b2cb, 0x0000b6cb, 0x0001b6cb, 0x0002b6cb, 0x0003b6cb, 0x0000bacb, 0x0001bacb, 0x0002bacb, 0x0003bacb, 0x0000becb, 0x0001becb, 0x0002becb, 0x0003becb, 0x0000b2db, 0x0001b2db, 0x0002b2db, 0x0003b2db, 0x0000b6db, 0x0001b6db, 0x0002b6db, 0x0003b6db, 0x0000badb, 0x0001badb, 0x0002badb, 0x0003badb, 0x0000bedb, 0x0001bedb, 0x0002bedb, 0x0003bedb, 0x0000b2eb, 0x0001b2eb, 0x0002b2eb, 0x0003b2eb, 0x0000b6eb, 0x0001b6eb, 0x0002b6eb, 0x0003b6eb, 0x0000baeb, 0x0001baeb, 0x0002baeb, 0x0003baeb, 0x0000beeb, 0x0001beeb, 0x0002beeb, 0x0003beeb, 0x0000b2fb, 0x0001b2fb, 0x0002b2fb, 0x0003b2fb, 0x0000b6fb, 0x0001b6fb, 0x0002b6fb, 0x0003b6fb, 0x0000bafb, 0x0001bafb, 0x0002bafb, 0x0003bafb, 0x0000befb, 0x0001befb, 0x0002befb, 0x0003befb, 0x002cb2cb, 0x006cb2cb, 0x00acb2cb, 0x00ecb2cb, 0x002db2cb, 0x006db2cb, 0x00adb2cb, 0x00edb2cb, 0x002eb2cb, 0x006eb2cb, 0x00aeb2cb, 0x00eeb2cb, 0x002fb2cb, 0x006fb2cb, 0x00afb2cb, 0x00efb2cb, 0x002cb6cb, 0x006cb6cb, 0x00acb6cb, 0x00ecb6cb, 0x002db6cb, 0x006db6cb, 0x00adb6cb, 0x00edb6cb, 0x002eb6cb, 0x006eb6cb, 0x00aeb6cb, 0x00eeb6cb, 0x002fb6cb, 0x006fb6cb, 0x00afb6cb, 0x00efb6cb, 0x002cbacb, 0x006cbacb, 0x00acbacb, 0x00ecbacb, 0x002dbacb, 0x006dbacb, 0x00adbacb, 0x00edbacb, 0x002ebacb, 0x006ebacb, 0x00aebacb, 0x00eebacb, 0x002fbacb, 0x006fbacb, 0x00afbacb, 0x00efbacb, 0x002cbecb, 0x006cbecb, 0x00acbecb, 0x00ecbecb, 0x002dbecb, 0x006dbecb, 0x00adbecb, 0x00edbecb, 0x002ebecb, 0x006ebecb, 0x00aebecb, 0x00eebecb, 0x002fbecb, 0x006fbecb, 0x00afbecb, 0x00efbecb, 0x002cb2db, 0x006cb2db, 0x00acb2db, 0x00ecb2db, 0x002db2db, 0x006db2db, 0x00adb2db, 0x00edb2db, 0x002eb2db, 0x006eb2db, 0x00aeb2db, 0x00eeb2db, 0x002fb2db, 0x006fb2db, 0x00afb2db, 0x00efb2db, 0x002cb6db, 0x006cb6db, 0x00acb6db, 0x00ecb6db, 0x002db6db, 0x006db6db, 0x00adb6db, 0x00edb6db, 0x002eb6db, 0x006eb6db, 0x00aeb6db, 0x00eeb6db, 0x002fb6db, 0x006fb6db, 0x00afb6db, 0x00efb6db, 0x002cbadb, 0x006cbadb, 0x00acbadb, 0x00ecbadb, 0x002dbadb, 0x006dbadb, 0x00adbadb, 0x00edbadb, 0x002ebadb, 0x006ebadb, 0x00aebadb, 0x00eebadb, 0x002fbadb, 0x006fbadb, 0x00afbadb, 0x00efbadb, 0x002cbedb, 0x006cbedb, 0x00acbedb, 0x00ecbedb, 0x002dbedb, 0x006dbedb, 0x00adbedb, 0x00edbedb, 0x002ebedb, 0x006ebedb, 0x00aebedb, 0x00eebedb, 0x002fbedb, 0x006fbedb, 0x00afbedb, 0x00efbedb, 0x002cb2eb, 0x006cb2eb, 0x00acb2eb, 0x00ecb2eb, 0x002db2eb, 0x006db2eb, 0x00adb2eb, 0x00edb2eb, 0x002eb2eb, 0x006eb2eb, 0x00aeb2eb, 0x00eeb2eb, 0x002fb2eb, 0x006fb2eb, 0x00afb2eb, 0x00efb2eb, 0x002cb6eb, 0x006cb6eb, 0x00acb6eb, 0x00ecb6eb, 0x002db6eb, 0x006db6eb, 0x00adb6eb, 0x00edb6eb, 0x002eb6eb, 0x006eb6eb, 0x00aeb6eb, 0x00eeb6eb, 0x002fb6eb, 0x006fb6eb, 0x00afb6eb, 0x00efb6eb, 0x002cbaeb, 0x006cbaeb, 0x00acbaeb, 0x00ecbaeb, 0x002dbaeb, 0x006dbaeb, 0x00adbaeb, 0x00edbaeb, 0x002ebaeb, 0x006ebaeb, 0x00aebaeb, 0x00eebaeb, 0x002fbaeb, 0x006fbaeb, 0x00afbaeb, 0x00efbaeb, 0x002cbeeb, 0x006cbeeb, 0x00acbeeb, 0x00ecbeeb, 0x002dbeeb, 0x006dbeeb, 0x00adbeeb, 0x00edbeeb, 0x002ebeeb, 0x006ebeeb, 0x00aebeeb, 0x00eebeeb, 0x002fbeeb, 0x006fbeeb, 0x00afbeeb, 0x00efbeeb, 0x002cb2fb, 0x006cb2fb, 0x00acb2fb, 0x00ecb2fb, 0x002db2fb, 0x006db2fb, 0x00adb2fb, 0x00edb2fb, 0x002eb2fb, 0x006eb2fb, 0x00aeb2fb, 0x00eeb2fb, 0x002fb2fb, 0x006fb2fb, 0x00afb2fb, 0x00efb2fb, 0x002cb6fb, 0x006cb6fb, 0x00acb6fb, 0x00ecb6fb, 0x002db6fb, 0x006db6fb, 0x00adb6fb, 0x00edb6fb, 0x002eb6fb, 0x006eb6fb, 0x00aeb6fb, 0x00eeb6fb, 0x002fb6fb, 0x006fb6fb, 0x00afb6fb, 0x00efb6fb, 0x002cbafb, 0x006cbafb, 0x00acbafb, 0x00ecbafb, 0x002dbafb, 0x006dbafb, 0x00adbafb, 0x00edbafb, 0x002ebafb, 0x006ebafb, 0x00aebafb, 0x00eebafb, 0x002fbafb, 0x006fbafb, 0x00afbafb, 0x00efbafb, 0x002cbefb, 0x006cbefb, 0x00acbefb, 0x00ecbefb, 0x002dbefb, 0x006dbefb, 0x00adbefb, 0x00edbefb, 0x002ebefb, 0x006ebefb, 0x00aebefb, 0x00eebefb, 0x002fbefb, 0x006fbefb, 0x00afbefb, 0x00efbefb, 0x0b2cb2cb, 0x1b2cb2cb, 0x2b2cb2cb, 0x3b2cb2cb, 0x0b6cb2cb, 0x1b6cb2cb, 0x2b6cb2cb, 0x3b6cb2cb, 0x0bacb2cb, 0x1bacb2cb, 0x2bacb2cb, 0x3bacb2cb, 0x0becb2cb, 0x1becb2cb, 0x2becb2cb, 0x3becb2cb, 0x0b2db2cb, 0x1b2db2cb, 0x2b2db2cb, 0x3b2db2cb, 0x0b6db2cb, 0x1b6db2cb, 0x2b6db2cb, 0x3b6db2cb, 0x0badb2cb, 0x1badb2cb, 0x2badb2cb, 0x3badb2cb, 0x0bedb2cb, 0x1bedb2cb, 0x2bedb2cb, 0x3bedb2cb, 0x0b2eb2cb, 0x1b2eb2cb, 0x2b2eb2cb, 0x3b2eb2cb, 0x0b6eb2cb, 0x1b6eb2cb, 0x2b6eb2cb, 0x3b6eb2cb, 0x0baeb2cb, 0x1baeb2cb, 0x2baeb2cb, 0x3baeb2cb, 0x0beeb2cb, 0x1beeb2cb, 0x2beeb2cb, 0x3beeb2cb, 0x0b2fb2cb, 0x1b2fb2cb, 0x2b2fb2cb, 0x3b2fb2cb, 0x0b6fb2cb, 0x1b6fb2cb, 0x2b6fb2cb, 0x3b6fb2cb, 0x0bafb2cb, 0x1bafb2cb, 0x2bafb2cb, 0x3bafb2cb, 0x0befb2cb, 0x1befb2cb, 0x2befb2cb, 0x3befb2cb, 0x0b2cb6cb, 0x1b2cb6cb, 0x2b2cb6cb, 0x3b2cb6cb, 0x0b6cb6cb, 0x1b6cb6cb, 0x2b6cb6cb, 0x3b6cb6cb, 0x0bacb6cb, 0x1bacb6cb, 0x2bacb6cb, 0x3bacb6cb, 0x0becb6cb, 0x1becb6cb, 0x2becb6cb, 0x3becb6cb, 0x0b2db6cb, 0x1b2db6cb, 0x2b2db6cb, 0x3b2db6cb, 0x0b6db6cb, 0x1b6db6cb, 0x2b6db6cb, 0x3b6db6cb, 0x0badb6cb, 0x1badb6cb, 0x2badb6cb, 0x3badb6cb, 0x0bedb6cb, 0x1bedb6cb, 0x2bedb6cb, 0x3bedb6cb, 0x0b2eb6cb, 0x1b2eb6cb, 0x2b2eb6cb, 0x3b2eb6cb, 0x0b6eb6cb, 0x1b6eb6cb, 0x2b6eb6cb, 0x3b6eb6cb, 0x0baeb6cb, 0x1baeb6cb, 0x2baeb6cb, 0x3baeb6cb, 0x0beeb6cb, 0x1beeb6cb, 0x2beeb6cb, 0x3beeb6cb, 0x0b2fb6cb, 0x1b2fb6cb, 0x2b2fb6cb, 0x3b2fb6cb, 0x0b6fb6cb, 0x1b6fb6cb, 0x2b6fb6cb, 0x3b6fb6cb, 0x0bafb6cb, 0x1bafb6cb, 0x2bafb6cb, 0x3bafb6cb, 0x0befb6cb, 0x1befb6cb, 0x2befb6cb, 0x3befb6cb, 0x0b2cbacb, 0x1b2cbacb, 0x2b2cbacb, 0x3b2cbacb, 0x0b6cbacb, 0x1b6cbacb, 0x2b6cbacb, 0x3b6cbacb, 0x0bacbacb, 0x1bacbacb, 0x2bacbacb, 0x3bacbacb, 0x0becbacb, 0x1becbacb, 0x2becbacb, 0x3becbacb, 0x0b2dbacb, 0x1b2dbacb, 0x2b2dbacb, 0x3b2dbacb, 0x0b6dbacb, 0x1b6dbacb, 0x2b6dbacb, 0x3b6dbacb, 0x0badbacb, 0x1badbacb, 0x2badbacb, 0x3badbacb, 0x0bedbacb, 0x1bedbacb, 0x2bedbacb, 0x3bedbacb, 0x0b2ebacb, 0x1b2ebacb, 0x2b2ebacb, 0x3b2ebacb, 0x0b6ebacb, 0x1b6ebacb, 0x2b6ebacb, 0x3b6ebacb, 0x0baebacb, 0x1baebacb, 0x2baebacb, 0x3baebacb, 0x0beebacb, 0x1beebacb, 0x2beebacb, 0x3beebacb, 0x0b2fbacb, 0x1b2fbacb, 0x2b2fbacb, 0x3b2fbacb, 0x0b6fbacb, 0x1b6fbacb, 0x2b6fbacb, 0x3b6fbacb, 0x0bafbacb, 0x1bafbacb, 0x2bafbacb, 0x3bafbacb, 0x0befbacb, 0x1befbacb, 0x2befbacb, 0x3befbacb, 0x0b2cbecb, 0x1b2cbecb, 0x2b2cbecb, 0x3b2cbecb, 0x0b6cbecb, 0x1b6cbecb, 0x2b6cbecb, 0x3b6cbecb, 0x0bacbecb, 0x1bacbecb, 0x2bacbecb, 0x3bacbecb, 0x0becbecb, 0x1becbecb, 0x2becbecb, 0x3becbecb, 0x0b2dbecb, 0x1b2dbecb, 0x2b2dbecb, 0x3b2dbecb, 0x0b6dbecb, 0x1b6dbecb, 0x2b6dbecb, 0x3b6dbecb, 0x0badbecb, 0x1badbecb, 0x2badbecb, 0x3badbecb, 0x0bedbecb, 0x1bedbecb, 0x2bedbecb, 0x3bedbecb, 0x0b2ebecb, 0x1b2ebecb, 0x2b2ebecb, 0x3b2ebecb, 0x0b6ebecb, 0x1b6ebecb, 0x2b6ebecb, 0x3b6ebecb, 0x0baebecb, 0x1baebecb, 0x2baebecb, 0x3baebecb, 0x0beebecb, 0x1beebecb, 0x2beebecb, 0x3beebecb, 0x0b2fbecb, 0x1b2fbecb, 0x2b2fbecb, 0x3b2fbecb, 0x0b6fbecb, 0x1b6fbecb, 0x2b6fbecb, 0x3b6fbecb, 0x0bafbecb, 0x1bafbecb, 0x2bafbecb, 0x3bafbecb, 0x0befbecb, 0x1befbecb, 0x2befbecb, 0x3befbecb, 0x0b2cb2db, 0x1b2cb2db, 0x2b2cb2db, 0x3b2cb2db, 0x0b6cb2db, 0x1b6cb2db, 0x2b6cb2db, 0x3b6cb2db, 0x0bacb2db, 0x1bacb2db, 0x2bacb2db, 0x3bacb2db, 0x0becb2db, 0x1becb2db, 0x2becb2db, 0x3becb2db, 0x0b2db2db, 0x1b2db2db, 0x2b2db2db, 0x3b2db2db, 0x0b6db2db, 0x1b6db2db, 0x2b6db2db, 0x3b6db2db, 0x0badb2db, 0x1badb2db, 0x2badb2db, 0x3badb2db, 0x0bedb2db, 0x1bedb2db, 0x2bedb2db, 0x3bedb2db, 0x0b2eb2db, 0x1b2eb2db, 0x2b2eb2db, 0x3b2eb2db, 0x0b6eb2db, 0x1b6eb2db, 0x2b6eb2db, 0x3b6eb2db, 0x0baeb2db, 0x1baeb2db, 0x2baeb2db, 0x3baeb2db, 0x0beeb2db, 0x1beeb2db, 0x2beeb2db, 0x3beeb2db, 0x0b2fb2db, 0x1b2fb2db, 0x2b2fb2db, 0x3b2fb2db, 0x0b6fb2db, 0x1b6fb2db, 0x2b6fb2db, 0x3b6fb2db, 0x0bafb2db, 0x1bafb2db, 0x2bafb2db, 0x3bafb2db, 0x0befb2db, 0x1befb2db, 0x2befb2db, 0x3befb2db, 0x0b2cb6db, 0x1b2cb6db, 0x2b2cb6db, 0x3b2cb6db, 0x0b6cb6db, 0x1b6cb6db, 0x2b6cb6db, 0x3b6cb6db, 0x0bacb6db, 0x1bacb6db, 0x2bacb6db, 0x3bacb6db, 0x0becb6db, 0x1becb6db, 0x2becb6db, 0x3becb6db, 0x0b2db6db, 0x1b2db6db, 0x2b2db6db, 0x3b2db6db, 0x0b6db6db, 0x1b6db6db, 0x2b6db6db, 0x3b6db6db, 0x0badb6db, 0x1badb6db, 0x2badb6db, 0x3badb6db, 0x0bedb6db, 0x1bedb6db, 0x2bedb6db, 0x3bedb6db, 0x0b2eb6db, 0x1b2eb6db, 0x2b2eb6db, 0x3b2eb6db, 0x0b6eb6db, 0x1b6eb6db, 0x2b6eb6db, 0x3b6eb6db, 0x0baeb6db, 0x1baeb6db, 0x2baeb6db, 0x3baeb6db, }; private static readonly uint[] kNonZeroRepsDepth = { 6, 6, 6, 6, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, }; private static readonly uint[] kCmdHistoSeed = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, }; private static readonly byte[] kOmitLastNTransforms = { 0, 12, 27, 23, 42, 63, 56, 48, 59, 64, }; private static readonly uint[] kDistanceCacheIndex = { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, }; private static readonly int[] kDistanceCacheOffset = { 0, 0, 0, 0, -1, 1, -2, 2, -3, 3, -1, 1, -2, 2, -3, 3 }; private static readonly byte[] kStaticCommandCodeDepth = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, }; private static readonly ushort[] kStaticCommandCodeBits = { 0, 256, 128, 384, 64, 320, 192, 448, 32, 288, 160, 416, 96, 352, 224, 480, 16, 272, 144, 400, 80, 336, 208, 464, 48, 304, 176, 432, 112, 368, 240, 496, 8, 264, 136, 392, 72, 328, 200, 456, 40, 296, 168, 424, 104, 360, 232, 488, 24, 280, 152, 408, 88, 344, 216, 472, 56, 312, 184, 440, 120, 376, 248, 504, 4, 260, 132, 388, 68, 324, 196, 452, 36, 292, 164, 420, 100, 356, 228, 484, 20, 276, 148, 404, 84, 340, 212, 468, 52, 308, 180, 436, 116, 372, 244, 500, 12, 268, 140, 396, 76, 332, 204, 460, 44, 300, 172, 428, 108, 364, 236, 492, 28, 284, 156, 412, 92, 348, 220, 476, 60, 316, 188, 444, 124, 380, 252, 508, 2, 258, 130, 386, 66, 322, 194, 450, 34, 290, 162, 418, 98, 354, 226, 482, 18, 274, 146, 402, 82, 338, 210, 466, 50, 306, 178, 434, 114, 370, 242, 498, 10, 266, 138, 394, 74, 330, 202, 458, 42, 298, 170, 426, 106, 362, 234, 490, 26, 282, 154, 410, 90, 346, 218, 474, 58, 314, 186, 442, 122, 378, 250, 506, 6, 262, 134, 390, 70, 326, 198, 454, 38, 294, 166, 422, 102, 358, 230, 486, 22, 278, 150, 406, 86, 342, 214, 470, 54, 310, 182, 438, 118, 374, 246, 502, 14, 270, 142, 398, 78, 334, 206, 462, 46, 302, 174, 430, 110, 366, 238, 494, 30, 286, 158, 414, 94, 350, 222, 478, 62, 318, 190, 446, 126, 382, 254, 510, 1, 257, 129, 385, 65, 321, 193, 449, 33, 289, 161, 417, 97, 353, 225, 481, 17, 273, 145, 401, 81, 337, 209, 465, 49, 305, 177, 433, 113, 369, 241, 497, 9, 265, 137, 393, 73, 329, 201, 457, 41, 297, 169, 425, 105, 361, 233, 489, 25, 281, 153, 409, 89, 345, 217, 473, 57, 313, 185, 441, 121, 377, 249, 505, 5, 261, 133, 389, 69, 325, 197, 453, 37, 293, 165, 421, 101, 357, 229, 485, 21, 277, 149, 405, 85, 341, 213, 469, 53, 309, 181, 437, 117, 373, 245, 501, 13, 269, 141, 397, 77, 333, 205, 461, 45, 301, 173, 429, 109, 365, 237, 493, 29, 285, 157, 413, 93, 349, 221, 477, 61, 317, 189, 445, 125, 381, 253, 509, 3, 259, 131, 387, 67, 323, 195, 451, 35, 291, 163, 419, 99, 355, 227, 483, 19, 275, 147, 403, 83, 339, 211, 467, 51, 307, 179, 435, 115, 371, 243, 499, 11, 267, 139, 395, 75, 331, 203, 459, 43, 299, 171, 427, 107, 363, 235, 491, 27, 283, 155, 411, 91, 347, 219, 475, 59, 315, 187, 443, 123, 379, 251, 507, 7, 1031, 519, 1543, 263, 1287, 775, 1799, 135, 1159, 647, 1671, 391, 1415, 903, 1927, 71, 1095, 583, 1607, 327, 1351, 839, 1863, 199, 1223, 711, 1735, 455, 1479, 967, 1991, 39, 1063, 551, 1575, 295, 1319, 807, 1831, 167, 1191, 679, 1703, 423, 1447, 935, 1959, 103, 1127, 615, 1639, 359, 1383, 871, 1895, 231, 1255, 743, 1767, 487, 1511, 999, 2023, 23, 1047, 535, 1559, 279, 1303, 791, 1815, 151, 1175, 663, 1687, 407, 1431, 919, 1943, 87, 1111, 599, 1623, 343, 1367, 855, 1879, 215, 1239, 727, 1751, 471, 1495, 983, 2007, 55, 1079, 567, 1591, 311, 1335, 823, 1847, 183, 1207, 695, 1719, 439, 1463, 951, 1975, 119, 1143, 631, 1655, 375, 1399, 887, 1911, 247, 1271, 759, 1783, 503, 1527, 1015, 2039, 15, 1039, 527, 1551, 271, 1295, 783, 1807, 143, 1167, 655, 1679, 399, 1423, 911, 1935, 79, 1103, 591, 1615, 335, 1359, 847, 1871, 207, 1231, 719, 1743, 463, 1487, 975, 1999, 47, 1071, 559, 1583, 303, 1327, 815, 1839, 175, 1199, 687, 1711, 431, 1455, 943, 1967, 111, 1135, 623, 1647, 367, 1391, 879, 1903, 239, 1263, 751, 1775, 495, 1519, 1007, 2031, 31, 1055, 543, 1567, 287, 1311, 799, 1823, 159, 1183, 671, 1695, 415, 1439, 927, 1951, 95, 1119, 607, 1631, 351, 1375, 863, 1887, 223, 1247, 735, 1759, 479, 1503, 991, 2015, 63, 1087, 575, 1599, 319, 1343, 831, 1855, 191, 1215, 703, 1727, 447, 1471, 959, 1983, 127, 1151, 639, 1663, 383, 1407, 895, 1919, 255, 1279, 767, 1791, 511, 1535, 1023, 2047, }; private static readonly byte[] kStaticDistanceCodeDepth = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, }; private static readonly ushort[] kStaticDistanceCodeBits = { 0, 32, 16, 48, 8, 40, 24, 56, 4, 36, 20, 52, 12, 44, 28, 60, 2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 62, 1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 63, }; private static readonly uint[] kStaticContextMapComplexUTF8 = { 11, 11, 12, 12, /* 0 special */ 0, 0, 0, 0, /* 4 lf */ 1, 1, 9, 9, /* 8 space */ 2, 2, 2, 2, /* !, first after space/lf and after something else. */ 1, 1, 1, 1, /* " */ 8, 3, 3, 3, /* % */ 1, 1, 1, 1, /* ({[ */ 2, 2, 2, 2, /* }]) */ 8, 4, 4, 4, /* :; */ 8, 7, 4, 4, /* . */ 8, 0, 0, 0, /* > */ 3, 3, 3, 3, /* [0..9] */ 5, 5, 10, 5, /* [A-Z] */ 5, 5, 10, 5, 6, 6, 6, 6, /* [a-z] */ 6, 6, 6, 6, }; private static readonly uint[] kStaticContextMapContinuation = { 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; private static readonly uint[] kStaticContextMapSimpleUTF8 = { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; } }
using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; using FSharpUtils.Newtonsoft; using Tweek.Engine; using Tweek.Engine.Context; using Tweek.Engine.Core.Context; using Tweek.Engine.DataTypes; using static LanguageExt.Prelude; namespace Tweek.ApiService.Security { public delegate bool CheckReadConfigurationAccess(ClaimsPrincipal identity, string path, ICollection<Identity> tweekIdentities); public delegate bool CheckWriteContextAccess(ClaimsPrincipal identity, Identity tweekIdentity); public static class Authorization { public static CheckReadConfigurationAccess CreateReadConfigurationAccessChecker(ITweek tweek, TweekIdentityProvider identityProvider) { return (identity, path, tweekIdentities) => { if (path == "@tweek/_" || path.StartsWith("@tweek/auth")) return false; return tweekIdentities .Select(x => x.ToAuthIdentity(identityProvider)) .Distinct() .DefaultIfEmpty(Identity.GlobalIdentity) .All(tweekIdentity => CheckAuthenticationForKey(tweek, "read_configuration", identity, tweekIdentity)); }; } public static bool CheckAuthenticationForKey(ITweek tweek, string permissionType, ClaimsPrincipal identity, Identity tweekIdentity) { var identityType = tweekIdentity.Type; var key = $"@tweek/auth/{identityType}/{permissionType}"; if (identity.IsTweekIdentity()) { return true; } var authValues = tweek.Calculate(key, new HashSet<Identity>(), type => type == "token" ? (GetContextValue) (q => Optional(identity.FindFirst(q)).Map(x => x.Value).Map(JsonValue.NewString)) : _ => None); if (!authValues.TryGetValue(key, out var authValue)) { return true; } if (authValue.Exception != null) { return false; } return match(authValue.Value.AsString(), with("allow", _ => true), with("deny", _ => false), claim => Optional(identity.FindFirst(claim)) .Match(c => c.Value.Equals(tweekIdentity.Id, StringComparison.OrdinalIgnoreCase), () => false)); } public static CheckWriteContextAccess CreateWriteContextAccessChecker(ITweek tweek, TweekIdentityProvider identityProvider) { return (identity, tweekIdentity) => CheckAuthenticationForKey(tweek, "write_context", identity, tweekIdentity.ToAuthIdentity(identityProvider)); } } }
/** * PathConfig V:0.0.1 * * 模块中路径管理可以继承此接口 * 用于在框架配置界面配置各种路径操作 * public 字段可以显示在窗口中 * privite字段不显示 * */ namespace SettingKit.Editor { public interface IPathConfig { string GetModuleName(); } }
using System.Threading.Tasks; using Discord.Commands; using Elvet.Core.Commands; using $safeprojectname$.Data; namespace $safeprojectname$ { internal class $pluginname$Module : ElvetModuleBase { private readonly $pluginname$Config _config; private readonly $pluginname$DbContext _dbContext; public $pluginname$Module($pluginname$Config config, $pluginname$DbContext dbContext) { _config = config; _dbContext = dbContext; } [Command("$pluginname$")] public async Task $pluginname$() { await MarkSuccessful(); } } }
using Famoser.ETHZMensa.Business.Services; using Famoser.ETHZMensa.View.Services; using GalaSoft.MvvmLight; namespace Famoser.ETHZMensa.View.ViewModel { public class ProgressViewModel : ViewModelBase, IProgressService { private IInteractionService _interactionService; public ProgressViewModel(IInteractionService interactionService) { _interactionService = interactionService; if (IsInDesignMode) { ShowProgress = true; ActiveProgress = 8; MaxProgress = 20; } } public void InitializeProgressBar(int total) { _interactionService.CheckBeginInvokeOnUi(() => { ShowProgress = true; ActiveProgress = 0; MaxProgress = total; }); } public void IncrementProgress() { _interactionService.CheckBeginInvokeOnUi(() => { ActiveProgress++; }); } public void HideProgress() { _interactionService.CheckBeginInvokeOnUi(() => { ShowProgress = false; }); } private bool _showProgress; public bool ShowProgress { get { return _showProgress; } set { Set(ref _showProgress, value); } } private int _maxProgress; public int MaxProgress { get { return _maxProgress; } set { Set(ref _maxProgress, value); } } private int _activeProgress; public int ActiveProgress { get { return _activeProgress; } set { Set(ref _activeProgress, value); } } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; namespace RootMotion.Dynamics { /// <summary> /// Adds force and torque to a Rigidbody to make it follow a target Transform. /// </summary> public class RigidbodyController : MonoBehaviour { public Transform target; [Range(0f, 1f)] public float weight = 1f; public bool useTargetVelocity = true; private Rigidbody r; private Vector3 lastTargetPos; private Quaternion lastTargetRot = Quaternion.identity; /// <summary> /// Call this after target has been teleported /// </summary> public void OnTargetTeleported() { lastTargetPos = target.position; lastTargetRot = target.rotation; } private void Start() { r = GetComponent<Rigidbody>(); OnTargetTeleported(); } private void FixedUpdate() { Vector3 targetVelocity = Vector3.zero; Vector3 targetAngularVelocity = Vector3.zero; // Calculate target velocity and angular velocity if (useTargetVelocity) { targetVelocity = (target.position - lastTargetPos) / Time.deltaTime; targetAngularVelocity = PhysXTools.GetAngularVelocity(lastTargetRot, target.rotation, Time.deltaTime); } lastTargetPos = target.position; lastTargetRot = target.rotation; // Force Vector3 force = PhysXTools.GetLinearAcceleration(r.position, target.position); force += targetVelocity; force -= r.velocity; if (r.useGravity) force -= Physics.gravity * Time.deltaTime; force *= weight; r.AddForce(force, ForceMode.VelocityChange); // Torque Vector3 torque = PhysXTools.GetAngularAcceleration(r.rotation, target.rotation); torque += targetAngularVelocity; torque -= r.angularVelocity; torque *= weight; r.AddTorque(torque, ForceMode.VelocityChange); } } }
using Microsoft.Phone.Controls; using System.Windows; namespace PhoneToolkitSample.Samples { public partial class PhoneSliderSample : BasePage { public PhoneSliderSample() { InitializeComponent(); TextSizeSlider.ValueChanged += TextSizeSlider_ValueChanged; UpdateSampleText(); } private void TextSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { UpdateSampleText(); } private void UpdateSampleText() { SampleTextBlock.Style = (Style)Resources["TextSize" + (int)TextSizeSlider.Value]; } } }
using USchedule.Core.Entities.Implementations; using USchedule.Persistence.Database; namespace USchedule.Persistence.Repositories { public class InstituteRepository: Repository<Institute>, IInstituteRepository { public InstituteRepository(DataContext context) : base(context) { } } }
using Taskington.Base.Steps; namespace Taskington.Gui.Extension { public interface IEditStepViewModel { public string? Icon { get; set; } public string? Caption { get; set; } public string? StepType { get; set; } public string? SubType { get; set; } PlanStep ConvertToStep(); } }
using System; using System.Threading.Tasks; using System.Collections.Generic; using MongoDB.Driver; using FaccSolutions.Data.Abstractions.Models; using FaccSolutions.Data.Abstractions.Repositories; namespace FaccSolutions.Data.Mongo.Abstractions.Repositories { public interface IMongoReadRepository<TModel, TKey> : IReadRepository<TModel, TKey> where TModel : Model<TKey> where TKey : new() { Task<IEnumerable<TModel>> FindManyAsync(FilterDefinition<TModel> predicate); Task<IEnumerable<TModel>> FindManyAsync(FilterDefinition<TModel> predicate, int page, int pageSize); Task<TModel> FindOneAsync(FilterDefinition<TModel> predicate); Task<bool> ExistsAsync(FilterDefinition<TModel> predicate); Task<long> CountAsync(FilterDefinition<TModel> predicate); Task<long> CountAsync(FilterDefinition<TModel> predicate, int page, int pageSize); } public interface IMongoReadRepository<TModel> : IMongoReadRepository<TModel, Guid> where TModel : Model { } }
namespace basketball_teams.domain { public class Entity { public Id Id { get; set; } public Entity(Id id) { Id = id; } } }
using System; namespace RestDB.Interfaces { [Flags] public enum CompareOperation { /// <summary> /// The index supports testing for null values /// </summary> IsNull = 0x1, /// <summary> /// The index supports equality comparing /// </summary> Equal = 0x2, /// <summary> /// The index supports less than queries /// </summary> Less = 0x4, /// <summary> /// The index supports greater than queries /// </summary> Greater = 0x8, /// <summary> /// The index supports greater than or equals queries /// </summary> NotLess = 0x10, /// <summary> /// The index supports less than or equals queries /// </summary> NotGreater = 0x20, /// <summary> /// The index supports similar value queries /// </summary> Similar = 0x40, /// <summary> /// The index supports subset queries /// </summary> Contains = 0x80, /// <summary> /// The index supports within queries /// </summary> Range = 0x100, /// <summary> /// Selects all comparison operations /// </summary> All = 0x1ff, /// <summary> /// Selects comparison operations that are typically available /// for numeric fields /// </summary> Number = 0x13f, /// <summary> /// Selects comparison operations that are typically available /// for text fields /// </summary> Text = 0xff } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using FlatRedBall; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; namespace Anfloga.Rendering { public class BloomExtractRenderer : IEffectsRenderer { public int Height { get; set; } public int Width { get; set; } public float Threshold { get; set; } = 0.7f; SpriteBatch spriteBatch; bool initialized = false; Effect effect; GraphicsDevice device; public void Initialize(GraphicsDevice device, Camera camera) { Width = device.PresentationParameters.BackBufferWidth; Height = device.PresentationParameters.BackBufferHeight; this.device = device; spriteBatch = new SpriteBatch(this.device); effect = FlatRedBallServices.Load<Effect>(@"Content\Shaders\BloomExtract"); effect.Parameters["BloomThreshold"].SetValue(Threshold); initialized = true; } public void Draw(RenderTarget2D src, RenderTarget2D dest = null) { if(!initialized) { throw new Exception("Draw called before effect initialized!"); } int destWidth = dest != null ? dest.Width : Width; int destHeight = dest != null ? dest.Height : Height; this.device.SetRenderTarget(dest); spriteBatch.Begin(0, BlendState.Opaque, null, null, null, effect); spriteBatch.Draw(src, new Rectangle(0, 0, destWidth, destHeight), Color.White); spriteBatch.End(); } } }
using System.Collections.Generic; using Todo.Web.Data; using Todo.Web.GraphQL.Common; namespace Todo.Web.GraphQL.Books { public class BookPayloadBase : Payload { protected BookPayloadBase(Book book) { Book = book; } protected BookPayloadBase(IReadOnlyList<UserError> errors) : base(errors) { } public Book? Book { get; } } }
using System; using DSIS.Core.System; namespace DSIS.Function.Predefined.Logistics { public class LogisticFunction : Function<double>, IFunction<double>, IDetDiffFunction<double> { private readonly double myA; public LogisticFunction(double a) : base(1) { myA = a; } public void Evaluate() { Output[0] = myA * Input[0] * (1 - Input[0]); } public double Evaluate(double[] data) { return myA*(1 - 2*data[0]); } } }
using System; namespace UnityEditor.ShaderGraph { public struct MatrixNames { public const string Model = "UNITY_MATRIX_M"; public const string ModelInverse = "UNITY_MATRIX_I_M"; public const string View = "UNITY_MATRIX_V"; public const string ViewInverse = "UNITY_MATRIX_I_V"; public const string Projection = "UNITY_MATRIX_P"; public const string ProjectionInverse = "UNITY_MATRIX_I_P"; public const string ViewProjection = "UNITY_MATRIX_VP"; public const string ViewProjectionInverse = "UNITY_MATRIX_I_VP"; } }
// CivOne // // To the extent possible under law, the person who associated CC0 with // CivOne has waived all copyright and related or neighboring rights // to CivOne. // // You should have received a copy of the CC0 legalcode along with this // work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. using CivOne.Enums; using CivOne.Leaders; namespace CivOne.Civilizations { internal class German : BaseCivilization<Frederick> { public German() : base(Civilization.Germans, "German", "Germans", "fred") { StartX = 38; StartY = 15; CityNames = new string[] { "Berlin", "Leipzig", "Hamburg", "Bremen", "Frankfurt", "Bonn", "Nuremberg", "Cologne", "Hannover", "Munich", "Stuttgart", "Heidelberg", "Salzburg", "Konigsberg", "Dortmond", "Brandenburg" }; } } }
@using Microsoft.AspNetCore.Identity @using EzPay.Model @using EzPay.WebApp @using EzPay.WebApp.Models @using EzPay.WebApp.Controllers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Net; using System.Net.Sockets; using UnityEngine.Networking; using UnityEngine.Networking.NetworkSystem; using UnityEngine; using UnityEngine.UI; public class client : MonoBehaviour { private byte reliableChannel; private const int MAX_USERS = 2; private const int SERVER_PORT = 25000; private const int WEBSERVER_PORT = 26000; private const string SERVER_IP = "127.0.0.1"; private int hostId; private bool isStarted = false; #region Monobehavior public void Start() { DontDestroyOnLoad(gameObject); Init(); } #endregion public void Init() { NetworkTransport.Init(); ConnectionConfig cc = new ConnectionConfig(); reliableChannel = cc.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(cc, MAX_USERS); // Client-only code hostId = NetworkTransport.AddHost(topology, 0); Debug.Log(string.Format("Opening connection on port {0} and webport {1}", SERVER_PORT, WEBSERVER_PORT)); isStarted = true; } public void Shoutdown() { isStarted = false; NetworkTransport.Shutdown(); } }
using System.Runtime.CompilerServices; namespace HardDev.Awaiter { /// <inheritdoc /> /// <summary> /// Basic template for Awaiters. /// </summary> public interface IAwaiter : INotifyCompletion { IAwaiter GetAwaiter(); bool IsCompleted { get; } void GetResult(); } /// <summary> /// Basic template for Awaiters. /// </summary> /// <typeparam name="T">Type of result to return</typeparam> public interface IAwaiter<out T> : INotifyCompletion { bool IsCompleted { get; } IAwaiter<T> GetAwaiter(); T GetResult(); } }
using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; using System.Data; namespace SQLDocGenerator { public class IndexColumnsHelper { private static DataTable indexColumns = new DataTable("IndexColumns"); public static DataTable IndexColumns { get { return indexColumns; } } public static void GetIndexColumns() { indexColumns = Utility.DBConnection.GetSchema("IndexColumns"); //Utility.PrintDatatable(indexColumns); } public static void WriteIndexColumns() { Utility.WriteXML(indexColumns, indexColumns.TableName + ".xml"); //Utility.PrintDatatable(indexColumns); } } }
namespace Leptonica { /// <summary> /// Flags for plotting on a Pix /// </summary> public enum FlagsForPlottingOnAPix { /// <summary> /// Plot horizontally at top /// </summary> L_PLOT_AT_TOP = 1, /// <summary> /// Plot horizontally at middle /// </summary> L_PLOT_AT_MID_HORIZ = 2, /// <summary> /// Plot horizontally at bottom /// </summary> L_PLOT_AT_BOT = 3, /// <summary> /// Plot vertically at left /// </summary> L_PLOT_AT_LEFT = 4, /// <summary> /// Plot vertically at middle /// </summary> L_PLOT_AT_MID_VERT = 5, /// <summary> /// Plot vertically at right /// </summary> L_PLOT_AT_RIGHT = 6 } }
using System.Threading.Tasks; namespace Dime.Scheduler.Sdk { public interface ICrudEndpoint<in T> : IEndpoint where T : class { Task Create(T requestParameters); Task Update(T requestParameters); Task Delete(T requestParameters); } }
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace SubtitleBroom { public class SubtitleData : INotifyPropertyChanged { public SubtitleData() { AvailableVideos = new ObservableCollection<string>(); } public bool IsInitialized { get; set; } private bool isActive; public bool IsActive { get { return isActive; } set { if (value == isActive) return; isActive = value; OnPropertyChanged(); } } public FileInfo Subtitle { get; set; } public ObservableCollection<string> AvailableVideos { get; private set; } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } } }
using System; namespace Terraria.Net { public enum AddressType { Tcp, Steam } }
namespace Semantity { public static class AccelerationDoubleExtensions { public static Acceleration MetersPerSecondSquared(this double value) { return new Acceleration(value, MeterPerSecondSquared.Instance); } } }
using System; using System.Linq; using System.Threading.Tasks; using Xunit; namespace Atlassian.Jira.Test.Integration { public class IssueCreateTest : BaseIntegrationTest { [Fact] public async Task CreateIssueWithIssueTypesPerProject() { var issue = new Issue(_jira, "TST") { Type = "Bug", Summary = "Test Summary " + _random.Next(int.MaxValue), Assignee = "admin" }; issue.Type.SearchByProjectOnly = true; var newIssue = await issue.SaveChangesAsync(); Assert.Equal("Bug", newIssue.Type.Name); } [Fact] public async Task CreateIssueWithOriginalEstimate() { var fields = new CreateIssueFields("TST") { TimeTrackingData = new IssueTimeTrackingData("1d") }; var issue = new Issue(_jira, fields) { Type = "1", Summary = "Test Summary " + _random.Next(int.MaxValue), Assignee = "admin" }; var newIssue = await issue.SaveChangesAsync(); Assert.Equal("1d", newIssue.TimeTrackingData.OriginalEstimate); } [Fact] public async Task CreateIssueAsync() { var summaryValue = "Test Summary " + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; var newIssue = await issue.SaveChangesAsync(); Assert.Equal(summaryValue, newIssue.Summary); Assert.Equal("TST", newIssue.Project); Assert.Equal("1", newIssue.Type.Id); // Create a subtask async. var subTask = new Issue(_jira, "TST", newIssue.Key.Value) { Type = "5", Summary = "My Subtask", Assignee = "admin" }; var newSubTask = await subTask.SaveChangesAsync(); Assert.Equal(newIssue.Key.Value, newSubTask.ParentIssueKey); } [Fact] public void CreateAndQueryIssueWithMinimumFieldsSet() { var summaryValue = "Test Summary " + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; issue.SaveChanges(); var issues = (from i in _jira.Issues.Queryable where i.Key == issue.Key select i).ToArray(); Assert.Single(issues); Assert.Equal(summaryValue, issues[0].Summary); Assert.Equal("TST", issues[0].Project); Assert.Equal("1", issues[0].Type.Id); } [Fact] public void CreateAndQueryIssueWithAllFieldsSet() { var summaryValue = "Test Summary " + _random.Next(int.MaxValue); var expectedDueDate = new DateTime(2011, 12, 12); var issue = _jira.CreateIssue("TST"); issue.AffectsVersions.Add("1.0"); issue.Assignee = "admin"; issue.Components.Add("Server"); issue["Custom Text Field"] = "Test Value"; // custom field issue.Description = "Test Description"; issue.DueDate = expectedDueDate; issue.Environment = "Test Environment"; issue.FixVersions.Add("2.0"); issue.Priority = "Major"; issue.Reporter = "admin"; issue.Summary = summaryValue; issue.Type = "1"; issue.Labels.Add("testLabel"); issue.SaveChanges(); var queriedIssue = (from i in _jira.Issues.Queryable where i.Key == issue.Key select i).ToArray().First(); Assert.Equal(summaryValue, queriedIssue.Summary); Assert.NotNull(queriedIssue.JiraIdentifier); Assert.Equal(expectedDueDate, queriedIssue.DueDate.Value); Assert.NotNull(queriedIssue.Priority.IconUrl); Assert.NotNull(queriedIssue.Type.IconUrl); Assert.NotNull(queriedIssue.Status.IconUrl); Assert.Contains("testLabel", queriedIssue.Labels); } [Fact] public void CreateAndQueryIssueWithSubTask() { var parentTask = _jira.CreateIssue("TST"); parentTask.Type = "1"; parentTask.Summary = "Test issue with SubTask" + _random.Next(int.MaxValue); parentTask.SaveChanges(); var subTask = _jira.CreateIssue("TST", parentTask.Key.Value); subTask.Type = "5"; // SubTask issue type. subTask.Summary = "Test SubTask" + _random.Next(int.MaxValue); subTask.SaveChanges(); Assert.False(parentTask.Type.IsSubTask); Assert.True(subTask.Type.IsSubTask); Assert.Equal(parentTask.Key.Value, subTask.ParentIssueKey); // query the subtask again to make sure it loads everything from server. subTask = _jira.Issues.GetIssueAsync(subTask.Key.Value).Result; Assert.False(parentTask.Type.IsSubTask); Assert.True(subTask.Type.IsSubTask); Assert.Equal(parentTask.Key.Value, subTask.ParentIssueKey); } [Fact] public void CreateAndQueryIssueWithVersions() { var summaryValue = "Test issue with versions (Created)" + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; issue.AffectsVersions.Add("1.0"); issue.AffectsVersions.Add("2.0"); issue.FixVersions.Add("3.0"); issue.FixVersions.Add("2.0"); issue.SaveChanges(); var newIssue = (from i in _jira.Issues.Queryable where i.AffectsVersions == "1.0" && i.AffectsVersions == "2.0" && i.FixVersions == "2.0" && i.FixVersions == "3.0" select i).First(); Assert.Equal(2, newIssue.AffectsVersions.Count); Assert.Contains(newIssue.AffectsVersions, v => v.Name == "1.0"); Assert.Contains(newIssue.AffectsVersions, v => v.Name == "2.0"); Assert.Equal(2, newIssue.FixVersions.Count); Assert.Contains(newIssue.FixVersions, v => v.Name == "2.0"); Assert.Contains(newIssue.FixVersions, v => v.Name == "3.0"); } [Fact] public void CreateAndQueryIssueWithComponents() { var summaryValue = "Test issue with components (Created)" + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; issue.Components.Add("Server"); issue.Components.Add("Client"); issue.SaveChanges(); var newIssue = (from i in _jira.Issues.Queryable where i.Summary == summaryValue && i.Components == "Server" && i.Components == "Client" select i).First(); Assert.Equal(2, newIssue.Components.Count); Assert.Contains(newIssue.Components, c => c.Name == "Server"); Assert.Contains(newIssue.Components, c => c.Name == "Client"); } [Fact] public void CreateAndQueryIssueWithCustomField() { var summaryValue = "Test issue with custom field (Created)" + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; issue["Custom Text Field"] = "My new value"; issue["Custom User Field"] = "admin"; issue.SaveChanges(); var newIssue = (from i in _jira.Issues.Queryable where i.Summary == summaryValue && i["Custom Text Field"] == "My new value" select i).First(); Assert.Equal("My new value", newIssue["Custom Text Field"]); Assert.Equal("admin", newIssue["Custom User Field"]); } [Fact] public void CreateIssueAsSubtask() { var summaryValue = "Test issue as subtask " + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST", "TST-1") { Type = "5", //subtask Summary = summaryValue, Assignee = "admin" }; issue.SaveChanges(); var subtasks = _jira.Issues.GetIssuesFromJqlAsync("project = TST and parent = TST-1").Result; Assert.True(subtasks.Any(s => s.Summary.Equals(summaryValue)), String.Format("'{0}' was not found as a sub-task of TST-1", summaryValue)); } } }
using System.Reflection; using Orleans; using Wordleans.Api.Grains; namespace Wordleans.Kernel.Game; public class WordDictionary : Grain, IWordDictionary { private DictionaryData? _data; public override async Task OnActivateAsync() { var id = this.GetPrimaryKeyString(); var root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var fname = Path.Combine(root!, $"{id}.txt"); var words = await File.ReadAllLinesAsync(fname); this._data = new DictionaryData(words); } public Task<bool> IsValidWord(string text) { var found = this._data!.ContainsWord(text); return Task.FromResult(found); } public Task<string> GetRandomWord(int seed) { return Task.FromResult(_data!.GetWordBySeed(seed)); } public Task<DictionaryData> GetFullDictionary() { return Task.FromResult(_data!); } }
using System; using System.Threading; namespace Futronic.Scanners.FS26X80 { public class CardReader : IDisposable { private const int CardPresenseCheckIntervalInMs = 50; private IntPtr handle; private Timer cardDetectionTimer; public event EventHandler<CardDetectedEventArgs> CardDetected; public event EventHandler<EventArgs> CardRemoved; public CardReader(IntPtr handle) { this.handle = handle; this.cardDetectionTimer = new Timer(this.CardDetectionCallback, null, Timeout.Infinite, Timeout.Infinite); } public void StartCardDetection() { this.cardDetectionTimer.Change(CardPresenseCheckIntervalInMs, CardPresenseCheckIntervalInMs); } public bool IsCardPresent { get; private set; } public ulong CardSerialNumber { get; private set; } private void CardDetectionCallback(object state) { LibMifareApi.ftrMFStartSequence(handle); var cardTypeBytes = new byte[1]; var serialNumberBytes = new byte[8]; LibMifareApi.ftrMFActivateIdle8bSN(this.handle, cardTypeBytes, serialNumberBytes); LibMifareApi.ftrMFEndSequence(this.handle); var cardType = (CardType)cardTypeBytes[0]; var isCardPresentNow = cardType != CardType.Invalid; if (isCardPresentNow != IsCardPresent) { if (isCardPresentNow) { var serialNumber = BitConverter.ToUInt64(serialNumberBytes, 0); this.CardSerialNumber = serialNumber; this.CardType = cardType; this.IsCardPresent = true; this.OnCardDetected(new CardDetectedEventArgs { SerialNumber = serialNumber, Type = cardType }); } else { this.IsCardPresent = false; this.CardType = CardType.Invalid; this.CardSerialNumber = 0; this.OnCardRemoved(); } } } public CardType CardType { get; private set; } public void Dispose() { this.cardDetectionTimer.Change(Timeout.Infinite, Timeout.Infinite); this.cardDetectionTimer.Dispose(); LibMifareApi.ftrMFCloseDevice(this.handle); } protected virtual void OnCardDetected(CardDetectedEventArgs e) { CardDetected?.Invoke(this, e); } protected virtual void OnCardRemoved() { CardRemoved?.Invoke(this, EventArgs.Empty); } } public class CardDetectedEventArgs : EventArgs { public ulong SerialNumber { get; set; } public CardType Type { get; set; } } }
using Prism.Events; using XFMoviesDemo.Core.Models; namespace XFMoviesDemo.Core.Messages { public class DetailEvent : PubSubEvent<MovieModel> { } }
using System; using System.Collections.Generic; using System.Linq; using Mechanical.MagicBag; using NUnit.Framework; namespace Mechanical.Tests.MagicBag { [TestFixture] public class GeneratorTests { private static readonly Mapping[] SourceMappings = new Mapping[] { Map<int>.To(() => 5).AsTransient(), Map<int>.To(() => 6).AsTransient(), Map<float>.To(() => 3.14f).AsTransient(), Map<int>.To(() => 7).AsTransient(), }; [Test] public void FuncTests() { var mappings = MappingGenerators.Func.Generate(SourceMappings); Assert.AreEqual(4, mappings.Length); var m = mappings[0]; Assert.AreEqual(m.From, typeof(Func<int>)); Assert.IsInstanceOf<Func<int>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(5, ((Func<int>)m.Get(MagicBagTests.EmptyBag))()); m = mappings[1]; Assert.AreEqual(m.From, typeof(Func<int>)); Assert.IsInstanceOf<Func<int>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(6, ((Func<int>)m.Get(MagicBagTests.EmptyBag))()); m = mappings[2]; Assert.AreEqual(m.From, typeof(Func<float>)); Assert.IsInstanceOf<Func<float>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(3.14f, ((Func<float>)m.Get(MagicBagTests.EmptyBag))()); m = mappings[3]; Assert.AreEqual(m.From, typeof(Func<int>)); Assert.IsInstanceOf<Func<int>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(7, ((Func<int>)m.Get(MagicBagTests.EmptyBag))()); } [Test] public void LazyTests() { var mappings = MappingGenerators.Lazy.Generate(SourceMappings); Assert.AreEqual(4, mappings.Length); var m = mappings[0]; Assert.AreEqual(m.From, typeof(Lazy<int>)); Assert.IsInstanceOf<Lazy<int>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(5, ((Lazy<int>)m.Get(MagicBagTests.EmptyBag)).Value); m = mappings[1]; Assert.AreEqual(m.From, typeof(Lazy<int>)); Assert.IsInstanceOf<Lazy<int>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(6, ((Lazy<int>)m.Get(MagicBagTests.EmptyBag)).Value); m = mappings[2]; Assert.AreEqual(m.From, typeof(Lazy<float>)); Assert.IsInstanceOf<Lazy<float>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(3.14f, ((Lazy<float>)m.Get(MagicBagTests.EmptyBag)).Value); m = mappings[3]; Assert.AreEqual(m.From, typeof(Lazy<int>)); Assert.IsInstanceOf<Lazy<int>>(m.Get(MagicBagTests.EmptyBag)); Assert.AreEqual(7, ((Lazy<int>)m.Get(MagicBagTests.EmptyBag)).Value); } [Test] public void IEnumerableTests() { var mappings = MappingGenerators.IEnumerable.Generate(SourceMappings); Assert.AreEqual(2, mappings.Length); var m = mappings[0]; Assert.AreEqual(m.From, typeof(IEnumerable<int>)); Assert.IsInstanceOf<IEnumerable<int>>(m.Get(MagicBagTests.EmptyBag)); var arr0 = ((IEnumerable<int>)m.Get(MagicBagTests.EmptyBag)).ToArray(); Assert.AreEqual(3, arr0.Length); Assert.AreEqual(5, arr0[0]); Assert.AreEqual(6, arr0[1]); Assert.AreEqual(7, arr0[2]); m = mappings[1]; Assert.AreEqual(m.From, typeof(IEnumerable<float>)); Assert.IsInstanceOf<IEnumerable<float>>(m.Get(MagicBagTests.EmptyBag)); var arr1 = ((IEnumerable<float>)m.Get(MagicBagTests.EmptyBag)).ToArray(); Assert.AreEqual(1, arr1.Length); Assert.AreEqual(3.14f, arr1[0]); } [Test] public void IListTests() { var mappings = MappingGenerators.IList.Generate(SourceMappings); Assert.AreEqual(2, mappings.Length); var m = mappings[0]; Assert.AreEqual(m.From, typeof(IList<int>)); Assert.IsInstanceOf<IList<int>>(m.Get(MagicBagTests.EmptyBag)); var arr0 = ((IEnumerable<int>)m.Get(MagicBagTests.EmptyBag)).ToArray(); Assert.AreEqual(3, arr0.Length); Assert.AreEqual(5, arr0[0]); Assert.AreEqual(6, arr0[1]); Assert.AreEqual(7, arr0[2]); m = mappings[1]; Assert.AreEqual(m.From, typeof(IList<float>)); Assert.IsInstanceOf<IList<float>>(m.Get(MagicBagTests.EmptyBag)); var arr1 = ((IEnumerable<float>)m.Get(MagicBagTests.EmptyBag)).ToArray(); Assert.AreEqual(1, arr1.Length); Assert.AreEqual(3.14f, arr1[0]); } [Test] public void ArrayTests() { var mappings = MappingGenerators.Array.Generate(SourceMappings); Assert.AreEqual(2, mappings.Length); var m = mappings[0]; Assert.AreEqual(m.From, typeof(int[])); Assert.IsInstanceOf<int[]>(m.Get(MagicBagTests.EmptyBag)); var arr0 = (int[])m.Get(MagicBagTests.EmptyBag); Assert.AreEqual(3, arr0.Length); Assert.AreEqual(5, arr0[0]); Assert.AreEqual(6, arr0[1]); Assert.AreEqual(7, arr0[2]); m = mappings[1]; Assert.AreEqual(m.From, typeof(float[])); Assert.IsInstanceOf<float[]>(m.Get(MagicBagTests.EmptyBag)); var arr1 = (float[])m.Get(MagicBagTests.EmptyBag); Assert.AreEqual(1, arr1.Length); Assert.AreEqual(3.14f, arr1[0]); } } }
using System.Collections.Generic; using System.Linq; using Dulcet.Twitter; using Inscribe.Filter.Core; using Inscribe.Storage; namespace Inscribe.Filter.Filters.Numeric { public class FilterUserId : UserFilterBase { private LongRange _range; [GuiVisible("ユーザー数値ID範囲")] public LongRange Range { get { return _range ?? LongRange.FromPivotValue(0); } set { _range = value; } } private FilterUserId() { } public FilterUserId(LongRange range) { this.Range = range; } public FilterUserId(long pivot) : this(LongRange.FromPivotValue(pivot)) { } public override string Identifier { get { return "uid"; } } public override IEnumerable<object> GetArgumentsForQueryify() { yield return this.Range; } public override string Description { get { return "ユーザーの数値ID"; } } public override string FilterStateString { get { if (this._range != null && this._range.From != null && this.Range.RangeType == RangeType.Pivot) { var u = UserStorage.Get(this._range.From.Value); if (u == null) { return "ユーザー数値ID:" + this.Range.ToString() + "(逆引き: Krile内に見つかりません)"; } else { return "ユーザー数値ID:" + this.Range.ToString() + "(逆引き: @" + u.TwitterUser.ScreenName + ")"; } } else { return "ユーザー数値ID:" + this.Range.ToString(); } } } public override bool FilterUser(TwitterUser user) { return this.Range.Check(user.NumericId); } } }
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using Units.Core.Parser.State; namespace Units.Core.Parser { public class UnitComparer : IComparer<(IUnit, int)> { public IUnit Wanted { get; } public string WantedString { get; } public UnitComparer(IUnit wanted) { Wanted = wanted; WantedString = wanted.SiName(); } private static readonly char[] nums = Enumerable.Range(0, 9).Select(i => (char)(i + '0')).ToArray(); public int Dist((IUnit unit, int depth) a) { var name1 = a.unit is IReadonlyUnit rou ? rou.SiName(true) : a.unit.SiName(); var to = Math.Min(WantedString.Length, name1.Length); var count1 = 0; for (int i = 1; i <= to; i++) { count1 += WantedString[^i] == name1[^i] ? 0 : 1; } double distance = Math.Pow(count1, a.depth); return distance < 0 || distance > int.MaxValue ? int.MaxValue : (int)distance; } public int Compare((IUnit, int) x, (IUnit, int) y) { var name1 = x.Item1 is IReadonlyUnit rou ? rou.SiName(true) : x.Item1.SiName(); var name2 = y.Item1 is IReadonlyUnit rou2 ? rou2.SiName(true) : y.Item1.SiName(); //if (name1 == name2) // return 0; //if (y.Item2 != x.Item2) // return x.Item2 < y.Item2 ? -1 : 1; var to = Math.Min(name1.Length, Math.Min(WantedString.Length, name2.Length)); var count1 = 0; var count2 = 0; for (int i = 1; i <= to; i++) { count1 += WantedString[^i] == name1[^i] ? 1 : 0; count2 += WantedString[^i] == name2[^i] ? 1 : 0; } //if (count1 == count2 && name1 == name2 && x.Item2) return count1 < count2 ? -1 : 1; } } }
using System.Text.Json.Serialization; namespace YaStation.Reverse.Quasar.Common.Properties { public class PropertyState { [JsonPropertyName("percent")] public object Percent { get; set; } [JsonPropertyName("status")] public object Status { get; set; } [JsonPropertyName("value")] public long Value { get; set; } } }
namespace TextStudio { partial class RecieveEmail { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.PortGroupBox = new System.Windows.Forms.GroupBox(); this.PortInput = new System.Windows.Forms.TextBox(); this.HostGroupBox = new System.Windows.Forms.GroupBox(); this.HostInput = new System.Windows.Forms.TextBox(); this.PasswordGroupBox = new System.Windows.Forms.GroupBox(); this.PasswordInput = new System.Windows.Forms.TextBox(); this.EmailGroupBox = new System.Windows.Forms.GroupBox(); this.EmailInput = new System.Windows.Forms.TextBox(); this.SubjectGroupBox = new System.Windows.Forms.GroupBox(); this.SubjectInput = new System.Windows.Forms.TextBox(); this.UseSSLSecurityCheckBox = new System.Windows.Forms.CheckBox(); this.InsertTextButton = new System.Windows.Forms.Button(); this.InsertWithFormatingButton = new System.Windows.Forms.Button(); this.CancelButton = new System.Windows.Forms.Button(); this.PortGroupBox.SuspendLayout(); this.HostGroupBox.SuspendLayout(); this.PasswordGroupBox.SuspendLayout(); this.EmailGroupBox.SuspendLayout(); this.SubjectGroupBox.SuspendLayout(); this.SuspendLayout(); // // PortGroupBox // this.PortGroupBox.Controls.Add(this.PortInput); this.PortGroupBox.Location = new System.Drawing.Point(622, 186); this.PortGroupBox.Name = "PortGroupBox"; this.PortGroupBox.Size = new System.Drawing.Size(160, 52); this.PortGroupBox.TabIndex = 12; this.PortGroupBox.TabStop = false; this.PortGroupBox.Text = "Port"; // // PortInput // this.PortInput.Location = new System.Drawing.Point(6, 19); this.PortInput.Name = "PortInput"; this.PortInput.Size = new System.Drawing.Size(148, 20); this.PortInput.TabIndex = 0; // // HostGroupBox // this.HostGroupBox.Controls.Add(this.HostInput); this.HostGroupBox.Location = new System.Drawing.Point(12, 186); this.HostGroupBox.Name = "HostGroupBox"; this.HostGroupBox.Size = new System.Drawing.Size(604, 52); this.HostGroupBox.TabIndex = 9; this.HostGroupBox.TabStop = false; this.HostGroupBox.Text = "Host"; // // HostInput // this.HostInput.Location = new System.Drawing.Point(9, 19); this.HostInput.Name = "HostInput"; this.HostInput.Size = new System.Drawing.Size(589, 20); this.HostInput.TabIndex = 0; // // PasswordGroupBox // this.PasswordGroupBox.Controls.Add(this.PasswordInput); this.PasswordGroupBox.Location = new System.Drawing.Point(12, 70); this.PasswordGroupBox.Name = "PasswordGroupBox"; this.PasswordGroupBox.Size = new System.Drawing.Size(770, 52); this.PasswordGroupBox.TabIndex = 11; this.PasswordGroupBox.TabStop = false; this.PasswordGroupBox.Text = "Password"; // // PasswordInput // this.PasswordInput.Location = new System.Drawing.Point(9, 19); this.PasswordInput.Name = "PasswordInput"; this.PasswordInput.Size = new System.Drawing.Size(755, 20); this.PasswordInput.TabIndex = 0; // // EmailGroupBox // this.EmailGroupBox.Controls.Add(this.EmailInput); this.EmailGroupBox.Location = new System.Drawing.Point(12, 12); this.EmailGroupBox.Name = "EmailGroupBox"; this.EmailGroupBox.Size = new System.Drawing.Size(770, 52); this.EmailGroupBox.TabIndex = 10; this.EmailGroupBox.TabStop = false; this.EmailGroupBox.Text = "Your Email"; // // EmailInput // this.EmailInput.Location = new System.Drawing.Point(9, 19); this.EmailInput.Name = "EmailInput"; this.EmailInput.Size = new System.Drawing.Size(755, 20); this.EmailInput.TabIndex = 0; // // SubjectGroupBox // this.SubjectGroupBox.Controls.Add(this.SubjectInput); this.SubjectGroupBox.Location = new System.Drawing.Point(12, 128); this.SubjectGroupBox.Name = "SubjectGroupBox"; this.SubjectGroupBox.Size = new System.Drawing.Size(770, 52); this.SubjectGroupBox.TabIndex = 8; this.SubjectGroupBox.TabStop = false; this.SubjectGroupBox.Text = "Subject"; // // SubjectInput // this.SubjectInput.Location = new System.Drawing.Point(9, 19); this.SubjectInput.Name = "SubjectInput"; this.SubjectInput.Size = new System.Drawing.Size(755, 20); this.SubjectInput.TabIndex = 0; // // UseSSLSecurityCheckBox // this.UseSSLSecurityCheckBox.AutoSize = true; this.UseSSLSecurityCheckBox.Checked = true; this.UseSSLSecurityCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; this.UseSSLSecurityCheckBox.Location = new System.Drawing.Point(21, 244); this.UseSSLSecurityCheckBox.Name = "UseSSLSecurityCheckBox"; this.UseSSLSecurityCheckBox.Size = new System.Drawing.Size(82, 17); this.UseSSLSecurityCheckBox.TabIndex = 13; this.UseSSLSecurityCheckBox.Text = "Enable SSL"; this.UseSSLSecurityCheckBox.UseVisualStyleBackColor = true; // // InsertTextButton // this.InsertTextButton.Location = new System.Drawing.Point(707, 270); this.InsertTextButton.Name = "InsertTextButton"; this.InsertTextButton.Size = new System.Drawing.Size(75, 23); this.InsertTextButton.TabIndex = 14; this.InsertTextButton.Text = "InsertText"; this.InsertTextButton.UseVisualStyleBackColor = true; this.InsertTextButton.Click += new System.EventHandler(this.InsertTextButton_Click); // // InsertWithFormatingButton // this.InsertWithFormatingButton.Location = new System.Drawing.Point(587, 270); this.InsertWithFormatingButton.Name = "InsertWithFormatingButton"; this.InsertWithFormatingButton.Size = new System.Drawing.Size(110, 23); this.InsertWithFormatingButton.TabIndex = 15; this.InsertWithFormatingButton.Text = "InsertWithFormating"; this.InsertWithFormatingButton.UseVisualStyleBackColor = true; this.InsertWithFormatingButton.Click += new System.EventHandler(this.InsertWithFormatingButton_Click); // // CancelButton // this.CancelButton.Location = new System.Drawing.Point(528, 270); this.CancelButton.Name = "CancelButton"; this.CancelButton.Size = new System.Drawing.Size(53, 23); this.CancelButton.TabIndex = 16; this.CancelButton.Text = "Cancel"; this.CancelButton.UseVisualStyleBackColor = true; this.CancelButton.Click += new System.EventHandler(this.CancelButton_Click); // // RecieveEmail // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 301); this.Controls.Add(this.CancelButton); this.Controls.Add(this.InsertWithFormatingButton); this.Controls.Add(this.InsertTextButton); this.Controls.Add(this.UseSSLSecurityCheckBox); this.Controls.Add(this.PortGroupBox); this.Controls.Add(this.HostGroupBox); this.Controls.Add(this.PasswordGroupBox); this.Controls.Add(this.EmailGroupBox); this.Controls.Add(this.SubjectGroupBox); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "RecieveEmail"; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "RecieveEmail"; this.PortGroupBox.ResumeLayout(false); this.PortGroupBox.PerformLayout(); this.HostGroupBox.ResumeLayout(false); this.HostGroupBox.PerformLayout(); this.PasswordGroupBox.ResumeLayout(false); this.PasswordGroupBox.PerformLayout(); this.EmailGroupBox.ResumeLayout(false); this.EmailGroupBox.PerformLayout(); this.SubjectGroupBox.ResumeLayout(false); this.SubjectGroupBox.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.GroupBox PortGroupBox; private System.Windows.Forms.TextBox PortInput; private System.Windows.Forms.GroupBox HostGroupBox; private System.Windows.Forms.TextBox HostInput; private System.Windows.Forms.GroupBox PasswordGroupBox; private System.Windows.Forms.TextBox PasswordInput; private System.Windows.Forms.GroupBox EmailGroupBox; private System.Windows.Forms.TextBox EmailInput; private System.Windows.Forms.GroupBox SubjectGroupBox; private System.Windows.Forms.TextBox SubjectInput; private System.Windows.Forms.CheckBox UseSSLSecurityCheckBox; private System.Windows.Forms.Button InsertTextButton; private System.Windows.Forms.Button InsertWithFormatingButton; private System.Windows.Forms.Button CancelButton; } }
using Seguranca.Domain.Entities; namespace Seguranca.Domain.Contracts.Repositories { public interface IFormularioEventoRepository : IRepository<FormularioEvento> { } }
using System; using System.Collections.Generic; using System.Text; namespace Componentes.Secundarios { public static class Palavras { public static class LeitorPalavra { public static int TamanhoPalavra = 16; public static Comando Ler(string Palavra) { string opcode = ""; string p1 = ""; string p2 = ""; opcode = Palavra.Substring(0, 16); if (Palavra.Substring(4, 2) == Palavras.Param.DiretoNumero || Palavra.Substring(4, 2) == Palavras.Param.IndiretoNumero) { p1 = Palavra.Substring(16, 16); } if (Palavra.Substring(10, 2) == Palavras.Param.DiretoNumero || Palavra.Substring(10, 2) == Palavras.Param.IndiretoNumero) { p2 = Palavra.Substring(32, 16); } return new Comando(opcode, p1, p2); } } public static class Opcode { // USO INTERNO PARA SINALIZAR QUE A PAVRA E UM DADO public static string DADO = "0000"; public static string Mov = "0001"; public static string Inc = "0010"; public static string Add = "0011"; public static string Sub = "0100"; public static string Mul = "0101"; public static string Div = "0110"; public static string Cmp = "0111"; public static string Je = "1000"; public static string Jne = "1001"; public static string Jg = "1010"; public static string Jge = "1011"; public static string Jl = "1100"; public static string Jle = "1101"; } public static class Param { public static string IndiretoRegistrador = "10"; public static string IndiretoNumero = "11"; public static string DiretoNumero = "00"; public static string DiretoRegistrador = "01"; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Extensions; using MicroBenchmarks; using System.Collections.Generic; namespace System.Collections { // the concurrent collections are covered with benchmarks in Add_Remove_SteadyState.cs [BenchmarkCategory(Categories.Libraries, Categories.Collections, Categories.GenericCollections)] [GenericTypeArguments(typeof(int))] // value type [GenericTypeArguments(typeof(string))] // reference type public class CreateAddAndRemove<T> { [Params(Utils.DefaultCollectionSize)] public int Size; private T[] _keys; [GlobalSetup] public void Setup() => _keys = ValuesGenerator.ArrayOfUniqueValues<T>(Size); [Benchmark] public List<T> List() { List<T> list = new List<T>(); foreach (T uniqueKey in _keys) { list.Add(uniqueKey); } foreach (T uniqueKey in _keys) { list.Remove(uniqueKey); } return list; } [Benchmark] public LinkedList<T> LinkedList() { LinkedList<T> linkedList = new LinkedList<T>(); foreach (T item in _keys) { linkedList.AddLast(item); } foreach (T item in _keys) { linkedList.Remove(item); } return linkedList; } [Benchmark] public HashSet<T> HashSet() { HashSet<T> hashSet = new HashSet<T>(); foreach (T uniqueKey in _keys) { hashSet.Add(uniqueKey); } foreach (T uniqueKey in _keys) { hashSet.Remove(uniqueKey); } return hashSet; } [Benchmark] public Dictionary<T, T> Dictionary() { Dictionary<T, T> dictionary = new Dictionary<T, T>(); foreach (T uniqueKey in _keys) { dictionary.Add(uniqueKey, uniqueKey); } foreach (T uniqueKey in _keys) { dictionary.Remove(uniqueKey); } return dictionary; } [Benchmark] public SortedList<T, T> SortedList() { SortedList<T, T> sortedList = new SortedList<T, T>(); foreach (T uniqueKey in _keys) { sortedList.Add(uniqueKey, uniqueKey); } foreach (T uniqueKey in _keys) { sortedList.Remove(uniqueKey); } return sortedList; } [Benchmark] public SortedSet<T> SortedSet() { SortedSet<T> sortedSet = new SortedSet<T>(); foreach (T uniqueKey in _keys) { sortedSet.Add(uniqueKey); } foreach (T uniqueKey in _keys) { sortedSet.Remove(uniqueKey); } return sortedSet; } [Benchmark] public SortedDictionary<T, T> SortedDictionary() { SortedDictionary<T, T> sortedDictionary = new SortedDictionary<T, T>(); foreach (T uniqueKey in _keys) { sortedDictionary.Add(uniqueKey, uniqueKey); } foreach (T uniqueKey in _keys) { sortedDictionary.Remove(uniqueKey); } return sortedDictionary; } [Benchmark] public Stack<T> Stack() { Stack<T> stack = new Stack<T>(); foreach (T uniqueKey in _keys) { stack.Push(uniqueKey); } foreach (T uniqueKey in _keys) { stack.Pop(); } return stack; } [Benchmark] public Queue<T> Queue() { Queue<T> queue = new Queue<T>(); foreach (T uniqueKey in _keys) { queue.Enqueue(uniqueKey); } foreach (T uniqueKey in _keys) { queue.Dequeue(); } return queue; } } }
using System; namespace lab_02_class { class Program { static void Main() { // use the class : create new Dog object ==> call this an INSTANCE (of a class) var dog01 = new Dog(); // create new empty blank Dog object dog01.Name = "Fido"; dog01.Age = 1; dog01.Height = 400; // GROW OUR DOG dog01.Grow(); // PRINT NEW AGE AND HEIGHT Console.WriteLine("Age is " + dog01.Age + " and height is " + dog01.Height); dog01.Grow(); // $ literal syntax : just print what's inside // EXCEPT {} CURLY BRACES : PUT VARIABLES IN THEM Console.WriteLine($"Age is {dog01.Age} and height is {dog01.Height}"); } } // INSTRUCTIONS (BLUEPRINT) FOR CREATING NEW DOG OBJECT class Dog { public string Name; public int Age; public int Height; public void Grow() // have the method but return nothing { // LET COMPUTER KNOW : IS IT RETURNING ANY VALUE??? // NO ==> VOID // YES ==> SPECIFY TYPE EG INT, STRING this.Age++; this.Height += 10; } } }
using System; using System.Collections.Generic; using System.Text; namespace WinesWorld.Web.ViewModels.Receipts.All { public class ReceiptAllViewModel { public string Id { get; set; } public DateTime IssuedOn { get; set; } public decimal Total { get; set; } public int Wines { get; set; } } }
using System.Collections.Generic; namespace JDict { public class TatoebaLink { public long SentenceId { get; } public long TranslationId { get; } public TatoebaLink(long sentenceId, long translationId) { SentenceId = sentenceId; TranslationId = translationId; } public KeyValuePair<long, long> AsKeyValuePair() { return new KeyValuePair<long, long>(SentenceId, TranslationId); } } }
using System; using System.Drawing; using System.Windows.Forms; namespace Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Check(); } private void AddColor_Click(object sender, EventArgs e) { var rnd = new Random(DateTime.Now.Millisecond); var randomColor = Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)); var randomPosition = (float)rnd.NextDouble(); GradientColorPicker1.AddColor(randomColor, randomPosition).SelectNextColor(); Check(); } private void GradientCanvas_Paint(object sender, PaintEventArgs e) { GradientColorPicker1.DrawLinearGradient(e.Graphics, GradientCanvas.ClientRectangle, AnglePicker.Value); } private void RemoveColor_Click(object sender, EventArgs e) { GradientColorPicker1.RemoveSelectedColor().SelectNextColor(); Check(); } private void SelectColor_Click(object sender, EventArgs e) { if (GradientColorPicker1.SelectedColor != null && ColorDialog.ShowDialog() == DialogResult.OK) { GradientColorPicker1.SelectedColor.Color = ColorDialog.Color; } } private void RandomizeColors_Click(object sender, EventArgs e) { GradientColorPicker1.Randomize(true, true); } private void InvertColors_Click(object sender, EventArgs e) { GradientColorPicker1.InvertColors(); } private void EvenlyAlignColors_Click(object sender, EventArgs e) { GradientColorPicker1.EvenlyAlignColors(); } private void AnglePicker_ValueChanged(object sender, EventArgs e) { GradientCanvas.Refresh(); } private void GradientColorPicker1_EventsHandler(object sender, EventArgs e) { GradientCanvas.Refresh(); Check(); } private void Check() { RemoveColor.Enabled = SelectColor.Enabled = RandomizeColors.Enabled = InvertColors.Enabled = EvenlyAlignColors.Enabled = GradientColorPicker1.Colors.Count > 0; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LicenseManagerLibrary.Licenses { public interface ILicenseFeature { /// <summary> /// Name of the feature /// </summary> string Name { get; set; } /// <summary> /// If the feature is enabled /// </summary> bool Enabled { get; set; } /// <summary> /// Minimum access requirement /// </summary> int AccessLevel { get; set; } /// <summary> /// Whether this feature is enabled by default. /// </summary> /// <remarks> /// Overrides AccessLevel and Enabled if set to true /// </remarks> bool Mandatory { get; set; } } }
namespace Library.Domain.Exceptions { public class InvalidCredentialsException : DomainException { public override string Code => "invalid_credentials"; public InvalidCredentialsException(string message) : base(message) { } } }
@using mko.Newton @model IQueryable<DB.Kepler.EF60.Sterne_Planeten_Monde> @{ ViewBag.Title = "Index"; } <h2>Alle Planeten des Sonnensystems</h2> <table class="table table-striped"> <tr> <th> Name </th> <th> Bahnradius in AU </th> <th> Anzahl der Monde </th> </tr> @foreach(var planet in Model) { <tr> <td> @planet.Himmelskoerper.Name </td> <td> @Length.AU(Length.Kilometer(planet.Himmelskoerper.Umlaufbahn.Laenge_grosse_Halbachse_in_km)).Vector[0] </td> <td> @planet.Himmelskoerper.TrabantenUmlaufbahnen.Count </td> </tr> } </table>
using ImageQuery.Environment; namespace ImageQuery.Query.Statements { public interface IQueryStatement { void Run(IEnvironment env); } }
using System; using NUnit.Framework; #if LIGHT_EXPRESSION using static FastExpressionCompiler.LightExpression.Expression; namespace FastExpressionCompiler.LightExpression.UnitTests #else using System.Linq.Expressions; using static System.Linq.Expressions.Expression; namespace FastExpressionCompiler.UnitTests #endif { [TestFixture] public class ValueTypeTests : ITest { public int Run() { Should_support_struct_params_with_field_access(); Should_support_virtual_calls_on_struct_arguments(); Should_support_virtual_calls_with_parameters_on_struct_arguments(); Can_create_struct(); Can_init_struct_member(); Can_get_struct_member(); Action_using_with_struct_closure_field(); return 7; } [Test] public void Should_support_struct_params_with_field_access() { Expression<Func<StructA, int>> expr = a => a.N; var f = expr.CompileFast(true); Assert.AreEqual(42, f(new StructA { N = 42 })); } [Test] public void Should_support_virtual_calls_on_struct_arguments() { Expression<Func<StructA, string>> expr = a => a.ToString(); var f = expr.CompileFast(true); Assert.AreEqual("42", f(new StructA { N = 42 })); } [Test] public void Should_support_virtual_calls_with_parameters_on_struct_arguments() { object aa = new StructA(); Expression<Func<StructA, bool>> expr = a => a.Equals(aa); var f = expr.CompileFast(true); Assert.AreEqual(false, f(new StructA { N = 42 })); } [Test] public void Can_create_struct() { Expression<Func<StructA>> expr = () => new StructA(); var newA = expr.CompileFast<Func<StructA>>(true); Assert.AreEqual(0, newA().N); } [Test] public void Can_init_struct_member() { Expression<Func<StructA>> expr = () => new StructA { N = 43, M = 34, Sf = "sf", Sp = "sp" }; var newA = expr.CompileFast<Func<StructA>>(true); var a = newA(); Assert.AreEqual(43, a.N); Assert.AreEqual(34, a.M); Assert.AreEqual("sf", a.Sf); Assert.AreEqual("sp", a.Sp); } [Test] public void Can_get_struct_member() { Expression<Func<int>> exprN = () => new StructA { N = 43, M = 34, Sf = "sf", Sp = "sp" }.N; Expression<Func<int>> exprM = () => new StructA { N = 43, M = 34, Sf = "sf", Sp = "sp" }.M; Expression<Func<string>> exprSf = () => new StructA { N = 43, M = 34, Sf = "sf", Sp = "sp" }.Sf; Expression<Func<string>> exprSp = () => new StructA { N = 43, M = 34, Sf = "sf", Sp = "sp" }.Sp; var n = exprN.CompileFast<Func<int>>(true); var m = exprM.CompileFast<Func<int>>(true); var sf = exprSf.CompileFast<Func<string>>(true); var sp = exprSp.CompileFast<Func<string>>(true); Assert.AreEqual(43, n()); Assert.AreEqual(34, m()); Assert.AreEqual("sf", sf()); Assert.AreEqual("sp", sp()); } struct StructA { public int N; public int M { get; set; } public string Sf; public string Sp { get; set; } public override string ToString() => N.ToString(); } [Test] public void Action_using_with_struct_closure_field() { var s = new SS(); Expression<Action<string>> expr = a => s.SetValue(a); var lambda = expr.CompileFast(ifFastFailedReturnNull: true); lambda("a"); Assert.AreEqual("a", s.Value); } public struct SS { public string Value; public void SetValue(string s) { Value = s; } } } }
using System; using System.Collections.Generic; namespace ParallelTestRunner.Impl { public class TestRunnerArgsFactoryImpl : ITestRunnerArgsFactory { public ITestRunnerArgs ParseArgs(string[] args) { TestRunnerArgsImpl data = new TestRunnerArgsImpl(); data.AssemblyList = new List<string>(); for (int i = 0; i < args.Length; i++) { string item = args[i].Replace("\"", string.Empty); if (item.StartsWith("provider:", StringComparison.InvariantCultureIgnoreCase)) { data.Provider = item.Remove(0, 9); } else if (item.StartsWith("threadcount:", StringComparison.InvariantCultureIgnoreCase)) { int number; int.TryParse(item.Remove(0, 12), out number); data.ThreadCount = number; } else if (item.StartsWith("root:", StringComparison.InvariantCultureIgnoreCase)) { data.Root = item.Remove(0, 5); if (data.Root.EndsWith("\\") || data.Root.EndsWith("/")) { data.Root = data.Root.Substring(0, data.Root.Length - 1); } } else if (item.StartsWith("out:", StringComparison.InvariantCultureIgnoreCase)) { data.Output = item.Remove(0, 4); } else if (item.StartsWith("plevel:", StringComparison.InvariantCultureIgnoreCase)) { PLevel result; if (Enum.TryParse<PLevel>(item.Remove(0, 7), true, out result)) { data.PLevel = result; } } else { string[] pathList = item.Split(' '); for (int j = 0; j < pathList.Length; j++) { data.AssemblyList.Add(pathList[j]); } } } return data; } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Sklad_v1_001.Control.SimpleControl { /// <summary> /// Логика взаимодействия для EditBoxWithLabel.xaml /// </summary> public partial class EditBoxWithLabel : UserControl, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } // свойство зависимостей public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(EditBoxWithLabel), new UIPropertyMetadata(String.Empty)); // свойство зависимостей public static readonly DependencyProperty IsRequiredProperty = DependencyProperty.Register( "IsRequired", typeof(Visibility), typeof(EditBoxWithLabel), new UIPropertyMetadata(Visibility.Collapsed)); // свойство зависимостей public static readonly DependencyProperty HorizontalTextAlignmentProperty = DependencyProperty.Register( "HorizontalTextAlignment", typeof(HorizontalAlignment), typeof(EditBoxWithLabel), new UIPropertyMetadata(HorizontalAlignment.Left)); // свойство зависимостей public static readonly DependencyProperty AcceptsReturnProperty = DependencyProperty.Register( "AcceptReturn", typeof(Boolean), typeof(EditBoxWithLabel), new UIPropertyMetadata(false)); // свойство зависимостей public static readonly DependencyProperty MaxLengthProperty = DependencyProperty.Register( "MaxLength", typeof(Int32), typeof(EditBoxWithLabel), new UIPropertyMetadata(50)); public EditBoxWithLabel() { InitializeComponent(); } // Обычное свойство .NET - обертка над свойством зависимостей public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); OnPropertyChanged("Text"); } } // Обычное свойство .NET - обертка над свойством зависимостей public Visibility IsRequired { get { return (Visibility)GetValue(IsRequiredProperty); } set { SetValue(IsRequiredProperty, value); OnPropertyChanged("IsRequired"); } } // Обычное свойство .NET - обертка над свойством зависимостей public Int32 MaxLength { get { return (Int32)GetValue(MaxLengthProperty); } set { SetValue(MaxLengthProperty, value); OnPropertyChanged("MaxLength"); } } // Обычное свойство .NET - обертка над свойством зависимостей public HorizontalAlignment HorizontalTextAlignment { get { return (HorizontalAlignment)GetValue(HorizontalTextAlignmentProperty); } set { SetValue(HorizontalTextAlignmentProperty, value); OnPropertyChanged("HorizontalTextAlignment"); } } // Обычное свойство .NET - обертка над свойством зависимостей public Boolean AcceptsReturn { get { return (Boolean)GetValue(AcceptsReturnProperty); } set { SetValue(AcceptsReturnProperty, value); } } public event Action ButtonClick; public string LabelText { get { return this.label.Content.ToString(); } set { this.label.Content = value; } } public double LabelWidth { get { return this.wrapPanel.Width; } set { this.wrapPanel.Width = value; } } public Boolean IsReadOnly { get { return this.TextBox.IsReadOnly; } set { this.TextBox.IsReadOnly = value; } } private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { ButtonClick?.Invoke(); } } }
using System; using System.Collections; using System.Collections.Generic; class LinkedList<T> : IEnumerable<T> { public Node<T> First { get; private set; } public Node<T> Last { get; private set; } public int Count { get; private set; } public void AddFirst(T value) { this.Count++; var node = new Node<T>(value); if (this.First == null) { this.First = this.Last = node; } else { node.Next = this.First; this.First.Previous = node; this.First = node; } } public Node<T> RemoveFirst() { if (this.First == null) return null; this.Count--; var first = this.First; // The list contains only one node if (this.First.Next == null) { this.Clear(); } else { this.First = this.First.Next; this.First.Previous = null; } first.Next = first.Previous = null; return first; } public void AddLast(T value) { this.Count++; var node = new Node<T>(value); if (this.Last == null) { this.First = this.Last = node; } else { node.Previous = this.Last; this.Last.Next = node; this.Last = node; } } public Node<T> RemoveLast() { if (this.Last == null) return null; this.Count--; var last = this.Last; // The list contains only one node if (this.Last.Previous == null) { this.Clear(); } else { this.Last = this.Last.Previous; this.Last.Next = null; } last.Next = last.Previous = null; return last; } public void Clear() { this.First = this.Last = null; } public IEnumerator<T> GetEnumerator() { for (var current = this.First; current != null; current = current.Next) yield return current.Value; } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } public override string ToString() { return string.Join(" <-> ", this); } }
using Senai.CodeTur.Dominio.Entidades; using Senai.CodeTur.Dominio.Interfaces.Repositorios; using Senai.CodeTur.Infra.Data.Contextos; using System; using System.Collections.Generic; using System.Linq; namespace Senai.CodeTur.Infra.Data.Repositorios { public class PacoteRepositorio : IPacotes, IDisposable { private CodeTurContext _context; public PacoteRepositorio(CodeTurContext context) { _context = context; } public PacoteDominio BuscarPorId(int id) { try { return _context.Pacotes.Find(id); } catch (Exception ex) { throw new Exception(ex.Message); } } public PacoteDominio Cadastrar(PacoteDominio pacote) { try { _context.Pacotes.Add(pacote); _context.SaveChanges(); return pacote; } catch (Exception ex) { throw new Exception(ex.Message); } } public List<PacoteDominio> Listar(bool? todos = null) { try { if (todos == null) { return _context.Pacotes.ToList(); } else if (todos == true) { return _context.Pacotes.Where(x => x.Ativo == true).ToList(); } else { return _context.Pacotes.Where(x => x.Ativo == false).ToList(); } } catch (Exception ex) { throw new Exception(ex.Message); } } public void Dispose() { _context.Dispose(); } } }
using System; namespace Gongchengshi { public class Future<T> { public delegate R FutureDelegate<R>(); public Future(FutureDelegate<T> @delegate) { _delegate = @delegate; _result = @delegate.BeginInvoke(null, null); } private FutureDelegate<T> _delegate; private IAsyncResult _result; private T _pValue; private bool _hasValue = false; private T Value { get { if (!_hasValue) { if (!_result.IsCompleted) _result.AsyncWaitHandle.WaitOne(); _pValue = _delegate.EndInvoke(_result); _hasValue = true; } return _pValue; } } public static implicit operator T(Future<T> f) { return f.Value; } } }
using System; namespace RDotNet.Graphics { public struct Size : IEquatable<Size> { private double height; private double width; public Size(double width, double height) { this.width = width; this.height = height; } public double Width { get { return this.width; } set { this.width = value; } } public double Height { get { return this.height; } set { this.height = value; } } #region IEquatable<Size> Members public bool Equals(Size other) { return (this == other); } #endregion IEquatable<Size> Members public static bool operator ==(Size size1, Size size2) { return size1.Width == size2.Width && size1.Height == size2.Height; } public static bool operator !=(Size size1, Size size2) { return !(size1 == size2); } public override int GetHashCode() { const int Prime = 31; return Prime * Width.GetHashCode() + Height.GetHashCode(); } public override bool Equals(object obj) { if (obj is Size) { var size = (Size)obj; return (this == size); } return false; } } }
namespace FluentBuild.Tests.Build.Samples.Simple.C_ { public class Propgram { //entry point for if this is built as a console application private static void Main(string[] args) { Basic hello = new Basic(); hello.Hello(); } } }
using System; namespace QuickGraph { #if !SILVERLIGHT [Serializable] #endif public abstract class QuickGraphException : Exception { protected QuickGraphException() { } protected QuickGraphException(string message) : base(message) { } protected QuickGraphException(string message, Exception inner) : base(message, inner) { } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using TopDownPlugin.ViewModels; using WpfDataUi.DataTypes; namespace TopDownPlugin.Views { /// <summary> /// Interaction logic for IndividualTopDownValuesView.xaml /// </summary> public partial class IndividualTopDownValuesView : UserControl { public event RoutedEventHandler XClick; TopDownValuesViewModel ViewModel => DataContext as TopDownValuesViewModel; public IndividualTopDownValuesView() { InitializeComponent(); this.DataContextChanged += HandleDataContextChanged; } private void HandleXClick(object sender, RoutedEventArgs e) { XClick?.Invoke(this, null); } private void HandleDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { DataGrid.Categories.Clear(); if(ViewModel != null) { var category = new MemberCategory() ; foreach(var kvp in ViewModel.AdditionalProperties) { var instanceMember = new InstanceMember(); instanceMember.Name = kvp.Key; instanceMember.CustomSetEvent += (owner, value) => { ViewModel.AdditionalProperties[kvp.Key].Value = value; ViewModel.NotifyAdditionalPropertiesChanged(); }; instanceMember.CustomGetEvent += (owner) => { return ViewModel.AdditionalProperties[kvp.Key].Value; }; instanceMember.CustomGetTypeEvent += (owner) => { return ViewModel.AdditionalProperties[kvp.Key].Type; }; // don't set the initial value, this will happen by using the getter above category.Members.Add(instanceMember); } DataGrid.Categories.Add(category); } } private void TextBox_KeyEnterUpdate(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { TextBox tBox = (TextBox)sender; DependencyProperty prop = TextBox.TextProperty; BindingExpression binding = BindingOperations.GetBindingExpression(tBox, prop); if (binding != null) { binding.UpdateSource(); } } } } }
using System; using System.Collections.Generic; namespace Minecraft.Model.Java { public sealed class Json:IArgumentText { #region IArgumentText members public string GetArgumentText() => "{}"; #endregion } }