commit
stringlengths 40
40
| subject
stringlengths 4
1.73k
| repos
stringlengths 5
127k
| old_file
stringlengths 2
751
| new_file
stringlengths 2
751
| new_contents
stringlengths 1
8.98k
| old_contents
stringlengths 0
6.59k
| license
stringclasses 13
values | lang
stringclasses 23
values |
---|---|---|---|---|---|---|---|---|
399812ede24478019058b0df541ab702113dd2b1 | add OrientationOnly ControllerState, update comments | vladkol/MixedRealityToolkit-Unity,killerantz/HoloToolkit-Unity,vladkol/MixedRealityToolkit-Unity,killerantz/HoloToolkit-Unity,vladkol/MixedRealityToolkit-Unity,killerantz/HoloToolkit-Unity,StephenHodgson/MixedRealityToolkit-Unity,killerantz/HoloToolkit-Unity,DDReaper/MixedRealityToolkit-Unity | Assets/MixedRealityToolkit/_Core/Definitions/Devices/ControllerState.cs | Assets/MixedRealityToolkit/_Core/Definitions/Devices/ControllerState.cs | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace Microsoft.MixedReality.Toolkit.Internal.Definitions.Devices
{
/// <summary>
/// The Controller State defines how a controller or headset is currently being tracked.
/// This enables developers to be able to handle non-tracked situations and react accordingly
/// </summary>
public enum ControllerState
{
/// <summary>
/// No controller state provided by the SDK.
/// </summary>
None = 0,
/// <summary>
/// The controller is currently fully tracked and has accurate positioning.
/// </summary>
Tracked,
/// <summary>
/// The controller is currently not tracked.
/// </summary>
NotTracked,
/// <summary>
/// The controller is currently only returning orientation data.
/// </summary>
OrientationOnly,
/// <summary>
/// Reserved, for systems that provide alternate tracking.
/// </summary>
Other
}
} | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace Microsoft.MixedReality.Toolkit.Internal.Definitions.Devices
{
/// <summary>
/// The Controller State defines whether a controller or headset is currently being tracker or not.
/// This enables developers to be able to handle non-tracked situations and react accordingly
/// </summary>
public enum ControllerState
{
/// <summary>
/// No controller state provided by the SDK.
/// </summary>
None = 0,
/// <summary>
/// The controller is currently fully tracked and has accurate positioning.
/// </summary>
Tracked,
/// <summary>
/// The controller is currently not visually tracked and has relative positioning.
/// </summary>
NotTracked,
/// <summary>
/// Reserved, for systems that provide alternate tracking.
/// </summary>
Other
}
} | mit | C# |
6c723d3788fe0420e6a09607031068928c96de91 | Test launching 10 listeners in CI | InEngine-NET/InEngine.NET,InEngine-NET/InEngine.NET,InEngine-NET/InEngine.NET | IntegrationEngine.Tests/JobProcessor/MessageQueueListenerManagerTest.cs | IntegrationEngine.Tests/JobProcessor/MessageQueueListenerManagerTest.cs | using BeekmanLabs.UnitTesting;
using IntegrationEngine.JobProcessor;
using NUnit.Framework;
using Moq;
using System;
using System.Threading;
namespace IntegrationEngine.Tests.JobProcessor
{
public class MessageQueueListenerManagerTest : TestBase<MessageQueueListenerManager>
{
public Mock<MessageQueueListenerFactory> MockMessageQueueListenerFactory { get; set; }
[SetUp]
public void Setup()
{
MockMessageQueueListenerFactory = new Mock<MessageQueueListenerFactory>();
MockMessageQueueListenerFactory.Setup(x => x.CreateRabbitMQListener())
.Returns<IMessageQueueListener>(null);
Subject.MessageQueueListenerFactory = MockMessageQueueListenerFactory.Object;
}
[Test]
public void ShouldStartListener()
{
Subject.ListenerTaskCount = 1;
Subject.StartListener();
MockMessageQueueListenerFactory.Verify(x => x.CreateRabbitMQListener(), Times.Once);
}
[Test]
public void ShouldStartMultipleListeners()
{
var listenerTaskCount = 10;
Subject.ListenerTaskCount = listenerTaskCount;
Subject.StartListener();
MockMessageQueueListenerFactory.Verify(x => x.CreateRabbitMQListener(),
Times.Exactly(listenerTaskCount));
}
[Test]
public void ShouldSetCancellationTokenOnDispose()
{
Subject.CancellationTokenSource = new CancellationTokenSource();
Subject.Dispose();
Assert.That(Subject.CancellationTokenSource.IsCancellationRequested, Is.True);
}
}
}
| using BeekmanLabs.UnitTesting;
using IntegrationEngine.JobProcessor;
using NUnit.Framework;
using Moq;
using System;
using System.Threading;
namespace IntegrationEngine.Tests.JobProcessor
{
public class MessageQueueListenerManagerTest : TestBase<MessageQueueListenerManager>
{
public Mock<MessageQueueListenerFactory> MockMessageQueueListenerFactory { get; set; }
[SetUp]
public void Setup()
{
MockMessageQueueListenerFactory = new Mock<MessageQueueListenerFactory>();
MockMessageQueueListenerFactory.Setup(x => x.CreateRabbitMQListener())
.Returns<IMessageQueueListener>(null);
Subject.MessageQueueListenerFactory = MockMessageQueueListenerFactory.Object;
}
[Test]
public void ShouldStartListener()
{
Subject.ListenerTaskCount = 1;
Subject.StartListener();
MockMessageQueueListenerFactory.Verify(x => x.CreateRabbitMQListener(), Times.Once);
}
[Test]
public void ShouldStartMultipleListeners()
{
var listenerTaskCount = 3;
Subject.ListenerTaskCount = listenerTaskCount;
Subject.StartListener();
MockMessageQueueListenerFactory.Verify(x => x.CreateRabbitMQListener(),
Times.Exactly(listenerTaskCount));
}
[Test]
public void ShouldSetCancellationTokenOnDispose()
{
Subject.CancellationTokenSource = new CancellationTokenSource();
Subject.Dispose();
Assert.That(Subject.CancellationTokenSource.IsCancellationRequested, Is.True);
}
}
}
| mit | C# |
fdf7189ab90abd138a1b2e629a0f807f60fc0ca2 | Add get best id method for season images. | henrikfroehling/TraktApiSharp | Source/Lib/TraktApiSharp/Objects/Get/Shows/Seasons/TraktSeasonImages.cs | Source/Lib/TraktApiSharp/Objects/Get/Shows/Seasons/TraktSeasonImages.cs | namespace TraktApiSharp.Objects.Get.Shows.Seasons
{
using Basic;
using Newtonsoft.Json;
/// <summary>A collection of images and image sets for a Trakt season.</summary>
public class TraktSeasonImages
{
/// <summary>Gets or sets the screenshot image set.</summary>
[JsonProperty(PropertyName = "poster")]
public TraktImageSet Poster { get; set; }
/// <summary>Gets or sets the thumb image.</summary>
[JsonProperty(PropertyName = "thumb")]
public TraktImage Thumb { get; set; }
}
}
| namespace TraktApiSharp.Objects.Get.Shows.Seasons
{
using Basic;
using Newtonsoft.Json;
/// <summary>
/// A collection of images for a Trakt season.
/// </summary>
public class TraktSeasonImages
{
/// <summary>
/// A poster image set for various sizes.
/// </summary>
[JsonProperty(PropertyName = "poster")]
public TraktImageSet Poster { get; set; }
/// <summary>
/// A thumbnail image.
/// </summary>
[JsonProperty(PropertyName = "thumb")]
public TraktImage Thumb { get; set; }
}
}
| mit | C# |
3da0e277eccc7ea96069962a60ef39f4ccaa0fa0 | Update ExchangeRateRepository.cs | tiksn/TIKSN-Framework | TIKSN.Core/Finance/ForeignExchange/Data/Mongo/ExchangeRateRepository.cs | TIKSN.Core/Finance/ForeignExchange/Data/Mongo/ExchangeRateRepository.cs | using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using TIKSN.Data.Mongo;
namespace TIKSN.Finance.ForeignExchange.Data.Mongo
{
public class ExchangeRateRepository : MongoRepository<ExchangeRateEntity, Guid>, IExchangeRateRepository
{
public ExchangeRateRepository(
IMongoClientSessionProvider mongoClientSessionProvider,
IMongoDatabaseProvider mongoDatabaseProvider) : base(
mongoClientSessionProvider,
mongoDatabaseProvider,
"ExchangeRates")
{
}
public Task<IReadOnlyCollection<ExchangeRateEntity>> SearchAsync(
Guid foreignExchangeID,
string baseCurrencyCode,
string counterCurrencyCode,
DateTimeOffset dateFrom,
DateTimeOffset dateTo,
CancellationToken cancellationToken)
{
var filter = Builders<ExchangeRateEntity>.Filter.And(
Builders<ExchangeRateEntity>.Filter.Eq(item => item.ForeignExchangeID, foreignExchangeID),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.BaseCurrencyCode, baseCurrencyCode),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.CounterCurrencyCode, counterCurrencyCode),
Builders<ExchangeRateEntity>.Filter.Gte(item => item.AsOn, dateFrom),
Builders<ExchangeRateEntity>.Filter.Lte(item => item.AsOn, dateTo));
return base.SearchAsync(filter, cancellationToken);
}
}
}
| using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using TIKSN.Data.Mongo;
namespace TIKSN.Finance.ForeignExchange.Data.Mongo
{
public class ExchangeRateRepository : MongoRepository<ExchangeRateEntity, Guid>, IExchangeRateRepository
{
public ExchangeRateRepository(
IMongoClientSessionProvider mongoClientSessionProvider,
IMongoDatabaseProvider mongoDatabaseProvider) : base(
mongoClientSessionProvider,
mongoDatabaseProvider,
"ExchangeRates")
{
}
public Task<ExchangeRateEntity> GetOrDefaultAsync(
Guid foreignExchangeID,
string baseCurrencyCode,
string counterCurrencyCode,
DateTimeOffset asOn,
CancellationToken cancellationToken)
{
var filter = Builders<ExchangeRateEntity>.Filter.And(
Builders<ExchangeRateEntity>.Filter.Eq(item => item.ForeignExchangeID, foreignExchangeID),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.BaseCurrencyCode, baseCurrencyCode),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.CounterCurrencyCode, counterCurrencyCode),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.AsOn, asOn));
return base.SingleOrDefaultAsync(filter, cancellationToken);
}
public Task<IReadOnlyCollection<ExchangeRateEntity>> SearchAsync(
Guid foreignExchangeID,
string baseCurrencyCode,
string counterCurrencyCode,
DateTimeOffset dateFrom,
DateTimeOffset dateTo,
CancellationToken cancellationToken)
{
var filter = Builders<ExchangeRateEntity>.Filter.And(
Builders<ExchangeRateEntity>.Filter.Eq(item => item.ForeignExchangeID, foreignExchangeID),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.BaseCurrencyCode, baseCurrencyCode),
Builders<ExchangeRateEntity>.Filter.Eq(item => item.CounterCurrencyCode, counterCurrencyCode),
Builders<ExchangeRateEntity>.Filter.Gte(item => item.AsOn, dateFrom),
Builders<ExchangeRateEntity>.Filter.Lte(item => item.AsOn, dateTo));
return base.SearchAsync(filter, cancellationToken);
}
}
}
| mit | C# |
b8e354eac15733598353242318ec15328421fcb4 | fix the logic of application stopping | thinking-home/system,thinking-home/system,thinking-home/system | ThinkingHome.Console/Program.cs | ThinkingHome.Console/Program.cs | using System;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using ThinkingHome.Core.Infrastructure;
namespace ThinkingHome.Console
{
internal class Program
{
public static void Main(string[] args)
{
// init and start
var config = new HomeConfiguration();
var app = new HomeApplication();
app.StartServices(config);
// finalize
void Shutdown()
{
System.Console.WriteLine("\nApplication is shutting down...");
app.StopServices();
System.Console.WriteLine("Done");
}
AssemblyLoadContext.Default.Unloading += context => { Shutdown(); };
System.Console.CancelKeyPress += (sender, eventArgs) => { Shutdown(); };
// wait
System.Console.WriteLine("Service is available. Press Ctrl+C to exit.");
var done = new AutoResetEvent(false);
done.WaitOne();
}
}
}
| using System;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using ThinkingHome.Core.Infrastructure;
namespace ThinkingHome.Console
{
internal class Program
{
public static void Main(string[] args)
{
// init and start
var config = new HomeConfiguration();
var app = new HomeApplication();
app.StartServices(config);
// finalize
Action shutdown = () =>
{
System.Console.WriteLine("Application is shutting down...");
app.StopServices();
System.Console.WriteLine("Done");
};
AssemblyLoadContext.Default.Unloading += context => { shutdown(); };
System.Console.CancelKeyPress += (sender, eventArgs) => { shutdown(); };
// wait
if (args.Any(value => value == "-enter"))
{
System.Console.WriteLine("Service is available. Press ENTER to exit.");
System.Console.ReadLine();
}
else
{
System.Console.WriteLine("Service is available. Press Ctrl+C to exit.");
var done = new AutoResetEvent(false);
done.WaitOne();
}
}
}
}
| mit | C# |
27ba2197843de4e6dc5b55ccd3f6d45f5ecdff99 | reorder modal | geffzhang/Opserver,VictoriaD/Opserver,rducom/Opserver,GABeech/Opserver,jeddytier4/Opserver,manesiotise/Opserver,rducom/Opserver,opserver/Opserver,VictoriaD/Opserver,geffzhang/Opserver,opserver/Opserver,manesiotise/Opserver,opserver/Opserver,mqbk/Opserver,mqbk/Opserver,GABeech/Opserver,jeddytier4/Opserver,manesiotise/Opserver | Opserver/Views/SQL/Databases.Modal.cshtml | Opserver/Views/SQL/Databases.Modal.cshtml | @using StackExchange.Opserver.Data.SQL
@using StackExchange.Opserver.Views.SQL
@model DatabasesModel
@{
var db = Model.Database;
}
<h4 class="modal-title">
Database details for @db
</h4>
@helper RenderLink(DatabasesModel.Views view, string text, bool disabled = false)
{
if (disabled)
{
<a href="javascript:void(0)" class="text-muted disabled">@text</a>
}
else
{
<a href="#/db/@Model.Database/@view.ToString().ToLower()" class="@(view == Model.View ? "active" : "")">@text</a>
}
}
<div class="row">
<div class="navbar-left col-md-2">
@RenderLink(DatabasesModel.Views.Tables, "Tables")
@RenderLink(DatabasesModel.Views.Views, "Views")
@RenderLink(DatabasesModel.Views.StoredProcedures, "Stored Procs")
@RenderLink(DatabasesModel.Views.Backups, "Backups")
@RenderLink(DatabasesModel.Views.Restores, "Restores")
@RenderLink(DatabasesModel.Views.Storage, "Storage")
@RenderLink(DatabasesModel.Views.MissingIndexes, "Missing Indexes", Model.Instance.Version < Singleton<SQLInstance.MissingIndex>.Instance.MinVersion)
@RenderLink(DatabasesModel.Views.UnusedIndexes, "Unused Indexes", true)
@RenderLink(DatabasesModel.Views.BlitzIndex, "Blitz Index", true)
</div>
<div class="col-md-10 js-database-modal-right">
@RenderBody()
</div>
</div> | @using StackExchange.Opserver.Data.SQL
@using StackExchange.Opserver.Views.SQL
@model DatabasesModel
@{
var db = Model.Database;
}
<h4 class="modal-title">
Database details for @db
</h4>
@helper RenderLink(DatabasesModel.Views view, string text, bool disabled = false)
{
if (disabled)
{
<a href="javascript:void(0)" class="text-muted disabled">@text</a>
}
else
{
<a href="#/db/@Model.Database/@view.ToString().ToLower()" class="@(view == Model.View ? "active" : "")">@text</a>
}
}
<div class="row">
<div class="navbar-left col-md-2">
@RenderLink(DatabasesModel.Views.Tables, "Tables")
@RenderLink(DatabasesModel.Views.Backups, "Backups")
@RenderLink(DatabasesModel.Views.Restores, "Restores")
@RenderLink(DatabasesModel.Views.Views, "Views")
@RenderLink(DatabasesModel.Views.StoredProcedures, "Stored Procedures")
@RenderLink(DatabasesModel.Views.Storage, "Storage")
@RenderLink(DatabasesModel.Views.MissingIndexes, "Missing Indexes", Model.Instance.Version < Singleton<SQLInstance.MissingIndex>.Instance.MinVersion)
@RenderLink(DatabasesModel.Views.UnusedIndexes, "Unused Indexes", true)
@RenderLink(DatabasesModel.Views.BlitzIndex, "Blitz Index", true)
</div>
<div class="col-md-10 js-database-modal-right">
@RenderBody()
</div>
</div> | mit | C# |
ebb84ce0ca1e4d43c9891339988e9e6a13d47975 | Remove Hakyll reference. | ForNeVeR/fornever.me,ForNeVeR/fornever.me,ForNeVeR/fornever.me | ForneverMind/views/_Layout.cshtml | ForneverMind/views/_Layout.cshtml | @using RazorEngine.Templating
@inherits TemplateBase
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>F. von Never — @ViewBag.Title</title>
<base href="@System.Configuration.ConfigurationManager.AppSettings["BaseUrl"]"/>
<link rel="alternate" type="application/rss+xml" href="./rss.xml" title="RSS Feed"/>
<link rel="stylesheet" type="text/css" href="./css/main.css"/>
</head>
<body>
<div id="header">
<div id="logo">
<a href="./">Инженер, программист, джентльмен</a>
</div>
<div id="navigation">
<a href="./archive.html">Посты</a>
<a href="./contact.html">Контакты</a>
<a href="./plans/index.html">Планы</a>
</div>
</div>
<div id="content">
<h1>@ViewBag.Title</h1>
@RenderBody()
</div>
<footer>
<div>
<a class="tag" href="./rss.xml">RSS</a>
<a class="tag" href="https://github.com/ForNeVeR/fornever.me">GitHub</a>
</div>
<div>
Сайт использует библиотеку
<a href="http://docs.freya.io/en/latest/">Freya</a>
</div>
</footer>
@RenderSection("scripts", false)
</body>
</html>
| @using RazorEngine.Templating
@inherits TemplateBase
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>F. von Never — @ViewBag.Title</title>
<base href="@System.Configuration.ConfigurationManager.AppSettings["BaseUrl"]"/>
<link rel="alternate" type="application/rss+xml" href="./rss.xml" title="RSS Feed"/>
<link rel="stylesheet" type="text/css" href="./css/main.css"/>
</head>
<body>
<div id="header">
<div id="logo">
<a href="./">Инженер, программист, джентльмен</a>
</div>
<div id="navigation">
<a href="./archive.html">Посты</a>
<a href="./contact.html">Контакты</a>
<a href="./plans/index.html">Планы</a>
</div>
</div>
<div id="content">
<h1>@ViewBag.Title</h1>
@RenderBody()
</div>
<footer>
<div>
<a class="tag" href="./rss.xml">RSS</a>
<a class="tag" href="https://github.com/ForNeVeR/fornever.me">GitHub</a>
</div>
<div>
Сайт сгенерирован при помощи
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</footer>
@RenderSection("scripts", false)
</body>
</html>
| mit | C# |
c3c881149049c58982e282269ecd6cbcc0314b33 | Fix test data path when building in Unity plugin | JetBrains/resharper-unity,JetBrains/resharper-unity,JetBrains/resharper-unity | resharper/resharper-yaml/test/src/TestEnvironment.cs | resharper/resharper-yaml/test/src/TestEnvironment.cs | using JetBrains.Application.BuildScript.Application.Zones;
using JetBrains.ReSharper.TestFramework;
using JetBrains.TestFramework;
using JetBrains.TestFramework.Application.Zones;
using NUnit.Framework;
[assembly: RequiresSTA]
// This attribute is marked obsolete but is still supported. Use is discouraged in preference to convention, but the
// convention doesn't work for us. That convention is to walk up the tree from the executing assembly and look for a
// relative path called "test/data". This doesn't work because our common "build" folder is one level above our
// "test/data" folder, so it doesn't get found. We want to keep the common "build" folder, but allow multiple "modules"
// with separate "test/data" folders. E.g. "resharper-unity" and "resharper-yaml"
// TODO: This makes things work when building as part of the Unity project, but breaks standalone
// Maybe it should be using product/subplatform markers?
#pragma warning disable 618
[assembly: TestDataPathBase("resharper-yaml/test/data")]
#pragma warning restore 618
namespace JetBrains.ReSharper.Plugins.Yaml.Tests
{
[ZoneDefinition]
public interface IYamlTestZone : ITestsEnvZone, IRequire<PsiFeatureTestZone>
{
}
[SetUpFixture]
public class TestEnvironment : ExtensionTestEnvironmentAssembly<IYamlTestZone>
{
}
}
| using JetBrains.Application.BuildScript.Application.Zones;
using JetBrains.ReSharper.TestFramework;
using JetBrains.TestFramework;
using JetBrains.TestFramework.Application.Zones;
using NUnit.Framework;
[assembly: RequiresSTA]
namespace JetBrains.ReSharper.Plugins.Yaml.Tests
{
[ZoneDefinition]
public interface IYamlTestZone : ITestsEnvZone, IRequire<PsiFeatureTestZone>
{
}
[SetUpFixture]
public class TestEnvironment : ExtensionTestEnvironmentAssembly<IYamlTestZone>
{
}
}
| apache-2.0 | C# |
3e93dd543d0ce3827ac9bf069824bee617cfb464 | Test construction is internal. | fixie/fixie | src/Fixie/Test.cs | src/Fixie/Test.cs | namespace Fixie
{
using System.Reflection;
public class Test
{
public string Class { get; }
public string Method { get; }
public string Name { get; }
internal Test(MethodInfo method)
{
Class = method.ReflectedType!.FullName!;
Method = method.Name;
Name = Class + "." + Method;
}
internal Test(string @class, string method)
{
Class = @class;
Method = method;
Name = Class + "." + Method;
}
internal Test(string name)
{
var indexOfMemberSeparator = name.LastIndexOf(".");
var className = name.Substring(0, indexOfMemberSeparator);
var methodName = name.Substring(indexOfMemberSeparator + 1);
Class = className;
Method = methodName;
Name = name;
}
}
} | namespace Fixie
{
using System.Reflection;
public class Test
{
public string Class { get; }
public string Method { get; }
public string Name { get; }
public Test(MethodInfo method)
{
Class = method.ReflectedType!.FullName!;
Method = method.Name;
Name = Class + "." + Method;
}
public Test(string @class, string method)
{
Class = @class;
Method = method;
Name = Class + "." + Method;
}
public Test(string name)
{
var indexOfMemberSeparator = name.LastIndexOf(".");
var className = name.Substring(0, indexOfMemberSeparator);
var methodName = name.Substring(indexOfMemberSeparator + 1);
Class = className;
Method = methodName;
Name = name;
}
}
} | mit | C# |
583a86ec3ebe014033bc2f5f2dac073d4e5b8d5f | Fix typo. | urasandesu/Enkidu | Urasandesu.Enkidu/Resources.cs | Urasandesu.Enkidu/Resources.cs | /*
* File: Resources.cs
*
* Author: Akira Sugiura ([email protected])
*
*
* Copyright (c) 2017 Akira Sugiura
*
* This software is MIT License.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Globalization;
using System.Resources;
namespace Urasandesu.Enkidu
{
class Resources
{
static ResourceManager ms_resourceManager;
public Resources()
{ }
public static ResourceManager ResourceManager
{
get
{
if (ReferenceEquals(ms_resourceManager, null))
ms_resourceManager = new ResourceManager("Urasandesu.Enkidu.Resources", typeof(Resources).Assembly);
return ms_resourceManager;
}
}
public static CultureInfo Culture { get; set; }
public static string GetString(string name)
{
return ResourceManager.GetString(name, Culture);
}
}
}
| /*
* File: Synchronizable.cs
*
* Author: Akira Sugiura ([email protected])
*
*
* Copyright (c) 2017 Akira Sugiura
*
* This software is MIT License.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Globalization;
using System.Resources;
namespace Urasandesu.Enkidu
{
class Resources
{
static ResourceManager m_resourceManager;
public Resources()
{ }
public static ResourceManager ResourceManager
{
get
{
if (ReferenceEquals(m_resourceManager, null))
m_resourceManager = new ResourceManager("Urasandesu.Enkidu.Resources", typeof(Resources).Assembly);
return m_resourceManager;
}
}
public static CultureInfo Culture { get; set; }
public static string GetString(string name)
{
return ResourceManager.GetString(name, Culture);
}
}
}
| mit | C# |
b6ca01b1a3c11b759ac3dff739baf720682984c4 | Fix resolver URI | ajlopez/Aktores | Samples/WebCrawler/WebCrawler/Resolver.cs | Samples/WebCrawler/WebCrawler/Resolver.cs | namespace WebCrawler
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Aktores.Core;
public class Resolver : Actor
{
private List<Uri> downloadedAddresses;
private string host;
public Resolver()
{
this.downloadedAddresses = new List<Uri>();
}
public ActorRef Downloader { get; set; }
public void Process(string url)
{
Console.WriteLine("[Resolver] processing " + url);
Uri target;
try
{
target = new Uri(url);
}
catch (Exception ex)
{
Console.WriteLine(
string.Format(CultureInfo.InvariantCulture, "URL rejected {0}: not an URI", url));
return;
}
if ((target.Scheme != Uri.UriSchemeHttp) &&
(target.Scheme != Uri.UriSchemeHttps))
{
Console.WriteLine(
string.Format(CultureInfo.InvariantCulture, "URL rejected {0}: unsupported protocol", url));
return;
}
if (this.host == null)
this.host = target.Host;
else if (this.host != target.Host)
{
Console.WriteLine(
string.Format(CultureInfo.InvariantCulture, "URL rejected {0}: external host", url));
return;
}
if (this.downloadedAddresses.Contains(target))
return;
this.downloadedAddresses.Add(target);
this.Downloader.Tell(url);
}
public override void Receive(object message)
{
this.Process((string)message);
}
}
} | namespace WebCrawler
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Aktores.Core;
public class Resolver : Actor
{
private List<Uri> downloadedAddresses;
public Resolver()
{
this.downloadedAddresses = new List<Uri>();
}
public ActorRef Downloader { get; set; }
public void Process(string url)
{
Console.WriteLine("[Resolver] processing " + url);
Uri target = new Uri(url);
if ((target.Scheme != Uri.UriSchemeHttp) &&
(target.Scheme != Uri.UriSchemeHttps))
{
Console.WriteLine(
string.Format(CultureInfo.InvariantCulture, "URL rejected {0}: unsupported protocol", url));
return;
}
if (this.downloadedAddresses.Contains(target))
return;
this.downloadedAddresses.Add(target);
this.Downloader.Tell(url);
}
public override void Receive(object message)
{
this.Process((string)message);
}
}
} | mit | C# |
20301be25ca45cc67496715ef1dd0d6423e1323a | Fix ListView item styling on Android | warappa/XamlCSS | XamlCSS.XamarinForms/VisualTreeCell.cs | XamlCSS.XamarinForms/VisualTreeCell.cs | using System;
using Xamarin.Forms;
using XamlCSS.Windows.Media;
namespace XamlCSS.XamarinForms
{
public static class VisualTreeCell
{
public static readonly BindableProperty IncludeProperty =
BindableProperty.CreateAttached(
"Include",
typeof(bool),
typeof(VisualTreeCell),
false,
propertyChanged: OnIncludeChanged);
public static bool GetInclude(BindableObject view)
{
return (bool)view.GetValue(IncludeProperty);
}
public static void SetInclude(BindableObject view, bool value)
{
view.SetValue(IncludeProperty, value);
}
static void OnIncludeChanged(BindableObject view, object oldValue, object newValue)
{
var entry = view as Cell;
if (entry == null)
{
return;
}
bool register = (bool)newValue;
if (register)
{
entry.Appearing += Entry_Appearing;
entry.Disappearing += Entry_Disappearing;
entry.PropertyChanged += Entry_PropertyChanged;
}
else
{
entry.Appearing -= Entry_Appearing;
entry.Disappearing -= Entry_Disappearing;
entry.PropertyChanged -= Entry_PropertyChanged;
}
}
private static void Entry_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Parent")
{
var s = sender as Element;
if (s.Parent != null)
VisualTreeHelper.Include(sender as Element);
else
VisualTreeHelper.Exclude(sender as Element);
}
}
private static void Entry_Disappearing(object sender, EventArgs e)
{
//Debug.WriteLine("Entry_Disappearing");
VisualTreeHelper.Exclude(sender as Element);
}
private static void Entry_Appearing(object sender, EventArgs e)
{
VisualTreeHelper.Include(sender as Element);
}
}
}
| using System;
using Xamarin.Forms;
using XamlCSS.Windows.Media;
namespace XamlCSS.XamarinForms
{
public static class VisualTreeCell
{
public static readonly BindableProperty IncludeProperty =
BindableProperty.CreateAttached(
"Include",
typeof(bool),
typeof(VisualTreeCell),
false,
propertyChanged: OnIncludeChanged);
public static bool GetInclude(BindableObject view)
{
return (bool)view.GetValue(IncludeProperty);
}
public static void SetInclude(BindableObject view, bool value)
{
view.SetValue(IncludeProperty, value);
}
static void OnIncludeChanged(BindableObject view, object oldValue, object newValue)
{
var entry = view as Cell;
if (entry == null)
{
return;
}
bool register = (bool)newValue;
if (register)
{
entry.Appearing += Entry_Appearing;
entry.Disappearing += Entry_Disappearing;
}
else
{
entry.Appearing -= Entry_Appearing;
entry.Disappearing -= Entry_Disappearing;
}
}
private static void Entry_Disappearing(object sender, EventArgs e)
{
VisualTreeHelper.Exclude(sender as Element);
}
private static void Entry_Appearing(object sender, EventArgs e)
{
VisualTreeHelper.Include(sender as Element);
}
}
}
| mit | C# |
bf6a1af030ace41d55967c3005b3fa524d6352ec | remove iOS specific top padding since we're using a nav bar | IrvingtonProgramming/InteractApp,IrvingtonProgramming/InteractApp,IrvingtonProgramming/InteractApp | InteractApp/EventListPage.xaml.cs | InteractApp/EventListPage.xaml.cs | using System;
using System.Collections.Generic;
using System.Diagnostics;
using Xamarin.Forms;
namespace InteractApp
{
public partial class EventListPage : ContentPage
{
private static readonly string EventDesc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
public List<Event> SampleList = new List<Event> () {
Event.newEvent(0, "http://www.grey-hare.co.uk/wp-content/uploads/2012/09/Event-management.png", "Event0", DateTime.Now, "Fremont, CA", EventDesc, new List<String> (){ "service" }),
new Event()
};
public EventListPage ()
{
InitializeComponent ();
this.Title = "Events";
ToolbarItems.Add(new ToolbarItem {
Text = "My Info",
Order = ToolbarItemOrder.Primary,
});
ToolbarItems.Add(new ToolbarItem {
Text = "My Events",
Order = ToolbarItemOrder.Primary,
});
EventList.ItemsSource = SampleList;
EventList.ItemTapped += async (sender, e) => {
await DisplayAlert("Tapped", ((Event) e.Item).Name + " row was tapped", "OK");
Debug.WriteLine("Tapped: " + ((Event) e.Item).Name);
((ListView)sender).SelectedItem = null; // de-select the row
};
Padding = new Thickness (0,0,0,0);
}
}
}
| using System;
using System.Collections.Generic;
using System.Diagnostics;
using Xamarin.Forms;
namespace InteractApp
{
public partial class EventListPage : ContentPage
{
private static readonly string EventDesc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
public List<Event> SampleList = new List<Event> () {
Event.newEvent(0, "http://www.grey-hare.co.uk/wp-content/uploads/2012/09/Event-management.png", "Event0", DateTime.Now, "Fremont, CA", EventDesc, new List<String> (){ "service" }),
new Event()
};
public EventListPage ()
{
InitializeComponent ();
this.Title = "Events";
ToolbarItems.Add(new ToolbarItem {
Text = "My Info",
Order = ToolbarItemOrder.Primary,
});
ToolbarItems.Add(new ToolbarItem {
Text = "My Events",
Order = ToolbarItemOrder.Primary,
});
EventList.ItemsSource = SampleList;
EventList.ItemTapped += async (sender, e) => {
await DisplayAlert("Tapped", ((Event) e.Item).Name + " row was tapped", "OK");
Debug.WriteLine("Tapped: " + ((Event) e.Item).Name);
((ListView)sender).SelectedItem = null; // de-select the row
};
Padding = new Thickness (0,Device.OnPlatform(20, 0, 0),0,0);
}
}
}
| mit | C# |
7ec68beaa4825a2a9bcb88c8902d8a46bcba7065 | Add download_url and content_type for file upload questions | bcemmett/SurveyMonkeyApi-v3 | SurveyMonkey/Containers/ResponseAnswer.cs | SurveyMonkey/Containers/ResponseAnswer.cs | using Newtonsoft.Json;
namespace SurveyMonkey.Containers
{
[JsonConverter(typeof(TolerantJsonConverter))]
public class ResponseAnswer
{
public long? ChoiceId { get; set; }
public long? RowId { get; set; }
public long? ColId { get; set; }
public long? OtherId { get; set; }
public string Text { get; set; }
public bool? IsCorrect { get; set; }
public int? Score { get; set; }
public string DownloadUrl { get; set; }
public string ContentType { get; set; }
public string SimpleText { get; set; }
[JsonIgnore]
internal object TagData { get; set; }
public ChoiceMetadata ChoiceMetadata { get; set; }
}
} | using Newtonsoft.Json;
namespace SurveyMonkey.Containers
{
[JsonConverter(typeof(TolerantJsonConverter))]
public class ResponseAnswer
{
public long? ChoiceId { get; set; }
public long? RowId { get; set; }
public long? ColId { get; set; }
public long? OtherId { get; set; }
public string Text { get; set; }
public bool? IsCorrect { get; set; }
public int? Score { get; set; }
public string SimpleText { get; set; }
[JsonIgnore]
internal object TagData { get; set; }
public ChoiceMetadata ChoiceMetadata { get; set; }
}
} | mit | C# |
1e16776254400ce5c6db206fbfc8777c22642cbc | Use with params from APL | lstefano71/Nowin,lstefano71/Nowin,lstefano71/Nowin | ZipFS/Helpers/Helpers.cs | ZipFS/Helpers/Helpers.cs | using System;
using Owin;
using Microsoft.Owin;
using System.Threading.Tasks;
using WildHeart.Owin.Middleware;
using Microsoft.Owin.StaticFiles;
using System.Collections.Generic;
namespace WildHeart.Owin
{
public static class APLHelper
{
public static void AddMimeTypes(FileServerOptions opts, string def)
{
AddMimeTypes(opts, new string[] { def });
}
public static void AddMimeTypes(FileServerOptions opts, string[] tdefs)
{
AddMimeTypes(opts, tdefs as IList<string>);
}
public static void AddMimeTypes(FileServerOptions opts,IList<string> tdefs)
{
var ctp = new Microsoft.Owin.StaticFiles.ContentTypes.FileExtensionContentTypeProvider();
foreach (var def in tdefs) {
var d = def.Split(';');
ctp.Mappings["." + d[0]] = d[1];
}
opts.StaticFileOptions.ContentTypeProvider = ctp;
}
public static IAppBuilder UseCompression(IAppBuilder app)
{
app.UseSendFileFallback();
return app.UseStaticCompression();
}
public static IAppBuilder UseErrorPage(IAppBuilder app)
{
return app.UseErrorPage(new Microsoft.Owin.Diagnostics.ErrorPageOptions {
SourceCodeLineCount = 20,
ShowExceptionDetails = true,
ShowCookies = true,
ShowEnvironment = true,
ShowHeaders = true,
ShowQuery = true,
ShowSourceCode = true
});
}
public static IAppBuilder Use(IAppBuilder app, Func<IOwinContext,object[], bool> callback,params object[] args)
{
return app.Use((ctx, next) => {
bool res = callback(ctx,args);
if (!res)
return next();
return Task.Delay(0);
});
}
public static IAppBuilder UseFromPool(IAppBuilder app, string pool, string fnname, Func<string, string, IOwinContext, bool> callback)
{
return app.Use((ctx, next) => {
bool res = callback(pool, fnname, ctx);
if (!res)
return next();
return Task.Delay(0);
});
}
}
}
| using System;
using Owin;
using Microsoft.Owin;
using System.Threading.Tasks;
using WildHeart.Owin.Middleware;
using Microsoft.Owin.StaticFiles;
using System.Collections.Generic;
namespace WildHeart.Owin
{
public static class APLHelper
{
public static void AddMimeTypes(FileServerOptions opts, string def)
{
AddMimeTypes(opts, new string[] { def });
}
public static void AddMimeTypes(FileServerOptions opts, string[] tdefs)
{
AddMimeTypes(opts, tdefs as IList<string>);
}
public static void AddMimeTypes(FileServerOptions opts,IList<string> tdefs)
{
var ctp = new Microsoft.Owin.StaticFiles.ContentTypes.FileExtensionContentTypeProvider();
foreach (var def in tdefs) {
var d = def.Split(';');
ctp.Mappings["." + d[0]] = d[1];
}
opts.StaticFileOptions.ContentTypeProvider = ctp;
}
public static IAppBuilder UseCompression(IAppBuilder app)
{
app.UseSendFileFallback();
return app.UseStaticCompression();
}
public static IAppBuilder UseErrorPage(IAppBuilder app)
{
return app.UseErrorPage(new Microsoft.Owin.Diagnostics.ErrorPageOptions {
SourceCodeLineCount = 20,
ShowExceptionDetails = true,
ShowCookies = true,
ShowEnvironment = true,
ShowHeaders = true,
ShowQuery = true,
ShowSourceCode = true
});
}
public static IAppBuilder Use(IAppBuilder app, Func<IOwinContext,bool> callback)
{
//app.Use<HeaderMiddleware>("X-UA-Compatible", "IE=Edge");
return app.Use((ctx, next) => {
bool res = callback(ctx);
if (!res)
return next();
return Task.Delay(0);
});
}
}
}
| mit | C# |
a9714d97260ba306e7821a9bcbcc66df1436b80c | Fix code formatting in ToxVersion. | uruk/SharpTox,Impyy/SharpTox | SharpTox/Core/ToxVersion.cs | SharpTox/Core/ToxVersion.cs | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharpTox.Core
{
public class ToxVersion
{
public int Major { get; private set; }
public int Minor { get; private set; }
public int Patch { get; private set; }
public static ToxVersion Current
{
get
{
return new ToxVersion(
(int)ToxFunctions.VersionMajor(),
(int)ToxFunctions.VersionMinor(),
(int)ToxFunctions.VersionPatch());
}
}
public bool IsCompatible()
{
return ToxFunctions.VersionIsCompatible((uint)Major, (uint)Minor, (uint)Patch);
}
public ToxVersion(int major, int minor, int patch)
{
Major = major;
Minor = minor;
Patch = patch;
}
}
}
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharpTox.Core
{
public class ToxVersion
{
public int Major { get; private set; }
public int Minor { get; private set; }
public int Patch { get; private set; }
public static ToxVersion Current
{
get
{
return new ToxVersion(
(int)ToxFunctions.VersionMajor(),
(int)ToxFunctions.VersionMinor(),
(int)ToxFunctions.VersionPatch());
}
}
public bool IsCompatible() {
return ToxFunctions.VersionIsCompatible((uint)Major, (uint)Minor, (uint)Patch);
}
public ToxVersion(int major, int minor, int patch)
{
Major = major;
Minor = minor;
Patch = patch;
}
}
}
| mit | C# |
fc81e477a3bf7daf7e9f158812e6b7e5e5c70055 | increase version | jittuu/RGeoIP | RGeoIP/Properties/AssemblyInfo.cs | RGeoIP/Properties/AssemblyInfo.cs | using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RGeoIP")]
[assembly: AssemblyDescription("Store IP Ranges in Redis as sorted sets for fast lookup")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RGeoIP")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2361907f-2215-4f65-a7ac-28191ed1ca5f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
| using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RGeoIP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RGeoIP")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2361907f-2215-4f65-a7ac-28191ed1ca5f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| mit | C# |
e7f95a214acdb74713c687125e587947113ab2c8 | Remove obsolete message from private function | ivandrofly/octokit.net,M-Zuber/octokit.net,TattsGroup/octokit.net,shana/octokit.net,thedillonb/octokit.net,ivandrofly/octokit.net,editor-tools/octokit.net,octokit/octokit.net,khellang/octokit.net,shiftkey/octokit.net,eriawan/octokit.net,TattsGroup/octokit.net,adamralph/octokit.net,SmithAndr/octokit.net,thedillonb/octokit.net,gdziadkiewicz/octokit.net,dampir/octokit.net,SamTheDev/octokit.net,shiftkey/octokit.net,devkhan/octokit.net,editor-tools/octokit.net,alfhenrik/octokit.net,eriawan/octokit.net,shiftkey-tester/octokit.net,chunkychode/octokit.net,shiftkey-tester-org-blah-blah/octokit.net,chunkychode/octokit.net,shiftkey-tester/octokit.net,shana/octokit.net,khellang/octokit.net,dampir/octokit.net,shiftkey-tester-org-blah-blah/octokit.net,M-Zuber/octokit.net,alfhenrik/octokit.net,Sarmad93/octokit.net,Sarmad93/octokit.net,devkhan/octokit.net,gdziadkiewicz/octokit.net,rlugojr/octokit.net,rlugojr/octokit.net,octokit/octokit.net,SmithAndr/octokit.net,SamTheDev/octokit.net | Octokit/Helpers/ModelExtensions.cs | Octokit/Helpers/ModelExtensions.cs | using System;
using System.Text.RegularExpressions;
namespace Octokit
{
// TODO: this is only related to SSH keys, we should rename this
/// <summary>
/// Extensions for working with SSH keys
/// </summary>
public static class ModelExtensions
{
#if NETFX_CORE
static readonly Regex sshKeyRegex = new Regex(@"ssh-[rd]s[as] (?<data>\S+) ?(?<name>.*)$");
#else
static readonly Regex sshKeyRegex = new Regex(@"ssh-[rd]s[as] (?<data>\S+) ?(?<name>.*)$", RegexOptions.Compiled);
#endif
/// <summary>
/// Extract SSH key information from the API response
/// </summary>
/// <param name="sshKey">Key details received from API</param>
[Obsolete("This method will be removed in a future release.")]
public static SshKeyInfo GetKeyDataAndName(this SshKey sshKey)
{
Ensure.ArgumentNotNull(sshKey, "sshKey");
var key = sshKey.Key;
if (key == null) return null;
var match = sshKeyRegex.Match(key);
return (match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null);
}
/// <summary>
/// Compare two SSH keys to see if they are equal
/// </summary>
/// <param name="key">Reference SSH key</param>
/// <param name="otherKey">Key to compare</param>
[Obsolete("This method will be removed in a future release.")]
public static bool HasSameDataAs(this SshKey key, SshKey otherKey)
{
Ensure.ArgumentNotNull(key, "key");
if (otherKey == null) return false;
var keyData = key.GetKeyData();
return keyData != null && keyData == otherKey.GetKeyData();
}
static string GetKeyData(this SshKey key)
{
var keyInfo = key.GetKeyDataAndName();
return keyInfo == null ? null : keyInfo.Data;
}
}
}
| using System;
using System.Text.RegularExpressions;
namespace Octokit
{
// TODO: this is only related to SSH keys, we should rename this
/// <summary>
/// Extensions for working with SSH keys
/// </summary>
public static class ModelExtensions
{
#if NETFX_CORE
static readonly Regex sshKeyRegex = new Regex(@"ssh-[rd]s[as] (?<data>\S+) ?(?<name>.*)$");
#else
static readonly Regex sshKeyRegex = new Regex(@"ssh-[rd]s[as] (?<data>\S+) ?(?<name>.*)$", RegexOptions.Compiled);
#endif
/// <summary>
/// Extract SSH key information from the API response
/// </summary>
/// <param name="sshKey">Key details received from API</param>
[Obsolete("This method will be removed in a future release.")]
public static SshKeyInfo GetKeyDataAndName(this SshKey sshKey)
{
Ensure.ArgumentNotNull(sshKey, "sshKey");
var key = sshKey.Key;
if (key == null) return null;
var match = sshKeyRegex.Match(key);
return (match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null);
}
/// <summary>
/// Compare two SSH keys to see if they are equal
/// </summary>
/// <param name="key">Reference SSH key</param>
/// <param name="otherKey">Key to compare</param>
[Obsolete("This method will be removed in a future release.")]
public static bool HasSameDataAs(this SshKey key, SshKey otherKey)
{
Ensure.ArgumentNotNull(key, "key");
if (otherKey == null) return false;
var keyData = key.GetKeyData();
return keyData != null && keyData == otherKey.GetKeyData();
}
[Obsolete("This method will be removed in a future release.")]
static string GetKeyData(this SshKey key)
{
var keyInfo = key.GetKeyDataAndName();
return keyInfo == null ? null : keyInfo.Data;
}
}
}
| mit | C# |
633be5ee0b2368ef9ab46be999721d850e1172c2 | Add HTTP codes to error responses | bwatts/Totem,bwatts/Totem | Source/Totem.Web/WebApiRequest.cs | Source/Totem.Web/WebApiRequest.cs | using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
using Totem.IO;
using Totem.Runtime.Timeline;
namespace Totem.Web
{
/// <summary>
/// An process observing and publishing to the timeline in order to make a web request
/// </summary>
public abstract class WebApiRequest : Runtime.Timeline.Request
{
private Response _response;
public Response ToResponse()
{
Expect(_response).IsNotNull("Web API flow has not responded");
return _response;
}
protected void Respond(Response response)
{
Expect(_response).IsNull("Web API flow has already responded");
_response = response;
ThenDone();
}
protected void RespondOK(string reason)
{
Respond(new Response { StatusCode = HttpStatusCode.OK, ReasonPhrase = reason });
}
protected void RespondCreated(string reason)
{
Respond(new Response { StatusCode = HttpStatusCode.Created, ReasonPhrase = reason });
}
protected void RespondError(string reason)
{
Respond(new Response { StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = reason });
}
protected void RespondError(string reason, string error)
{
Log.Error("[web] 500 Internal server error: {Reason:l} {Error}", reason, error);
Respond(new Response
{
StatusCode = HttpStatusCode.InternalServerError,
ReasonPhrase = reason,
ContentType = MediaType.Plain.ToTextUtf8(),
Contents = body =>
{
using(var writer = new StreamWriter(body))
{
writer.Write(error);
}
}
});
}
protected void RespondUnprocessableEntity(string reasonPhrase)
{
Log.Error("[web] 422 Unprocessable entity: {Reason:l}", reasonPhrase);
Respond(new Response { StatusCode = HttpStatusCode.UnprocessableEntity, ReasonPhrase = reasonPhrase });
}
void When(FlowStopped e)
{
RespondError("[web] Flow stopped: " + Text.Of(e.Type), e.Error);
}
}
} | using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
using Totem.IO;
using Totem.Runtime.Timeline;
namespace Totem.Web
{
/// <summary>
/// An process observing and publishing to the timeline in order to make a web request
/// </summary>
public abstract class WebApiRequest : Runtime.Timeline.Request
{
private Response _response;
public Response ToResponse()
{
Expect(_response).IsNotNull("Web API flow has not responded");
return _response;
}
protected void Respond(Response response)
{
Expect(_response).IsNull("Web API flow has already responded");
_response = response;
ThenDone();
}
protected void RespondOK(string reason)
{
Respond(new Response { StatusCode = HttpStatusCode.OK, ReasonPhrase = reason });
}
protected void RespondCreated(string reason)
{
Respond(new Response { StatusCode = HttpStatusCode.Created, ReasonPhrase = reason });
}
protected void RespondError(string reason)
{
Respond(new Response { StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = reason });
}
protected void RespondError(string reason, string error)
{
Log.Error("[web] Internal server error: {Reason:l} {Error}", reason, error);
Respond(new Response
{
StatusCode = HttpStatusCode.InternalServerError,
ReasonPhrase = reason,
ContentType = MediaType.Plain.ToTextUtf8(),
Contents = body =>
{
using(var writer = new StreamWriter(body))
{
writer.Write(error);
}
}
});
}
protected void RespondUnprocessableEntity(string reasonPhrase)
{
Log.Error("[web] Unprocessable entity: {Reason:l}", reasonPhrase);
Respond(new Response { StatusCode = HttpStatusCode.UnprocessableEntity, ReasonPhrase = reasonPhrase });
}
void When(FlowStopped e)
{
RespondError("[web] Flow stopped: " + Text.Of(e.Type), e.Error);
}
}
} | mit | C# |
d05a136b937fd3874c3148d9eaa48667571a8c73 | fix $flatten behavior | Soluto/tweek,Soluto/tweek,Soluto/tweek,Soluto/tweek,Soluto/tweek,Soluto/tweek | Tweek.ApiService/ServingModule.cs | Tweek.ApiService/ServingModule.cs | using System;
using System.Collections.Generic;
using System.Linq;
using Engine;
using Engine.Core.Context;
using Engine.DataTypes;
using LanguageExt;
using Nancy;
using Newtonsoft.Json;
namespace Tweek.ApiService
{
public class ServingModule : NancyModule
{
public static Tuple<IReadOnlyDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>> PartitionByKey<TKey, TValue>(IDictionary<TKey,TValue> source,
Predicate<TKey> predicate)
{
IReadOnlyDictionary<bool, IReadOnlyDictionary<TKey,TValue>> dict = source.GroupBy(x => predicate(x.Key))
.ToDictionary(p => p.Key, p => (IReadOnlyDictionary<TKey,TValue>)p.ToDictionary(x=>x.Key, x=>x.Value));
return Tuple.Create(dict.TryGetValue(true).IfNone(new Dictionary<TKey, TValue>()),
dict.TryGetValue(false).IfNone(new Dictionary<TKey, TValue>()));
}
private static readonly string PREFIX = "/configurations";
public ServingModule(ITweek tweek) : base(PREFIX)
{
Get["{query*}", runAsync:true] = async (@params, ct) =>
{
var allParams = PartitionByKey(((DynamicDictionary) Request.Query).ToDictionary(), x => x.StartsWith("$"));
var modifiers = allParams.Item1;
var isFlatten = modifiers.TryGetValue("$flatten").Select(x=>bool.Parse(x.ToString())).IfNone(false);
IReadOnlyDictionary<string, string> contextParams = allParams.Item2.ToDictionary(x=>x.Key, x=>x.Value.ToString());
var identities = new HashSet<Identity>(contextParams.Where(x => !x.Key.Contains(".")).Select(x=>new Identity(x.Key, x.Value)));
GetLoadedContextByIdentityType contextProps =
identityType => key => contextParams.TryGetValue($"{identityType}.{key}");
var query = ConfigurationPath.New(((string) @params.query));
var data = await tweek.Calculate(query, identities, contextProps);
return JsonConvert.SerializeObject(!isFlatten
? TreeResult.From(data)
: data.ToDictionary(x => x.Key.ToString(), x => x.Value.ToString()));
};
}
}
} | using System.Collections.Generic;
using System.Linq;
using Engine;
using Engine.Core.Context;
using Engine.DataTypes;
using LanguageExt;
using Nancy;
using Newtonsoft.Json;
namespace Tweek.ApiService
{
public class ServingModule : NancyModule
{
private static readonly string PREFIX = "/configurations";
public ServingModule(ITweek tweek) : base(PREFIX)
{
Get["{query*}", runAsync:true] = async (@params, ct) =>
{
var isFlatten = @params["$flatten"] == true;
IReadOnlyDictionary<string,string> requestParams = ((DynamicDictionary) Request.Query).ToDictionary()
.ToDictionary(x => x.Key, x => x.Value.ToString());
var identities = new HashSet<Identity>(requestParams.Where(x => !x.Key.Contains(".")).Select(x=>new Identity(x.Key, x.Value)));
GetLoadedContextByIdentityType contextProps =
identityType => key => requestParams.TryGetValue($"{identityType}.{key}");
var query = ConfigurationPath.New(((string) @params.query));
var data = await tweek.Calculate(query, identities, contextProps);
return JsonConvert.SerializeObject(!isFlatten
? TreeResult.From(data)
: data.ToDictionary(x => x.Key.ToString(), x => x.Value.ToString()));
};
}
}
} | mit | C# |
6d28a5ea0efd604eba3d3bb5ddf7ce6148f419a1 | fix typos (#166) | skbkontur/NuGetGallery,KuduApps/NugetGallery16Fx45-DeleteMe,KuduApps/NuGetGallery,KuduApps/NuGetGallery,KuduApps/NugetGallery21Fx45-DeleteMe,KuduApps/NuGetGallery,mtian/SiteExtensionGallery,kudustress/NuGetGallery2,grenade/NuGetGallery_download-count-patch,mtian/SiteExtensionGallery,kudustress/NuGetGalleryOptmized,grenade/NuGetGallery_download-count-patch,KuduApps/NuGetGallery,projectkudu/SiteExtensionGallery,projectkudu/SiteExtensionGallery,JetBrains/ReSharperGallery,projectkudu/SiteExtensionGallery,kudustress/NuGetGallery2,ScottShingler/NuGetGallery,KuduApps/NuGetGallery,JetBrains/ReSharperGallery,ScottShingler/NuGetGallery,kudustress/NuGetGallery,ScottShingler/NuGetGallery,skbkontur/NuGetGallery,grenade/NuGetGallery_download-count-patch,JetBrains/ReSharperGallery,KuduApps/NugetGallery21Fx45-DeleteMe,KuduApps/NugetGallery16Fx45-DeleteMe,kudustress/NuGetGallery,kudustress/NuGetGalleryOptmized,skbkontur/NuGetGallery,mtian/SiteExtensionGallery | Website/Views/Pages/Home.cshtml | Website/Views/Pages/Home.cshtml | @{
ViewBag.Tab = "Home";
}
<section class="featured">
<div>
<h1>Jump Start Your Projects with NuGet</h1>
<p >NuGet is a Visual Studio extension that makes it easy to install and update open source libraries and tools in Visual Studio.</p>
<p class="sub"><em>So <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/27077b70-9dad-4c64-adcf-c7cf6bc9970c/file/37502/5/NuGet.Tools.signed.vsix">install NuGet</a> and get a jump on your next project!</em></p>
<a class="install" href="http://visualstudiogallery.msdn.microsoft.com/en-us/27077b70-9dad-4c64-adcf-c7cf6bc9970c/fil/37502/5/NuGet.Tools.signed.vsix">Install NuGet</a>
</div>
<img src="@Url.Content("~/content/images/hero.png")" alt="NuGet GUI Window" />
</section>
<section class="release">
<h2>NuGet 1.5 Released</h2>
<p>Take 5 minutes and UPGRADE NOW using the Visual Studio Extension Manager. Why? Because there's a pile of new features and it will
make your life easier! All these details and <a href="http://docs.nuget.org/docs/release-notes/nuget-1.4">more here...</a></p>
</section>
<section class="info">
<h3>About</h3>
<p>When you use NuGet to install a package, it copies the library files to your solution and automatically updates your project
(add references, change config files, etc). If you remove a package, NuGet reverses whatever changes it made so that no clutter is left.</p>
<h3>Important Notice</h3>
<p>You can develop your own package and share it via the NuGet Gallery. Read the documentation for more details on
<a title="Creating and submitting a package" href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package">how to
create and publish a package</a>. If you don’t plan on submitting a package, there’s no need to register.</p>
</section>
| @{
ViewBag.Tab = "Home";
}
<section class="featured">
<div>
<h1>Jump Start Your Projects with NuGet</h1>
<p >NuGet is a Visual Studio extension that makes it easy to install and update open source libraries and tools in Visual Studio.</p>
<p class="sub"><em>So <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/27077b70-9dad-4c64-adcf-c7cf6bc9970c/file/37502/5/NuGet.Tools.signed.vsix">install NuGet</a> and get a jump on your next project!</em></p>
<a class="install" href="http://visualstudiogallery.msdn.microsoft.com/en-us/27077b70-9dad-4c64-adcf-c7cf6bc9970c/fil/37502/5/NuGet.Tools.signed.vsix">Install NuGet</a>
</div>
<img src="@Url.Content("~/content/images/hero.png")" alt="NuGet GUI Window" />
</section>
<section class="release">
<h2>NuGet 1.5 Released</h2>
<p>Take 5 minutes and UPGRADE NOW using the Visual Studio Extension Manager. Why? Because there's a pile of new features and it will
make your life easier! All these details and <a href="http://docs.nuget.org/docs/release-notes/nuget-1.4">more here...</a></p>
</section>
<section class="info">
<h3>About</h3>
<p>When you use NuGet to install a package, it copies the library files to your solution and automatically updates your project
(add references, change config files, etc). If you remove a package, NuGet reverses whatever changes it made so that no clutter is left.</p>
<h3>Important Notice</h3>
<p>ou can develop your own package and share it via the NuGet Gallery. Read the documentation for more details on
<a title="Creating and submitting a package" href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package">how to
create and publish a package</a>. If you don’t plan on submitting a package, there’s no need to register.</p>
</section>
| apache-2.0 | C# |
798d21cf3e3c1820d9f5a28da7363a2951d38ad3 | update ConversionMethods | bryan2894-playgrnd/SimpleWeather-Xamarin,bryan2894-playgrnd/SimpleWeather-Xamarin | SimpleWeather/ConversionMethods.cs | SimpleWeather/ConversionMethods.cs | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleWeather
{
public static class ConversionMethods
{
private const double KM_TO_MI = 0.621371192;
private const double MI_TO_KM = 1.609344;
public static string mbToInHg(String input)
{
double result = 29.92 * double.Parse(input) / 1013.25;
return Math.Round(result, 2).ToString();
}
public static string kmToMi(String input)
{
double result = KM_TO_MI * double.Parse(input);
return Math.Round(result).ToString();
}
public static string miToKm(String input)
{
double result = MI_TO_KM * double.Parse(input);
return Math.Round(result).ToString();
}
public static string mphTokph(String input)
{
double result = MI_TO_KM * double.Parse(input);
return Math.Round(result).ToString();
}
public static string kphTomph(String input)
{
double result = KM_TO_MI * double.Parse(input);
return Math.Round(result).ToString();
}
public static string FtoC(String input)
{
double result = (double.Parse(input) - 32) * ((double)5 / 9);
return Math.Round(result).ToString();
}
public static string CtoF(string input)
{
double result = (double.Parse(input) * ((double)9 /5)) + 32;
return Math.Round(result).ToString();
}
}
}
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleWeather
{
public static class ConversionMethods
{
public const double KM_TO_MI = 0.621371192;
public const double MI_TO_KM = 1.609344;
public static string mbToInHg(String input)
{
double result = 29.92 * double.Parse(input) / 1013.25;
return result.ToString("0.00");
}
public static string mbToInHg(double input)
{
double result = 29.92 * input / 1013.25;
return result.ToString("0.00");
}
public static string kmToMi(String input)
{
double result = KM_TO_MI * double.Parse(input);
return Math.Round(result, 2).ToString();
}
public static string kmToMi(double input)
{
double result = KM_TO_MI * input;
return Math.Round(result, 2).ToString();
}
public static string miToKm(String input)
{
double result = MI_TO_KM * double.Parse(input);
return Math.Round(result, 2).ToString();
}
public static string miToKm(double input)
{
double result = MI_TO_KM * input;
return Math.Round(result, 2).ToString();
}
public static string mphTokph(String input)
{
double result = MI_TO_KM * double.Parse(input);
return Math.Round(result).ToString();
}
public static string mphTokph(double input)
{
double result = MI_TO_KM * input;
return Math.Round(result).ToString();
}
public static string kphTomph(String input)
{
double result = KM_TO_MI * double.Parse(input);
return Math.Round(result).ToString();
}
public static string kphTomph(double input)
{
double result = KM_TO_MI * input;
return Math.Round(result).ToString();
}
}
}
| apache-2.0 | C# |
3003e86882707638c203140a2edc246d96bd586f | Add company name to assembly. | GetTabster/Tabster | Tabster/Properties/AssemblyInfo.cs | Tabster/Properties/AssemblyInfo.cs | #region
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tabster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nate Shoffner")]
[assembly: AssemblyProduct("Tabster")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("05e93702-6d2b-4e7e-888a-cf5d891f9fb8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")] | #region
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tabster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tabster")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("05e93702-6d2b-4e7e-888a-cf5d891f9fb8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")] | apache-2.0 | C# |
7f8a1a7863c7ae5722637b397fae86e169f7aaa8 | Revert "And we have the medium line working!" | pcamp123/GadgtSpot-Windows-Phone-Application | WP8App/Services/WordWrapService.cs | WP8App/Services/WordWrapService.cs | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WPAppStudio.Services.Interfaces;
namespace WPAppStudio.Services
{
public class WordWrapService
{
private readonly ITextMeasurementService _tms;
public WordWrapService(ITextMeasurementService textMeasurementService)
{
_tms = textMeasurementService;
}
public string GetWords(string text, int wordCount)
{
StringBuilder result = new StringBuilder();
for (int word = 0; word < wordCount; word++)
{
int space = text.IndexOf(' ', 1);
//return text.Substring(0, space);
if (space == -1)
{
result.Append(text);
return result.ToString();
}
result.Append(text.Substring(0, space));
text = text.Substring(space);
}
return result.ToString();
}
public string GetLine(string text, int lineLength)
{
string line = GetWords(text, 3);
int width = _tms.GetTextWidth(line);
if (width <= lineLength)
{
return line;
}
return GetWords(text, 1);
}
}
}
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WPAppStudio.Services.Interfaces;
namespace WPAppStudio.Services
{
public class WordWrapService
{
private readonly ITextMeasurementService _tms;
public WordWrapService(ITextMeasurementService textMeasurementService)
{
_tms = textMeasurementService;
}
public string GetWords(string text, int wordCount)
{
StringBuilder result = new StringBuilder();
for (int word = 0; word < wordCount; word++)
{
int space = text.IndexOf(' ', 1);
//return text.Substring(0, space);
if (space == -1)
{
result.Append(text);
return result.ToString();
}
result.Append(text.Substring(0, space));
text = text.Substring(space);
}
return result.ToString();
}
public string GetLine(string text, int lineLength)
{
for (int wordCount = 10; wordCount > 0; wordCount--)
{
string line = GetWords(text, wordCount);
int width = _tms.GetTextWidth(line);
if (width <= lineLength)
{
return line;
}
}
return GetWords(text, 1);
}
}
}
| mit | C# |
0fe4265e26d6b4eba23378be5b4f899d0e89edc1 | implement Classifier.Clustering(Raw.RawBlock) | myxini/block-program | block-program/Detection/Classifier.cs | block-program/Detection/Classifier.cs | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myxini.Recognition
{
class Classifier : IClassifier
{
private class Pattern
{
private Image.IImage pattern;
public IBlock Block { get; private set; }
public Pattern(Image.IImage pattern, IBlock block)
{
this.pattern = pattern;
Block = block;
}
public double Match(Image.IImage image)
{
// ここでパターンマッチング
// 仮に値を返す
return (new Random()).NextDouble() * 2 - 1;
}
}
private IList<Pattern> patterns = new List<Pattern>
{
//LED
new Pattern(
/* なにかパターンの画像 */null,
new Block(Command.LED, /* なにかパラメータ */new BlockParameter(), false)
),
//Move
//Rotate
//MicroSwitch
//PSD
//Start
//End
};
public IBlock clustering(Raw.IRawBlock raw_block)
{
// ここでパターンマッチングして最もマッチする
Pattern pattern_max_matching = patterns
.OrderByDescending(pattern => Math.Abs(pattern.Match(raw_block.BoundingImage)))
.First();
return pattern_max_matching.Block;
}
}
}
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myxini.Recognition
{
class Classifier : IClassifier
{
private class Pattern
{
private Image.IImage pattern;
IBlock Block { get; private set; }
Pattern(Image.IImage pattern, IBlock block)
{
this.pattern = pattern;
Block = block;
}
double Match(Image.IImage image)
{
// ここでパターンマッチング
// 仮に値を返す
return (new Random()).NextDouble() * 2 - 1;
}
}
private IList<Pattern> patterns = new List<Pattern>
{
//LED
//Move
//Rotate
//MicroSwitch
//PSD
//Start
//End
};
public IBlock clustering(Raw.IRawBlock raw_block)
{
// ここでパターンマッチング
throw new NotImplementedException();
}
}
}
| mit | C# |
f117ec80c640d9f9ca3abf6685aa24553b3dfe2b | Throw InvalidOperationException when ActiveCharacterRenderer is null in MainCharacterEntityRenderer | ethanmoffat/EndlessClient | EndlessClient/Rendering/MapEntityRenderers/MainCharacterEntityRenderer.cs | EndlessClient/Rendering/MapEntityRenderers/MainCharacterEntityRenderer.cs | // Original Work Copyright (c) Ethan Moffat 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file
using System;
using EndlessClient.Rendering.Character;
using EndlessClient.Rendering.Map;
using EOLib.Domain.Character;
using Microsoft.Xna.Framework.Graphics;
namespace EndlessClient.Rendering.MapEntityRenderers
{
public class MainCharacterEntityRenderer : BaseMapEntityRenderer
{
private readonly ICharacterRendererProvider _characterRendererProvider;
public MainCharacterEntityRenderer(ICharacterProvider characterProvider,
ICharacterRendererProvider characterRendererProvider,
ICharacterRenderOffsetCalculator characterRenderOffsetCalculator)
: base(characterProvider, characterRenderOffsetCalculator)
{
_characterRendererProvider = characterRendererProvider;
}
public override MapRenderLayer RenderLayer
{
get { return MapRenderLayer.MainCharacter; }
}
protected override int RenderDistance
{
get { return 1; }
}
protected override bool ElementExistsAt(int row, int col)
{
return row == _characterProvider.ActiveCharacter.RenderProperties.MapY &&
col == _characterProvider.ActiveCharacter.RenderProperties.MapX;
}
public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col, int alpha)
{
if(_characterRendererProvider.ActiveCharacterRenderer == null)
throw new InvalidOperationException("Active character renderer is null! Did you call MapRenderer.Update() before calling MapRenderer.Draw()?");
spriteBatch.End();
//todo: use different blend state if character is hidden
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
_characterRendererProvider.ActiveCharacterRenderer.DrawToSpriteBatch(spriteBatch);
spriteBatch.End();
spriteBatch.Begin();
}
}
}
| // Original Work Copyright (c) Ethan Moffat 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file
using EndlessClient.Rendering.Character;
using EndlessClient.Rendering.Map;
using EOLib.Domain.Character;
using Microsoft.Xna.Framework.Graphics;
namespace EndlessClient.Rendering.MapEntityRenderers
{
public class MainCharacterEntityRenderer : BaseMapEntityRenderer
{
private readonly ICharacterRendererProvider _characterRendererProvider;
public MainCharacterEntityRenderer(ICharacterProvider characterProvider,
ICharacterRendererProvider characterRendererProvider,
ICharacterRenderOffsetCalculator characterRenderOffsetCalculator)
: base(characterProvider, characterRenderOffsetCalculator)
{
_characterRendererProvider = characterRendererProvider;
}
public override MapRenderLayer RenderLayer
{
get { return MapRenderLayer.MainCharacter; }
}
protected override int RenderDistance
{
get { return 1; }
}
protected override bool ElementExistsAt(int row, int col)
{
return row == _characterProvider.ActiveCharacter.RenderProperties.MapY &&
col == _characterProvider.ActiveCharacter.RenderProperties.MapX;
}
public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col, int alpha)
{
spriteBatch.End();
//todo: use different blend state if character is hidden
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
_characterRendererProvider.ActiveCharacterRenderer.DrawToSpriteBatch(spriteBatch);
spriteBatch.End();
spriteBatch.Begin();
}
}
}
| mit | C# |
54deea464cb66d774d203c434796f452d8428c61 | Fix method reference in XML comment | artem-aliev/tinkerpop,apache/incubator-tinkerpop,pluradj/incubator-tinkerpop,apache/tinkerpop,krlohnes/tinkerpop,artem-aliev/tinkerpop,apache/tinkerpop,robertdale/tinkerpop,robertdale/tinkerpop,apache/incubator-tinkerpop,apache/tinkerpop,robertdale/tinkerpop,krlohnes/tinkerpop,artem-aliev/tinkerpop,apache/tinkerpop,apache/incubator-tinkerpop,krlohnes/tinkerpop,jorgebay/tinkerpop,krlohnes/tinkerpop,apache/tinkerpop,robertdale/tinkerpop,pluradj/incubator-tinkerpop,apache/tinkerpop,jorgebay/tinkerpop,artem-aliev/tinkerpop,robertdale/tinkerpop,jorgebay/tinkerpop,artem-aliev/tinkerpop,krlohnes/tinkerpop,pluradj/incubator-tinkerpop,apache/tinkerpop,jorgebay/tinkerpop | gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs | gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs | #region License
/*
* 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.
*/
#endregion
using System;
using System.Collections.Generic;
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
/// A <see cref="ITraversal" /> can maintain global sideEffects.
/// </summary>
public interface ITraversalSideEffects : IDisposable
{
/// <summary>
/// Retrieves the keys of the side-effect that can be supplied to <see cref="Get" />.
/// </summary>
/// <returns>The keys of the side-effect.</returns>
IReadOnlyCollection<string> Keys();
/// <summary>
/// Gets the side-effect associated with the provided key.
/// </summary>
/// <param name="key">The key to get the value for.</param>
/// <returns>The value associated with key.</returns>
object Get(string key);
/// <summary>
/// Invalidates the side effect cache for traversal.
/// </summary>
void Close();
}
} | #region License
/*
* 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.
*/
#endregion
using System;
using System.Collections.Generic;
namespace Gremlin.Net.Process.Traversal
{
/// <summary>
/// A <see cref="ITraversal" /> can maintain global sideEffects.
/// </summary>
public interface ITraversalSideEffects : IDisposable
{
/// <summary>
/// Retrieves the keys of the side-effect that can be supplied to <see cref="Get(string)" />.
/// </summary>
/// <returns>The keys of the side-effect.</returns>
IReadOnlyCollection<string> Keys();
/// <summary>
/// Gets the side-effect associated with the provided key.
/// </summary>
/// <param name="key">The key to get the value for.</param>
/// <returns>The value associated with key.</returns>
object Get(string key);
/// <summary>
/// Invalidates the side effect cache for traversal.
/// </summary>
void Close();
}
} | apache-2.0 | C# |
6b613e84a588496099e77581a6bd39d59165f985 | Add new file userAuth.cpl/Droid/MainActivity.cs | ArcanaMagus/userAuth.cpl,ArcanaMagus/userAuth.cpl,ArcanaMagus/userAuth.cpl,ArcanaMagus/userAuth.cpl | userAuth.cpl/Droid/MainActivity.cs | userAuth.cpl/Droid/MainActivity.cs | �
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace userAuth.cpl.Droid
{
[Activity (Label = "userAuth.cpl.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = Android.Content.PM.ConfigChanges.Density | Android.Content.PM.ConfigChanges.Touchscreen)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.ActivityIndicatorRenderer
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new App ());
// Create your apponlication here
}
}
}
|