content stringlengths 5 1.04M | avg_line_length float64 1.75 12.9k | max_line_length int64 2 244k | alphanum_fraction float64 0 0.98 | licenses list | repository_name stringlengths 7 92 | path stringlengths 3 249 | size int64 5 1.04M | lang stringclasses 2 values |
|---|---|---|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ItemEdit.wpf.ViewModel.Common
{
interface ICommand
{
event EventHandler CanExecuteChanged;
bool CanExecute(object parameter);
void Execute(object parameter);
}
}
| 20.25 | 45 | 0.728395 | [
"MIT"
] | dmankill/ItemEdit | ItemEdit/ItemEdit.wpf/ViewModel/Common/ICommand.cs | 326 | C# |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option or rebuild the Visual Studio project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "12.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Messages {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Messages() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Resources.Messages", global::System.Reflection.Assembly.Load("App_GlobalResources"));
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to {0} was not found with id {1}..
/// </summary>
internal static string NotFound {
get {
return ResourceManager.GetString("NotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} has been successfully saved..
/// </summary>
internal static string Saved {
get {
return ResourceManager.GetString("Saved", resourceCulture);
}
}
}
}
| 41.731707 | 199 | 0.59585 | [
"MIT"
] | ucdavis/Agribusiness | Agribusiness.Web/App_GlobalResources/Messages.Designer.cs | 3,422 | C# |
namespace FirebaseCoreAdmin.Firebase.Storage
{
public enum SigningAction
{
Read,
Write,
Delete
}
} | 15 | 45 | 0.585185 | [
"Apache-2.0"
] | ScriptBox99/FirebaseCoreSDK | FirebaseCoreSDK/Firebase/Storage/SigningAction.cs | 137 | C# |
using NeuralNetwork.Learning.XOR;
using System;
namespace NeuralNetwork
{
class NeuralNetworkProgram
{
static void Main()
{
// XOR Learning
DateTime startDate = DateTime.Now;
XORMain xorMain = new XORMain();
xorMain.Learn(5000);
DateTime endDate = DateTime.Now;
xorMain.NNResult(startDate, endDate);
}
}
}
| 21.894737 | 49 | 0.569712 | [
"MIT"
] | Domon-Casle/NeuralNetworkXOR | NeuralNetwork/Main.cs | 418 | C# |
//Copyright (c) 2006, Adobe Systems Incorporated
//All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// This product includes software developed by the Adobe Systems Incorporated.
// 4. Neither the name of the Adobe Systems Incorporated nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY ADOBE SYSTEMS INCORPORATED ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL ADOBE SYSTEMS INCORPORATED BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// http://www.adobe.com/devnet/xmp/library/eula-xmp-library-java.html
namespace iTextSharp.xmp
{
/// <summary>
/// XMP Toolkit Version Information.
/// <p>
/// Version information for the XMP toolkit is stored in the jar-library and available through a
/// runtime call, <seealso cref="XMPMetaFactory#getVersionInfo()"/>, addition static version numbers are
/// defined in "version.properties".
///
/// @since 23.01.2006
/// </summary>
public interface IXmpVersionInfo
{
/// <returns> Returns the primary release number, the "1" in version "1.2.3". </returns>
int Major { get;}
/// <returns> Returns the secondary release number, the "2" in version "1.2.3". </returns>
int Minor { get;}
/// <returns> Returns the tertiary release number, the "3" in version "1.2.3". </returns>
int Micro { get;}
/// <returns> Returns a rolling build number, monotonically increasing in a release. </returns>
int Build { get;}
/// <returns> Returns true if this is a debug build. </returns>
bool Debug { get;}
/// <returns> Returns a comprehensive version information string. </returns>
string Message { get;}
}
}
| 46.086957 | 109 | 0.677987 | [
"MIT"
] | krolpiotr/PHOENIX.Fakturering | itextsharp-core/iTextSharp/xmp/IXmpVersionInfo.cs | 3,180 | C# |
// == Inspoy Technology ==
// Assembly: Instech.Framework.AssetHelper
// FileName: AssetException.cs
// Created on 2019/12/17 by inspoy
// All rights reserved.
using System;
using System.Text;
namespace Instech.Framework.AssetHelper
{
public enum ErrorCode
{
Success,
NotInited,
InitFailed,
UnknownPath,
BundleNotFound,
LoadFailed,
Other
}
public class AssetException : Exception
{
private static readonly StringBuilder MessageBuilder = new StringBuilder();
public AssetException(ErrorCode reason, string path = null, string msg = null) : base(MakeMessage(reason, path, msg))
{
}
private static string MakeMessage(ErrorCode reason, string path, string msg)
{
MessageBuilder.Clear();
MessageBuilder.Append($"Asset Exception: {reason}");
if (!string.IsNullOrEmpty(path))
{
MessageBuilder
.Append("\n -AssetPath: ")
.Append(path);
}
if (!string.IsNullOrEmpty(msg))
{
MessageBuilder
.Append("\n -Message: ")
.Append(msg);
}
return MessageBuilder.ToString();
}
}
} | 25.423077 | 125 | 0.551437 | [
"Apache-2.0"
] | inspoy/Instech | cc.inspoy.framework.assethelper/AssetException.cs | 1,322 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneGames : MonoBehaviour
{
private void OnGUI()
{
if(GUI.Button(new Rect(525,330,137,38), "Volver"))
{
SceneManager.LoadScene("SceneLogin");
}
if(GUI.Button(new Rect(178,100,150,38), "Calculadora"))
{
SceneManager.LoadScene("SceneCalculation");
}
}
private void Start()
{
Camera camera = GetComponent<Camera>();
camera.clearFlags = CameraClearFlags.SolidColor;
camera.backgroundColor = Color.black;
}
}
| 21 | 57 | 0.723104 | [
"MIT"
] | Eneye280/Examples | Assets/Calculadora/SceneGames.cs | 569 | C# |
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18047
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace HttpListener
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#line 2 "..\..\Fortunes.cshtml"
using System.Web;
#line default
#line hidden
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
public partial class Fortunes : RazorGenerator.Templating.RazorTemplateBase
{
#line hidden
#line 3 "..\..\Fortunes.cshtml"
public IEnumerable<Benchmarks.AspNet.Models.Fortune> Model { get; set; }
#line default
#line hidden
public override void Execute()
{
WriteLiteral("<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id<" +
"/th><th>message</th></tr>");
#line 7 "..\..\Fortunes.cshtml"
foreach (var fortune in Model)
{
#line default
#line hidden
WriteLiteral("<tr><td>");
#line 9 "..\..\Fortunes.cshtml"
Write(fortune.ID);
#line default
#line hidden
WriteLiteral("</td><td>");
#line 9 "..\..\Fortunes.cshtml"
Write(HttpUtility.HtmlEncode(fortune.Message));
#line default
#line hidden
WriteLiteral("</td></tr>");
#line 9 "..\..\Fortunes.cshtml"
#line default
#line hidden
#line 10 "..\..\Fortunes.cshtml"
}
#line default
#line hidden
WriteLiteral("</table></body></html>");
}
}
}
#pragma warning restore 1591
| 20.542056 | 98 | 0.474977 | [
"BSD-3-Clause"
] | Acidburn0zzz/FrameworkBenchmarks | frameworks/CSharp/HttpListener/HttpListener/Fortunes.generated.cs | 2,200 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Web;
using InertiaAdapter.Extensions;
using InertiaAdapter.Interfaces;
using InertiaAdapter.Models;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
namespace InertiaAdapter.Core
{
internal class ResultFactory : IResultFactory
{
private readonly SharedProps _share = new();
private string _rootView = "Views/Shared/App.cshtml";
private object? _version;
public void Share(string key, object obj) => _share.AddOrUpdate(key, obj);
public void Share(string key, Func<object> func) => _share.AddOrUpdate(key, func);
public IDictionary<string, object> GetShared() => _share.Value;
public object GetSharedByKey(string key) => _share.GetValue(key);
public void SetRootView(string s) => _rootView = s;
public void Version(string version) => _version = version;
public void Version(Func<string> version) => _version = version;
public string? GetVersion() =>
_version switch
{
Func<string> func => func(),
string s => s,
_ => null
};
public IHtmlContent Html(dynamic model)
{
var data = JsonSerializer.Serialize(model,
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
return new HtmlString($"<div id=\"app\" data-page=\"{HttpUtility.HtmlEncode(data)}\"></div>");
}
public IActionResult Location(string url) => new LocationResult(url);
public IActionResult Render(string component, object data, object controller) =>
new Result(_share.Value.Concat(data.AsDictionary()).ToDictionary(c => c.Key, c => c.Value), component, _rootView,
GetVersion(), controller);
}
}
| 32.389831 | 125 | 0.646782 | [
"MIT"
] | JPBetley/inertia-aspnetcore | src/InertiaAdapter/Core/ResultFactory.cs | 1,911 | C# |
//------------------------------------------------------------------------------
// <auto-generated>
// Copyright (C) 2009-2010 ORMBattle.NET.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Alexis Kochetov
// Created: 2009.07.31
// Updated by: Svyatoslav Danyliv
// Updated: 2015.12.14
//
// This file is generated from LinqTests.tt
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using LinqToDB;
using static Tests.Model.Northwind;
namespace Tests.OrmBattle
{
using Tests.Model;
using Tests.OrmBattle.Helper;
[TestFixture]
public class OrmBattleTests : TestBase
{
private const double doubleDelta = 1E-9;
private string _currentContext;
protected NorthwindDB db;
protected void Setup(string context)
{
if (_currentContext == context)
return;
using (db)
db = null;
using (new DisableLogging())
{
db = new NorthwindDB(context);
Customers = db.Customer.ToList();
Employees = db.Employee.ToList();
Order = db.Order.ToList();
Products = db.Product.ToList();
foreach (var o in Order)
{
o.Customer = Customers.SingleOrDefault(c => c.CustomerID == o.CustomerID);
o.Employee = Employees.SingleOrDefault(e => e.EmployeeID == o.EmployeeID);
}
foreach (var c in Customers)
c.Orders = Order.Where(o => c.CustomerID == o.CustomerID).ToList();
}
_currentContext = context;
}
[TearDown]
protected void TearDown()
{
_currentContext = null;
using (db)
db = null;
}
List<Northwind.Customer> Customers;
List<Northwind.Employee> Employees;
List<Northwind.Order> Order;
List<Northwind.Product> Products;
// List<Northwind.Category> Categories;
// List<Northwind.Supplier> Suppliers;
// List<Northwind.Product> DiscontinuedProducts;
// List<Northwind.OrderDetail> OrderDetails;
// DTO for testing purposes.
public class OrderDTO
{
public int Id { get; set; }
public string CustomerId { get; set; }
public DateTime? OrderDate { get; set; }
}
#region Filtering tests
[Test]
public void WhereTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
where o.ShipCity == "Seattle"
select o;
var expected = from o in Order
where o.ShipCity == "Seattle"
select o;
var list = result.ToList();
Assert.AreEqual(14, list.Count);
Assert.AreEqual(0, expected.Except(list).Count());
}
[Test]
public void WhereParameterTest([NorthwindDataContext] string context)
{
Setup(context);
var city = "Seattle";
var result = from o in db.Order
where o.ShipCity == city
select o;
var expected = from o in Order
where o.ShipCity == city
select o;
var list = result.ToList();
Assert.AreEqual(14, list.Count);
Assert.AreEqual(0, expected.Except(list).Count());
city = "Rio de Janeiro";
list = result.ToList();
Assert.AreEqual(34, list.Count);
Assert.AreEqual(0, expected.Except(list).Count());
}
[Test]
public void WhereConditionsTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from p in db.Product
where p.UnitsInStock < p.ReorderLevel && p.UnitsOnOrder == 0
select p;
var list = result.ToList();
Assert.AreEqual(1, list.Count);
}
[Test]
public void WhereNullTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
where o.ShipRegion == null
select o;
var list = result.ToList();
Assert.AreEqual(507, list.Count);
}
[Test]
public void WhereNullParameterTest([NorthwindDataContext] string context)
{
Setup(context);
string region = null;
var result = from o in db.Order
where o.ShipRegion == region
select o;
var list = result.ToList();
Assert.AreEqual(507, list.Count);
region = "WA";
list = result.ToList();
Assert.AreEqual(19, list.Count);
}
[Test]
public void WhereNullableTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
where !o.ShippedDate.HasValue
select o;
var list = result.ToList();
Assert.AreEqual(21, list.Count);
}
[Test]
public void WhereNullableParameterTest([NorthwindDataContext] string context)
{
Setup(context);
DateTime? shippedDate = null;
var result = from o in db.Order
where o.ShippedDate == shippedDate
select o;
var list = result.ToList();
Assert.AreEqual(21, list.Count);
}
[Test]
public void WhereCoalesceTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
where (o.ShipRegion ?? "N/A") == "N/A"
select o;
var list = result.ToList();
Assert.AreEqual(507, list.Count);
}
[Test]
public void WhereConditionalTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
where (o.ShipCity == "Seattle" ? "Home" : "Other") == "Home"
select o;
var list = result.ToList();
Assert.AreEqual(14, list.Count);
}
[Test]
public void WhereConditionalBooleanTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
where o.ShipCity == "Seattle" ? true : false
select o;
var list = result.ToList();
Assert.AreEqual(14, list.Count);
}
[Test]
public void WhereAnonymousParameterTest([NorthwindDataContext] string context)
{
Setup(context);
var cityRegion = new {City = "Seattle", Region = "WA"};
var result = from o in db.Order
where new {City = o.ShipCity, Region = o.ShipRegion} == cityRegion
select o;
var list = result.ToList();
Assert.AreEqual(14, list.Count);
}
[Test]
public void WhereEntityParameterTest([NorthwindDataContext] string context)
{
Setup(context);
var order = db.Order.OrderBy(o => o.OrderDate).First();
var result = from o in db.Order
where o == order
select o;
var list = result.ToList();
Assert.AreEqual(1, list.Count);
Assert.AreEqual(order, list[0]);
//Assert.AreSame(order, list[0]);
}
#endregion
#region Projection tests
[Test]
public void SelectTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
select o.ShipRegion;
var expected = from o in Order
select o.ShipRegion;
var list = result.ToList();
Assert.AreEqual(expected.Count(), list.Count);
Assert.AreEqual(0, expected.Except(list).Count());
}
[Test]
public void SelectBooleanTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
select o.ShipRegion == "WA";
var expected = from o in Order
select o.ShipRegion == "WA";
var list = result.ToList();
Assert.AreEqual(expected.Count(), list.Count);
Assert.AreEqual(0, expected.Except(list).Count());
}
[Test]
public void SelectCalculatedTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
select o.Freight * 1000;
var expected = from o in Order
select o.Freight * 1000;
var list = result.ToList();
var expectedList = expected.ToList();
list.Sort();
expectedList.Sort();
// Assert.AreEqual(expectedList.Count, list.Count);
// expectedList.Zip(list, (i, j) => {
// Assert.AreEqual(i,j);
// return true;
// });
CollectionAssert.AreEquivalent(expectedList, list);
}
[Test]
public void SelectNestedCalculatedTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from r in
from o in db.Order
select o.Freight * 1000
where r > 100000
select r / 1000;
var expected = from o in Order
where o.Freight > 100
select o.Freight;
var list = result.ToList();
var expectedList = expected.ToList();
list.Sort();
expectedList.Sort();
Assert.AreEqual(187, list.Count);
// Assert.AreEqual(expectedList.Count, list.Count);
// expectedList.Zip(list, (i, j) => {
// Assert.AreEqual(i,j);
// return true;
// });
CollectionAssert.AreEquivalent(expectedList, list);
}
[Test]
public void SelectAnonymousTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
select new {OrderID = o.OrderID, o.OrderDate, o.Freight};
var expected = from o in Order
select new {OrderID = o.OrderID, o.OrderDate, o.Freight};
var list = result.ToList();
Assert.AreEqual(expected.Count(), list.Count);
Assert.AreEqual(0, expected.Except(list).Count());
}
[Test]
public void SelectSubqueryTest([NorthwindDataContext] string context)
{
Setup(context);
Assert.AreNotEqual(db.GetType().FullName, "OrmBattle.EF7Model.NorthwindContext",
"EF7 has infinite loop here");
var result = from o in db.Order
select db.Customer.Where(c => c.CustomerID == o.Customer.CustomerID);
var expected = from o in Order
select Customers.Where(c => c.CustomerID == o.Customer.CustomerID);
var list = result.ToList();
var expectedList = expected.ToList();
CollectionAssert.AreEquivalent(expectedList, list);
//Assert.AreEqual(expected.Count(), list.Count);
//expected.Zip(result, (expectedCustomers, actualCustomers) => {
// Assert.AreEqual(expectedCustomers.Count(), actualCustomers.Count());
// Assert.AreEqual(0, expectedCustomers.Except(actualCustomers));
// return true;
// });
}
[Test]
public void SelectDtoTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from o in db.Order
select new OrderDTO {Id = o.OrderID, CustomerId = o.Customer.CustomerID, OrderDate = o.OrderDate};
var list = result.ToList();
Assert.AreEqual(Order.Count(), list.Count);
}
[Test]
public void SelectNestedDtoTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from r in
from o in db.Order
select new OrderDTO {Id = o.OrderID, CustomerId = o.Customer.CustomerID, OrderDate = o.OrderDate}
where r.OrderDate > new DateTime(1998, 01, 01)
select r;
var list = result.ToList();
Assert.AreEqual(267, list.Count);
}
[Test]
public void SelectManyAnonymousTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from c in db.Customer
from o in c.Orders
where o.Freight < 500.00M
select new {CustomerId = c.CustomerID, o.OrderID, o.Freight};
var list = result.ToList();
Assert.AreEqual(817, list.Count);
}
[Test]
public void SelectManyLetTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from c in db.Customer
from o in c.Orders
let freight = o.Freight
where freight < 500.00M
select new {CustomerId = c.CustomerID, o.OrderID, freight};
var list = result.ToList();
Assert.AreEqual(817, list.Count);
}
[Test]
public void SelectManyGroupByTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Order
.GroupBy(o => o.Customer)
.Where(g => g.Count() > 20)
.SelectMany(g => g.Select(o => o.Customer));
var list = result.ToList();
Assert.AreEqual(89, list.Count);
}
[Test]
public void SelectManyOuterProjectionTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.SelectMany(i => i.Orders.Select(t => i));
var list = result.ToList();
Assert.AreEqual(830, list.Count);
}
[Test]
public void SelectManyLeftJoinTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
from o in c.Orders.Select(o => new {o.OrderID, c.CompanyName}).DefaultIfEmpty()
select new {c.ContactName, o};
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
#endregion
#region Take / Skip tests
[Test]
public void TakeTest([NorthwindDataContext] string context)
{
Setup(context);
var result = (from o in db.Order
orderby o.OrderDate, o.OrderID
select o).Take(10);
var expected = (from o in Order
orderby o.OrderDate, o.OrderID
select o).Take(10);
var list = result.ToList();
Assert.AreEqual(10, list.Count);
Assert.IsTrue(expected.SequenceEqual(list));
}
[Test]
public void SkipTest([NorthwindDataContext] string context)
{
Setup(context);
var result = (from o in db.Order
orderby o.OrderDate, o.OrderID
select o).Skip(10);
var expected = (from o in Order
orderby o.OrderDate, o.OrderID
select o).Skip(10);
var list = result.ToList();
Assert.AreEqual(820, list.Count);
Assert.IsTrue(expected.SequenceEqual(list));
}
[Test]
public void TakeSkipTest([NorthwindDataContext] string context)
{
Setup(context);
var result = (from o in db.Order
orderby o.OrderDate, o.OrderID
select o).Skip(10).Take(10);
var expected = (from o in Order
orderby o.OrderDate, o.OrderID
select o).Skip(10).Take(10);
var list = result.ToList();
Assert.AreEqual(10, list.Count);
Assert.IsTrue(expected.SequenceEqual(list));
}
[Test]
public void TakeNestedTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
select new {Customer = c, TopOrder = c.Orders.OrderByDescending(o => o.OrderDate).Take(5)};
var expected =
from c in Customers
select new {Customer = c, TopOrder = c.Orders.OrderByDescending(o => o.OrderDate).Take(5)};
var list = result.ToList();
Assert.AreEqual(expected.Count(), list.Count);
foreach (var anonymous in list)
{
var count = anonymous.TopOrder.ToList().Count;
Assert.GreaterOrEqual(count, 0);
Assert.LessOrEqual(count, 5);
}
}
[Test]
public void ComplexTakeSkipTest([NorthwindDataContext] string context)
{
Setup(context);
var original = db.Order.ToList()
.OrderBy(o => o.OrderDate)
.Skip(100)
.Take(50)
.OrderBy(o => o.RequiredDate)
.Where(o => o.OrderDate != null)
.Select(o => o.RequiredDate)
.Distinct()
.OrderByDescending(_ => _)
.Skip(10);
var result = db.Order
.OrderBy(o => o.OrderDate)
.Skip(100)
.Take(50)
.OrderBy(o => o.RequiredDate)
.Where(o => o.OrderDate != null)
.Select(o => o.RequiredDate)
.Distinct()
.OrderByDescending(_ => _)
.Skip(10);
var originalList = original.ToList();
var resultList = result.ToList();
Assert.AreEqual(originalList.Count, resultList.Count);
Assert.IsTrue(originalList.SequenceEqual(resultList));
}
#endregion
#region Ordering tests
[Test]
public void OrderByTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
orderby o.OrderDate, o.ShippedDate descending, o.OrderID
select o;
var expected =
from o in Order
orderby o.OrderDate, o.ShippedDate descending, o.OrderID
select o;
var list = result.ToList();
var expectedList = expected.ToList();
Assert.AreEqual(expectedList.Count, list.Count);
Assert.IsTrue(expected.SequenceEqual(list));
}
[Test]
public void OrderByWhereTest([NorthwindDataContext] string context)
{
Setup(context);
var result = (from o in db.Order
orderby o.OrderDate, o.OrderID
where o.OrderDate > new DateTime(1997, 1, 1)
select o).Take(10);
var expected = (from o in Order
where o.OrderDate > new DateTime(1997, 1, 1)
orderby o.OrderDate, o.OrderID
select o).Take(10);
var list = result.ToList();
Assert.AreEqual(10, list.Count);
Assert.IsTrue(expected.SequenceEqual(list));
}
[Test]
public void OrderByCalculatedColumnTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
orderby o.Freight * o.OrderID descending
select o;
var expected =
from o in Order
orderby o.Freight * o.OrderID descending
select o;
Assert.IsTrue(expected.SequenceEqual(result));
}
[Test]
public void OrderByEntityTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
orderby o
select o;
var expected =
from o in Order
orderby o.OrderID
select o;
Assert.IsTrue(expected.SequenceEqual(result, new GenericEqualityComparer<Order>(o => o.OrderID)));
}
[Test]
public void OrderByAnonymousTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
orderby new {o.OrderDate, o.ShippedDate, o.OrderID}
select o;
var expected =
from o in Order
orderby o.OrderDate, o.ShippedDate, o.OrderID
select o;
Assert.IsTrue(expected.SequenceEqual(result, new GenericEqualityComparer<Order>(o => o.OrderID)));
}
[Test]
[ActiveIssue("Bad database data", Configuration = TestProvName.AllSQLiteNorthwind)]
public void OrderByDistinctTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer
.OrderBy(c => c.CompanyName)
.Select(c => c.City)
.Distinct()
.OrderBy(c => c)
.Select(c => c);
var expected = Customers
.OrderBy(c => c.CompanyName)
.Select(c => c.City)
.Distinct()
.OrderBy(c => c)
.Select(c => c);
Assert.IsTrue(expected.SequenceEqual(result));
}
[Test]
[ActiveIssue("Bad database data", Configuration = TestProvName.AllSQLiteNorthwind)]
public void OrderBySelectManyTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer.OrderBy(c => c.ContactName)
from o in db.Order.OrderBy(o => o.OrderDate)
where c == o.Customer
select new {c.ContactName, o.OrderDate};
var expected =
from c in Customers.OrderBy(c => c.ContactName)
from o in Order.OrderBy(o => o.OrderDate)
where c == o.Customer
select new {c.ContactName, o.OrderDate};
Assert.IsTrue(expected.SequenceEqual(result));
}
[Test]
public void OrderByPredicateTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
db.Order.OrderBy(o => o.Freight > 0 && o.ShippedDate != null).ThenBy(o => o.OrderID).Select(o => o.OrderID);
var list = result.ToList();
var original =
Order.OrderBy(o => o.Freight > 0 && o.ShippedDate != null).ThenBy(o => o.OrderID).Select(o => o.OrderID).ToList();
Assert.IsTrue(list.SequenceEqual(original));
}
#endregion
#region Grouping tests
[Test]
public void GroupByTest([NorthwindDataContext] string context)
{
using (new GuardGrouping(false))
{
Setup(context);
var result = from o in db.Order
group o by o.OrderDate;
var list = result.ToList();
Assert.AreEqual(480, list.Count);
}
}
[Test]
public void GroupByReferenceTest([NorthwindDataContext] string context)
{
using (new GuardGrouping(false))
{
Setup(context);
var result = from o in db.Order
group o by o.Customer;
var list = result.ToList();
Assert.AreEqual(89, list.Count);
}
}
[Test]
public void GroupByWhereTest([NorthwindDataContext] string context)
{
using (new GuardGrouping(false))
{
Setup(context);
var result =
from o in db.Order
group o by o.OrderDate
into g
where g.Count() > 5
select g;
var list = result.ToList();
Assert.AreEqual(1, list.Count);
}
}
[Test]
public void GroupByTestAnonymous([NorthwindDataContext] string context)
{
using (new GuardGrouping(false))
{
Setup(context);
var result = from c in db.Customer
group c by new { c.Region, c.City };
var list = result.ToList();
Assert.AreEqual(69, list.Count);
}
}
[Test]
public void GroupByCalculatedTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
group o by o.Freight > 50 ? o.Freight > 100 ? "expensive" : "average" : "cheap"
into g
select g;
var list = result.ToList();
Assert.AreEqual(3, list.Count);
}
[Test]
public void GroupBySelectManyTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer
.GroupBy(c => c.City)
.SelectMany(g => g);
var list = result.ToList();
Assert.AreEqual(91, list.Count);
}
[Test]
public void GroupByCalculateAggregateTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
group o by o.Customer
into g
select g.Sum(o => o.Freight);
var list = result.ToList();
Assert.AreEqual(89, list.Count);
}
[Test]
public void GroupByCalculateManyAggreagetes([NorthwindDataContext] string context)
{
Setup(context);
var result =
from o in db.Order
group o by o.Customer
into g
select new
{
Sum = g.Sum(o => o.Freight),
Min = g.Min(o => o.Freight),
Max = g.Max(o => o.Freight),
Avg = g.Average(o => o.Freight)
};
var list = result.ToList();
Assert.AreEqual(89, list.Count);
}
[Test]
public void GroupByAggregate([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
group c by c.Orders.Average(o => o.Freight) >= 80;
var list = result.ToList();
Assert.AreEqual(2, list.Count);
var firstGroupList = list.First(g => !g.Key).ToList();
Assert.AreEqual(71, firstGroupList.Count);
}
[Test]
public void ComplexGroupingTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
select new
{
c.CompanyName,
YearGroups =
from o in c.Orders
group o by o.OrderDate.Value.Year
into yg
select new
{
Year = yg.Key,
MonthGroups =
from o in yg
group o by o.OrderDate.Value.Month
into mg
select new {Month = mg.Key, Order = mg}
}
};
var list = result.ToList();
foreach (var customer in list)
{
var OrderList = customer.YearGroups.ToList();
Assert.LessOrEqual(OrderList.Count, 3);
}
}
#endregion
#region Set operations / Distinct tests
[Test]
public void ConcatTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.Where(c => c.Orders.Count <= 1)
.Concat(db.Customer.Where(c => c.Orders.Count > 1));
var list = result.ToList();
Assert.AreEqual(91, list.Count);
}
[Test]
public void UnionTest([NorthwindDataContext] string context)
{
Setup(context);
var result = (
from c in db.Customer
select c.Phone)
.Union(
from c in db.Customer
select c.Fax)
.Union(
from e in db.Employee
select e.HomePhone
);
var list = result.ToList();
Assert.AreEqual(167, list.Count);
}
[Test]
public void ExceptTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
db.Customer.Except(db.Customer.Where(c => c.Orders.Count() > 0));
var list = result.ToList();
Assert.AreEqual(2, list.Count);
}
[Test]
public void IntersectTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
db.Customer.Intersect(db.Customer.Where(c => c.Orders.Count() > 0));
var list = result.ToList();
Assert.AreEqual(89, list.Count);
}
[Test]
public void DistinctTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Order.Select(c => c.Freight).Distinct();
var list = result.ToList();
Assert.AreEqual(799, list.Count);
}
[Test]
public void DistinctTakeLastTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
(from o in db.Order
orderby o.OrderDate
select o.OrderDate).Distinct().Take(5);
var list = result.ToList();
Assert.AreEqual(5, list.Count);
}
[Test]
public void DistinctTakeFirstTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
(from o in db.Order
orderby o.OrderDate
select o.OrderDate).Take(5).Distinct();
var list = result.ToList();
Assert.AreEqual(4, list.Count);
}
[Test]
public void DistinctEntityTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.Distinct();
var list = result.ToList();
Assert.AreEqual(91, list.Count);
}
[Test]
public void DistinctAnonymousTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.Select(c => new {c.Region, c.City}).Distinct();
var list = result.ToList();
Assert.AreEqual(69, list.Count);
}
#endregion
#region Type casts
[Test]
public void TypeCastIsChildTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Product.Where(p => p is DiscontinuedProduct);
var expected = db.Product.ToList().Where(p => p is DiscontinuedProduct);
var list = result.ToList();
Assert.Greater(list.Count, 0);
Assert.AreEqual(expected.Count(), list.Count);
}
[Test]
public void TypeCastIsParentTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Product.Where(p => p is Product);
var expected = db.Product.ToList();
var list = result.ToList();
Assert.Greater(list.Count, 0);
Assert.AreEqual(expected.Count(), list.Count);
}
[Test, ActiveIssue(573)]
public void TypeCastIsChildConditionalTest([NorthwindDataContext] string context)
{
//TODO: sdanyliv: strange test for me
Setup(context);
var result = db.Product
.Select(x => x is DiscontinuedProduct
? x
: null);
var expected = db.Product.ToList()
.Select(x => x is DiscontinuedProduct
? x
: null);
var list = result.ToList();
Assert.Greater(list.Count, 0);
Assert.AreEqual(expected.Count(), list.Count);
Assert.IsTrue(list.Except(expected).Count() == 0);
Assert.IsTrue(list.Contains(null));
}
[Test]
public void TypeCastOfTypeTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Product.OfType<DiscontinuedProduct>();
var expected = db.Product.ToList().OfType<DiscontinuedProduct>();
var list = result.ToList();
Assert.Greater(list.Count, 0);
Assert.AreEqual(expected.Count(), list.Count);
}
[Test]
public void TypeCastAsTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.DiscontinuedProduct
.Select(discontinuedProduct => discontinuedProduct as Product)
.Select(product =>
product == null
? "NULL"
: product.ProductName);
var expected = db.DiscontinuedProduct.ToList()
.Select(discontinuedProduct => discontinuedProduct as Product)
.Select(product =>
product == null
? "NULL"
: product.ProductName);
var list = result.ToList();
Assert.Greater(list.Count, 0);
Assert.AreEqual(expected.Count(), list.Count);
Assert.IsTrue(list.Except(expected).Count() == 0);
}
#endregion
#region Element operations
[Test]
public void FirstTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.First();
Assert.IsNotNull(customer);
}
[Test]
public void FirstOrDefaultTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.CustomerID == "ALFKI").FirstOrDefault();
Assert.IsNotNull(customer);
}
[Test]
public void FirstPredicateTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.First(c => c.CustomerID == "ALFKI");
Assert.IsNotNull(customer);
}
[Test]
public void NestedFirstOrDefaultTest([IncludeDataSources(TestProvName.Northwind)] string context)
{
Setup(context);
var result =
from p in db.Product
select new
{
ProductID = p.ProductID,
MaxOrder = db.OrderDetail
.Where(od => od.Product == p)
.OrderByDescending(od => od.UnitPrice * od.Quantity)
.FirstOrDefault()
.Order
};
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
[Test]
public void FirstOrDefaultEntitySetTest([IncludeDataSources(TestProvName.Northwind)] string context)
{
Setup(context);
var customersCount = Customers.Count;
var result = db.Customer.Select(c => c.Orders.FirstOrDefault());
var list = result.ToList();
Assert.AreEqual(customersCount, list.Count);
}
[Test]
public void NestedSingleOrDefaultTest([IncludeDataSources(TestProvName.Northwind)] string context)
{
Setup(context);
var customersCount = Customers.Count;
var result = db.Customer.Select(c => c.Orders.Take(1).SingleOrDefault());
var list = result.ToList();
Assert.AreEqual(customersCount, list.Count);
}
[Test]
public void NestedSingleTest([IncludeDataSources(TestProvName.Northwind)] string context)
{
Setup(context);
var result = db.Customer.Where(c => c.Orders.Count() > 0).Select(c => c.Orders.Take(1).Single());
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
[Test]
public void ElementAtTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.OrderBy(c => c.CustomerID).ElementAt(15);
Assert.IsNotNull(customer);
Assert.AreEqual("CONSH", customer.CustomerID);
}
[Test]
public void NestedElementAtTest([IncludeDataSources(TestProvName.Northwind)] string context)
{
Setup(context);
var result =
from c in db.Customer
where c.Orders.Count() > 5
select c.Orders.ElementAt(3);
var list = result.ToList();
Assert.AreEqual(63, list.Count);
}
#endregion
#region Contains / Any / All tests
[Test]
public void AllNestedTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
where
db.Order.Where(o => o.Customer == c)
.All(o => db.Employee.Where(e => o.Employee == e).Any(e => e.FirstName.StartsWith("A")))
select c;
var list = result.ToList();
Assert.AreEqual(2, list.Count);
}
[Test]
public void ComplexAllTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
(from o in db.Order
where
db.Customer.Where(c => c == o.Customer).All(c => c.CompanyName.StartsWith("A")) ||
db.Employee.Where(e => e == o.Employee).All(e => e.FirstName.EndsWith("t"))
select o).ToList();
var expected =
from o in Order
where
Customers.Where(c => c == o.Customer).All(c => c.CompanyName.StartsWith("A")) ||
Employees.Where(e => e == o.Employee).All(e => e.FirstName.EndsWith("t"))
select o;
Assert.AreEqual(0, expected.Except(result).Count());
Assert.AreEqual(result.ToList().Count, 366);
}
[Test]
public void ContainsNestedTest([NorthwindDataContext] string context)
{
Setup(context);
var result = from c in db.Customer
select new
{
Customer = c,
HasNewOrder = db.Order
.Where(o => o.OrderDate > new DateTime(2001, 1, 1))
.Select(o => o.Customer)
.Contains(c)
};
var resultList = result.ToList();
var expected =
from c in Customers
select new
{
Customer = c,
HasNewOrder = Order
.Where(o => o.OrderDate > new DateTime(2001, 1, 1))
.Select(o => o.Customer)
.Contains(c)
};
Assert.AreEqual(0, expected.Except(resultList).Count());
Assert.AreEqual(0, resultList.Count(i => i.HasNewOrder));
}
[Test]
public void AnyTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.Where(c => c.Orders.Any(o => o.Freight > 400)).ToList();
var expected = Customers.Where(c => c.Orders.Any(o => o.Freight > 400));
Assert.AreEqual(0, expected.Except(result).Count());
Assert.AreEqual(10, result.ToList().Count);
}
[Test]
public void AnyParameterizedTest([NorthwindDataContext] string context)
{
Setup(context);
var ids = new[] {"ABCDE", "ALFKI"};
var result = db.Customer.Where(c => ids.Any(id => c.CustomerID == id));
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
[Test]
public void ContainsParameterizedTest([NorthwindDataContext] string context)
{
Setup(context);
var customerIDs = new[] {"ALFKI", "ANATR", "AROUT", "BERGS"};
var result = db.Order.Where(o => customerIDs.Contains(o.Customer.CustomerID));
var list = result.ToList();
Assert.Greater(list.Count, 0);
Assert.AreEqual(41, list.Count);
}
#endregion
#region Aggregates tests
[Test]
public void SumTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var sum = db.Order.Select(o => o.Freight).Sum();
var sum1 = Order.Select(o => o.Freight).Sum();
Assert.AreEqual((double)sum1, (double)sum, doubleDelta);
}
[Test]
public void CountPredicateTest([NorthwindDataContext] string context)
{
Setup(context);
var count = db.Order.Count(o => o.OrderID > 10);
var count1 = Order.Count(o => o.OrderID > 10);
Assert.AreEqual(count1, count);
}
[Test]
public void NestedCountTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.Where(c => db.Order.Count(o => o.Customer.CustomerID == c.CustomerID) > 5);
var expected = Customers.Where(c => db.Order.Count(o => o.Customer.CustomerID == c.CustomerID) > 5);
Assert.IsTrue(expected.Except(result).Count() == 0);
}
[Test]
public void NullableSumTest([NorthwindDataContext] string context)
{
Setup(context);
var sum = db.Order.Select(o => (int?) o.OrderID).Sum();
var sum1 = Order.Select(o => (int?) o.OrderID).Sum();
Assert.AreEqual(sum1, sum);
}
[Test]
public void MaxCountTest([NorthwindDataContext] string context)
{
Setup(context);
var max = db.Customer.Max(c => db.Order.Count(o => o.Customer.CustomerID == c.CustomerID));
var max1 = Customers.Max(c => Order.Count(o => o.Customer.CustomerID == c.CustomerID));
Assert.AreEqual(max1, max);
}
#endregion
#region Join tests
[Test]
public void GroupJoinTest([NorthwindDataContext] string context)
{
//TODO: sdanyliv: o.Customer.CustomerID - it is association that means additional JOIN. We have to decide if it is a bug.
Setup(context);
var result =
from c in db.Customer
join o in db.Order on c.CustomerID equals o.Customer.CustomerID into go
join e in db.Employee on c.City equals e.City into ge
select new
{
OrderCount = go.Count(),
EmployeesCount = ge.Count()
};
var list = result.ToList();
Assert.AreEqual(91, list.Count);
}
[Test]
public void JoinTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from p in db.Product
join s in db.Supplier on p.Supplier.SupplierID equals s.SupplierID
select new {p.ProductName, s.ContactName, s.Phone};
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
[Test]
public void JoinByAnonymousTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
join o in db.Order on new {Customer = c, Name = c.ContactName} equals
new {o.Customer, Name = o.Customer.ContactName}
select new {c.ContactName, o.OrderDate};
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
[Test]
public void LeftJoinTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Category
join p in db.Product on c.CategoryID equals p.Category.CategoryID into g
from p in g.DefaultIfEmpty()
select new {Name = p == null ? "Nothing!" : p.ProductName, c.CategoryName};
var list = result.ToList();
Assert.AreEqual(77, list.Count);
}
#endregion
#region References tests
[Test]
public void JoinByReferenceTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
join o in db.Order on c equals o.Customer
select new {c.ContactName, o.OrderDate};
var list = result.ToList();
Assert.AreEqual(830, list.Count);
}
[Test]
public void CompareReferenceTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from c in db.Customer
from o in db.Order
where c == o.Customer
select new {c.ContactName, o.OrderDate};
var list = result.ToList();
Assert.AreEqual(830, list.Count);
}
[Test]
public void ReferenceNavigationTestTest([NorthwindDataContext] string context)
{
Setup(context);
var result =
from od in db.OrderDetail
where od.Product.Category.CategoryName == "Seafood"
select new {od.Order, od.Product};
var list = result.ToList();
Assert.AreEqual(330, list.Count);
foreach (var anonymous in list)
{
Assert.IsNotNull(anonymous);
Assert.IsNotNull(anonymous.Order);
Assert.IsNotNull(anonymous.Product);
}
}
[Test]
public void EntitySetCountTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Category.Where(c => c.Products.Count > 10);
var list = result.ToList();
Assert.AreEqual(4, list.Count);
}
#endregion
#region Complex tests
[Test]
public void ComplexTest1([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Supplier.Select(
supplier => db.Product.Select(
product => db.Product.Where(p =>
p.ProductID == product.ProductID && p.Supplier.SupplierID == supplier.SupplierID)))
.ToList();
var count = result.Count;
Assert.Greater(count, 0);
foreach (var queryable in result)
{
foreach (var queryable1 in queryable)
{
foreach (var product in queryable1)
{
Assert.IsNotNull(product);
}
}
}
}
[Test, ActiveIssue(573, Details = "'k.CompanyName' cannot be converted to SQL.")]
public void ComplexTest2([NorthwindDataContext] string context)
{
Setup(context);
//TODO: sdanyliv: It can be replaced by the following linq expression. We have to decide that we have time to implement.
var r = from c in db.Customer
group c by c.Country
into g
from gi in g
where gi.CompanyName.Substring(0, 1) == g.Key.Substring(0, 1)
select gi;
var result = db.Customer
.GroupBy(c => c.Country,
(country, customers) =>
customers.Where(k => k.CompanyName.Substring(0, 1) == country.Substring(0, 1)))
.SelectMany(k => k);
var expected = Customers
.GroupBy(c => c.Country,
(country, customers) =>
customers.Where(k => k.CompanyName.Substring(0, 1) == country.Substring(0, 1)))
.SelectMany(k => k);
Assert.AreEqual(0, expected.Except(result).Count());
}
[Test]
public void ComplexTest3([NorthwindDataContext] string context)
{
Setup(context);
var products = db.Product;
var suppliers = db.Supplier;
var result = from p in products
select new
{
Product = p,
Suppliers = suppliers
.Where(s => s.SupplierID == p.Supplier.SupplierID)
.Select(s => s.CompanyName)
};
var list = result.ToList();
Assert.Greater(list.Count, 0);
foreach (var p in list)
foreach (var companyName in p.Suppliers)
Assert.IsNotNull(companyName);
}
[Test, ActiveIssue(573)]
public void ComplexTest4([NorthwindDataContext] string context)
{
//TODO: sdanyliv: This is a bug
Setup(context);
var result = db.Customer
.Take(2)
.Select(
c =>
db.Order.Select(o => db.Employee.Take(2).Where(e => e.Orders.Contains(o)))
.Where(o => o.Count() > 0))
.Select(os => os);
var list = result.ToList();
Assert.Greater(list.Count, 0);
foreach (var item in list)
item.ToList();
}
[Test]
public void ComplexTest5([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer
.Select(c => new {Customer = c, Order = db.Order})
.Select(i => i.Customer.Orders);
var list = result.ToList();
Assert.Greater(list.Count, 0);
foreach (var item in list)
item.ToList();
}
[Test]
public void ComplexTest6([NorthwindDataContext] string context)
{
Setup(context);
var r =
from c in db.Customer
from o in db.Order
where o.Customer == c
select new
{
Customer = c,
Order = o
};
var result = db.Customer
.Select(c => new {Customer = c, Order = db.Order.Where(o => o.Customer == c)})
.SelectMany(i => i.Order.Select(o => new {i.Customer, Order = o}));
var list = result.ToList();
Assert.Greater(list.Count, 0);
}
#endregion
#region Standard functions tests
[Test]
public void StringStartsWithTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Customer.Where(c => c.CustomerID.StartsWith("A") || c.CustomerID.StartsWith("L"));
var list = result.ToList();
Assert.AreEqual(13, list.Count);
}
[Test]
public void StringStartsWithParameterizedTest([NorthwindDataContext] string context)
{
Setup(context);
var likeA = "A";
var likeL = "L";
var result = db.Customer.Where(c => c.CustomerID.StartsWith(likeA) || c.CustomerID.StartsWith(likeL));
var list = result.ToList();
Assert.AreEqual(13, list.Count);
}
[Test]
public void StringLengthTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.City.Length == 7).First();
Assert.IsNotNull(customer);
}
[Test]
public void StringContainsTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.ContactName.Contains("and")).First();
Assert.IsNotNull(customer);
}
[Test]
public void StringToLowerTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.City.ToLower() == "seattle").First();
Assert.IsNotNull(customer);
}
[Test]
public void StringRemoveTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.City.Remove(3) == "Sea").First();
Assert.IsNotNull(customer);
}
[Test]
public void StringIndexOfTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.City.IndexOf("tt") == 3).First();
Assert.IsNotNull(customer);
}
[Test]
public void StringLastIndexOfTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.City.LastIndexOf("t", 1, 3) == 3).First();
Assert.IsNotNull(customer);
}
[Test]
public void StringPadLeftTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var customer = db.Customer.Where(c => "123" + c.City.PadLeft(8) == "123 Seattle").First();
Assert.IsNotNull(customer);
}
[Test]
public void DateTimeTest([NorthwindDataContext] string context)
{
Setup(context);
var order = db.Order.Where(o => o.OrderDate >= new DateTime(o.OrderDate.Value.Year, 1, 1)).First();
Assert.IsNotNull(order);
}
[Test]
public void DateTimeDayTest([NorthwindDataContext] string context)
{
Setup(context);
var order = db.Order.Where(o => o.OrderDate.Value.Day == 5).First();
Assert.IsNotNull(order);
}
[Test]
public void DateTimeDayOfWeek([NorthwindDataContext] string context)
{
Setup(context);
var order = db.Order.Where(o => o.OrderDate.Value.DayOfWeek == DayOfWeek.Friday).First();
Assert.IsNotNull(order);
}
[Test]
public void DateTimeDayOfYear([NorthwindDataContext] string context)
{
Setup(context);
var order = db.Order.Where(o => o.OrderDate.Value.DayOfYear == 360).First();
Assert.IsNotNull(order);
}
[Test]
public void MathAbsTest([NorthwindDataContext] string context)
{
Setup(context);
var order = db.Order.Where(o => Math.Abs(o.OrderID) == 10 || o.OrderID > 0).First();
Assert.IsNotNull(order);
}
[Test]
public void MathTrignometricTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var order = db.Order.Where(o => Math.Asin(Math.Cos(o.OrderID)) == 0 || o.OrderID > 0).First();
Assert.IsNotNull(order);
}
[Test]
public void MathFloorTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var result = db.Order.Where(o => Math.Floor(o.Freight) == 140);
var list = result.ToList();
Assert.AreEqual(2, list.Count);
}
[Test]
public void MathCeilingTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var result = db.Order.Where(o => Math.Ceiling(o.Freight) == 141);
var list = result.ToList();
Assert.AreEqual(2, list.Count);
}
[Test]
public void MathTruncateTest([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var result = db.Order.Where(o => Math.Truncate(o.Freight) == 141);
var list = result.ToList();
Assert.AreEqual(2, list.Count);
}
[Test]
public void MathRoundAwayFromZeroTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Order.Where(o => Math.Round(o.Freight / 10, 1, MidpointRounding.AwayFromZero) == 6.5m);
var list = result.ToList();
Assert.AreEqual(7, list.Count);
}
[Test]
public void MathRoundToEvenTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Order.Where(o => Math.Round(o.Freight / 10, 1, MidpointRounding.ToEven) == 6.5m);
var list = result.ToList();
Assert.AreEqual(6, list.Count);
}
[Test]
public void MathRoundDefaultTest([NorthwindDataContext] string context)
{
Setup(context);
var result = db.Order.Where(o => Math.Round(o.Freight / 10, 1) == 6.5m);
var list = result.ToList();
Assert.AreEqual(6, list.Count);
}
[Test]
public void ConvertToInt32([NorthwindDataContext(false, true)] string context)
{
Setup(context);
var expected = Order.Where(o => Convert.ToInt32(o.Freight * 10) == 592);
var result = db.Order.Where(o => Convert.ToInt32(o.Freight * 10) == 592);
var list = result.ToList();
Assert.AreEqual(expected.Count(), list.Count);
}
[Test]
public void StringCompareToTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => c.City.CompareTo("Seattle") >= 0).First();
Assert.IsNotNull(customer);
}
[Test]
public void ComparisonWithNullTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => null != c.City).First();
Assert.IsNotNull(customer);
}
[Test]
public void EqualsWithNullTest([NorthwindDataContext] string context)
{
Setup(context);
var customer = db.Customer.Where(c => !c.Address.Equals(null)).First();
Assert.IsNotNull(customer);
}
#endregion
}
}
| 27.645382 | 125 | 0.635533 | [
"MIT"
] | Kshitij-Kafle-123/linq2db | Tests/Linq/OrmBattle/OrmBattleTests.cs | 46,739 | C# |
// Copyright © 2015 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Platformus.Barebone.Backend.ViewModels.Shared
{
public class GridColumnViewModelFactory : ViewModelFactoryBase
{
public GridColumnViewModelFactory(IRequestHandler requestHandler)
: base(requestHandler)
{
}
public GridColumnViewModel Create(string name, string orderBy = null)
{
return new GridColumnViewModel()
{
Name = name,
OrderBy = string.IsNullOrEmpty(orderBy) ? null : orderBy.ToLower()
};
}
public GridColumnViewModel CreateEmpty()
{
return new GridColumnViewModel()
{
Name = " "
};
}
}
} | 26.4 | 111 | 0.675505 | [
"Apache-2.0"
] | 5118234/Platformus | src/Platformus.Barebone.Backend/Areas/Backend/ViewModels/Shared/GridColumn/GridColumnViewModelFactory.cs | 795 | C# |
using System.Reflection;
using System.Runtime.CompilerServices;
using Android.App;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("SwipeListView")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Chris Riesgo")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("2.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
| 34.793103 | 81 | 0.747275 | [
"Apache-2.0"
] | adlair/android-swipelistview-sharp | SwipeListView/Properties/AssemblyInfo.cs | 1,011 | C# |
using System;
using System.Threading.Tasks;
using LambdaSharp;
using LambdaSharp.SimpleNotificationService;
namespace Legacy.ModuleV081.MyTopicFunction {
public class Message {
//--- Properties ---
// TO-DO: add message properties
}
public sealed class Function : ALambdaTopicFunction<Message> {
//--- Methods ---
public override async Task InitializeAsync(LambdaConfig config) {
// TO-DO: add function initialization and reading configuration settings
}
public override async Task ProcessMessageAsync(Message message) {
// TO-DO: add business logic
}
}
}
| 22.793103 | 84 | 0.659607 | [
"Apache-2.0"
] | LambdaSharp/LambdaSharpTool | Tests/Legacy/v0.8.1/MyTopicFunction/Function.cs | 661 | C# |
//Credit to Martin Nerukar at Shark Bomb Studios for this code
//http://www.sharkbombs.com/2015/02/17/unity-editor-enum-flags-as-toggle-buttons/
//Used 10/31/2016
using UnityEngine;
public class EnumFlagAttribute : PropertyAttribute
{
public EnumFlagAttribute() { }
} | 27.1 | 81 | 0.771218 | [
"MIT"
] | HardlightVR/HL-Unity-pluginSDK | Assets/Hardlight SDK/Demos/Scripts/EnumFlagAttribute.cs | 273 | C# |
using JsonExcelExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
namespace DocumentCreator.Core.Model
{
/// <summary>
/// Represents the user-defined information of a mapping
/// </summary>
public class MappingData
{
/// <summary>
/// The mapping name
/// </summary>
[Required]
public string MappingName { get; set; }
/// <summary>
/// The template name
/// </summary>
[Required]
public string TemplateName { get; set; }
}
/// <summary>
/// Represents a mapping (an Excel workbook with mapping expression)
/// </summary>
public class Mapping : MappingData
{
/// <summary>
/// The template version
/// </summary>
[Required]
public string TemplateVersion { get; set; }
/// <summary>
/// The mapping version
/// </summary>
[Required]
public string MappingVersion { get; set; }
/// <summary>
/// The creation date
/// </summary>
public DateTime Timestamp { get; set; }
/// <summary>
/// The size of the mapping in bytes
/// </summary>
public long Size { get; set; }
/// <summary>
/// The filename of the mapping
/// </summary>
public string FileName { get; set; }
}
/// <summary>
/// Represents a mapping (an Excel workbook with mapping expression) with details
/// </summary>
public class MappingDetails : Mapping
{
/// <summary>
/// The stream with the contents of the mapping
/// </summary>
[JsonIgnore]
public Stream Buffer { get; set; }
/// <summary>
/// The expressions (Excel formulas) of the mapping
/// </summary>
[Required]
public IEnumerable<MappingExpression> Expressions { get; set; }
/// <summary>
/// The JSON sources of the mapping
/// </summary>
[Required]
public IEnumerable<EvaluationSource> Sources { get; set; }
}
public class MappingInfo
{
public IEnumerable<MappingExpression> Expressions { get; set; }
public IEnumerable<EvaluationSource> Sources { get; set; }
}
/// <summary>
/// An expression definition
/// </summary>
public class MappingExpression
{
/// <summary>
/// The name of the expression
/// </summary>
public string Name { get; set; }
/// <summary>
/// The cell address of the expression - can be used for reference
/// </summary>
public string Cell { get; set; }
/// <summary>
/// The excel formula
/// </summary>
public string Expression { get; set; }
/// <summary>
/// The name of the parent expression (if exists)
/// </summary>
public string Parent { get; set; }
/// <summary>
/// True if the expression is parent of other expressions
/// </summary>
public bool IsCollection { get; set; }
/// <summary>
/// The content of the expression in the template (used for hide/show content)
/// </summary>
public string Content { get; set; }
/// <summary>
/// The Excel format identifier of the cell for numeric expressions
/// </summary>
public int? NumFormatId { get; set; }
/// <summary>
/// The Excel format code of the cell for numeric expressions
/// </summary>
public string NumFormatCode { get; set; }
}
/// <summary>
/// Aggreagated information for a mapping or template
/// </summary>
public class MappingStats
{
/// <summary>
/// The mapping name
/// </summary>
public string MappingName { get; set; }
/// <summary>
/// The template name
/// </summary>
public string TemplateName { get; set; }
/// <summary>
/// The timestamp of latest version
/// </summary>
public DateTime Timestamp { get; set; }
/// <summary>
/// The total number of templates associated with the mapping.
/// It is 1 if template name is not null.
/// </summary>
public int Templates { get; set; }
/// <summary>
/// The total number of documents associated with the mapping and the template (if defined).
/// </summary>
public int Documents { get; set; }
}
public class FillMappingInfo
{
public string TemplateName { get; set; }
public string MappingName { get; set; }
public string TestUrl { get; set; }
public FillMappingPayload Payload { get; set; }
}
public class FillMappingResult
{
public string FileName { get; set; }
public Stream Buffer { get; set; }
}
/// <summary>
/// Information to fill a mapping Excel workbook
/// </summary>
public class FillMappingPayload
{
/// <summary>
/// A collection of JSON sources
/// </summary>
public IEnumerable<EvaluationSource> Sources { get; set; }
}
}
| 28.978261 | 100 | 0.551575 | [
"MIT"
] | pkokki/DocumentCreator | DocumentCreator.Core/Model/Mapping.cs | 5,334 | C# |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Data.Sql;
// 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("UDT")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UDT")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
//
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
| 30.125 | 83 | 0.740664 | [
"Apache-2.0"
] | michals96/CLR-UDT-App | UDT/UDT/Properties/AssemblyInfo.cs | 967 | C# |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;
// 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("Test.Droid")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test.Droid")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
// 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")]
// Add some common permissions, these can be removed if not needed
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
| 37.171429 | 85 | 0.734051 | [
"MIT"
] | AsimKhan2019/MVVM-Helpers | MvvmHelpers.Portable/Test/Test.Droid/Properties/AssemblyInfo.cs | 1,304 | C# |
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Square;
using Square.Utilities;
namespace Square.Models
{
public class UpdateItemTaxesRequest
{
public UpdateItemTaxesRequest(IList<string> itemIds,
IList<string> taxesToEnable = null,
IList<string> taxesToDisable = null)
{
ItemIds = itemIds;
TaxesToEnable = taxesToEnable;
TaxesToDisable = taxesToDisable;
}
/// <summary>
/// IDs for the CatalogItems associated with the CatalogTax objects being updated.
/// </summary>
[JsonProperty("item_ids")]
public IList<string> ItemIds { get; }
/// <summary>
/// IDs of the CatalogTax objects to enable.
/// </summary>
[JsonProperty("taxes_to_enable")]
public IList<string> TaxesToEnable { get; }
/// <summary>
/// IDs of the CatalogTax objects to disable.
/// </summary>
[JsonProperty("taxes_to_disable")]
public IList<string> TaxesToDisable { get; }
public Builder ToBuilder()
{
var builder = new Builder(ItemIds)
.TaxesToEnable(TaxesToEnable)
.TaxesToDisable(TaxesToDisable);
return builder;
}
public class Builder
{
private IList<string> itemIds;
private IList<string> taxesToEnable = new List<string>();
private IList<string> taxesToDisable = new List<string>();
public Builder(IList<string> itemIds)
{
this.itemIds = itemIds;
}
public Builder ItemIds(IList<string> value)
{
itemIds = value;
return this;
}
public Builder TaxesToEnable(IList<string> value)
{
taxesToEnable = value;
return this;
}
public Builder TaxesToDisable(IList<string> value)
{
taxesToDisable = value;
return this;
}
public UpdateItemTaxesRequest Build()
{
return new UpdateItemTaxesRequest(itemIds,
taxesToEnable,
taxesToDisable);
}
}
}
} | 29.363636 | 91 | 0.532895 | [
"Apache-2.0"
] | kaijaa/square-dotnet-sdk | Square/Models/UpdateItemTaxesRequest.cs | 2,584 | C# |
// 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 System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading;
namespace System.Collections
{
internal static class HashHelpers
{
public const int HashCollisionThreshold = 100;
public const int HashPrime = 101;
// Table of prime numbers to use as hash table sizes.
// A typical resize algorithm would pick the smallest prime number in this array
// that is larger than twice the previous capacity.
// Suppose our Hashtable currently has capacity x and enough elements are added
// such that a resize needs to occur. Resizing first computes 2x then finds the
// first prime in the table greater than 2x, i.e. if primes are ordered
// p_1, p_2, ..., p_i, ..., it finds p_n such that p_n-1 < 2x < p_n.
// Doubling is important for preserving the asymptotic complexity of the
// hashtable operations such as add. Having a prime guarantees that double
// hashing does not lead to infinite loops. IE, your hash function will be
// h1(key) + i*h2(key), 0 <= i < size. h2 and the size must be relatively prime.
public static readonly int[] primes = {
3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919,
1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591,
17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437,
187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,
1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369};
public static bool IsPrime(int candidate)
{
if ((candidate & 1) != 0)
{
int limit = (int)Math.Sqrt(candidate);
for (int divisor = 3; divisor <= limit; divisor += 2)
{
if ((candidate % divisor) == 0)
return false;
}
return true;
}
return (candidate == 2);
}
public static int GetPrime(int min)
{
if (min < 0)
throw new ArgumentException(SR.Arg_HTCapacityOverflow);
for (int i = 0; i < primes.Length; i++)
{
int prime = primes[i];
if (prime >= min) return prime;
}
//outside of our predefined table.
//compute the hard way.
for (int i = (min | 1); i < Int32.MaxValue; i += 2)
{
if (IsPrime(i) && ((i - 1) % HashPrime != 0))
return i;
}
return min;
}
// Returns size of hashtable to grow to.
public static int ExpandPrime(int oldSize)
{
int newSize = 2 * oldSize;
// Allow the hashtables to grow to maximum possible size (~2G elements) before encoutering capacity overflow.
// Note that this check works even when _items.Length overflowed thanks to the (uint) cast
if ((uint)newSize > MaxPrimeArrayLength && MaxPrimeArrayLength > oldSize)
{
Debug.Assert(MaxPrimeArrayLength == GetPrime(MaxPrimeArrayLength), "Invalid MaxPrimeArrayLength");
return MaxPrimeArrayLength;
}
return GetPrime(newSize);
}
// This is the maximum prime smaller than Array.MaxArrayLength
public const int MaxPrimeArrayLength = 0x7FEFFFFD;
// Used by Hashtable and Dictionary's SeralizationInfo .ctor's to store the SeralizationInfo
// object until OnDeserialization is called.
private static ConditionalWeakTable<object, SerializationInfo> s_serializationInfoTable;
internal static ConditionalWeakTable<object, SerializationInfo> SerializationInfoTable
{
get
{
if (s_serializationInfoTable == null)
Interlocked.CompareExchange(ref s_serializationInfoTable, new ConditionalWeakTable<object, SerializationInfo>(), null);
return s_serializationInfoTable;
}
}
}
}
| 41.706422 | 139 | 0.594589 | [
"MIT"
] | BigBadBleuCheese/corefx | src/Common/src/CoreLib/System/Collections/HashHelpers.cs | 4,546 | C# |
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
class Result
{
public static void countApplesAndOranges(int s, int t, int a, int b, List<int> apples, List<int> oranges)
{
var A=0;
var O=0;
for(var i=0;i<apples.Count;i++)
{
apples[i]=apples[i]+a;
if(apples[i]>=s && apples[i]<=t)
{
A++;
}
}
for(int j=0;j<oranges.Count;j++)
{
oranges[j]=oranges[j]+b;
if(oranges[j]>=s && oranges[j]<=t)
{
O++;
}
}
System.Console.WriteLine(A);
System.Console.WriteLine(O);
}
}
class Solution
{
public static void Main(string[] args)
{
string[] firstMultipleInput = Console.ReadLine().TrimEnd().Split(' ');
int s = Convert.ToInt32(firstMultipleInput[0]);
int t = Convert.ToInt32(firstMultipleInput[1]);
string[] secondMultipleInput = Console.ReadLine().TrimEnd().Split(' ');
int a = Convert.ToInt32(secondMultipleInput[0]);
int b = Convert.ToInt32(secondMultipleInput[1]);
string[] thirdMultipleInput = Console.ReadLine().TrimEnd().Split(' ');
int m = Convert.ToInt32(thirdMultipleInput[0]);
int n = Convert.ToInt32(thirdMultipleInput[1]);
List<int> apples = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(applesTemp => Convert.ToInt32(applesTemp)).ToList();
List<int> oranges = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(orangesTemp => Convert.ToInt32(orangesTemp)).ToList();
Result.countApplesAndOranges(s, t, a, b, apples, oranges);
}
}
| 27.652778 | 138 | 0.609242 | [
"Apache-2.0"
] | revanthakula/Hackerrank-Algorithms- | Apples_Oranges.cs | 1,991 | C# |
using Caliburn.Micro;
using MiniCalendar.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace MiniCalendar.ViewModels
{
public class MainViewModel : PropertyChangedBase
{
// Important (usage)
// TODO: Make snooze time the time that is showen in the calendar instead of original reminder (also make for appointments and fix the way tasks are retreived)
// TODO: Make bottom buttons look better
// TODO: Style context menu
// TODO: Style delete message box
// TODO: Resizing to narrow doesn't look good
// TODO: When displaying an appointment, display the reccurence and not the series
// TODO: Weekly navigation: D:\Git\MiniCalendar\CurrentWeek.png
// The next stage
// TODO: minical -> focus point
// TODO: Add routine placeholder for food, dog, breakfest and more
// TODO: Add sport plugin that finds empty spots before and after eating
// TODO: Connect with stove/coffee machine to find out if I ate/drank
// Nice to have
// TODO: Don't crash when outlook isn't connected
// TODO: Allow browsing next week and on
// TODO: When hovering a day, adding the buttons at the bottom might create a scrollbar because items are almost filling the whole container, then the scrollbar will be pushing some almost long items, making them drop down one line, further affecting the ui
// TODO: Move data.item to the events themselves maybe
// TODO: Move outlook utils to item
// TODO: Hide context menu if empty (all items collapsed)
// TODO: Right click a task or appointment to covert to other type of event
// TODO: Show tasks with empty or expired reminders - where?
// TODO: Dark mode with selector - Remember dark mode, fix light mode colors
// TODO: Properly run updates on thread and timers
// TODO: Give thanks to: thenounproject, calibrun, TextBlockService
// TODO: Localization - First day of the week, dates, remove Hebrew text, hours
// TODO: Updates
// TODO: Installer
public MainViewModel()
{
if (Execute.InDesignMode)
{
RefreshDataDesignTime();
return;
}
var mapiNamespace = OutlookUtils.GetOutlookNameSpace();
OutlookUtils.HandleUpdateEvents(mapiNamespace, RefreshData);
var timer = new Timer(TimeSpan.FromMinutes(5).TotalMilliseconds);
#if DEBUG
timer.Interval = TimeSpan.FromSeconds(15).TotalMilliseconds;
#endif
timer.Elapsed += (s, e) => RefreshData();
timer.Start();
RefreshData();
var timerCurrentTime = new Timer(500);
timerCurrentTime.Elapsed += (s, e) => RefreshTime();
timerCurrentTime.Start();
}
private void RefreshTime()
{
CurrentTime = DateTime.Now;
SnoozeTime = SnoozeTime;
var eventsWithin30Minutes = Week.AllEvents().Where(wevent => wevent.Start - CurrentTime < TimeSpan.FromMinutes(30) && wevent.Start - CurrentTime > TimeSpan.Zero);
var eventsOrderedByDateAppoitmentFirst = eventsWithin30Minutes.OrderBy(wevent => (wevent.Type == EventType.Appointment ? DateTime.MinValue : wevent.Start));
// Only show events if there is an upcoming appointment
if (eventsOrderedByDateAppoitmentFirst.Any(eventi => eventi.Type == EventType.Appointment))
NextEvents = new BindableCollection<Event>(eventsOrderedByDateAppoitmentFirst);
else
NextEvents = new BindableCollection<Event>();
}
public bool PauseRefresh { get; set; } = false;
private bool isRefreshing = false;
public bool IsRefreshing
{
get { return isRefreshing; }
set
{
isRefreshing = value;
NotifyOfPropertyChange(() => isRefreshing);
}
}
#region Next Events
private bool isSnoozing = false;
public bool IsSnoozing
{
get { return isSnoozing; }
set
{
isSnoozing = value;
NotifyOfPropertyChange(() => isSnoozing);
}
}
private DateTime currentTime = DateTime.MinValue;
public DateTime CurrentTime
{
get { return currentTime; }
set
{
currentTime = value;
NotifyOfPropertyChange(() => currentTime);
}
}
private DateTime snoozeTime = DateTime.MinValue;
public DateTime SnoozeTime
{
get { return snoozeTime; }
set
{
snoozeTime = value;
NotifyOfPropertyChange(() => snoozeTime);
IsSnoozing = CurrentTime - SnoozeTime < TimeSpan.FromMinutes(5);
}
}
private BindableCollection<Event> nextEvents = new BindableCollection<Event>();
public BindableCollection<Event> NextEvents
{
get { return nextEvents; }
set
{
nextEvents = value;
NotifyOfPropertyChange(() => nextEvents);
}
}
public void Snooze()
{
SnoozeTime = DateTime.Now;
}
#endregion
private Week week = new Week();
public Week Week
{
get { return week; }
set
{
week = value;
NotifyOfPropertyChange(() => week);
}
}
private BindableCollection<MailItem> importantEMails = new BindableCollection<MailItem>();
public BindableCollection<MailItem> ImportantEMails
{
get { return importantEMails; }
set
{
importantEMails = value;
NotifyOfPropertyChange(() => importantEMails);
}
}
private void RefreshDataDesignTime()
{
var sunday = new DateTime(2021, 1, 3, 10, 0, 0);
var monday = sunday.AddDays(1);
var tuesday = sunday.AddDays(2);
var wednesday = sunday.AddDays(3);
var thursday = sunday.AddDays(4);
var friday = sunday.AddDays(5);
var saturday = sunday.AddDays(6);
Week = new Week(sunday, saturday, new List<Event> {
new Event { Start = sunday, End = sunday.AddHours(1), Type = EventType.Task, Subject = "Test" },
new Event { Start = tuesday, End = tuesday.AddHours(1), Type = EventType.Appointment, Subject = "Test2" },
new Event { Start = saturday, End = saturday.AddHours(1), Type = EventType.Appointment, Subject = "Test3" },
});
ImportantEMails = new BindableCollection<MailItem> { new MailItem { Start = sunday, Subject = "Test4" } };
}
async public void RefreshData()
{
if (!IsRefreshing && !PauseRefresh)
{
IsRefreshing = true;
await Task.Run(() =>
{
var oNamespace = OutlookUtils.GetOutlookNameSpace();
DateTime weekStart;
DateTime weekEnd;
if (DateTime.Now.DayOfWeek >= DayOfWeek.Thursday && DateTime.Now.DayOfWeek <= DayOfWeek.Saturday)
weekStart = DayOfWeek.Wednesday.GetThisWeekday();
else
weekStart = DayOfWeek.Sunday.GetThisWeekday();
weekEnd = weekStart.AddDays(6);
var apptItems = OutlookUtils.GetCalendarItems(oNamespace, weekStart, weekEnd);
var taskItems = OutlookUtils.GetTasksItems(oNamespace, weekStart, weekEnd);
Week = new Week(weekStart, weekEnd, apptItems.Concat(taskItems).OrderBy(item => item.Start).ToList());
});
await Task.Run(() =>
{
var oNamespace = OutlookUtils.GetOutlookNameSpace();
var flaggedMailItems = OutlookUtils.GetMailItems(oNamespace, true);
ImportantEMails = new BindableCollection<MailItem>(flaggedMailItems.OrderByDescending(item => item.Start));
});
IsRefreshing = false;
}
}
}
} | 37.736842 | 265 | 0.57113 | [
"MIT"
] | ivorco/MiniCalendar | src/ViewModels/MainViewModel.cs | 8,606 | C# |
using Landis.PlugIns;
using Landis.PlugIns.Admin;
using NUnit.Framework;
using System.Collections.Generic;
namespace Landis.Test.PlugIns.Admin
{
[TestFixture]
public class PersistentDataset_Test
{
private PersistentDataset.PlugInInfo fooPlugIn;
private PersistentDataset.PlugInInfo partialPlugIn;
//---------------------------------------------------------------------
[TestFixtureSetUp]
public void Init()
{
fooPlugIn = new PersistentDataset.PlugInInfo();
fooPlugIn.Name = "Foo Plug-in";
fooPlugIn.Version = "3.10";
fooPlugIn.TypeName = "succession";
fooPlugIn.AssemblyName = "Org.Bar.Foo";
fooPlugIn.ClassName = "Org.Bar.Foo.PlugIn";
fooPlugIn.UserGuidePath = "Foo PlugIn User Guide.pdf";
partialPlugIn = new PersistentDataset.PlugInInfo();
partialPlugIn.Name = "Partial Plug-in";
// No version
partialPlugIn.TypeName = "disturbance:wind";
partialPlugIn.AssemblyName = "Com.Acme";
partialPlugIn.ClassName = "Com.Acme.PlugIn";
// No user guide
}
//---------------------------------------------------------------------
private void CreateSaveLoadAndCompareDataset(string filename,
params PersistentDataset.PlugInInfo[] plugIns)
{
PersistentDataset dataset = new PersistentDataset();
foreach (PersistentDataset.PlugInInfo plugIn in plugIns)
dataset.PlugIns.Add(plugIn);
string path = Data.MakeOutputPath(filename);
dataset.Save(path);
PersistentDataset dataset2;
dataset2 = PersistentDataset.Load(path);
AssertAreEqual(dataset, dataset2);
}
//---------------------------------------------------------------------
[Test]
public void ZeroPlugIns()
{
CreateSaveLoadAndCompareDataset("ZeroPlugIns.xml");
}
//---------------------------------------------------------------------
[Test]
public void OnePlugIn()
{
CreateSaveLoadAndCompareDataset("OnePlugIn.xml", fooPlugIn);
}
//---------------------------------------------------------------------
[Test]
public void TwoPlugIns()
{
CreateSaveLoadAndCompareDataset("TwoPlugIns.xml", fooPlugIn,
partialPlugIn);
}
//---------------------------------------------------------------------
private void AssertAreEqual(PersistentDataset expected,
PersistentDataset actual)
{
Assert.IsNotNull(actual);
AssertAreEqual(expected.PlugIns, actual.PlugIns);
}
//---------------------------------------------------------------------
private void AssertAreEqual(List<PersistentDataset.PlugInInfo> expected,
List<PersistentDataset.PlugInInfo> actual)
{
Assert.IsNotNull(actual);
Assert.AreEqual(expected.Count, actual.Count);
for (int i = 0; i < expected.Count; i++)
AssertAreEqual(expected[i], actual[i]);
}
//---------------------------------------------------------------------
private void AssertAreEqual(PersistentDataset.PlugInInfo expected,
PersistentDataset.PlugInInfo actual)
{
Assert.IsNotNull(actual);
Assert.AreEqual(expected.Name, actual.Name);
Assert.AreEqual(expected.Version, actual.Version);
Assert.AreEqual(expected.TypeName, actual.TypeName);
Assert.AreEqual(expected.AssemblyName, actual.AssemblyName);
Assert.AreEqual(expected.ClassName, actual.ClassName);
Assert.AreEqual(expected.UserGuidePath, actual.UserGuidePath);
}
}
}
| 35.789474 | 100 | 0.493873 | [
"Apache-2.0"
] | LANDIS-II-Foundation/Core-Model | model/ext-admin-archive/test/PersistentDataset_Test.cs | 4,080 | C# |
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Xml;
using System.Web;
using CookComputing.XmlRpc;
using Graffiti.Core;
namespace Graffiti.BlogExtensions
{
[XmlRpcMissingMapping(MappingAction.Ignore)]
public struct PingResult
{
public XmlRpcBoolean flerror;
public string message;
}
/// <summary>
/// Enables pinging of community blogging sites such as weblogs.com after the weblog is updated.
/// </summary>
[Serializable]
public class XmlRpcPings : XmlRpcClientProtocol
{
#region Private Fields
private string siteName = string.Empty;
private string siteUrl = string.Empty;
private string siteFeedUrl = string.Empty;
private string[] pingServiceUrls = null;
#endregion
#region Constructor
public XmlRpcPings(string name, string url, string feedUrl, string[] pingUrls)
{
this.siteName = name;
this.siteUrl = url;
this.siteFeedUrl = feedUrl;
this.pingServiceUrls = pingUrls;
this.UserAgent = SiteSettings.VersionDescription;
this.Timeout = 60000;
// This improves compatibility with XML-RPC servers that do not fully comply with the XML-RPC specification.
this.NonStandard = XmlRpcNonStandard.All;
// Use a proxy server if one has been configured
SiteSettings siteSettings = SiteSettings.Get();
if (siteSettings.ProxyHost != string.Empty)
{
WebProxy proxy = new WebProxy(siteSettings.ProxyHost, siteSettings.ProxyPort);
proxy.BypassProxyOnLocal = siteSettings.ProxyBypassOnLocal;
if (siteSettings.ProxyUsername != string.Empty)
proxy.Credentials = new NetworkCredential(siteSettings.ProxyUsername, siteSettings.ProxyPassword);
this.Proxy = proxy;
}
}
#endregion
public static void SendPings(Post post, string pingUrls)
{
// Split ping urls into string array
string[] pingUrlsArray = pingUrls.Split('\n');
// Gather information to pass to ping service(s)
string name = SiteSettings.Get().Title;
string url = post.Category.IsUncategorized ? new Macros().FullUrl(new Urls().Home) : new Macros().FullUrl(post.Category.Url);
string feedUrl = SiteSettings.Get().ExternalFeedUrl ?? new Macros().FullUrl(VirtualPathUtility.ToAbsolute("~/feed/"));
XmlRpcPings pinger = new XmlRpcPings(name, url, feedUrl, pingUrlsArray);
ManagedThreadPool.QueueUserWorkItem(new WaitCallback(pinger.SendPings));
}
public void SendPings(object state)
{
if (pingServiceUrls == null || pingServiceUrls.Length == 0)
return;
foreach (string pingUrl in pingServiceUrls)
{
if (!string.IsNullOrEmpty(pingUrl))
{
this.Url = pingUrl.Trim();
bool result = false;
string errorMessage = string.Empty;
// Try to remember if the last ping to this URL supported the ExtendedPing spec, so we don't send out unnecessary pings repeatdly
bool isExtendedPing = true;
string lastPingResult = ZCache.Get<string>(CacheKey(pingUrl));
if (!string.IsNullOrEmpty(lastPingResult))
{
try { isExtendedPing = bool.Parse(lastPingResult); }
catch { }
}
if (isExtendedPing)
{
try
{
PingResult response = ExtendedPing(this.siteName, this.siteUrl, this.siteUrl, this.siteFeedUrl);
if (response.flerror != null && response.flerror == true)
{
if (string.IsNullOrEmpty(response.message))
errorMessage = "Remote weblogUpdates.extendedPing service indicated an error but provided no error message.";
else
errorMessage = response.message;
}
else
{
result = true;
}
}
catch (CookComputing.XmlRpc.XmlRpcException ex)
{
errorMessage = ex.Message;
}
catch (System.Exception ex)
{
errorMessage = ex.Message;
}
// If the ExtendedPing request failed, try a basic ping to this url
if (!result)
isExtendedPing = false;
}
if (!isExtendedPing)
{
try
{
PingResult response = BasicPing(this.siteName, this.siteUrl);
if (response.flerror != null && response.flerror == true)
{
if (string.IsNullOrEmpty(response.message))
errorMessage = "Remote weblogUpdates.ping service indicated an error but provided no error message.";
else
errorMessage = response.message;
}
else
{
result = true;
}
}
catch (CookComputing.XmlRpc.XmlRpcException ex)
{
errorMessage = ex.Message;
}
catch (System.Exception ex)
{
errorMessage = ex.Message;
}
}
// Log succcess or failure to EventLog
if (result)
{
// Remember whether extended or basic ping worked for this url in the future
ZCache.InsertCache(CacheKey(pingUrl), isExtendedPing.ToString(), 43200);
string message = String.Format("Blog Ping sent to {0}.", pingUrl);
Log.Info("Ping Sent", message);
}
else
{
string message = String.Format("Blog Ping attempt to the url {0} failed. Error message returned was: {1}.", pingUrl, errorMessage);
Log.Warn("Ping Error", message);
}
}
}
}
private string CacheKey(string url)
{
return string.Format("BlogExtensions:Pings:{0}", url);
}
[XmlRpcMethod("weblogUpdates.ping")]
public PingResult BasicPing(string name, string url)
{
return (PingResult)Invoke("BasicPing", new Object[] { name, url });
}
[XmlRpcMethod("weblogUpdates.extendedPing")]
public PingResult ExtendedPing(string name, string url, string checkUrl, string feedUrl)
{
return (PingResult)Invoke("ExtendedPing", new Object[] { name, url, checkUrl, feedUrl });
}
}
}
| 28.216749 | 137 | 0.674232 | [
"MIT"
] | harder/GraffitiCMS | plugins/BlogExtensions/Pings/XmlRpcPings.cs | 5,728 | C# |
using System;
using System.Text;
using System.Linq;
using Xunit;
using FluentAssertions;
using Nexogen.Libraries.Metrics.Extensions.Buckets;
namespace Nexogen.Libraries.Metrics.UnitTests.Extensions
{
public class ExponentialBucketGeneratorTest
{
ExponentialBucketGenerator generator = new ExponentialBucketGenerator();
[Fact]
public void ExponentialBuckets_for_IHistogramBuilder_null_builder_throws()
{
IHistogramBuilder builder = null;
Assert.Throws<ArgumentNullException>("builder", () => builder.ExponentialBuckets(1, 10, 3));
}
[Fact]
public void ExponentialBuckets_for_ILabelledHistogramBuilder_null_builder_throws()
{
ILabelledHistogramBuilder builder = null;
Assert.Throws<ArgumentNullException>("builder", () => builder.ExponentialBuckets(1, 10, 3));
}
[Theory]
[InlineDataAttribute(0)]
[InlineDataAttribute(-1)]
public void ExponentialBuckets_for_invalid_count_throws(int count)
{
Assert.Throws<ArgumentException>("count", () => generator.ExponentialBuckets(1, 10, count));
}
[Theory]
[InlineDataAttribute(-0.1)]
[InlineDataAttribute(0)]
[InlineDataAttribute(double.NegativeInfinity)]
[InlineDataAttribute(double.PositiveInfinity)]
[InlineDataAttribute(double.NaN)]
public void ExponentialBuckets_for_invalid_start_throws(double start)
{
Assert.Throws<ArgumentException>("start", () => generator.ExponentialBuckets(start, 10, 3));
}
[Theory]
[InlineDataAttribute(-0.1)]
[InlineDataAttribute(0)]
[InlineDataAttribute(0.1)]
[InlineDataAttribute(1)]
[InlineDataAttribute(double.NegativeInfinity)]
[InlineDataAttribute(double.PositiveInfinity)]
[InlineDataAttribute(double.NaN)]
public void ExponentialBuckets_for_invalid_factor_throws(double factor)
{
Assert.Throws<ArgumentException>("factor", () => generator.ExponentialBuckets(1, factor, 3));
}
[Fact]
public void ExponentialBuckets_single_bucket_is_generated_properly()
{
var expectedBuckets = new[] {
new Bucket(double.NegativeInfinity, 1),
new Bucket(1, double.PositiveInfinity)
};
var buckets = generator.ExponentialBuckets(1, 10, 1);
buckets.Should().BeEquivalentTo(expectedBuckets);
}
[Fact]
public void ExponentialBuckets_multiple_buckets_are_generated_properly()
{
var expectedBuckets = new[] {
new Bucket(double.NegativeInfinity, 1),
new Bucket(1, 10),
new Bucket(10, 100),
new Bucket(100, double.PositiveInfinity)
};
var buckets = generator.ExponentialBuckets(1, 10, 3);
buckets.Should().BeEquivalentTo(expectedBuckets);
}
}
}
| 33.967033 | 105 | 0.626011 | [
"MIT"
] | nexogen-international/Nexogen.Libraries.Metrics | Nexogen.Libraries.Metrics.UnitTests/Extensions/ExponentialBucketGeneratorTest.cs | 3,093 | C# |
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al.
//
// 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.
namespace MassTransit
{
using Courier.Contracts;
using MongoDbIntegration.Courier;
using MongoDbIntegration.Courier.Consumers;
using Pipeline.Filters.Partitioner;
public static class RoutingSlipEventConsumerConfigurationExtensions
{
/// <summary>
/// Configure the routing slip event consumers on a receive endpoint
/// </summary>
/// <param name="configurator"></param>
/// <param name="persister">The event persister used to save the events</param>
public static void RoutingSlipEventConsumers(this IReceiveEndpointConfigurator configurator, IRoutingSlipEventPersister persister)
{
configurator.Consumer(() => new RoutingSlipCompletedConsumer(persister));
configurator.Consumer(() => new RoutingSlipFaultedConsumer(persister));
configurator.Consumer(() => new RoutingSlipCompensationFailedConsumer(persister));
configurator.Consumer(() => new RoutingSlipRevisedConsumer(persister));
configurator.Consumer(() => new RoutingSlipTerminatedConsumer(persister));
}
/// <summary>
/// Configure the routing slip event consumers on a receive endpoint
/// </summary>
/// <param name="configurator"></param>
/// <param name="persister">The event persister used to save the events</param>
/// <param name="partitioner">Use a partitioner to reduce duplicate key errors</param>
public static void RoutingSlipEventConsumers(this IReceiveEndpointConfigurator configurator, IRoutingSlipEventPersister persister, IPartitioner partitioner)
{
configurator.Consumer(() => new RoutingSlipCompletedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipCompleted>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipFaultedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipFaulted>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipCompensationFailedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipCompensationFailed>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipRevisedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipRevised>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipTerminatedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipTerminated>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
}
/// <summary>
/// Configure the routing slip activity event consumers on a receive endpoint
/// </summary>
/// <param name="configurator"></param>
/// <param name="persister"></param>
public static void RoutingSlipActivityEventConsumers(this IReceiveEndpointConfigurator configurator, IRoutingSlipEventPersister persister)
{
configurator.Consumer(() => new RoutingSlipActivityCompensatedConsumer(persister));
configurator.Consumer(() => new RoutingSlipActivityCompletedConsumer(persister));
configurator.Consumer(() => new RoutingSlipActivityFaultedConsumer(persister));
configurator.Consumer(() => new RoutingSlipActivityCompensationFailedConsumer(persister));
}
/// <summary>
/// Configure the routing slip activity event consumers on a receive endpoint
/// </summary>
/// <param name="configurator"></param>
/// <param name="persister"></param>
/// <param name="partitioner">Use a partitioner to reduce duplicate key errors</param>
public static void RoutingSlipActivityEventConsumers(this IReceiveEndpointConfigurator configurator, IRoutingSlipEventPersister persister, IPartitioner partitioner)
{
configurator.Consumer(() => new RoutingSlipActivityCompensatedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipActivityCompensated>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipActivityCompletedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipActivityCompleted>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipActivityFaultedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipActivityFaulted>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
configurator.Consumer(() => new RoutingSlipActivityCompensationFailedConsumer(persister),
x => x.ConfigureMessage<RoutingSlipActivityCompensationFailed>(y => y.UsePartitioner(partitioner, p => p.Message.TrackingNumber)));
}
}
} | 64.920455 | 173 | 0.686855 | [
"Apache-2.0"
] | Johavale19/Johanna | src/Persistence/MassTransit.MongoDbIntegration/Courier/RoutingSlipEventConsumerConfigurationExtensions.cs | 5,715 | C# |
// 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 System.Threading;
using System.Threading.Tasks;
namespace System.Reactive.Disposables
{
public sealed class SingleAssignmentAsyncDisposable : IAsyncDisposable
{
private static readonly IAsyncDisposable Disposed = AsyncDisposable.Create(() => Task.CompletedTask);
private IAsyncDisposable _disposable;
public async Task AssignAsync(IAsyncDisposable disposable)
{
if (disposable == null)
throw new ArgumentNullException(nameof(disposable));
var old = Interlocked.CompareExchange(ref _disposable, disposable, null);
if (old == null)
return;
if (old != Disposed)
throw new InvalidOperationException("Disposable already assigned.");
await disposable.DisposeAsync().ConfigureAwait(false);
}
public Task DisposeAsync()
{
return Interlocked.Exchange(ref _disposable, Disposed)?.DisposeAsync() ?? Task.CompletedTask;
}
}
}
| 32.368421 | 109 | 0.665854 | [
"MIT"
] | ltrzesniewski/reactive | AsyncRx.NET/System.Reactive.Async.Disposables/System/Reactive/Disposables/SingleAssignmentAsyncDisposable.cs | 1,232 | C# |
using System.Collections.Generic;
using System.Management;
namespace WindowsMonitor.Hardware.Network
{
/// <summary>
/// </summary>
public sealed class PortStateData
{
public uint Direction { get; private set; }
public uint Flags { get; private set; }
public dynamic Header { get; private set; }
public uint MediaConnectState { get; private set; }
public uint RcvAuthorizationState { get; private set; }
public uint RcvControlState { get; private set; }
public ulong RcvLinkSpeed { get; private set; }
public uint SendAuthorizationState { get; private set; }
public uint SendControlState { get; private set; }
public ulong XmitLinkSpeed { get; private set; }
public static IEnumerable<PortStateData> Retrieve(string remote, string username, string password)
{
var options = new ConnectionOptions
{
Impersonation = ImpersonationLevel.Impersonate,
Username = username,
Password = password
};
var managementScope = new ManagementScope(new ManagementPath($"\\\\{remote}\\root\\wmi"), options);
managementScope.Connect();
return Retrieve(managementScope);
}
public static IEnumerable<PortStateData> Retrieve()
{
var managementScope = new ManagementScope(new ManagementPath("root\\wmi"));
return Retrieve(managementScope);
}
public static IEnumerable<PortStateData> Retrieve(ManagementScope managementScope)
{
var objectQuery = new ObjectQuery("SELECT * FROM MSNdis_PortStateData");
var objectSearcher = new ManagementObjectSearcher(managementScope, objectQuery);
var objectCollection = objectSearcher.Get();
foreach (ManagementObject managementObject in objectCollection)
yield return new PortStateData
{
Direction = (uint) (managementObject.Properties["Direction"]?.Value ?? default(uint)),
Flags = (uint) (managementObject.Properties["Flags"]?.Value ?? default(uint)),
Header = (dynamic) (managementObject.Properties["Header"]?.Value ?? default(dynamic)),
MediaConnectState = (uint) (managementObject.Properties["MediaConnectState"]?.Value ?? default(uint)),
RcvAuthorizationState = (uint) (managementObject.Properties["RcvAuthorizationState"]?.Value ?? default(uint)),
RcvControlState = (uint) (managementObject.Properties["RcvControlState"]?.Value ?? default(uint)),
RcvLinkSpeed = (ulong) (managementObject.Properties["RcvLinkSpeed"]?.Value ?? default(ulong)),
SendAuthorizationState = (uint) (managementObject.Properties["SendAuthorizationState"]?.Value ?? default(uint)),
SendControlState = (uint) (managementObject.Properties["SendControlState"]?.Value ?? default(uint)),
XmitLinkSpeed = (ulong) (managementObject.Properties["XmitLinkSpeed"]?.Value ?? default(ulong))
};
}
}
} | 46.65625 | 115 | 0.673811 | [
"MIT"
] | Biztactix/WindowsMonitor | WindowsMonitor.Standard/Hardware/Network/PortStateData.cs | 2,986 | C# |
// *** WARNING: this file was generated by the Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.AzureNative.Devices.V20200301.Outputs
{
[OutputType]
public sealed class IotDpsPropertiesDescriptionResponse
{
/// <summary>
/// Allocation policy to be used by this provisioning service.
/// </summary>
public readonly string? AllocationPolicy;
/// <summary>
/// List of authorization keys for a provisioning service.
/// </summary>
public readonly ImmutableArray<Outputs.SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionResponse> AuthorizationPolicies;
/// <summary>
/// Device endpoint for this provisioning service.
/// </summary>
public readonly string DeviceProvisioningHostName;
/// <summary>
/// Unique identifier of this provisioning service.
/// </summary>
public readonly string IdScope;
/// <summary>
/// List of IoT hubs associated with this provisioning service.
/// </summary>
public readonly ImmutableArray<Outputs.IotHubDefinitionDescriptionResponse> IotHubs;
/// <summary>
/// The IP filter rules.
/// </summary>
public readonly ImmutableArray<Outputs.IpFilterRuleResponse> IpFilterRules;
/// <summary>
/// Private endpoint connections created on this IotHub
/// </summary>
public readonly ImmutableArray<Outputs.PrivateEndpointConnectionResponse> PrivateEndpointConnections;
/// <summary>
/// The ARM provisioning state of the provisioning service.
/// </summary>
public readonly string? ProvisioningState;
/// <summary>
/// Whether requests from Public Network are allowed
/// </summary>
public readonly string? PublicNetworkAccess;
/// <summary>
/// Service endpoint for provisioning service.
/// </summary>
public readonly string ServiceOperationsHostName;
/// <summary>
/// Current state of the provisioning service.
/// </summary>
public readonly string? State;
[OutputConstructor]
private IotDpsPropertiesDescriptionResponse(
string? allocationPolicy,
ImmutableArray<Outputs.SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionResponse> authorizationPolicies,
string deviceProvisioningHostName,
string idScope,
ImmutableArray<Outputs.IotHubDefinitionDescriptionResponse> iotHubs,
ImmutableArray<Outputs.IpFilterRuleResponse> ipFilterRules,
ImmutableArray<Outputs.PrivateEndpointConnectionResponse> privateEndpointConnections,
string? provisioningState,
string? publicNetworkAccess,
string serviceOperationsHostName,
string? state)
{
AllocationPolicy = allocationPolicy;
AuthorizationPolicies = authorizationPolicies;
DeviceProvisioningHostName = deviceProvisioningHostName;
IdScope = idScope;
IotHubs = iotHubs;
IpFilterRules = ipFilterRules;
PrivateEndpointConnections = privateEndpointConnections;
ProvisioningState = provisioningState;
PublicNetworkAccess = publicNetworkAccess;
ServiceOperationsHostName = serviceOperationsHostName;
State = state;
}
}
}
| 37.323232 | 140 | 0.661976 | [
"Apache-2.0"
] | pulumi-bot/pulumi-azure-native | sdk/dotnet/Devices/V20200301/Outputs/IotDpsPropertiesDescriptionResponse.cs | 3,695 | C# |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
namespace NuGet.Services.Entities
{
public static class PackageExtensions
{
/// <summary>
/// Get the latest(last) uploaded symbols package for the given package.
/// </summary>
/// <param name="package"><see cref="Package"/> for which latest symbol package is to be retrieved.</param>
/// <returns>The latest symbol package if present, null otherwise</returns>
public static SymbolPackage LatestSymbolPackage(this Package package)
{
return package
.SymbolPackages?
.OrderByDescending(sp => sp.Created)
.FirstOrDefault();
}
/// <summary>
/// Returns true if there exists a symbol package which is latest and is in
/// available state, false otherwise.
/// </summary>
public static bool IsLatestSymbolPackageAvailable(this Package package)
{
var latestSymbolPackage = package.LatestSymbolPackage();
return latestSymbolPackage != null
&& latestSymbolPackage.StatusKey == PackageStatus.Available;
}
}
} | 38.852941 | 115 | 0.63134 | [
"Apache-2.0"
] | DalavanCloud/ServerCommon | src/NuGet.Services.Entities/Extensions/PackageExtensions.cs | 1,323 | C# |
/*
* Copyright 2015 Google Inc
*
* 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 System;
using Google.Apis.Dfareporting.v3_4;
using Google.Apis.Dfareporting.v3_4.Data;
namespace DfaReporting.Samples {
/// <summary>
/// This example downloads activity tags for a given floodlight activity.
/// </summary>
class DownloadFloodlightTags : SampleBase {
/// <summary>
/// Returns a description about the code example.
/// </summary>
public override string Description {
get {
return "This example downloads activity tags for a given floodlight" +
" activity.\n";
}
}
/// <summary>
/// Main method, to run this code example as a standalone application.
/// </summary>
/// <param name="args">The command line arguments.</param>
public static void Main(string[] args) {
SampleBase codeExample = new DownloadFloodlightTags();
Console.WriteLine(codeExample.Description);
codeExample.Run(DfaReportingFactory.getInstance());
}
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="service">An initialized Dfa Reporting service object
/// </param>
public override void Run(DfareportingService service) {
long activityId = long.Parse(_T("ENTER_ACTIVITY_ID_HERE"));
long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));
// Generate the floodlight activity tag.
FloodlightActivitiesResource.GeneratetagRequest request =
service.FloodlightActivities.Generatetag(profileId);
request.FloodlightActivityId = activityId;
FloodlightActivitiesGenerateTagResponse response = request.Execute();
if (response.GlobalSiteTagGlobalSnippet != null) {
// This is a global site tag, display both the global snippet and event snippet.
Console.WriteLine("Global site tag global snippet:\n\n{0}",
response.GlobalSiteTagGlobalSnippet);
Console.WriteLine("\n\nGlobal site tag event snippet:\n\n{0}",
response.FloodlightActivityTag);
} else {
// This is an image or iframe tag.
Console.WriteLine("Floodlight activity tag:\n\n{0}", response.FloodlightActivityTag);
}
}
}
}
| 36.6 | 93 | 0.688525 | [
"Apache-2.0"
] | googleads/googleads-dfa-reporting-samples | dotnet/v3.4/Floodlight/DownloadFloodlightTags.cs | 2,747 | C# |
using System;
using System.Threading.Tasks;
using Waf.NewsReader.Applications.Services;
using Xamarin.Essentials;
namespace Waf.NewsReader.Presentation.Services
{
public class LauncherService : ILauncherService
{
public Task LaunchBrowser(Uri uri)
{
return Browser.OpenAsync(uri, BrowserLaunchMode.External);
}
}
}
| 22.8125 | 70 | 0.709589 | [
"MIT"
] | DotNetUz/waf | src/NewsReader/NewsReader.Presentation/Services/LauncherService.cs | 367 | C# |
namespace Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview
{
using static Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Extensions;
/// <summary>Trigger context</summary>
public partial class TriggerContext
{
/// <summary>
/// <c>AfterFromJson</c> will be called after the json deserialization has finished, allowing customization of the object
/// before it is returned. Implement this method in a partial class to enable this behavior
/// </summary>
/// <param name="json">The JsonNode that should be deserialized into this object.</param>
partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject json);
/// <summary>
/// <c>AfterToJson</c> will be called after the json erialization has finished, allowing customization of the <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject"
/// /> before it is returned. Implement this method in a partial class to enable this behavior
/// </summary>
/// <param name="container">The JSON container that the serialization result will be placed in.</param>
partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject container);
/// <summary>
/// <c>BeforeFromJson</c> will be called before the json deserialization has commenced, allowing complete customization of
/// the object before it is deserialized.
/// If you wish to disable the default deserialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter.
/// Implement this method in a partial class to enable this behavior.
/// </summary>
/// <param name="json">The JsonNode that should be deserialized into this object.</param>
/// <param name="returnNow">Determines if the rest of the deserialization should be processed, or if the method should return
/// instantly.</param>
partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject json, ref bool returnNow);
/// <summary>
/// <c>BeforeToJson</c> will be called before the json serialization has commenced, allowing complete customization of the
/// object before it is serialized.
/// If you wish to disable the default serialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter.
/// Implement this method in a partial class to enable this behavior.
/// </summary>
/// <param name="container">The JSON container that the serialization result will be placed in.</param>
/// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return
/// instantly.</param>
partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject container, ref bool returnNow);
/// <summary>
/// Deserializes a <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode"/> into an instance of Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.ITriggerContext.
/// Note: the Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.ITriggerContext interface is polymorphic,
/// and the precise model class that will get deserialized is determined at runtime based on the payload.
/// </summary>
/// <param name="node">a <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode" /> to deserialize from.</param>
/// <returns>
/// an instance of Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.ITriggerContext.
/// </returns>
public static Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.ITriggerContext FromJson(Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode node)
{
if (!(node is Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject json))
{
return null;
}
// Polymorphic type -- select the appropriate constructor using the discriminator
switch ( json.StringProperty("objectType") )
{
case "AdhocBasedTriggerContext":
{
return new AdhocBasedTriggerContext(json);
}
case "ScheduleBasedTriggerContext":
{
return new ScheduleBasedTriggerContext(json);
}
}
return new TriggerContext(json);
}
/// <summary>
/// Serializes this instance of <see cref="TriggerContext" /> into a <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode" />.
/// </summary>
/// <param name="container">The <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject"/> container to serialize this object into. If the caller
/// passes in <c>null</c>, a new instance will be created and returned to the caller.</param>
/// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SerializationMode"/>.</param>
/// <returns>
/// a serialized instance of <see cref="TriggerContext" /> as a <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode" />.
/// </returns>
public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SerializationMode serializationMode)
{
container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject();
bool returnNow = false;
BeforeToJson(ref container, ref returnNow);
if (returnNow)
{
return container;
}
AddIf( null != (((object)this._objectType)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonString(this._objectType.ToString()) : null, "objectType" ,container.Add );
AfterToJson(ref container);
return container;
}
/// <summary>
/// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject into a new instance of <see cref="TriggerContext" />.
/// </summary>
/// <param name="json">A Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject instance to deserialize from.</param>
internal TriggerContext(Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonObject json)
{
bool returnNow = false;
BeforeFromJson(json, ref returnNow);
if (returnNow)
{
return;
}
{_objectType = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.Json.JsonString>("objectType"), out var __jsonObjectType) ? (string)__jsonObjectType : (string)ObjectType;}
AfterFromJson(json);
}
}
} | 63.916667 | 290 | 0.672751 | [
"MIT"
] | Khushboo-Baheti/azure-powershell | src/DataProtection/generated/api/Models/Api20210201Preview/TriggerContext.json.cs | 7,551 | C# |
using System;
namespace NAudio.WaveFormRenderer
{
public sealed class RmsPeakProvider : PeakProvider
{
private readonly int blockSize;
public RmsPeakProvider(int blockSize)
{
this.blockSize = blockSize;
}
public override PeakInfo GetNextPeak()
{
var samplesRead = Provider.Read(ReadBuffer, 0, ReadBuffer.Length);
var max = 0.0f;
for (int x = 0; x < samplesRead; x += blockSize)
{
double total = 0.0;
for (int y = 0; y < blockSize && x + y < samplesRead; y++)
{
total += ReadBuffer[x + y] * ReadBuffer[x + y];
}
var rms = (float) Math.Sqrt(total/blockSize);
max = Math.Max(max, rms);
}
return new PeakInfo(0 - max, max);
}
}
} | 26.470588 | 78 | 0.488889 | [
"MIT"
] | carbon/NAudio.WaveFormRenderer | WaveFormRendererLib/RmsPeakProvider.cs | 902 | C# |
using System;
namespace Imagin.Common.Input
{
/// <summary>
/// Specifies a changed value.
/// </summary>
/// <typeparam name="TValue">The kind of value.</typeparam>
public class ChangedValue<TValue>
{
readonly Tuple<TValue, TValue> _value;
/// <summary>
/// The old value.
/// </summary>
public TValue OldValue => _value.Item1;
/// <summary>
/// The new value.
/// </summary>
public TValue NewValue => _value.Item2;
/// <summary>
///
/// </summary>
/// <param name="OldValue"></param>
/// <param name="NewValue"></param>
public ChangedValue(TValue OldValue, TValue NewValue) => _value = Tuple.Create<TValue, TValue>(OldValue, NewValue);
}
}
| 25.677419 | 123 | 0.547739 | [
"BSD-2-Clause"
] | OkumaScott/Imagin.NET | Imagin.Common/Input/ChangedValue.Generic.cs | 798 | C# |
using System;
namespace LiveHAPI.Shared.Interfaces.Model
{
public interface IObsMemberScreening
{
DateTime BookingDate { get; set; }
Guid Eligibility { get; set; }
Guid IndexClientId { get; set; }
Guid EncounterId { get; set; }
Guid HivStatus { get; set; }
string Remarks { get; set; }
DateTime ScreeningDate { get; set; }
bool BookingMet { get; set; }
DateTime? DateBookingMet { get; set; }
Guid? TraceId { get; set; }
}
} | 28.722222 | 46 | 0.586074 | [
"MIT"
] | palladiumkenya/livehapi | LiveHAPI.Shared/Interfaces/Model/IObsMemberScreening.cs | 519 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using PossumLabs.Specflow.Core;
namespace PossumLabs.Specflow.Selenium
{
public static class Extensions
{
public static string LogFormat(this Dictionary<string, WebValidation> validations)
=> validations.Keys.Select(column => $"column:'{column}' with validation:'{validations[column].Text}'").LogFormat();
public static IEnumerable<T> Concat<T>(this IEnumerable<T> source, T item)
=>source.Concat(new List<T> { item });
public static TValue AddOrUpdate<TKey, TValue>(
this IDictionary<TKey, TValue> dict,
TKey key,
TValue addValue)
{
TValue existing;
if (dict.TryGetValue(key, out existing))
{
dict[key] = addValue;
}
else
{
dict.Add(key, addValue);
}
return addValue;
}
public static TValue AddUnlessPresent<TKey, TValue>(
this IDictionary<TKey, TValue> dict,
TKey key,
TValue addValue)
{
TValue existing;
if (!dict.TryGetValue(key, out existing))
{
dict.Add(key, addValue);
}
return addValue;
}
public static string SafeGetProperty(this IWebElement webElement, string name)
{
try
{
return webElement.GetProperty(name);
}
catch
{
return null;
}
}
public static void ScriptClear(this IJavaScriptExecutor ScriptExecutor, IWebElement e)
=> ScriptExecutor.ScriptSet(e, "");
public static void ScriptSet(this IJavaScriptExecutor ScriptExecutor, IWebElement e, string val)
{
var r = ScriptExecutor.ExecuteScript(@"
try{
var i = $(arguments[1]);
i.val(arguments[0]);
i.trigger( 'change' );
return i.val();
}
catch(err) {
return err
}", val, e);
if (r?.ToString() != val)
throw new Exception(r.ToString());
}
}
}
| 27.182927 | 128 | 0.545985 | [
"MIT"
] | BasHamer/PossumLabs.Specflow.Selenium | PossumLabs.Specflow.Selenium/Extensions.cs | 2,231 | C# |
using System;
using System.Collections.Generic;
namespace SitefinityWebApp.TorrentTrackerServices.Contracts
{
public interface ITaxonomyService
{
List<string> GetTaxonNamesByTaxonomy(string taxonomyName);
List<Guid> GetTaxonIdsByTaxonomy(List<string> taxonNames, string taxonomyName);
}
}
| 26.583333 | 87 | 0.768025 | [
"MIT"
] | annix8/Torrent-Tracker-Sitefinity | TorrentTracker/TorrentTrackerServices/Contracts/ITaxonomyService.cs | 321 | C# |
/*
* Copyright 2015 Google Inc
*
* 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 System;
using System.Collections.Generic;
using System.Linq;
using Google.Apis.Dfareporting.v3_2;
using Google.Apis.Dfareporting.v3_2.Data;
namespace DfaReporting.Samples {
/// <summary>
/// This example targets an ad to a remarketing list.
///
/// The first targetable remarketing list, either owned by or shared to the ad's advertiser,
/// will be used. To create a remarketing list, see CreateRemarketingList.cs. To share a
/// remarketing list with the ad's advertiser, see ShareRemarketingListToAdvertiser.cs.
/// </summary>
class TargetAdToRemarketingList : SampleBase {
/// <summary>
/// Returns a description about the code example.
/// </summary>
public override string Description {
get {
return "This example targets an ad to a remarketing list.\n\nThe first targetable" +
" remarketing list, either owned by or shared to the ad's advertiser, will be used." +
" To create a remarketing list, see CreateRemarketingList.cs. To share a remarketing" +
" list with the ad's advertiser, see ShareRemarketingListToAdvertiser.cs.\n";
}
}
/// <summary>
/// Main method, to run this code example as a standalone application.
/// </summary>
/// <param name="args">The command line arguments.</param>
public static void Main(string[] args) {
SampleBase codeExample = new TargetAdToRemarketingList();
Console.WriteLine(codeExample.Description);
codeExample.Run(DfaReportingFactory.getInstance());
}
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="service">An initialized Dfa Reporting service object
/// </param>
public override void Run(DfareportingService service) {
long adId = long.Parse(_T("INSERT_AD_ID_HERE"));
long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));
Ad ad = service.Ads.Get(profileId, adId).Execute();
TargetableRemarketingListsResource.ListRequest listRequest =
service.TargetableRemarketingLists.List(profileId, ad.AdvertiserId.Value);
listRequest.MaxResults = 1;
TargetableRemarketingListsListResponse lists = listRequest.Execute();
if(lists.TargetableRemarketingLists.Any()) {
// Select the first targetable remarketing list that was returned.
TargetableRemarketingList list = lists.TargetableRemarketingLists.First();
// Create a list targeting expression.
ListTargetingExpression expression = new ListTargetingExpression();
expression.Expression = list.Id.ToString();
// Update the ad.
ad.RemarketingListExpression = expression;
Ad result = service.Ads.Update(ad, profileId).Execute();
Console.WriteLine(
"Ad with ID {0} updated to use remarketing list expression: {1}.\n",
result.Id, result.RemarketingListExpression.Expression);
} else {
Console.WriteLine("No targetable remarketing lists found for ad with ID {0}.\n", adId);
}
}
}
}
| 39.956044 | 99 | 0.694719 | [
"Apache-2.0"
] | Ankan1991/googleads-dfa-reporting-samples | dotnet/v3.2/Remarketing/TargetAdToRemarketingList.cs | 3,638 | C# |
using System;
using System.Collections.Generic;
using System.Text;
using ZimaHrm.Core.Infrastructure.Result;
using FluentValidation;
namespace ZimaHrm.Core.Infrastructure.Validation
{
public abstract class Validator<T> : AbstractValidator<T>
{
protected Validator()
{
}
protected Validator(string errorMessage)
{
ErrorMessage = errorMessage;
}
private string ErrorMessage { get; }
public IResult Valid(T instance)
{
if (Equals(instance, default(T)))
{
return new ErrorResult(ErrorMessage);
}
var result = Validate(instance);
if (result.IsValid)
{
return new SuccessResult();
}
return new ErrorResult(ErrorMessage ?? result.ToString());
}
}
}
| 22.05 | 70 | 0.566893 | [
"Apache-2.0"
] | Dakicksoft/ZimaHrm | ZimaHrm.Infrastructure/Validation/Validator.cs | 884 | C# |
/*
SecureMessage
VERSION: 1.0
Inputs: Message to encrypt.
Outputs: Encrypted message.
Description: This software tool allows to encrypt and decrypt a message.
Developer: Nicolas CHEN
*/
using System;
using System.Windows.Forms;
namespace SecureMessage
{
public partial class SecureMessage : Form
{
public SecureMessage()
{
InitializeComponent();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void instructionsToolStripMenuItem_Click(object sender, EventArgs e)
{
SpecialMessageBox multiLines = new SpecialMessageBox();
string[] instructions = new string[]
{
"Welcome to Secure Message Software Tool"
, ""
, "This software tool aims to encrypt and decrypt a message."
, ""
, "There are two modes:"
, ""
, "1) Encrypt the message."
, ""
, "2) Decrypt the message"
};
multiLines.MessageBoxMultiLines(instructions);
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
SpecialMessageBox multiLinesAbout = new SpecialMessageBox();
string[] about = new string[]
{
"Secure Message Software Tool"
, ""
, "VERSION: 1.0"
, ""
, "Developed by Nicolas Chen"
};
multiLinesAbout.MessageBoxMultiLines(about);
}
private void encryptMode_Click(object sender, EventArgs e)
{
this.Hide();
EncryptMode encryptWindow = new EncryptMode();
encryptWindow.Show();
}
private void decryptMode_Click(object sender, EventArgs e)
{
this.Hide();
DecryptMode decryptWindow = new DecryptMode();
decryptWindow.Show();
}
}
} | 26.790123 | 85 | 0.517512 | [
"MIT"
] | hnjm/SecureMessage | SecureMessage/MainMenu.cs | 2,172 | C# |
using Windows.UI.Xaml.Controls;
namespace Coding4Fun.Toolkit.Controls
{
public class ColorSliderThumb : Control
{
public ColorSliderThumb()
{
DefaultStyleKey = typeof(ColorSliderThumb);
}
}
}
| 18.615385 | 56 | 0.632231 | [
"MIT"
] | Coding4FunProjects/Coding4FunToolk | Experimental/Sliders/Win8SuperSliderTest/App1/ColorSliderThumb.cs | 244 | C# |
using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Threading;
namespace Mrh.DataStructures.Buffer
{
/// <summary>
/// Creates a ring buffer that's backed by a memory mapped file.
/// File format is [number(long)][previous(long)][size(int)][msg(bytes)][-1next number(long)]
/// </summary>
public sealed class RingBufferMemoryMap : RingBufferBase, IDisposable
{
private const long _numberOffset = 0;
private const long _previousOffset = 8 + _numberOffset;
private const long _sizeOffset = 8 + _previousOffset;
private const long _msgOffset = 4 + _sizeOffset;
private readonly MemoryMappedFile _file;
private readonly bool _isCreated;
private readonly long _size;
private readonly MemoryMappedViewAccessor _view;
private long _currentPosition;
private long _nextFreeSlot;
/// <summary>
/// Creates a new memory mapped ring buffer.
/// </summary>
/// <param name="size">The size of the ring buffer to create.</param>
/// <param name="location">The location to store the ring buffer at.</param>
/// <param name="name">The name of the ring buffer.</param>
public RingBufferMemoryMap(long size, string location, string name)
{
_size = size;
_isCreated = !System.IO.File.Exists(location);
_file = MemoryMappedFile.CreateFromFile(location, FileMode.OpenOrCreate, name, size,
MemoryMappedFileAccess.ReadWrite);
_view = _file.CreateViewAccessor(0, size);
if (_isCreated)
{
// If created write -1 to the front of the ring buffer so it will find position 0 as the end.
_view.Write(0, -1L);
}
SeekToEnd();
}
public long LastNumber
{
get { return _view.ReadInt64(_currentPosition); }
}
public void Dispose()
{
try
{
_view.Dispose();
}
finally
{
_file.Dispose();
}
}
public override void Insert(byte[] msg, long number)
{
var size = msg.Length;
var totalLength = size + _msgOffset;
// Make sure to include the write ahead.
if (totalLength + 8 > _size - _nextFreeSlot)
{
_nextFreeSlot = 0;
}
_view.Write(_nextFreeSlot + _numberOffset, number);
_view.Write(_nextFreeSlot + _previousOffset, _currentPosition);
_view.Write(_nextFreeSlot + _sizeOffset, size);
_view.WriteArray(_nextFreeSlot + _msgOffset, msg, 0, size);
_view.Write(_nextFreeSlot + totalLength, -1L);
Interlocked.Exchange(ref _currentPosition, _nextFreeSlot);
Interlocked.Add(ref _nextFreeSlot, totalLength);
Fire(msg, number);
}
/// <summary>
/// Used to get a message from the current position.
/// </summary>
/// <param name="msgId">The id of the message to get.</param>
/// <returns></returns>
public override byte[] Get(long msgId)
{
var pos = _currentPosition;
var wrapped = false;
while (true)
{
var number = _view.ReadInt64(pos + _numberOffset);
if (number == msgId)
{
var size = _view.ReadInt32(pos + _sizeOffset);
var buffer = new byte[size];
_view.ReadArray(pos + _msgOffset, buffer, 0, size);
return buffer;
}
pos = _view.ReadInt64(pos + _previousOffset);
if (pos == 0)
{
if (wrapped)
{
return null;
}
wrapped = true;
}
}
}
/// <summary>
/// Finds the end of the ring buffer if opening from the file system.
/// </summary>
private void SeekToEnd()
{
var last = 0L;
var pos = 0L;
while (true)
{
var number = _view.ReadInt64(pos + _numberOffset);
if (number == -1)
{
Interlocked.Exchange(ref _currentPosition, last);
return;
}
var size = _view.ReadInt32(pos + _sizeOffset);
last = pos;
pos = pos + size + _msgOffset;
}
}
}
} | 34.525547 | 109 | 0.515222 | [
"Apache-2.0"
] | mrh0057/net-data-structures | Mrh.DataStructures/Buffer/RingBufferMemoryMap.cs | 4,732 | C# |
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Calculator.Tokenization;
namespace Calculator;
public class LexerError
{
public int Position { get; }
public LexerError(int position)
{
this.Position = position;
}
}
public class Lexer
{
private readonly Reader reader;
public Lexer(Reader reader)
{
this.reader = reader;
}
private static Regex floatingPointLiteralRegex = new Regex(@"\G[0-9]+\.[0-9]*");
private static Regex decimalLiteralRegex = new Regex(@"\G[0-9]+");
private static Regex binaryLiteralRegex = new Regex(@"\G0b[0-1]+");
private static Regex octalLiteralRegex = new Regex(@"\G0o[0-7]+");
private static Regex hexLiteralRegex = new Regex(@"\G0x[0-9A-Fa-f]+");
private static Regex identifierRegex = new Regex(@"\G[A-Za-z][A-Za-z0-9]*");
private static Regex operatorRegex = new Regex(@"\G(\+|\-|\*|\/|\^|and|or|not|log|ln|xor|sin|cos|tan|ctg|factorial|sqrt|\<\-)");
private static Regex whitespaceRegex = new Regex(@"\G[\s]+");
public Result<Token, LexerError> NextToken()
{
var current = reader.Peek();
if (current == -1)
{
return Result<Token, LexerError>.Of(new EndOfInputToken());
}
if (current == '(')
{
this.reader.Skip();
return Result<Token, LexerError>.Of(new OpenParen());
}
if (current == ')')
{
this.reader.Skip();
return Result<Token, LexerError>.Of(new CloseParen());
}
if ('0' <= current && current <= '9')
{
{
var match = reader.Match(hexLiteralRegex);
if (match.Success)
{
if (int.TryParse(match.Value.AsSpan().Slice(2), NumberStyles.HexNumber,
CultureInfo.InvariantCulture, out var number))
{
reader.Advance(match.Value.Length);
return Result<Token, LexerError>.Of(new HexadecimalIntegralLiteral(number));
}
else
{
return Result<Token, LexerError>.OfError(new LexerError(this.reader.Position));
}
}
}
{
var match = reader.Match(octalLiteralRegex);
if (match.Success)
{
var parseResult = ParseBase(match.Value.Substring(2), 8);
if(parseResult != null)
{
reader.Advance(match.Value.Length);
return Result<Token, LexerError>.Of(new OctalIntegralLiteral(parseResult.Value));
}
else
{
return Result<Token, LexerError>.OfError(new LexerError(this.reader.Position));
}
}
}
{
var match = reader.Match(binaryLiteralRegex);
if (match.Success)
{
var parseResult = ParseBase(match.Value.Substring(2), 2);
if(parseResult != null)
{
reader.Advance(match.Value.Length);
return Result<Token, LexerError>.Of(new BinaryIntegralLiteral(parseResult.Value));
}
else
{
return Result<Token, LexerError>.OfError(new LexerError(this.reader.Position));
}
}
}
{
var match = reader.Match(floatingPointLiteralRegex);
if (match.Success)
{
if (double.TryParse(match.Value, NumberStyles.Number | NumberStyles.AllowExponent,
CultureInfo.InvariantCulture, out var number))
{
reader.Advance(match.Value.Length);
return Result<Token, LexerError>.Of(new FloatingPointLiteral(number));
}
else
{
return Result<Token, LexerError>.OfError(new LexerError(this.reader.Position));
}
}
}
{
var match = reader.Match(decimalLiteralRegex);
if (match.Success)
{
if (int.TryParse(match.Value, NumberStyles.Number,
CultureInfo.InvariantCulture, out var number))
{
reader.Advance(match.Value.Length);
return Result<Token, LexerError>.Of(new DecimalIntegralLiteral(number));
}
else
{
return Result<Token, LexerError>.OfError(new LexerError(this.reader.Position));
}
}
}
}
var whitespaceMatch = reader.Match(whitespaceRegex);
if (whitespaceMatch.Success)
{
reader.Advance(whitespaceMatch.Value.Length);
return Result<Token, LexerError>.Of(new WhitespaceToken(whitespaceMatch.Value));
}
var operatorMatch = reader.Match(operatorRegex);
if (operatorMatch.Success)
{
reader.Advance(operatorMatch.Value.Length);
return Result<Token, LexerError>.Of(new OperatorToken(operatorMatch.Value));
}
var identifierMatch = reader.Match(identifierRegex);
if (identifierMatch.Success)
{
reader.Advance(identifierMatch.Value.Length);
return Result<Token, LexerError>.Of(new Identifier(identifierMatch.Value));
}
return Result<Token, LexerError>.OfError(new LexerError(reader.Position));
}
private int? ParseBase(string str, int b)
{
int currentExp = 1;
int sum = 0;
foreach (var c in str.Reverse())
{
int digit;
if ('a' <= c && c <= 'z')
{
digit = c - 'a' + 10;
}
else if ('A' <= c && c <= 'Z')
{
digit = c - 'A' + 10;
}
else if ('0' <= c && c <= '9')
{
digit = c - '0';
}
else
{
return null;
}
try
{
sum = checked(sum + currentExp * digit);
currentExp *= b;
}
catch (OverflowException)
{
return null;
}
}
return sum;
}
} | 33.221698 | 132 | 0.460883 | [
"MIT"
] | milleniumbug/ExpressionEvaluator | Calculator/Lexer.cs | 7,045 | C# |
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.AvalonEdit.AddIn
{
/// <summary>
/// Adapter between AvalonEdit InsightWindow and SharpDevelop IInsightWindow interface.
/// </summary>
public class SharpDevelopInsightWindow : OverloadInsightWindow, IInsightWindow
{
sealed class SDItemProvider : IOverloadProvider
{
readonly SharpDevelopInsightWindow insightWindow;
int selectedIndex;
public SDItemProvider(SharpDevelopInsightWindow insightWindow)
{
this.insightWindow = insightWindow;
insightWindow.items.CollectionChanged += insightWindow_items_CollectionChanged;
}
void insightWindow_items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged("Count");
OnPropertyChanged("CurrentHeader");
OnPropertyChanged("CurrentContent");
OnPropertyChanged("CurrentIndexText");
}
public event PropertyChangedEventHandler PropertyChanged;
public int SelectedIndex {
get {
return selectedIndex;
}
set {
if (selectedIndex != value) {
selectedIndex = value;
OnPropertyChanged("SelectedIndex");
OnPropertyChanged("CurrentHeader");
OnPropertyChanged("CurrentContent");
OnPropertyChanged("CurrentIndexText");
}
}
}
public int Count {
get { return insightWindow.Items.Count; }
}
public string CurrentIndexText {
get { return (selectedIndex + 1).ToString() + " of " + this.Count.ToString(); }
}
public object CurrentHeader {
get {
IInsightItem item = insightWindow.SelectedItem;
return item != null ? item.Header : null;
}
}
public object CurrentContent {
get {
IInsightItem item = insightWindow.SelectedItem;
return item != null ? item.Content : null;
}
}
void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
readonly ObservableCollection<IInsightItem> items = new ObservableCollection<IInsightItem>();
public SharpDevelopInsightWindow(TextArea textArea) : base(textArea)
{
this.Provider = new SDItemProvider(this);
this.Provider.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == "SelectedIndex")
OnSelectedItemChanged(EventArgs.Empty);
};
this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle;
AttachEvents();
}
public IList<IInsightItem> Items {
get { return items; }
}
public IInsightItem SelectedItem {
get {
int index = this.Provider.SelectedIndex;
if (index < 0 || index >= items.Count)
return null;
else
return items[index];
}
set {
this.Provider.SelectedIndex = items.IndexOf(value);
OnSelectedItemChanged(EventArgs.Empty);
}
}
TextDocument document;
Caret caret;
void AttachEvents()
{
document = this.TextArea.Document;
caret = this.TextArea.Caret;
if (document != null)
document.Changed += document_Changed;
if (caret != null)
caret.PositionChanged += caret_PositionChanged;
}
void caret_PositionChanged(object sender, EventArgs e)
{
OnCaretPositionChanged(e);
}
/// <inheritdoc/>
protected override void DetachEvents()
{
if (document != null)
document.Changed -= document_Changed;
if (caret != null)
caret.PositionChanged -= caret_PositionChanged;
base.DetachEvents();
}
void document_Changed(object sender, DocumentChangeEventArgs e)
{
if (DocumentChanged != null)
DocumentChanged(this, new TextChangeEventArgs(e.Offset, e.RemovedText, e.InsertedText));
}
public event EventHandler<TextChangeEventArgs> DocumentChanged;
public event EventHandler SelectedItemChanged;
protected virtual void OnSelectedItemChanged(EventArgs e)
{
if (SelectedItemChanged != null) {
SelectedItemChanged(this, e);
}
}
public event EventHandler CaretPositionChanged;
protected virtual void OnCaretPositionChanged(EventArgs e)
{
if (CaretPositionChanged != null) {
CaretPositionChanged(this, e);
}
}
}
}
| 26.851429 | 103 | 0.715684 | [
"MIT"
] | Plankankul/SharpDevelop-w-Framework | src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs | 4,701 | C# |
// dnlib: See LICENSE.txt for more info
using dnlib.DotNet.MD;
using System.Collections.Generic;
namespace dnlib.DotNet.Writer
{
/// <summary>
/// MD table interface
/// </summary>
public interface IMDTable
{
/// <summary>
/// Gets the table type
/// </summary>
Table Table { get; }
/// <summary>
/// <c>true</c> if the table is empty
/// </summary>
bool IsEmpty { get; }
/// <summary>
/// Gets the number of rows in this table
/// </summary>
int Rows { get; }
/// <summary>
/// Gets/sets a value indicating whether it's sorted
/// </summary>
bool IsSorted { get; set; }
/// <summary>
/// <c>true</c> if <see cref="SetReadOnly()"/> has been called
/// </summary>
bool IsReadOnly { get; }
/// <summary>
/// Gets/sets the <see cref="TableInfo"/>
/// </summary>
TableInfo TableInfo { get; set; }
/// <summary>
/// Called when the table can't be modified any more
/// </summary>
void SetReadOnly();
/// <summary>
/// Gets a raw row
/// </summary>
/// <param name="rid">Row ID</param>
/// <returns>The raw row</returns>
IRawRow Get(uint rid);
/// <summary>
/// Gets all raw rows
/// </summary>
IEnumerable<IRawRow> GetRawRows();
}
/// <summary>
/// Creates rows in a table. Rows can optionally be shared to create a compact table.
/// </summary>
/// <typeparam name="T">The raw row type</typeparam>
public sealed class MDTable<T> : IMDTable, IEnumerable<T> where T : IRawRow
{
readonly Table table;
readonly Dictionary<T, uint> cachedDict;
readonly List<T> cached;
TableInfo tableInfo;
bool isSorted;
bool isReadOnly;
/// <inheritdoc/>
public Table Table
{
get { return table; }
}
/// <inheritdoc/>
public bool IsEmpty
{
get { return cached.Count == 0; }
}
/// <inheritdoc/>
public int Rows
{
get { return cached.Count; }
}
/// <inheritdoc/>
public bool IsSorted
{
get { return isSorted; }
set { isSorted = value; }
}
/// <inheritdoc/>
public bool IsReadOnly
{
get { return isReadOnly; }
}
/// <inheritdoc/>
public TableInfo TableInfo
{
get { return tableInfo; }
set { tableInfo = value; }
}
/// <summary>
/// Gets the value with rid <paramref name="rid"/>
/// </summary>
/// <param name="rid">The row ID</param>
public T this[uint rid]
{
get { return cached[(int)rid - 1]; }
}
/// <inheritdoc/>
public IRawRow Get(uint rid)
{
return this[rid];
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="table">The table type</param>
/// <param name="equalityComparer">Equality comparer</param>
public MDTable(Table table, IEqualityComparer<T> equalityComparer)
{
this.table = table;
this.cachedDict = new Dictionary<T, uint>(equalityComparer);
this.cached = new List<T>();
}
/// <inheritdoc/>
public void SetReadOnly()
{
isReadOnly = true;
}
/// <summary>
/// Adds a row. If the row already exists, returns a rid to the existing one, else
/// it's created and a new rid is returned.
/// </summary>
/// <param name="row">The row. It's now owned by us and must NOT be modified by the caller.</param>
/// <returns>The RID (row ID) of the row</returns>
public uint Add(T row)
{
if (isReadOnly)
throw new ModuleWriterException(string.Format("Trying to modify table {0} after it's been set to read-only", table));
uint rid;
if (cachedDict.TryGetValue(row, out rid))
return rid;
return Create(row);
}
/// <summary>
/// Creates a new row even if this row already exists.
/// </summary>
/// <param name="row">The row. It's now owned by us and must NOT be modified by the caller.</param>
/// <returns>The RID (row ID) of the row</returns>
public uint Create(T row)
{
if (isReadOnly)
throw new ModuleWriterException(string.Format("Trying to modify table {0} after it's been set to read-only", table));
uint rid = (uint)cached.Count + 1;
if (!cachedDict.ContainsKey(row))
cachedDict[row] = rid;
cached.Add(row);
return rid;
}
/// <summary>
/// Re-adds all added rows. Should be called if rows have been modified after being
/// inserted.
/// </summary>
public void ReAddRows()
{
if (isReadOnly)
throw new ModuleWriterException(string.Format("Trying to modify table {0} after it's been set to read-only", table));
cachedDict.Clear();
for (int i = 0; i < cached.Count; i++)
{
uint rid = (uint)i + 1;
var row = cached[i];
if (!cachedDict.ContainsKey(row))
cachedDict[row] = rid;
}
}
/// <summary>
/// Reset the table.
/// </summary>
public void Reset()
{
if (isReadOnly)
throw new ModuleWriterException(string.Format("Trying to modify table {0} after it's been set to read-only", table));
cachedDict.Clear();
cached.Clear();
}
/// <inheritdoc/>
public IEnumerator<T> GetEnumerator()
{
return cached.GetEnumerator();
}
/// <inheritdoc/>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <inheritdoc/>
public IEnumerable<IRawRow> GetRawRows()
{
foreach (var rawRow in cached)
yield return rawRow;
}
}
}
| 28.668142 | 133 | 0.501158 | [
"MIT"
] | Owen0225/ConfuserEx-Plus | dnlib/src/DotNet/Writer/MDTable.cs | 6,479 | C# |
namespace FlexLib.Parsing
{
public class Token
{
public readonly string Type;
public readonly string Ligature;
public readonly string Input;
public readonly int Index;
public Token(string type, string input, int index)
: this(type, null, input, index) { }
public Token(string type, string ligature, string input, int index)
{
Type = type;
Ligature = ligature;
Input = input;
Index = index;
}
public override string ToString()
{
if (Ligature == null)
{
return Type;
}
else
{
return Ligature;
}
}
}
}
| 22.558824 | 75 | 0.479791 | [
"MIT"
] | matthewm8m/FlexLib | FlexLib/Parsing/Token.cs | 769 | C# |
// <auto-generated />
using System;
using DataAccess;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DataAccess.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20200829234509_UpdateCoveringPeriodToCoverPeriod")]
partial class UpdateCoveringPeriodToCoverPeriod
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("DataAccess.Models.Country", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(30)")
.HasMaxLength(30);
b.HasKey("Id");
b.ToTable("Countries");
});
modelBuilder.Entity("DataAccess.Models.CoverType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("CoverPercentage")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(100)")
.HasMaxLength(100);
b.HasKey("Id");
b.ToTable("CoverTypes");
});
modelBuilder.Entity("DataAccess.Models.Gender", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(10)")
.HasMaxLength(10);
b.HasKey("Id");
b.ToTable("Genders");
});
modelBuilder.Entity("DataAccess.Models.InsurancePolicy", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<long>("Cost")
.HasColumnType("bigint");
b.Property<byte>("CoverPeriod")
.HasColumnType("tinyint");
b.Property<int>("CoverTypeId")
.HasColumnType("int");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(300)")
.HasMaxLength(300);
b.Property<int>("LocationId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(30)")
.HasMaxLength(30);
b.Property<int>("RiskTypeId")
.HasColumnType("int");
b.Property<DateTime>("Start")
.HasColumnType("datetime2");
b.Property<string>("UserCreate")
.IsRequired()
.HasColumnType("nvarchar(20)")
.HasMaxLength(20);
b.HasKey("Id");
b.HasIndex("CoverTypeId");
b.HasIndex("LocationId");
b.HasIndex("RiskTypeId");
b.ToTable("InsurancePolicies");
});
modelBuilder.Entity("DataAccess.Models.Location", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("CountryId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CountryId");
b.ToTable("Locations");
});
modelBuilder.Entity("DataAccess.Models.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<int>("CountryId")
.HasColumnType("int");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(20)")
.HasMaxLength(20);
b.Property<int>("GenderId")
.HasColumnType("int");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(20)")
.HasMaxLength(20);
b.Property<DateTime>("Modified")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("CountryId");
b.HasIndex("GenderId");
b.ToTable("Person");
});
modelBuilder.Entity("DataAccess.Models.RiskType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(15)")
.HasMaxLength(15);
b.HasKey("Id");
b.ToTable("RiskTypes");
});
modelBuilder.Entity("DataAccess.Models.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(30)")
.HasMaxLength(30);
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DataAccess.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<DateTime>("LastActive")
.HasColumnType("datetime2");
b.Property<byte[]>("PasswordHash")
.IsRequired()
.HasColumnType("varbinary(max)");
b.Property<byte[]>("PasswordSalt")
.IsRequired()
.HasColumnType("varbinary(max)");
b.Property<int>("PersonId")
.HasColumnType("int");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(20)")
.HasMaxLength(20);
b.HasKey("Id");
b.HasIndex("PersonId");
b.ToTable("Users");
});
modelBuilder.Entity("DataAccess.Models.UserRoles", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles");
});
modelBuilder.Entity("DataAccess.Models.InsurancePolicy", b =>
{
b.HasOne("DataAccess.Models.CoverType", "CoverType")
.WithMany()
.HasForeignKey("CoverTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DataAccess.Models.Location", "Location")
.WithMany()
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DataAccess.Models.RiskType", "RiskType")
.WithMany()
.HasForeignKey("RiskTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DataAccess.Models.Location", b =>
{
b.HasOne("DataAccess.Models.Country", "Country")
.WithMany()
.HasForeignKey("CountryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DataAccess.Models.Person", b =>
{
b.HasOne("DataAccess.Models.Country", "Country")
.WithMany()
.HasForeignKey("CountryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DataAccess.Models.Gender", "Gender")
.WithMany()
.HasForeignKey("GenderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DataAccess.Models.User", b =>
{
b.HasOne("DataAccess.Models.Person", "Person")
.WithMany()
.HasForeignKey("PersonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DataAccess.Models.UserRoles", b =>
{
b.HasOne("DataAccess.Models.Role", "Role")
.WithMany("Users")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("DataAccess.Models.User", "User")
.WithMany("Roles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
| 36.451429 | 125 | 0.445132 | [
"Unlicense"
] | Kemma87/gap | Insurance.Api/DataAccess/Migrations/20200829234509_UpdateCoveringPeriodToCoverPeriod.Designer.cs | 12,760 | C# |
//-----------------------------------------------------------------------
// <copyright file="PrimitiveCriteriaSingle.cs" company="Marimer LLC">
// Copyright (c) Marimer LLC. All rights reserved.
// Website: http://www.lhotka.net/cslanet/
// </copyright>
// <summary>no summary</summary>
//-----------------------------------------------------------------------
using System.Collections.Generic;
using System.Text;
#if SILVERLIGHT
using Csla.Serialization;
#else
#endif
using Csla;
using System;
using Csla.Core;
namespace Csla.Test.DataPortalTest
{
#if TESTING
[System.Diagnostics.DebuggerNonUserCode]
#endif
[Serializable]
public class PrimitiveCriteriaSingle : BusinessBase<PrimitiveCriteriaSingle>
{
#region Business Methods
private static PropertyInfo<int> IdProperty = RegisterProperty(new PropertyInfo<int>("Id", "Id"));
public int Id
{
get { return GetProperty(IdProperty); }
set { SetProperty(IdProperty, value); }
}
private static PropertyInfo<string> MethodCalledProperty = RegisterProperty(new PropertyInfo<string>("MethodCalled", "MethodCalled"));
public string MethodCalled
{
get { return GetProperty(MethodCalledProperty); }
set { SetProperty(MethodCalledProperty, value); }
}
protected override object GetIdValue()
{
return Id;
}
#endregion
#region Factory Methods
public static void DeleteObject(int id, EventHandler<DataPortalResult<PrimitiveCriteriaSingle>> handler)
{
Csla.DataPortal.BeginDelete<PrimitiveCriteriaSingle>(id, handler);
}
public static void GetObject(int id, EventHandler<DataPortalResult<PrimitiveCriteriaSingle>> handler)
{
Csla.DataPortal.BeginFetch<PrimitiveCriteriaSingle>(id, handler);
}
public static void NewObject(int id, EventHandler<DataPortalResult<PrimitiveCriteriaSingle>> handler)
{
Csla.DataPortal.BeginCreate<PrimitiveCriteriaSingle>(id, handler);
}
public PrimitiveCriteriaSingle()
{ /* Require use of factory methods */ }
#endregion
#region Data Access
#if !SILVERLIGHT
#region DataPortal_Create
protected void DataPortal_Create(int id)
{
DoCreate(id);
}
private void DoCreate(int id)
{
Id = id;
ApplicationContext.GlobalContext.Clear();
ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", "Created");
MethodCalled = "Created";
if (id == 9999)
throw new Exception("Bad data");
}
#endregion
#region DataPortal_Fetch
private void DataPortal_Fetch(int id)
{
DoFetch(id);
}
private void DataPortal_Fetch(string id)
{
DoFetch(int.Parse(id));
}
private void DataPortal_Fetch(Guid id)
{
DoFetch(1234);
}
private void DoFetch(int id)
{
Id = id;
ApplicationContext.GlobalContext.Clear();
ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", "Fetched");
MethodCalled = "Fetched";
if (id == 9999)
throw new Exception("Bad data");
}
#endregion
#region DataPortal_Insert / DataPortal_Update / DataPortal_Delete
protected override void DataPortal_Insert()
{
DoInsertUpdate(false);
}
private void DoInsertUpdate(bool isUpdate)
{
var insertOrUpdate = isUpdate ? "Updated" : "Inserted";
ApplicationContext.GlobalContext.Clear();
ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", insertOrUpdate);
MethodCalled = insertOrUpdate;
}
#endregion
private void DataPortal_Delete(int id)
{
ApplicationContext.GlobalContext.Clear();
ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", "Deleted");
MethodCalled = "Deleted+" + id.ToString();
}
#endif
#endregion
}
} | 23.420732 | 138 | 0.658683 | [
"MIT"
] | angtianqiang/csla | Source/Csla.test/Silverlight/Server/DataPortal/PrimitiveCriteriaSingle.cs | 3,843 | C# |
/* ====================================================================
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.
==================================================================== */
using System;
using NPOI.XSSF.UserModel.Helpers;
using NUnit.Framework;
namespace TestCases.XSSF.UserModel.Helpers
{
/**
* Test the header and footer helper.
* As we go through XmlBeans, should always use &,
* and not &
*/
[TestFixture]
public class TestHeaderFooterHelper
{
[Test]
public void TestGetCenterLeftRightSection()
{
HeaderFooterHelper helper = new HeaderFooterHelper();
String headerFooter = "&CTest the center section";
Assert.AreEqual("Test the center section", helper.GetCenterSection(headerFooter));
headerFooter = "&CTest the center section<he left one&RAnd the right one";
Assert.AreEqual("Test the center section", helper.GetCenterSection(headerFooter));
Assert.AreEqual("The left one", helper.GetLeftSection(headerFooter));
Assert.AreEqual("And the right one", helper.GetRightSection(headerFooter));
}
[Test]
public void TestSetCenterLeftRightSection()
{
HeaderFooterHelper helper = new HeaderFooterHelper();
String headerFooter = "";
headerFooter = helper.SetCenterSection(headerFooter, "First Added center section");
Assert.AreEqual("First Added center section", helper.GetCenterSection(headerFooter));
headerFooter = helper.SetLeftSection(headerFooter, "First left");
Assert.AreEqual("First left", helper.GetLeftSection(headerFooter));
headerFooter = helper.SetRightSection(headerFooter, "First right");
Assert.AreEqual("First right", helper.GetRightSection(headerFooter));
Assert.AreEqual("&CFirst Added center section&LFirst left&RFirst right", headerFooter);
headerFooter = helper.SetRightSection(headerFooter, "First right&F");
Assert.AreEqual("First right&F", helper.GetRightSection(headerFooter));
Assert.AreEqual("&CFirst Added center section&LFirst left&RFirst right&F", headerFooter);
headerFooter = helper.SetRightSection(headerFooter, "First right&");
Assert.AreEqual("First right&", helper.GetRightSection(headerFooter));
Assert.AreEqual("&CFirst Added center section&LFirst left&RFirst right&", headerFooter);
}
}
}
| 46.714286 | 101 | 0.662385 | [
"Apache-2.0"
] | 68681395/npoi | testcases/ooxml/XSSF/UserModel/Helpers/TestHeaderFooterHelper.cs | 3,270 | C# |
using System;
using System.Collections;
using System.Collections.Generic;
namespace DotNetCoreTest.SinglyLinkedList
{
public class SinglyLinkedList<T> : IEnumerable<T>, ISinglyLinkedList<T>
{
private SinglyLinkedNode<T> head;
private bool recount;
private int count;
public int Count
{
get
{
if (this.recount) this.Recount();
return this.count;
}
}
public bool HasNodes
{
get
{
return !IsEmpty;
}
}
public bool IsEmpty
{
get
{
return head == null;
}
}
private bool AreEqual(T first, T second)
{
if (first == null) return second == null;
return first.Equals(second);
}
private void Recount()
{
this.recount = false;
var runningTotal = 0;
var node = this.head;
while (node != null)
{
node = node.Next;
runningTotal++;
}
this.count = runningTotal;
}
public IEnumerator<T> GetEnumerator()
{
var node = this.head;
while(node != null)
{
yield return node.Data;
node = node.Next;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public T this[int index]
{
get
{
if (index >= this.Count)
{
throw new Exception("Outside bounds of list");
}
var node = this.head;
for (int i = 0; i < index; i++)
{
node = node.Next;
}
return node.Data;
}
set
{
if (index >= this.Count)
{
throw new Exception("Outside bounds of list");
}
var node = this.head;
for (int i = 0; i < index; i++)
{
node = node.Next;
}
node.Data = value;
}
}
public T[] ToArray()
{
var array = new T[this.Count];
var node = this.head;
for (int i = 0; i < this.Count; i++)
{
array[i] = node.Data;
node = node.Next;
}
return array;
}
public SinglyLinkedNode<T>[] GetNodeArray()
{
var array = new SinglyLinkedNode<T>[this.Count];
var node = this.head;
for (int i = 0; i < this.Count; i++)
{
array[i] = node;
node = node.Next;
}
return array;
}
public T Get(int index)
{
return GetNode(index).Data;
}
public SinglyLinkedNode<T> GetNode(int index)
{
if (index >= this.Count)
{
throw new Exception("Outside bounds of list");
}
var node = this.head;
for (int i = 0; i < index; i++)
{
node = node.Next;
}
return node;
}
public T PopHead()
{
if (IsEmpty) throw new Exception("List is empty");
this.recount = true;
var node = this.head;
this.head = this.head.Next;
return node.Data;
}
public T PopTail()
{
if (IsEmpty) throw new Exception("List is empty");
this.recount = true;
if (this.head.Next == null)
{
var headData = this.head.Data;
this.head = null;
return headData;
}
var node = this.head;
while(node.Next.Next != null)
{
node = node.Next;
}
var data = node.Next.Data;
node.Next = null;
return data;
}
public int Find(T data)
{
var node = this.head;
var counter = 0;
while(node != null)
{
if (AreEqual(data, node.Data)) return counter;
node = node.Next;
counter++;
}
return -1;
}
public int[] FindAll(T data)
{
var list = new List<int>();
var node = this.head;
var counter = 0;
while(node != null)
{
if (AreEqual(data, node.Data)) list.Add(counter);
node = node.Next;
counter++;
}
return list.ToArray();
}
public void Add(T data)
{
this.recount = true;
var node = new SinglyLinkedNode<T>(data, this.head);
this.head = node;
}
public void Append(T data)
{
this.recount = true;
var newNode = new SinglyLinkedNode<T>(data, null);
if (this.head == null)
{
this.head = newNode;;
return;
}
var node = this.head;
while(node != null)
{
if (node.Next == null)
{
node.Next = newNode;
return;
}
node = node.Next;
}
}
public void Insert(T data, int index)
{
if (index > this.Count)
{
throw new Exception("Outside bounds of list");
}
if(index == 0)
{
this.Add(data);
return;
}
this.recount = true;
var node = this.head;
for (int i = 0; i < index - 1; i++)
{
node = node.Next;
}
var newNode = new SinglyLinkedNode<T>(data, node.Next);
node.Next = newNode;
}
public void Remove(T data)
{
if (this.IsEmpty) return;
this.recount = true;
while(this.head != null)
{
if (this.AreEqual(head.Data, data))
{
this.head = this.head.Next;
}
else break;
}
var node = this.head;
while(node != null)
{
if (node.Next != null && AreEqual(node.Next.Data, data))
{
node.Next = node.Next.Next;
}
else
{
node = node.Next;
}
}
}
public void RemoveByUID(long uid)
{
if (this.IsEmpty) return;
this.recount = true;
var node = this.head;
SinglyLinkedNode<T> prev = this.head;
while(node != null)
{
if (node.UID.Equals(uid))
{
if (node == this.head)
{
this.head = this.head.Next;
return;
}
prev.Next = node.Next;
return;
}
prev = node;
node = node.Next;
}
}
public void RemoveAt(int index)
{
if (index >= this.Count)
{
throw new Exception("Outside bounds of list");
}
this.recount = true;
if (index == 0)
{
this.head = this.head.Next;
return;
}
var node = this.head;
for (int i = 0; i < index; i++)
{
if (i + 1 == index)
{
node.Next = node.Next.Next;
return;
}
node = node.Next;
}
}
public void Reverse()
{
if (this.IsEmpty) return;
SinglyLinkedNode<T> prev = null;
var node = this.head;
SinglyLinkedNode<T> next = null;
while(node != null)
{
next = node.Next;
node.Next = prev;
prev = node;
node = next;
}
this.head = prev;
}
}
}
| 21.531707 | 75 | 0.370526 | [
"MIT"
] | XACT-RobA/dotnetcoretest | src/SinglyLinkedList/SinglyLinkedList.cs | 8,828 | C# |
using Renci.SshNet.Sftp;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests
{
/// <summary>
///This is a test class for SftpSynchronizeDirectoriesAsyncResultTest and is intended
///to contain all SftpSynchronizeDirectoriesAsyncResultTest Unit Tests
///</summary>
[TestClass()]
public class SftpSynchronizeDirectoriesAsyncResultTest : TestBase
{
/// <summary>
///A test for SftpSynchronizeDirectoriesAsyncResult Constructor
///</summary>
[TestMethod()]
public void SftpSynchronizeDirectoriesAsyncResultConstructorTest()
{
AsyncCallback asyncCallback = null; // TODO: Initialize to an appropriate value
object state = null; // TODO: Initialize to an appropriate value
SftpSynchronizeDirectoriesAsyncResult target = new SftpSynchronizeDirectoriesAsyncResult(asyncCallback, state);
Assert.Inconclusive("TODO: Implement code to verify target");
}
}
}
| 37.892857 | 123 | 0.708765 | [
"Unlicense"
] | RSchwoerer/SSH.NET | Renci.SshClient/Renci.SshNet.Tests/Classes/Sftp/SftpSynchronizeDirectoriesAsyncResultTest.cs | 1,063 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Runtime.InteropServices;
using System;
internal class NullableTest1
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((char)o, Helper.Create(default(char)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((char?)o, Helper.Create(default(char)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((char)o, Helper.Create(default(char)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((char?)o, Helper.Create(default(char)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((char)(object)o, Helper.Create(default(char)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((char?)(object)o, Helper.Create(default(char)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((char)(object)o, Helper.Create(default(char)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((char?)(object)o, Helper.Create(default(char)));
}
public static void Run()
{
char? s = Helper.Create(default(char));
Console.WriteLine("--- char? s = Helper.Create(default(char)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- char? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- char u = Helper.Create(default(char)) ---");
char u = Helper.Create(default(char));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<char>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<char>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest2
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((bool)o, Helper.Create(default(bool)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((bool?)o, Helper.Create(default(bool)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((bool)o, Helper.Create(default(bool)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((bool?)o, Helper.Create(default(bool)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((bool)(object)o, Helper.Create(default(bool)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((bool?)(object)o, Helper.Create(default(bool)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((bool)(object)o, Helper.Create(default(bool)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((bool?)(object)o, Helper.Create(default(bool)));
}
public static void Run()
{
bool? s = Helper.Create(default(bool));
Console.WriteLine("--- bool? s = Helper.Create(default(bool)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- bool? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- bool u = Helper.Create(default(bool)) ---");
bool u = Helper.Create(default(bool));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<bool>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<bool>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest3
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((byte)o, Helper.Create(default(byte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((byte?)o, Helper.Create(default(byte)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((byte)o, Helper.Create(default(byte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((byte?)o, Helper.Create(default(byte)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((byte)(object)o, Helper.Create(default(byte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((byte?)(object)o, Helper.Create(default(byte)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((byte)(object)o, Helper.Create(default(byte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((byte?)(object)o, Helper.Create(default(byte)));
}
public static void Run()
{
byte? s = Helper.Create(default(byte));
Console.WriteLine("--- byte? s = Helper.Create(default(byte)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- byte? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- byte u = Helper.Create(default(byte)) ---");
byte u = Helper.Create(default(byte));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<byte>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<byte>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest4
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((sbyte)o, Helper.Create(default(sbyte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((sbyte?)o, Helper.Create(default(sbyte)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((sbyte)o, Helper.Create(default(sbyte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((sbyte?)o, Helper.Create(default(sbyte)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((sbyte)(object)o, Helper.Create(default(sbyte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((sbyte?)(object)o, Helper.Create(default(sbyte)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((sbyte)(object)o, Helper.Create(default(sbyte)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((sbyte?)(object)o, Helper.Create(default(sbyte)));
}
public static void Run()
{
sbyte? s = Helper.Create(default(sbyte));
Console.WriteLine("--- sbyte? s = Helper.Create(default(sbyte)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- sbyte? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- sbyte u = Helper.Create(default(sbyte)) ---");
sbyte u = Helper.Create(default(sbyte));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<sbyte>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<sbyte>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest5
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((short)o, Helper.Create(default(short)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((short?)o, Helper.Create(default(short)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((short)o, Helper.Create(default(short)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((short?)o, Helper.Create(default(short)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((short)(object)o, Helper.Create(default(short)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((short?)(object)o, Helper.Create(default(short)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((short)(object)o, Helper.Create(default(short)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((short?)(object)o, Helper.Create(default(short)));
}
public static void Run()
{
short? s = Helper.Create(default(short));
Console.WriteLine("--- short? s = Helper.Create(default(short)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- short? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- short u = Helper.Create(default(short)) ---");
short u = Helper.Create(default(short));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<short>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<short>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest6
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ushort)o, Helper.Create(default(ushort)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ushort?)o, Helper.Create(default(ushort)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ushort)o, Helper.Create(default(ushort)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ushort?)o, Helper.Create(default(ushort)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ushort)(object)o, Helper.Create(default(ushort)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ushort?)(object)o, Helper.Create(default(ushort)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ushort)(object)o, Helper.Create(default(ushort)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ushort?)(object)o, Helper.Create(default(ushort)));
}
public static void Run()
{
ushort? s = Helper.Create(default(ushort));
Console.WriteLine("--- ushort? s = Helper.Create(default(ushort)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ushort? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ushort u = Helper.Create(default(ushort)) ---");
ushort u = Helper.Create(default(ushort));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ushort>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ushort>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest7
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((int)o, Helper.Create(default(int)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((int?)o, Helper.Create(default(int)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((int)o, Helper.Create(default(int)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((int?)o, Helper.Create(default(int)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((int)(object)o, Helper.Create(default(int)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((int?)(object)o, Helper.Create(default(int)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((int)(object)o, Helper.Create(default(int)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((int?)(object)o, Helper.Create(default(int)));
}
public static void Run()
{
int? s = Helper.Create(default(int));
Console.WriteLine("--- int? s = Helper.Create(default(int)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- int? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- int u = Helper.Create(default(int)) ---");
int u = Helper.Create(default(int));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<int>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<int>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest8
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((uint)o, Helper.Create(default(uint)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((uint?)o, Helper.Create(default(uint)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((uint)o, Helper.Create(default(uint)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((uint?)o, Helper.Create(default(uint)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((uint)(object)o, Helper.Create(default(uint)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((uint?)(object)o, Helper.Create(default(uint)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((uint)(object)o, Helper.Create(default(uint)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((uint?)(object)o, Helper.Create(default(uint)));
}
public static void Run()
{
uint? s = Helper.Create(default(uint));
Console.WriteLine("--- uint? s = Helper.Create(default(uint)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- uint? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- uint u = Helper.Create(default(uint)) ---");
uint u = Helper.Create(default(uint));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<uint>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<uint>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest9
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((long)o, Helper.Create(default(long)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((long?)o, Helper.Create(default(long)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((long)o, Helper.Create(default(long)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((long?)o, Helper.Create(default(long)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((long)(object)o, Helper.Create(default(long)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((long?)(object)o, Helper.Create(default(long)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((long)(object)o, Helper.Create(default(long)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((long?)(object)o, Helper.Create(default(long)));
}
public static void Run()
{
long? s = Helper.Create(default(long));
Console.WriteLine("--- long? s = Helper.Create(default(long)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- long? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- long u = Helper.Create(default(long)) ---");
long u = Helper.Create(default(long));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<long>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<long>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest10
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ulong)o, Helper.Create(default(ulong)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ulong?)o, Helper.Create(default(ulong)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ulong)o, Helper.Create(default(ulong)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ulong?)o, Helper.Create(default(ulong)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ulong)(object)o, Helper.Create(default(ulong)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ulong?)(object)o, Helper.Create(default(ulong)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ulong)(object)o, Helper.Create(default(ulong)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ulong?)(object)o, Helper.Create(default(ulong)));
}
public static void Run()
{
ulong? s = Helper.Create(default(ulong));
Console.WriteLine("--- ulong? s = Helper.Create(default(ulong)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ulong? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ulong u = Helper.Create(default(ulong)) ---");
ulong u = Helper.Create(default(ulong));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ulong>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ulong>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest11
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((float)o, Helper.Create(default(float)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((float?)o, Helper.Create(default(float)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((float)o, Helper.Create(default(float)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((float?)o, Helper.Create(default(float)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((float)(object)o, Helper.Create(default(float)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((float?)(object)o, Helper.Create(default(float)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((float)(object)o, Helper.Create(default(float)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((float?)(object)o, Helper.Create(default(float)));
}
public static void Run()
{
float? s = Helper.Create(default(float));
Console.WriteLine("--- float? s = Helper.Create(default(float)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- float? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- float u = Helper.Create(default(float)) ---");
float u = Helper.Create(default(float));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<float>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<float>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest12
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((double)o, Helper.Create(default(double)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((double?)o, Helper.Create(default(double)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((double)o, Helper.Create(default(double)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((double?)o, Helper.Create(default(double)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((double)(object)o, Helper.Create(default(double)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((double?)(object)o, Helper.Create(default(double)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((double)(object)o, Helper.Create(default(double)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((double?)(object)o, Helper.Create(default(double)));
}
public static void Run()
{
double? s = Helper.Create(default(double));
Console.WriteLine("--- double? s = Helper.Create(default(double)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- double? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- double u = Helper.Create(default(double)) ---");
double u = Helper.Create(default(double));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<double>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<double>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest13
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((decimal)o, Helper.Create(default(decimal)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((decimal?)o, Helper.Create(default(decimal)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((decimal)o, Helper.Create(default(decimal)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((decimal?)o, Helper.Create(default(decimal)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((decimal)(object)o, Helper.Create(default(decimal)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((decimal?)(object)o, Helper.Create(default(decimal)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((decimal)(object)o, Helper.Create(default(decimal)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((decimal?)(object)o, Helper.Create(default(decimal)));
}
public static void Run()
{
decimal? s = Helper.Create(default(decimal));
Console.WriteLine("--- decimal? s = Helper.Create(default(decimal)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- decimal? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- decimal u = Helper.Create(default(decimal)) ---");
decimal u = Helper.Create(default(decimal));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<decimal>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<decimal>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest14
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((IntPtr)o, Helper.Create(default(IntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((IntPtr?)o, Helper.Create(default(IntPtr)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((IntPtr)o, Helper.Create(default(IntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((IntPtr?)o, Helper.Create(default(IntPtr)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((IntPtr)(object)o, Helper.Create(default(IntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((IntPtr?)(object)o, Helper.Create(default(IntPtr)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((IntPtr)(object)o, Helper.Create(default(IntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((IntPtr?)(object)o, Helper.Create(default(IntPtr)));
}
public static void Run()
{
IntPtr? s = Helper.Create(default(IntPtr));
Console.WriteLine("--- IntPtr? s = Helper.Create(default(IntPtr)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- IntPtr? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- IntPtr u = Helper.Create(default(IntPtr)) ---");
IntPtr u = Helper.Create(default(IntPtr));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<IntPtr>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<IntPtr>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest15
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((UIntPtr)o, Helper.Create(default(UIntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((UIntPtr?)o, Helper.Create(default(UIntPtr)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((UIntPtr)o, Helper.Create(default(UIntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((UIntPtr?)o, Helper.Create(default(UIntPtr)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((UIntPtr)(object)o, Helper.Create(default(UIntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((UIntPtr?)(object)o, Helper.Create(default(UIntPtr)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((UIntPtr)(object)o, Helper.Create(default(UIntPtr)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((UIntPtr?)(object)o, Helper.Create(default(UIntPtr)));
}
public static void Run()
{
UIntPtr? s = Helper.Create(default(UIntPtr));
Console.WriteLine("--- UIntPtr? s = Helper.Create(default(UIntPtr)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- UIntPtr? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- UIntPtr u = Helper.Create(default(UIntPtr)) ---");
UIntPtr u = Helper.Create(default(UIntPtr));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<UIntPtr>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<UIntPtr>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest16
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((Guid)o, Helper.Create(default(Guid)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((Guid?)o, Helper.Create(default(Guid)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((Guid)o, Helper.Create(default(Guid)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((Guid?)o, Helper.Create(default(Guid)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((Guid)(object)o, Helper.Create(default(Guid)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((Guid?)(object)o, Helper.Create(default(Guid)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((Guid)(object)o, Helper.Create(default(Guid)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((Guid?)(object)o, Helper.Create(default(Guid)));
}
public static void Run()
{
Guid? s = Helper.Create(default(Guid));
Console.WriteLine("--- Guid? s = Helper.Create(default(Guid)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- Guid? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- Guid u = Helper.Create(default(Guid)) ---");
Guid u = Helper.Create(default(Guid));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<Guid>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<Guid>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest17
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((GCHandle)o, Helper.Create(default(GCHandle)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((GCHandle?)o, Helper.Create(default(GCHandle)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((GCHandle)o, Helper.Create(default(GCHandle)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((GCHandle?)o, Helper.Create(default(GCHandle)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((GCHandle)(object)o, Helper.Create(default(GCHandle)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((GCHandle?)(object)o, Helper.Create(default(GCHandle)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((GCHandle)(object)o, Helper.Create(default(GCHandle)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((GCHandle?)(object)o, Helper.Create(default(GCHandle)));
}
public static void Run()
{
GCHandle? s = Helper.Create(default(GCHandle));
Console.WriteLine("--- GCHandle? s = Helper.Create(default(GCHandle)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- GCHandle? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- GCHandle u = Helper.Create(default(GCHandle)) ---");
GCHandle u = Helper.Create(default(GCHandle));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<GCHandle>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<GCHandle>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest18
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ByteE)o, Helper.Create(default(ByteE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ByteE?)o, Helper.Create(default(ByteE)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ByteE)o, Helper.Create(default(ByteE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ByteE?)o, Helper.Create(default(ByteE)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ByteE)(object)o, Helper.Create(default(ByteE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ByteE?)(object)o, Helper.Create(default(ByteE)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ByteE)(object)o, Helper.Create(default(ByteE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ByteE?)(object)o, Helper.Create(default(ByteE)));
}
public static void Run()
{
ByteE? s = Helper.Create(default(ByteE));
Console.WriteLine("--- ByteE? s = Helper.Create(default(ByteE)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ByteE? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ByteE u = Helper.Create(default(ByteE)) ---");
ByteE u = Helper.Create(default(ByteE));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ByteE>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ByteE>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest19
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((IntE)o, Helper.Create(default(IntE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((IntE?)o, Helper.Create(default(IntE)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((IntE)o, Helper.Create(default(IntE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((IntE?)o, Helper.Create(default(IntE)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((IntE)(object)o, Helper.Create(default(IntE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((IntE?)(object)o, Helper.Create(default(IntE)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((IntE)(object)o, Helper.Create(default(IntE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((IntE?)(object)o, Helper.Create(default(IntE)));
}
public static void Run()
{
IntE? s = Helper.Create(default(IntE));
Console.WriteLine("--- IntE? s = Helper.Create(default(IntE)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- IntE? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- IntE u = Helper.Create(default(IntE)) ---");
IntE u = Helper.Create(default(IntE));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<IntE>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<IntE>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest20
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((LongE)o, Helper.Create(default(LongE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((LongE?)o, Helper.Create(default(LongE)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((LongE)o, Helper.Create(default(LongE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((LongE?)o, Helper.Create(default(LongE)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((LongE)(object)o, Helper.Create(default(LongE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((LongE?)(object)o, Helper.Create(default(LongE)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((LongE)(object)o, Helper.Create(default(LongE)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((LongE?)(object)o, Helper.Create(default(LongE)));
}
public static void Run()
{
LongE? s = Helper.Create(default(LongE));
Console.WriteLine("--- LongE? s = Helper.Create(default(LongE)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- LongE? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- LongE u = Helper.Create(default(LongE)) ---");
LongE u = Helper.Create(default(LongE));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<LongE>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<LongE>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest21
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((EmptyStruct)o, Helper.Create(default(EmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((EmptyStruct?)o, Helper.Create(default(EmptyStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((EmptyStruct)o, Helper.Create(default(EmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((EmptyStruct?)o, Helper.Create(default(EmptyStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((EmptyStruct)(object)o, Helper.Create(default(EmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((EmptyStruct?)(object)o, Helper.Create(default(EmptyStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((EmptyStruct)(object)o, Helper.Create(default(EmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((EmptyStruct?)(object)o, Helper.Create(default(EmptyStruct)));
}
public static void Run()
{
EmptyStruct? s = Helper.Create(default(EmptyStruct));
Console.WriteLine("--- EmptyStruct? s = Helper.Create(default(EmptyStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- EmptyStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- EmptyStruct u = Helper.Create(default(EmptyStruct)) ---");
EmptyStruct u = Helper.Create(default(EmptyStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<EmptyStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<EmptyStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest22
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStruct)o, Helper.Create(default(NotEmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStruct?)o, Helper.Create(default(NotEmptyStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStruct)o, Helper.Create(default(NotEmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStruct?)o, Helper.Create(default(NotEmptyStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStruct)(object)o, Helper.Create(default(NotEmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStruct?)(object)o, Helper.Create(default(NotEmptyStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStruct)(object)o, Helper.Create(default(NotEmptyStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStruct?)(object)o, Helper.Create(default(NotEmptyStruct)));
}
public static void Run()
{
NotEmptyStruct? s = Helper.Create(default(NotEmptyStruct));
Console.WriteLine("--- NotEmptyStruct? s = Helper.Create(default(NotEmptyStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStruct u = Helper.Create(default(NotEmptyStruct)) ---");
NotEmptyStruct u = Helper.Create(default(NotEmptyStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest23
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructQ)o, Helper.Create(default(NotEmptyStructQ)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructQ?)o, Helper.Create(default(NotEmptyStructQ)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructQ)o, Helper.Create(default(NotEmptyStructQ)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructQ?)o, Helper.Create(default(NotEmptyStructQ)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructQ)(object)o, Helper.Create(default(NotEmptyStructQ)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructQ?)(object)o, Helper.Create(default(NotEmptyStructQ)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructQ)(object)o, Helper.Create(default(NotEmptyStructQ)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructQ?)(object)o, Helper.Create(default(NotEmptyStructQ)));
}
public static void Run()
{
NotEmptyStructQ? s = Helper.Create(default(NotEmptyStructQ));
Console.WriteLine("--- NotEmptyStructQ? s = Helper.Create(default(NotEmptyStructQ)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructQ? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructQ u = Helper.Create(default(NotEmptyStructQ)) ---");
NotEmptyStructQ u = Helper.Create(default(NotEmptyStructQ));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructQ>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructQ>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest24
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructA)o, Helper.Create(default(NotEmptyStructA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructA?)o, Helper.Create(default(NotEmptyStructA)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructA)o, Helper.Create(default(NotEmptyStructA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructA?)o, Helper.Create(default(NotEmptyStructA)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructA)(object)o, Helper.Create(default(NotEmptyStructA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructA?)(object)o, Helper.Create(default(NotEmptyStructA)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructA)(object)o, Helper.Create(default(NotEmptyStructA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructA?)(object)o, Helper.Create(default(NotEmptyStructA)));
}
public static void Run()
{
NotEmptyStructA? s = Helper.Create(default(NotEmptyStructA));
Console.WriteLine("--- NotEmptyStructA? s = Helper.Create(default(NotEmptyStructA)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructA? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructA u = Helper.Create(default(NotEmptyStructA)) ---");
NotEmptyStructA u = Helper.Create(default(NotEmptyStructA));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructA>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructA>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest25
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructQA)o, Helper.Create(default(NotEmptyStructQA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructQA?)o, Helper.Create(default(NotEmptyStructQA)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructQA)o, Helper.Create(default(NotEmptyStructQA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructQA?)o, Helper.Create(default(NotEmptyStructQA)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructQA)(object)o, Helper.Create(default(NotEmptyStructQA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructQA?)(object)o, Helper.Create(default(NotEmptyStructQA)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructQA)(object)o, Helper.Create(default(NotEmptyStructQA)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructQA?)(object)o, Helper.Create(default(NotEmptyStructQA)));
}
public static void Run()
{
NotEmptyStructQA? s = Helper.Create(default(NotEmptyStructQA));
Console.WriteLine("--- NotEmptyStructQA? s = Helper.Create(default(NotEmptyStructQA)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructQA? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructQA u = Helper.Create(default(NotEmptyStructQA)) ---");
NotEmptyStructQA u = Helper.Create(default(NotEmptyStructQA));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructQA>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructQA>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest26
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((EmptyStructGen<int>)o, Helper.Create(default(EmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((EmptyStructGen<int>?)o, Helper.Create(default(EmptyStructGen<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((EmptyStructGen<int>)o, Helper.Create(default(EmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((EmptyStructGen<int>?)o, Helper.Create(default(EmptyStructGen<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((EmptyStructGen<int>)(object)o, Helper.Create(default(EmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((EmptyStructGen<int>?)(object)o, Helper.Create(default(EmptyStructGen<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((EmptyStructGen<int>)(object)o, Helper.Create(default(EmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((EmptyStructGen<int>?)(object)o, Helper.Create(default(EmptyStructGen<int>)));
}
public static void Run()
{
EmptyStructGen<int>? s = Helper.Create(default(EmptyStructGen<int>));
Console.WriteLine("--- EmptyStructGen<int>? s = Helper.Create(default(EmptyStructGen<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- EmptyStructGen<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- EmptyStructGen<int> u = Helper.Create(default(EmptyStructGen<int>)) ---");
EmptyStructGen<int> u = Helper.Create(default(EmptyStructGen<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<EmptyStructGen<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<EmptyStructGen<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest27
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructGen<int>)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructGen<int>?)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructGen<int>)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructGen<int>?)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructGen<int>)(object)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructGen<int>?)(object)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructGen<int>)(object)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructGen<int>?)(object)o, Helper.Create(default(NotEmptyStructGen<int>)));
}
public static void Run()
{
NotEmptyStructGen<int>? s = Helper.Create(default(NotEmptyStructGen<int>));
Console.WriteLine("--- NotEmptyStructGen<int>? s = Helper.Create(default(NotEmptyStructGen<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructGen<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructGen<int> u = Helper.Create(default(NotEmptyStructGen<int>)) ---");
NotEmptyStructGen<int> u = Helper.Create(default(NotEmptyStructGen<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructGen<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructGen<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest28
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructConstrainedGen<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGen<int>)));
}
public static void Run()
{
NotEmptyStructConstrainedGen<int>? s = Helper.Create(default(NotEmptyStructConstrainedGen<int>));
Console.WriteLine("--- NotEmptyStructConstrainedGen<int>? s = Helper.Create(default(NotEmptyStructConstrainedGen<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGen<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGen<int> u = Helper.Create(default(NotEmptyStructConstrainedGen<int>)) ---");
NotEmptyStructConstrainedGen<int> u = Helper.Create(default(NotEmptyStructConstrainedGen<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructConstrainedGen<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructConstrainedGen<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest29
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructConstrainedGenA<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenA<int>)));
}
public static void Run()
{
NotEmptyStructConstrainedGenA<int>? s = Helper.Create(default(NotEmptyStructConstrainedGenA<int>));
Console.WriteLine("--- NotEmptyStructConstrainedGenA<int>? s = Helper.Create(default(NotEmptyStructConstrainedGenA<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGenA<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGenA<int> u = Helper.Create(default(NotEmptyStructConstrainedGenA<int>)) ---");
NotEmptyStructConstrainedGenA<int> u = Helper.Create(default(NotEmptyStructConstrainedGenA<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructConstrainedGenA<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructConstrainedGenA<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest30
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructConstrainedGenQ<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)));
}
public static void Run()
{
NotEmptyStructConstrainedGenQ<int>? s = Helper.Create(default(NotEmptyStructConstrainedGenQ<int>));
Console.WriteLine("--- NotEmptyStructConstrainedGenQ<int>? s = Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGenQ<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGenQ<int> u = Helper.Create(default(NotEmptyStructConstrainedGenQ<int>)) ---");
NotEmptyStructConstrainedGenQ<int> u = Helper.Create(default(NotEmptyStructConstrainedGenQ<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructConstrainedGenQ<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructConstrainedGenQ<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest31
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>?)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NotEmptyStructConstrainedGenQA<int>?)(object)o, Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)));
}
public static void Run()
{
NotEmptyStructConstrainedGenQA<int>? s = Helper.Create(default(NotEmptyStructConstrainedGenQA<int>));
Console.WriteLine("--- NotEmptyStructConstrainedGenQA<int>? s = Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGenQA<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NotEmptyStructConstrainedGenQA<int> u = Helper.Create(default(NotEmptyStructConstrainedGenQA<int>)) ---");
NotEmptyStructConstrainedGenQA<int> u = Helper.Create(default(NotEmptyStructConstrainedGenQA<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NotEmptyStructConstrainedGenQA<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NotEmptyStructConstrainedGenQA<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest32
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NestedStruct)o, Helper.Create(default(NestedStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NestedStruct?)o, Helper.Create(default(NestedStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NestedStruct)o, Helper.Create(default(NestedStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NestedStruct?)o, Helper.Create(default(NestedStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NestedStruct)(object)o, Helper.Create(default(NestedStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NestedStruct?)(object)o, Helper.Create(default(NestedStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NestedStruct)(object)o, Helper.Create(default(NestedStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NestedStruct?)(object)o, Helper.Create(default(NestedStruct)));
}
public static void Run()
{
NestedStruct? s = Helper.Create(default(NestedStruct));
Console.WriteLine("--- NestedStruct? s = Helper.Create(default(NestedStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NestedStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NestedStruct u = Helper.Create(default(NestedStruct)) ---");
NestedStruct u = Helper.Create(default(NestedStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NestedStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NestedStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest33
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((NestedStructGen<int>)o, Helper.Create(default(NestedStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NestedStructGen<int>?)o, Helper.Create(default(NestedStructGen<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((NestedStructGen<int>)o, Helper.Create(default(NestedStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((NestedStructGen<int>?)o, Helper.Create(default(NestedStructGen<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((NestedStructGen<int>)(object)o, Helper.Create(default(NestedStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((NestedStructGen<int>?)(object)o, Helper.Create(default(NestedStructGen<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((NestedStructGen<int>)(object)o, Helper.Create(default(NestedStructGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((NestedStructGen<int>?)(object)o, Helper.Create(default(NestedStructGen<int>)));
}
public static void Run()
{
NestedStructGen<int>? s = Helper.Create(default(NestedStructGen<int>));
Console.WriteLine("--- NestedStructGen<int>? s = Helper.Create(default(NestedStructGen<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- NestedStructGen<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- NestedStructGen<int> u = Helper.Create(default(NestedStructGen<int>)) ---");
NestedStructGen<int> u = Helper.Create(default(NestedStructGen<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<NestedStructGen<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<NestedStructGen<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest34
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ExplicitFieldOffsetStruct)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ExplicitFieldOffsetStruct?)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ExplicitFieldOffsetStruct)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ExplicitFieldOffsetStruct?)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ExplicitFieldOffsetStruct)(object)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ExplicitFieldOffsetStruct?)(object)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ExplicitFieldOffsetStruct)(object)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ExplicitFieldOffsetStruct?)(object)o, Helper.Create(default(ExplicitFieldOffsetStruct)));
}
public static void Run()
{
ExplicitFieldOffsetStruct? s = Helper.Create(default(ExplicitFieldOffsetStruct));
Console.WriteLine("--- ExplicitFieldOffsetStruct? s = Helper.Create(default(ExplicitFieldOffsetStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ExplicitFieldOffsetStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ExplicitFieldOffsetStruct u = Helper.Create(default(ExplicitFieldOffsetStruct)) ---");
ExplicitFieldOffsetStruct u = Helper.Create(default(ExplicitFieldOffsetStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ExplicitFieldOffsetStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ExplicitFieldOffsetStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest37
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((MarshalAsStruct)o, Helper.Create(default(MarshalAsStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((MarshalAsStruct?)o, Helper.Create(default(MarshalAsStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((MarshalAsStruct)o, Helper.Create(default(MarshalAsStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((MarshalAsStruct?)o, Helper.Create(default(MarshalAsStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((MarshalAsStruct)(object)o, Helper.Create(default(MarshalAsStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((MarshalAsStruct?)(object)o, Helper.Create(default(MarshalAsStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((MarshalAsStruct)(object)o, Helper.Create(default(MarshalAsStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((MarshalAsStruct?)(object)o, Helper.Create(default(MarshalAsStruct)));
}
public static void Run()
{
MarshalAsStruct? s = Helper.Create(default(MarshalAsStruct));
Console.WriteLine("--- MarshalAsStruct? s = Helper.Create(default(MarshalAsStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- MarshalAsStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- MarshalAsStruct u = Helper.Create(default(MarshalAsStruct)) ---");
MarshalAsStruct u = Helper.Create(default(MarshalAsStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<MarshalAsStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<MarshalAsStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest38
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ImplementOneInterface)o, Helper.Create(default(ImplementOneInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ImplementOneInterface?)o, Helper.Create(default(ImplementOneInterface)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ImplementOneInterface)o, Helper.Create(default(ImplementOneInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ImplementOneInterface?)o, Helper.Create(default(ImplementOneInterface)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ImplementOneInterface)(object)o, Helper.Create(default(ImplementOneInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ImplementOneInterface?)(object)o, Helper.Create(default(ImplementOneInterface)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ImplementOneInterface)(object)o, Helper.Create(default(ImplementOneInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ImplementOneInterface?)(object)o, Helper.Create(default(ImplementOneInterface)));
}
public static void Run()
{
ImplementOneInterface? s = Helper.Create(default(ImplementOneInterface));
Console.WriteLine("--- ImplementOneInterface? s = Helper.Create(default(ImplementOneInterface)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementOneInterface? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementOneInterface u = Helper.Create(default(ImplementOneInterface)) ---");
ImplementOneInterface u = Helper.Create(default(ImplementOneInterface));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ImplementOneInterface>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ImplementOneInterface>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest39
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ImplementTwoInterface)o, Helper.Create(default(ImplementTwoInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ImplementTwoInterface?)o, Helper.Create(default(ImplementTwoInterface)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ImplementTwoInterface)o, Helper.Create(default(ImplementTwoInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ImplementTwoInterface?)o, Helper.Create(default(ImplementTwoInterface)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ImplementTwoInterface)(object)o, Helper.Create(default(ImplementTwoInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ImplementTwoInterface?)(object)o, Helper.Create(default(ImplementTwoInterface)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ImplementTwoInterface)(object)o, Helper.Create(default(ImplementTwoInterface)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ImplementTwoInterface?)(object)o, Helper.Create(default(ImplementTwoInterface)));
}
public static void Run()
{
ImplementTwoInterface? s = Helper.Create(default(ImplementTwoInterface));
Console.WriteLine("--- ImplementTwoInterface? s = Helper.Create(default(ImplementTwoInterface)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementTwoInterface? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementTwoInterface u = Helper.Create(default(ImplementTwoInterface)) ---");
ImplementTwoInterface u = Helper.Create(default(ImplementTwoInterface));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ImplementTwoInterface>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ImplementTwoInterface>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest40
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ImplementOneInterfaceGen<int>)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ImplementOneInterfaceGen<int>?)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ImplementOneInterfaceGen<int>)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ImplementOneInterfaceGen<int>?)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ImplementOneInterfaceGen<int>)(object)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ImplementOneInterfaceGen<int>?)(object)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ImplementOneInterfaceGen<int>)(object)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ImplementOneInterfaceGen<int>?)(object)o, Helper.Create(default(ImplementOneInterfaceGen<int>)));
}
public static void Run()
{
ImplementOneInterfaceGen<int>? s = Helper.Create(default(ImplementOneInterfaceGen<int>));
Console.WriteLine("--- ImplementOneInterfaceGen<int>? s = Helper.Create(default(ImplementOneInterfaceGen<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementOneInterfaceGen<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementOneInterfaceGen<int> u = Helper.Create(default(ImplementOneInterfaceGen<int>)) ---");
ImplementOneInterfaceGen<int> u = Helper.Create(default(ImplementOneInterfaceGen<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ImplementOneInterfaceGen<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ImplementOneInterfaceGen<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest41
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ImplementTwoInterfaceGen<int>)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ImplementTwoInterfaceGen<int>?)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ImplementTwoInterfaceGen<int>)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ImplementTwoInterfaceGen<int>?)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ImplementTwoInterfaceGen<int>)(object)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ImplementTwoInterfaceGen<int>?)(object)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ImplementTwoInterfaceGen<int>)(object)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ImplementTwoInterfaceGen<int>?)(object)o, Helper.Create(default(ImplementTwoInterfaceGen<int>)));
}
public static void Run()
{
ImplementTwoInterfaceGen<int>? s = Helper.Create(default(ImplementTwoInterfaceGen<int>));
Console.WriteLine("--- ImplementTwoInterfaceGen<int>? s = Helper.Create(default(ImplementTwoInterfaceGen<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementTwoInterfaceGen<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementTwoInterfaceGen<int> u = Helper.Create(default(ImplementTwoInterfaceGen<int>)) ---");
ImplementTwoInterfaceGen<int> u = Helper.Create(default(ImplementTwoInterfaceGen<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ImplementTwoInterfaceGen<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ImplementTwoInterfaceGen<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest42
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((ImplementAllInterface<int>)o, Helper.Create(default(ImplementAllInterface<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((ImplementAllInterface<int>?)o, Helper.Create(default(ImplementAllInterface<int>)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((ImplementAllInterface<int>)o, Helper.Create(default(ImplementAllInterface<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((ImplementAllInterface<int>?)o, Helper.Create(default(ImplementAllInterface<int>)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((ImplementAllInterface<int>)(object)o, Helper.Create(default(ImplementAllInterface<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((ImplementAllInterface<int>?)(object)o, Helper.Create(default(ImplementAllInterface<int>)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((ImplementAllInterface<int>)(object)o, Helper.Create(default(ImplementAllInterface<int>)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((ImplementAllInterface<int>?)(object)o, Helper.Create(default(ImplementAllInterface<int>)));
}
public static void Run()
{
ImplementAllInterface<int>? s = Helper.Create(default(ImplementAllInterface<int>));
Console.WriteLine("--- ImplementAllInterface<int>? s = Helper.Create(default(ImplementAllInterface<int>)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementAllInterface<int>? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- ImplementAllInterface<int> u = Helper.Create(default(ImplementAllInterface<int>)) ---");
ImplementAllInterface<int> u = Helper.Create(default(ImplementAllInterface<int>));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<ImplementAllInterface<int>>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<ImplementAllInterface<int>>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest43
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((WithMultipleGCHandleStruct)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((WithMultipleGCHandleStruct?)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((WithMultipleGCHandleStruct)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((WithMultipleGCHandleStruct?)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((WithMultipleGCHandleStruct)(object)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((WithMultipleGCHandleStruct?)(object)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((WithMultipleGCHandleStruct)(object)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((WithMultipleGCHandleStruct?)(object)o, Helper.Create(default(WithMultipleGCHandleStruct)));
}
public static void Run()
{
WithMultipleGCHandleStruct? s = Helper.Create(default(WithMultipleGCHandleStruct));
Console.WriteLine("--- WithMultipleGCHandleStruct? s = Helper.Create(default(WithMultipleGCHandleStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- WithMultipleGCHandleStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- WithMultipleGCHandleStruct u = Helper.Create(default(WithMultipleGCHandleStruct)) ---");
WithMultipleGCHandleStruct u = Helper.Create(default(WithMultipleGCHandleStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<WithMultipleGCHandleStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<WithMultipleGCHandleStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest44
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((WithOnlyFXTypeStruct)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((WithOnlyFXTypeStruct?)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((WithOnlyFXTypeStruct)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((WithOnlyFXTypeStruct?)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((WithOnlyFXTypeStruct)(object)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((WithOnlyFXTypeStruct?)(object)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((WithOnlyFXTypeStruct)(object)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((WithOnlyFXTypeStruct?)(object)o, Helper.Create(default(WithOnlyFXTypeStruct)));
}
public static void Run()
{
WithOnlyFXTypeStruct? s = Helper.Create(default(WithOnlyFXTypeStruct));
Console.WriteLine("--- WithOnlyFXTypeStruct? s = Helper.Create(default(WithOnlyFXTypeStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- WithOnlyFXTypeStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- WithOnlyFXTypeStruct u = Helper.Create(default(WithOnlyFXTypeStruct)) ---");
WithOnlyFXTypeStruct u = Helper.Create(default(WithOnlyFXTypeStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<WithOnlyFXTypeStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<WithOnlyFXTypeStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class NullableTest45
{
private static bool BoxUnboxToNQ(object o)
{
try
{
return Helper.Compare((MixedAllStruct)o, Helper.Create(default(MixedAllStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((MixedAllStruct?)o, Helper.Create(default(MixedAllStruct)));
}
private static bool BoxUnboxToNQV(ValueType o)
{
try
{
return Helper.Compare((MixedAllStruct)o, Helper.Create(default(MixedAllStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQV(ValueType o)
{
return Helper.Compare((MixedAllStruct?)o, Helper.Create(default(MixedAllStruct)));
}
private static bool BoxUnboxToNQGen<T>(T o)
{
try
{
return Helper.Compare((MixedAllStruct)(object)o, Helper.Create(default(MixedAllStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGen<T>(T o)
{
return Helper.Compare((MixedAllStruct?)(object)o, Helper.Create(default(MixedAllStruct)));
}
private static bool BoxUnboxToNQGenC<T>(T? o) where T : struct
{
try
{
return Helper.Compare((MixedAllStruct)(object)o, Helper.Create(default(MixedAllStruct)));
}
catch (NullReferenceException)
{
return o == null;
}
}
private static bool BoxUnboxToQGenC<T>(T? o) where T : struct
{
return Helper.Compare((MixedAllStruct?)(object)o, Helper.Create(default(MixedAllStruct)));
}
public static void Run()
{
MixedAllStruct? s = Helper.Create(default(MixedAllStruct));
Console.WriteLine("--- MixedAllStruct? s = Helper.Create(default(MixedAllStruct)) ---");
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), true, "BoxUnboxToQGenC");
Console.WriteLine("--- MixedAllStruct? s = null ---");
s = null;
Assert.AreEqual(BoxUnboxToNQ(s), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(s), false, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(s), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(s), false, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(s), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(s), false, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC(s), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC(s), false, "BoxUnboxToQGenC");
Console.WriteLine("--- MixedAllStruct u = Helper.Create(default(MixedAllStruct)) ---");
MixedAllStruct u = Helper.Create(default(MixedAllStruct));
Assert.AreEqual(BoxUnboxToNQ(u), true, "BoxUnboxToNQ");
Assert.AreEqual(BoxUnboxToQ(u), true, "BoxUnboxToQ");
Assert.AreEqual(BoxUnboxToNQV(u), true, "BoxUnboxToNQV");
Assert.AreEqual(BoxUnboxToQV(u), true, "BoxUnboxToQV");
Assert.AreEqual(BoxUnboxToNQGen(u), true, "BoxUnboxToNQGen");
Assert.AreEqual(BoxUnboxToQGen(u), true, "BoxUnboxToQGen");
Assert.AreEqual(BoxUnboxToNQGenC<MixedAllStruct>(u), true, "BoxUnboxToNQGenC");
Assert.AreEqual(BoxUnboxToQGenC<MixedAllStruct>(u), true, "BoxUnboxToQGenC");
}
}
internal class Test_boxunboxvaluetype
{
private static int Main()
{
try
{
NullableTest1.Run();
NullableTest2.Run();
NullableTest3.Run();
NullableTest4.Run();
NullableTest5.Run();
NullableTest6.Run();
NullableTest7.Run();
NullableTest8.Run();
NullableTest9.Run();
NullableTest10.Run();
NullableTest11.Run();
NullableTest12.Run();
NullableTest13.Run();
NullableTest14.Run();
NullableTest15.Run();
NullableTest16.Run();
NullableTest17.Run();
NullableTest18.Run();
NullableTest19.Run();
NullableTest20.Run();
NullableTest21.Run();
NullableTest22.Run();
NullableTest23.Run();
NullableTest24.Run();
NullableTest25.Run();
NullableTest26.Run();
NullableTest27.Run();
NullableTest28.Run();
NullableTest29.Run();
NullableTest30.Run();
NullableTest31.Run();
NullableTest32.Run();
NullableTest33.Run();
NullableTest34.Run();
NullableTest37.Run();
NullableTest38.Run();
NullableTest39.Run();
NullableTest40.Run();
NullableTest41.Run();
NullableTest42.Run();
NullableTest43.Run();
NullableTest44.Run();
NullableTest45.Run();
}
catch (System.Exception e)
{
Console.WriteLine("Test Failed" + e.ToString());
Console.WriteLine(e);
return 666;
}
Console.WriteLine("Test SUCCESS");
return 100;
}
}
| 35.849727 | 143 | 0.630381 | [
"MIT"
] | 333fred/runtime | src/tests/JIT/Directed/nullabletypes/Desktop/boxunboxvaluetype.cs | 170,573 | C# |
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Tests
{
[TestClass]
public class BTests
{
[TestMethod]
public void TestMethod1()
{
const string input = @"3 2
1 2
5 5
-2 8";
const string output = @"1";
Tester.InOutTest(() => Tasks.B.Solve(), input, output);
}
[TestMethod]
public void TestMethod2()
{
const string input = @"3 4
-3 7 8 2
-12 1 10 2
-2 8 9 3";
const string output = @"2";
Tester.InOutTest(() => Tasks.B.Solve(), input, output);
}
[TestMethod]
public void TestMethod3()
{
const string input = @"5 1
1
2
3
4
5";
const string output = @"10";
Tester.InOutTest(() => Tasks.B.Solve(), input, output);
}
}
}
| 19.363636 | 67 | 0.497653 | [
"CC0-1.0"
] | AconCavy/AtCoder.Tasks.CS | ABC/ABC133/Tests/BTests.cs | 852 | C# |
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.Application.Dtos;
namespace BiKe.Poetry.Dto
{
public class ShiJingDto : AuditedEntityDto<Guid>
{
/// <summary>
/// 词牌名
/// </summary>
public virtual string Chapter { get; set; }
/// <summary>
/// ...
/// </summary>
public virtual string Section { get; set; }
/// <summary>
/// 内容
/// </summary>
public virtual string Content { get; set; }
/// <summary>
/// 标题
/// </summary>
public virtual string Title { get; set; }
/// <summary>
/// 测试
/// </summary>
public List<TestDto> Tests { get; set; }
}
public class TestDto
{
public string Name { get; set; }
public int Count { get; set; }
}
}
| 20.395349 | 52 | 0.49943 | [
"MIT"
] | coco-bike/BiKe.Poetry | src/BiKe.Poetry.Application.Contracts/Dto/ShiJingDto.cs | 897 | C# |
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.ServiceLayer.Utility;
using System.Collections.Generic;
namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts
{
public class SchemaCompareObjectId
{
/// <summary>
/// Name to create object identifier
/// </summary>
public string[] NameParts;
/// <summary>
/// sql object type
/// </summary>
public string SqlObjectType;
}
/// <summary>
/// Parameters for a schema compare open scmp file request.
/// </summary>
public class SchemaCompareOpenScmpParams
{
/// <summary>
/// filepath of scmp
/// </summary>
public string FilePath { get; set; }
}
/// <summary>
/// Parameters returned from a schema compare open scmp request.
/// </summary>
public class SchemaCompareOpenScmpResult : ResultStatus
{
/// <summary>
/// Gets or sets the current source endpoint info
/// </summary>
public SchemaCompareEndpointInfo SourceEndpointInfo { get; set; }
/// <summary>
/// Gets or sets the current target endpoint info
/// </summary>
public SchemaCompareEndpointInfo TargetEndpointInfo { get; set; }
/// <summary>
/// Gets or sets the original target name. This is the initial target name, not necessarily the same as TargetEndpointInfo if they were swapped
/// The original target name is used to determine whether to use ExcludedSourceElements or ExcludedTargetElements if source and target were swapped
/// </summary>
public string OriginalTargetName { get; set; }
/// <summary>
/// Gets or sets the original target connection string. This is the initial target connection string, not necessarily the same as TargetEndpointInfo if they were swapped
/// The target connection string is necessary if the source and target are a dacpac and db with the same name
/// </summary>
public string OriginalTargetConnectionString { get; set; }
/// <summary>
/// Gets or sets the deployment options
/// </summary>
public DeploymentOptions DeploymentOptions { get; set; }
/// <summary>
/// Gets or sets the excluded source elements. This is based on the initial source, not necessarily the same as SourceEndpointInfo if they were swapped
/// </summary>
public List<SchemaCompareObjectId> ExcludedSourceElements { get; set; }
/// <summary>
/// Gets or sets the excluded target elements. This is based on the initial target, not necessarily the same as TargetEndpointInfo if they were swapped
/// </summary>
public List<SchemaCompareObjectId> ExcludedTargetElements { get; set; }
}
/// <summary>
/// Defines the Schema Compare open scmp request type
/// </summary>
class SchemaCompareOpenScmpRequest
{
public static readonly RequestType<SchemaCompareOpenScmpParams, SchemaCompareOpenScmpResult> Type =
RequestType<SchemaCompareOpenScmpParams, SchemaCompareOpenScmpResult>.Create("schemaCompare/openScmp");
}
}
| 39.068182 | 177 | 0.666958 | [
"MIT"
] | Bhaskers-Blu-Org2/sqltoolsservice | src/Microsoft.SqlTools.ServiceLayer/SchemaCompare/Contracts/SchemaCompareOpenScmpRequest.cs | 3,440 | C# |
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("AWSSDK.MediaLive")]
[assembly: AssemblyDescription("The Amazon Web Services SDK for .NET (3.5) - AWS Elemental MediaLive. AWS Elemental MediaLive is a video service that lets you easily create live outputs for broadcast and streaming delivery.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Amazon Web Services SDK for .NET")]
[assembly: AssemblyCompany("Amazon.com, Inc")]
[assembly: AssemblyCopyright("Copyright 2009-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.")]
[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)]
// 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("3.3")]
[assembly: AssemblyFileVersion("3.3.106.3")] | 46.875 | 226 | 0.752667 | [
"Apache-2.0"
] | dwainew/aws-sdk-net | sdk/code-analysis/ServiceAnalysis/MediaLive/Properties/AssemblyInfo.cs | 1,500 | C# |
/*
* Copyright (c) 2018 THL A29 Limited, a Tencent company. 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.
*/
namespace TencentCloud.Dnspod.V20210323.Models
{
using Newtonsoft.Json;
using System.Collections.Generic;
using TencentCloud.Common;
public class UserInfo : AbstractModel
{
/// <summary>
/// 用户昵称
/// </summary>
[JsonProperty("Nick")]
public string Nick{ get; set; }
/// <summary>
/// 用户ID
/// </summary>
[JsonProperty("Id")]
public long? Id{ get; set; }
/// <summary>
/// 用户账号, 邮箱格式
/// </summary>
[JsonProperty("Email")]
public string Email{ get; set; }
/// <summary>
/// 账号状态:”enabled”: 正常;”disabled”: 被封禁
/// </summary>
[JsonProperty("Status")]
public string Status{ get; set; }
/// <summary>
/// 电话号码
/// </summary>
[JsonProperty("Telephone")]
public string Telephone{ get; set; }
/// <summary>
/// 邮箱是否通过验证:”yes”: 通过;”no”: 未通过
/// </summary>
[JsonProperty("EmailVerified")]
public string EmailVerified{ get; set; }
/// <summary>
/// 手机是否通过验证:”yes”: 通过;”no”: 未通过
/// </summary>
[JsonProperty("TelephoneVerified")]
public string TelephoneVerified{ get; set; }
/// <summary>
/// 账号等级, 按照用户账号下域名等级排序, 选取一个最高等级为账号等级, 具体对应情况参见域名等级。
/// </summary>
[JsonProperty("UserGrade")]
public string UserGrade{ get; set; }
/// <summary>
/// 用户名称, 企业用户对应为公司名称
/// </summary>
[JsonProperty("RealName")]
public string RealName{ get; set; }
/// <summary>
/// 是否绑定微信:”yes”: 通过;”no”: 未通过
/// </summary>
[JsonProperty("WechatBinded")]
public string WechatBinded{ get; set; }
/// <summary>
/// 用户UIN
/// </summary>
[JsonProperty("Uin")]
public long? Uin{ get; set; }
/// <summary>
/// For internal usage only. DO NOT USE IT.
/// </summary>
public override void ToMap(Dictionary<string, string> map, string prefix)
{
this.SetParamSimple(map, prefix + "Nick", this.Nick);
this.SetParamSimple(map, prefix + "Id", this.Id);
this.SetParamSimple(map, prefix + "Email", this.Email);
this.SetParamSimple(map, prefix + "Status", this.Status);
this.SetParamSimple(map, prefix + "Telephone", this.Telephone);
this.SetParamSimple(map, prefix + "EmailVerified", this.EmailVerified);
this.SetParamSimple(map, prefix + "TelephoneVerified", this.TelephoneVerified);
this.SetParamSimple(map, prefix + "UserGrade", this.UserGrade);
this.SetParamSimple(map, prefix + "RealName", this.RealName);
this.SetParamSimple(map, prefix + "WechatBinded", this.WechatBinded);
this.SetParamSimple(map, prefix + "Uin", this.Uin);
}
}
}
| 31.578947 | 91 | 0.570833 | [
"Apache-2.0"
] | TencentCloud/tencentcloud-sdk-dotnet | TencentCloud/Dnspod/V20210323/Models/UserInfo.cs | 3,896 | C# |
namespace Dalion.WebAppTemplate.Api.Security {
public static class Constants {
public static class Scopes {
public const string ApiFullAccess = "Api.FullAccess";
}
public static class Roles {
public const string ApiFullAccess = "Api.FullAccess";
}
public static class ClaimTypes {
public const string Scope = "http://schemas.microsoft.com/identity/claims/scope";
public const string Role = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role";
}
public static class AuthorizationPolicies {
public const string RequireApiAccess = "RequireApiAccess";
}
}
} | 35 | 102 | 0.635714 | [
"MIT"
] | DavidLievrouw/DalionWebAppTemplate | src/WebAppTemplate.Api/Security/Constants.cs | 702 | C# |
using Microsoft.SqlServer.TransactSql.ScriptDom;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace SqlServerValidator.Formatter.Visitors
{
public abstract class ReplaceSqlFragmentVisitor : TSqlFragmentVisitor
{
protected readonly Dictionary<TSqlParserToken, string> _insertBeforeDict = new();
protected readonly Dictionary<TSqlParserToken, string> _replaceDict = new();
protected readonly Dictionary<TSqlParserToken, string> _insertAfterDict = new();
public IReadOnlyDictionary<TSqlParserToken, string> InsertBeforeDict => _insertBeforeDict;
public IReadOnlyDictionary<TSqlParserToken, string> ReplaceDict => _replaceDict;
public IReadOnlyDictionary<TSqlParserToken, string> InsertAfterDict => _insertAfterDict;
public ReadOnlyCollection<Type> Dependencies
{
get;
}
public abstract bool IsEnabled
{
get;
}
public ReplaceSqlFragmentVisitor(
params Type[] dependencies
)
{
if (dependencies is null)
{
throw new ArgumentNullException(nameof(dependencies));
}
Dependencies = dependencies.ToList().AsReadOnly();
}
public virtual void Reset()
{
_insertBeforeDict.Clear();
_replaceDict.Clear();
_insertAfterDict.Clear();
}
protected void InsertBeforeTransform(TSqlParserToken token, string value)
{
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
_insertBeforeDict[token] = value;
}
protected void InsertBeforeTransform(TSqlFragment node, string value)
{
if (node is null)
{
throw new ArgumentNullException(nameof(node));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
var token = node.ScriptTokenStream[node.FirstTokenIndex];
_insertBeforeDict[token] = value;
}
protected void ReplaceTransform(TSqlFragment node, string value)
{
if (node is null)
{
throw new ArgumentNullException(nameof(node));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
AddReplaceTransform(node, value);
}
protected void ReplaceTransform(TSqlParserToken token, string value)
{
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
AddReplaceTransform(token, value);
}
protected void InsertAfterTransform(TSqlFragment node, string value)
{
if (node is null)
{
throw new ArgumentNullException(nameof(node));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
var token = node.ScriptTokenStream[node.LastTokenIndex];
_insertAfterDict[token] = value;
}
protected void InsertAfterTransform(TSqlParserToken token, string value)
{
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
_insertAfterDict[token] = value;
}
private void AddReplaceTransform(
TSqlParserToken token,
string value
)
{
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
_replaceDict[token] = value;
}
private void AddReplaceTransform(
TSqlFragment node,
string value
)
{
if (node is null)
{
throw new ArgumentNullException(nameof(node));
}
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
for (var tokenIndex = node.FirstTokenIndex; tokenIndex <= node.LastTokenIndex; tokenIndex++)
{
var token = node.ScriptTokenStream[tokenIndex];
if (tokenIndex == node.FirstTokenIndex)
{
_replaceDict[token] = value;
}
else
{
_replaceDict[token] = string.Empty;
}
}
}
}
}
| 26.024752 | 104 | 0.528248 | [
"MIT"
] | Dimsday/ReSequel | SqlServerValidator/Formatter/Visitors/ReplaceSqlFragmentVisitor.cs | 5,259 | C# |
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EasyCron.Sample.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
| 28.675 | 110 | 0.600697 | [
"MIT"
] | Anymedi-Inc/EasyCronJob | samples/EasyCron.Sample/Controllers/WeatherForecastController.cs | 1,149 | C# |
// Copyright 2007-2015 Chris Patterson, Dru Sellers, Travis Smith, et. al.
//
// 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.
namespace MassTransit.Saga
{
using System.Threading.Tasks;
using GreenPipes;
/// <summary>
/// Creates a saga instance when an existing saga instance is missing
/// </summary>
/// <typeparam name="TSaga">The saga type</typeparam>
/// <typeparam name="TMessage"></typeparam>
public interface ISagaFactory<TSaga, TMessage>
where TSaga : class, ISaga
where TMessage : class
{
/// <summary>
/// Create a new saga instance using the supplied consume context
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
TSaga Create(ConsumeContext<TMessage> context);
/// <summary>
/// Send the context through the factory, with the proper decorations
/// </summary>
/// <param name="context"></param>
/// <param name="next"></param>
/// <returns></returns>
Task Send(ConsumeContext<TMessage> context, IPipe<SagaConsumeContext<TSaga, TMessage>> next);
}
} | 39.674419 | 102 | 0.639508 | [
"ECL-2.0",
"Apache-2.0"
] | AOrlov/MassTransit | src/MassTransit/Saga/ISagaFactory.cs | 1,706 | C# |
using HumanFood.Food;
using HumanFood.Human;
using Microsoft.Extensions.DependencyInjection;
var provider = new ServiceCollection()
.AddTransient<List<IFood>>()
.AddScoped<Human>()
.AddTransient<IFeed>(s => s.GetRequiredService<Human>())
.AddTransient<IHuman>(s => s.GetRequiredService<Human>())
.AddTransient<Cook>()
.BuildServiceProvider();
var firstCook = provider.GetRequiredService<Cook>();
firstCook.Feed(new Orange());
firstCook.Ask();
using var humanFeedScope = provider.CreateScope();
var secondCook = humanFeedScope.ServiceProvider.GetRequiredService<Cook>();
secondCook.Feed(new Peach());
secondCook.Ask();
var thirdCook = humanFeedScope.ServiceProvider.GetRequiredService<Cook>();
thirdCook.Feed(new Watermelon());
thirdCook.Ask();
firstCook.Feed(new Orange());
firstCook.Ask();
| 28.344828 | 75 | 0.751825 | [
"MIT"
] | aleksandrmaslovskii/HumanFood | HumanFood/Program.cs | 824 | C# |
//-----------------------------------------------------------------------
// <copyright file="Int32ArrayBinaryReader.cs" company="Leet">
// Copyright © by Hubert Bukowski. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Leet.Binary
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// A class that represents a binary reader which underlying data is an <see cref="Int32"/> array.
/// </summary>
internal sealed class Int32ArrayBinaryReader : ArrayBinaryReader<int>
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="Int32ArrayBinaryReader"/> class with
/// a bit array,
/// a bit offset value and
/// a bit count.
/// </summary>
/// <param name="bitArray">
/// An array which contains reader bits.
/// </param>
/// <param name="arrayBitOffset">
/// An array bit index at which the reading shall begin.
/// </param>
/// <param name="bitLength">
/// Number of bits available for the reader.
/// </param>
internal Int32ArrayBinaryReader(int[] bitArray, int arrayBitOffset, int bitLength)
: base(bitArray, arrayBitOffset, bitLength)
{
Contract.Requires(bitArray != null);
Contract.Requires(arrayBitOffset >= 0);
Contract.Requires(bitLength >= 0);
Contract.Requires(arrayBitOffset + bitLength <= Bits.BitSizeOf(bitArray));
Contract.Ensures(this.BitLength == bitLength);
Contract.Ensures(this.BitSegment.Value == bitArray);
Contract.Ensures(this.BitSegment.BitOffset == arrayBitOffset);
Contract.Ensures(this.BitSegment.BitCount == bitLength);
}
#endregion
#region Methods
/// <summary>
/// Reads specified numbers of bits starting at the specified offset.
/// </summary>
/// <param name="bitOffset">
/// Offset at which the read shall begin.
/// </param>
/// <param name="bitCount">
/// Number of bits to read.
/// </param>
/// <returns>
/// A bit segment of the <see cref="Int32"/> value that delimits the bits read from the object.
/// </returns>
public override BitSegment<int> ReadBitsAsInt32(int bitOffset, int bitCount)
{
if (bitCount == 0 || this.BitSegment.BitCount == 0)
{
return new BitSegment<int>();
}
int startBitIndex = this.BitSegment.BitOffset + bitOffset;
int limitIndex = Math.Min(startBitIndex + bitCount, this.BitSegment.BitOffset + bitOffset + bitCount);
int startArrayIndex = Bits.GetArrayIndex(Bits.Int32BitSize, startBitIndex);
int startElementBitOffset = Bits.GetArrayElementBitOffset(Bits.Int32BitSize, startBitIndex);
int limitArrayIndex = Bits.GetArrayIndex(Bits.Int32BitSize, limitIndex);
int limitElementBitOffset = Bits.GetArrayElementBitOffset(Bits.Int32BitSize, limitIndex);
Contract.Assume(startArrayIndex < this.BitSegment.Value.Length);
int value = this.BitSegment.Value[startArrayIndex];
int segmentBitOffset = startElementBitOffset;
Contract.Assume(Bits.BitSizeOf(value) == Bits.Int32BitSize);
Contract.Assume(this.BitLength == -1 || Contract.Result<BitSegment<int>>().BitCount <= this.BitLength - bitOffset);
if (limitArrayIndex > startArrayIndex)
{
Contract.Assume(Bits.BitSizeOf(value) - segmentBitOffset <= bitCount);
BitSegment<int> result = new BitSegment<int>(value, segmentBitOffset);
Contract.Assume(this.BitLength == -1 || result.BitCount <= this.BitLength - bitOffset);
return result;
}
else
{
int segmentBitCount = limitElementBitOffset - startElementBitOffset + 1;
BitSegment<int> result = new BitSegment<int>(value, segmentBitOffset, segmentBitCount);
Contract.Assume(this.BitLength == -1 || result.BitCount <= this.BitLength - bitOffset);
return result;
}
}
/// <summary>
/// Reads specified numbers of bits starting at the specified offset.
/// </summary>
/// <param name="bitOffset">
/// Offset at which the read shall begin.
/// </param>
/// <param name="bitCount">
/// Number of bits to read.
/// </param>
/// <returns>
/// A bit segment of the <see cref="Int64"/> value that delimits the bits read from the object.
/// </returns>
public override BitSegment<long> ReadBitsAsInt64(int bitOffset, int bitCount)
{
if (bitCount == 0 || this.BitSegment.BitCount == 0)
{
return new BitSegment<long>();
}
int startBitIndex = this.BitSegment.BitOffset + bitOffset;
int limitIndex = Math.Min(startBitIndex + bitCount, this.BitSegment.BitOffset + bitOffset + bitCount);
int startArrayIndex = Bits.GetArrayIndex(Bits.Int32BitSize, startBitIndex);
int startElementBitOffset = Bits.GetArrayElementBitOffset(Bits.Int32BitSize, startBitIndex);
int limitArrayIndex = Bits.GetArrayIndex(Bits.Int32BitSize, limitIndex);
int limitElementBitOffset = Bits.GetArrayElementBitOffset(Bits.Int32BitSize, limitIndex);
Contract.Assume(startArrayIndex < this.BitSegment.Value.Length);
long value = this.BitSegment.Value[startArrayIndex];
int segmentBitOffset = 32 + startElementBitOffset;
Contract.Assume(Bits.BitSizeOf(value) == Bits.Int64BitSize);
if (limitArrayIndex > startArrayIndex)
{
Contract.Assume(Bits.BitSizeOf(value) - segmentBitOffset <= bitCount);
BitSegment<long> result = new BitSegment<long>(value, segmentBitOffset);
Contract.Assume(this.BitLength == -1 || result.BitCount <= this.BitLength - bitOffset);
return result;
}
else
{
int segmentBitCount = limitElementBitOffset - startElementBitOffset + 1;
BitSegment<long> result = new BitSegment<long>(value, segmentBitOffset, segmentBitCount);
Contract.Assume(this.BitLength == -1 || result.BitCount <= this.BitLength - bitOffset);
return result;
}
}
#endregion
}
}
| 44.576923 | 127 | 0.586713 | [
"MIT"
] | hubuk/Binary | src/LeetABit.Binary/Backups/Bits/Int32ArrayBinaryReader.cs | 6,955 | C# |
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace Workday.Compensation
{
[GeneratedCode("System.Xml", "4.6.1590.0"), DesignerCategory("code"), DebuggerStepThrough, XmlType(Namespace = "urn:com.workday/bsvc")]
[Serializable]
public class Condition_RuleObjectIDType : INotifyPropertyChanged
{
private string typeField;
private string valueField;
[method: CompilerGenerated]
[CompilerGenerated]
public event PropertyChangedEventHandler PropertyChanged;
[XmlAttribute(Form = XmlSchemaForm.Qualified)]
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
this.RaisePropertyChanged("type");
}
}
[XmlText]
public string Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
this.RaisePropertyChanged("Value");
}
}
protected void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
| 20.672131 | 136 | 0.727201 | [
"MIT"
] | matteofabbri/Workday.WebServices | Workday.Compensation/Condition_RuleObjectIDType.cs | 1,261 | C# |
namespace DaggerLib.UI.Windows
{
partial class ValueEditorDialog
{
/// <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()
{
System.ComponentModel.StringConverter stringConverter1 = new System.ComponentModel.StringConverter();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.genericValueEditor1 = new GenericValueEditor();
this.SuspendLayout();
//
// okButton
//
this.okButton.Location = new System.Drawing.Point(52, 38);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 0;
this.okButton.Text = "Ok";
this.okButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
this.cancelButton.Location = new System.Drawing.Point(133, 38);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 1;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// genericValueEditor1
//
this.genericValueEditor1.Converter = stringConverter1;
this.genericValueEditor1.Location = new System.Drawing.Point(12, 12);
this.genericValueEditor1.Name = "genericValueEditor1";
this.genericValueEditor1.Size = new System.Drawing.Size(235, 20);
this.genericValueEditor1.TabIndex = 2;
this.genericValueEditor1.Text = "genericValueEditor1";
//
// ValueEditorDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(262, 69);
this.Controls.Add(this.genericValueEditor1);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ValueEditorDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "ValueEditorDialog";
this.Load += new System.EventHandler(this.ValueEditorDialog_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private GenericValueEditor genericValueEditor1;
}
} | 40.311111 | 113 | 0.590959 | [
"MIT"
] | mikecopperwhite/DSGraphEdit | DaggerLib.UI.Windows/ValueEditorDialog.Designer.cs | 3,628 | C# |
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.
using System;
using System.Runtime.InteropServices;
using System.Text;
using Silk.NET.Core.Native;
using Ultz.SuperInvoke;
namespace Silk.NET.Vulkan
{
public unsafe struct PerformanceValueINTEL
{
public PerformanceValueINTEL
(
PerformanceValueTypeINTEL type = default,
PerformanceValueDataINTEL data = default
)
{
Type = type;
Data = data;
}
/// <summary></summary>
public PerformanceValueTypeINTEL Type;
/// <summary></summary>
public PerformanceValueDataINTEL Data;
}
}
| 22.515152 | 57 | 0.652759 | [
"MIT"
] | mcavanagh/Silk.NET | src/Vulkan/Silk.NET.Vulkan/Structs/PerformanceValueINTEL.gen.cs | 743 | C# |
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.Azure.Kusto
{
/// <summary>
/// Manages a Kusto (also known as Azure Data Explorer) Database Principal
///
/// > **NOTE:** This resource is being **deprecated** due to API updates and should no longer be used. Please use azure.kusto.DatabasePrincipalAssignment instead.
///
/// ## Example Usage
///
/// ```csharp
/// using Pulumi;
/// using Azure = Pulumi.Azure;
///
/// class MyStack : Stack
/// {
/// public MyStack()
/// {
/// var current = Output.Create(Azure.Core.GetClientConfig.InvokeAsync());
/// var rg = new Azure.Core.ResourceGroup("rg", new Azure.Core.ResourceGroupArgs
/// {
/// Location = "West Europe",
/// });
/// var cluster = new Azure.Kusto.Cluster("cluster", new Azure.Kusto.ClusterArgs
/// {
/// Location = rg.Location,
/// ResourceGroupName = rg.Name,
/// Sku = new Azure.Kusto.Inputs.ClusterSkuArgs
/// {
/// Name = "Standard_D13_v2",
/// Capacity = 2,
/// },
/// });
/// var database = new Azure.Kusto.Database("database", new Azure.Kusto.DatabaseArgs
/// {
/// ResourceGroupName = rg.Name,
/// Location = rg.Location,
/// ClusterName = cluster.Name,
/// HotCachePeriod = "P7D",
/// SoftDeletePeriod = "P31D",
/// });
/// var principal = new Azure.Kusto.DatabasePrincipal("principal", new Azure.Kusto.DatabasePrincipalArgs
/// {
/// ResourceGroupName = rg.Name,
/// ClusterName = cluster.Name,
/// DatabaseName = azurerm_kusto_database.Test.Name,
/// Role = "Viewer",
/// Type = "User",
/// ClientId = current.Apply(current => current.TenantId),
/// ObjectId = current.Apply(current => current.ClientId),
/// });
/// }
///
/// }
/// ```
///
/// ## Import
///
/// Kusto Database Principals can be imported using the `resource id`, e.g.
///
/// ```sh
/// $ pulumi import azure:kusto/databasePrincipal:DatabasePrincipal example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/Databases/database1/Role/role1/FQN/some-guid
/// ```
/// </summary>
[AzureResourceType("azure:kusto/databasePrincipal:DatabasePrincipal")]
public partial class DatabasePrincipal : Pulumi.CustomResource
{
/// <summary>
/// The app id, if not empty, of the principal.
/// </summary>
[Output("appId")]
public Output<string> AppId { get; private set; } = null!;
/// <summary>
/// The Client ID that owns the specified `object_id`. Changing this forces a new resource to be created.
/// </summary>
[Output("clientId")]
public Output<string> ClientId { get; private set; } = null!;
/// <summary>
/// Specifies the name of the Kusto Cluster this database principal will be added to. Changing this forces a new resource to be created.
/// </summary>
[Output("clusterName")]
public Output<string> ClusterName { get; private set; } = null!;
/// <summary>
/// Specified the name of the Kusto Database this principal will be added to. Changing this forces a new resource to be created.
/// </summary>
[Output("databaseName")]
public Output<string> DatabaseName { get; private set; } = null!;
/// <summary>
/// The email, if not empty, of the principal.
/// </summary>
[Output("email")]
public Output<string> Email { get; private set; } = null!;
/// <summary>
/// The fully qualified name of the principal.
/// </summary>
[Output("fullyQualifiedName")]
public Output<string> FullyQualifiedName { get; private set; } = null!;
/// <summary>
/// The name of the Kusto Database Principal.
/// </summary>
[Output("name")]
public Output<string> Name { get; private set; } = null!;
/// <summary>
/// An Object ID of a User, Group, or App. Changing this forces a new resource to be created.
/// </summary>
[Output("objectId")]
public Output<string> ObjectId { get; private set; } = null!;
/// <summary>
/// Specifies the Resource Group where the Kusto Database Principal should exist. Changing this forces a new resource to be created.
/// </summary>
[Output("resourceGroupName")]
public Output<string> ResourceGroupName { get; private set; } = null!;
/// <summary>
/// Specifies the permissions the Principal will have. Valid values include `Admin`, `Ingestor`, `Monitor`, `UnrestrictedViewers`, `User`, `Viewer`. Changing this forces a new resource to be created.
/// </summary>
[Output("role")]
public Output<string> Role { get; private set; } = null!;
/// <summary>
/// Specifies the type of object the principal is. Valid values include `App`, `Group`, `User`. Changing this forces a new resource to be created.
/// </summary>
[Output("type")]
public Output<string> Type { get; private set; } = null!;
/// <summary>
/// Create a DatabasePrincipal resource with the given unique name, arguments, and options.
/// </summary>
///
/// <param name="name">The unique name of the resource</param>
/// <param name="args">The arguments used to populate this resource's properties</param>
/// <param name="options">A bag of options that control this resource's behavior</param>
public DatabasePrincipal(string name, DatabasePrincipalArgs args, CustomResourceOptions? options = null)
: base("azure:kusto/databasePrincipal:DatabasePrincipal", name, args ?? new DatabasePrincipalArgs(), MakeResourceOptions(options, ""))
{
}
private DatabasePrincipal(string name, Input<string> id, DatabasePrincipalState? state = null, CustomResourceOptions? options = null)
: base("azure:kusto/databasePrincipal:DatabasePrincipal", name, state, MakeResourceOptions(options, id))
{
}
private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
{
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
merged.Id = id ?? merged.Id;
return merged;
}
/// <summary>
/// Get an existing DatabasePrincipal resource's state with the given name, ID, and optional extra
/// properties used to qualify the lookup.
/// </summary>
///
/// <param name="name">The unique name of the resulting resource.</param>
/// <param name="id">The unique provider ID of the resource to lookup.</param>
/// <param name="state">Any extra arguments used during the lookup.</param>
/// <param name="options">A bag of options that control this resource's behavior</param>
public static DatabasePrincipal Get(string name, Input<string> id, DatabasePrincipalState? state = null, CustomResourceOptions? options = null)
{
return new DatabasePrincipal(name, id, state, options);
}
}
public sealed class DatabasePrincipalArgs : Pulumi.ResourceArgs
{
/// <summary>
/// The Client ID that owns the specified `object_id`. Changing this forces a new resource to be created.
/// </summary>
[Input("clientId", required: true)]
public Input<string> ClientId { get; set; } = null!;
/// <summary>
/// Specifies the name of the Kusto Cluster this database principal will be added to. Changing this forces a new resource to be created.
/// </summary>
[Input("clusterName", required: true)]
public Input<string> ClusterName { get; set; } = null!;
/// <summary>
/// Specified the name of the Kusto Database this principal will be added to. Changing this forces a new resource to be created.
/// </summary>
[Input("databaseName", required: true)]
public Input<string> DatabaseName { get; set; } = null!;
/// <summary>
/// An Object ID of a User, Group, or App. Changing this forces a new resource to be created.
/// </summary>
[Input("objectId", required: true)]
public Input<string> ObjectId { get; set; } = null!;
/// <summary>
/// Specifies the Resource Group where the Kusto Database Principal should exist. Changing this forces a new resource to be created.
/// </summary>
[Input("resourceGroupName", required: true)]
public Input<string> ResourceGroupName { get; set; } = null!;
/// <summary>
/// Specifies the permissions the Principal will have. Valid values include `Admin`, `Ingestor`, `Monitor`, `UnrestrictedViewers`, `User`, `Viewer`. Changing this forces a new resource to be created.
/// </summary>
[Input("role", required: true)]
public Input<string> Role { get; set; } = null!;
/// <summary>
/// Specifies the type of object the principal is. Valid values include `App`, `Group`, `User`. Changing this forces a new resource to be created.
/// </summary>
[Input("type", required: true)]
public Input<string> Type { get; set; } = null!;
public DatabasePrincipalArgs()
{
}
}
public sealed class DatabasePrincipalState : Pulumi.ResourceArgs
{
/// <summary>
/// The app id, if not empty, of the principal.
/// </summary>
[Input("appId")]
public Input<string>? AppId { get; set; }
/// <summary>
/// The Client ID that owns the specified `object_id`. Changing this forces a new resource to be created.
/// </summary>
[Input("clientId")]
public Input<string>? ClientId { get; set; }
/// <summary>
/// Specifies the name of the Kusto Cluster this database principal will be added to. Changing this forces a new resource to be created.
/// </summary>
[Input("clusterName")]
public Input<string>? ClusterName { get; set; }
/// <summary>
/// Specified the name of the Kusto Database this principal will be added to. Changing this forces a new resource to be created.
/// </summary>
[Input("databaseName")]
public Input<string>? DatabaseName { get; set; }
/// <summary>
/// The email, if not empty, of the principal.
/// </summary>
[Input("email")]
public Input<string>? Email { get; set; }
/// <summary>
/// The fully qualified name of the principal.
/// </summary>
[Input("fullyQualifiedName")]
public Input<string>? FullyQualifiedName { get; set; }
/// <summary>
/// The name of the Kusto Database Principal.
/// </summary>
[Input("name")]
public Input<string>? Name { get; set; }
/// <summary>
/// An Object ID of a User, Group, or App. Changing this forces a new resource to be created.
/// </summary>
[Input("objectId")]
public Input<string>? ObjectId { get; set; }
/// <summary>
/// Specifies the Resource Group where the Kusto Database Principal should exist. Changing this forces a new resource to be created.
/// </summary>
[Input("resourceGroupName")]
public Input<string>? ResourceGroupName { get; set; }
/// <summary>
/// Specifies the permissions the Principal will have. Valid values include `Admin`, `Ingestor`, `Monitor`, `UnrestrictedViewers`, `User`, `Viewer`. Changing this forces a new resource to be created.
/// </summary>
[Input("role")]
public Input<string>? Role { get; set; }
/// <summary>
/// Specifies the type of object the principal is. Valid values include `App`, `Group`, `User`. Changing this forces a new resource to be created.
/// </summary>
[Input("type")]
public Input<string>? Type { get; set; }
public DatabasePrincipalState()
{
}
}
}
| 42.772727 | 243 | 0.587825 | [
"ECL-2.0",
"Apache-2.0"
] | ScriptBox99/pulumi-azure | sdk/dotnet/Kusto/DatabasePrincipal.cs | 13,174 | C# |
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org)
// Copyright (c) 2018-2021 Stride and its contributors (https://stride3d.net)
// Copyright (c) 2011-2018 Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// See the LICENSE.md file in the project root for full license information.
using System;
using System.Runtime.InteropServices;
using Stride.Core.Mathematics;
namespace Stride.Graphics
{
/// <summary>
/// Describes a custom vertex format structure that contains position and color information.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct VertexPositionTexture : IEquatable<VertexPositionTexture>, IVertex
{
/// <summary>
/// Initializes a new <see cref="VertexPositionTexture"/> instance.
/// </summary>
/// <param name="position">The position of this vertex.</param>
/// <param name="textureCoordinate">UV texture coordinates.</param>
public VertexPositionTexture(Vector3 position, Vector2 textureCoordinate)
: this()
{
Position = position;
TextureCoordinate = textureCoordinate;
}
/// <summary>
/// XYZ position.
/// </summary>
public Vector3 Position;
/// <summary>
/// UV texture coordinates.
/// </summary>
public Vector2 TextureCoordinate;
/// <summary>
/// Defines structure byte size.
/// </summary>
public static readonly int Size = 20;
/// <summary>
/// The vertex layout of this struct.
/// </summary>
public static readonly VertexDeclaration Layout = new VertexDeclaration(VertexElement.Position<Vector3>(), VertexElement.TextureCoordinate<Vector2>());
public bool Equals(VertexPositionTexture other)
{
return Position.Equals(other.Position) && TextureCoordinate.Equals(other.TextureCoordinate);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is VertexPositionTexture && Equals((VertexPositionTexture)obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = Position.GetHashCode();
hashCode = (hashCode * 397) ^ TextureCoordinate.GetHashCode();
return hashCode;
}
}
public VertexDeclaration GetLayout()
{
return Layout;
}
public void FlipWinding()
{
TextureCoordinate.X = (1.0f - TextureCoordinate.X);
}
public static bool operator ==(VertexPositionTexture left, VertexPositionTexture right)
{
return left.Equals(right);
}
public static bool operator !=(VertexPositionTexture left, VertexPositionTexture right)
{
return !left.Equals(right);
}
public override string ToString()
{
return string.Format("Position: {0}, Texcoord: {1}", Position, TextureCoordinate);
}
}
}
| 32.316327 | 159 | 0.606568 | [
"MIT"
] | Ethereal77/stride | sources/engine/Stride.Graphics/VertexPositionTexture.cs | 3,167 | C# |
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Nssol.Platypus.ApiModels;
using Nssol.Platypus.Controllers.Util;
using Nssol.Platypus.DataAccess;
using Nssol.Platypus.DataAccess.Core;
using Nssol.Platypus.DataAccess.Repositories;
using Nssol.Platypus.DataAccess.Repositories.Interfaces;
using Nssol.Platypus.DataAccess.Repositories.Interfaces.TenantRepositories;
using Nssol.Platypus.DataAccess.Repositories.TenantRepositories;
using Nssol.Platypus.Filters;
using Nssol.Platypus.Infrastructure;
using Nssol.Platypus.Infrastructure.Options;
using Nssol.Platypus.Logic;
using Nssol.Platypus.Logic.HostedService;
using Nssol.Platypus.Logic.Interfaces;
using Nssol.Platypus.Services;
using Nssol.Platypus.Services.Interfaces;
using Nssol.Platypus.Swagger;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Nssol.Platypus
{
/// <summary>
/// スタートアップクラス
/// </summary>
public class Startup
{
/// <summary>
/// コンフィギュレーション
/// </summary>
private IConfiguration Configuration { get; }
/// <summary>
/// 共通DBの接続文字列
/// TODO: Entity Framework CoreにSeed機能が実装されたら削除する。
/// </summary>
public static string DefaultConnectionString { get; set; }
/// <summary>
/// <see cref="Configure(IApplicationBuilder, IHostingEnvironment, ILoggerFactory, IOptions{WebSecurityOptions}, ICommonDiLogic)"/> 内処理用のロガー
/// </summary>
private ILogger logger;
/// <summary>
/// パイプラインのデバッグがあまりに辛いので、デバッグ用のログを出せるようにした。
/// </summary>
private bool isDebug;
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="configuration">設定情報</param>
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
/// <summary>
/// 使用するサービスをコンテナに追加します。
/// </summary>
/// <param name="services">サービスコンテナ</param>
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddOptions();
services.Configure<ActiveDirectoryOptions>(Configuration.GetSection("ActiveDirectoryOptions"));
services.Configure<ContainerManageOptions>(Configuration.GetSection("ContainerManageOptions"));
services.Configure<WebSecurityOptions>(Configuration.GetSection("WebSecurityOptions"));
services.Configure<ObjectStorageOptions>(Configuration.GetSection("ObjectStorageOptions"));
services.Configure<DeleteTensorBoardContainerTimerOptions>(Configuration.GetSection("DeleteTensorBoardContainerTimerOptions"));
services.Configure<BackupPostgresTimerOptions>(Configuration.GetSection("BackupPostgresTimerOptions"));
services.Configure<DBInitRetryOptions>(Configuration.GetSection("DBInitRetryOptions"));
services.Configure<SyncClusterFromDBOptions>(Configuration.GetSection("SyncClusterFromDBOptions"));
services.Configure<DeployOptions>(Configuration.GetSection("DeployOptions"));
DefaultConnectionString = Configuration.GetConnectionString("DefaultConnection");
// Entity Frameworkの追加
services.AddDbContext<CommonDbContext>(ServiceLifetime.Scoped);
// LogicのDI設定
services.AddTransient<IClusterManagementLogic, ClusterManagementLogic>();
services.AddTransient<ILoginLogic, LoginLogic>();
services.AddTransient<IDataLogic, DataLogic>();
services.AddTransient<ITrainingLogic, TrainingLogic>();
services.AddTransient<IInferenceLogic, InferenceLogic>();
services.AddTransient<IPreprocessLogic, PreprocessLogic>();
services.AddTransient<IStorageLogic, StorageLogic>();
services.AddTransient<ITagLogic, TagLogic>();
services.AddTransient<IGitLogic, GitLogic>();
services.AddTransient<IRegistryLogic, RegistryLogic>();
services.AddTransient<IMenuLogic, MenuLogic>();
services.AddTransient<IVersionLogic, VersionLogic>();
// ServiceのDI設定
services.AddTransient<IClusterManagementService, KubernetesService>();
services.AddTransient<IObjectStorageService, ObjectStorageS3Service>();
// 切替のため型指定でDI設定
services.AddTransient<GitHubService>();
services.AddTransient<GitLabService>();
services.AddTransient<DockerHubRegistryService>();
services.AddTransient<GitLabRegistryService>();
services.AddTransient<PrivateDockerRegistryService>();
// RepositoryのDI設定
services.AddTransient<IDataRepository, DataRepository>();
services.AddTransient<IDataTypeRepository, DataTypeRepository>();
services.AddTransient<IDataSetRepository, DataSetRepository>();
services.AddTransient<IPreprocessHistoryRepository, PreprocessHistoryRepository>();
services.AddTransient<IPreprocessRepository, PreprocessRepository>();
services.AddTransient<ITagRepository, TagRepository>();
services.AddTransient<ITenantRepository, TenantRepository>();
services.AddTransient<IRegistryRepository, RegistryRepository>();
services.AddTransient<IGitRepository, GitRepository>();
services.AddTransient<ITensorBoardContainerRepository, TensorBoardContainerRepository>();
services.AddTransient<ITrainingHistoryRepository, TrainingHistoryRepository>();
services.AddTransient<IInferenceHistoryRepository, InferenceHistoryRepository>();
services.AddTransient<IRoleRepository, RoleRepository>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<IMenuRepository, MenuRepository>();
services.AddTransient<INodeRepository, NodeRepository>();
services.AddTransient<ISettingRepository, SettingRepository>();
services.AddTransient<INodeTenantMapRepository, NodeTenantMapRepository>();
// その他のDI設定
services.AddTransient<IUnitOfWork, UnitOfWork>();
services.AddTransient(typeof(JsonExceptionHandlerAttribute));
services.AddTransient(typeof(Seed));
services.AddScoped<IMultiTenancyLogic, MultiTenancyLogic>();
services.AddScoped<ICommonDiLogic, CommonDiLogic>();
//appsettingss.jsonから設定値を取得できるようにする
services.AddSingleton<IConfiguration>(Configuration);
// HostedService(Timer類)のDI設定
services.AddSingleton<DeleteTensorBoardContainerTimer>();
services.AddSingleton<BackupPostgresTimer>();
services.AddSingleton<SyncClusterFromDBTimer>();
//ASP.NET Core MVCの追加
WebSecurityOptions wsops = new WebSecurityOptions();
Configuration.GetSection("WebSecurityOptions").Bind(wsops);
//DBの内容を一定時間保持するためのメモリキャッシュを利用する
services.AddMemoryCache();
#region services.AddAuthentication
var sp = services.BuildServiceProvider();
var settingRepository = sp.GetService<ISettingRepository>();
var key = settingRepository.GetApiJwtSigningKey();
services.AddAuthentication(
//既定の認証スキーマ。
JwtBearerDefaults.AuthenticationScheme
)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme,
options =>
{
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
{
// 署名キー検証
ValidateIssuerSigningKey = true,
IssuerSigningKey = key,
// iss(issuer)クレーム
ValidateIssuer = true,
ValidIssuer = wsops.ApiJwtIssuer,
// aud(audience)クレーム
ValidateAudience = true,
ValidAudience = wsops.ApiJwtAudience,
// トークンの有効期限の検証
ValidateLifetime = true,
// クライアントとサーバーの間の時刻の設定で許容される最大の時刻のずれ
ClockSkew = TimeSpan.Zero
};
options.Events = new JwtBearerEvents
{
OnTokenValidated = context =>
{
var token = context.SecurityToken as System.IdentityModel.Tokens.Jwt.JwtSecurityToken;
if (token != null && isDebug)
{
//アクセスログ出力
LogUtil.WritePLog(logger.LogInformation, context.HttpContext, $"Receive authorized api request with token {token.Id} as {token.Subject}");
}
return Task.FromResult(0);
},
OnChallenge = context =>
{
// 失敗した際のメッセージをレスポンスに格納する
if (context.AuthenticateFailure != null)
{
context.Response.OnStarting(async state =>
{
// アクセスコードが不正な文字列で復元できない場合や、アクセスコードの期限が切れているときにこちらに入る
//期限切れはInfo扱いで出力する
LogUtil.WritePLog(logger.LogInformation, context.HttpContext, $"The Access code is expired or invalid:{context.AuthenticateFailure.Message}");
await new CustomJsonResult(StatusCodes.Status401Unauthorized,
new JsonErrorResponse()
{
Type = this.GetType().FullName,
Title = "The Access code is expired or invalid.",
Instance = context.Request?.Path.Value
}
).SerializeJsonAsync(((JwtBearerChallengeContext)state).Response);
return;
}, context);
}
else
{
context.Response.OnStarting(async state =>
{
// アクセスコードがヘッダに設定されていない場合はこちらに入る
//WebAPIは常にplatypus cliから実行されるので、ヘッダが設定されていない場合はありえない。
//なのでここに到達したら不正アクセスと見なして、警告を出力する
LogUtil.WritePLog(logger.LogWarning, context.HttpContext, $"The access code is required. status = {state}");
await new CustomJsonResult(StatusCodes.Status401Unauthorized,
new JsonErrorResponse()
{
Type = this.GetType().FullName,
Title = "The access code is required.",
Instance = context.Request?.Path.Value
}
).SerializeJsonAsync(((JwtBearerChallengeContext)state).Response);
return;
}, context);
}
return Task.FromResult(0);
},
};
});
#endregion
services.AddCors();
services.AddMvc(cfg =>
{
// 集約エラー用フィルター
cfg.Filters.Add(typeof(GlobalExceptionHandlerAttribute));
});
if (wsops.EnableSwagger)
{
// SwaggerにXMLコメントの内容を反映させるために、サーバ上での XML Document のパスを渡す
var location = System.Reflection.Assembly.GetEntryAssembly().Location;
var xmlPath = location.Replace("dll", "xml");
//// SwaggerGen を追加
services.AddSwaggerGen(options =>
{
// APIの署名を記載
options.SwaggerDoc("v1", new Info
{
Title = "KAMONOHASHI API",
Version = "v1",
Description = "For developers only.",
Contact = new Contact()
{
Email = "kamonohashi-support@jp.nssol.nipponsteel.com",
Name = "KAMONOHASHI Support"
},
TermsOfService = ApplicationConst.Copyright
});
// デフォルトだと同じクラス名の入出力モデルを使えないので、識別に名前空間名も含める
// https://stackoverflow.com/questions/46071513/swagger-error-conflicting-schemaids-duplicate-schemaids-detected-for-types-a-a
options.CustomSchemaIds(x => x.FullName);
// XML Document Comment を読込む
options.IncludeXmlComments(xmlPath);
//トークン認証用のUIを追加する
options.AddSecurityDefinition("api_key", new ApiKeyScheme()
{
Name = "Authorization",
In = "header",
Type = "apiKey", //この指定が必須。https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/124
Description = "JWT Authorization header using the Bearer scheme. Example: \"Bearer {token}\""
});
options.OperationFilter<AssignJwtSecurityRequirements>();
});
}
services.Configure<Microsoft.AspNetCore.Http.Features.FormOptions>(options =>
{
//アプリケーションのアップロードサイズ上限を4GBに設定
options.MultipartBodyLengthLimit = 4294967295;
});
// HostedService(Timer類)の登録
services.AddHostedService<DeleteTensorBoardContainerTimer>();
services.AddHostedService<BackupPostgresTimer>();
services.AddHostedService<SyncClusterFromDBTimer>();
}
/// <summary>
/// HTTPリクエストパイプラインを構成します。
/// app.UseXxx()でパイプラインにミドルウェアを登録して、app.Run()でミドルウェアのチェーンを終端させます。
/// </summary>
/// <param name="app">アプリケーション</param>
/// <param name="env">ホスト環境</param>
/// <param name="loggerFactory">ロガーファクトリ</param>
/// <param name="securityOptions">appsettings.jsonから読み込んだセキュリティ設定情報</param>
/// <param name="commonDiLogic">DI用</param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions<WebSecurityOptions> securityOptions, ICommonDiLogic commonDiLogic)
{
WebSecurityOptions options = securityOptions.Value;
isDebug = options.EnableRequestPiplineDebugLog;
//ログ設定(ここで一回やれば、各クラスでの設定は不要)
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
loggerFactory.AddProvider(new Log4NetProvider());
logger = loggerFactory.CreateLogger<Startup>();
LogUtil.WriteSystemLog(logger.LogDebug, "Start to configure Platypus WebUI application");
//Startup中に例外が起きるとログが残らないため、原因追跡のためのtry/catchでエラー出力を用意する
try
{
AddMiddlewareForLogging(app, "Start pipeline", "end pipeline");
//例外処理のミドルウェアを追加する
//ASP.NET Core MVC内で発生した例外はFilterで吸収し、ここではその前段で発生した例外を処理する
//例外の発生点からこのミドルウェアまでの間のパイプラインは、特にcatch処理がなければスキップされるので注意
app.Use(async (context, next) =>
{
try
{
await next();
}
catch (Exception e)
{
string errorMessage = "Unhandled Exception Occured: " + e.Message;
LogUtil.WriteErrorPLog(logger, context, errorMessage, e);
await new CustomJsonResult(StatusCodes.Status500InternalServerError,
new JsonErrorResponse()
{
Type = this.GetType().FullName,
Title = errorMessage,
Instance = context.Request?.Path.Value,
})
.SerializeJsonAsync(context.Response);
}
});
AddMiddlewareForLogging(app, "Execute Request", "Return Response");
app.Use(async (httpContext, next) =>
{
//クリックジャッキング対策
httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
//後続のミドルウェアにつなぐ
await next();
});
//静的ファイルがあればそれを出力する
//エラーは発生しないハズなのでログ出力は行わない
app.UseStaticFiles();
AddMiddlewareForLogging(app, "Move to dinamic resource pipe", "Back from dinamic resource pipe");
if (options.EnableSwagger)
{
// UseSwagger と UseSwaggerUi を追加
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "KAMONOHASHI API V1");
});
}
AddMiddlewareForLogging(app, "Move to authentication", "Back from authentication");
app.UseAuthentication();
//ASP.NET Core MVCからのレスポンスは常にデバッグログを残す
AddMiddlewareForLogging(app, "Execute Request in ASP.NET Core MVC", null);
AddMiddlewareForLogging(app, null, "Return Response from ASP.NET Core MVC", true);
app.UseCors(builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Account}/{action=Index}/{id?}");
});
// /wsにアクセスされた際、kubernetes podのshell実行用のwebsocket通信を確立する
app.UseWhen(context => IsWebSocket(context), appBuilder =>
{
AddMiddlewareForLogging(appBuilder, "Execute WebSocket Request", null, true);
appBuilder.UseWebSockets();
appBuilder.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest)
{
var clusterManagementLogic = commonDiLogic.DynamicDi<Logic.Interfaces.IClusterManagementLogic>();
await clusterManagementLogic.ConnectKubernetesWebSocketAsync(context);
}
}
);
});
// 終端
app.Run(async context =>
{
//静的ファイル(拡張子付きのURL)はspa-fallbackに捕まらずバイパスされるので、ここでも404処理を入れる
LogUtil.WritePLog(logger.LogWarning, context, $"Failed to access valid resources or applications.");
await new CustomJsonResult(StatusCodes.Status404NotFound,
new JsonErrorResponse()
{
Type = this.GetType().FullName,
Title = "404 NOT FOUND..",
Instance = context.Request?.Path.Value
})
.SerializeJsonAsync(context.Response);
return;
});
}
catch (Exception e)
{
//ログ出力するためのcatch処理。そのままリスロー。
LogUtil.WriteSystemErrorLog(logger, e.Message, e);
throw;
}
LogUtil.WriteSystemLog(logger.LogDebug, "End to configure Platypus WebUI application");
}
/// <summary>
/// リクエストパスがWebsocketに向けたもの(/ws)か否かを判定
/// </summary>
/// <param name="context">コンテキスト</param>
private bool IsWebSocket(HttpContext context)
{
bool result = context.Request.Path.StartsWithSegments(new PathString("/ws"));
return result;
}
/// <summary>
/// ログ出力用のミドルウェアを追加する。
/// </summary>
/// <param name="app">ミドルウェアを追加するApplicationBuilder</param>
/// <param name="inMessage">次のミドルウェアに進む前に出力するログメッセージ</param>
/// <param name="outMessage">次のミドルウェアから戻ってきた後に出力するログメッセージ</param>
/// <param name="force">デバッグフラグがついていてもログ出力を強制するか</param>
private void AddMiddlewareForLogging(IApplicationBuilder app, string inMessage, string outMessage, bool force = false)
{
if (isDebug == false && force == false)
{
return;
}
app.Use(async (context, next) =>
{
//force=trueになっているものについては、レスポンスタイムを追記する
System.Diagnostics.Stopwatch stopwatch = null;
if (force)
{
stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
}
if (string.IsNullOrEmpty(inMessage) == false)
{
LogUtil.WritePLog(logger.LogDebug, context, $"{context.Response.StatusCode}:{inMessage}");
}
//後続のミドルウェアにつなぐ
await next();
if (string.IsNullOrEmpty(outMessage) == false)
{
string message = $"{context.Response.StatusCode}:{outMessage}";
if (force)
{
//実行時間の計測
stopwatch.Stop();
message += $"({stopwatch.ElapsedMilliseconds}ms)";
}
LogUtil.WritePLog(logger.LogDebug, context, message);
}
});
}
}
}
| 45.083984 | 185 | 0.54577 | [
"Apache-2.0"
] | kurage0807/kamonohashi | web-api/platypus/platypus/Startup.cs | 25,529 | C# |
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using TerraFX.ApplicationModel;
using TerraFX.Samples.Audio;
using TerraFX.Samples.Graphics;
namespace TerraFX.Samples
{
public static unsafe class Program
{
internal static readonly Assembly s_audioProviderPulseAudio = Assembly.LoadFrom("TerraFX.Audio.Providers.PulseAudio.dll");
internal static readonly Assembly s_graphicsProviderD3D12 = Assembly.LoadFrom("TerraFX.Graphics.Providers.D3D12.dll");
internal static readonly Assembly s_graphicsProviderVulkan = Assembly.LoadFrom("TerraFX.Graphics.Providers.Vulkan.dll");
private static readonly Sample[] s_samples = {
new EnumerateGraphicsAdapters("D3D12.EnumerateGraphicsAdapters", s_graphicsProviderD3D12),
new EnumerateGraphicsAdapters("Vulkan.EnumerateGraphicsAdapters", s_graphicsProviderVulkan),
new HelloWindow("D3D12.HelloWindow", s_graphicsProviderD3D12),
new HelloWindow("Vulkan.HelloWindow", s_graphicsProviderVulkan),
new HelloTriangle("D3D12.HelloTriangle", s_graphicsProviderD3D12),
new HelloTriangle("Vulkan.HelloTriangle", s_graphicsProviderVulkan),
new HelloQuad("D3D12.HelloQuad", s_graphicsProviderD3D12),
new HelloQuad("Vulkan.HelloQuad", s_graphicsProviderVulkan),
new HelloTransform("D3D12.HelloTransform", s_graphicsProviderD3D12),
new HelloTransform("Vulkan.HelloTransform", s_graphicsProviderVulkan),
new HelloTexture("D3D12.HelloTexture", s_graphicsProviderD3D12),
new HelloTexture("Vulkan.HelloTexture", s_graphicsProviderVulkan),
new HelloTextureTransform("D3D12.HelloTextureTransform", s_graphicsProviderD3D12),
new HelloTextureTransform("Vulkan.HelloTextureTransform", s_graphicsProviderVulkan),
new HelloTexture3D("D3D12.HelloTexture3D", s_graphicsProviderD3D12),
new HelloTexture3D("Vulkan.HelloTexture3D", s_graphicsProviderVulkan),
new HelloSmoke("D3D12.HelloSmoke", true, s_graphicsProviderD3D12),
new HelloSmoke("Vulkan.HelloSmoke", true, s_graphicsProviderVulkan),
new HelloSierpinskiPyramid("D3D12.HelloSierpinskiPyramid", 5, s_graphicsProviderD3D12),
new HelloSierpinskiPyramid("Vulkan.HelloSierpinskiPyramid", 5, s_graphicsProviderVulkan),
new HelloSierpinskiQuad("D3D12.HelloSierpinskiQuad", 6, s_graphicsProviderD3D12),
new HelloSierpinskiQuad("Vulkan.HelloSierpinskiQuad", 6, s_graphicsProviderVulkan),
new EnumerateAudioAdapters("PulseAudio.EnumerateAudioAdapters.Sync", false, s_audioProviderPulseAudio),
new EnumerateAudioAdapters("PulseAudio.EnumerateAudioAdapters.Async", true, s_audioProviderPulseAudio),
new PlaySampleAudio("PulseAudio.PlaySampleAudio", s_audioProviderPulseAudio),
};
public static void Main(string[] args)
{
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!;
if ((args.Length == 0) || args.Any((arg) => Matches(arg, "?", "h", "help")))
{
PrintHelp();
}
else
{
RunSamples(args);
}
}
private static bool IsSupported(Sample sample)
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? !sample.CompositionAssemblies.Contains(s_audioProviderPulseAudio)
: RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !sample.CompositionAssemblies.Contains(s_graphicsProviderD3D12);
;
}
private static bool Matches(string arg, params string[] keywords)
{
return keywords.Any((keyword) => ((arg.Length == keyword.Length) && arg.Equals(keyword, StringComparison.OrdinalIgnoreCase))
|| (((arg.Length - 1) == keyword.Length) && ((arg[0] == '-') || (arg[0] == '/')) && (string.Compare(arg, 1, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase) == 0)));
}
private static void PrintHelp()
{
Console.WriteLine("General Options");
Console.WriteLine(" ALL: Indicates that all samples should be run.");
Console.WriteLine();
Console.WriteLine("Available Samples - Can specify multiple");
foreach (var sample in s_samples)
{
if (IsSupported(sample))
{
Console.WriteLine($" {sample.Name}");
}
}
}
private static void Run(Sample sample)
{
using var application = new Application(sample.CompositionAssemblies);
sample.Initialize(application);
application.Run();
sample.Cleanup();
}
private static void RunSamples(string[] args)
{
var ranAnySamples = false;
if (args.Any((arg) => Matches(arg, "all")))
{
foreach (var sample in s_samples)
{
if (IsSupported(sample))
{
RunSample(sample);
ranAnySamples = true;
}
}
}
foreach (var arg in args)
{
foreach (var sample in s_samples.Where((sample) => arg.Equals(sample.Name, StringComparison.OrdinalIgnoreCase)))
{
if (IsSupported(sample))
{
RunSample(sample);
ranAnySamples = true;
}
}
}
if (ranAnySamples == false)
{
PrintHelp();
}
}
private static void RunSample(Sample sample)
{
Console.WriteLine($"Running: {sample.Name}");
var thread = new Thread(() => Run(sample));
thread.Start();
thread.Join();
}
}
}
| 39.825 | 222 | 0.611111 | [
"MIT"
] | LoicBaumann/terrafx | samples/TerraFX/Program.cs | 6,373 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyObj : MonoBehaviour
{
private float counter = 0;
void Update ()
{
counter += Time.deltaTime;
if (counter >= 1)
{
Destroy(gameObject);
}
}
}
| 16.5 | 39 | 0.599327 | [
"MIT"
] | julianapotengy/GameFeel | Assets/Scripts/DestroyObj.cs | 299 | C# |
// 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 System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.Asn1;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.Pkcs.Asn1;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace Internal.Cryptography.Pal.AnyOS
{
internal static class AsnHelpers
{
internal static SubjectIdentifierOrKey ToSubjectIdentifierOrKey(
this OriginatorIdentifierOrKeyAsn originator)
{
if (originator.IssuerAndSerialNumber.HasValue)
{
var name = new X500DistinguishedName(originator.IssuerAndSerialNumber.Value.Issuer.ToArray());
return new SubjectIdentifierOrKey(
SubjectIdentifierOrKeyType.IssuerAndSerialNumber,
new X509IssuerSerial(
name.Name,
originator.IssuerAndSerialNumber.Value.SerialNumber.Span.ToBigEndianHex()));
}
if (originator.SubjectKeyIdentifier.HasValue)
{
return new SubjectIdentifierOrKey(
SubjectIdentifierOrKeyType.SubjectKeyIdentifier,
originator.SubjectKeyIdentifier.Value.Span.ToBigEndianHex());
}
if (originator.OriginatorKey.HasValue)
{
OriginatorPublicKeyAsn originatorKey = originator.OriginatorKey.Value;
return new SubjectIdentifierOrKey(
SubjectIdentifierOrKeyType.PublicKeyInfo,
new PublicKeyInfo(
originatorKey.Algorithm.ToPresentationObject(),
originatorKey.PublicKey.ToArray()));
}
Debug.Fail("Unknown SubjectIdentifierOrKey state");
return new SubjectIdentifierOrKey(SubjectIdentifierOrKeyType.Unknown, string.Empty);
}
internal static AlgorithmIdentifier ToPresentationObject(this AlgorithmIdentifierAsn asn)
{
int keyLength;
switch (asn.Algorithm.Value)
{
case Oids.Rc2Cbc:
{
if (asn.Parameters == null)
{
keyLength = 0;
break;
}
Rc2CbcParameters rc2Params = Rc2CbcParameters.Decode(
asn.Parameters.Value,
AsnEncodingRules.BER);
int keySize = rc2Params.GetEffectiveKeyBits();
// These are the only values .NET Framework would set.
switch (keySize)
{
case 40:
case 56:
case 64:
case 128:
keyLength = keySize;
break;
default:
keyLength = 0;
break;
}
break;
}
case Oids.Rc4:
{
if (asn.Parameters == null)
{
keyLength = 0;
break;
}
int saltLen = 0;
AsnReader reader = new AsnReader(asn.Parameters.Value, AsnEncodingRules.BER);
// DER NULL is considered the same as not present.
// No call to ReadNull() is necessary because the serializer already verified that
// there's no data after the [AnyValue] value.
if (reader.PeekTag() != Asn1Tag.Null)
{
if (reader.TryReadPrimitiveOctetStringBytes(out ReadOnlyMemory<byte> contents))
{
saltLen = contents.Length;
}
else
{
Span<byte> salt = stackalloc byte[KeyLengths.Rc4Max_128Bit / 8];
if (!reader.TryCopyOctetStringBytes(salt, out saltLen))
{
throw new CryptographicException();
}
}
}
keyLength = KeyLengths.Rc4Max_128Bit - 8 * saltLen;
break;
}
case Oids.DesCbc:
keyLength = KeyLengths.Des_64Bit;
break;
case Oids.TripleDesCbc:
keyLength = KeyLengths.TripleDes_192Bit;
break;
default:
// .NET Framework doesn't set a keylength for AES, or any other algorithm than the ones
// listed here.
keyLength = 0;
break;
}
return new AlgorithmIdentifier(new Oid(asn.Algorithm), keyLength);
}
}
}
| 39.177305 | 110 | 0.476647 | [
"MIT"
] | AlanParr/corefx | src/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/AnyOS/AsnHelpers.cs | 5,524 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Source_UnitInventory
{
public List<Source_InventoryGroup> groups;//Группировки слотов.
public Source_UnitInventory(Source_UnitInventory based)
{
this.groups = based.groups;
}
}
| 21.2 | 67 | 0.761006 | [
"MIT"
] | Airashe/DrippingMind | Source/Objects/Units/Source_UnitInventory.cs | 337 | C# |
using UnityEngine;
using System.Collections;
public class BGLooper : MonoBehaviour {
int numBGPanels = 6;
float pipeMax = 0.6540825f;
float pipeMin = -0.08800149f;
void Start() {
GameObject[] pipes = GameObject.FindGameObjectsWithTag ("Pipe");
foreach (GameObject pipe in pipes) {
Vector3 pos = pipe.transform.position;
pos.y = Random.Range(pipeMin, pipeMax);
pipe.transform.position = pos;
}
}
void OnTriggerEnter2D(Collider2D collider) {
Debug.Log ("Triggered: " + collider.name);
float widthOfBGObject = ((BoxCollider2D) collider).size.x;
Vector3 pos = collider.transform.position;
pos.x += widthOfBGObject * numBGPanels;
if (collider.tag == "Pipe") {
pos.y = Random.Range(pipeMin, pipeMax);
}
collider.transform.position = pos;
}
}
| 21.916667 | 66 | 0.69962 | [
"MIT"
] | mnapier/ClonyBird | Assets/Scripts/BGLooper.cs | 791 | C# |
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.Gcp.CloudRun.Inputs
{
public sealed class ServiceTemplateSpecVolumeSecretArgs : Pulumi.ResourceArgs
{
[Input("items")]
private InputList<Inputs.ServiceTemplateSpecVolumeSecretItemArgs>? _items;
/// <summary>
/// If unspecified, the volume will expose a file whose name is the
/// secret_name.
/// If specified, the key will be used as the version to fetch from Cloud
/// Secret Manager and the path will be the name of the file exposed in the
/// volume. When items are defined, they must specify a key and a path.
/// Structure is documented below.
/// </summary>
public InputList<Inputs.ServiceTemplateSpecVolumeSecretItemArgs> Items
{
get => _items ?? (_items = new InputList<Inputs.ServiceTemplateSpecVolumeSecretItemArgs>());
set => _items = value;
}
/// <summary>
/// The name of the secret in Cloud Secret Manager. By default, the secret
/// is assumed to be in the same project.
/// If the secret is in another project, you must define an alias.
/// An alias definition has the form:
/// <alias>:projects/<project-id|project-number>/secrets/<secret-name>.
/// If multiple alias definitions are needed, they must be separated by
/// commas.
/// The alias definitions must be set on the run.googleapis.com/secrets
/// annotation.
/// </summary>
[Input("secretName", required: true)]
public Input<string> SecretName { get; set; } = null!;
public ServiceTemplateSpecVolumeSecretArgs()
{
}
}
}
| 39.588235 | 104 | 0.64636 | [
"ECL-2.0",
"Apache-2.0"
] | la3mmchen/pulumi-gcp | sdk/dotnet/CloudRun/Inputs/ServiceTemplateSpecVolumeSecretArgs.cs | 2,019 | C# |
using System.Collections.Generic;
namespace Sawczyn.EFDesigner.EFModel.EditingOnly
{
public partial class GeneratedTextTransformation
{
#region Template
// EFDesigner v3.0.6
// Copyright (c) 2017-2021 Michael Sawczyn
// https://github.com/msawczyn/EFDesigner
public class EFCore3ModelGenerator : EFCore2ModelGenerator
{
public EFCore3ModelGenerator(GeneratedTextTransformation host) : base(host) { }
protected override void WriteTargetDeleteBehavior(UnidirectionalAssociation association, List<string> segments)
{
if (!association.Source.IsDependentType
&& !association.Target.IsDependentType
&& (association.TargetRole == EndpointRole.Principal || association.SourceRole == EndpointRole.Principal))
{
DeleteAction deleteAction = association.SourceRole == EndpointRole.Principal
? association.SourceDeleteAction
: association.TargetDeleteAction;
switch (deleteAction)
{
case DeleteAction.None:
segments.Add("OnDelete(DeleteBehavior.NoAction)");
break;
case DeleteAction.Cascade:
segments.Add("OnDelete(DeleteBehavior.Cascade)");
break;
}
}
}
protected override void WriteSourceDeleteBehavior(BidirectionalAssociation association, List<string> segments)
{
if (!association.Source.IsDependentType
&& !association.Target.IsDependentType
&& (association.TargetRole == EndpointRole.Principal || association.SourceRole == EndpointRole.Principal))
{
DeleteAction deleteAction = association.SourceRole == EndpointRole.Principal
? association.SourceDeleteAction
: association.TargetDeleteAction;
switch (deleteAction)
{
case DeleteAction.None:
segments.Add("OnDelete(DeleteBehavior.NoAction)");
break;
case DeleteAction.Cascade:
segments.Add("OnDelete(DeleteBehavior.Cascade)");
break;
}
}
}
}
#endregion Template
}
}
| 35.366197 | 120 | 0.556352 | [
"MIT"
] | BigHam/EFDesigner | src/DslPackage/TextTemplates/EditingOnly/EFCore3ModelGenerator.cs | 2,511 | C# |
using System.Numerics;
using System.Threading.Tasks;
using Rocket.API.Entities;
namespace Rocket.API.Player
{
/// <summary>
/// Represents a player entity.
/// </summary>
public interface IPlayerEntity<TPlayer> : IEntity where TPlayer : IPlayer
{
TPlayer Player { get; }
}
} | 22.285714 | 77 | 0.653846 | [
"MIT"
] | DropMod/Drop | Rocket.API/Player/IPlayerEntity.cs | 314 | C# |
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код был создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GetGuid.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GetGuid.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
| 40.450704 | 173 | 0.616992 | [
"MIT"
] | shakir-timur/GetGuid | GetGuid/Properties/Resources.Designer.cs | 3,406 | C# |
using System;
namespace PizzaStoreMVC.UI.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
} | 19.454545 | 70 | 0.672897 | [
"MIT"
] | 1811-nov27-net/JohnPot_Project_1 | PizzaStoreMVC.UI/Models/ErrorViewModel.cs | 214 | C# |
namespace Parsnet.FileWatchers.CreationTimeWatcher.Data
{
public class CreationTimeWatcherData
{
public int Id { get; set; }
public string ParserName { get; set; }
public long LastCreationTimeUtc { get; set; }
}
} | 27.666667 | 55 | 0.662651 | [
"MIT"
] | Metetron/Metetron.FileParser | src/Parsnet/FileWatchers/CreationTimeWatcher/Data/CreationTimeWatcherData.cs | 249 | C# |
using System;
namespace sbcsms
{
public class TelicEvent
{
public DateTime EventTime { get; set; }
public EventType EventType { get; set; }
public DateTime ReceiveTime { get; set; }
public DateTime GpsTime { get; set; }
public float Speed { get; set; } // [km/h]
public float Course { get; set; } // [°]
public string EventText { get; set; }
public float Latitude { get; set; }
public float Longitude { get; set; }
public PositionType PositionType { get; set; }
public byte GsmRssiEvent { get; set; }
public byte GsmRssiSmsSent { get; set; }
public uint StationarySeconds { get; set; }
public float AnalogInput { get; set; }
public float InternalBattery { get; set; }
public float ExternalPowerSupply { get; set; }
public string DigitalOutputStatus { get; set; }
public string DigitalInputStatus { get; set; }
public uint MCCMNC { get; set; }
public uint Mileage { get; set; }
public int Altitude { get; set; }
public int Satellites { get; set; }
public uint EventInfo { get; set; }
public int Hdop { get; set; }
public int Vdop { get; set; }
public uint PositionAccuracy { get; set; }
public override string ToString()
{
return $"{EventTime.ToLocalTime()}: {EventText}";
}
}
}
| 31.478261 | 61 | 0.578039 | [
"MIT"
] | SystemCheater/sbcsms | sbcsms/sbcsms/TelicEvent.cs | 1,451 | C# |
using System.Reflection;
using System.Runtime.CompilerServices;
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("WordCount")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WordCount")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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("fc3a3bf1-4b11-4446-9c92-0cda7551a996")]
// 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")]
| 37.594595 | 84 | 0.744069 | [
"MIT"
] | stStoyanov93/SoftUni-TechModule-ProgrammingFundamentals-2017 | 12 Files, Directories and Exceptions/LAB_FilesDirectoriesAndExceptions/WordCount/Properties/AssemblyInfo.cs | 1,394 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Silk.NET.Core.Attributes;
#pragma warning disable 1591
namespace Silk.NET.SDL
{
[NativeName("AnonymousName", "__AnonymousEnum_SDL_events_L55_C9")]
[NativeName("Name", "SDL_EventType")]
public enum EventType : int
{
[NativeName("Name", "SDL_FIRSTEVENT")]
Firstevent = 0x0,
[NativeName("Name", "SDL_QUIT")]
Quit = 0x100,
[NativeName("Name", "SDL_APP_TERMINATING")]
AppTerminating = 0x101,
[NativeName("Name", "SDL_APP_LOWMEMORY")]
AppLowmemory = 0x102,
[NativeName("Name", "SDL_APP_WILLENTERBACKGROUND")]
AppWillenterbackground = 0x103,
[NativeName("Name", "SDL_APP_DIDENTERBACKGROUND")]
AppDidenterbackground = 0x104,
[NativeName("Name", "SDL_APP_WILLENTERFOREGROUND")]
AppWillenterforeground = 0x105,
[NativeName("Name", "SDL_APP_DIDENTERFOREGROUND")]
AppDidenterforeground = 0x106,
[NativeName("Name", "SDL_LOCALECHANGED")]
Localechanged = 0x107,
[NativeName("Name", "SDL_DISPLAYEVENT")]
Displayevent = 0x150,
[NativeName("Name", "SDL_WINDOWEVENT")]
Windowevent = 0x200,
[NativeName("Name", "SDL_SYSWMEVENT")]
Syswmevent = 0x201,
[NativeName("Name", "SDL_KEYDOWN")]
Keydown = 0x300,
[NativeName("Name", "SDL_KEYUP")]
Keyup = 0x301,
[NativeName("Name", "SDL_TEXTEDITING")]
Textediting = 0x302,
[NativeName("Name", "SDL_TEXTINPUT")]
Textinput = 0x303,
[NativeName("Name", "SDL_KEYMAPCHANGED")]
Keymapchanged = 0x304,
[NativeName("Name", "SDL_MOUSEMOTION")]
Mousemotion = 0x400,
[NativeName("Name", "SDL_MOUSEBUTTONDOWN")]
Mousebuttondown = 0x401,
[NativeName("Name", "SDL_MOUSEBUTTONUP")]
Mousebuttonup = 0x402,
[NativeName("Name", "SDL_MOUSEWHEEL")]
Mousewheel = 0x403,
[NativeName("Name", "SDL_JOYAXISMOTION")]
Joyaxismotion = 0x600,
[NativeName("Name", "SDL_JOYBALLMOTION")]
Joyballmotion = 0x601,
[NativeName("Name", "SDL_JOYHATMOTION")]
Joyhatmotion = 0x602,
[NativeName("Name", "SDL_JOYBUTTONDOWN")]
Joybuttondown = 0x603,
[NativeName("Name", "SDL_JOYBUTTONUP")]
Joybuttonup = 0x604,
[NativeName("Name", "SDL_JOYDEVICEADDED")]
Joydeviceadded = 0x605,
[NativeName("Name", "SDL_JOYDEVICEREMOVED")]
Joydeviceremoved = 0x606,
[NativeName("Name", "SDL_CONTROLLERAXISMOTION")]
Controlleraxismotion = 0x650,
[NativeName("Name", "SDL_CONTROLLERBUTTONDOWN")]
Controllerbuttondown = 0x651,
[NativeName("Name", "SDL_CONTROLLERBUTTONUP")]
Controllerbuttonup = 0x652,
[NativeName("Name", "SDL_CONTROLLERDEVICEADDED")]
Controllerdeviceadded = 0x653,
[NativeName("Name", "SDL_CONTROLLERDEVICEREMOVED")]
Controllerdeviceremoved = 0x654,
[NativeName("Name", "SDL_CONTROLLERDEVICEREMAPPED")]
Controllerdeviceremapped = 0x655,
[NativeName("Name", "SDL_CONTROLLERTOUCHPADDOWN")]
Controllertouchpaddown = 0x656,
[NativeName("Name", "SDL_CONTROLLERTOUCHPADMOTION")]
Controllertouchpadmotion = 0x657,
[NativeName("Name", "SDL_CONTROLLERTOUCHPADUP")]
Controllertouchpadup = 0x658,
[NativeName("Name", "SDL_CONTROLLERSENSORUPDATE")]
Controllersensorupdate = 0x659,
[NativeName("Name", "SDL_FINGERDOWN")]
Fingerdown = 0x700,
[NativeName("Name", "SDL_FINGERUP")]
Fingerup = 0x701,
[NativeName("Name", "SDL_FINGERMOTION")]
Fingermotion = 0x702,
[NativeName("Name", "SDL_DOLLARGESTURE")]
Dollargesture = 0x800,
[NativeName("Name", "SDL_DOLLARRECORD")]
Dollarrecord = 0x801,
[NativeName("Name", "SDL_MULTIGESTURE")]
Multigesture = 0x802,
[NativeName("Name", "SDL_CLIPBOARDUPDATE")]
Clipboardupdate = 0x900,
[NativeName("Name", "SDL_DROPFILE")]
Dropfile = 0x1000,
[NativeName("Name", "SDL_DROPTEXT")]
Droptext = 0x1001,
[NativeName("Name", "SDL_DROPBEGIN")]
Dropbegin = 0x1002,
[NativeName("Name", "SDL_DROPCOMPLETE")]
Dropcomplete = 0x1003,
[NativeName("Name", "SDL_AUDIODEVICEADDED")]
Audiodeviceadded = 0x1100,
[NativeName("Name", "SDL_AUDIODEVICEREMOVED")]
Audiodeviceremoved = 0x1101,
[NativeName("Name", "SDL_SENSORUPDATE")]
Sensorupdate = 0x1200,
[NativeName("Name", "SDL_RENDER_TARGETS_RESET")]
RenderTargetsReset = 0x2000,
[NativeName("Name", "SDL_RENDER_DEVICE_RESET")]
RenderDeviceReset = 0x2001,
[NativeName("Name", "SDL_USEREVENT")]
Userevent = 0x8000,
[NativeName("Name", "SDL_LASTEVENT")]
Lastevent = 0xFFFF,
}
}
| 39.069231 | 71 | 0.625517 | [
"MIT"
] | Ar37-rs/Silk.NET | src/Windowing/Silk.NET.SDL/Enums/EventType.gen.cs | 5,079 | C# |
namespace Bali.Converter.App.Modules.MediaDownloader.ViewModels
{
using Prism.Mvvm;
public class VideoFormatViewModel : BindableBase
{
private int fps;
private int height;
private int width;
private float abr;
private float vbr;
public int Width
{
get => this.width;
set => this.SetProperty(ref this.width, value);
}
public int Height
{
get => this.height;
set => this.SetProperty(ref this.height, value);
}
public int Fps
{
get => this.fps;
set => this.SetProperty(ref this.fps, value);
}
public float AverageAudioBitRate
{
get => this.abr;
set => this.SetProperty(ref this.abr, value);
}
public float AverageVideoBitRate
{
get => this.vbr;
set => this.SetProperty(ref this.vbr, value);
}
}
}
| 22.659091 | 64 | 0.515547 | [
"Unlicense"
] | bozali/bali-converter | sources/Bali.Converter.App/Modules/MediaDownloader/ViewModels/VideoFormatViewModel.cs | 999 | C# |
namespace dBosque.Stub.Editor
{
partial class AddEditMessageTypeForm
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddEditMessageTypeForm));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.passthroughEnabled = new System.Windows.Forms.CheckBox();
this.tbPassthrougUri = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.regexTb = new System.Windows.Forms.TextBox();
this.namespaceTb = new System.Windows.Forms.TextBox();
this.descriptionTb = new System.Windows.Forms.TextBox();
this.rootnodeTb = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.sampleTb = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.tabControl1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.button2);
this.splitContainer1.Panel2.Controls.Add(this.button1);
this.splitContainer1.Size = new System.Drawing.Size(589, 442);
this.splitContainer1.SplitterDistance = 400;
this.splitContainer1.TabIndex = 0;
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(15, 17);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(566, 380);
this.tabControl1.TabIndex = 8;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.passthroughEnabled);
this.tabPage1.Controls.Add(this.tbPassthrougUri);
this.tabPage1.Controls.Add(this.label5);
this.tabPage1.Controls.Add(this.label4);
this.tabPage1.Controls.Add(this.label1);
this.tabPage1.Controls.Add(this.button3);
this.tabPage1.Controls.Add(this.label2);
this.tabPage1.Controls.Add(this.regexTb);
this.tabPage1.Controls.Add(this.namespaceTb);
this.tabPage1.Controls.Add(this.descriptionTb);
this.tabPage1.Controls.Add(this.rootnodeTb);
this.tabPage1.Controls.Add(this.label3);
this.tabPage1.Location = new System.Drawing.Point(4, 25);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(558, 351);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Add or Edit MessageType";
//
// passthroughEnabled
//
this.passthroughEnabled.AutoSize = true;
this.passthroughEnabled.Location = new System.Drawing.Point(21, 269);
this.passthroughEnabled.Name = "passthroughEnabled";
this.passthroughEnabled.Size = new System.Drawing.Size(237, 21);
this.passthroughEnabled.TabIndex = 11;
this.passthroughEnabled.Text = "Relay when no match was found.";
this.passthroughEnabled.UseVisualStyleBackColor = true;
//
// tbPassthrougUri
//
this.tbPassthrougUri.Location = new System.Drawing.Point(21, 313);
this.tbPassthrougUri.Name = "tbPassthrougUri";
this.tbPassthrougUri.Size = new System.Drawing.Size(523, 22);
this.tbPassthrougUri.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(18, 293);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(114, 17);
this.label5.TabIndex = 10;
this.label5.Text = "PassthroughUri :";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(18, 77);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(189, 17);
this.label4.TabIndex = 8;
this.label4.Text = "Test the regular expression :";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(18, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(260, 17);
this.label1.TabIndex = 0;
this.label1.Text = "Namespace or URI regular expression : ";
//
// button3
//
this.button3.Location = new System.Drawing.Point(451, 136);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(93, 28);
this.button3.TabIndex = 2;
this.button3.Text = "Validate";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(18, 159);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(82, 17);
this.label2.TabIndex = 1;
this.label2.Text = "Rootnode : ";
//
// regexTb
//
this.regexTb.Location = new System.Drawing.Point(21, 99);
this.regexTb.Name = "regexTb";
this.regexTb.Size = new System.Drawing.Size(523, 22);
this.regexTb.TabIndex = 1;
//
// namespaceTb
//
this.namespaceTb.Location = new System.Drawing.Point(21, 46);
this.namespaceTb.Name = "namespaceTb";
this.namespaceTb.Size = new System.Drawing.Size(523, 22);
this.namespaceTb.TabIndex = 0;
//
// descriptionTb
//
this.descriptionTb.Location = new System.Drawing.Point(21, 227);
this.descriptionTb.Name = "descriptionTb";
this.descriptionTb.Size = new System.Drawing.Size(523, 22);
this.descriptionTb.TabIndex = 3;
//
// rootnodeTb
//
this.rootnodeTb.Location = new System.Drawing.Point(21, 179);
this.rootnodeTb.Name = "rootnodeTb";
this.rootnodeTb.Size = new System.Drawing.Size(523, 22);
this.rootnodeTb.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(18, 207);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(87, 17);
this.label3.TabIndex = 4;
this.label3.Text = "Description :";
//
// tabPage2
//
this.tabPage2.Controls.Add(this.sampleTb);
this.tabPage2.Location = new System.Drawing.Point(4, 25);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(558, 351);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Sample";
this.tabPage2.UseVisualStyleBackColor = true;
//
// sampleTb
//
this.sampleTb.Dock = System.Windows.Forms.DockStyle.Fill;
this.sampleTb.Location = new System.Drawing.Point(3, 3);
this.sampleTb.Multiline = true;
this.sampleTb.Name = "sampleTb";
this.sampleTb.Size = new System.Drawing.Size(552, 345);
this.sampleTb.TabIndex = 0;
//
// button2
//
this.button2.Location = new System.Drawing.Point(470, 7);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(93, 28);
this.button2.TabIndex = 0;
this.button2.Text = "Apply";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(371, 7);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(93, 28);
this.button1.TabIndex = 1;
this.button1.Text = "Cancel";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// AddEditMessageTypeForm
//
this.AcceptButton = this.button2;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1;
this.ClientSize = new System.Drawing.Size(589, 442);
this.Controls.Add(this.splitContainer1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AddEditMessageTypeForm";
this.ShowInTaskbar = false;
this.Text = "Properties";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox rootnodeTb;
private System.Windows.Forms.TextBox namespaceTb;
private System.Windows.Forms.TextBox descriptionTb;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox regexTb;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox passthroughEnabled;
private System.Windows.Forms.TextBox tbPassthrougUri;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TextBox sampleTb;
}
} | 46.089404 | 154 | 0.586033 | [
"Apache-2.0"
] | dbosque/Stub | dBosque.Stub.Editor/Forms/AddEditMessageTypeForm.Designer.cs | 13,921 | C# |
// 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 System;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[ExportLspRequestHandlerProvider, Shared]
[LspMethod(Methods.TextDocumentFoldingRangeName, mutatesSolutionState: false)]
internal sealed class FoldingRangesHandler : AbstractStatelessRequestHandler<FoldingRangeParams, FoldingRange[]>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FoldingRangesHandler()
{
}
public override TextDocumentIdentifier? GetTextDocumentIdentifier(FoldingRangeParams request) => request.TextDocument;
public override async Task<FoldingRange[]> HandleRequestAsync(FoldingRangeParams request, RequestContext context, CancellationToken cancellationToken)
{
var document = context.Document;
if (document == null)
{
return Array.Empty<FoldingRange>();
}
var blockStructureService = document.Project.LanguageServices.GetService<BlockStructureService>();
if (blockStructureService == null)
{
return Array.Empty<FoldingRange>();
}
var blockStructure = await blockStructureService.GetBlockStructureAsync(document, cancellationToken).ConfigureAwait(false);
if (blockStructure == null)
{
return Array.Empty<FoldingRange>();
}
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
return GetFoldingRanges(blockStructure, text);
}
public static FoldingRange[] GetFoldingRanges(
SyntaxTree syntaxTree,
HostLanguageServices languageServices,
OptionSet options,
bool isMetadataAsSource,
CancellationToken cancellationToken)
{
var blockStructureService = (BlockStructureServiceWithProviders)languageServices.GetRequiredService<BlockStructureService>();
var blockStructure = blockStructureService.GetBlockStructure(syntaxTree, options, isMetadataAsSource, cancellationToken);
if (blockStructure == null)
{
return Array.Empty<FoldingRange>();
}
var text = syntaxTree.GetText(cancellationToken);
return GetFoldingRanges(blockStructure, text);
}
private static FoldingRange[] GetFoldingRanges(BlockStructure blockStructure, SourceText text)
{
if (blockStructure.Spans.IsEmpty)
{
return Array.Empty<FoldingRange>();
}
using var _ = ArrayBuilder<FoldingRange>.GetInstance(out var foldingRanges);
foreach (var span in blockStructure.Spans)
{
if (!span.IsCollapsible)
{
continue;
}
var linePositionSpan = text.Lines.GetLinePositionSpan(span.TextSpan);
// Filter out single line spans.
if (linePositionSpan.Start.Line == linePositionSpan.End.Line)
{
continue;
}
// TODO - Figure out which blocks should be returned as a folding range (and what kind).
// https://github.com/dotnet/roslyn/projects/45#card-20049168
FoldingRangeKind? foldingRangeKind = span.Type switch
{
BlockTypes.Comment => FoldingRangeKind.Comment,
BlockTypes.Imports => FoldingRangeKind.Imports,
BlockTypes.PreprocessorRegion => FoldingRangeKind.Region,
_ => null,
};
foldingRanges.Add(new FoldingRange()
{
StartLine = linePositionSpan.Start.Line,
StartCharacter = linePositionSpan.Start.Character,
EndLine = linePositionSpan.End.Line,
EndCharacter = linePositionSpan.End.Character,
Kind = foldingRangeKind
});
}
return foldingRanges.ToArray();
}
}
}
| 39.363636 | 158 | 0.629435 | [
"MIT"
] | mbpframework/roslyn | src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs | 4,765 | C# |
using UnityEngine;
namespace SteeringBehaviours
{
public class Flee : AgentBehaviour
{
public float secureDistance = 3; //Secure distance to flee and stop
public override Steering GetSteering()
{
// Create the structure to hold our output
Steering steering = new Steering();
// Get the direction to the target
steering.linear = transform.position - target.transform.position;
// Set secure distance to stop
if (steering.linear.magnitude <= secureDistance)
{
//Give full acceleration along this direction
steering.linear.Normalize();
steering.linear *= agent.maxAccel;
// steering.angular = 0;
}
else
{
//Reduce speed until it is small enough to set velocity to zero
steering.linear = -agent.velocity / 1.5f;
if (steering.linear.magnitude < 1 / 8)
{
agent.velocity = Vector3.zero;
}
}
return steering;
}
}
}
| 29.175 | 79 | 0.525278 | [
"MIT"
] | jotaate/Crowds | Assets/Scripts/Steering Behaviours/Basics/Flee.cs | 1,169 | C# |
using DaAPI.Core.Common;
using DaAPI.Core.Common.DHCPv6;
using DaAPI.Core.Packets.DHCPv4;
using DaAPI.Core.Packets.DHCPv6;
using DaAPI.Infrastructure.FilterEngines.DHCPv4;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace DaAPI.Infrastructure.FilterEngines.DHCPv4
{
public class SimpleDHCPv4PacketFilterEngine : SimpleDHCPPacketFilterEngine<
SimpleDHCPv4PacketFilterEngine, IDHCPv4PacketFilter,DHCPv4Packet,IPv4Address>, IDHCPv4PacketFilterEngine
{
#region Fields
#endregion
#region Properties
#endregion
#region Constructor
public SimpleDHCPv4PacketFilterEngine(
ILogger<SimpleDHCPv4PacketFilterEngine> logger) : this(Array.Empty<IDHCPv4PacketFilter>(), logger)
{
}
public SimpleDHCPv4PacketFilterEngine(
IEnumerable<IDHCPv4PacketFilter> filters,
ILogger<SimpleDHCPv4PacketFilterEngine> logger
) : base(filters,logger)
{
}
public void RemoveFilter<T>() where T : class, IDHCPv4PacketFilter => base.RemoveFilterBasedOnType<T>();
#endregion
#region Methods
#endregion
}
}
| 25.461538 | 112 | 0.71148 | [
"MIT"
] | just-the-benno/DaAPI | src/DaAPI.Infrastructure/FilterEngines/DHCPv4/SimpleDHCPv4PacketFilterEngine.cs | 1,326 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HideCube : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
transform.localScale = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update()
{
}
}
| 16.9 | 52 | 0.633136 | [
"MIT"
] | kangningchen/museum-navigator | Assets/Scripts/HideCube.cs | 340 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
namespace Microsoft.EntityFrameworkCore.Query;
public abstract class NorthwindQueryRelationalFixture<TModelCustomizer> : NorthwindQueryFixtureBase<TModelCustomizer>
where TModelCustomizer : IModelCustomizer, new()
{
public new RelationalTestStore TestStore
=> (RelationalTestStore)base.TestStore;
public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> base.AddOptions(builder).ConfigureWarnings(
c => c
.Log(RelationalEventId.QueryPossibleUnintendedUseOfEqualsWarning))
.EnableDetailedErrors();
protected override bool ShouldLogCategory(string logCategory)
=> logCategory == DbLoggerCategory.Query.Name;
protected override Type ContextType
=> typeof(NorthwindRelationalContext);
}
| 38.62069 | 117 | 0.759821 | [
"MIT"
] | Applesauce314/efcore | test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs | 1,120 | C# |
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Win32
{
public class IconImpl : IWindowIconImpl
{
private readonly MemoryStream _ms;
public IconImpl(Stream data)
{
_ms = new MemoryStream();
data.CopyTo(_ms);
_ms.Seek(0, SeekOrigin.Begin);
IntPtr bitmap;
var status = Gdip.GdipLoadImageFromStream(new ComIStreamWrapper(_ms), out bitmap);
if (status != Gdip.Status.Ok)
throw new Exception("Unable to load icon, gdip status: " + (int) status);
IntPtr icon;
status = Gdip.GdipCreateHICONFromBitmap(bitmap, out icon);
if (status != Gdip.Status.Ok)
throw new Exception("Unable to create HICON, gdip status: " + (int)status);
Gdip.GdipDisposeImage(bitmap);
HIcon = icon;
}
public IntPtr HIcon { get;}
public void Save(Stream outputStream)
{
lock (_ms)
{
_ms.Seek(0, SeekOrigin.Begin);
_ms.CopyTo(outputStream);
}
}
}
}
| 29.326087 | 94 | 0.585619 | [
"MIT"
] | Beffyman/Avalonia | src/Windows/Avalonia.Win32.NetStandard/IconImpl.cs | 1,351 | C# |
using System;
using System.Linq;
using System.Windows.Controls;
#if netle40
using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Controls;
using HandyControlDemo.Data;
using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
public class StepBarDemoViewModel : DemoViewModelBase<StepBarDemoModel>
{
public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList();
private int _stepIndex;
public int StepIndex
{
get => _stepIndex;
#if netle40
set => Set(nameof(StepIndex), ref _stepIndex, value);
#else
set => Set(ref _stepIndex, value);
#endif
}
/// <summary>
/// 下一步
/// </summary>
public RelayCommand<Panel> NextCmd => new Lazy<RelayCommand<Panel>>(() => new RelayCommand<Panel>(Next)).Value;
/// <summary>
/// 上一步
/// </summary>
public RelayCommand<Panel> PrevCmd => new Lazy<RelayCommand<Panel>>(() => new RelayCommand<Panel>(Prev)).Value;
private void Next(Panel panel)
{
foreach (var stepBar in panel.Children.OfType<StepBar>())
{
stepBar.Next();
}
}
private void Prev(Panel panel)
{
foreach (var stepBar in panel.Children.OfType<StepBar>())
{
stepBar.Prev();
}
}
}
} | 26.280702 | 119 | 0.594126 | [
"MIT"
] | DinoChan/HandyControl | src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs | 1,512 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Net.Http;
namespace Microsoft.Rest
{
/// <summary>
/// Represents the base return type of all ServiceClient REST operations without response body.
/// </summary>
public interface IHttpOperationResponse
{
/// <summary>
/// Gets information about the associated HTTP request.
/// </summary>
HttpRequestMessage Request { get; set; }
/// <summary>
/// Gets information about the associated HTTP response.
/// </summary>
HttpResponseMessage Response { get; set; }
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations with response body.
/// </summary>
public interface IHttpOperationResponse<T> : IHttpOperationResponse
{
/// <summary>
/// Gets or sets the response object.
/// </summary>
T Body { get; set; }
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations with a header response.
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IHttpOperationHeaderResponse<T> : IHttpOperationResponse
{
/// <summary>
/// Gets or sets the response header object.
/// </summary>
T Headers { get; set; }
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations with response body and header.
/// </summary>
public interface IHttpOperationResponse<TBody, THeader> : IHttpOperationResponse<TBody>, IHttpOperationHeaderResponse<THeader>
{
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations without response body.
/// </summary>
public class HttpOperationResponse : IHttpOperationResponse, IDisposable
{
/// <summary>
/// Indicates whether the HttpOperationResponse has been disposed.
/// </summary>
private bool _disposed;
/// <summary>
/// Gets information about the associated HTTP request.
/// </summary>
public HttpRequestMessage Request { get; set; }
/// <summary>
/// Gets information about the associated HTTP response.
/// </summary>
public HttpResponseMessage Response { get; set; }
/// <summary>
/// Dispose the HttpOperationResponse.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose the HttpClient and Handlers.
/// </summary>
/// <param name="disposing">True to release both managed and unmanaged resources; false to releases only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
_disposed = true;
// Dispose the request and response
if (Request != null)
{
Request.Dispose();
}
if (Response != null)
{
Response.Dispose();
}
Request = null;
Response = null;
}
}
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations.
/// </summary>
public class HttpOperationResponse<T> : HttpOperationResponse, IHttpOperationResponse<T>
{
/// <summary>
/// Gets or sets the response object.
/// </summary>
public T Body { get; set; }
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations.
/// </summary>
public class HttpOperationHeaderResponse<THeader> : HttpOperationResponse, IHttpOperationHeaderResponse<THeader>
{
public THeader Headers { get; set; }
}
/// <summary>
/// Represents the base return type of all ServiceClient REST operations.
/// </summary>
public class HttpOperationResponse<TBody, THeader> : HttpOperationResponse<TBody>, IHttpOperationResponse<TBody, THeader>
{
/// <summary>
/// Gets or sets the response header object.
/// </summary>
public THeader Headers { get; set; }
}
} | 32.258993 | 141 | 0.590767 | [
"MIT"
] | 0rland0Wats0n/azure-sdk-for-net | sdk/mgmtcommon/ClientRuntime/ClientRuntime/HttpOperationResponse.cs | 4,486 | C# |
using Microsoft.Azure.ServiceBus;
namespace DFC.Api.JobProfiles.IntegrationTests.Support.AzureServiceBus.ServiceBusFactory.Interfaces
{
public interface IMessageFactory
{
Message Create(string messageId, byte[] messageBody, string actionType, string contentType);
}
} | 32.111111 | 100 | 0.782007 | [
"MIT"
] | SkillsFundingAgency/dfc-api-integration-tests | DFC.Api.JobProfiles.IntegrationTests/Support/AzureServiceBus/ServiceBusFactory/Interfaces/IMessageFactory.cs | 291 | C# |
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace StylesSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
| 18.111111 | 42 | 0.705521 | [
"MIT"
] | CNinnovation/WPFWorkshopSep2018 | Day1/StylesSample/StylesSample/App.xaml.cs | 328 | C# |
using System.Reflection;
using System.Runtime.CompilerServices;
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("BP.DataService.Base")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BP.DataService.Base")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[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("463a00f7-1b24-47cb-b912-b7cf1616351c")]
// 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")]
| 38 | 84 | 0.747511 | [
"MIT"
] | xEvilDevilx/BusinessPrototype | BusinessPrototype_Template/DataService/BP.DataService.Base/Properties/AssemblyInfo.cs | 1,409 | C# |
using ExtensionsIO;
using ExtensionsRegex;
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceProcess;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
namespace WinFix.Services
{
class Diagnostic_Services : _IFeature
{
public string Name => "Diagnostic Services (Inventory)";
public string Description =>
"Enables problem detection, troubleshooting and resolution for Windows components." +
"\r\n\r\n" +
"While this is sometimes useful, all the other times, it is useless and it may send PC usage data to Microsoft." +
"\r\n" +
"Disabling this service also disables Inventory Collector and parts of Telemetry (Privacy).";
public bool Default => true;
public dynamic Recommended => false;
public bool Optimized => false;
public bool Enabled
{
get
{
return Service.IsEnabled(
"diagsvc",
"DPS",
"WdiServiceHost",
"WdiSystemHost",
"DiagTrack", // ALSO FOR TELEMETRY !!
"dmwappushsvc", // ALSO FOR TELEMETRY !!
"diagnosticshub.standardcollector.service", // ALSO FOR TELEMETRY !!
"pla"
);
}
}
public void Enable(bool Enable)
{
Service.EnableDisable("diagsvc", Enable, ServiceStartMode.Manual);
Service.EnableDisable("DPS", Enable, ServiceStartMode.Automatic);
Service.EnableDisable("WdiServiceHost", Enable, ServiceStartMode.Manual);
Service.EnableDisable("WdiSystemHost", Enable, ServiceStartMode.Manual);
if (!Enable)
{
Service.EnableDisable("DiagTrack", Enable, ServiceStartMode.Automatic); // ALSO FOR TELEMETRY !!
Service.EnableDisable("dmwappushsvc", Enable, ServiceStartMode.Manual); // ALSO FOR TELEMETRY !!
Service.EnableDisable("diagnosticshub.standardcollector.service", Enable, ServiceStartMode.Manual); // ALSO FOR TELEMETRY !!
string key = @"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\AppCompat";
//RegEdit.SetValue(key, "DisableUAR", 1); // Steps Recorder
RegEdit.SetValue(key, "DisableInventory", 1); // Inventory Collector
Dir.DeleteDir(@"C:\ProgramData\Microsoft\Diagnosis\ETLLogs");
RegEdit.SetValue(
@"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\WMI\Autologger\AutoLogger-Diagtrack-Listener",
"Start", 0
); // ALSO FOR TELEMETRY ..
}
/**
* Always disable requests for feedback (diagnostic usage data).
*/
RegEdit.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Siuf\Rules", "NumberOfSIUFInPeriod", 0);
Service.EnableDisable("pla", Enable, ServiceStartMode.Manual);
}
}
}
| 37.517241 | 140 | 0.575061 | [
"MIT"
] | bvandevliet/WinFix | WinFix/Services/Diagnostic_Services.cs | 3,266 | C# |
using Blu4Net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reactive.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
namespace BluMiniPlayer
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
private string _playerName;
private IReadOnlyCollection<string> _mediaTitles;
private Uri _mediaImageUri;
private PlayerState _playerState;
private int _volume;
public BluPlayer Player { get; private set; }
public MainWindow()
{
InitializeComponent();
DataContext = this;
Loaded += MainWindow_Loaded;
}
public event PropertyChangedEventHandler PropertyChanged;
private bool SetPropertyValue<T>(ref T storage, T value, [CallerMemberName] string name = null)
{
if (!Equals(storage, value))
{
storage = value;
RaisePropertyChanged(name);
return true;
}
return false;
}
private void RaisePropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
var endpoint = await BluEnvironment.ResolveEndpoints().FirstOrDefaultAsync();
if (endpoint != null)
{
Player = await BluPlayer.Connect(endpoint);
PlayerName = Player.Name;
PlayerState = await Player.GetState();
Player.StateChanges.ObserveOnDispatcher().Subscribe(value => PlayerState = value);
Volume = await Player.GetVolume();
Player.VolumeChanges.ObserveOnDispatcher().Subscribe(value => Volume = value);
UpdateMedia(await Player.GetMedia());
Player.MediaChanges.ObserveOnDispatcher().Subscribe(UpdateMedia);
}
}
private void UpdateMedia(PlayerMedia media)
{
_mediaTitles = media.Titles;
RaisePropertyChanged(nameof(MediaTitle1));
RaisePropertyChanged(nameof(MediaTitle2));
RaisePropertyChanged(nameof(MediaTitle3));
MediaImageUri = media.ImageUri;
}
public string PlayerName
{
get { return _playerName; }
set { SetPropertyValue(ref _playerName, value); }
}
public string MediaTitle1
{
get { return _mediaTitles?.Skip(0).FirstOrDefault(); }
}
public string MediaTitle2
{
get { return _mediaTitles?.Skip(1).FirstOrDefault(); }
}
public string MediaTitle3
{
get { return _mediaTitles?.Skip(2).FirstOrDefault(); }
}
public Uri MediaImageUri
{
get { return _mediaImageUri; }
set { SetPropertyValue(ref _mediaImageUri, value); }
}
public int Volume
{
get { return _volume; }
set { SetPropertyValue(ref _volume, value); }
}
public PlayerState PlayerState
{
get { return _playerState; }
set
{
if (SetPropertyValue(ref _playerState, value))
{
PauseButton.Visibility = PlayerState == PlayerState.Paused ? Visibility.Collapsed : Visibility.Visible;
PlayButton.Visibility = PlayerState == PlayerState.Paused ? Visibility.Visible : Visibility.Collapsed;
}
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
private async void Preset_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (sender is FrameworkElement element && int.TryParse((string)element.Tag, out var preset))
{
await Player.PresetList.LoadPreset(preset);
}
}
private async void Action_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (sender is FrameworkElement element)
{
switch(element.Tag)
{
case "Back":
await Player.Back();
break;
case "Play":
await Player.Play();
break;
case "Pause":
await Player.Pause();
break;
case "Skip":
await Player.Skip();
break;
}
}
}
private async void ChangeVolume_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (sender is FrameworkElement element)
{
var volume = await Player.GetVolume();
switch (element.Tag)
{
case "Up":
await Player.SetVolume(volume + 1);
break;
case "Down":
await Player.SetVolume(volume - 1);
break;
}
}
}
private void Caption_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
{
DragMove();
}
}
}
}
| 30.552632 | 123 | 0.532127 | [
"MIT"
] | roblans/Blu4Net | samples/BluMiniPlayer/MainWindow.xaml.cs | 5,807 | C# |
using GraphQL.Conventions.Tests.Templates;
using GraphQL.Conventions.Tests.Templates.Extensions;
using GraphQL.Conventions.Types.Resolution;
using GraphQL.Types;
using Extended = GraphQL.Conventions.Adapters.Types;
namespace GraphQL.Conventions.Tests.Adapters
{
public class FieldDerivationTests : ConstructionTestBase
{
[Test]
public void Can_Derive_Output_Type_With_No_Fields()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<OutputTypeWithNoFields>()) as IObjectGraphType;
type.ShouldHaveFields(0);
}
[Test]
public void Can_Derive_Input_Type_With_No_Fields()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<InputTypeWithNoFields>()) as InputObjectGraphType;
type.ShouldHaveFields(0);
}
[Test]
public void Can_Derive_Output_Type_With_Fields()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<OutputTypeWithFields>()) as IObjectGraphType;
type.ShouldHaveFields(2);
}
[Test]
public void Can_Derive_Input_Type_With_Fields()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<InputTypeWithFields>()) as InputObjectGraphType;
type.ShouldHaveFields(2);
}
[Test]
public void Can_Hide_Ignored_Field()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
type.ShouldNotHaveFieldWithName("ignoredField");
}
[Test]
public void Can_Derive_Normal_Field()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
var field = type.ShouldHaveFieldWithName("normalField");
field.Arguments.Count.ShouldEqual(0);
}
[Test]
public void Can_Derive_Field_With_Overridden_Name()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
type.ShouldHaveFieldWithName("overriddenField");
}
[Test]
public void Can_Derive_Field_With_Description()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
var field = type.ShouldHaveFieldWithName("fieldWithDescription");
field.Description.ShouldEqual("Some Description");
}
[Test]
public void Can_Derive_Field_With_Deprecation_Reason()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
var field = type.ShouldHaveFieldWithName("fieldWithDeprecationReason");
field.DeprecationReason.ShouldEqual("Some Deprecation Reason");
}
[Test]
public void Can_Derive_Field_Type_When_Unwrapped()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
var field = type.ShouldHaveFieldWithName("stringField");
field.Type.ShouldEqual(typeof(StringGraphType));
}
[Test]
public void Can_Derive_Field_Type_When_Wrapped()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
var field = type.ShouldHaveFieldWithName("nonNullStringField");
field.Type.ShouldEqual(typeof(NonNullGraphType<StringGraphType>));
}
[Test]
public void Can_Derive_Field_With_Arguments()
{
var typeResolver = new TypeResolver();
var type = Type(typeResolver.DeriveType<Fields>()) as IObjectGraphType;
var field = type.ShouldHaveFieldWithName("fieldWithArguments");
field.Type.ShouldEqual(typeof(NonNullGraphType<IntGraphType>));
field.Arguments.Count.ShouldEqual(2);
field.ShouldHaveArgument("a");
field.ShouldHaveArgument("b");
}
[Test]
public void Can_Override_Fields_In_Derived_Types()
{
var type = OutputType<Foo>();
type.Name.ShouldEqual("Fooz");
type.Description.ShouldEqual("Foo bar baz");
type.ShouldHaveFields(3);
type.ShouldHaveFieldWithName("id").OfType<NonNullGraphType<Extended.IdGraphType>>();
type.ShouldHaveFieldWithName("a").OfType<IntGraphType>();
type.ShouldHaveFieldWithName("b").OfType<NonNullGraphType<IntGraphType>>();
}
class OutputTypeWithNoFields
{
}
[InputType]
class InputTypeWithNoFields
{
}
class OutputTypeWithFields
{
public int Field1 => 1;
public int Field2 => 2;
}
[InputType]
class InputTypeWithFields
{
public int Field1 { get; set; }
public int Field2 { get; set; }
}
class Fields
{
public int NormalField => 0;
[Name("overriddenField")]
public int FieldWithOverriddenName => 0;
[Description("Some Description")]
public int FieldWithDescription => 0;
[Deprecated("Some Deprecation Reason")]
public int FieldWithDeprecationReason => 0;
[Ignore]
public int IgnoredField => 0;
public string StringField => string.Empty;
public NonNull<string> NonNullStringField => string.Empty;
public int FieldWithArguments(int a, int b) => a + b;
}
[Name("Fooz")]
class FooDto
{
public string Id => "A";
public int? A => 0;
public int B => 1;
public string C => "Ignore";
}
[Description("Foo bar baz")]
class Foo : FooDto
{
public new Id Id => base.Id;
[Ignore]
public new string C => string.Empty;
}
}
} | 32.477157 | 102 | 0.597687 | [
"MIT"
] | rodolfotorres/conventions | test/Tests/Adapters/FieldDerivationTests.cs | 6,398 | C# |
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
using System;
namespace Esfa.Recruit.Employer.UnitTests.Employer.Web.HardMocks
{
internal class VacancyOrchestratorTestData
{
internal static Vacancy GetPart1CompleteVacancy()
{
return new Vacancy
{
EmployerAccountId = "EMPLOYER ACCOUNT ID",
Id = Guid.Parse("84af954e-5baf-4942-897d-d00180a0839e"),
Title = "has a value",
EmployerLocation = new Address { Postcode = "has a value" },
ShortDescription = "has a value",
ProgrammeId = "has a value",
Wage = new Wage { WageType = WageType.FixedWage }
};
}
internal static VacancyUser GetVacancyUser()
{
return new VacancyUser
{
Email = "scotty@scotty.com",
Name = "scott",
UserId = "scott"
};
}
}
}
| 30.060606 | 76 | 0.53125 | [
"MIT"
] | bjstone82/das-recruit | src/Employer/UnitTests/Employer.Web/HardMocks/VacancyOrchestratorTestData.cs | 994 | C# |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.