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 |
|---|---|---|---|---|---|---|---|---|
namespace Essensoft.AspNetCore.Payment.Alipay.Response
{
/// <summary>
/// AlipayOpenAppMembersCreateResponse.
/// </summary>
public class AlipayOpenAppMembersCreateResponse : AlipayResponse
{
}
}
| 22.2 | 68 | 0.702703 | [
"MIT"
] | LuohuaRain/payment | src/Essensoft.AspNetCore.Payment.Alipay/Response/AlipayOpenAppMembersCreateResponse.cs | 224 | C# |
namespace EntityFramework.UI
{
public abstract class DbContextUI<TDbContext>
where TDbContext : Microsoft.EntityFrameworkCore.DbContext
{
protected internal abstract void OnModelCreating(ModelBuilder<TDbContext> modelBuilder);
}
}
| 26.555556 | 90 | 0.820084 | [
"MIT"
] | mirsaeedi/EntityFramework.UI | EntityFranework.UI.Metadata/DbContextUI.cs | 241 | C# |
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Threading;
using TemperatureReader.ClientApp.Helpers;
using TemperatureReader.ClientApp.Messages;
using TemperatureReader.ClientApp.ViewModels;
namespace TemperatureReader.ClientApp
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
SimpleIoc.Default.Register<IMessageDisplayer, Toaster>();
SimpleIoc.Default.Register<IErrorLogger, ErrorLogger>();
InitializeComponent();
Suspending += OnSuspending;
UnhandledException += SimpleIoc.Default.GetInstance<IErrorLogger>().LogUnhandledException;
UnhandledException += App_UnhandledException;
Resuming += App_Resuming;
}
private void App_Resuming(object sender, object e)
{
Messenger.Default.Send(new ResumeMessage());
}
private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
SimpleIoc.Default.GetInstance<IMessageDisplayer>().ShowMessage ($"Crashed: {e.Message}");
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
DispatcherHelper.Initialize();
MainViewModel.Instance.Init();
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
//this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
await MainViewModel.Instance.OnSuspend();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}
| 34.718519 | 96 | 0.705782 | [
"MIT"
] | LocalJoost/TemperatureReaderDemo | TemperatureReader.ClientApp/App.xaml.cs | 4,689 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HymnalEntities.Hymnal
{
public class Tag : Entity
{
public string TagName { get; set; }
//TODO: Attributes?
}
}
| 17.866667 | 43 | 0.682836 | [
"MIT"
] | ddelamare/MobileHymnal | HymnalEntities/Hymnal/Tag.cs | 270 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace corsairs.core.worldgen
{
public class DiamondSquareAlgorihm
{
public ArrayMap<int> Square
{
get;
set;
}
public Func<int, int> HeightRandomiser { get; set; }
public void DiamondStep()
{
// loops over the square, starting 1 square in and finishing 1 square before the edge, skipping 2
// each time. This ensures it will target the center of new squares made by the subdivision process
for (var w = 1; w <= Square.Size - 2; w += 2)
{
for (var h = 1; h <= Square.Size - 2; h += 2)
{
var averagedHeight = (
Square[h - 1, w - 1] +
Square[h - 1, w + 1] +
Square[h + 1, w - 1] +
Square[h + 1, w + 1]
) / 4;
var randomised = HeightRandomiser(averagedHeight);
Square[h, w] = randomised;
}
}
}
public void SquareStep()
{
// loops over the structure, filling in the gaps using the information provided by the
// diamond step. Swaps over starting at index 1 and 0
for (var h = 0; h < Square.Size; h++)
{
// jump over alternate squares, e.g.
// with square x-x
// -x-
// x-x
// follow this sequence:
// 1 xox
// -x-
// x-x
//
// 2 x-x
// ox-
// x-x
//
// 3 x-x
// -xo
// x-x
// and so on...
for (var w = h % 2 == 1 ? 0 : 1; w < Square.Size; w += 2)
{
var coordsAround = Square.SquareCoords(h, w);
var countOfValid = coordsAround.Count;
var sum = 0;
foreach (var coordToSum in coordsAround)
{
sum += Square[coordToSum[0], coordToSum[1]];
}
var averagedHeight = sum / countOfValid;
var randomised = HeightRandomiser(averagedHeight);
Square[h, w] = randomised;
}
}
}
}
}
| 33.902439 | 112 | 0.379496 | [
"Apache-2.0"
] | danrose/corsairs | corsairs.core/worldgen/DiamondSquareAlgorithm.cs | 2,782 | C# |
using System;
using System.Xml.Serialization;
using System.ComponentModel.DataAnnotations;
using BroadWorksConnector.Ocip.Validation;
using System.Collections.Generic;
namespace BroadWorksConnector.Ocip.Models
{
/// <summary>
///
/// </summary>
[Serializable]
[XmlRoot(Namespace = "")]
[Groups(@"[{""__type"":""Sequence:#BroadWorksConnector.Ocip.Validation"",""id"":""ab0042aa512abc10edb3c55e4b416b0b:35309""}]")]
public class SystemVoiceMessagingGroupGetVoicePortalMenusResponse20ChangeBusyOrNoAnswerGreetingMenuKeys
{
private string _recordNewGreeting;
[XmlElement(ElementName = "recordNewGreeting", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"ab0042aa512abc10edb3c55e4b416b0b:35309")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string RecordNewGreeting
{
get => _recordNewGreeting;
set
{
RecordNewGreetingSpecified = true;
_recordNewGreeting = value;
}
}
[XmlIgnore]
protected bool RecordNewGreetingSpecified { get; set; }
private string _listenToCurrentGreeting;
[XmlElement(ElementName = "listenToCurrentGreeting", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"ab0042aa512abc10edb3c55e4b416b0b:35309")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string ListenToCurrentGreeting
{
get => _listenToCurrentGreeting;
set
{
ListenToCurrentGreetingSpecified = true;
_listenToCurrentGreeting = value;
}
}
[XmlIgnore]
protected bool ListenToCurrentGreetingSpecified { get; set; }
private string _revertToSystemDefaultGreeting;
[XmlElement(ElementName = "revertToSystemDefaultGreeting", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"ab0042aa512abc10edb3c55e4b416b0b:35309")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string RevertToSystemDefaultGreeting
{
get => _revertToSystemDefaultGreeting;
set
{
RevertToSystemDefaultGreetingSpecified = true;
_revertToSystemDefaultGreeting = value;
}
}
[XmlIgnore]
protected bool RevertToSystemDefaultGreetingSpecified { get; set; }
private string _returnToPreviousMenu;
[XmlElement(ElementName = "returnToPreviousMenu", IsNullable = false, Namespace = "")]
[Group(@"ab0042aa512abc10edb3c55e4b416b0b:35309")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string ReturnToPreviousMenu
{
get => _returnToPreviousMenu;
set
{
ReturnToPreviousMenuSpecified = true;
_returnToPreviousMenu = value;
}
}
[XmlIgnore]
protected bool ReturnToPreviousMenuSpecified { get; set; }
private string _repeatMenu;
[XmlElement(ElementName = "repeatMenu", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"ab0042aa512abc10edb3c55e4b416b0b:35309")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string RepeatMenu
{
get => _repeatMenu;
set
{
RepeatMenuSpecified = true;
_repeatMenu = value;
}
}
[XmlIgnore]
protected bool RepeatMenuSpecified { get; set; }
}
}
| 30.4 | 131 | 0.590186 | [
"MIT"
] | JTOne123/broadworks-connector-net | BroadworksConnector/Ocip/Models/SystemVoiceMessagingGroupGetVoicePortalMenusResponse20ChangeBusyOrNoAnswerGreetingMenuKeys.cs | 3,648 | C# |
using Microsoft.Extensions.Logging;
using SFA.DAS.RoatpGateway.Domain;
using SFA.DAS.RoatpGateway.Web.Extensions;
using SFA.DAS.RoatpGateway.Web.Infrastructure.ApiClients;
using SFA.DAS.RoatpGateway.Web.ViewModels;
using System.Linq;
using System.Threading.Tasks;
namespace SFA.DAS.RoatpGateway.Web.Services
{
public class GatewayRegisterChecksOrchestrator : IGatewayRegisterChecksOrchestrator
{
private readonly IRoatpApplicationApiClient _applyApiClient;
private readonly IRoatpRegisterApiClient _roatpApiClient;
private readonly ILogger<GatewayRegisterChecksOrchestrator> _logger;
public GatewayRegisterChecksOrchestrator(IRoatpApplicationApiClient applyApiClient, IRoatpRegisterApiClient roatpApiClient,
ILogger<GatewayRegisterChecksOrchestrator> logger)
{
_applyApiClient = applyApiClient;
_roatpApiClient = roatpApiClient;
_logger = logger;
}
public async Task<RoatpPageViewModel> GetRoatpViewModel(GetRoatpRequest request)
{
var pageId = GatewayPageIds.Roatp;
_logger.LogInformation($"Retrieving RoATP details for application {request.ApplicationId}");
var model = new RoatpPageViewModel();
await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.RegisterChecks,
pageId,
request.UserId,
request.UserName,
RoatpGatewayConstants.Captions.RegisterChecks,
RoatpGatewayConstants.Headings.Roatp,
NoSelectionErrorMessages.Errors[GatewayPageIds.Roatp]);
model.ApplyProviderRoute = await _applyApiClient.GetProviderRouteName(model.ApplicationId);
var roatpProviderDetails = await _roatpApiClient.GetOrganisationRegisterStatus(model.Ukprn);
if (roatpProviderDetails != null)
{
model.RoatpUkprnOnRegister = roatpProviderDetails.UkprnOnRegister;
model.RoatpStatusDate = roatpProviderDetails.StatusDate;
model.RoatpProviderRoute = await GetProviderRoute(roatpProviderDetails.ProviderTypeId);
model.RoatpStatus = await GetProviderStatus(roatpProviderDetails.StatusId, roatpProviderDetails.ProviderTypeId);
model.RoatpRemovedReason = await GetRemovedReason(roatpProviderDetails.RemovedReasonId);
}
return model;
}
public async Task<RoepaoPageViewModel> GetRoepaoViewModel(GetRoepaoRequest request)
{
var pageId = GatewayPageIds.Roepao;
_logger.LogInformation($"Retrieving RoEPAO details for application {request.ApplicationId}");
var model = new RoepaoPageViewModel();
await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.RegisterChecks,
pageId,
request.UserId,
request.UserName,
RoatpGatewayConstants.Captions.RegisterChecks,
RoatpGatewayConstants.Headings.Roepao,
NoSelectionErrorMessages.Errors[GatewayPageIds.Roepao]);
return model;
}
private async Task<string> GetProviderRoute(int? providerTypeId)
{
string route = null;
if (providerTypeId.HasValue)
{
var roatpTypes = await _roatpApiClient.GetProviderTypes();
route = roatpTypes?.FirstOrDefault(t => t.Id == providerTypeId.Value)?.Type;
}
return route;
}
private async Task<string> GetProviderStatus(int? providerStatusId, int? providerTypeId)
{
string status = null;
if (providerStatusId.HasValue)
{
var roatpStatuses = await _roatpApiClient.GetOrganisationStatuses(providerTypeId);
status = roatpStatuses?.FirstOrDefault(s => s.Id == providerStatusId.Value)?.Status;
}
return status;
}
private async Task<string> GetRemovedReason(int? providerRemovedReasonId)
{
string reason = null;
if (providerRemovedReasonId.HasValue)
{
var roatpRemovedReasons = await _roatpApiClient.GetRemovedReasons();
reason = roatpRemovedReasons?.FirstOrDefault(rm => rm.Id == providerRemovedReasonId.Value)?.Reason;
}
return reason;
}
}
}
| 43.486957 | 131 | 0.59968 | [
"MIT"
] | SkillsFundingAgency/das-roatp-gateway | src/SFA.DAS.RoatpGateway.Web/Services/GatewayRegisterChecksOrchestrator.cs | 5,003 | C# |
//#define REREAD_STATE_AFTER_WRITE_FAILED
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
using Orleans.TestingHost;
using TestExtensions;
using Orleans.Hosting;
using Orleans.Configuration;
// ReSharper disable RedundantAssignment
// ReSharper disable UnusedVariable
// ReSharper disable InconsistentNaming
namespace Tester.AzureUtils.Persistence
{
/// <summary>
/// PersistenceStateTests using AzureStore - Requires access to external Azure blob storage
/// </summary>
[TestCategory("Persistence"), TestCategory("Azure")]
public class PersistenceStateTests_AzureBlobStore : Base_PersistenceGrainTests_AzureStore, IClassFixture<PersistenceStateTests_AzureBlobStore.Fixture>
{
public class Fixture : BaseAzureTestClusterFixture
{
protected override void ConfigureTestCluster(TestClusterBuilder builder)
{
builder.Options.InitialSilosCount = 4;
builder.Options.UseTestClusterMembership = false;
builder.AddSiloBuilderConfigurator<SiloBuilderConfigurator>();
builder.AddSiloBuilderConfigurator<StorageSiloBuilderConfigurator>();
builder.AddClientBuilderConfigurator<ClientBuilderConfigurator>();
}
private class StorageSiloBuilderConfigurator : ISiloConfigurator
{
public void Configure(ISiloBuilder hostBuilder)
{
hostBuilder.AddAzureBlobGrainStorage("GrainStorageForTest", (AzureBlobStorageOptions options) =>
{
options.ConnectionString = TestDefaultConfiguration.DataConnectionString;
});
}
}
}
public PersistenceStateTests_AzureBlobStore(ITestOutputHelper output, Fixture fixture) : base(output, fixture, "UnitTests.PersistentState.Grains")
{
fixture.EnsurePreconditionsMet();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_AzureBlobStore_Delete()
{
await base.Grain_AzureStore_Delete();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_AzureBlobStore_Read()
{
await base.Grain_AzureStore_Read();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_GuidKey_AzureBlobStore_Read_Write()
{
await base.Grain_GuidKey_AzureStore_Read_Write();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_LongKey_AzureBlobStore_Read_Write()
{
await base.Grain_LongKey_AzureStore_Read_Write();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_LongKeyExtended_AzureBlobStore_Read_Write()
{
await base.Grain_LongKeyExtended_AzureStore_Read_Write();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_GuidKeyExtended_AzureBlobStore_Read_Write()
{
await base.Grain_GuidKeyExtended_AzureStore_Read_Write();
}
[SkippableFact, TestCategory("Functional")]
public async Task Grain_AzureBlobStore_SiloRestart()
{
await base.Grain_AzureStore_SiloRestart();
}
}
}
// ReSharper restore RedundantAssignment
// ReSharper restore UnusedVariable
// ReSharper restore InconsistentNaming
| 35.591837 | 154 | 0.674599 | [
"MIT"
] | Abramalin/orleans | test/Extensions/TesterAzureUtils/Persistence/PersistenceStateTests_AzureBlobStore.cs | 3,488 | 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 System.Collections.Generic;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tracing;
namespace Tracing.Tests.Common
{
public class Logger
{
public static Logger logger = new Logger();
private TextWriter _log;
private Stopwatch _sw;
public Logger(TextWriter log = null)
{
_log = log ?? Console.Out;
_sw = new Stopwatch();
}
public void Log(string message)
{
if (!_sw.IsRunning)
_sw.Start();
_log.WriteLine($"{_sw.Elapsed.TotalSeconds,5:f1}s: {message}");
}
}
public class ExpectedEventCount
{
// The acceptable percent error on the expected value
// represented as a floating point value in [0,1].
public float Error { get; private set; }
// The expected count of events. A value of -1 indicates
// that count does not matter, and we are simply testing
// that the provider exists in the trace.
public int Count { get; private set; }
public ExpectedEventCount(int count, float error = 0.0f)
{
Count = count;
Error = error;
}
public bool Validate(int actualValue)
{
return Count == -1 || CheckErrorBounds(actualValue);
}
public bool CheckErrorBounds(int actualValue)
{
return Math.Abs(actualValue - Count) <= (Count * Error);
}
public static implicit operator ExpectedEventCount(int i)
{
return new ExpectedEventCount(i);
}
public override string ToString()
{
return $"{Count} +- {Count * Error}";
}
}
// This event source is used by the test infra to
// to insure that providers have finished being enabled
// for the session being observed. Since the client API
// returns the pipe for reading _before_ it finishes
// enabling the providers to write to that session,
// we need to guarantee that our providers are on before
// sending events. This is a _unique_ problem I imagine
// should _only_ affect scenarios like these tests
// where the reading and sending of events are required
// to synchronize.
public sealed class SentinelEventSource : EventSource
{
private SentinelEventSource() {}
public static SentinelEventSource Log = new SentinelEventSource();
public void SentinelEvent() { WriteEvent(1, "SentinelEvent"); }
}
public class IpcTraceTest
{
// This Action is executed while the trace is being collected.
private Action _eventGeneratingAction;
// A dictionary of event providers to number of events.
// A count of -1 indicates that you are only testing for the presence of the provider
// and don't care about the number of events sent
private Dictionary<string, ExpectedEventCount> _expectedEventCounts;
private Dictionary<string, int> _actualEventCounts = new Dictionary<string, int>();
// A function to be called with the EventPipeEventSource _before_
// the call to `source.Process()`. The function should return another
// function that will be called to check whether the optional test was validated.
// Example in situ: providervalidation.cs
private Func<EventPipeEventSource, Func<int>> _optionalTraceValidator;
/// <summary>
/// This is list of the EventPipe providers to turn on for the test execution
/// </summary>
private List<EventPipeProvider> _testProviders;
/// <summary>
/// This represents the current EventPipeSession
/// </summary>
private EventPipeSession _eventPipeSession;
/// <summary>
/// This is the list of EventPipe providers for the sentinel EventSource that indicates that the process is ready
/// </summary>
private List<EventPipeProvider> _sentinelProviders = new List<EventPipeProvider>()
{
new EventPipeProvider("SentinelEventSource", EventLevel.Verbose, -1)
};
IpcTraceTest(
Dictionary<string, ExpectedEventCount> expectedEventCounts,
Action eventGeneratingAction,
List<EventPipeProvider> providers,
int circularBufferMB,
Func<EventPipeEventSource, Func<int>> optionalTraceValidator = null)
{
_eventGeneratingAction = eventGeneratingAction;
_expectedEventCounts = expectedEventCounts;
_testProviders = providers;
_optionalTraceValidator = optionalTraceValidator;
}
private int Fail(string message = "")
{
Logger.logger.Log("Test FAILED!");
Logger.logger.Log(message);
Logger.logger.Log("Configuration:");
Logger.logger.Log("{");
Logger.logger.Log("\tproviders: [");
Logger.logger.Log("\t]");
Logger.logger.Log("}\n");
Logger.logger.Log("Expected:");
Logger.logger.Log("{");
foreach (var (k, v) in _expectedEventCounts)
{
Logger.logger.Log($"\t\"{k}\" = {v}");
}
Logger.logger.Log("}\n");
Logger.logger.Log("Actual:");
Logger.logger.Log("{");
foreach (var (k, v) in _actualEventCounts)
{
Logger.logger.Log($"\t\"{k}\" = {v}");
}
Logger.logger.Log("}");
return -1;
}
private int Validate()
{
// FIXME: This is a bandaid fix for a deadlock in EventPipeEventSource caused by
// the lazy caching in the Regex library. The caching creates a ConcurrentDictionary
// and because it is the first one in the process, it creates an EventSource which
// results in a deadlock over a lock in EventPipe. These lines should be removed once the
// underlying issue is fixed by forcing these events to try to be written _before_ we shutdown.
//
// see: https://github.com/dotnet/runtime/pull/1794 for details on the issue
//
var emptyConcurrentDictionary = new ConcurrentDictionary<string, string>();
emptyConcurrentDictionary["foo"] = "bar";
var __count = emptyConcurrentDictionary.Count;
var isClean = IpcTraceTest.EnsureCleanEnvironment();
if (!isClean)
return -1;
// CollectTracing returns before EventPipe::Enable has returned, so the
// the sources we want to listen for may not have been enabled yet.
// We'll use this sentinel EventSource to check if Enable has finished
ManualResetEvent sentinelEventReceived = new ManualResetEvent(false);
var sentinelTask = new Task(() =>
{
Logger.logger.Log("Started sending sentinel events...");
while (!sentinelEventReceived.WaitOne(50))
{
SentinelEventSource.Log.SentinelEvent();
}
Logger.logger.Log("Stopped sending sentinel events");
});
sentinelTask.Start();
int processId = Process.GetCurrentProcess().Id;
object threadSync = new object(); // for locking eventpipeSession access
Func<int> optionalTraceValidationCallback = null;
DiagnosticsClient client = new DiagnosticsClient(processId);
#if DIAGNOSTICS_RUNTIME
if (OperatingSystem.IsAndroid())
client = new DiagnosticsClient(new IpcEndpointConfig("127.0.0.1:9000", IpcEndpointConfig.TransportType.TcpSocket, IpcEndpointConfig.PortType.Listen));
#endif
var readerTask = new Task(() =>
{
Logger.logger.Log("Connecting to EventPipe...");
try
{
_eventPipeSession = client.StartEventPipeSession(_testProviders.Concat(_sentinelProviders));
}
catch (DiagnosticsClientException ex)
{
Logger.logger.Log("Failed to connect to EventPipe!");
Logger.logger.Log(ex.ToString());
throw new ApplicationException("Failed to connect to EventPipe");
}
using (var eventPipeStream = new StreamProxy(_eventPipeSession.EventStream))
{
Logger.logger.Log("Creating EventPipeEventSource...");
using (EventPipeEventSource source = new EventPipeEventSource(eventPipeStream))
{
Logger.logger.Log("EventPipeEventSource created");
source.Dynamic.All += (eventData) =>
{
try
{
if (eventData.ProviderName == "SentinelEventSource")
{
if (!sentinelEventReceived.WaitOne(0))
Logger.logger.Log("Saw sentinel event");
sentinelEventReceived.Set();
}
else if (_actualEventCounts.TryGetValue(eventData.ProviderName, out _))
{
_actualEventCounts[eventData.ProviderName]++;
}
else
{
Logger.logger.Log($"Saw new provider '{eventData.ProviderName}'");
_actualEventCounts[eventData.ProviderName] = 1;
}
}
catch (Exception e)
{
Logger.logger.Log("Exception in Dynamic.All callback " + e.ToString());
}
};
Logger.logger.Log("Dynamic.All callback registered");
if (_optionalTraceValidator != null)
{
Logger.logger.Log("Running optional trace validator");
optionalTraceValidationCallback = _optionalTraceValidator(source);
Logger.logger.Log("Finished running optional trace validator");
}
Logger.logger.Log("Starting stream processing...");
try
{
source.Process();
}
catch (Exception)
{
Logger.logger.Log($"Exception thrown while reading; dumping culprit stream to disk...");
eventPipeStream.DumpStreamToDisk();
// rethrow it to fail the test
throw;
}
Logger.logger.Log("Stopping stream processing");
Logger.logger.Log($"Dropped {source.EventsLost} events");
}
}
});
var waitSentinelEventTask = new Task(() => {
sentinelEventReceived.WaitOne();
});
readerTask.Start();
waitSentinelEventTask.Start();
// Will throw if the reader task throws any exceptions before signaling sentinelEventReceived.
Task.WaitAny(readerTask, waitSentinelEventTask);
Logger.logger.Log("Starting event generating action...");
_eventGeneratingAction();
Logger.logger.Log("Stopping event generating action");
var stopTask = Task.Run(() =>
{
Logger.logger.Log("Sending StopTracing command...");
lock (threadSync) // eventpipeSession
{
_eventPipeSession.Stop();
}
Logger.logger.Log("Finished StopTracing command");
});
// Should throw if the reader task throws any exceptions
Task.WaitAll(readerTask, stopTask);
Logger.logger.Log("Reader task finished");
foreach (var (provider, expectedCount) in _expectedEventCounts)
{
if (_actualEventCounts.TryGetValue(provider, out var actualCount))
{
if (!expectedCount.Validate(actualCount))
{
return Fail($"Event count mismatch for provider \"{provider}\": expected {expectedCount}, but saw {actualCount}");
}
}
else
{
return Fail($"No events for provider \"{provider}\"");
}
}
if (optionalTraceValidationCallback != null)
{
Logger.logger.Log("Validating optional callback...");
// reader thread should be dead now, no need to lock
return optionalTraceValidationCallback();
}
else
{
return 100;
}
}
// Ensure that we have a clean environment for running the test.
// Specifically check that we don't have more than one match for
// Diagnostic IPC sockets in the TempPath. These can be left behind
// by bugs, catastrophic test failures, etc. from previous testing.
// The tmp directory is only cleared on reboot, so it is possible to
// run into these zombie pipes if there are failures over time.
// Note: Windows has some guarantees about named pipes not living longer
// the process that created them, so we don't need to check on that platform.
static public bool EnsureCleanEnvironment()
{
if (!OperatingSystem.IsWindows())
{
Func<(IEnumerable<IGrouping<int,FileInfo>>, List<int>)> getPidsAndSockets = () =>
{
IEnumerable<IGrouping<int,FileInfo>> currentIpcs = Directory.GetFiles(Path.GetTempPath(), "dotnet-diagnostic*")
.Select(filename => new { pid = int.Parse(Regex.Match(filename, @"dotnet-diagnostic-(?<pid>\d+)").Groups["pid"].Value), fileInfo = new FileInfo(filename) })
.GroupBy(fileInfos => fileInfos.pid, fileInfos => fileInfos.fileInfo);
List<int> currentPids = System.Diagnostics.Process.GetProcesses().Select(pid => pid.Id).ToList();
return (currentIpcs, currentPids);
};
var (currentIpcs, currentPids) = getPidsAndSockets();
foreach (var ipc in currentIpcs)
{
if (!currentPids.Contains(ipc.Key))
{
foreach (FileInfo fi in ipc)
{
Logger.logger.Log($"Attempting to delete the zombied pipe: {fi.FullName}");
fi.Delete();
Logger.logger.Log($"Deleted");
}
}
else
{
if (ipc.Count() > 1)
{
// delete zombied pipes except newest which is owned
var duplicates = ipc.OrderBy(fileInfo => fileInfo.CreationTime.Ticks).SkipLast(1);
foreach (FileInfo fi in duplicates)
{
Logger.logger.Log($"Attempting to delete the zombied pipe: {fi.FullName}");
fi.Delete();
}
}
}
}
}
return true;
}
public static int RunAndValidateEventCounts(
Dictionary<string, ExpectedEventCount> expectedEventCounts,
Action eventGeneratingAction,
List<EventPipeProvider> providers,
int circularBufferMB=1024,
Func<EventPipeEventSource, Func<int>> optionalTraceValidator = null)
{
Logger.logger.Log("==TEST STARTING==");
var test = new IpcTraceTest(expectedEventCounts, eventGeneratingAction, providers, circularBufferMB, optionalTraceValidator);
try
{
var ret = test.Validate();
if (ret == 100)
Logger.logger.Log("==TEST FINISHED: PASSED!==");
else
Logger.logger.Log("==TEST FINISHED: FAILED!==");
return ret;
}
catch (Exception e)
{
Logger.logger.Log(e.ToString());
Logger.logger.Log("==TEST FINISHED: FAILED!==");
return -1;
}
}
}
}
| 42.2494 | 180 | 0.537235 | [
"MIT"
] | AUTOMATE-2001/runtime | src/tests/tracing/eventpipe/common/IpcTraceTest.cs | 17,618 | C# |
namespace FakeItEasy.Specs
{
using System;
using FakeItEasy.Tests.TestHelpers;
using FluentAssertions;
using Xbehave;
using Xunit;
public static class AnyCallConfigurationSpecs
{
public interface IFoo
{
T Bar<T>() where T : class;
void Baz();
}
[Scenario]
public static void WithNonVoidReturnType(IFoo fake)
{
"Given a fake with a generic method"
.x(() => fake = A.Fake<IFoo>());
"When the fake's generic method is configured to return null for any non-void return type"
.x(() => A.CallTo(fake).Where(call => call.Method.Name == "Bar").WithNonVoidReturnType().Returns(null));
"Then the configured method returns null when called with generic argument String"
.x(() => fake.Bar<string>().Should().BeNull());
"And the configured method returns null when called with generic argument IFoo"
.x(() => fake.Bar<IFoo>().Should().BeNull());
}
[Scenario]
public static void WithNonVoidReturnTypeAndVoidMethod(
IFoo fake,
bool methodWasIntercepted)
{
"Given a fake with a void method"
.x(() => fake = A.Fake<IFoo>());
"And the fake is configured to set a flag for any non-void return type"
.x(() => A.CallTo(fake).WithNonVoidReturnType().Invokes(() => methodWasIntercepted = true));
"When the void method is called"
.x(() => fake.Baz());
"Then the flag is not set"
.x(() => methodWasIntercepted.Should().BeFalse());
}
[Scenario]
public static void WithNonVoidReturnTypeDescription(
IFoo fake,
Exception exception)
{
"Given a fake"
.x(() => fake = A.Fake<IFoo>());
"When an assertion is made that a non-void method was called"
.x(() => exception = Record.Exception(() => A.CallTo(fake).WithNonVoidReturnType().MustHaveHappened()));
"Then an exception is thrown"
.x(() => exception.Should().BeAnExceptionOfType<ExpectationException>()
.WithMessage("*Any call with non-void return type to the fake object.*"));
}
[Scenario]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = nameof(IFoo), Justification = "It's an identifier")]
public static void WithReturnType(
IFoo fake,
string returnValue)
{
"Given a fake with a generic method"
.x(() => fake = A.Fake<IFoo>());
"When the fake's generic method is configured to return a specific value for a given return type"
.x(() => A.CallTo(fake).Where(call => call.Method.Name == "Bar").WithReturnType<string>().Returns(returnValue = "hello world"));
"Then the configured method returns the specified value when called with generic argument String"
.x(() => fake.Bar<string>().Should().Be(returnValue));
"And the configured method returns a dummy when called with generic argument IFoo"
.x(() => fake.Bar<IFoo>().Should().NotBeNull().And.BeAssignableTo<IFoo>());
}
[Scenario]
public static void WithReturnTypeDescription(
IFoo fake,
Exception exception)
{
"Given a fake"
.x(() => fake = A.Fake<IFoo>());
"When an assertion is made that a method with a particular return type was called"
.x(() => exception = Record.Exception(() => A.CallTo(fake).WithReturnType<Guid>().MustHaveHappened()));
"Then an exception is thrown"
.x(() => exception.Should().BeAnExceptionOfType<ExpectationException>()
.WithMessage("*Any call with return type System.Guid to the fake object.*"));
}
[Scenario]
public static void AnyCallDescription(
IFoo fake,
Exception exception)
{
"Given a fake"
.x(() => fake = A.Fake<IFoo>());
"When an assertion is made that any method was called"
.x(() => exception = Record.Exception(() => A.CallTo(fake).MustHaveHappened()));
"Then an exception is thrown"
.x(() => exception.Should().BeAnExceptionOfType<ExpectationException>()
.WithMessage("*Any call made to the fake object.*"));
}
}
}
| 39.9 | 189 | 0.548037 | [
"MIT"
] | DynamicsValue/365saturday | FakeItEasy-3.2.0-patch/tests/FakeItEasy.Specs/AnyCallConfigurationSpecs.cs | 4,790 | C# |
//
// Encog(tm) Core v3.1 - .Net Version
// http://www.heatonresearch.com/encog/
//
// Copyright 2008-2012 Heaton Research, 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.
//
// For more information on Heaton Research copyrights, licenses
// and trademarks visit:
// http://www.heatonresearch.com/copyright
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Encog.Engine.Network.Activation;
using Encog.ML;
using Encog.ML.Train;
using Encog.ML.Data;
namespace Encog.Plugin
{
public interface IEncogPluginService1 : EncogPluginBase
{
/// <summary>
/// Create an activation function.
/// </summary>
/// <param name="name">The name of the activation function.</param>
/// <returns>The newly created activation function.</returns>
IActivationFunction CreateActivationFunction(String name);
/// <summary>
/// Create a new machine learning method.
/// </summary>
/// <param name="methodType">The method to create.</param>
/// <param name="architecture">The architecture string.</param>
/// <param name="input">The input count.</param>
/// <param name="output">The output count.</param>
/// <returns>The newly created machine learning method.</returns>
IMLMethod CreateMethod(String methodType,
String architecture,
int input, int output);
/// <summary>
/// Create a trainer.
/// </summary>
/// <param name="method">The method to train.</param>
/// <param name="training">The training data.</param>
/// <param name="type">Type type of trainer.</param>
/// <param name="args">The training args.</param>
/// <returns>The new training method.</returns>
IMLTrain CreateTraining(IMLMethod method,
IMLDataSet training,
String type, String args);
}
}
| 35.571429 | 75 | 0.646988 | [
"BSD-3-Clause"
] | mpcoombes/MaterialPredictor | encog-core-cs/Plugin/IEncogPluginService1.cs | 2,490 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace HallOfBeorn.Models.LotR.ProductGroups
{
public class AngmarAwakenedProductGroup : ProductGroup
{
public AngmarAwakenedProductGroup()
: base("Angmar Awakened Cycle")
{
AddMainProduct(Product.TheLostRealm);
AddChildProduct(Product.TheWastesOfEriador);
AddChildProduct(Product.EscapeFromMountGram);
AddChildProduct(Product.AcrossTheEttenmoors);
AddChildProduct(Product.TheTreacheryOfRhudaur);
AddChildProduct(Product.TheBattleOfCarnDum);
AddChildProduct(Product.TheDreadRealm);
}
}
} | 33.181818 | 60 | 0.669863 | [
"MIT"
] | danpoage/hall-of-beorn | src/HallOfBeorn/Models/LotR/ProductGroups/AngmarAwakenedProductGroup.cs | 732 | C# |
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Buffers;
using System.Buffers.Reader;
using System.Buffers.Text;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Http.Parser.Internal;
namespace System.Text.Http.Parser
{
public class HttpParser : IHttpParser
{
// TODO: commented out;
//public ILogger Log { get; set; }
// byte types don't have a data type annotation so we pre-cast them; to avoid in-place casts
private const byte ByteCR = (byte)'\r';
private const byte ByteLF = (byte)'\n';
private const byte ByteColon = (byte)':';
private const byte ByteSpace = (byte)' ';
private const byte ByteTab = (byte)'\t';
private const byte ByteQuestionMark = (byte)'?';
private const byte BytePercentage = (byte)'%';
private const long maxRequestLineLength = 1024;
static readonly byte[] s_Eol = Encoding.UTF8.GetBytes("\r\n");
static readonly byte[] s_http11 = Encoding.UTF8.GetBytes("HTTP/1.1");
static readonly byte[] s_http10 = Encoding.UTF8.GetBytes("HTTP/1.0");
static readonly byte[] s_http20 = Encoding.UTF8.GetBytes("HTTP/2.0");
private readonly bool _showErrorDetails;
public HttpParser()
: this(showErrorDetails: true)
{
}
public HttpParser(bool showErrorDetails)
{
_showErrorDetails = showErrorDetails;
}
public unsafe bool ParseRequestLine<T>(T handler, in ReadOnlySequence<byte> buffer, out SequencePosition consumed, out SequencePosition examined) where T : IHttpRequestLineHandler
{
consumed = buffer.Start;
examined = buffer.End;
// Prepare the first span
var span = buffer.First.Span;
var lineIndex = span.IndexOf(ByteLF);
if (lineIndex >= 0)
{
consumed = buffer.GetPosition(lineIndex + 1, consumed);
span = span.Slice(0, lineIndex + 1);
}
else if (buffer.IsSingleSegment)
{
return false;
}
else
{
if (TryGetNewLineSpan(buffer, out SequencePosition found))
{
span = PipelineExtensions.ToSpan(buffer.Slice(consumed, found));
consumed = found;
}
else
{
// No request line end
return false;
}
}
// Fix and parse the span
fixed (byte* data = &MemoryMarshal.GetReference(span))
{
ParseRequestLine(ref handler, data, span.Length);
}
examined = consumed;
return true;
}
public unsafe bool ParseRequestLine<T>(ref T handler, in ReadOnlySequence<byte> buffer, out int consumed) where T : IHttpRequestLineHandler
{
// Prepare the first span
var span = buffer.First.Span;
var lineIndex = span.IndexOf(ByteLF);
if (lineIndex >= 0)
{
consumed = lineIndex + 1;
span = span.Slice(0, lineIndex + 1);
}
else
{
var eol = Sequence.IndexOf(buffer, s_Eol[0], s_Eol[1]);
if (eol == -1)
{
consumed = 0;
return false;
}
span = PipelineExtensions.ToSpan(buffer.Slice(0, eol + s_Eol.Length));
}
// Fix and parse the span
fixed (byte* data = &MemoryMarshal.GetReference(span))
{
ParseRequestLine(ref handler, data, span.Length);
}
consumed = span.Length;
return true;
}
private unsafe void ParseRequestLine<T>(ref T handler, byte* data, int length) where T : IHttpRequestLineHandler
{
// Get Method and set the offset
var method = HttpUtilities.GetKnownMethod(data, length, out var offset);
ReadOnlySpan<byte> customMethod =
method == Http.Method.Custom ?
GetUnknownMethod(data, length, out offset) :
default;
// Skip space
offset++;
byte ch = 0;
// Target = Path and Query
var pathEncoded = false;
var pathStart = -1;
for (; offset < length; offset++)
{
ch = data[offset];
if (ch == ByteSpace)
{
if (pathStart == -1)
{
// Empty path is illegal
RejectRequestLine(data, length);
}
break;
}
else if (ch == ByteQuestionMark)
{
if (pathStart == -1)
{
// Empty path is illegal
RejectRequestLine(data, length);
}
break;
}
else if (ch == BytePercentage)
{
if (pathStart == -1)
{
// Path starting with % is illegal
RejectRequestLine(data, length);
}
pathEncoded = true;
}
else if (pathStart == -1)
{
pathStart = offset;
}
}
if (pathStart == -1)
{
// Start of path not found
RejectRequestLine(data, length);
}
var pathBuffer = new ReadOnlySpan<byte>(data + pathStart, offset - pathStart);
// Query string
var queryStart = offset;
if (ch == ByteQuestionMark)
{
// We have a query string
for (; offset < length; offset++)
{
ch = data[offset];
if (ch == ByteSpace)
{
break;
}
}
}
// End of query string not found
if (offset == length)
{
RejectRequestLine(data, length);
}
var targetBuffer = new ReadOnlySpan<byte>(data + pathStart, offset - pathStart);
var query = new ReadOnlySpan<byte>(data + queryStart, offset - queryStart);
// Consume space
offset++;
// Version
var httpVersion = HttpUtilities.GetKnownVersion(data + offset, length - offset);
if (httpVersion == Http.Version.Unknown)
{
if (data[offset] == ByteCR || data[length - 2] != ByteCR)
{
// If missing delimiter or CR before LF, reject and log entire line
RejectRequestLine(data, length);
}
else
{
// else inform HTTP version is unsupported.
RejectUnknownVersion(data + offset, length - offset - 2);
}
}
// After version's 8 bytes and CR, expect LF
if (data[offset + 8 + 1] != ByteLF)
{
RejectRequestLine(data, length);
}
var line = new ReadOnlySpan<byte>(data, length);
handler.OnStartLine(method, httpVersion, targetBuffer, pathBuffer, query, customMethod, pathEncoded);
}
public unsafe bool ParseHeaders<T>(T handler, in ReadOnlySequence<byte> buffer, out SequencePosition consumed, out SequencePosition examined, out int consumedBytes) where T : IHttpHeadersHandler
{
consumed = buffer.Start;
examined = buffer.End;
consumedBytes = 0;
var bufferEnd = buffer.End;
var reader = BufferReader.Create(buffer);
var start = default(BufferReader);
var done = false;
try
{
while (!reader.End)
{
var span = reader.CurrentSegment;
var remaining = span.Length - reader.CurrentSegmentIndex;
fixed (byte* pBuffer = &MemoryMarshal.GetReference(span))
{
while (remaining > 0)
{
var index = reader.CurrentSegmentIndex;
int ch1;
int ch2;
// Fast path, we're still looking at the same span
if (remaining >= 2)
{
ch1 = pBuffer[index];
ch2 = pBuffer[index + 1];
}
else
{
// Store the reader before we look ahead 2 bytes (probably straddling
// spans)
start = reader;
// Possibly split across spans
ch1 = reader.Read();
ch2 = reader.Read();
}
if (ch1 == ByteCR)
{
// Check for final CRLF.
if (ch2 == -1)
{
// Reset the reader so we don't consume anything
reader = start;
return false;
}
else if (ch2 == ByteLF)
{
// If we got 2 bytes from the span directly so skip ahead 2 so that
// the reader's state matches what we expect
if (index == reader.CurrentSegmentIndex)
{
reader.Advance(2);
}
done = true;
return true;
}
// Headers don't end in CRLF line.
RejectRequest(RequestRejectionReason.InvalidRequestHeadersNoCRLF);
}
// We moved the reader so look ahead 2 bytes so reset both the reader
// and the index
if (index != reader.CurrentSegmentIndex)
{
reader = start;
index = reader.CurrentSegmentIndex;
}
var endIndex = new ReadOnlySpan<byte>(pBuffer + index, remaining).IndexOf(ByteLF);
var length = 0;
if (endIndex != -1)
{
length = endIndex + 1;
var pHeader = pBuffer + index;
TakeSingleHeader(pHeader, length, ref handler);
}
else
{
var current = reader.Position;
var subBuffer = buffer.Slice(reader.Position);
// Split buffers
var lineEnd = BuffersExtensions.PositionOf(subBuffer, ByteLF);
if (!lineEnd.HasValue)
{
// Not there
return false;
}
// Make sure LF is included in lineEnd
lineEnd = subBuffer.GetPosition(1, lineEnd.Value);
var headerSpan = PipelineExtensions.ToSpan(subBuffer.Slice(current, lineEnd.Value));
length = headerSpan.Length;
fixed (byte* pHeader = &MemoryMarshal.GetReference(headerSpan))
{
TakeSingleHeader(pHeader, length, ref handler);
}
// We're going to the next span after this since we know we crossed spans here
// so mark the remaining as equal to the headerSpan so that we end up at 0
// on the next iteration
remaining = length;
}
// Skip the reader forward past the header line
reader.Advance(length);
remaining -= length;
}
}
}
return false;
}
finally
{
consumed = reader.Position;
consumedBytes = reader.ConsumedBytes;
if (done)
{
examined = consumed;
}
}
}
public unsafe bool ParseHeaders<T>(ref T handler, ReadOnlySequence<byte> buffer, out int consumedBytes) where T : IHttpHeadersHandler
{
var index = 0;
consumedBytes = 0;
SequencePosition position = buffer.Start;
if (!buffer.TryGet(ref position, out ReadOnlyMemory<byte> currentMemory))
{
consumedBytes = 0;
return false;
}
ReadOnlySpan<byte> currentSpan = currentMemory.Span;
var remaining = currentSpan.Length;
while (true)
{
fixed (byte* pBuffer = &MemoryMarshal.GetReference(currentSpan))
{
while (remaining > 0)
{
int ch1;
int ch2;
// Fast path, we're still looking at the same span
if (remaining >= 2)
{
ch1 = pBuffer[index];
ch2 = pBuffer[index + 1];
}
// Slow Path
else
{
ReadTwoChars(buffer, consumedBytes, out ch1, out ch2);
// I think the above is fast enough. If we don't like it, we can do the code below after some modifications
// to ensure that one next.Span is enough
//if(hasNext) ReadNextTwoChars(pBuffer, remaining, index, out ch1, out ch2, next.Span);
//else
//{
// return false;
//}
}
if (ch1 == ByteCR)
{
if (ch2 == ByteLF)
{
consumedBytes += 2;
return true;
}
if (ch2 == -1)
{
consumedBytes = 0;
return false;
}
// Headers don't end in CRLF line.
RejectRequest(RequestRejectionReason.InvalidRequestHeadersNoCRLF);
}
var endIndex = new ReadOnlySpan<byte>(pBuffer + index, remaining).IndexOf(ByteLF);
var length = 0;
if (endIndex != -1)
{
length = endIndex + 1;
var pHeader = pBuffer + index;
TakeSingleHeader(pHeader, length, ref handler);
}
else
{
// Split buffers
var end = Sequence.IndexOf(buffer.Slice(index), ByteLF);
if (end == -1)
{
// Not there
consumedBytes = 0;
return false;
}
var headerSpan = PipelineExtensions.ToSpan(buffer.Slice(index, end - index + 1));
length = headerSpan.Length;
fixed (byte* pHeader = &MemoryMarshal.GetReference(headerSpan))
{
TakeSingleHeader(pHeader, length, ref handler);
}
}
// Skip the reader forward past the header line
index += length;
consumedBytes += length;
remaining -= length;
}
}
if (buffer.TryGet(ref position, out var nextSegment))
{
currentSpan = nextSegment.Span;
remaining = currentSpan.Length + remaining;
index = currentSpan.Length - remaining;
}
else
{
consumedBytes = 0;
return false;
}
}
}
public static bool ParseResponseLine<T>(ref T handler, ref ReadOnlySequence<byte> buffer, out int consumedBytes) where T : IHttpResponseLineHandler
{
var line = buffer.First.Span;
var lf = line.IndexOf(ByteLF);
if (lf >= 0)
{
line = line.Slice(0, lf + 1);
}
else if (buffer.IsSingleSegment)
{
consumedBytes = 0;
return false;
}
else
{
long index = Sequence.IndexOf(buffer, ByteLF);
if (index < 0)
{
consumedBytes = 0;
return false;
}
if (index > maxRequestLineLength)
{
throw new Exception("invalid response (LF too far)");
}
line = line.Slice(0, lf + 1);
}
if (line[lf - 1] != ByteCR)
{
throw new Exception("invalid response (no CR)");
}
Http.Version version;
if (line.StartsWith(s_http11)) { version = Http.Version.Http11; }
else if (line.StartsWith(s_http20)) { version = Http.Version.Http20; }
else if (line.StartsWith(s_http10)) { version = Http.Version.Http10; }
else
{
throw new Exception("invalid response (version)");
}
int codeStart = line.IndexOf((byte)' ') + 1;
var codeSlice = line.Slice(codeStart);
if (!Utf8Parser.TryParse(codeSlice, out ushort code, out consumedBytes))
{
throw new Exception("invalid response (status code)");
}
var reasonStart = consumedBytes + 1;
var reason = codeSlice.Slice(reasonStart, codeSlice.Length - reasonStart - 2);
consumedBytes = lf + s_Eol.Length;
handler.OnStatusLine(version, code, reason);
return true;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void ReadTwoChars(ReadOnlySequence<byte> buffer, int consumedBytes, out int ch1, out int ch2)
{
var first = buffer.First.Span;
if (first.Length - consumedBytes > 1)
{
ch1 = first[consumedBytes];
ch2 = first[consumedBytes + 1];
}
if (buffer.Length < consumedBytes + 2)
{
ch1 = -1;
ch2 = -1;
}
else
{
buffer = buffer.Slice(consumedBytes, 2);
Span<byte> temp = stackalloc byte[2];
buffer.CopyTo(temp);
ch1 = temp[0];
ch2 = temp[1];
}
}
// This is not needed, but I will leave it here for now, as we might need it later when optimizing
//private static unsafe void ReadNextTwoChars(byte* pBuffer, int remaining, int index, out int ch1, out int ch2, ReadOnlySpan<byte> next)
//{
// Debug.Assert(next.Length > 1);
// Debug.Assert(remaining == 0 || remaining == 1);
// if (remaining == 1)
// {
// ch1 = pBuffer[index];
// ch2 = next.IsEmpty ? -1 : next[0];
// }
// else
// {
// ch1 = -1;
// ch2 = -1;
// if (next.Length > 0)
// {
// ch1 = next[0];
// if (next.Length > 1)
// {
// ch2 = next[1];
// }
// }
// }
//}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe int FindEndOfName(byte* headerLine, int length)
{
var index = 0;
var sawWhitespace = false;
for (; index < length; index++)
{
var ch = headerLine[index];
if (ch == ByteColon)
{
break;
}
if (ch == ByteTab || ch == ByteSpace || ch == ByteCR)
{
sawWhitespace = true;
}
}
if (index == length || sawWhitespace)
{
RejectRequestHeader(headerLine, length);
}
return index;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe void TakeSingleHeader<T>(byte* headerLine, int length, ref T handler) where T : IHttpHeadersHandler
{
// Skip CR, LF from end position
var valueEnd = length - 3;
var nameEnd = FindEndOfName(headerLine, length);
if (headerLine[valueEnd + 2] != ByteLF)
{
RejectRequestHeader(headerLine, length);
}
if (headerLine[valueEnd + 1] != ByteCR)
{
RejectRequestHeader(headerLine, length);
}
// Skip colon from value start
var valueStart = nameEnd + 1;
// Ignore start whitespace
for (; valueStart < valueEnd; valueStart++)
{
var ch = headerLine[valueStart];
if (ch != ByteTab && ch != ByteSpace && ch != ByteCR)
{
break;
}
else if (ch == ByteCR)
{
RejectRequestHeader(headerLine, length);
}
}
// Check for CR in value
var i = valueStart + 1;
if (Contains(headerLine + i, valueEnd - i, ByteCR))
{
RejectRequestHeader(headerLine, length);
}
// Ignore end whitespace
for (; valueEnd >= valueStart; valueEnd--)
{
var ch = headerLine[valueEnd];
if (ch != ByteTab && ch != ByteSpace)
{
break;
}
}
var nameBuffer = new ReadOnlySpan<byte>(headerLine, nameEnd);
var valueBuffer = new ReadOnlySpan<byte>(headerLine + valueStart, valueEnd - valueStart + 1);
handler.OnHeader(nameBuffer, valueBuffer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe bool Contains(byte* searchSpace, int length, byte value)
{
var i = 0;
if (Vector.IsHardwareAccelerated)
{
// Check Vector lengths
if (length - Vector<byte>.Count >= i)
{
var vValue = GetVector(value);
do
{
if (!Vector<byte>.Zero.Equals(Vector.Equals(vValue, Unsafe.Read<Vector<byte>>(searchSpace + i))))
{
goto found;
}
i += Vector<byte>.Count;
} while (length - Vector<byte>.Count >= i);
}
}
// Check remaining for CR
for (; i <= length; i++)
{
var ch = searchSpace[i];
if (ch == value)
{
goto found;
}
}
return false;
found:
return true;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool TryGetNewLineSpan(in ReadOnlySequence<byte> buffer, out SequencePosition found)
{
var position = BuffersExtensions.PositionOf(buffer, ByteLF);
if (position.HasValue)
{
// Move 1 byte past the \n
found = buffer.GetPosition(1, position.Value);
return true;
}
found = default;
return false;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private unsafe ReadOnlySpan<byte> GetUnknownMethod(byte* data, int length, out int methodLength)
{
methodLength = 0;
for (var i = 0; i < length; i++)
{
var ch = data[i];
if (ch == ByteSpace)
{
if (i == 0)
{
RejectRequestLine(data, length);
}
methodLength = i;
break;
}
else if (!IsValidTokenChar((char)ch))
{
RejectRequestLine(data, length);
}
}
return new ReadOnlySpan<byte>(data, methodLength);
}
// TODO: this could be optimized by using a table
private static bool IsValidTokenChar(char c)
{
// Determines if a character is valid as a 'token' as defined in the
// HTTP spec: https://tools.ietf.org/html/rfc7230#section-3.2.6
return
(c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
c == '!' ||
c == '#' ||
c == '$' ||
c == '%' ||
c == '&' ||
c == '\'' ||
c == '*' ||
c == '+' ||
c == '-' ||
c == '.' ||
c == '^' ||
c == '_' ||
c == '`' ||
c == '|' ||
c == '~';
}
private void RejectRequest(RequestRejectionReason reason)
=> throw BadHttpRequestException.GetException(reason);
private unsafe void RejectRequestLine(byte* requestLine, int length)
=> throw GetInvalidRequestException(RequestRejectionReason.InvalidRequestLine, requestLine, length);
private unsafe void RejectRequestHeader(byte* headerLine, int length)
=> throw GetInvalidRequestException(RequestRejectionReason.InvalidRequestHeader, headerLine, length);
private unsafe void RejectUnknownVersion(byte* version, int length)
=> throw GetInvalidRequestException(RequestRejectionReason.UnrecognizedHTTPVersion, version, length);
private unsafe BadHttpRequestException GetInvalidRequestException(RequestRejectionReason reason, byte* detail, int length)
{
string errorDetails = _showErrorDetails ?
new Span<byte>(detail, length).GetAsciiStringEscaped(Constants.MaxExceptionDetailSize) :
string.Empty;
return BadHttpRequestException.GetException(reason, errorDetails);
}
public void Reset()
{
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Vector<byte> GetVector(byte vectorByte)
{
// Vector<byte> .ctor doesn't become an intrinsic due to detection issue
// However this does cause it to become an intrinsic (with additional multiply and reg->reg copy)
// https://github.com/dotnet/coreclr/issues/7459#issuecomment-253965670
return Vector.AsVectorByte(new Vector<uint>(vectorByte * 0x01010101u));
}
enum State : byte
{
ParsingName,
BeforValue,
ParsingValue,
ArferCR,
}
}
}
| 36.167883 | 202 | 0.430071 | [
"MIT"
] | benaadams/corefxlab | src/System.Text.Http/System/Text/Http/Parser/HttpParser.cs | 29,730 | 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("Reformat CSharp Code")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Reformat CSharp Code")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("55c85be1-f04e-4400-b4ba-c9700eabe152")]
// 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.189189 | 84 | 0.745223 | [
"MIT"
] | jsdelivrbot/Telerik_Academy | CSharp/CSharp Part 1/Training/Telerik - Homework/Homework 1/Reformat CSharp Code/Properties/AssemblyInfo.cs | 1,416 | C# |
using BleReaderNet.Device;
using BleReaderNet.Exception;
using BleReaderNet.Wrapper;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace BleReaderNet.Reader
{
/// <summary>
/// Provides functionality to scan and read manufacturer data of Bluetooth LE devices
/// </summary>
public class BleReader : IBleReader
{
public const int DefaultScanDurationSeconds = 10;
private readonly IBluetoothService _bluetoothService;
private IReadOnlyList<IBluetoothDevice> _deviceList = null;
public BleReader(IBluetoothService bluetoothService)
{
_bluetoothService = bluetoothService;
}
/// <inheritdoc/>
public async Task<IReadOnlyList<DeviceInfo>> GetAllDevicesAsync()
{
if (_deviceList == null)
{
throw new DevicesNotScannedException("Scan the available devices before trying to access the data");
}
var deviceInfoList = new List<DeviceInfo>();
foreach (var device in _deviceList)
{
var properties = await device.GetPropertiesAsync();
deviceInfoList.Add(new DeviceInfo()
{
Name = properties.Name,
Address = properties.Address,
ManufacturerData = properties.GetManufacturerData()
});
}
return deviceInfoList;
}
/// <inheritdoc/>
public async Task<int> ScanAsync(string adapterName = null, int scanDurationSeconds = DefaultScanDurationSeconds)
{
var adapter = await _bluetoothService.GetAdapterAsync(adapterName);
if (adapter == null)
{
throw new AdapterNotFoundException($"Adapter '{adapterName}' was not found");
}
await adapter.StartDiscoveryAsync();
await Task.Delay(TimeSpan.FromSeconds(scanDurationSeconds));
await adapter.StopDiscoveryAsync();
_deviceList = await adapter.GetDevicesAsync();
return _deviceList.Count;
}
/// <inheritdoc cref="IBleReader"/>
public async Task<T> GetManufacturerDataAsync<T>(string macAddress)
{
var manufacturerData = await ReadDeviceDataAsync(macAddress);
if (manufacturerData != null)
{
if (typeof(T) == typeof(RuuviTag))
{
return (T)Convert.ChangeType(RuuviTag.Parse(manufacturerData.Data), typeof(T));
}
// Add support for parsing data of other device types
else
{
throw new UnsupportedDeviceTypeException($"Support for getting manufacturer data of type '{typeof(T).ToString()}' has not been implemented");
}
}
return default(T);
}
private async Task<ManufacturerData> ReadDeviceDataAsync(string macAddress)
{
if (macAddress == null)
{
throw new ArgumentNullException(nameof(macAddress));
}
if (_deviceList == null)
{
throw new DevicesNotScannedException("Scan the available devices before trying to access the data");
}
foreach (var device in _deviceList)
{
var properties = await device.GetPropertiesAsync();
if (properties.Address.Equals(macAddress))
{
return properties.GetManufacturerData();
}
}
return null;
}
}
}
| 34.026786 | 161 | 0.55576 | [
"MIT"
] | ilpork/BleReader.Net | src/BleReaderNet/Reader/BleReader.cs | 3,813 | C# |
// Copyright (c) Aksio Insurtech. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#nullable disable
namespace Aksio.Cratis.Events.Store.Observation;
/// <summary>
/// Represents the state used for an observer.
/// </summary>
public class ObserverState
{
/// <summary>
/// The name of the storage provider used for working with this type of state.
/// </summary>
public const string StorageProvider = "observer-state";
/// <summary>
/// Gets or sets the identifier of the observer state.
/// </summary>
public string Id { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the event types the observer is observing.
/// </summary>
public IEnumerable<EventType> EventTypes { get; set; } = Array.Empty<EventType>();
/// <summary>
/// Gets or sets the <see cref="EventSequenceId"/> the state is for.
/// </summary>
public EventSequenceId EventSequenceId { get; set; } = EventSequenceId.Unspecified;
/// <summary>
/// Gets or sets the <see cref="EventSequenceId"/> the state is for.
/// </summary>
public ObserverId ObserverId { get; set; } = ObserverId.Unspecified;
/// <summary>
/// Gets or sets a friendly name for the observer.
/// </summary>
public ObserverName Name { get; set; } = ObserverName.NotSpecified;
/// <summary>
/// Gets or sets the <see cref="ObserverType"/>.
/// </summary>
public ObserverType Type { get; set; } = ObserverType.Unknown;
/// <summary>
/// Gets or sets the expected next event sequence number into the event log.
/// </summary>
public EventSequenceNumber NextEventSequenceNumber { get; set; } = EventSequenceNumber.First;
/// <summary>
/// Gets or sets the last handled event in the event log, ever. This value will never reset during a rewind.
/// </summary>
public EventSequenceNumber LastHandled { get; set; } = EventSequenceNumber.First;
/// <summary>
/// Gets or sets the running state.
/// </summary>
public ObserverRunningState RunningState { get; set; } = ObserverRunningState.New;
/// <summary>
/// The current namespace we want to target stream to.
/// </summary>
public ObserverNamespace CurrentNamespace { get; set; } = ObserverNamespace.NotSet;
/// <summary>
/// Gets or sets the failed partitions for the observer.
/// </summary>
public IEnumerable<FailedObserverPartition> FailedPartitions
{
get => _failedPartitions;
set => _failedPartitions = new(value);
}
/// <summary>
/// Gets or sets the failed partitions for the observer.
/// </summary>
public IEnumerable<RecoveringFailedObserverPartition> RecoveringPartitions
{
get => _partitionsBeingRecovered;
set => _partitionsBeingRecovered = new(value);
}
/// <summary>
/// Gets whether or not there are any failed partitions.
/// </summary>
public bool HasFailedPartitions => _failedPartitions.Count > 0;
/// <summary>
/// Gets whether or not there are any partitions being recovered.
/// </summary>
public bool IsRecoveringAnyPartition => _partitionsBeingRecovered.Count > 0;
List<FailedObserverPartition> _failedPartitions = new();
List<RecoveringFailedObserverPartition> _partitionsBeingRecovered = new();
/// <summary>
/// Fail a partition. If the partition is already failed, it will update it with the details.
/// </summary>
/// <param name="eventSourceId">The partition to fail.</param>
/// <param name="sequenceNumber">Sequence number it failed at.</param>
/// <param name="messages">Messages describing the failure.</param>
/// <param name="stackTrace">Stack trace, if any.</param>
public void FailPartition(EventSourceId eventSourceId, EventSequenceNumber sequenceNumber, string[] messages, string stackTrace)
{
var partition = _failedPartitions.Find(_ => _.EventSourceId == eventSourceId);
if (partition is null)
{
partition = new();
_failedPartitions.Add(partition);
}
partition.EventSourceId = eventSourceId;
partition.SequenceNumber = sequenceNumber;
partition.Messages = messages;
partition.StackTrace = stackTrace;
AddAttemptToFailedPartition(eventSourceId);
}
/// <summary>
/// Start the recovery of a failed partition.
/// </summary>
/// <param name="eventSourceId">Partition to start recovery on.</param>
/// <remarks>If the partition is not failed, it will not register it for recovering.</remarks>
public void StartRecoveringPartition(EventSourceId eventSourceId)
{
if (!IsPartitionFailed(eventSourceId) || IsRecoveringPartition(eventSourceId))
{
return;
}
var failedPartition = GetFailedPartition(eventSourceId);
_partitionsBeingRecovered.Add(new()
{
EventSourceId = eventSourceId,
SequenceNumber = failedPartition.SequenceNumber,
StartedRecoveryAt = DateTimeOffset.UtcNow
});
}
/// <summary>
/// Check whether or not a partition is being recovered.
/// </summary>
/// <param name="eventSourceId">Partition to check.</param>
/// <returns>True if being recovered, false if not.</returns>
public bool IsRecoveringPartition(EventSourceId eventSourceId) => _partitionsBeingRecovered.Any(_ => _.EventSourceId == eventSourceId);
/// <summary>
/// Recover a failed partition.
/// </summary>
/// <param name="eventSourceId">Partition to recover.</param>
public void PartitionRecovered(EventSourceId eventSourceId)
{
var partition = _failedPartitions.Find(_ => _.EventSourceId == eventSourceId);
if (partition is not null)
{
_failedPartitions.Remove(partition);
}
var recoveringPartition = _partitionsBeingRecovered.Find(_ => _.EventSourceId == eventSourceId);
if (recoveringPartition is not null)
{
_partitionsBeingRecovered.Remove(recoveringPartition);
}
}
/// <summary>
/// Get the recovery information for a partition being recovered.
/// </summary>
/// <param name="eventSourceId">Partition to get for.</param>
/// <returns>Recovery information.</returns>
public RecoveringFailedObserverPartition GetPartitionRecovery(EventSourceId eventSourceId) => _partitionsBeingRecovered.Find(_ => _.EventSourceId == eventSourceId);
/// <summary>
/// Check whether or not a partition is failed.
/// </summary>
/// <param name="eventSourceId">Partition to check.</param>
/// <returns>True if failed, false if not.</returns>
public bool IsPartitionFailed(EventSourceId eventSourceId) => _failedPartitions.Any(_ => _.EventSourceId == eventSourceId);
/// <summary>
/// Gets a failed partition by its partition identifier.
/// </summary>
/// <param name="eventSourceId">Partition to get.</param>
/// <returns>The failed partition.</returns>
public FailedObserverPartition GetFailedPartition(EventSourceId eventSourceId) => _failedPartitions.Find(_ => _.EventSourceId == eventSourceId);
/// <summary>
/// Add an attempt to a failed partition.
/// </summary>
/// <param name="eventSourceId">Partition to add to.</param>
public void AddAttemptToFailedPartition(EventSourceId eventSourceId)
{
var partition = _failedPartitions.Find(_ => _.EventSourceId == eventSourceId);
if (partition is not null)
{
partition.Attempts++;
partition.LastAttempt = DateTimeOffset.UtcNow;
}
}
/// <summary>
/// Clear any failed partitions.
/// </summary>
public void ClearFailedPartitions()
{
_failedPartitions.Clear();
}
/// <summary>
/// Clear any recovering partitions.
/// </summary>
public void ClearRecoveringPartitions()
{
_partitionsBeingRecovered.Clear();
}
}
| 37.073394 | 168 | 0.660604 | [
"MIT"
] | aksio-insurtech/Cratis | Source/Kernel/Store/Shared/Observation/ObserverState.cs | 8,082 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using UnityEngine;
using UnityEditor;
namespace Microsoft.SpatialAudio.Spatializer
{
[DisallowMultipleComponent]
[RequireComponent(typeof(AudioSource))]
public class RoomEffectSendLevel : MonoBehaviour
{
private const float c_RoomEffectSendPowerMin = -100;
private const float c_RoomEffectSendPowerMax = 20;
private const float c_RoomEffectSendPowerMaxDistance = 100;
private const string c_RoomEffectSendPowerLabel = "Room Effect Send Level (dB)";
// Spatializer parameter indices
public enum SpatializerParams
{
RoomEffectSendPower = 0,
Count
}
[CurveDimensions(0, c_RoomEffectSendPowerMaxDistance, c_RoomEffectSendPowerMin, c_RoomEffectSendPowerMax, c_RoomEffectSendPowerLabel)]
[Tooltip("Calculate the amount of non-spatialized source signal that should be processed for the room effect (typically reverb) in dB based on the source-listener distance. Default=0dB, Range [-100dB,20dB]")]
[ContextMenuItem("Reset", "ResetRoomEffectSendPowerCurve")]
public AnimationCurve RoomEffectSendPowerCurve = AnimationCurve.Linear(0, 0, c_RoomEffectSendPowerMaxDistance, 0);
private float _LastRoomEffectSendPower = float.MinValue;
private void ResetRoomEffectSendPowerCurve()
{
RoomEffectSendPowerCurve = AnimationCurve.Linear(0, 0, c_RoomEffectSendPowerMaxDistance, 0);
#if UNITY_EDITOR
// This forces the inspector preview of the animation curve to refresh
AssetDatabase.Refresh();
#endif
}
void Update()
{
var source = GetComponent<AudioSource>();
// Source-listener distance
float distance = Vector3.Distance(transform.position, Camera.main.transform.position);
// Get the room effect send level for this distance
float roomEffectSendPower = RoomEffectSendPowerCurve.Evaluate(distance);
if (_LastRoomEffectSendPower != roomEffectSendPower)
{
_LastRoomEffectSendPower = roomEffectSendPower;
source.SetSpatializerFloat((int)SpatializerParams.RoomEffectSendPower, _LastRoomEffectSendPower);
}
}
}
#if UNITY_EDITOR
/// <summary>
/// Custom drawer for the startup of AnimationCurves. Sets the grid range for the curve editor.
/// </summary>
[CustomPropertyDrawer(typeof(CurveDimensions))]
public class CurveDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var curve = attribute as CurveDimensions;
if (property.propertyType == SerializedPropertyType.AnimationCurve)
{
var rect = new Rect(curve.XMin, curve.YMin, System.Math.Abs(curve.XMin - curve.XMax), System.Math.Abs(curve.YMin - curve.YMax));
EditorGUI.CurveField(position, property, Color.green, rect, new GUIContent(curve.Label));
}
}
}
#endif
/// <summary>
/// Property attribute for setting the CurveField grid range.
/// </summary>
public class CurveDimensions : PropertyAttribute
{
public float XMin, XMax, YMin, YMax;
public string Label;
public CurveDimensions(float xMin, float xMax, float yMin, float yMax, string label)
{
this.XMin = xMin;
this.XMax = xMax;
this.YMin = yMin;
this.YMax = yMax;
this.Label = label;
}
}
}
| 37.469388 | 216 | 0.665577 | [
"MIT"
] | Janniku9/P05-Virtual-Graffiti | Packages/Microsoft.SpatialAudio.Spatializer.Unity.1.0.176/Scripts/RoomEffectSendLevel.cs | 3,674 | C# |
using System;
using System.Drawing;
using System.IO;
using System.Net;
using NUnit.Framework;
using NServiceKit.Common.Utils;
using NServiceKit.Common.Web;
using NServiceKit.Text;
using NServiceKit.WebHost.IntegrationTests.Services;
namespace NServiceKit.WebHost.IntegrationTests.Tests
{
/// <summary>A file upload tests.</summary>
[TestFixture]
public class FileUploadTests
: RestsTestBase
{
/// <summary>Uploads a file.</summary>
///
/// <param name="pathInfo">Information describing the path.</param>
/// <param name="fileInfo">Information describing the file.</param>
///
/// <returns>A WebResponse.</returns>
public WebResponse UploadFile(string pathInfo, FileInfo fileInfo)
{
//long length = 0;
string boundary = "----------------------------" +
DateTime.Now.Ticks.ToString("x");
var httpWebRequest = (HttpWebRequest)WebRequest.Create(base.ServiceClientBaseUri + pathInfo);
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
httpWebRequest.Accept = ContentType.Json;
httpWebRequest.Method = "POST";
httpWebRequest.AllowAutoRedirect = false;
httpWebRequest.KeepAlive = false;
Stream memStream = new System.IO.MemoryStream();
byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary);
string headerTemplate = "\r\n--" + boundary + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
string header = string.Format(headerTemplate, "upload", fileInfo.Name, MimeTypes.GetMimeType(fileInfo.Name));
byte[] headerbytes = System.Text.Encoding.ASCII.GetBytes(header);
memStream.Write(headerbytes, 0, headerbytes.Length);
//Image img = null;
//img = Image.FromFile("C:/Documents and Settings/Dorin Cucicov/My Documents/My Pictures/Sunset.jpg", true);
//img.Save(memStream, System.Drawing.Imaging.ImageFormat.Jpeg);
using (var fs = fileInfo.OpenRead())
{
fs.WriteTo(memStream);
}
memStream.Write(boundarybytes, 0, boundarybytes.Length);
//string formdataTemplate = "\r\nContent-Disposition: form-data; name=\"{0}\";\r\n\r\n{1}";
//string formitem = string.Format(formdataTemplate, "headline", "Sunset");
//byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
//memStream.Write(formitembytes, 0, formitembytes.Length);
//memStream.Write(boundarybytes, 0, boundarybytes.Length);
httpWebRequest.ContentLength = memStream.Length;
var requestStream = httpWebRequest.GetRequestStream();
memStream.Position = 0;
var tempBuffer = new byte[memStream.Length];
memStream.Read(tempBuffer, 0, tempBuffer.Length);
memStream.Close();
requestStream.Write(tempBuffer, 0, tempBuffer.Length);
requestStream.Close();
return httpWebRequest.GetResponse();
}
/// <summary>Can post upload file.</summary>
[Test]
public void Can_POST_upload_file()
{
var uploadForm = new FileInfo("~/TestExistingDir/upload.html".MapHostAbsolutePath());
var webResponse = UploadFile("/fileuploads", uploadForm);
AssertResponse<FileUploadResponse>((HttpWebResponse)webResponse, r =>
{
var expectedContents = new StreamReader(uploadForm.OpenRead()).ReadToEnd();
Assert.That(r.FileName, Is.EqualTo(uploadForm.Name));
Assert.That(r.ContentLength, Is.EqualTo(uploadForm.Length));
Assert.That(r.ContentType, Is.EqualTo(MimeTypes.GetMimeType(uploadForm.Name)));
Assert.That(r.Contents, Is.EqualTo(expectedContents));
});
}
/// <summary>Can get upload file.</summary>
[Test]
public void Can_GET_upload_file()
{
var uploadForm = new FileInfo("~/TestExistingDir/upload.html".MapHostAbsolutePath());
var webRequest = (HttpWebRequest)WebRequest.Create(base.ServiceClientBaseUri + "/fileuploads/TestExistingDir/upload.html");
var expectedContents = new StreamReader(uploadForm.OpenRead()).ReadToEnd();
var webResponse = webRequest.GetResponse();
var actualContents = new StreamReader(webResponse.GetResponseStream()).ReadToEnd();
Assert.That(webResponse.ContentType, Is.EqualTo(MimeTypes.GetMimeType(uploadForm.Name)));
Assert.That(actualContents, Is.EqualTo(expectedContents));
}
}
} | 35.341463 | 148 | 0.695192 | [
"BSD-3-Clause"
] | NServiceKit/NServiceKit | tests/NServiceKit.WebHost.IntegrationTests/Tests/FileUploadTests.cs | 4,225 | C# |
// -----------------------------------------------------------------------
// <copyright file="IEventHandlerFactory.cs" company="OSharp开源团队">
// Copyright (c) 2014-2017 OSharp. All rights reserved.
// </copyright>
// <site>http://www.osharp.org</site>
// <last-editor>郭明锋</last-editor>
// <last-date>2017-09-19 1:27</last-date>
// -----------------------------------------------------------------------
using OSharp.EventBuses.Internal;
namespace OSharp.EventBuses
{
/// <summary>
/// 定义获取<see cref="IEventHandler"/>实例的方式
/// </summary>
public interface IEventHandlerFactory
{
/// <summary>
/// 获取事件处理器实例
/// </summary>
/// <returns></returns>
EventHandlerDisposeWrapper GetHandler();
}
} | 29.461538 | 75 | 0.497389 | [
"Apache-2.0"
] | 1051324354/osharp | src/OSharp/EventBuses/IEventHandlerFactory.cs | 818 | C# |
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace EddiEvents
{
public class FighterRebuiltEvent : Event
{
public const string NAME = "Fighter rebuilt";
public const string DESCRIPTION = "Triggered when a ship's fighter is rebuilt in the hangar";
public const string SAMPLE = "{\"timestamp\":\"2016-07-22T10:53:19Z\",\"event\":\"FighterRebuilt\",\"Loadout\":\"four\"}";
public static Dictionary<string, string> VARIABLES = new Dictionary<string, string>();
static FighterRebuiltEvent()
{
VARIABLES.Add("loadout", "The loadout of the fighter");
}
[JsonProperty("loadout")]
public string loadout { get; private set; }
public FighterRebuiltEvent(DateTime timestamp, string loadout) : base(timestamp, NAME)
{
this.loadout = loadout;
}
}
}
| 32.214286 | 130 | 0.637472 | [
"Apache-2.0"
] | Juggernaut93/EDDI | Events/FighterRebuiltEvent.cs | 904 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.AspNet.FriendlyUrls.Resolvers;
namespace ASP.NET_WebForms_Remote_Authentication
{
public partial class ViewSwitcher : System.Web.UI.UserControl
{
protected string CurrentView { get; private set; }
protected string AlternateView { get; private set; }
protected string SwitchUrl { get; private set; }
protected void Page_Load(object sender, EventArgs e)
{
// Determine current view
var isMobile = WebFormsFriendlyUrlResolver.IsMobileView(new HttpContextWrapper(Context));
CurrentView = isMobile ? "Mobile" : "Desktop";
// Determine alternate view
AlternateView = isMobile ? "Desktop" : "Mobile";
// Create switch URL from the route, e.g. ~/__FriendlyUrls_SwitchView/Mobile?ReturnUrl=/Page
var switchViewRouteName = "AspNet.FriendlyUrls.SwitchView";
var switchViewRoute = RouteTable.Routes[switchViewRouteName];
if (switchViewRoute == null)
{
// Friendly URLs is not enabled or the name of the switch view route is out of sync
this.Visible = false;
return;
}
var url = GetRouteUrl(switchViewRouteName, new { view = AlternateView, __FriendlyUrls_SwitchViews = true });
url += "?ReturnUrl=" + HttpUtility.UrlEncode(Request.RawUrl);
SwitchUrl = url;
}
}
} | 37.488372 | 120 | 0.648263 | [
"MIT"
] | EmilMitev/Telerik-Academy | ASP.NET Web Forms/09. Identity/Demo/ASP.NET WebForms Remote Authentication/ViewSwitcher.ascx.cs | 1,612 | C# |
using System;
using System.Xml.Serialization;
using System.ComponentModel.DataAnnotations;
using BroadWorksConnector.Ocip.Validation;
using System.Collections.Generic;
namespace BroadWorksConnector.Ocip.Models
{
/// <summary>
///
/// </summary>
[Serializable]
[XmlRoot(Namespace = "")]
[Groups(@"[{""__type"":""Sequence:#BroadWorksConnector.Ocip.Validation"",""id"":""3347d430e0d5c93a9ff8dcf0e3b60d6c:1108""}]")]
public class SystemVoiceMessagingGroupGetVoicePortalMenusResponse21PersonalAssistantMenuKeys
{
private string _setPresenceToNone;
[XmlElement(ElementName = "setPresenceToNone", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToNone
{
get => _setPresenceToNone;
set
{
SetPresenceToNoneSpecified = true;
_setPresenceToNone = value;
}
}
[XmlIgnore]
protected bool SetPresenceToNoneSpecified { get; set; }
private string _setPresenceToBusinessTrip;
[XmlElement(ElementName = "setPresenceToBusinessTrip", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToBusinessTrip
{
get => _setPresenceToBusinessTrip;
set
{
SetPresenceToBusinessTripSpecified = true;
_setPresenceToBusinessTrip = value;
}
}
[XmlIgnore]
protected bool SetPresenceToBusinessTripSpecified { get; set; }
private string _setPresenceToGoneForTheDay;
[XmlElement(ElementName = "setPresenceToGoneForTheDay", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToGoneForTheDay
{
get => _setPresenceToGoneForTheDay;
set
{
SetPresenceToGoneForTheDaySpecified = true;
_setPresenceToGoneForTheDay = value;
}
}
[XmlIgnore]
protected bool SetPresenceToGoneForTheDaySpecified { get; set; }
private string _setPresenceToLunch;
[XmlElement(ElementName = "setPresenceToLunch", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToLunch
{
get => _setPresenceToLunch;
set
{
SetPresenceToLunchSpecified = true;
_setPresenceToLunch = value;
}
}
[XmlIgnore]
protected bool SetPresenceToLunchSpecified { get; set; }
private string _setPresenceToMeeting;
[XmlElement(ElementName = "setPresenceToMeeting", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToMeeting
{
get => _setPresenceToMeeting;
set
{
SetPresenceToMeetingSpecified = true;
_setPresenceToMeeting = value;
}
}
[XmlIgnore]
protected bool SetPresenceToMeetingSpecified { get; set; }
private string _setPresenceToOutOfOffice;
[XmlElement(ElementName = "setPresenceToOutOfOffice", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToOutOfOffice
{
get => _setPresenceToOutOfOffice;
set
{
SetPresenceToOutOfOfficeSpecified = true;
_setPresenceToOutOfOffice = value;
}
}
[XmlIgnore]
protected bool SetPresenceToOutOfOfficeSpecified { get; set; }
private string _setPresenceToTemporarilyOut;
[XmlElement(ElementName = "setPresenceToTemporarilyOut", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToTemporarilyOut
{
get => _setPresenceToTemporarilyOut;
set
{
SetPresenceToTemporarilyOutSpecified = true;
_setPresenceToTemporarilyOut = value;
}
}
[XmlIgnore]
protected bool SetPresenceToTemporarilyOutSpecified { get; set; }
private string _setPresenceToTraining;
[XmlElement(ElementName = "setPresenceToTraining", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToTraining
{
get => _setPresenceToTraining;
set
{
SetPresenceToTrainingSpecified = true;
_setPresenceToTraining = value;
}
}
[XmlIgnore]
protected bool SetPresenceToTrainingSpecified { get; set; }
private string _setPresenceToUnavailable;
[XmlElement(ElementName = "setPresenceToUnavailable", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToUnavailable
{
get => _setPresenceToUnavailable;
set
{
SetPresenceToUnavailableSpecified = true;
_setPresenceToUnavailable = value;
}
}
[XmlIgnore]
protected bool SetPresenceToUnavailableSpecified { get; set; }
private string _setPresenceToVacation;
[XmlElement(ElementName = "setPresenceToVacation", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string SetPresenceToVacation
{
get => _setPresenceToVacation;
set
{
SetPresenceToVacationSpecified = true;
_setPresenceToVacation = value;
}
}
[XmlIgnore]
protected bool SetPresenceToVacationSpecified { get; set; }
private string _returnToPreviousMenu;
[XmlElement(ElementName = "returnToPreviousMenu", IsNullable = false, Namespace = "")]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string ReturnToPreviousMenu
{
get => _returnToPreviousMenu;
set
{
ReturnToPreviousMenuSpecified = true;
_returnToPreviousMenu = value;
}
}
[XmlIgnore]
protected bool ReturnToPreviousMenuSpecified { get; set; }
private string _repeatMenu;
[XmlElement(ElementName = "repeatMenu", IsNullable = false, Namespace = "")]
[Optional]
[Group(@"3347d430e0d5c93a9ff8dcf0e3b60d6c:1108")]
[Length(1)]
[RegularExpression(@"[0-9]|\*|#")]
public string RepeatMenu
{
get => _repeatMenu;
set
{
RepeatMenuSpecified = true;
_repeatMenu = value;
}
}
[XmlIgnore]
protected bool RepeatMenuSpecified { get; set; }
}
}
| 31.061538 | 130 | 0.579123 | [
"MIT"
] | Rogn/broadworks-connector-net | BroadworksConnector/Ocip/Models/SystemVoiceMessagingGroupGetVoicePortalMenusResponse21PersonalAssistantMenuKeys.cs | 8,076 | C# |
using System;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
namespace UnityEditor.VFX.Operator
{
class SampleMeshProvider : VariantProvider
{
protected override sealed Dictionary<string, object[]> variants
{
get
{
return new Dictionary<string, object[]>
{
{ "source", Enum.GetValues(typeof(SampleMesh.SourceType)).Cast<object>().ToArray() },
};
}
}
}
[VFXInfo(category = "Sampling", variantProvider = typeof(SampleMeshProvider), experimental = true)]
class SampleMesh : VFXOperator
{
override public string name
{
get
{
if (source == SourceType.Mesh)
return "Sample Mesh";
else
return "Sample Skinned Mesh";
}
}
public enum PlacementMode
{
Vertex,
Edge,
Surface
};
public class InputPropertiesMesh
{
[Tooltip("Specifies the Mesh to sample from.")]
public Mesh mesh = VFXResources.defaultResources.mesh;
}
public class InputPropertiesSkinnedMeshRenderer
{
[Tooltip("Specifies the Skinned Mesh Renderer component to sample from. The Skinned Mesh Renderer has to be an exposed entry.")]
public SkinnedMeshRenderer skinnedMesh = null;
}
public class InputPropertiesPlacementVertex
{
[Tooltip("Sets the vertex index to read from.")]
public uint vertex = 0u;
}
public enum SurfaceCoordinates
{
Barycentric,
Uniform,
}
public class InputPropertiesEdge
{
[Tooltip("Sets the start index of the edge. The Block uses this index and the next index to render the line.")]
public uint index = 0u;
[Range(0, 1), Tooltip("Controls the percentage along the edge, from the start position to the end position, that the sample position is taken.")]
public float edge;
}
public class InputPropertiesPlacementSurfaceBarycentricCoordinates
{
[Tooltip("The triangle index to read from.")]
public uint triangle = 0u;
[Tooltip("Barycentric coordinate (z is computed from x & y).")]
public Vector2 barycentric;
}
public class InputPropertiesPlacementSurfaceLowDistorsionMapping
{
[Tooltip("The triangle index to read from.")]
public uint triangle = 0u;
[Tooltip("The uniform coordinate to sample the triangle at. The Block takes this value and maps it from a square coordinate to triangle space.")]
public Vector2 square;
}
[Flags]
public enum VertexAttributeFlag
{
None = 0,
Position = 1 << 0,
Normal = 1 << 1,
Tangent = 1 << 2,
Color = 1 << 3,
TexCoord0 = 1 << 4,
TexCoord1 = 1 << 5,
TexCoord2 = 1 << 6,
TexCoord3 = 1 << 7,
TexCoord4 = 1 << 8,
TexCoord5 = 1 << 9,
TexCoord6 = 1 << 10,
TexCoord7 = 1 << 11,
BlendWeight = 1 << 12,
BlendIndices = 1 << 13
}
public enum SourceType
{
Mesh,
SkinnedMeshRenderer
}
[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), SerializeField, Tooltip("Outputs the result of the Mesh sampling operation.")]
private VertexAttributeFlag output = VertexAttributeFlag.Position | VertexAttributeFlag.Color | VertexAttributeFlag.TexCoord0;
[VFXSetting, SerializeField, Tooltip("Specifies how Unity handles the sample when the custom vertex index is out the out of bounds of the vertex array.")]
private VFXOperatorUtility.SequentialAddressingMode mode = VFXOperatorUtility.SequentialAddressingMode.Clamp;
[VFXSetting, SerializeField, Tooltip("Specifies which primitive part of the mesh to sample from.")]
private PlacementMode placementMode = PlacementMode.Vertex;
[VFXSetting, SerializeField, Tooltip("Specifies how to sample the surface of a triangle.")]
private SurfaceCoordinates surfaceCoordinates = SurfaceCoordinates.Uniform;
[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), SerializeField, Tooltip("Specifies the kind of geometry to sample from.")]
private SourceType source = SourceType.Mesh;
private bool HasOutput(VertexAttributeFlag flag)
{
return (output & flag) == flag;
}
private IEnumerable<VertexAttribute> GetOutputVertexAttributes()
{
var vertexAttributes = Enum.GetValues(typeof(VertexAttributeFlag)).Cast<VertexAttributeFlag>();
foreach (var vertexAttribute in vertexAttributes)
if (vertexAttribute != VertexAttributeFlag.None && HasOutput(vertexAttribute))
yield return GetActualVertexAttribute(vertexAttribute);
}
private static Type GetOutputType(VertexAttribute attribute)
{
switch (attribute)
{
case VertexAttribute.Position: return typeof(Vector3);
case VertexAttribute.Normal: return typeof(Vector3);
case VertexAttribute.Tangent: return typeof(Vector4);
case VertexAttribute.Color: return typeof(Vector4);
case VertexAttribute.TexCoord0:
case VertexAttribute.TexCoord1:
case VertexAttribute.TexCoord2:
case VertexAttribute.TexCoord3:
case VertexAttribute.TexCoord4:
case VertexAttribute.TexCoord5:
case VertexAttribute.TexCoord6:
case VertexAttribute.TexCoord7: return typeof(Vector4);
case VertexAttribute.BlendWeight: return typeof(Vector4);
case VertexAttribute.BlendIndices: return typeof(Vector4);
default: throw new InvalidOperationException("Unexpected attribute : " + attribute);
}
}
private static VertexAttribute GetActualVertexAttribute(VertexAttributeFlag attribute)
{
switch (attribute)
{
case VertexAttributeFlag.Position: return VertexAttribute.Position;
case VertexAttributeFlag.Normal: return VertexAttribute.Normal;
case VertexAttributeFlag.Tangent: return VertexAttribute.Tangent;
case VertexAttributeFlag.Color: return VertexAttribute.Color;
case VertexAttributeFlag.TexCoord0: return VertexAttribute.TexCoord0;
case VertexAttributeFlag.TexCoord1: return VertexAttribute.TexCoord1;
case VertexAttributeFlag.TexCoord2: return VertexAttribute.TexCoord2;
case VertexAttributeFlag.TexCoord3: return VertexAttribute.TexCoord3;
case VertexAttributeFlag.TexCoord4: return VertexAttribute.TexCoord4;
case VertexAttributeFlag.TexCoord5: return VertexAttribute.TexCoord5;
case VertexAttributeFlag.TexCoord6: return VertexAttribute.TexCoord6;
case VertexAttributeFlag.TexCoord7: return VertexAttribute.TexCoord7;
case VertexAttributeFlag.BlendWeight: return VertexAttribute.BlendWeight;
case VertexAttributeFlag.BlendIndices: return VertexAttribute.BlendIndices;
default: throw new InvalidOperationException("Unexpected attribute : " + attribute);
}
}
protected override IEnumerable<string> filteredOutSettings
{
get
{
foreach (var settings in base.filteredOutSettings)
yield return settings;
if (placementMode != PlacementMode.Surface)
yield return nameof(surfaceCoordinates);
}
}
protected sealed override IEnumerable<VFXPropertyWithValue> inputProperties
{
get
{
var props = base.inputProperties;
if (source == SourceType.Mesh)
props = props.Concat(PropertiesFromType(nameof(InputPropertiesMesh)));
else if (source == SourceType.SkinnedMeshRenderer)
props = props.Concat(PropertiesFromType(nameof(InputPropertiesSkinnedMeshRenderer)));
else
throw new InvalidOperationException("Unexpected source type : " + source);
if (placementMode == PlacementMode.Vertex)
props = props.Concat(PropertiesFromType(nameof(InputPropertiesPlacementVertex)));
else if (placementMode == PlacementMode.Surface)
{
if (surfaceCoordinates == SurfaceCoordinates.Barycentric)
props = props.Concat(PropertiesFromType(nameof(InputPropertiesPlacementSurfaceBarycentricCoordinates)));
else if (surfaceCoordinates == SurfaceCoordinates.Uniform)
props = props.Concat(PropertiesFromType(nameof(InputPropertiesPlacementSurfaceLowDistorsionMapping)));
else
throw new InvalidOperationException("Unexpected surfaceCoordinates : " + surfaceCoordinates);
}
else if (placementMode == PlacementMode.Edge)
props = props.Concat(PropertiesFromType(nameof(InputPropertiesEdge)));
else
throw new InvalidOperationException("Unexpected placementMode : " + placementMode);
return props;
}
}
protected override IEnumerable<VFXPropertyWithValue> outputProperties
{
get
{
foreach (var vertexAttribute in GetOutputVertexAttributes())
{
var outputType = GetOutputType(vertexAttribute);
yield return new VFXPropertyWithValue(new VFXProperty(outputType, vertexAttribute.ToString()));
}
}
}
public static IEnumerable<VFXExpression> SampleVertexAttribute(VFXExpression source, VFXExpression vertexIndex, IEnumerable<VertexAttribute> vertexAttributes)
{
bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer;
var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source);
foreach (var vertexAttribute in vertexAttributes)
{
var channelIndex = VFXValue.Constant<uint>((uint)vertexAttribute);
var meshVertexStride = new VFXExpressionMeshVertexStride(mesh, channelIndex);
var meshChannelOffset = new VFXExpressionMeshChannelOffset(mesh, channelIndex);
var outputType = GetOutputType(vertexAttribute);
VFXExpression sampled = null;
var meshChannelFormatAndDimension = new VFXExpressionMeshChannelInfos(mesh, channelIndex);
var vertexOffset = vertexIndex * meshVertexStride + meshChannelOffset;
if (!skinnedMesh)
{
if (vertexAttribute == VertexAttribute.Color)
sampled = new VFXExpressionSampleMeshColor(source, vertexOffset, meshChannelFormatAndDimension);
else if (outputType == typeof(float))
sampled = new VFXExpressionSampleMeshFloat(source, vertexOffset, meshChannelFormatAndDimension);
else if (outputType == typeof(Vector2))
sampled = new VFXExpressionSampleMeshFloat2(source, vertexOffset, meshChannelFormatAndDimension);
else if (outputType == typeof(Vector3))
sampled = new VFXExpressionSampleMeshFloat3(source, vertexOffset, meshChannelFormatAndDimension);
else
sampled = new VFXExpressionSampleMeshFloat4(source, vertexOffset, meshChannelFormatAndDimension);
}
else
{
if (vertexAttribute == VertexAttribute.Color)
sampled = new VFXExpressionSampleSkinnedMeshRendererColor(source, vertexOffset, meshChannelFormatAndDimension);
else if (outputType == typeof(float))
sampled = new VFXExpressionSampleSkinnedMeshRendererFloat(source, vertexOffset, meshChannelFormatAndDimension);
else if (outputType == typeof(Vector2))
sampled = new VFXExpressionSampleSkinnedMeshRendererFloat2(source, vertexOffset, meshChannelFormatAndDimension);
else if (outputType == typeof(Vector3))
sampled = new VFXExpressionSampleSkinnedMeshRendererFloat3(source, vertexOffset, meshChannelFormatAndDimension);
else
sampled = new VFXExpressionSampleSkinnedMeshRendererFloat4(source, vertexOffset, meshChannelFormatAndDimension);
}
yield return sampled;
}
}
public static IEnumerable<VFXExpression> SampleVertexAttribute(VFXExpression source, VFXExpression vertexIndex, VFXOperatorUtility.SequentialAddressingMode mode, IEnumerable<VertexAttribute> vertexAttributes)
{
bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer;
var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source);
var meshVertexCount = new VFXExpressionMeshVertexCount(mesh);
vertexIndex = VFXOperatorUtility.ApplyAddressingMode(vertexIndex, meshVertexCount, mode);
return SampleVertexAttribute(source, vertexIndex, vertexAttributes);
}
public static IEnumerable<VFXExpression> SampleEdgeAttribute(VFXExpression source, VFXExpression index, VFXExpression lerp, IEnumerable<VertexAttribute> vertexAttributes)
{
bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer;
var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source);
var meshIndexFormat = new VFXExpressionMeshIndexFormat(mesh);
var oneInt = VFXOperatorUtility.OneExpression[UnityEngine.VFX.VFXValueType.Int32];
var oneUint = VFXOperatorUtility.OneExpression[UnityEngine.VFX.VFXValueType.Uint32];
var threeUint = VFXOperatorUtility.ThreeExpression[UnityEngine.VFX.VFXValueType.Uint32];
var nextIndex = index + oneUint;
//Loop triangle
var loop = VFXOperatorUtility.Modulo(nextIndex, threeUint);
var predicat = new VFXExpressionCondition(UnityEngine.VFX.VFXValueType.Uint32, VFXCondition.NotEqual, loop, VFXOperatorUtility.ZeroExpression[UnityEngine.VFX.VFXValueType.Uint32]);
nextIndex = new VFXExpressionBranch(predicat, nextIndex, nextIndex - threeUint);
var sampledIndex_A = new VFXExpressionSampleIndex(mesh, index, meshIndexFormat);
var sampledIndex_B = new VFXExpressionSampleIndex(mesh, nextIndex, meshIndexFormat);
var sampling_A = SampleVertexAttribute(source, sampledIndex_A, vertexAttributes).ToArray();
var sampling_B = SampleVertexAttribute(source, sampledIndex_B, vertexAttributes).ToArray();
for (int i = 0; i < vertexAttributes.Count(); ++i)
{
var outputValueType = sampling_A[i].valueType;
var s = VFXOperatorUtility.CastFloat(lerp, outputValueType);
yield return VFXOperatorUtility.Lerp(sampling_A[i], sampling_B[i], s);
}
}
public static IEnumerable<VFXExpression> SampleEdgeAttribute(VFXExpression source, VFXExpression index, VFXExpression x, VFXOperatorUtility.SequentialAddressingMode mode, IEnumerable<VertexAttribute> vertexAttributes)
{
bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer;
var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source);
var meshIndexCount = new VFXExpressionMeshIndexCount(mesh);
index = VFXOperatorUtility.ApplyAddressingMode(index, meshIndexCount, mode);
return SampleEdgeAttribute(source, index, x, vertexAttributes);
}
public static IEnumerable<VFXExpression> SampleTriangleAttribute(VFXExpression source, VFXExpression triangleIndex, VFXExpression coord, SurfaceCoordinates coordMode, IEnumerable<VertexAttribute> vertexAttributes)
{
bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer;
var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source);
var meshIndexCount = new VFXExpressionMeshIndexCount(mesh);
var meshIndexFormat = new VFXExpressionMeshIndexFormat(mesh);
var threeUint = VFXOperatorUtility.ThreeExpression[UnityEngine.VFX.VFXValueType.Uint32];
var baseIndex = triangleIndex * threeUint;
var sampledIndex_A = new VFXExpressionSampleIndex(mesh, baseIndex, meshIndexFormat);
var sampledIndex_B = new VFXExpressionSampleIndex(mesh, baseIndex + VFXValue.Constant<uint>(1u), meshIndexFormat);
var sampledIndex_C = new VFXExpressionSampleIndex(mesh, baseIndex + VFXValue.Constant<uint>(2u), meshIndexFormat);
var allInputValues = new List<VFXExpression>();
var sampling_A = SampleVertexAttribute(source, sampledIndex_A, vertexAttributes).ToArray();
var sampling_B = SampleVertexAttribute(source, sampledIndex_B, vertexAttributes).ToArray();
var sampling_C = SampleVertexAttribute(source, sampledIndex_C, vertexAttributes).ToArray();
VFXExpression barycentricCoordinates = null;
var one = VFXOperatorUtility.OneExpression[UnityEngine.VFX.VFXValueType.Float];
if (coordMode == SurfaceCoordinates.Barycentric)
{
var barycentricCoordinateInput = coord;
barycentricCoordinates = new VFXExpressionCombine(barycentricCoordinateInput.x, barycentricCoordinateInput.y, one - barycentricCoordinateInput.x - barycentricCoordinateInput.y);
}
else if (coordMode == SurfaceCoordinates.Uniform)
{
//https://hal.archives-ouvertes.fr/hal-02073696v2/document
var input = coord;
var half2 = VFXOperatorUtility.HalfExpression[UnityEngine.VFX.VFXValueType.Float2];
var zero = VFXOperatorUtility.ZeroExpression[UnityEngine.VFX.VFXValueType.Float];
var t = input * half2;
var offset = t.y - t.x;
var pred = new VFXExpressionCondition(UnityEngine.VFX.VFXValueType.Float, VFXCondition.Greater, offset, zero);
var t2 = new VFXExpressionBranch(pred, t.y + offset, t.y);
var t1 = new VFXExpressionBranch(pred, t.x, t.x - offset);
var t3 = one - t2 - t1;
barycentricCoordinates = new VFXExpressionCombine(t1, t2, t3);
/* Possible variant See http://inis.jinr.ru/sl/vol1/CMC/Graphics_Gems_1,ed_A.Glassner.pdf (p24) uniform distribution from two numbers in triangle generating barycentric coordinate
var input = VFXOperatorUtility.Saturate(inputExpression[2]);
var s = input.x;
var t = VFXOperatorUtility.Sqrt(input.y);
var a = one - t;
var b = (one - s) * t;
var c = s * t;
barycentricCoordinates = new VFXExpressionCombine(a, b, c);
*/
}
else
{
throw new InvalidOperationException("No supported surfaceCoordinates : " + coord);
}
for (int i = 0; i < vertexAttributes.Count(); ++i)
{
var outputValueType = sampling_A[i].valueType;
var barycentricCoordinateX = VFXOperatorUtility.CastFloat(barycentricCoordinates.x, outputValueType);
var barycentricCoordinateY = VFXOperatorUtility.CastFloat(barycentricCoordinates.y, outputValueType);
var barycentricCoordinateZ = VFXOperatorUtility.CastFloat(barycentricCoordinates.z, outputValueType);
var r = sampling_A[i] * barycentricCoordinateX + sampling_B[i] * barycentricCoordinateY + sampling_C[i] * barycentricCoordinateZ;
yield return r;
}
}
public static IEnumerable<VFXExpression> SampleTriangleAttribute(VFXExpression source, VFXExpression triangleIndex, VFXExpression coord, VFXOperatorUtility.SequentialAddressingMode mode, SurfaceCoordinates coordMode, IEnumerable<VertexAttribute> vertexAttributes)
{
bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer;
var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source);
var UintThree = VFXOperatorUtility.ThreeExpression[UnityEngine.VFX.VFXValueType.Uint32];
var meshIndexCount = new VFXExpressionMeshIndexCount(mesh);
var triangleCount = meshIndexCount / UintThree;
triangleIndex = VFXOperatorUtility.ApplyAddressingMode(triangleIndex, triangleCount, mode);
return SampleTriangleAttribute(source, triangleIndex, coord, coordMode, vertexAttributes);
}
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
{
VFXExpression[] outputExpressions = null;
if (placementMode == PlacementMode.Vertex)
{
var sampled = SampleVertexAttribute(inputExpression[0], inputExpression[1], mode, GetOutputVertexAttributes());
outputExpressions = sampled.ToArray();
}
else if (placementMode == PlacementMode.Edge)
{
var sampled = SampleEdgeAttribute(inputExpression[0], inputExpression[1], inputExpression[2], mode, GetOutputVertexAttributes());
outputExpressions = sampled.ToArray();
}
else if (placementMode == PlacementMode.Surface)
{
var sampled = SampleTriangleAttribute(inputExpression[0], inputExpression[1], inputExpression[2], mode, surfaceCoordinates, GetOutputVertexAttributes());
outputExpressions = sampled.ToArray();
}
else
{
throw new InvalidOperationException("Not supported placement mode " + placementMode);
}
return outputExpressions;
}
}
}
| 50.574236 | 271 | 0.641886 | [
"MIT"
] | Reality-Hack-2022/TEAM-52 | unity-visualeffectgraph-builtin-main/Editor/Models/Operators/Implementations/SampleMesh.cs | 23,163 | 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.Runtime.InteropServices;
namespace System.Security.Cryptography.X509Certificates.Tests
{
//
// Helper class centralizes all loading of PFX's. Loading PFX's is a problem because of the key on disk that it creates and gets left behind
// if the certificate isn't properly disposed. Properly disposing PFX's imported into a X509Certificate2Collection is a pain because X509Certificate2Collection
// doesn't implement IDisposable. To make this easier, we wrap these in an ImportedCollection class that does implement IDisposable.
//
internal static class Cert
{
// netstandard: DefaultKeySet
// netcoreapp-OSX: DefaultKeySet
// netcoreapp-other: EphemeralKeySet
internal static readonly X509KeyStorageFlags EphemeralIfPossible =
!RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? X509KeyStorageFlags.EphemeralKeySet :
X509KeyStorageFlags.DefaultKeySet;
//
// The Import() methods have an overload for each X509Certificate2Collection.Import() overload.
//
// Do not refactor this into a call to Import(byte[], string, X509KeyStorageFlags). The test meant to exercise
// the api that takes only one argument.
public static ImportedCollection Import(byte[] rawData)
{
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(rawData);
return new ImportedCollection(collection);
}
public static ImportedCollection Import(byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(rawData, password, keyStorageFlags);
return new ImportedCollection(collection);
}
// Do not refactor this into a call to Import(string, string, X509KeyStorageFlags). The test meant to exercise
// the api that takes only one argument.
public static ImportedCollection Import(string fileName)
{
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(fileName);
return new ImportedCollection(collection);
}
public static ImportedCollection Import(string fileName, string password, X509KeyStorageFlags keyStorageFlags)
{
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(fileName, password, keyStorageFlags);
return new ImportedCollection(collection);
}
}
//
// Wraps an X509Certificate2Collection in an IDisposable for easier cleanup.
//
internal sealed class ImportedCollection : IDisposable
{
public ImportedCollection(X509Certificate2Collection collection)
{
// Make an independent copy of the certs to dispose (in case the test mutates the collection after we return.)
_certs = new X509Certificate2[collection.Count];
collection.CopyTo(_certs, 0);
Collection = collection;
}
public X509Certificate2Collection Collection { get; }
public void Dispose()
{
if (_certs != null)
{
foreach (X509Certificate2 cert in _certs)
{
cert.Dispose();
}
_certs = null;
}
}
private X509Certificate2[] _certs;
}
}
| 41.722222 | 164 | 0.670573 | [
"MIT"
] | AlexGhiondea/corefx | src/System.Security.Cryptography.X509Certificates/tests/Cert.cs | 3,755 | C# |
using System;
using Grpc.Net.Client;
namespace GrpcEventsComponents
{
public class ClientBase
{
protected readonly GrpcChannel _channel;
protected readonly string _serviceBaseUrl;
public ClientBase(string baseUrl)
{
_serviceBaseUrl = baseUrl;
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
_channel = GrpcChannel.ForAddress(_serviceBaseUrl);
}
}
} | 23.055556 | 92 | 0.783133 | [
"MIT"
] | aurlaw/GrpcEventsDemo | GrpcEventsComponents/ClientBase.cs | 417 | 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.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32)]
public static partial BOOL EndPath(HDC hdc);
}
}
| 28.8 | 71 | 0.731481 | [
"MIT"
] | Olina-Zhang/winforms | src/System.Windows.Forms.Primitives/src/Interop/Gdi32/Interop.EndPath.cs | 434 | C# |
using System;
namespace Vk.CSharp.Sdk.Global.Exceptions
{
/// <summary>
/// Исключение, выбрасываемое при неверном или отсутствующем ключе доступа.
/// </summary>
public class InvalidAccessTokenException : Exception
{
public InvalidAccessTokenException() { }
public InvalidAccessTokenException(string message)
: base(message) { }
public InvalidAccessTokenException(string message, Exception inner)
: base(message, inner) { }
}
} | 28 | 79 | 0.666667 | [
"MIT"
] | fossabot/vk-csharp-sdk | src/Core/Vk.CSharp.Sdk/Vk.CSharp.Sdk/Global/Exceptions/InvalidAccessTokenException.cs | 568 | C# |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using Datos;
namespace Negocios
{
public class RegistroRespaldo:CollectionBase
{
respaldo _oRespaldo = new respaldo();
public bool respaldar(string nombre,string dispositivo,DateTime fecha,string carpeta)//publica el metodo Buscar del tipo Producto que lleva la variable clave de tipo entero
{
try
{
_oRespaldo.respaldar(nombre,fecha,dispositivo,carpeta);
return true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public void respaldarRapido(/*string directorio*/)//publica el metodo Buscar del tipo Producto que lleva la variable clave de tipo entero
{
try
{
//_oRespaldo.respaldoRapido(/*directorio*/);
////return true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public bool restaurarRapido(string directorio)//publica el metodo Buscar del tipo Producto que lleva la variable clave de tipo entero
{
try
{
_oRespaldo.restauracionRapida(directorio);
return true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public bool restaurar(string nombre, string dispositivo, string carpeta)//publica el metodo Buscar del tipo Producto que lleva la variable clave de tipo entero
{
try
{
_oRespaldo.restaurar(nombre, dispositivo, carpeta);
return true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}
| 29.086957 | 181 | 0.527155 | [
"Apache-2.0"
] | RSSFrancisco/sistema-punto-de-venta | Negocios/Backup/RegistroRespaldo.cs | 2,009 | C# |
#nullable enable
using Content.Server.GameObjects.Components.Atmos;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions;
using Content.Shared.Alert;
using Content.Shared.GameObjects.Components;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.GameObjects.Verbs;
using Content.Shared.Interfaces.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.ComponentDependencies;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
namespace Content.Server.GameObjects.Components
{
[RegisterComponent]
[ComponentReference(typeof(IActivate))]
public sealed class MagbootsComponent : SharedMagbootsComponent, IUnequipped, IEquipped, IUse, IActivate
{
[ComponentDependency] private ItemComponent? _item = null;
[ComponentDependency] private ItemActionsComponent? _itemActions = null;
[ComponentDependency] private SpriteComponent? _sprite = null;
private bool _on;
[ViewVariables]
public override bool On
{
get => _on;
set
{
_on = value;
UpdateContainer();
_itemActions?.Toggle(ItemActionType.ToggleMagboots, On);
if (_item != null)
_item.EquippedPrefix = On ? "on" : null;
_sprite?.LayerSetState(0, On ? "icon-on" : "icon");
OnChanged();
Dirty();
}
}
public void Toggle(IEntity user)
{
On = !On;
}
void IUnequipped.Unequipped(UnequippedEventArgs eventArgs)
{
if (On && eventArgs.Slot == Slots.SHOES)
{
if (eventArgs.User.TryGetComponent(out MovedByPressureComponent? movedByPressure))
{
movedByPressure.Enabled = true;
}
if (eventArgs.User.TryGetComponent(out ServerAlertsComponent? alerts))
{
alerts.ClearAlert(AlertType.Magboots);
}
}
}
void IEquipped.Equipped(EquippedEventArgs eventArgs)
{
UpdateContainer();
}
private void UpdateContainer()
{
if (!Owner.TryGetContainer(out var container))
return;
if (container.Owner.TryGetComponent(out InventoryComponent? inventoryComponent)
&& inventoryComponent.GetSlotItem(Slots.SHOES)?.Owner == Owner)
{
if (container.Owner.TryGetComponent(out MovedByPressureComponent? movedByPressure))
{
movedByPressure.Enabled = false;
}
if (container.Owner.TryGetComponent(out ServerAlertsComponent? alerts))
{
if (On)
{
alerts.ShowAlert(AlertType.Magboots);
}
else
{
alerts.ClearAlert(AlertType.Magboots);
}
}
}
}
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
Toggle(eventArgs.User);
return true;
}
void IActivate.Activate(ActivateEventArgs eventArgs)
{
Toggle(eventArgs.User);
}
public override ComponentState GetComponentState()
{
return new MagbootsComponentState(On);
}
[UsedImplicitly]
public sealed class ToggleMagbootsVerb : Verb<MagbootsComponent>
{
protected override void GetData(IEntity user, MagbootsComponent component, VerbData data)
{
if (!ActionBlockerSystem.CanInteract(user))
{
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Text = Loc.GetString("Toggle Magboots");
}
protected override void Activate(IEntity user, MagbootsComponent component)
{
component.Toggle(user);
}
}
}
[UsedImplicitly]
public sealed class ToggleMagbootsAction : IToggleItemAction
{
public void ExposeData(ObjectSerializer serializer) { }
public bool DoToggleAction(ToggleItemActionEventArgs args)
{
if (!args.Item.TryGetComponent<MagbootsComponent>(out var magboots))
return false;
magboots.Toggle(args.Performer);
return true;
}
}
}
| 32.139241 | 108 | 0.589996 | [
"MIT"
] | Sweptstation/space-station-14 | Content.Server/GameObjects/Components/MagbootsComponent.cs | 5,080 | C# |
using Pgshardnet.Exceptions;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Polly;
using System.Collections.Concurrent;
using System.Data.Common;
using System.Data.Odbc;
using System.Diagnostics;
namespace Pgshardnet
{
public class ShardingManager
{
LogicalShard[] shards;
List<PhysicalShard> physicalShards;
public enum ShardSelector { OneRandomShard, AllShards };
public static string Conv<T>(T obj, bool dontConvertNumeric=false, int stringLengthCrop=0)
{
if (obj == null)
{
return "NULL";
}
if (!dontConvertNumeric)
{
if (typeof(decimal) == obj.GetType())
{
decimal value = (decimal)(object)obj;
return Math.Round((Math.Round(value, 2) * 100), 0).ToString();
}
if (typeof(double) == obj.GetType())
{
double value = (double)(object)obj;
return Math.Round((Math.Round(value, 2) * 100), 0).ToString();
}
if (typeof(float) == obj.GetType())
{
float value = (float)(object)obj;
return Math.Round((Math.Round(value, 2) * 100), 0).ToString();
}
}
if (typeof(bool) == obj.GetType())
{
var value = ((bool)(object)obj);
if (value) { return "TRUE"; }
else { return "FALSE"; }
}
if (typeof(DateTime) == obj.GetType())
{
var value = ((DateTime)(object)obj);
return value.ToString("yyyy-MM-dd HH:mm:ss");
}
if (typeof(string) == obj.GetType() || typeof(String)==obj.GetType())
{
string value = (string)(object)obj;
if (stringLengthCrop > 0 && value.Length > stringLengthCrop) value = value.Substring(0, stringLengthCrop);
string newValue = value;
if (value.Contains("'"))
{
do
{
value = value.Replace("''", "'");
} while (value.Contains("''"));
newValue= value.Replace("'", "''");
}
else { newValue= value; }
return newValue;
}
else
{
return obj.ToString();
}
}
public LogicalShard[] GetLogicalShards() { return shards; }
public List<PhysicalShard> GetPhysicalShards() { return physicalShards; }
public ShardingManager(List<PhysicalShard> physicalShards, List<LogicalShard> logicalShards)
{
this.shards = logicalShards.ToArray();
this.physicalShards = physicalShards;
ThreadPool.SetMinThreads(shards.Length, shards.Length);
}
public LogicalShard GetShardByshardingKey(long shardingKey)
{
return shards[shardingKey % shards.Length];
}
public IDbConnection GetConnectionByshardingKey(long shardingKey)
{
return shards[shardingKey % shards.Length].physicalShard.GetConnection();
}
public IDbCommand GetCommand()
{
return new OdbcCommand();
}
public int ExecuteNonQueryShard(long shardingKey, IDbCommand command)
{
using (var conn = GetConnectionByshardingKey(shardingKey))
{
command.Connection = conn;
command.CommandText = SchemaSelect(shardingKey) + command.CommandText;
OpenConnection(conn);
return command.ExecuteNonQuery();
}
}
public int ExecuteNonQueriesShard(long shardingKey, List<IDbCommand> commands)
{
int result = -1;
using (var conn = GetConnectionByshardingKey(shardingKey))
{
OpenConnection(conn);
using (var tran = conn.BeginTransaction())
{
using (var command = conn.CreateCommand())
{
command.Connection = conn;
command.Transaction = tran;
foreach (var inputCommand in commands)
{
try
{
command.CommandText = SchemaSelect(shardingKey) + inputCommand.CommandText;
result += command.ExecuteNonQuery();
}
catch (Exception e)
{
if (tran != null) tran.Rollback();
throw;
}
}
}
tran.Commit();
}
conn.Close();
}
return result;
}
public int ExecuteNonQueryShard(LogicalShard shard, IDbCommand command)
{
using (var conn = shard.physicalShard.GetConnection())
{
OpenConnection(conn);
command.Connection = conn;
command.CommandText = SchemaSelectByShard(shard.id) + command.CommandText;
int res=command.ExecuteNonQuery();
return res;
}
}
public int ExecuteNonQueryAllShards(IDbCommand command)
{
var exceptions = new ConcurrentQueue<Exception>();
ConcurrentStack<int> result = new ConcurrentStack<int>();
var lshards = GetLogicalShards();
var pshards = GetPhysicalShards();
var state = new ParallelOptions();
state.MaxDegreeOfParallelism = pshards.Count();
// iterate thru phycical shards in parallel.
Parallel.ForEach(pshards, state, physicalshard =>
{
try
{
// select all logical shards in physical one
var shardsByPhysical = lshards.Where(x => x.physicalShard == physicalshard).ToArray();
for (int i = 0; i < shardsByPhysical.Length; i++)
{
var lshard = shardsByPhysical[i];
using (var conn = physicalshard.GetConnection())
{
OpenConnection(conn);
var insideCommand = conn.CreateCommand();
insideCommand.CommandText = SchemaSelectByShard(lshard.id) + command.CommandText;
insideCommand.Parameters.AddRange(CloneParameters(command));
insideCommand.CommandTimeout = command.CommandTimeout;
int queryResult = insideCommand.ExecuteNonQuery();
result.Push(queryResult);
}
}
}
catch (Exception e)
{
exceptions.Enqueue(e);
}
});
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
return result.Sum();
}
public int ExecuteNonQueryPhysicalCommon(IDbCommand command, bool forceIntegrity = true)
{
var exceptions = new ConcurrentQueue<Exception>();
object _lock = new object();
List<WaitHandle> handles = new List<WaitHandle>();
List<int> resultList = new List<int>();
var state = new ParallelOptions();
state.MaxDegreeOfParallelism = physicalShards.Count();
List<dynamic> shardsToExecute = new List<dynamic>();
foreach (var physShard in physicalShards)
{
ManualResetEvent e = new ManualResetEvent(false);
handles.Add(e);
shardsToExecute.Add(new { resetEvent = e, shard = physShard });
}
Parallel.ForEach(shardsToExecute, state, item =>
{
try
{
PhysicalShard physicalshard = item.shard;
ManualResetEvent e = item.resetEvent;
using (var conn = physicalshard.GetConnection())
{
OpenConnection(conn);
using (var transaction = conn.BeginTransaction())
{
var insideCommand = conn.CreateCommand();
insideCommand.CommandText = SchemaSelectCommon() + command.CommandText;
insideCommand.Parameters.AddRange(CloneParameters(command));
insideCommand.CommandTimeout = command.CommandTimeout;
insideCommand.Transaction = transaction;
var affectedCount = insideCommand.ExecuteNonQuery();
resultList.Add(affectedCount);
// commiting only after all shards executed properly
e.Set();
if (WaitHandle.WaitAll(handles.ToArray(), command.CommandTimeout * 1000))
{
if (!forceIntegrity)
{
transaction.Commit();
}
else
{
// commit only if all results are equal
if (!resultList.Any(o => o != resultList[0]))
{
transaction.Commit();
}
else
{
transaction.Rollback();
throw new ShardedTransactionCommitException(String.Format("Affected rows number is not equal in all shards so it will be rolled back. \nQuery: {0}", command.CommandText));
}
}
}
else
{
transaction.Rollback();
throw new ShardedTransactionCommitException(String.Format("Query timed out on least one shard so it will be rolled back. \nQuery: {0}", command.CommandText));
}
}
conn.Close();
}
}
catch (Exception e)
{
exceptions.Enqueue(e);
}
});
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
else
{
return resultList[0];
}
}
public object ExecuteScalarShard(long shardingKey, IDbCommand command)
{
using (var conn = GetConnectionByshardingKey(shardingKey))
{
command.Connection = conn;
command.CommandText = SchemaSelect(shardingKey) + command.CommandText;
OpenConnection(conn);
return command.ExecuteScalar();
}
}
public object ExecuteScalarShard(LogicalShard shard, IDbCommand command)
{
using (var conn = shard.physicalShard.GetConnection())
{
command.Connection = conn;
command.CommandText = SchemaSelectByShard(shard.id) + command.CommandText;
OpenConnection(conn);
return command.ExecuteScalar();
}
}
public List<DataTable> ExecuteDataTableAllShards(IDbCommand command)
{
var exceptions = new ConcurrentQueue<Exception>();
var result = new ConcurrentStack<DataTable>();
List<Task> tasks = new List<Task>();
foreach (var lshard in shards)
{
tasks.Add(Task.Factory.StartNew(() =>
{
try
{
Stopwatch sw = new Stopwatch();
sw.Start();
using (var conn = lshard.physicalShard.GetConnection())
{
OpenConnection(conn);
var insideCommand = conn.CreateCommand();
insideCommand.CommandText = SchemaSelectByShard(lshard.id) + command.CommandText;
insideCommand.Parameters.AddRange(CloneParameters(command));
insideCommand.CommandTimeout = command.CommandTimeout;
using (var reader = insideCommand.ExecuteReader())
{
var dt = new DataTable();
dt.Load(reader);
result.Push(dt);
}
conn.Close();
}
}
catch (Exception e)
{
exceptions.Enqueue(e);
}
}));
}
Task.WaitAll(tasks.ToArray());
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
return result.ToList();
}
public DataTable ExecuteDataTablePhysicalCommon(IDbCommand command, bool checkIntegrity = true)
{
var exceptions = new ConcurrentQueue<Exception>();
var _lockObj = new object();
var result = new List<DataTable>();
var state = new ParallelOptions();
state.MaxDegreeOfParallelism = physicalShards.Count();
// when checking integrity, we will ask all shards and compare results. If not, ask just random shard.
List<PhysicalShard> physicalShardToQuery;
if (checkIntegrity)
{
physicalShardToQuery = new List<PhysicalShard>(physicalShards);
}
else
{
physicalShardToQuery = new List<PhysicalShard>();
Random rnd = new Random();
int randomShardId = rnd.Next(physicalShards.Count());
physicalShardToQuery.Add(physicalShards[randomShardId]);
}
Parallel.ForEach(physicalShards, state, physicalshard =>
{
try
{
using (var conn = physicalshard.GetConnection())
{
OpenConnection(conn);
var insideCommand = conn.CreateCommand();
insideCommand.CommandText = SchemaSelectCommon() + command.CommandText;
insideCommand.Parameters.AddRange(CloneParameters(command));
insideCommand.CommandTimeout = command.CommandTimeout;
using (var reader = insideCommand.ExecuteReader())
{
var dt = new DataTable("Result"); //name is required for xml serialized used below
dt.Load(reader);
lock (_lockObj)
{
result.Add(dt);
}
}
conn.Close();
}
}
catch (Exception e)
{
exceptions.Enqueue(e);
}
});
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
if (checkIntegrity)
{
if (result.Count() > 0)
{
List<string> hashList = new List<string>();
MD5 hash = MD5.Create();
foreach (var ds in result)
{
using (var stream = new MemoryStream())
{
ds.WriteXml(stream);
stream.Position = 0;
var hs = hash.ComputeHash(stream);
var str = BitConverter.ToString(hs);
hashList.Add(str);
}
}
if (hashList.Any(o => o != hashList[0]))
{
throw new DataNotIntegralException(String.Format("Query results are not equal in all shards. Query: {0}", command.CommandText));
}
}
}
if (result.Count() > 0)
{
return result[0];
}
else
{
return null;
}
}
public void ExecuteReaderAllShards(IDbCommand command, Action<IDataReader> callback)
{
var exceptions = new ConcurrentQueue<Exception>();
var state = new ParallelOptions();
state.MaxDegreeOfParallelism = physicalShards.Count();
Parallel.ForEach(shards, state, lshard =>
{
try
{
using (var conn = lshard.physicalShard.GetConnection())
{
OpenConnection(conn);
var insideCommand = conn.CreateCommand();
insideCommand.CommandText = SchemaSelectByShard(lshard.id) + command.CommandText;
insideCommand.Parameters.AddRange(CloneParameters(command));
insideCommand.CommandTimeout = command.CommandTimeout;
long rows = 0;
using (var reader = insideCommand.ExecuteReader())
{
while (reader.Read())
{
rows++;
callback(reader);
}
}
conn.Close();
}
}
catch (Exception e)
{
exceptions.Enqueue(e);
}
});
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
}
public void ExecuteReaderPhysicalCommon(IDbCommand command, Action<IDataReader> callback, ShardSelector selector=ShardSelector.OneRandomShard)
{
var exceptions = new ConcurrentQueue<Exception>();
Random rnd = new Random();
var physicalShardsToExecute = new List<PhysicalShard>();
if (selector == ShardSelector.OneRandomShard)
{
int randomShardId = rnd.Next(physicalShards.Count());
physicalShardsToExecute.Add(physicalShards[randomShardId]);
}
else
{
physicalShardsToExecute = this.physicalShards;
}
var state = new ParallelOptions();
state.MaxDegreeOfParallelism = physicalShards.Count();
Parallel.ForEach(physicalShardsToExecute, state, physicalshard =>
{
try
{
using (var conn = physicalshard.GetConnection())
{
OpenConnection(conn);
var insideCommand = conn.CreateCommand();
insideCommand.CommandText = SchemaSelectCommon() + command.CommandText;
insideCommand.Parameters.AddRange(CloneParameters(command));
insideCommand.CommandTimeout = command.CommandTimeout;
using (var reader = insideCommand.ExecuteReader())
{
while (reader.Read())
{
callback(reader);
}
}
conn.Close();
}
}
catch (Exception e)
{
exceptions.Enqueue(e);
}
});
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
}
private string SchemaSelect(long shardingKey)
{
return String.Format("SET search_path TO {0};", shards[shardingKey % shards.Length].name);
}
private string SchemaSelectByShard(int shardId)
{
return String.Format("SET search_path TO {0};", shards[shardId].name);
}
private string SchemaSelectCommon()
{
return String.Format("SET search_path TO {0};", "public");
}
private void OpenConnection(IDbConnection conn)
{
var policy = Policy
.Handle<OdbcException>(ex => ex.InnerException is System.TimeoutException)
.WaitAndRetry(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
policy.Execute(() =>
{
if (conn.State == ConnectionState.Closed) conn.Open();
});
}
private DbParameter[] CloneParameters(IDbCommand sourceCmd)
{
var parameters = sourceCmd.Parameters.Cast<DbParameter>();
var result=new List<DbParameter>();
foreach (DbParameter p in parameters)
{
var newParam = new OdbcParameter(p.ParameterName, p.DbType);
newParam.Value = p.Value;
newParam.Direction = p.Direction;
newParam.Size = p.Size;
result.Add(newParam);
}
return result.ToArray();
}
}
}
| 38.106209 | 212 | 0.446465 | [
"MIT"
] | adekmm/pgshardnet | pgshardnet/ShardingManager.cs | 23,323 | C# |
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Linq;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp.UnitTests;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.ExpressionEvaluator;
using Microsoft.CodeAnalysis.ExpressionEvaluator.UnitTests;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.VisualStudio.Debugger.Clr;
using Microsoft.VisualStudio.Debugger.Evaluation;
using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.UnitTests
{
public class DynamicTests : ExpressionCompilerTestBase
{
[Fact]
public void Local_Simple()
{
var source =
@"class C
{
static void M()
{
dynamic d = 1;
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, method.ReturnType.TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x01);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
.locals init (dynamic V_0) //d
IL_0000: ldloc.0
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void Local_Array()
{
var source =
@"class C
{
static void M()
{
dynamic[] d = new dynamic[1];
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, ((ArrayTypeSymbol)method.ReturnType).ElementType.TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x02);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
.locals init (dynamic[] V_0) //d
IL_0000: ldloc.0
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void Local_Generic()
{
var source =
@"class C
{
static void M()
{
System.Collections.Generic.List<dynamic> d = null;
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, ((NamedTypeSymbol)method.ReturnType).TypeArguments.Single().TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x02);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
.locals init (System.Collections.Generic.List<dynamic> V_0) //d
IL_0000: ldloc.0
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void LocalConstant_Simple()
{
var source =
@"class C
{
static void M()
{
const dynamic d = null;
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, method.ReturnType.TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x01);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedFlags: DkmClrCompilationResultFlags.ReadOnlyResult, expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldnull
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void LocalConstant_Array()
{
var source =
@"class C
{
static void M()
{
const dynamic[] d = null;
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, ((ArrayTypeSymbol)method.ReturnType).ElementType.TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x02);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedFlags: DkmClrCompilationResultFlags.ReadOnlyResult, expectedILOpt: @"
{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldnull
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void LocalConstant_Generic()
{
var source =
@"class C
{
static void M()
{
const Generic<dynamic> d = null;
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}
class Generic<T>
{
}
";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, ((NamedTypeSymbol)method.ReturnType).TypeArguments.Single().TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x02);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedFlags: DkmClrCompilationResultFlags.ReadOnlyResult, expectedILOpt: @"
{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldnull
IL_0001: ret
}");
locals.Free();
});
}
[WorkItem(4106, "https://github.com/dotnet/roslyn/issues/4106")]
[Fact]
public void LocalDuplicateConstantAndNonConstantDynamic()
{
var source =
@"class C
{
static void M()
{
{
#line 799
dynamic a = null;
const dynamic b = null;
}
{
const dynamic[] a = null;
#line 899
dynamic[] b = null;
}
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 799);
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(2, locals.Count);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[0], "a", 0x01);
}
else
{
VerifyCustomTypeInfo(locals[0], "a", null); // Dynamic info ignored because ambiguous.
}
VerifyCustomTypeInfo(locals[1], "b", 0x01);
locals.Free();
context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 899);
testData = new CompilationTestData();
locals = ArrayBuilder<LocalAndMethod>.GetInstance();
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(2, locals.Count);
VerifyCustomTypeInfo(locals[0], "b", 0x02);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[1], "a", 0x02);
}
else
{
VerifyCustomTypeInfo(locals[1], "a", null); // Dynamic info ignored because ambiguous.
}
locals.Free();
});
}
[WorkItem(4106, "https://github.com/dotnet/roslyn/issues/4106")]
[Fact]
public void LocalDuplicateConstantAndNonConstantNonDynamic()
{
var source =
@"class C
{
static void M()
{
{
#line 799
object a = null;
const dynamic b = null;
}
{
const dynamic[] a = null;
#line 899
object[] b = null;
}
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 799);
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(2, locals.Count);
VerifyCustomTypeInfo(locals[0], "a", null);
VerifyCustomTypeInfo(locals[1], "b", 0x01);
locals.Free();
context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 899);
testData = new CompilationTestData();
locals = ArrayBuilder<LocalAndMethod>.GetInstance();
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(2, locals.Count);
VerifyCustomTypeInfo(locals[0], "b", null);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[1], "a", 0x02);
}
else
{
VerifyCustomTypeInfo(locals[1], "a", null); // Dynamic info ignored because ambiguous.
}
locals.Free();
});
}
[WorkItem(4106, "https://github.com/dotnet/roslyn/issues/4106")]
[Fact]
public void LocalDuplicateConstantAndConstantDynamic()
{
var source =
@"class C
{
static void M()
{
{
const dynamic a = null;
const dynamic b = null;
#line 799
object e = null;
}
{
const dynamic[] a = null;
const dynamic[] c = null;
#line 899
object[] e = null;
}
{
#line 999
object e = null;
const dynamic a = null;
const dynamic c = null;
}
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 799);
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(3, locals.Count);
VerifyCustomTypeInfo(locals[0], "e", null);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[1], "a", 0x01);
}
else
{
VerifyCustomTypeInfo(locals[1], "a", null); // Dynamic info ignored because ambiguous.
}
VerifyCustomTypeInfo(locals[2], "b", 0x01);
locals.Free();
context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 899);
testData = new CompilationTestData();
locals = ArrayBuilder<LocalAndMethod>.GetInstance();
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(3, locals.Count);
VerifyCustomTypeInfo(locals[0], "e", null);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[1], "a", 0x02);
VerifyCustomTypeInfo(locals[2], "c", 0x02);
}
else
{
VerifyCustomTypeInfo(locals[1], "a", null); // Dynamic info ignored because ambiguous.
VerifyCustomTypeInfo(locals[2], "c", null); // Dynamic info ignored because ambiguous.
}
locals.Free();
context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 999);
testData = new CompilationTestData();
locals = ArrayBuilder<LocalAndMethod>.GetInstance();
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(3, locals.Count);
VerifyCustomTypeInfo(locals[0], "e", null);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[1], "a", 0x01);
VerifyCustomTypeInfo(locals[2], "c", 0x01);
}
else
{
VerifyCustomTypeInfo(locals[1], "a", null); // Dynamic info ignored because ambiguous.
VerifyCustomTypeInfo(locals[2], "c", null); // Dynamic info ignored because ambiguous.
}
locals.Free();
});
}
[WorkItem(4106, "https://github.com/dotnet/roslyn/issues/4106")]
[Fact]
public void LocalDuplicateConstantAndConstantNonDynamic()
{
var source =
@"class C
{
static void M()
{
{
const dynamic a = null;
const object c = null;
#line 799
object e = null;
}
{
const dynamic[] b = null;
#line 899
object[] e = null;
}
{
const object[] a = null;
#line 999
object e = null;
const dynamic[] c = null;
}
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 799);
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(3, locals.Count);
VerifyCustomTypeInfo(locals[0], "e", null);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[1], "a", 0x01);
}
else
{
VerifyCustomTypeInfo(locals[1], "a", null); // Dynamic info ignored because ambiguous.
}
VerifyCustomTypeInfo(locals[2], "c", null);
locals.Free();
context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 899);
testData = new CompilationTestData();
locals = ArrayBuilder<LocalAndMethod>.GetInstance();
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(2, locals.Count);
VerifyCustomTypeInfo(locals[0], "e", null);
VerifyCustomTypeInfo(locals[1], "b", 0x02);
locals.Free();
context = CreateMethodContext(runtime, methodName: "C.M", atLineNumber: 999);
testData = new CompilationTestData();
locals = ArrayBuilder<LocalAndMethod>.GetInstance();
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(3, locals.Count);
VerifyCustomTypeInfo(locals[0], "e", null);
VerifyCustomTypeInfo(locals[1], "a", null);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[2], "c", 0x02);
}
else
{
VerifyCustomTypeInfo(locals[2], "c", null); // Dynamic info ignored because ambiguous.
}
locals.Free();
});
}
[Fact]
public void LocalsWithLongAndShortNames()
{
var source =
@"class C
{
static void M()
{
const dynamic a123456789012345678901234567890123456789012345678901234567890123 = null; // 64 chars
const dynamic b = null;
dynamic c123456789012345678901234567890123456789012345678901234567890123 = null; // 64 chars
dynamic d = null;
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, methodName: "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(4, locals.Count);
if (runtime.DebugFormat == DebugInformationFormat.PortablePdb)
{
VerifyCustomTypeInfo(locals[0], "c123456789012345678901234567890123456789012345678901234567890123", 0x01);
VerifyCustomTypeInfo(locals[2], "a123456789012345678901234567890123456789012345678901234567890123", 0x01);
}
else
{
VerifyCustomTypeInfo(locals[0], "c123456789012345678901234567890123456789012345678901234567890123", null); // dynamic info dropped
VerifyCustomTypeInfo(locals[2], "a123456789012345678901234567890123456789012345678901234567890123", null); // dynamic info dropped
}
VerifyCustomTypeInfo(locals[1], "d", 0x01);
VerifyCustomTypeInfo(locals[3], "b", 0x01);
locals.Free();
});
}
[Fact]
public void Parameter_Simple()
{
var source =
@"class C
{
static void M(dynamic d)
{
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, method.ReturnType.TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x01);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void Parameter_Array()
{
var source =
@"class C
{
static void M(dynamic[] d)
{
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, ((ArrayTypeSymbol)method.ReturnType).ElementType.TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x02);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void Parameter_Generic()
{
var source =
@"class C
{
static void M(System.Collections.Generic.List<dynamic> d)
{
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
Assert.Equal(TypeKind.Dynamic, ((NamedTypeSymbol)method.ReturnType).TypeArguments.Single().TypeKind);
VerifyCustomTypeInfo(locals[0], "d", 0x02);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ret
}");
locals.Free();
});
}
[WorkItem(1087216, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1087216")]
[Fact]
public void ComplexDynamicType()
{
var source =
@"class C
{
static void M(Outer<dynamic[], object[]>.Inner<Outer<object, dynamic>[], dynamic> d)
{
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}
public class Outer<T, U>
{
public class Inner<V, W>
{
}
}
";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: true);
VerifyCustomTypeInfo(locals[0], "d", 0x04, 0x03);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ret
}");
string error;
var result = context.CompileExpression("d", out error);
Assert.Null(error);
VerifyCustomTypeInfo(result, 0x04, 0x03);
// Note that the method produced by CompileAssignment returns void
// so there is never custom type info.
result = context.CompileAssignment("d", "d", out error);
Assert.Null(error);
VerifyCustomTypeInfo(result, null);
ResultProperties resultProperties;
ImmutableArray<AssemblyIdentity> missingAssemblyIdentities;
testData = new CompilationTestData();
result = context.CompileExpression(
"var dd = d;",
DkmEvaluationFlags.None,
NoAliases,
DebuggerDiagnosticFormatter.Instance,
out resultProperties,
out error,
out missingAssemblyIdentities,
EnsureEnglishUICulture.PreferredOrNull,
testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, null);
Assert.Equal(resultProperties.Flags, DkmClrCompilationResultFlags.PotentialSideEffect | DkmClrCompilationResultFlags.ReadOnlyResult);
testData.GetMethodData("<>x.<>m0").VerifyIL(
@"{
// Code size 60 (0x3c)
.maxstack 6
IL_0000: ldtoken ""Outer<dynamic[], object[]>.Inner<Outer<object, dynamic>[], dynamic>""
IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_000a: ldstr ""dd""
IL_000f: ldstr ""108766ce-df68-46ee-b761-0dcb7ac805f1""
IL_0014: newobj ""System.Guid..ctor(string)""
IL_0019: ldc.i4.3
IL_001a: newarr ""byte""
IL_001f: dup
IL_0020: ldtoken ""<PrivateImplementationDetails>.__StaticArrayInitTypeSize=3 <PrivateImplementationDetails>.A4E591DA7617172655FE45FC3878ECC8CC0D44B3""
IL_0025: call ""void System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray(System.Array, System.RuntimeFieldHandle)""
IL_002a: call ""void Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.CreateVariable(System.Type, string, System.Guid, byte[])""
IL_002f: ldstr ""dd""
IL_0034: call ""Outer<dynamic[], object[]>.Inner<Outer<object, dynamic>[], dynamic> Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<Outer<dynamic[], object[]>.Inner<Outer<object, dynamic>[], dynamic>>(string)""
IL_0039: ldarg.0
IL_003a: stind.ref
IL_003b: ret
}");
locals.Free();
});
}
[Fact]
public void DynamicAliases()
{
var source =
@"class C
{
static void M()
{
}
static dynamic ForceDynamicAttribute()
{
return null;
}
}";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(
runtime,
"C.M");
var aliases = ImmutableArray.Create(
Alias(
DkmClrAliasKind.Variable,
"d1",
"d1",
typeof(object).AssemblyQualifiedName,
MakeCustomTypeInfo(true)),
Alias(
DkmClrAliasKind.Variable,
"d2",
"d2",
typeof(Dictionary<Dictionary<dynamic, Dictionary<object[], dynamic[]>>, object>).AssemblyQualifiedName,
MakeCustomTypeInfo(false, false, true, false, false, false, false, true, false)));
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var diagnostics = DiagnosticBag.GetInstance();
var testData = new CompilationTestData();
context.CompileGetLocals(
locals,
argumentsOnly: false,
aliases: aliases,
diagnostics: diagnostics,
typeName: out typeName,
testData: testData);
diagnostics.Free();
Assert.Equal(locals.Count, 2);
VerifyCustomTypeInfo(locals[0], "d1", 0x01);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d1", expectedILOpt:
@"{
// Code size 11 (0xb)
.maxstack 1
IL_0000: ldstr ""d1""
IL_0005: call ""object Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(string)""
IL_000a: ret
}");
VerifyCustomTypeInfo(locals[1], "d2", 0x84, 0x00); // Note: read flags right-to-left in each byte: 0010 0001 0(000 0000)
VerifyLocal(testData, typeName, locals[1], "<>m1", "d2", expectedILOpt:
@"{
// Code size 16 (0x10)
.maxstack 1
IL_0000: ldstr ""d2""
IL_0005: call ""object Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(string)""
IL_000a: castclass ""System.Collections.Generic.Dictionary<System.Collections.Generic.Dictionary<dynamic, System.Collections.Generic.Dictionary<object[], dynamic[]>>, object>""
IL_000f: ret
}");
locals.Free();
});
}
private static ReadOnlyCollection<byte> MakeCustomTypeInfo(params bool[] flags)
{
Assert.NotNull(flags);
var builder = ArrayBuilder<bool>.GetInstance();
builder.AddRange(flags);
var bytes = DynamicFlagsCustomTypeInfo.ToBytes(builder);
builder.Free();
return CustomTypeInfo.Encode(bytes, null);
}
[Fact]
public void DynamicAttribute_NotAvailable()
{
var source =
@"class C
{
static void M()
{
dynamic d = 1;
}
}";
var comp = CreateStandardCompilation(source, options: TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
string typeName;
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
Assert.Equal(1, locals.Count);
var method = testData.Methods.Single().Value.Method;
CheckAttribute(assembly, method, AttributeDescription.DynamicAttribute, expected: false);
VerifyCustomTypeInfo(locals[0], "d", null);
VerifyLocal(testData, typeName, locals[0], "<>m0", "d", expectedILOpt:
@"{
// Code size 2 (0x2)
.maxstack 1
.locals init (dynamic V_0) //d
IL_0000: ldloc.0
IL_0001: ret
}");
locals.Free();
});
}
[Fact]
public void DynamicCall()
{
var source = @"
class C
{
void M()
{
dynamic d = this;
d.M();
}
}
";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
string error;
var result = context.CompileExpression("d.M()", out error, testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, 0x01);
var methodData = testData.GetMethodData("<>x.<>m0");
Assert.Equal(TypeKind.Dynamic, methodData.Method.ReturnType.TypeKind);
methodData.VerifyIL(@"
{
// Code size 77 (0x4d)
.maxstack 9
.locals init (dynamic V_0) //d
IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0005: brtrue.s IL_0037
IL_0007: ldc.i4.0
IL_0008: ldstr ""M""
IL_000d: ldnull
IL_000e: ldtoken ""C""
IL_0013: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_0018: ldc.i4.1
IL_0019: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_001e: dup
IL_001f: ldc.i4.0
IL_0020: ldc.i4.0
IL_0021: ldnull
IL_0022: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0027: stelem.ref
IL_0028: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_002d: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_0032: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0037: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_003c: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target""
IL_0041: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0046: ldloc.0
IL_0047: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_004c: ret
}
");
});
}
[WorkItem(1160855, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1160855")]
[Fact]
public void AwaitDynamic()
{
var source = @"
using System;
using System.Threading;
using System.Threading.Tasks;
class C
{
dynamic d;
void M(int p)
{
d.Test(); // Force reference to runtime binder.
}
static void G(Func<Task<object>> f)
{
}
}
";
var comp = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
string error;
var result = context.CompileExpression("G(async () => await d())", out error, testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, null);
var methodData = testData.GetMethodData("<>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()");
methodData.VerifyIL(@"
{
// Code size 542 (0x21e)
.maxstack 10
.locals init (int V_0,
<>x.<>c__DisplayClass0_0 V_1,
object V_2,
object V_3,
System.Runtime.CompilerServices.ICriticalNotifyCompletion V_4,
System.Runtime.CompilerServices.INotifyCompletion V_5,
System.Exception V_6)
IL_0000: ldarg.0
IL_0001: ldfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_0006: stloc.0
IL_0007: ldarg.0
IL_0008: ldfld ""<>x.<>c__DisplayClass0_0 <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>4__this""
IL_000d: stloc.1
.try
{
IL_000e: ldloc.0
IL_000f: brfalse IL_018a
IL_0014: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__0""
IL_0019: brtrue.s IL_004b
IL_001b: ldc.i4.0
IL_001c: ldstr ""GetAwaiter""
IL_0021: ldnull
IL_0022: ldtoken ""C""
IL_0027: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_002c: ldc.i4.1
IL_002d: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_0032: dup
IL_0033: ldc.i4.0
IL_0034: ldc.i4.0
IL_0035: ldnull
IL_0036: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_003b: stelem.ref
IL_003c: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0041: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_0046: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__0""
IL_004b: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__0""
IL_0050: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target""
IL_0055: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__0""
IL_005a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_005f: brtrue.s IL_008b
IL_0061: ldc.i4.0
IL_0062: ldtoken ""C""
IL_0067: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_006c: ldc.i4.1
IL_006d: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_0072: dup
IL_0073: ldc.i4.0
IL_0074: ldc.i4.0
IL_0075: ldnull
IL_0076: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_007b: stelem.ref
IL_007c: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.Invoke(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0081: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_0086: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_008b: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0090: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target""
IL_0095: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_009a: ldloc.1
IL_009b: ldfld ""C <>x.<>c__DisplayClass0_0.<>4__this""
IL_00a0: ldfld ""dynamic C.d""
IL_00a5: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_00aa: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_00af: stloc.3
IL_00b0: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__2""
IL_00b5: brtrue.s IL_00dc
IL_00b7: ldc.i4.s 16
IL_00b9: ldtoken ""bool""
IL_00be: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_00c3: ldtoken ""C""
IL_00c8: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_00cd: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.Convert(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, System.Type, System.Type)""
IL_00d2: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_00d7: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__2""
IL_00dc: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__2""
IL_00e1: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>>.Target""
IL_00e6: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__2""
IL_00eb: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__1""
IL_00f0: brtrue.s IL_0121
IL_00f2: ldc.i4.0
IL_00f3: ldstr ""IsCompleted""
IL_00f8: ldtoken ""C""
IL_00fd: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_0102: ldc.i4.1
IL_0103: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_0108: dup
IL_0109: ldc.i4.0
IL_010a: ldc.i4.0
IL_010b: ldnull
IL_010c: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0111: stelem.ref
IL_0112: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.GetMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0117: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_011c: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__1""
IL_0121: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__1""
IL_0126: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target""
IL_012b: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__1""
IL_0130: ldloc.3
IL_0131: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_0136: callvirt ""bool System.Func<System.Runtime.CompilerServices.CallSite, dynamic, bool>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_013b: brtrue.s IL_01a1
IL_013d: ldarg.0
IL_013e: ldc.i4.0
IL_013f: dup
IL_0140: stloc.0
IL_0141: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_0146: ldarg.0
IL_0147: ldloc.3
IL_0148: stfld ""object <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>u__1""
IL_014d: ldloc.3
IL_014e: isinst ""System.Runtime.CompilerServices.ICriticalNotifyCompletion""
IL_0153: stloc.s V_4
IL_0155: ldloc.s V_4
IL_0157: brtrue.s IL_0174
IL_0159: ldloc.3
IL_015a: castclass ""System.Runtime.CompilerServices.INotifyCompletion""
IL_015f: stloc.s V_5
IL_0161: ldarg.0
IL_0162: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0167: ldloca.s V_5
IL_0169: ldarg.0
IL_016a: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.AwaitOnCompleted<System.Runtime.CompilerServices.INotifyCompletion, <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d>(ref System.Runtime.CompilerServices.INotifyCompletion, ref <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d)""
IL_016f: ldnull
IL_0170: stloc.s V_5
IL_0172: br.s IL_0182
IL_0174: ldarg.0
IL_0175: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_017a: ldloca.s V_4
IL_017c: ldarg.0
IL_017d: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.ICriticalNotifyCompletion, <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d>(ref System.Runtime.CompilerServices.ICriticalNotifyCompletion, ref <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d)""
IL_0182: ldnull
IL_0183: stloc.s V_4
IL_0185: leave IL_021d
IL_018a: ldarg.0
IL_018b: ldfld ""object <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>u__1""
IL_0190: stloc.3
IL_0191: ldarg.0
IL_0192: ldnull
IL_0193: stfld ""object <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>u__1""
IL_0198: ldarg.0
IL_0199: ldc.i4.m1
IL_019a: dup
IL_019b: stloc.0
IL_019c: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_01a1: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__3""
IL_01a6: brtrue.s IL_01d8
IL_01a8: ldc.i4.0
IL_01a9: ldstr ""GetResult""
IL_01ae: ldnull
IL_01af: ldtoken ""C""
IL_01b4: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_01b9: ldc.i4.1
IL_01ba: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_01bf: dup
IL_01c0: ldc.i4.0
IL_01c1: ldc.i4.0
IL_01c2: ldnull
IL_01c3: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_01c8: stelem.ref
IL_01c9: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_01ce: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_01d3: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__3""
IL_01d8: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__3""
IL_01dd: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target""
IL_01e2: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__3""
IL_01e7: ldloc.3
IL_01e8: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_01ed: stloc.2
IL_01ee: leave.s IL_0209
}
catch System.Exception
{
IL_01f0: stloc.s V_6
IL_01f2: ldarg.0
IL_01f3: ldc.i4.s -2
IL_01f5: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_01fa: ldarg.0
IL_01fb: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0200: ldloc.s V_6
IL_0202: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.SetException(System.Exception)""
IL_0207: leave.s IL_021d
}
IL_0209: ldarg.0
IL_020a: ldc.i4.s -2
IL_020c: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_0211: ldarg.0
IL_0212: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0217: ldloc.2
IL_0218: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.SetResult(object)""
IL_021d: ret
}
");
});
}
[WorkItem(1072296, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1072296")]
[Fact]
public void InvokeStaticMemberInLambda()
{
var source = @"
class C
{
static dynamic x;
static void Goo(dynamic y)
{
System.Action a = () => Goo(x);
}
}
";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.Goo");
var testData = new CompilationTestData();
string error;
var result = context.CompileAssignment("a", "() => Goo(x)", out error, testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, null);
testData.GetMethodData("<>x.<>c.<<>m0>b__0_0").VerifyIL(@"
{
// Code size 106 (0x6a)
.maxstack 9
IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> <>x.<>o__0.<>p__0""
IL_0005: brtrue.s IL_0046
IL_0007: ldc.i4 0x100
IL_000c: ldstr ""Goo""
IL_0011: ldnull
IL_0012: ldtoken ""C""
IL_0017: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_001c: ldc.i4.2
IL_001d: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_0022: dup
IL_0023: ldc.i4.0
IL_0024: ldc.i4.s 33
IL_0026: ldnull
IL_0027: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_002c: stelem.ref
IL_002d: dup
IL_002e: ldc.i4.1
IL_002f: ldc.i4.0
IL_0030: ldnull
IL_0031: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0036: stelem.ref
IL_0037: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_003c: call ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_0041: stsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> <>x.<>o__0.<>p__0""
IL_0046: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> <>x.<>o__0.<>p__0""
IL_004b: ldfld ""System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic> System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>>.Target""
IL_0050: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> <>x.<>o__0.<>p__0""
IL_0055: ldtoken ""<>x""
IL_005a: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_005f: ldsfld ""dynamic C.x""
IL_0064: callvirt ""void System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, System.Type, dynamic)""
IL_0069: ret
}");
context = CreateMethodContext(runtime, "C.<>c.<Goo>b__1_0");
testData = new CompilationTestData();
result = context.CompileExpression("Goo(x)", out error, testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, 0x01);
var methodData = testData.GetMethodData("<>x.<>m0");
methodData.VerifyIL(@"
{
// Code size 102 (0x66)
.maxstack 9
IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0005: brtrue.s IL_0042
IL_0007: ldc.i4.0
IL_0008: ldstr ""Goo""
IL_000d: ldnull
IL_000e: ldtoken ""C""
IL_0013: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_0018: ldc.i4.2
IL_0019: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_001e: dup
IL_001f: ldc.i4.0
IL_0020: ldc.i4.s 33
IL_0022: ldnull
IL_0023: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0028: stelem.ref
IL_0029: dup
IL_002a: ldc.i4.1
IL_002b: ldc.i4.0
IL_002c: ldnull
IL_002d: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0032: stelem.ref
IL_0033: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0038: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_003d: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0042: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0047: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>>.Target""
IL_004c: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0051: ldtoken ""<>x""
IL_0056: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_005b: ldsfld ""dynamic C.x""
IL_0060: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, System.Type, dynamic)""
IL_0065: ret
}");
});
}
[WorkItem(1095613, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1095613")]
[Fact]
public void HoistedLocalsLoseDynamicAttribute()
{
var source = @"
class C
{
static void M(dynamic x)
{
dynamic y = 3;
System.Func<dynamic> a = () => x + y;
}
static void Goo(int x)
{
M(x);
}
}
";
var comp = CreateStandardCompilation(source, new[] { SystemCoreRef, CSharpRef }, TestOptions.DebugDll);
WithRuntimeInstance(comp, runtime =>
{
var context = CreateMethodContext(runtime, "C.M");
var testData = new CompilationTestData();
string error;
var result = context.CompileExpression("Goo(x)", out error, testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, 0x01);
testData.GetMethodData("<>x.<>m0").VerifyIL(
@"{
// Code size 103 (0x67)
.maxstack 9
.locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0
System.Func<dynamic> V_1) //a
IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0005: brtrue.s IL_0042
IL_0007: ldc.i4.0
IL_0008: ldstr ""Goo""
IL_000d: ldnull
IL_000e: ldtoken ""C""
IL_0013: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_0018: ldc.i4.2
IL_0019: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_001e: dup
IL_001f: ldc.i4.0
IL_0020: ldc.i4.s 33
IL_0022: ldnull
IL_0023: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0028: stelem.ref
IL_0029: dup
IL_002a: ldc.i4.1
IL_002b: ldc.i4.0
IL_002c: ldnull
IL_002d: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0032: stelem.ref
IL_0033: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0038: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_003d: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0042: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0047: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>>.Target""
IL_004c: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0051: ldtoken ""<>x""
IL_0056: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_005b: ldloc.0
IL_005c: ldfld ""dynamic C.<>c__DisplayClass0_0.x""
IL_0061: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, System.Type, dynamic)""
IL_0066: ret
}");
testData = new CompilationTestData();
result = context.CompileExpression("Goo(y)", out error, testData);
Assert.Null(error);
VerifyCustomTypeInfo(result, 0x01);
testData.GetMethodData("<>x.<>m0").VerifyIL(
@"{
// Code size 103 (0x67)
.maxstack 9
.locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0
System.Func<dynamic> V_1) //a
IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0005: brtrue.s IL_0042
IL_0007: ldc.i4.0
IL_0008: ldstr ""Goo""
IL_000d: ldnull
IL_000e: ldtoken ""C""
IL_0013: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_0018: ldc.i4.2
IL_0019: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo""
IL_001e: dup
IL_001f: ldc.i4.0
IL_0020: ldc.i4.s 33
IL_0022: ldnull
IL_0023: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0028: stelem.ref
IL_0029: dup
IL_002a: ldc.i4.1
IL_002b: ldc.i4.0
IL_002c: ldnull
IL_002d: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)""
IL_0032: stelem.ref
IL_0033: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0038: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_003d: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0042: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0047: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>>.Target""
IL_004c: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>> <>x.<>o__0.<>p__0""
IL_0051: ldtoken ""<>x""
IL_0056: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_005b: ldloc.0
IL_005c: ldfld ""dynamic C.<>c__DisplayClass0_0.y""
IL_0061: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, System.Type, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, System.Type, dynamic)""
IL_0066: ret
}");
});
}
private static void VerifyCustomTypeInfo(LocalAndMethod localAndMethod, string expectedName, params byte[] expectedBytes)
{
Assert.Equal(localAndMethod.LocalName, expectedName);
ReadOnlyCollection<byte> customTypeInfo;
Guid customTypeInfoId = localAndMethod.GetCustomTypeInfo(out customTypeInfo);
VerifyCustomTypeInfo(customTypeInfoId, customTypeInfo, expectedBytes);
}
private static void VerifyCustomTypeInfo(CompileResult compileResult, params byte[] expectedBytes)
{
ReadOnlyCollection<byte> customTypeInfo;
Guid customTypeInfoId = compileResult.GetCustomTypeInfo(out customTypeInfo);
VerifyCustomTypeInfo(customTypeInfoId, customTypeInfo, expectedBytes);
}
private static void VerifyCustomTypeInfo(Guid customTypeInfoId, ReadOnlyCollection<byte> customTypeInfo, params byte[] expectedBytes)
{
if (expectedBytes == null)
{
Assert.Equal(Guid.Empty, customTypeInfoId);
Assert.Null(customTypeInfo);
}
else
{
Assert.Equal(CustomTypeInfo.PayloadTypeId, customTypeInfoId);
// Include leading count byte.
var builder = ArrayBuilder<byte>.GetInstance();
builder.Add((byte)expectedBytes.Length);
builder.AddRange(expectedBytes);
expectedBytes = builder.ToArrayAndFree();
Assert.Equal(expectedBytes, customTypeInfo);
}
}
}
}
| 48.246021 | 341 | 0.642787 | [
"Apache-2.0"
] | gewarren/roslyn | src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/DynamicTests.cs | 72,757 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using Paketti.Contexts;
namespace Paketti.Extensions
{
internal static class TypeContextExtensions
{
/// <summary>
/// Gets a value indicating whether any of the types are an interweave.
/// </summary>
/// <param name="types"></param>
/// <returns></returns>
public static bool AnyInterweaves(this IEnumerable<TypeContext> types)
=> types.Any(x => x.IsInterweave);
/// <summary>
/// Gets only the TypeContexts that are interweaves.
/// </summary>
/// <param name="types"></param>
/// <returns></returns>
public static IEnumerable<TypeContext> OnlyInterweaves(this IEnumerable<TypeContext> types)
=> types.Where(x => x.IsInterweave);
}
} | 32.230769 | 99 | 0.618138 | [
"MIT"
] | sirphilliptubell/Paketti | Paketti/Extensions/TypeContextExtensions.cs | 840 | C# |
// Copyright © 2012-2021 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.
namespace Vlingo.Xoom.Lattice.Exchange
{
public interface IExchangeAdapter
{
object? FromExchange(object exchangeMessage);
object? ToExchange(object localMessage);
/// <summary>
/// Gets whether or not this adapter supports the <paramref name="exchangeMessage"/>.
/// </summary>
/// <param name="exchangeMessage">The possibly supported exchange message</param>
/// <returns>True if supports <paramref name="exchangeMessage"/></returns>
bool Supports(object? exchangeMessage);
}
/// <summary>
/// Adapts the local messages of type <typeparamref name="TLocal"/> to exchange messages
/// of type <typeparamref name="TExchange"/> that hold external type <typeparamref name="TExternal"/>. This may involve
/// mapping, in which case the underlying implementation must arrange a for
/// <see cref="IExchangeMapper{TLocal,TExternal}"/> to be established. Note that the <typeparamref name="TLocal"/>
/// and <typeparamref name="TExchange"/> types may be different between <see cref="IExchangeAdapter{TLocal,TExternal,TExchange}"/>
/// and the <see cref="IExchangeMapper{TLocal,TExternal}"/>
/// </summary>
/// <typeparam name="TLocal">The local object type</typeparam>
/// <typeparam name="TExternal">The external object type</typeparam>
/// <typeparam name="TExchange">The exchange message type</typeparam>
public interface IExchangeAdapter<TLocal, TExternal, TExchange> : IExchangeAdapter
{
/// <summary>
/// Gets the <typeparamref name="TLocal"/> typed local message from the <paramref name="exchangeMessage"/>
/// of type <typeparamref name="TExchange"/>.
/// </summary>
/// <param name="exchangeMessage">the <typeparamref name="TExchange"/> typed exchange message</param>
/// <returns>The message of type <typeparamref name="TLocal"/></returns>
TLocal FromExchange(TExchange exchangeMessage);
/// <summary>
/// Gets the <typeparamref name="TExchange"/> typed exchange message from the <paramref name="localMessage"/>
/// of type <typeparamref name="TLocal"/>.
/// </summary>
/// <param name="localMessage">The message of type <typeparamref name="TLocal"/></param>
/// <returns>The message of type <typeparamref name="TExchange"/></returns>
TExchange ToExchange(TLocal localMessage);
}
} | 51.433962 | 134 | 0.667278 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Luteceo/vlingo-net-lattice | src/Vlingo.Xoom.Lattice/Exchange/IExchangeAdapter.cs | 2,727 | C# |
/*
The MIT License (MIT)
Copyright (c) 2007 - 2021 Microting A/S
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
namespace eFormAPI.Web.Services.Mailing.EmailTags
{
using System.Threading.Tasks;
using Infrastructure.Models.Mailing;
using Microting.eFormApi.BasePn.Infrastructure.Models.API;
using Microting.eFormApi.BasePn.Infrastructure.Models.Common;
public interface IEmailTagsService
{
Task<OperationDataResult<CommonDictionaryModel[]>> GetEmailTags();
Task<OperationResult> UpdateEmailTag(EmailRecipientTagModel requestModel);
Task<OperationResult> DeleteEmailTag(int id);
Task<OperationResult> CreateEmailTag(EmailRecipientTagModel requestModel);
}
} | 44.684211 | 82 | 0.787397 | [
"MIT"
] | Gid733/eform-angular-frontend | eFormAPI/eFormAPI.Web/Services/Mailing/EmailTags/IEmailTagsService.cs | 1,700 | C# |
namespace Yapool
{
public interface IProcessor<T>
{
/// <summary>Create new Instance of Type T using source object.</summary>
/// <param name="key">Unique identifer for Pool.</param>
/// <param name="source">Source object.</param>
/// <returns>New instance.</returns>
public T CreateObject(T source);
/// <summary>Destroy Instance of Type T.</summary>
/// <param name="key">Unique identifer for Pool.</param>
/// <param name="instance">Instance to destroy.</param>
public void DisposeInstance(T instance);
/// <summary>Called when instance is enabled.</summary>
/// <param name="key">Unique identifer for Pool.</param>
/// <param name="instance">Instance to enable.</param>
public void EnableInstance(T instance);
/// <summary>Called when instance is disabled.</summary>
/// <param name="key">Unique identifer for Pool.</param>
/// <param name="instance">Instance to disable.</param>
public void DisableInstance(T instance);
}
} | 37.423077 | 76 | 0.68962 | [
"MIT"
] | peterdijkstra/Yapool | Assets/Plugins/Yapool/Runtime/Interfaces/IProcessor.cs | 973 | C# |
/**
* Copyright 2017-2021 Plexus Interop Deutsche Bank AG
* SPDX-License-Identifier: Apache-2.0
*
* 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 Plexus.Interop.Metamodel.Json.Internal
{
using System.Collections.Generic;
using System.Runtime.Serialization;
[DataContract]
internal sealed class ConsumedMethodDto
{
private List<OptionDto> _options = new List<OptionDto>();
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "options")]
public List<OptionDto> Options
{
get => _options = _options ?? new List<OptionDto>();
set => _options = value ?? new List<OptionDto>();
}
}
}
| 32.578947 | 75 | 0.676898 | [
"Apache-2.0"
] | deutschebank/Plexus-interop | desktop/src/Plexus.Interop.Metamodel.Json/Internal/ConsumedMethodDto.cs | 1,240 | C# |
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new() { Title = "_002_webapi", Version = "v1" });
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (builder.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "_002_webapi v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
| 20.733333 | 91 | 0.713826 | [
"MIT"
] | fernandezja/net6-experiments | 002-webapi/Program.cs | 622 | C# |
using System.Collections.Generic;
namespace MotorcycleChoiceHelper.Class
{
public class MotorcycleBrand
{
public string Brand { get; set; }
public List<Model> Models { get; set; }
}
}
| 21.3 | 47 | 0.661972 | [
"MIT"
] | kolendomichal/AI-on-Microsoft-Azure | AI Machine Learning/bot/MotorcycleChoiceHelper/Class/MotorcycleBrand.cs | 215 | C# |
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;
using UnityEditor.ShaderGraph.Internal;
using Data.Util;
namespace UnityEditor.ShaderGraph
{
static class GenerationUtils
{
const string kDebugSymbol = "SHADERGRAPH_DEBUG";
public static bool GenerateShaderPass(AbstractMaterialNode masterNode, ShaderPass pass, GenerationMode mode,
ActiveFields activeFields, ShaderGenerator result, List<string> sourceAssetDependencyPaths,
List<Dependency[]> dependencies, string resourceClassName, string assemblyName)
{
// --------------------------------------------------
// Debug
// Get scripting symbols
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
bool isDebug = defines.Contains(kDebugSymbol);
// --------------------------------------------------
// Setup
// Initiailize Collectors
var propertyCollector = new PropertyCollector();
var keywordCollector = new KeywordCollector();
masterNode.owner.CollectShaderKeywords(keywordCollector, mode);
// Get upstream nodes from ShaderPass port mask
List<AbstractMaterialNode> vertexNodes;
List<AbstractMaterialNode> pixelNodes;
GetUpstreamNodesForShaderPass(masterNode, pass, out vertexNodes, out pixelNodes);
// Track permutation indices for all nodes
List<int>[] vertexNodePermutations = new List<int>[vertexNodes.Count];
List<int>[] pixelNodePermutations = new List<int>[pixelNodes.Count];
// Get active fields from upstream Node requirements
ShaderGraphRequirementsPerKeyword graphRequirements;
GetActiveFieldsAndPermutationsForNodes(masterNode, pass, keywordCollector, vertexNodes, pixelNodes,
vertexNodePermutations, pixelNodePermutations, activeFields, out graphRequirements);
// GET CUSTOM ACTIVE FIELDS HERE!
// Get active fields from ShaderPass
AddRequiredFields(pass.requiredAttributes, activeFields.baseInstance);
AddRequiredFields(pass.requiredVaryings, activeFields.baseInstance);
// Get Port references from ShaderPass
var pixelSlots = FindMaterialSlotsOnNode(pass.pixelPorts, masterNode);
var vertexSlots = FindMaterialSlotsOnNode(pass.vertexPorts, masterNode);
// Function Registry
var functionBuilder = new ShaderStringBuilder();
var functionRegistry = new FunctionRegistry(functionBuilder);
// Hash table of named $splice(name) commands
// Key: splice token
// Value: string to splice
Dictionary<string, string> spliceCommands = new Dictionary<string, string>();
// --------------------------------------------------
// Dependencies
// Propagate active field requirements using dependencies
// Must be executed before types are built
foreach (var instance in activeFields.all.instances)
ShaderSpliceUtil.ApplyDependencies(instance, dependencies);
// --------------------------------------------------
// Pass Setup
// Name
if(!string.IsNullOrEmpty(pass.displayName))
{
spliceCommands.Add("PassName", $"Name \"{pass.displayName}\"");
}
else
{
spliceCommands.Add("PassName", "// Name: <None>");
}
// Tags
if(!string.IsNullOrEmpty(pass.lightMode))
{
spliceCommands.Add("LightMode", $"\"LightMode\" = \"{pass.lightMode}\"");
}
else
{
spliceCommands.Add("LightMode", "// LightMode: <None>");
}
// Render state
BuildRenderStatesFromPass(pass, ref spliceCommands);
// --------------------------------------------------
// Pass Code
// Pragmas
using (var passPragmaBuilder = new ShaderStringBuilder())
{
if(pass.pragmas != null)
{
foreach(string pragma in pass.pragmas)
{
passPragmaBuilder.AppendLine($"#pragma {pragma}");
}
}
if(passPragmaBuilder.length == 0)
passPragmaBuilder.AppendLine("// PassPragmas: <None>");
spliceCommands.Add("PassPragmas", passPragmaBuilder.ToCodeBlack());
}
// Includes
using (var passIncludeBuilder = new ShaderStringBuilder())
{
if(pass.includes != null)
{
foreach(string include in pass.includes)
{
passIncludeBuilder.AppendLine($"#include \"{include}\"");
}
}
if(passIncludeBuilder.length == 0)
passIncludeBuilder.AppendLine("// PassIncludes: <None>");
spliceCommands.Add("PassIncludes", passIncludeBuilder.ToCodeBlack());
}
// Keywords
using (var passKeywordBuilder = new ShaderStringBuilder())
{
if(pass.keywords != null)
{
foreach(KeywordDescriptor keyword in pass.keywords)
{
passKeywordBuilder.AppendLine(keyword.ToDeclarationString());
}
}
if(passKeywordBuilder.length == 0)
passKeywordBuilder.AppendLine("// PassKeywords: <None>");
spliceCommands.Add("PassKeywords", passKeywordBuilder.ToCodeBlack());
}
// --------------------------------------------------
// Graph Vertex
var vertexBuilder = new ShaderStringBuilder();
// If vertex modification enabled
if (activeFields.baseInstance.Contains("features.graphVertex"))
{
// Setup
string vertexGraphInputName = "VertexDescriptionInputs";
string vertexGraphOutputName = "VertexDescription";
string vertexGraphFunctionName = "VertexDescriptionFunction";
var vertexGraphInputGenerator = new ShaderGenerator();
var vertexGraphFunctionBuilder = new ShaderStringBuilder();
var vertexGraphOutputBuilder = new ShaderStringBuilder();
// Build vertex graph inputs
ShaderSpliceUtil.BuildType(GetTypeForStruct("VertexDescriptionInputs", resourceClassName, assemblyName), activeFields, vertexGraphInputGenerator, isDebug);
// Build vertex graph outputs
// Add struct fields to active fields
SubShaderGenerator.GenerateVertexDescriptionStruct(vertexGraphOutputBuilder, vertexSlots, vertexGraphOutputName, activeFields.baseInstance);
// Build vertex graph functions from ShaderPass vertex port mask
SubShaderGenerator.GenerateVertexDescriptionFunction(
masterNode.owner as GraphData,
vertexGraphFunctionBuilder,
functionRegistry,
propertyCollector,
keywordCollector,
mode,
masterNode,
vertexNodes,
vertexNodePermutations,
vertexSlots,
vertexGraphInputName,
vertexGraphFunctionName,
vertexGraphOutputName);
// Generate final shader strings
vertexBuilder.AppendLines(vertexGraphInputGenerator.GetShaderString(0, false));
vertexBuilder.AppendNewLine();
vertexBuilder.AppendLines(vertexGraphOutputBuilder.ToString());
vertexBuilder.AppendNewLine();
vertexBuilder.AppendLines(vertexGraphFunctionBuilder.ToString());
}
// Add to splice commands
if(vertexBuilder.length == 0)
vertexBuilder.AppendLine("// GraphVertex: <None>");
spliceCommands.Add("GraphVertex", vertexBuilder.ToCodeBlack());
// --------------------------------------------------
// Graph Pixel
// Setup
string pixelGraphInputName = "SurfaceDescriptionInputs";
string pixelGraphOutputName = "SurfaceDescription";
string pixelGraphFunctionName = "SurfaceDescriptionFunction";
var pixelGraphInputGenerator = new ShaderGenerator();
var pixelGraphOutputBuilder = new ShaderStringBuilder();
var pixelGraphFunctionBuilder = new ShaderStringBuilder();
// Build pixel graph inputs
ShaderSpliceUtil.BuildType(GetTypeForStruct("SurfaceDescriptionInputs", resourceClassName, assemblyName), activeFields, pixelGraphInputGenerator, isDebug);
// Build pixel graph outputs
// Add struct fields to active fields
SubShaderGenerator.GenerateSurfaceDescriptionStruct(pixelGraphOutputBuilder, pixelSlots, pixelGraphOutputName, activeFields.baseInstance);
// Build pixel graph functions from ShaderPass pixel port mask
SubShaderGenerator.GenerateSurfaceDescriptionFunction(
pixelNodes,
pixelNodePermutations,
masterNode,
masterNode.owner as GraphData,
pixelGraphFunctionBuilder,
functionRegistry,
propertyCollector,
keywordCollector,
mode,
pixelGraphFunctionName,
pixelGraphOutputName,
null,
pixelSlots,
pixelGraphInputName);
using (var pixelBuilder = new ShaderStringBuilder())
{
// Generate final shader strings
pixelBuilder.AppendLines(pixelGraphInputGenerator.GetShaderString(0, false));
pixelBuilder.AppendNewLine();
pixelBuilder.AppendLines(pixelGraphOutputBuilder.ToString());
pixelBuilder.AppendNewLine();
pixelBuilder.AppendLines(pixelGraphFunctionBuilder.ToString());
// Add to splice commands
if(pixelBuilder.length == 0)
pixelBuilder.AppendLine("// GraphPixel: <None>");
spliceCommands.Add("GraphPixel", pixelBuilder.ToCodeBlack());
}
// --------------------------------------------------
// Graph Functions
if(functionBuilder.length == 0)
functionBuilder.AppendLine("// GraphFunctions: <None>");
spliceCommands.Add("GraphFunctions", functionBuilder.ToCodeBlack());
// --------------------------------------------------
// Graph Keywords
using (var keywordBuilder = new ShaderStringBuilder())
{
keywordCollector.GetKeywordsDeclaration(keywordBuilder, mode);
if(keywordBuilder.length == 0)
keywordBuilder.AppendLine("// GraphKeywords: <None>");
spliceCommands.Add("GraphKeywords", keywordBuilder.ToCodeBlack());
}
// --------------------------------------------------
// Graph Properties
using (var propertyBuilder = new ShaderStringBuilder())
{
propertyCollector.GetPropertiesDeclaration(propertyBuilder, mode, masterNode.owner.concretePrecision);
if(propertyBuilder.length == 0)
propertyBuilder.AppendLine("// GraphProperties: <None>");
spliceCommands.Add("GraphProperties", propertyBuilder.ToCodeBlack());
}
// --------------------------------------------------
// Graph Defines
using (var graphDefines = new ShaderStringBuilder())
{
graphDefines.AppendLine("#define {0}", pass.referenceName);
if (graphRequirements.permutationCount > 0)
{
List<int> activePermutationIndices;
// Depth Texture
activePermutationIndices = graphRequirements.allPermutations.instances
.Where(p => p.requirements.requiresDepthTexture)
.Select(p => p.permutationIndex)
.ToList();
if (activePermutationIndices.Count > 0)
{
graphDefines.AppendLine(KeywordUtil.GetKeywordPermutationSetConditional(activePermutationIndices));
graphDefines.AppendLine("#define REQUIRE_DEPTH_TEXTURE");
graphDefines.AppendLine("#endif");
}
// Opaque Texture
activePermutationIndices = graphRequirements.allPermutations.instances
.Where(p => p.requirements.requiresCameraOpaqueTexture)
.Select(p => p.permutationIndex)
.ToList();
if (activePermutationIndices.Count > 0)
{
graphDefines.AppendLine(KeywordUtil.GetKeywordPermutationSetConditional(activePermutationIndices));
graphDefines.AppendLine("#define REQUIRE_OPAQUE_TEXTURE");
graphDefines.AppendLine("#endif");
}
}
else
{
// Depth Texture
if (graphRequirements.baseInstance.requirements.requiresDepthTexture)
graphDefines.AppendLine("#define REQUIRE_DEPTH_TEXTURE");
// Opaque Texture
if (graphRequirements.baseInstance.requirements.requiresCameraOpaqueTexture)
graphDefines.AppendLine("#define REQUIRE_OPAQUE_TEXTURE");
}
// Add to splice commands
spliceCommands.Add("GraphDefines", graphDefines.ToCodeBlack());
}
// --------------------------------------------------
// Main
// Main include is expected to contain vert/frag definitions for the pass
// This must be defined after all graph code
using (var mainBuilder = new ShaderStringBuilder())
{
mainBuilder.AppendLine($"#include \"{pass.varyingsInclude}\"");
mainBuilder.AppendLine($"#include \"{pass.passInclude}\"");
// Add to splice commands
spliceCommands.Add("MainInclude", mainBuilder.ToCodeBlack());
}
// --------------------------------------------------
// Debug
// Debug output all active fields
using(var debugBuilder = new ShaderStringBuilder())
{
if (isDebug)
{
// Active fields
debugBuilder.AppendLine("// ACTIVE FIELDS:");
foreach (string field in activeFields.baseInstance.fields)
{
debugBuilder.AppendLine("// " + field);
}
}
if(debugBuilder.length == 0)
debugBuilder.AppendLine("// <None>");
// Add to splice commands
spliceCommands.Add("Debug", debugBuilder.ToCodeBlack());
}
// --------------------------------------------------
// Finalize
// Get Template
string templateLocation = GetTemplatePath("PassMesh.template");
if (!File.Exists(templateLocation))
return false;
// Get Template preprocessor
string templatePath = "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Templates";
var templatePreprocessor = new ShaderSpliceUtil.TemplatePreprocessor(activeFields, spliceCommands,
isDebug, templatePath, sourceAssetDependencyPaths, assemblyName, resourceClassName);
// Process Template
templatePreprocessor.ProcessTemplateFile(templateLocation);
result.AddShaderChunk(templatePreprocessor.GetShaderCode().ToString(), false);
return true;
}
public static Type GetTypeForStruct(string structName, string resourceClassName, string assemblyName)
{
// 'C# qualified assembly type names' for $buildType() commands
string assemblyQualifiedTypeName = $"{resourceClassName}+{structName}, {assemblyName}";
return Type.GetType(assemblyQualifiedTypeName);
}
static void GetUpstreamNodesForShaderPass(AbstractMaterialNode masterNode, ShaderPass pass, out List<AbstractMaterialNode> vertexNodes, out List<AbstractMaterialNode> pixelNodes)
{
// Traverse Graph Data
vertexNodes = Graphing.ListPool<AbstractMaterialNode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(vertexNodes, masterNode, NodeUtils.IncludeSelf.Include, pass.vertexPorts);
pixelNodes = Graphing.ListPool<AbstractMaterialNode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(pixelNodes, masterNode, NodeUtils.IncludeSelf.Include, pass.pixelPorts);
}
static void GetActiveFieldsAndPermutationsForNodes(AbstractMaterialNode masterNode, ShaderPass pass,
KeywordCollector keywordCollector, List<AbstractMaterialNode> vertexNodes, List<AbstractMaterialNode> pixelNodes,
List<int>[] vertexNodePermutations, List<int>[] pixelNodePermutations,
ActiveFields activeFields, out ShaderGraphRequirementsPerKeyword graphRequirements)
{
// Initialize requirements
ShaderGraphRequirementsPerKeyword pixelRequirements = new ShaderGraphRequirementsPerKeyword();
ShaderGraphRequirementsPerKeyword vertexRequirements = new ShaderGraphRequirementsPerKeyword();
graphRequirements = new ShaderGraphRequirementsPerKeyword();
// Evaluate all Keyword permutations
if (keywordCollector.permutations.Count > 0)
{
for(int i = 0; i < keywordCollector.permutations.Count; i++)
{
// Get active nodes for this permutation
var localVertexNodes = Graphing.ListPool<AbstractMaterialNode>.Get();
var localPixelNodes = Graphing.ListPool<AbstractMaterialNode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(localVertexNodes, masterNode, NodeUtils.IncludeSelf.Include, pass.vertexPorts, keywordCollector.permutations[i]);
NodeUtils.DepthFirstCollectNodesFromNode(localPixelNodes, masterNode, NodeUtils.IncludeSelf.Include, pass.pixelPorts, keywordCollector.permutations[i]);
// Track each vertex node in this permutation
foreach(AbstractMaterialNode vertexNode in localVertexNodes)
{
int nodeIndex = vertexNodes.IndexOf(vertexNode);
if(vertexNodePermutations[nodeIndex] == null)
vertexNodePermutations[nodeIndex] = new List<int>();
vertexNodePermutations[nodeIndex].Add(i);
}
// Track each pixel node in this permutation
foreach(AbstractMaterialNode pixelNode in localPixelNodes)
{
int nodeIndex = pixelNodes.IndexOf(pixelNode);
if(pixelNodePermutations[nodeIndex] == null)
pixelNodePermutations[nodeIndex] = new List<int>();
pixelNodePermutations[nodeIndex].Add(i);
}
// Get requirements for this permutation
vertexRequirements[i].SetRequirements(ShaderGraphRequirements.FromNodes(localVertexNodes, ShaderStageCapability.Vertex, false));
pixelRequirements[i].SetRequirements(ShaderGraphRequirements.FromNodes(localPixelNodes, ShaderStageCapability.Fragment, false));
// Add active fields
AddActiveFieldsFromGraphRequirements(activeFields[i], vertexRequirements[i].requirements, "VertexDescriptionInputs");
AddActiveFieldsFromGraphRequirements(activeFields[i], pixelRequirements[i].requirements, "SurfaceDescriptionInputs");
}
}
// No Keywords
else
{
// Get requirements
vertexRequirements.baseInstance.SetRequirements(ShaderGraphRequirements.FromNodes(vertexNodes, ShaderStageCapability.Vertex, false));
pixelRequirements.baseInstance.SetRequirements(ShaderGraphRequirements.FromNodes(pixelNodes, ShaderStageCapability.Fragment, false));
// Add active fields
AddActiveFieldsFromGraphRequirements(activeFields.baseInstance, vertexRequirements.baseInstance.requirements, "VertexDescriptionInputs");
AddActiveFieldsFromGraphRequirements(activeFields.baseInstance, pixelRequirements.baseInstance.requirements, "SurfaceDescriptionInputs");
}
// Build graph requirements
graphRequirements.UnionWith(pixelRequirements);
graphRequirements.UnionWith(vertexRequirements);
}
static void AddActiveFieldsFromGraphRequirements(IActiveFields activeFields, ShaderGraphRequirements requirements, string structName)
{
if (requirements.requiresScreenPosition)
{
activeFields.Add($"{structName}.ScreenPosition");
}
if (requirements.requiresVertexColor)
{
activeFields.Add($"{structName}.VertexColor");
}
if (requirements.requiresFaceSign)
{
activeFields.Add($"{structName}.FaceSign");
}
if (requirements.requiresNormal != 0)
{
if ((requirements.requiresNormal & NeededCoordinateSpace.Object) > 0)
activeFields.Add($"{structName}.ObjectSpaceNormal");
if ((requirements.requiresNormal & NeededCoordinateSpace.View) > 0)
activeFields.Add($"{structName}.ViewSpaceNormal");
if ((requirements.requiresNormal & NeededCoordinateSpace.World) > 0)
activeFields.Add($"{structName}.WorldSpaceNormal");
if ((requirements.requiresNormal & NeededCoordinateSpace.Tangent) > 0)
activeFields.Add($"{structName}.TangentSpaceNormal");
}
if (requirements.requiresTangent != 0)
{
if ((requirements.requiresTangent & NeededCoordinateSpace.Object) > 0)
activeFields.Add($"{structName}.ObjectSpaceTangent");
if ((requirements.requiresTangent & NeededCoordinateSpace.View) > 0)
activeFields.Add($"{structName}.ViewSpaceTangent");
if ((requirements.requiresTangent & NeededCoordinateSpace.World) > 0)
activeFields.Add($"{structName}.WorldSpaceTangent");
if ((requirements.requiresTangent & NeededCoordinateSpace.Tangent) > 0)
activeFields.Add($"{structName}.TangentSpaceTangent");
}
if (requirements.requiresBitangent != 0)
{
if ((requirements.requiresBitangent & NeededCoordinateSpace.Object) > 0)
activeFields.Add($"{structName}.ObjectSpaceBiTangent");
if ((requirements.requiresBitangent & NeededCoordinateSpace.View) > 0)
activeFields.Add($"{structName}.ViewSpaceBiTangent");
if ((requirements.requiresBitangent & NeededCoordinateSpace.World) > 0)
activeFields.Add($"{structName}.WorldSpaceBiTangent");
if ((requirements.requiresBitangent & NeededCoordinateSpace.Tangent) > 0)
activeFields.Add($"{structName}.TangentSpaceBiTangent");
}
if (requirements.requiresViewDir != 0)
{
if ((requirements.requiresViewDir & NeededCoordinateSpace.Object) > 0)
activeFields.Add($"{structName}.ObjectSpaceViewDirection");
if ((requirements.requiresViewDir & NeededCoordinateSpace.View) > 0)
activeFields.Add($"{structName}.ViewSpaceViewDirection");
if ((requirements.requiresViewDir & NeededCoordinateSpace.World) > 0)
activeFields.Add($"{structName}.WorldSpaceViewDirection");
if ((requirements.requiresViewDir & NeededCoordinateSpace.Tangent) > 0)
activeFields.Add($"{structName}.TangentSpaceViewDirection");
}
if (requirements.requiresPosition != 0)
{
if ((requirements.requiresPosition & NeededCoordinateSpace.Object) > 0)
activeFields.Add($"{structName}.ObjectSpacePosition");
if ((requirements.requiresPosition & NeededCoordinateSpace.View) > 0)
activeFields.Add($"{structName}.ViewSpacePosition");
if ((requirements.requiresPosition & NeededCoordinateSpace.World) > 0)
activeFields.Add($"{structName}.WorldSpacePosition");
if ((requirements.requiresPosition & NeededCoordinateSpace.Tangent) > 0)
activeFields.Add($"{structName}.TangentSpacePosition");
if ((requirements.requiresPosition & NeededCoordinateSpace.AbsoluteWorld) > 0)
activeFields.Add($"{structName}.AbsoluteWorldSpacePosition");
}
foreach (var channel in requirements.requiresMeshUVs.Distinct())
{
activeFields.Add($"{structName}.{channel.GetUVName()}");
}
if (requirements.requiresTime)
{
activeFields.Add($"{structName}.TimeParameters");
}
if (requirements.requiresVertexSkinning)
{
activeFields.Add($"{structName}.BoneWeights");
activeFields.Add($"{structName}.BoneIndices");
}
}
static void AddRequiredFields(
List<string> passRequiredFields, // fields the pass requires
IActiveFieldsSet activeFields)
{
if (passRequiredFields != null)
{
foreach (var requiredField in passRequiredFields)
{
activeFields.AddAll(requiredField);
}
}
}
static List<MaterialSlot> FindMaterialSlotsOnNode(IEnumerable<int> slots, AbstractMaterialNode node)
{
var activeSlots = new List<MaterialSlot>();
if (slots != null)
{
foreach (var id in slots)
{
MaterialSlot slot = node.FindSlot<MaterialSlot>(id);
if (slot != null)
{
activeSlots.Add(slot);
}
}
}
return activeSlots;
}
static void BuildRenderStatesFromPass(ShaderPass pass, ref Dictionary<string, string> spliceCommands)
{
spliceCommands.Add("Blending", pass.BlendOverride != null ? pass.BlendOverride : "// Blending: <None>");
spliceCommands.Add("Culling", pass.CullOverride != null ? pass.CullOverride : "// Culling: <None>");
spliceCommands.Add("ZTest", pass.ZTestOverride != null ? pass.ZTestOverride : "// ZTest: <None>");
spliceCommands.Add("ZWrite", pass.ZWriteOverride != null ? pass.ZWriteOverride : "// ZWrite: <None>");
spliceCommands.Add("ZClip", pass.ZClipOverride != null ? pass.ZClipOverride : "// ZClip: <None>");
spliceCommands.Add("ColorMask", pass.ColorMaskOverride != null ? pass.ColorMaskOverride : "// ColorMask: <None>");
using(var stencilBuilder = new ShaderStringBuilder())
{
if (pass.StencilOverride != null)
{
foreach (var str in pass.StencilOverride)
stencilBuilder.AppendLine(str);
}
spliceCommands.Add("Stencil", stencilBuilder.ToCodeBlack());
}
}
static string GetTemplatePath(string templateName)
{
var basePath = "Packages/com.unity.shadergraph/Editor/Templates/";
string templatePath = Path.Combine(basePath, templateName);
if (File.Exists(templatePath))
return templatePath;
throw new FileNotFoundException(string.Format(@"Cannot find a template with name ""{0}"".", templateName));
}
}
}
| 46.740798 | 187 | 0.559212 | [
"MIT"
] | DanielConrad/HSTD | Library/PackageCache/com.unity.shadergraph@7.3.1/Editor/CodeGen/GenerationUtils.cs | 30,475 | 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 System.Xml;
using System.Xml.XPath;
using System.Xml.Schema;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml.Xsl;
using System.Xml.Xsl.Qil;
using System.Xml.Xsl.Runtime;
using System.Diagnostics.CodeAnalysis;
namespace System.Xml.Xsl.IlGen
{
using TypeFactory = System.Xml.Xsl.XmlQueryTypeFactory;
/// <summary>
/// Creates Msil code for an entire QilExpression graph. Code is generated in one of two modes: push or
/// pull. In push mode, code is generated to push the values in an iterator to the XmlWriter
/// interface. In pull mode, the values in an iterator are stored in a physical location such as
/// the stack or a local variable by an iterator. The iterator is passive, and will just wait for
/// a caller to pull the data and/or instruct the iterator to enumerate the next value.
/// </summary>
internal class XmlILVisitor : QilVisitor
{
private QilExpression _qil = null!;
private GenerateHelper _helper = null!;
private IteratorDescriptor _iterCurr = null!;
private IteratorDescriptor? _iterNested;
private int _indexId;
[RequiresUnreferencedCode("Method VisitXsltInvokeEarlyBound will require code that cannot be statically analyzed.")]
public XmlILVisitor()
{ }
//-----------------------------------------------
// Entry
//-----------------------------------------------
/// <summary>
/// Visits the specified QilExpression graph and generates MSIL code.
/// </summary>
public void Visit(QilExpression qil, GenerateHelper helper, MethodInfo methRoot)
{
_qil = qil;
_helper = helper;
_iterNested = null;
_indexId = 0;
// Prepare each global parameter and global variable to be visited
PrepareGlobalValues(qil.GlobalParameterList);
PrepareGlobalValues(qil.GlobalVariableList);
// Visit each global parameter and global variable
VisitGlobalValues(qil.GlobalParameterList);
VisitGlobalValues(qil.GlobalVariableList);
// Build each function
foreach (QilFunction ndFunc in qil.FunctionList)
{
// Visit each parameter and the function body
Function(ndFunc);
}
// Build the root expression
_helper.MethodBegin(methRoot, null, true);
StartNestedIterator(qil.Root);
Visit(qil.Root);
Debug.Assert(_iterCurr.Storage.Location == ItemLocation.None, "Root expression should have been pushed to the writer.");
EndNestedIterator(qil.Root);
_helper.MethodEnd();
}
/// <summary>
/// Create IteratorDescriptor for each global value. This pre-visit is necessary because a global early
/// in the list may reference a global later in the list and therefore expect its IteratorDescriptor to already
/// be initialized.
/// </summary>
private void PrepareGlobalValues(QilList globalIterators)
{
MethodInfo? methGlobal;
IteratorDescriptor iterInfo;
foreach (QilIterator iter in globalIterators)
{
Debug.Assert(iter.NodeType == QilNodeType.Let || iter.NodeType == QilNodeType.Parameter);
// Get metadata for method which computes this global's value
methGlobal = XmlILAnnotation.Write(iter).FunctionBinding;
Debug.Assert(methGlobal != null, "Metadata for global value should have already been computed");
// Create an IteratorDescriptor for this global value
iterInfo = new IteratorDescriptor(_helper);
// Iterator items will be stored in a global location
iterInfo.Storage = StorageDescriptor.Global(methGlobal, GetItemStorageType(iter), !iter.XmlType!.IsSingleton);
// Associate IteratorDescriptor with parameter
XmlILAnnotation.Write(iter).CachedIteratorDescriptor = iterInfo;
}
}
/// <summary>
/// Visit each global variable or parameter. Create a IteratorDescriptor for each global value. Generate code for
/// default values.
/// </summary>
private void VisitGlobalValues(QilList globalIterators)
{
MethodInfo methGlobal;
Label lblGetGlobal, lblComputeGlobal;
bool isCached;
int idxValue;
foreach (QilIterator iter in globalIterators)
{
QilParameter? param = iter as QilParameter;
// Get MethodInfo for method that computes the value of this global
methGlobal = XmlILAnnotation.Write(iter).CachedIteratorDescriptor!.Storage.GlobalLocation!;
isCached = !iter.XmlType!.IsSingleton;
// Notify the StaticDataManager of the new global value
idxValue = _helper.StaticData.DeclareGlobalValue(iter.DebugName!);
// Generate code for this method
_helper.MethodBegin(methGlobal, iter.SourceLine, false);
lblGetGlobal = _helper.DefineLabel();
lblComputeGlobal = _helper.DefineLabel();
// if (runtime.IsGlobalComputed(idx)) goto LabelGetGlobal;
_helper.LoadQueryRuntime();
_helper.LoadInteger(idxValue);
_helper.Call(XmlILMethods.GlobalComputed);
_helper.Emit(OpCodes.Brtrue, lblGetGlobal);
// Compute value of global value
StartNestedIterator(iter);
if (param != null)
{
Debug.Assert(iter.XmlType == TypeFactory.ItemS, "IlGen currently only supports parameters of type item*.");
// param = runtime.ExternalContext.GetParameter(localName, namespaceUri);
// if (param == null) goto LabelComputeGlobal;
LocalBuilder locParam = _helper.DeclareLocal("$$$param", typeof(object));
_helper.CallGetParameter(param.Name!.LocalName, param.Name.NamespaceUri);
_helper.Emit(OpCodes.Stloc, locParam);
_helper.Emit(OpCodes.Ldloc, locParam);
_helper.Emit(OpCodes.Brfalse, lblComputeGlobal);
// runtime.SetGlobalValue(idxValue, runtime.ChangeTypeXsltResult(idxType, value));
// Ensure that the storage type of the parameter corresponds to static type
_helper.LoadQueryRuntime();
_helper.LoadInteger(idxValue);
_helper.LoadQueryRuntime();
_helper.LoadInteger(_helper.StaticData.DeclareXmlType(XmlQueryTypeFactory.ItemS));
_helper.Emit(OpCodes.Ldloc, locParam);
_helper.Call(XmlILMethods.ChangeTypeXsltResult);
_helper.CallSetGlobalValue(typeof(object));
// goto LabelGetGlobal;
_helper.EmitUnconditionalBranch(OpCodes.Br, lblGetGlobal);
}
// LabelComputeGlobal:
_helper.MarkLabel(lblComputeGlobal);
if (iter.Binding != null)
{
// runtime.SetGlobalValue(idxValue, (object) value);
_helper.LoadQueryRuntime();
_helper.LoadInteger(idxValue);
// Compute value of global value
NestedVisitEnsureStack(iter.Binding, GetItemStorageType(iter), isCached);
_helper.CallSetGlobalValue(GetStorageType(iter));
}
else
{
// Throw exception, as there is no default value for this parameter
// XmlQueryRuntime.ThrowException("...");
Debug.Assert(iter.NodeType == QilNodeType.Parameter, "Only parameters may not have a default value");
_helper.LoadQueryRuntime();
_helper.Emit(OpCodes.Ldstr, SR.Format(SR.XmlIl_UnknownParam, new string?[] { param!.Name!.LocalName, param.Name.NamespaceUri }));
_helper.Call(XmlILMethods.ThrowException);
}
EndNestedIterator(iter);
// LabelGetGlobal:
// return (T) runtime.GetGlobalValue(idxValue);
_helper.MarkLabel(lblGetGlobal);
_helper.CallGetGlobalValue(idxValue, GetStorageType(iter));
_helper.MethodEnd();
}
}
/// <summary>
/// Generate code for the specified function.
/// </summary>
private void Function(QilFunction ndFunc)
{
MethodInfo methFunc;
int paramId;
IteratorDescriptor iterInfo;
bool useWriter;
// Annotate each function parameter with a IteratorDescriptor
foreach (QilIterator iter in ndFunc.Arguments)
{
Debug.Assert(iter.NodeType == QilNodeType.Parameter);
// Create an IteratorDescriptor for this parameter
iterInfo = new IteratorDescriptor(_helper);
// Add one to parameter index, as 0th parameter is always "this"
paramId = XmlILAnnotation.Write(iter).ArgumentPosition + 1;
// The ParameterInfo for each argument should be set as its location
iterInfo.Storage = StorageDescriptor.Parameter(paramId, GetItemStorageType(iter), !iter.XmlType!.IsSingleton);
// Associate IteratorDescriptor with Let iterator
XmlILAnnotation.Write(iter).CachedIteratorDescriptor = iterInfo;
}
methFunc = XmlILAnnotation.Write(ndFunc).FunctionBinding!;
useWriter = (XmlILConstructInfo.Read(ndFunc).ConstructMethod == XmlILConstructMethod.Writer);
// Generate query code from QilExpression tree
_helper.MethodBegin(methFunc, ndFunc.SourceLine, useWriter);
foreach (QilIterator iter in ndFunc.Arguments)
{
// DebugInfo: Sequence point just before generating code for the bound expression
if (_qil.IsDebug && iter.SourceLine != null)
_helper.DebugSequencePoint(iter.SourceLine);
// Calculate default value of this parameter
if (iter.Binding != null)
{
Debug.Assert(iter.XmlType == TypeFactory.ItemS, "IlGen currently only supports default values in parameters of type item*.");
paramId = (iter.Annotation as XmlILAnnotation)!.ArgumentPosition + 1;
// runtime.MatchesXmlType(param, XmlTypeCode.QName);
Label lblLocalComputed = _helper.DefineLabel();
_helper.LoadQueryRuntime();
_helper.LoadParameter(paramId);
_helper.LoadInteger((int)XmlTypeCode.QName);
_helper.Call(XmlILMethods.SeqMatchesCode);
_helper.Emit(OpCodes.Brfalse, lblLocalComputed);
// Compute default value of this parameter
StartNestedIterator(iter);
NestedVisitEnsureStack(iter.Binding, GetItemStorageType(iter), /*isCached:*/!iter.XmlType.IsSingleton);
EndNestedIterator(iter);
_helper.SetParameter(paramId);
_helper.MarkLabel(lblLocalComputed);
}
}
StartNestedIterator(ndFunc);
// If function did not push results to writer, then function will return value(s) (rather than void)
if (useWriter)
NestedVisit(ndFunc.Definition);
else
NestedVisitEnsureStack(ndFunc.Definition, GetItemStorageType(ndFunc), !ndFunc.XmlType!.IsSingleton);
EndNestedIterator(ndFunc);
_helper.MethodEnd();
}
//-----------------------------------------------
// QilVisitor
//-----------------------------------------------
/// <summary>
/// Generate a query plan for the QilExpression subgraph.
/// </summary>
protected override QilNode Visit(QilNode nd)
{
if (nd == null)
return null!;
// DebugInfo: Sequence point just before generating code for this expression
if (_qil.IsDebug && nd.SourceLine != null && !(nd is QilIterator))
_helper.DebugSequencePoint(nd.SourceLine);
// Expressions are constructed using one of several possible methods
switch (XmlILConstructInfo.Read(nd).ConstructMethod)
{
case XmlILConstructMethod.WriterThenIterator:
// Push results of expression to cached writer; then iterate over cached results
NestedConstruction(nd);
break;
case XmlILConstructMethod.IteratorThenWriter:
// Iterate over items in the sequence; send items to writer
CopySequence(nd);
break;
case XmlILConstructMethod.Iterator:
Debug.Assert(nd.XmlType!.IsSingleton || CachesResult(nd) || _iterCurr.HasLabelNext,
"When generating code for a non-singleton expression, LabelNext must be defined.");
goto default;
default:
// Allow base internal class to dispatch to correct Visit method
base.Visit(nd);
break;
}
return nd;
}
/// <summary>
/// VisitChildren should never be called.
/// </summary>
protected override QilNode VisitChildren(QilNode parent)
{
Debug.Fail("Visit" + parent.NodeType + " should never be called");
return parent;
}
/// <summary>
/// Generate code to cache a sequence of items that are pushed to output.
/// </summary>
private void NestedConstruction(QilNode nd)
{
// Start nested construction of a sequence of items
_helper.CallStartSequenceConstruction();
// Allow base internal class to dispatch to correct Visit method
base.Visit(nd);
// Get the result sequence
_helper.CallEndSequenceConstruction();
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathItem), true);
}
/// <summary>
/// Iterate over items produced by the "nd" expression and copy each item to output.
/// </summary>
private void CopySequence(QilNode nd)
{
XmlQueryType typ = nd.XmlType!;
bool hasOnEnd;
Label lblOnEnd;
StartWriterLoop(nd, out hasOnEnd, out lblOnEnd);
if (typ.IsSingleton)
{
// Always write atomic values via XmlQueryOutput
_helper.LoadQueryOutput();
// Allow base internal class to dispatch to correct Visit method
base.Visit(nd);
_iterCurr.EnsureItemStorageType(nd.XmlType!, typeof(XPathItem));
}
else
{
// Allow base internal class to dispatch to correct Visit method
base.Visit(nd);
_iterCurr.EnsureItemStorageType(nd.XmlType!, typeof(XPathItem));
// Save any stack values in a temporary local
_iterCurr.EnsureNoStackNoCache("$$$copyTemp");
_helper.LoadQueryOutput();
}
// Write value to output
_iterCurr.EnsureStackNoCache();
_helper.Call(XmlILMethods.WriteItem);
EndWriterLoop(nd, hasOnEnd, lblOnEnd);
}
/// <summary>
/// Generate code for QilNodeType.DataSource.
/// </summary>
/// <remarks>
/// Generates code to retrieve a document using the XmlResolver.
/// </remarks>
protected override QilNode VisitDataSource(QilDataSource ndSrc)
{
LocalBuilder locNav;
// XPathNavigator navDoc = runtime.ExternalContext.GetEntity(uri)
_helper.LoadQueryContext();
NestedVisitEnsureStack(ndSrc.Name);
NestedVisitEnsureStack(ndSrc.BaseUri);
_helper.Call(XmlILMethods.GetDataSource);
locNav = _helper.DeclareLocal("$$$navDoc", typeof(XPathNavigator));
_helper.Emit(OpCodes.Stloc, locNav);
// if (navDoc == null) goto LabelNextCtxt;
_helper.Emit(OpCodes.Ldloc, locNav);
_helper.Emit(OpCodes.Brfalse, _iterCurr.GetLabelNext());
_iterCurr.Storage = StorageDescriptor.Local(locNav, typeof(XPathNavigator), false);
return ndSrc;
}
/// <summary>
/// Generate code for QilNodeType.Nop.
/// </summary>
protected override QilNode VisitNop(QilUnary ndNop)
{
return Visit(ndNop.Child);
}
/// <summary>
/// Generate code for QilNodeType.OptimizeBarrier.
/// </summary>
protected override QilNode VisitOptimizeBarrier(QilUnary ndBarrier)
{
return Visit(ndBarrier.Child);
}
/// <summary>
/// Generate code for QilNodeType.Error.
/// </summary>
protected override QilNode VisitError(QilUnary ndErr)
{
// XmlQueryRuntime.ThrowException(strErr);
_helper.LoadQueryRuntime();
NestedVisitEnsureStack(ndErr.Child);
_helper.Call(XmlILMethods.ThrowException);
if (XmlILConstructInfo.Read(ndErr).ConstructMethod == XmlILConstructMethod.Writer)
{
_iterCurr.Storage = StorageDescriptor.None();
}
else
{
// Push dummy value so that Location is not None and IL rules are met
_helper.Emit(OpCodes.Ldnull);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathItem), false);
}
return ndErr;
}
/// <summary>
/// Generate code for QilNodeType.Warning.
/// </summary>
protected override QilNode VisitWarning(QilUnary ndWarning)
{
// runtime.SendMessage(strWarning);
_helper.LoadQueryRuntime();
NestedVisitEnsureStack(ndWarning.Child);
_helper.Call(XmlILMethods.SendMessage);
if (XmlILConstructInfo.Read(ndWarning).ConstructMethod == XmlILConstructMethod.Writer)
_iterCurr.Storage = StorageDescriptor.None();
else
VisitEmpty(ndWarning);
return ndWarning;
}
/// <summary>
/// Generate code for QilNodeType.True.
/// </summary>
/// <remarks>
/// BranchingContext.OnFalse context: [nothing]
/// BranchingContext.OnTrue context: goto LabelParent;
/// BranchingContext.None context: push true();
/// </remarks>
protected override QilNode VisitTrue(QilNode ndTrue)
{
if (_iterCurr.CurrentBranchingContext != BranchingContext.None)
{
// Make sure there's an IL code path to both the true and false branches in order to avoid dead
// code which can cause IL verification errors.
_helper.EmitUnconditionalBranch(_iterCurr.CurrentBranchingContext == BranchingContext.OnTrue ?
OpCodes.Brtrue : OpCodes.Brfalse, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
}
else
{
// Push boolean result onto the stack
_helper.LoadBoolean(true);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
}
return ndTrue;
}
/// <summary>
/// Generate code for QilNodeType.False.
/// </summary>
/// <remarks>
/// BranchingContext.OnFalse context: goto LabelParent;
/// BranchingContext.OnTrue context: [nothing]
/// BranchingContext.None context: push false();
/// </remarks>
protected override QilNode VisitFalse(QilNode ndFalse)
{
if (_iterCurr.CurrentBranchingContext != BranchingContext.None)
{
// Make sure there's an IL code path to both the true and false branches in order to avoid dead
// code which can cause IL verification errors.
_helper.EmitUnconditionalBranch(_iterCurr.CurrentBranchingContext == BranchingContext.OnFalse ?
OpCodes.Brtrue : OpCodes.Brfalse, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
}
else
{
// Push boolean result onto the stack
_helper.LoadBoolean(false);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
}
return ndFalse;
}
/// <summary>
/// Generate code for QilNodeType.LiteralString.
/// </summary>
protected override QilNode VisitLiteralString(QilLiteral ndStr)
{
_helper.Emit(OpCodes.Ldstr, (string)ndStr);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
return ndStr;
}
/// <summary>
/// Generate code for QilNodeType.LiteralInt32.
/// </summary>
protected override QilNode VisitLiteralInt32(QilLiteral ndInt)
{
_helper.LoadInteger((int)ndInt);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(int), false);
return ndInt;
}
/// <summary>
/// Generate code for QilNodeType.LiteralInt64.
/// </summary>
protected override QilNode VisitLiteralInt64(QilLiteral ndLong)
{
_helper.Emit(OpCodes.Ldc_I8, (long)ndLong);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(long), false);
return ndLong;
}
/// <summary>
/// Generate code for QilNodeType.LiteralDouble.
/// </summary>
protected override QilNode VisitLiteralDouble(QilLiteral ndDbl)
{
_helper.Emit(OpCodes.Ldc_R8, (double)ndDbl);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(double), false);
return ndDbl;
}
/// <summary>
/// Generate code for QilNodeType.LiteralDecimal.
/// </summary>
protected override QilNode VisitLiteralDecimal(QilLiteral ndDec)
{
_helper.ConstructLiteralDecimal((decimal)ndDec);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(decimal), false);
return ndDec;
}
/// <summary>
/// Generate code for QilNodeType.LiteralQName.
/// </summary>
protected override QilNode VisitLiteralQName(QilName ndQName)
{
_helper.ConstructLiteralQName(ndQName.LocalName, ndQName.NamespaceUri);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XmlQualifiedName), false);
return ndQName;
}
/// <summary>
/// Generate code for QilNodeType.And.
/// </summary>
/// <remarks>
/// BranchingContext.OnFalse context: (expr1) and (expr2)
/// ==> if (!expr1) goto LabelParent;
/// if (!expr2) goto LabelParent;
///
/// BranchingContext.OnTrue context: (expr1) and (expr2)
/// ==> if (!expr1) goto LabelTemp;
/// if (expr1) goto LabelParent;
/// LabelTemp:
///
/// BranchingContext.None context: (expr1) and (expr2)
/// ==> if (!expr1) goto LabelTemp;
/// if (!expr1) goto LabelTemp;
/// push true();
/// goto LabelSkip;
/// LabelTemp:
/// push false();
/// LabelSkip:
///
/// </remarks>
protected override QilNode VisitAnd(QilBinary ndAnd)
{
IteratorDescriptor iterParent = _iterCurr;
Label lblOnFalse;
// Visit left branch
StartNestedIterator(ndAnd.Left);
lblOnFalse = StartConjunctiveTests(iterParent.CurrentBranchingContext, iterParent.LabelBranch);
Visit(ndAnd.Left);
EndNestedIterator(ndAnd.Left);
// Visit right branch
StartNestedIterator(ndAnd.Right);
StartLastConjunctiveTest(iterParent.CurrentBranchingContext, iterParent.LabelBranch, lblOnFalse);
Visit(ndAnd.Right);
EndNestedIterator(ndAnd.Right);
// End And expression
EndConjunctiveTests(iterParent.CurrentBranchingContext, iterParent.LabelBranch, lblOnFalse);
return ndAnd;
}
/// <summary>
/// Fixup branching context for all but the last test in a conjunctive (Logical And) expression.
/// Return a temporary label which will be passed to StartLastAndBranch() and EndAndBranch().
/// </summary>
private Label StartConjunctiveTests(BranchingContext brctxt, Label lblBranch)
{
Label lblOnFalse;
switch (brctxt)
{
case BranchingContext.OnFalse:
// If condition evaluates to false, branch to false label
_iterCurr.SetBranching(BranchingContext.OnFalse, lblBranch);
return lblBranch;
default:
// If condition evaluates to false:
// 1. Jump to new false label that will be fixed just beyond the second condition
// 2. Or, jump to code that pushes "false"
lblOnFalse = _helper.DefineLabel();
_iterCurr.SetBranching(BranchingContext.OnFalse, lblOnFalse);
return lblOnFalse;
}
}
/// <summary>
/// Fixup branching context for the last test in a conjunctive (Logical And) expression.
/// </summary>
private void StartLastConjunctiveTest(BranchingContext brctxt, Label lblBranch, Label lblOnFalse)
{
switch (brctxt)
{
case BranchingContext.OnTrue:
// If last condition evaluates to true, branch to true label
_iterCurr.SetBranching(BranchingContext.OnTrue, lblBranch);
break;
default:
// If last condition evalutes to false, branch to false label
// Else fall through to true code path
_iterCurr.SetBranching(BranchingContext.OnFalse, lblOnFalse);
break;
}
}
/// <summary>
/// Anchor any remaining labels.
/// </summary>
private void EndConjunctiveTests(BranchingContext brctxt, Label lblBranch, Label lblOnFalse)
{
switch (brctxt)
{
case BranchingContext.OnTrue:
// Anchor false label
_helper.MarkLabel(lblOnFalse);
goto case BranchingContext.OnFalse;
case BranchingContext.OnFalse:
_iterCurr.Storage = StorageDescriptor.None();
break;
case BranchingContext.None:
// Convert branch targets into push of true/false
_helper.ConvBranchToBool(lblOnFalse, false);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
break;
}
}
/// <summary>
/// Generate code for QilNodeType.Or.
/// </summary>
/// <remarks>
/// BranchingContext.OnFalse context: (expr1) or (expr2)
/// ==> if (expr1) goto LabelTemp;
/// if (!expr2) goto LabelParent;
/// LabelTemp:
///
/// BranchingContext.OnTrue context: (expr1) or (expr2)
/// ==> if (expr1) goto LabelParent;
/// if (expr1) goto LabelParent;
///
/// BranchingContext.None context: (expr1) or (expr2)
/// ==> if (expr1) goto LabelTemp;
/// if (expr1) goto LabelTemp;
/// push false();
/// goto LabelSkip;
/// LabelTemp:
/// push true();
/// LabelSkip:
///
/// </remarks>
protected override QilNode VisitOr(QilBinary ndOr)
{
Label lblTemp = default;
// Visit left branch
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
// If left condition evaluates to true, jump to new label that will be fixed
// just beyond the second condition
lblTemp = _helper.DefineLabel();
NestedVisitWithBranch(ndOr.Left, BranchingContext.OnTrue, lblTemp);
break;
case BranchingContext.OnTrue:
// If left condition evaluates to true, branch to true label
NestedVisitWithBranch(ndOr.Left, BranchingContext.OnTrue, _iterCurr.LabelBranch);
break;
default:
// If left condition evalutes to true, jump to code that pushes "true"
Debug.Assert(_iterCurr.CurrentBranchingContext == BranchingContext.None);
lblTemp = _helper.DefineLabel();
NestedVisitWithBranch(ndOr.Left, BranchingContext.OnTrue, lblTemp);
break;
}
// Visit right branch
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
// If right condition evaluates to false, branch to false label
NestedVisitWithBranch(ndOr.Right, BranchingContext.OnFalse, _iterCurr.LabelBranch);
break;
case BranchingContext.OnTrue:
// If right condition evaluates to true, branch to true label
NestedVisitWithBranch(ndOr.Right, BranchingContext.OnTrue, _iterCurr.LabelBranch);
break;
default:
// If right condition evalutes to true, jump to code that pushes "true".
// Otherwise, if both conditions evaluate to false, fall through code path
// will push "false".
NestedVisitWithBranch(ndOr.Right, BranchingContext.OnTrue, lblTemp);
break;
}
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
// Anchor true label
_helper.MarkLabel(lblTemp);
goto case BranchingContext.OnTrue;
case BranchingContext.OnTrue:
_iterCurr.Storage = StorageDescriptor.None();
break;
case BranchingContext.None:
// Convert branch targets into push of true/false
_helper.ConvBranchToBool(lblTemp, true);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
break;
}
return ndOr;
}
/// <summary>
/// Generate code for QilNodeType.Not.
/// </summary>
/// <remarks>
/// BranchingContext.OnFalse context: not(expr1)
/// ==> if (expr1) goto LabelParent;
///
/// BranchingContext.OnTrue context: not(expr1)
/// ==> if (!expr1) goto LabelParent;
///
/// BranchingContext.None context: not(expr1)
/// ==> if (expr1) goto LabelTemp;
/// push false();
/// goto LabelSkip;
/// LabelTemp:
/// push true();
/// LabelSkip:
///
/// </remarks>
protected override QilNode VisitNot(QilUnary ndNot)
{
Label lblTemp = default;
// Visit operand
// Reverse branch types
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
NestedVisitWithBranch(ndNot.Child, BranchingContext.OnTrue, _iterCurr.LabelBranch);
break;
case BranchingContext.OnTrue:
NestedVisitWithBranch(ndNot.Child, BranchingContext.OnFalse, _iterCurr.LabelBranch);
break;
default:
// Replace boolean argument on top of stack with its inverse
Debug.Assert(_iterCurr.CurrentBranchingContext == BranchingContext.None);
lblTemp = _helper.DefineLabel();
NestedVisitWithBranch(ndNot.Child, BranchingContext.OnTrue, lblTemp);
break;
}
if (_iterCurr.CurrentBranchingContext == BranchingContext.None)
{
// If condition evaluates to true, then jump to code that pushes false
_helper.ConvBranchToBool(lblTemp, false);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
}
else
{
_iterCurr.Storage = StorageDescriptor.None();
}
return ndNot;
}
/// <summary>
/// Generate code for QilNodeType.Conditional.
/// </summary>
protected override QilNode VisitConditional(QilTernary ndCond)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(ndCond);
if (info.ConstructMethod == XmlILConstructMethod.Writer)
{
Label lblFalse, lblDone;
// Evaluate if test
lblFalse = _helper.DefineLabel();
NestedVisitWithBranch(ndCond.Left, BranchingContext.OnFalse, lblFalse);
// Generate true branch code
NestedVisit(ndCond.Center);
// Generate false branch code. If false branch is the empty list,
if (ndCond.Right.NodeType == QilNodeType.Sequence && ndCond.Right.Count == 0)
{
// Then generate simplified code that doesn't contain a false branch
_helper.MarkLabel(lblFalse);
NestedVisit(ndCond.Right);
}
else
{
// Jump past false branch
lblDone = _helper.DefineLabel();
_helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
// Generate false branch code
_helper.MarkLabel(lblFalse);
NestedVisit(ndCond.Right);
_helper.MarkLabel(lblDone);
}
_iterCurr.Storage = StorageDescriptor.None();
}
else
{
IteratorDescriptor? iterInfoTrue;
LocalBuilder? locBool = null, locCond = null;
Label lblFalse, lblDone, lblNext;
Type itemStorageType = GetItemStorageType(ndCond);
Debug.Assert(info.ConstructMethod == XmlILConstructMethod.Iterator);
// Evaluate conditional test -- save boolean result in boolResult
Debug.Assert(ndCond.Left.XmlType!.TypeCode == XmlTypeCode.Boolean);
lblFalse = _helper.DefineLabel();
if (ndCond.XmlType!.IsSingleton)
{
// if (!bool-expr) goto LabelFalse;
NestedVisitWithBranch(ndCond.Left, BranchingContext.OnFalse, lblFalse);
}
else
{
// CondType itemCond;
// int boolResult = bool-expr;
locCond = _helper.DeclareLocal("$$$cond", itemStorageType);
locBool = _helper.DeclareLocal("$$$boolResult", typeof(bool));
NestedVisitEnsureLocal(ndCond.Left, locBool);
// if (!boolResult) goto LabelFalse;
_helper.Emit(OpCodes.Ldloc, locBool);
_helper.Emit(OpCodes.Brfalse, lblFalse);
}
// Generate code for true branch
ConditionalBranch(ndCond.Center, itemStorageType, locCond);
iterInfoTrue = _iterNested;
// goto LabelDone;
lblDone = _helper.DefineLabel();
_helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
// Generate code for false branch
// LabelFalse:
_helper.MarkLabel(lblFalse);
ConditionalBranch(ndCond.Right, itemStorageType, locCond);
// If conditional is not cardinality one, then need to iterate through all values
if (!ndCond.XmlType.IsSingleton)
{
Debug.Assert(!ndCond.Center.XmlType!.IsSingleton || !ndCond.Right.XmlType!.IsSingleton);
// IL's rules do not allow OpCodes.Br here
// goto LabelDone;
_helper.EmitUnconditionalBranch(OpCodes.Brtrue, lblDone);
// LabelNext:
lblNext = _helper.DefineLabel();
_helper.MarkLabel(lblNext);
// if (boolResult) goto LabelNextTrue else goto LabelNextFalse;
_helper.Emit(OpCodes.Ldloc, locBool!);
_helper.Emit(OpCodes.Brtrue, iterInfoTrue!.GetLabelNext());
_helper.EmitUnconditionalBranch(OpCodes.Br, _iterNested!.GetLabelNext());
_iterCurr.SetIterator(lblNext, StorageDescriptor.Local(locCond!, itemStorageType, false));
}
// LabelDone:
_helper.MarkLabel(lblDone);
}
return ndCond;
}
/// <summary>
/// Generate code for one of the branches of QilNodeType.Conditional.
/// </summary>
private void ConditionalBranch(QilNode ndBranch, Type itemStorageType, LocalBuilder? locResult)
{
if (locResult == null)
{
Debug.Assert(ndBranch.XmlType!.IsSingleton, "Conditional must produce a singleton");
// If in a branching context, then inherit branch target from parent context
if (_iterCurr.IsBranching)
{
Debug.Assert(itemStorageType == typeof(bool));
NestedVisitWithBranch(ndBranch, _iterCurr.CurrentBranchingContext, _iterCurr.LabelBranch);
}
else
{
NestedVisitEnsureStack(ndBranch, itemStorageType, false);
}
}
else
{
// Link nested iterator to parent conditional's iterator
NestedVisit(ndBranch, _iterCurr.GetLabelNext());
_iterCurr.EnsureItemStorageType(ndBranch.XmlType!, itemStorageType);
_iterCurr.EnsureLocalNoCache(locResult);
}
}
/// <summary>
/// Generate code for QilNodeType.Choice.
/// </summary>
protected override QilNode VisitChoice(QilChoice ndChoice)
{
QilNode ndBranches;
Label[] switchLabels;
Label lblOtherwise, lblDone;
int regBranches, idx;
Debug.Assert(XmlILConstructInfo.Read(ndChoice).PushToWriterFirst);
// Evaluate the expression
NestedVisit(ndChoice.Expression);
// Generate switching code
ndBranches = ndChoice.Branches;
regBranches = ndBranches.Count - 1;
switchLabels = new Label[regBranches];
for (idx = 0; idx < regBranches; idx++)
switchLabels[idx] = _helper.DefineLabel();
lblOtherwise = _helper.DefineLabel();
lblDone = _helper.DefineLabel();
// switch (value)
// case 0: goto Label[0];
// ...
// case N-1: goto Label[N-1];
// default: goto LabelOtherwise;
_helper.Emit(OpCodes.Switch, switchLabels);
_helper.EmitUnconditionalBranch(OpCodes.Br, lblOtherwise);
for (idx = 0; idx < regBranches; idx++)
{
// Label[i]:
_helper.MarkLabel(switchLabels[idx]);
// Generate regular branch code
NestedVisit(ndBranches[idx]);
// goto LabelDone
_helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
}
// LabelOtherwise:
_helper.MarkLabel(lblOtherwise);
// Generate otherwise branch code
NestedVisit(ndBranches[idx]);
// LabelDone:
_helper.MarkLabel(lblDone);
_iterCurr.Storage = StorageDescriptor.None();
return ndChoice;
}
/// <summary>
/// Generate code for QilNodeType.Length.
/// </summary>
/// <remarks>
/// int length = 0;
/// foreach (item in expr)
/// length++;
/// </remarks>
protected override QilNode VisitLength(QilUnary ndSetLen)
{
Label lblOnEnd = _helper.DefineLabel();
OptimizerPatterns patt = OptimizerPatterns.Read(ndSetLen);
if (CachesResult(ndSetLen.Child))
{
NestedVisitEnsureStack(ndSetLen.Child);
_helper.CallCacheCount(_iterNested!.Storage.ItemStorageType);
}
else
{
// length = 0;
_helper.Emit(OpCodes.Ldc_I4_0);
StartNestedIterator(ndSetLen.Child, lblOnEnd);
// foreach (item in expr) {
Visit(ndSetLen.Child);
// Pop values of SetLength expression from the stack if necessary
_iterCurr.EnsureNoCache();
_iterCurr.DiscardStack();
// length++;
_helper.Emit(OpCodes.Ldc_I4_1);
_helper.Emit(OpCodes.Add);
if (patt.MatchesPattern(OptimizerPatternName.MaxPosition))
{
// Short-circuit rest of loop if max position has been exceeded
_helper.Emit(OpCodes.Dup);
_helper.LoadInteger((int)patt.GetArgument(OptimizerPatternArgument.MaxPosition));
_helper.Emit(OpCodes.Bgt, lblOnEnd);
}
// }
_iterCurr.LoopToEnd(lblOnEnd);
EndNestedIterator(ndSetLen.Child);
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(int), false);
return ndSetLen;
}
/// <summary>
/// Find physical query plan for QilNodeType.Sequence.
/// </summary>
protected override QilNode VisitSequence(QilList ndSeq)
{
if (XmlILConstructInfo.Read(ndSeq).ConstructMethod == XmlILConstructMethod.Writer)
{
// Push each item in the list to output
foreach (QilNode nd in ndSeq)
NestedVisit(nd);
}
else
{
// Empty sequence is special case
if (ndSeq.Count == 0)
VisitEmpty(ndSeq);
else
Sequence(ndSeq);
}
return ndSeq;
}
/// <summary>
/// Generate code for the empty sequence.
/// </summary>
private void VisitEmpty(QilNode nd)
{
Debug.Assert(XmlILConstructInfo.Read(nd).PullFromIteratorFirst, "VisitEmpty should only be called if items are iterated");
// IL's rules prevent OpCodes.Br here
// Empty sequence
_helper.EmitUnconditionalBranch(OpCodes.Brtrue, _iterCurr.GetLabelNext());
// Push dummy value so that Location is not None and IL rules are met
_helper.Emit(OpCodes.Ldnull);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathItem), false);
}
/// <summary>
/// Generate code for QilNodeType.Sequence, when sort-merging to retain document order is not necessary.
/// </summary>
private void Sequence(QilList ndSeq)
{
LocalBuilder locIdx, locList;
Label lblStart, lblNext, lblOnEnd = default;
Label[] arrSwitchLabels;
int i;
Type itemStorageType = GetItemStorageType(ndSeq);
Debug.Assert(XmlILConstructInfo.Read(ndSeq).ConstructMethod == XmlILConstructMethod.Iterator, "This method should only be called if items in list are pulled from a code iterator.");
// Singleton list is a special case if in addition to the singleton there are warnings or errors which should be executed
if (ndSeq.XmlType.IsSingleton)
{
foreach (QilNode nd in ndSeq)
{
// Generate nested iterator's code
if (nd.XmlType!.IsSingleton)
{
NestedVisitEnsureStack(nd);
}
else
{
lblOnEnd = _helper.DefineLabel();
NestedVisit(nd, lblOnEnd);
_iterCurr.DiscardStack();
_helper.MarkLabel(lblOnEnd);
}
}
_iterCurr.Storage = StorageDescriptor.Stack(itemStorageType, false);
}
else
{
// Type itemList;
// int idxList;
locList = _helper.DeclareLocal("$$$itemList", itemStorageType);
locIdx = _helper.DeclareLocal("$$$idxList", typeof(int));
arrSwitchLabels = new Label[ndSeq.Count];
lblStart = _helper.DefineLabel();
for (i = 0; i < ndSeq.Count; i++)
{
// LabelOnEnd[i - 1]:
// When previous nested iterator is exhausted, it should jump to this (the next) iterator
if (i != 0)
_helper.MarkLabel(lblOnEnd);
// Create new LabelOnEnd for all but the last iterator, which jumps back to parent iterator when exhausted
if (i == ndSeq.Count - 1)
lblOnEnd = _iterCurr.GetLabelNext();
else
lblOnEnd = _helper.DefineLabel();
// idxList = [i];
_helper.LoadInteger(i);
_helper.Emit(OpCodes.Stloc, locIdx);
// Generate nested iterator's code
NestedVisit(ndSeq[i], lblOnEnd);
// Result of list should be saved to a common type and location
_iterCurr.EnsureItemStorageType(ndSeq[i].XmlType!, itemStorageType);
_iterCurr.EnsureLocalNoCache(locList);
// Switch statement will jump to nested iterator's LabelNext
arrSwitchLabels[i] = _iterNested!.GetLabelNext();
// IL's rules prevent OpCodes.Br here
// goto LabelStart;
_helper.EmitUnconditionalBranch(OpCodes.Brtrue, lblStart);
}
// LabelNext:
lblNext = _helper.DefineLabel();
_helper.MarkLabel(lblNext);
// switch (idxList)
// case 0: goto LabelNext1;
// ...
// case N-1: goto LabelNext[N];
_helper.Emit(OpCodes.Ldloc, locIdx);
_helper.Emit(OpCodes.Switch, arrSwitchLabels);
// LabelStart:
_helper.MarkLabel(lblStart);
_iterCurr.SetIterator(lblNext, StorageDescriptor.Local(locList, itemStorageType, false));
}
}
/// <summary>
/// Generate code for QilNodeType.Union.
/// </summary>
protected override QilNode VisitUnion(QilBinary ndUnion)
{
return CreateSetIterator(ndUnion, "$$$iterUnion", typeof(UnionIterator), XmlILMethods.UnionCreate, XmlILMethods.UnionNext, XmlILMethods.UnionCurrent);
}
/// <summary>
/// Generate code for QilNodeType.Intersection.
/// </summary>
protected override QilNode VisitIntersection(QilBinary ndInter)
{
return CreateSetIterator(ndInter, "$$$iterInter", typeof(IntersectIterator), XmlILMethods.InterCreate, XmlILMethods.InterNext, XmlILMethods.InterCurrent);
}
/// <summary>
/// Generate code for QilNodeType.Difference.
/// </summary>
protected override QilNode VisitDifference(QilBinary ndDiff)
{
return CreateSetIterator(ndDiff, "$$$iterDiff", typeof(DifferenceIterator), XmlILMethods.DiffCreate, XmlILMethods.DiffNext, XmlILMethods.DiffCurrent);
}
/// <summary>
/// Generate code to combine nodes from two nested iterators using Union, Intersection, or Difference semantics.
/// </summary>
private QilNode CreateSetIterator(QilBinary ndSet, string iterName, Type iterType, MethodInfo methCreate, MethodInfo methNext, MethodInfo methCurrent)
{
LocalBuilder locIter, locNav;
Label lblNext, lblCall, lblNextLeft, lblNextRight, lblInitRight;
// SetIterator iterSet;
// XPathNavigator navSet;
locIter = _helper.DeclareLocal(iterName, iterType);
locNav = _helper.DeclareLocal("$$$navSet", typeof(XPathNavigator));
// iterSet.Create(runtime);
_helper.Emit(OpCodes.Ldloca, locIter);
_helper.LoadQueryRuntime();
_helper.Call(methCreate);
// Define labels that will be used
lblNext = _helper.DefineLabel();
lblCall = _helper.DefineLabel();
lblInitRight = _helper.DefineLabel();
// Generate left nested iterator. When it is empty, it will branch to lblNext.
// goto LabelCall;
NestedVisit(ndSet.Left, lblNext);
lblNextLeft = _iterNested!.GetLabelNext();
_iterCurr.EnsureLocal(locNav);
_helper.EmitUnconditionalBranch(OpCodes.Brtrue, lblCall);
// Generate right nested iterator. When it is empty, it will branch to lblNext.
// LabelInitRight:
// goto LabelCall;
_helper.MarkLabel(lblInitRight);
NestedVisit(ndSet.Right, lblNext);
lblNextRight = _iterNested.GetLabelNext();
_iterCurr.EnsureLocal(locNav);
_helper.EmitUnconditionalBranch(OpCodes.Brtrue, lblCall);
// LabelNext:
_helper.MarkLabel(lblNext);
_helper.Emit(OpCodes.Ldnull);
_helper.Emit(OpCodes.Stloc, locNav);
// LabelCall:
// switch (iterSet.MoveNext(nestedNested)) {
// case SetIteratorResult.NoMoreNodes: goto LabelNextCtxt;
// case SetIteratorResult.InitRightIterator: goto LabelInitRight;
// case SetIteratorResult.NeedLeftNode: goto LabelNextLeft;
// case SetIteratorResult.NeedRightNode: goto LabelNextRight;
// }
_helper.MarkLabel(lblCall);
_helper.Emit(OpCodes.Ldloca, locIter);
_helper.Emit(OpCodes.Ldloc, locNav);
_helper.Call(methNext);
// If this iterator always returns a single node, then NoMoreNodes will never be returned
// Don't expose Next label if this iterator always returns a single node
if (ndSet.XmlType!.IsSingleton)
{
_helper.Emit(OpCodes.Switch, new Label[] { lblInitRight, lblNextLeft, lblNextRight });
_iterCurr.Storage = StorageDescriptor.Current(locIter, methCurrent, typeof(XPathNavigator));
}
else
{
_helper.Emit(OpCodes.Switch, new Label[] { _iterCurr.GetLabelNext(), lblInitRight, lblNextLeft, lblNextRight });
_iterCurr.SetIterator(lblNext, StorageDescriptor.Current(locIter, methCurrent, typeof(XPathNavigator)));
}
return ndSet;
}
/// <summary>
/// Generate code for QilNodeType.Average.
/// </summary>
protected override QilNode VisitAverage(QilUnary ndAvg)
{
XmlILStorageMethods meths = XmlILMethods.StorageMethods[GetItemStorageType(ndAvg)];
return CreateAggregator(ndAvg, "$$$aggAvg", meths, meths.AggAvg!, meths.AggAvgResult!);
}
/// <summary>
/// Generate code for QilNodeType.Sum.
/// </summary>
protected override QilNode VisitSum(QilUnary ndSum)
{
XmlILStorageMethods meths = XmlILMethods.StorageMethods[GetItemStorageType(ndSum)];
return CreateAggregator(ndSum, "$$$aggSum", meths, meths.AggSum!, meths.AggSumResult!);
}
/// <summary>
/// Generate code for QilNodeType.Minimum.
/// </summary>
protected override QilNode VisitMinimum(QilUnary ndMin)
{
XmlILStorageMethods meths = XmlILMethods.StorageMethods[GetItemStorageType(ndMin)];
return CreateAggregator(ndMin, "$$$aggMin", meths, meths.AggMin!, meths.AggMinResult!);
}
/// <summary>
/// Generate code for QilNodeType.Maximum.
/// </summary>
protected override QilNode VisitMaximum(QilUnary ndMax)
{
XmlILStorageMethods meths = XmlILMethods.StorageMethods[GetItemStorageType(ndMax)];
return CreateAggregator(ndMax, "$$$aggMax", meths, meths.AggMax!, meths.AggMaxResult!);
}
/// <summary>
/// Generate code for QilNodeType.Sum, QilNodeType.Average, QilNodeType.Minimum, and QilNodeType.Maximum.
/// </summary>
private QilNode CreateAggregator(QilUnary ndAgg, string aggName, XmlILStorageMethods methods, MethodInfo methAgg, MethodInfo methResult)
{
Label lblOnEnd = _helper.DefineLabel();
Type typAgg = methAgg.DeclaringType!;
LocalBuilder locAgg;
// Aggregate agg;
// agg.Create();
locAgg = _helper.DeclareLocal(aggName, typAgg);
_helper.Emit(OpCodes.Ldloca, locAgg);
_helper.Call(methods.AggCreate!);
// foreach (num in expr) {
StartNestedIterator(ndAgg.Child, lblOnEnd);
_helper.Emit(OpCodes.Ldloca, locAgg);
Visit(ndAgg.Child);
// agg.Aggregate(num);
_iterCurr.EnsureStackNoCache();
_iterCurr.EnsureItemStorageType(ndAgg.XmlType!, GetItemStorageType(ndAgg));
_helper.Call(methAgg);
_helper.Emit(OpCodes.Ldloca, locAgg);
// }
_iterCurr.LoopToEnd(lblOnEnd);
// End nested iterator
EndNestedIterator(ndAgg.Child);
// If aggregate might be empty sequence, then generate code to handle this possibility
if (ndAgg.XmlType!.MaybeEmpty)
{
// if (agg.IsEmpty) goto LabelNextCtxt;
_helper.Call(methods.AggIsEmpty!);
_helper.Emit(OpCodes.Brtrue, _iterCurr.GetLabelNext());
_helper.Emit(OpCodes.Ldloca, locAgg);
}
// result = agg.Result;
_helper.Call(methResult);
_iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(ndAgg), false);
return ndAgg;
}
/// <summary>
/// Generate code for QilNodeType.Negate.
/// </summary>
protected override QilNode VisitNegate(QilUnary ndNeg)
{
NestedVisitEnsureStack(ndNeg.Child);
_helper.CallArithmeticOp(QilNodeType.Negate, ndNeg.XmlType!.TypeCode);
_iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(ndNeg), false);
return ndNeg;
}
/// <summary>
/// Generate code for QilNodeType.Add.
/// </summary>
protected override QilNode VisitAdd(QilBinary ndPlus)
{
return ArithmeticOp(ndPlus);
}
/// <summary>
/// Generate code for QilNodeType.Subtract.
/// </summary>
protected override QilNode VisitSubtract(QilBinary ndMinus)
{
return ArithmeticOp(ndMinus);
}
/// <summary>
/// Generate code for QilNodeType.Multiply.
/// </summary>
protected override QilNode VisitMultiply(QilBinary ndMul)
{
return ArithmeticOp(ndMul);
}
/// <summary>
/// Generate code for QilNodeType.Divide.
/// </summary>
protected override QilNode VisitDivide(QilBinary ndDiv)
{
return ArithmeticOp(ndDiv);
}
/// <summary>
/// Generate code for QilNodeType.Modulo.
/// </summary>
protected override QilNode VisitModulo(QilBinary ndMod)
{
return ArithmeticOp(ndMod);
}
/// <summary>
/// Generate code for two-argument arithmetic operations.
/// </summary>
private QilNode ArithmeticOp(QilBinary ndOp)
{
NestedVisitEnsureStack(ndOp.Left, ndOp.Right);
_helper.CallArithmeticOp(ndOp.NodeType, ndOp.XmlType!.TypeCode);
_iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(ndOp), false);
return ndOp;
}
/// <summary>
/// Generate code for QilNodeType.StrLength.
/// </summary>
protected override QilNode VisitStrLength(QilUnary ndLen)
{
NestedVisitEnsureStack(ndLen.Child);
_helper.Call(XmlILMethods.StrLen);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(int), false);
return ndLen;
}
/// <summary>
/// Generate code for QilNodeType.StrConcat.
/// </summary>
protected override QilNode VisitStrConcat(QilStrConcat ndStrConcat)
{
LocalBuilder locStringConcat;
bool fasterConcat;
QilNode? delimiter;
QilNode listStrings;
Debug.Assert(!ndStrConcat.Values.XmlType!.IsSingleton, "Optimizer should have folded StrConcat of a singleton value");
// Get delimiter (assuming it's not the empty string)
delimiter = ndStrConcat.Delimiter;
if (delimiter.NodeType == QilNodeType.LiteralString && ((string)(QilLiteral)delimiter).Length == 0)
{
delimiter = null;
}
listStrings = ndStrConcat.Values;
if (listStrings.NodeType == QilNodeType.Sequence && listStrings.Count < 5)
{
// Faster concat possible only if cardinality can be guaranteed at compile-time and there's no delimiter
fasterConcat = true;
foreach (QilNode ndStr in listStrings)
{
if (!ndStr.XmlType!.IsSingleton)
fasterConcat = false;
}
}
else
{
// If more than 4 strings, array will need to be built
fasterConcat = false;
}
if (fasterConcat)
{
foreach (QilNode ndStr in listStrings)
NestedVisitEnsureStack(ndStr);
_helper.CallConcatStrings(listStrings.Count);
}
else
{
// Create StringConcat helper internal class
locStringConcat = _helper.DeclareLocal("$$$strcat", typeof(StringConcat));
_helper.Emit(OpCodes.Ldloca, locStringConcat);
_helper.Call(XmlILMethods.StrCatClear);
// Set delimiter, if it's not empty string
if (delimiter != null)
{
_helper.Emit(OpCodes.Ldloca, locStringConcat);
NestedVisitEnsureStack(delimiter);
_helper.Call(XmlILMethods.StrCatDelim);
}
_helper.Emit(OpCodes.Ldloca, locStringConcat);
if (listStrings.NodeType == QilNodeType.Sequence)
{
foreach (QilNode ndStr in listStrings)
GenerateConcat(ndStr, locStringConcat);
}
else
{
GenerateConcat(listStrings, locStringConcat);
}
// Push resulting string onto stack
_helper.Call(XmlILMethods.StrCatResult);
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
return ndStrConcat;
}
/// <summary>
/// Generate code to concatenate string values returned by expression "ndStr" using the StringConcat helper class.
/// </summary>
private void GenerateConcat(QilNode ndStr, LocalBuilder locStringConcat)
{
Label lblOnEnd;
// str = each string;
lblOnEnd = _helper.DefineLabel();
StartNestedIterator(ndStr, lblOnEnd);
Visit(ndStr);
// strcat.Concat(str);
_iterCurr.EnsureStackNoCache();
_iterCurr.EnsureItemStorageType(ndStr.XmlType!, typeof(string));
_helper.Call(XmlILMethods.StrCatCat);
_helper.Emit(OpCodes.Ldloca, locStringConcat);
// Get next string
// goto LabelNext;
// LabelOnEnd:
_iterCurr.LoopToEnd(lblOnEnd);
// End nested iterator
EndNestedIterator(ndStr);
}
/// <summary>
/// Generate code for QilNodeType.StrParseQName.
/// </summary>
protected override QilNode VisitStrParseQName(QilBinary ndParsedTagName)
{
VisitStrParseQName(ndParsedTagName, false);
return ndParsedTagName;
}
/// <summary>
/// Generate code for QilNodeType.StrParseQName.
/// </summary>
private void VisitStrParseQName(QilBinary ndParsedTagName, bool preservePrefix)
{
// If QName prefix should be preserved, then don't create an XmlQualifiedName, which discards the prefix
if (!preservePrefix)
_helper.LoadQueryRuntime();
// Push (possibly computed) tag name onto the stack
NestedVisitEnsureStack(ndParsedTagName.Left);
// If type of second parameter is string,
if (ndParsedTagName.Right.XmlType!.TypeCode == XmlTypeCode.String)
{
// Then push (possibly computed) namespace onto the stack
Debug.Assert(ndParsedTagName.Right.XmlType.IsSingleton);
NestedVisitEnsureStack(ndParsedTagName.Right);
if (!preservePrefix)
_helper.CallParseTagName(GenerateNameType.TagNameAndNamespace);
}
else
{
// Else push index of set of prefix mappings to use in resolving the prefix
if (ndParsedTagName.Right.NodeType == QilNodeType.Sequence)
_helper.LoadInteger(_helper.StaticData.DeclarePrefixMappings(ndParsedTagName.Right));
else
_helper.LoadInteger(_helper.StaticData.DeclarePrefixMappings(new QilNode[] { ndParsedTagName.Right }));
// If QName prefix should be preserved, then don't create an XmlQualifiedName, which discards the prefix
if (!preservePrefix)
_helper.CallParseTagName(GenerateNameType.TagNameAndMappings);
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XmlQualifiedName), false);
}
/// <summary>
/// Generate code for QilNodeType.Ne.
/// </summary>
protected override QilNode VisitNe(QilBinary ndNe)
{
Compare(ndNe);
return ndNe;
}
/// <summary>
/// Generate code for QilNodeType.Eq.
/// </summary>
protected override QilNode VisitEq(QilBinary ndEq)
{
Compare(ndEq);
return ndEq;
}
/// <summary>
/// Generate code for QilNodeType.Gt.
/// </summary>
protected override QilNode VisitGt(QilBinary ndGt)
{
Compare(ndGt);
return ndGt;
}
/// <summary>
/// Generate code for QilNodeType.Ne.
/// </summary>
protected override QilNode VisitGe(QilBinary ndGe)
{
Compare(ndGe);
return ndGe;
}
/// <summary>
/// Generate code for QilNodeType.Lt.
/// </summary>
protected override QilNode VisitLt(QilBinary ndLt)
{
Compare(ndLt);
return ndLt;
}
/// <summary>
/// Generate code for QilNodeType.Le.
/// </summary>
protected override QilNode VisitLe(QilBinary ndLe)
{
Compare(ndLe);
return ndLe;
}
/// <summary>
/// Generate code for comparison operations.
/// </summary>
private void Compare(QilBinary ndComp)
{
QilNodeType relOp = ndComp.NodeType;
XmlTypeCode code;
Debug.Assert(ndComp.Left.XmlType!.IsAtomicValue && ndComp.Right.XmlType!.IsAtomicValue, "Operands to compare must be atomic values.");
Debug.Assert(ndComp.Left.XmlType.IsSingleton && ndComp.Right.XmlType.IsSingleton, "Operands to compare must be cardinality one.");
Debug.Assert(ndComp.Left.XmlType == ndComp.Right.XmlType, "Operands to compare may not be heterogenous.");
if (relOp == QilNodeType.Eq || relOp == QilNodeType.Ne)
{
// Generate better code for certain special cases
if (TryZeroCompare(relOp, ndComp.Left, ndComp.Right))
return;
if (TryZeroCompare(relOp, ndComp.Right, ndComp.Left))
return;
if (TryNameCompare(relOp, ndComp.Left, ndComp.Right))
return;
if (TryNameCompare(relOp, ndComp.Right, ndComp.Left))
return;
}
// Push two operands onto the stack
NestedVisitEnsureStack(ndComp.Left, ndComp.Right);
// Perform comparison
code = ndComp.Left.XmlType.TypeCode;
switch (code)
{
case XmlTypeCode.String:
case XmlTypeCode.Decimal:
case XmlTypeCode.QName:
if (relOp == QilNodeType.Eq || relOp == QilNodeType.Ne)
{
_helper.CallCompareEquals(code);
// If relOp is Eq, then branch to true label or push "true" if Equals function returns true (non-zero)
// If relOp is Ne, then branch to true label or push "true" if Equals function returns false (zero)
ZeroCompare((relOp == QilNodeType.Eq) ? QilNodeType.Ne : QilNodeType.Eq, true);
}
else
{
Debug.Assert(code != XmlTypeCode.QName, "QName values do not support the " + relOp + " operation");
// Push -1, 0, or 1 onto the stack depending upon the result of the comparison
_helper.CallCompare(code);
// Compare result to 0 (e.g. Ge is >= 0)
_helper.Emit(OpCodes.Ldc_I4_0);
ClrCompare(relOp, code);
}
break;
case XmlTypeCode.Integer:
case XmlTypeCode.Int:
case XmlTypeCode.Boolean:
case XmlTypeCode.Double:
ClrCompare(relOp, code);
break;
default:
Debug.Fail("Comparisons for datatype " + code + " are invalid.");
break;
}
}
/// <summary>
/// Generate code for QilNodeType.VisitIs.
/// </summary>
protected override QilNode VisitIs(QilBinary ndIs)
{
// Generate code to push arguments onto stack
NestedVisitEnsureStack(ndIs.Left, ndIs.Right);
_helper.Call(XmlILMethods.NavSamePos);
// navThis.IsSamePosition(navThat);
ZeroCompare(QilNodeType.Ne, true);
return ndIs;
}
/// <summary>
/// Generate code for QilNodeType.VisitBefore.
/// </summary>
protected override QilNode VisitBefore(QilBinary ndBefore)
{
ComparePosition(ndBefore);
return ndBefore;
}
/// <summary>
/// Generate code for QilNodeType.VisitAfter.
/// </summary>
protected override QilNode VisitAfter(QilBinary ndAfter)
{
ComparePosition(ndAfter);
return ndAfter;
}
/// <summary>
/// Generate code for QilNodeType.VisitBefore and QilNodeType.VisitAfter.
/// </summary>
private void ComparePosition(QilBinary ndComp)
{
// Generate code to push arguments onto stack
_helper.LoadQueryRuntime();
NestedVisitEnsureStack(ndComp.Left, ndComp.Right);
_helper.Call(XmlILMethods.CompPos);
// XmlQueryRuntime.ComparePosition(navThis, navThat) < 0;
_helper.LoadInteger(0);
ClrCompare(ndComp.NodeType == QilNodeType.Before ? QilNodeType.Lt : QilNodeType.Gt, XmlTypeCode.String);
}
/// <summary>
/// Generate code for a QilNodeType.For.
/// </summary>
protected override QilNode VisitFor(QilIterator ndFor)
{
IteratorDescriptor iterInfo;
// Reference saved location
iterInfo = XmlILAnnotation.Write(ndFor).CachedIteratorDescriptor!;
_iterCurr.Storage = iterInfo.Storage;
// If the iterator is a reference to a global variable or parameter,
if (_iterCurr.Storage.Location == ItemLocation.Global)
{
// Then compute global value and push it onto the stack
_iterCurr.EnsureStack();
}
return ndFor;
}
/// <summary>
/// Generate code for a QilNodeType.Let.
/// </summary>
protected override QilNode VisitLet(QilIterator ndLet)
{
// Same as For
return VisitFor(ndLet);
}
/// <summary>
/// Generate code for a QilNodeType.Parameter.
/// </summary>
protected override QilNode VisitParameter(QilParameter ndParameter)
{
// Same as For
return VisitFor(ndParameter);
}
/// <summary>
/// Generate code for a QilNodeType.Loop.
/// </summary>
protected override QilNode VisitLoop(QilLoop ndLoop)
{
bool hasOnEnd;
Label lblOnEnd;
StartWriterLoop(ndLoop, out hasOnEnd, out lblOnEnd);
StartBinding(ndLoop.Variable);
// Unnest loop body as part of the current iterator
Visit(ndLoop.Body);
EndBinding(ndLoop.Variable);
EndWriterLoop(ndLoop, hasOnEnd, lblOnEnd);
return ndLoop;
}
/// <summary>
/// Generate code for a QilNodeType.Filter.
/// </summary>
protected override QilNode VisitFilter(QilLoop ndFilter)
{
// Handle any special-case patterns that are rooted at Filter
if (HandleFilterPatterns(ndFilter))
return ndFilter;
StartBinding(ndFilter.Variable);
// Result of filter is the sequence bound to the iterator
_iterCurr.SetIterator(_iterNested!);
// If filter is false, skip the current item
StartNestedIterator(ndFilter.Body);
_iterCurr.SetBranching(BranchingContext.OnFalse, _iterCurr.ParentIterator!.GetLabelNext());
Visit(ndFilter.Body);
EndNestedIterator(ndFilter.Body);
EndBinding(ndFilter.Variable);
return ndFilter;
}
/// <summary>
/// There are a number of path patterns that can be rooted at Filter nodes. Determine whether one of these patterns
/// has been previously matched on "ndFilter". If so, generate code for the pattern and return true. Otherwise, just
/// return false.
/// </summary>
private bool HandleFilterPatterns(QilLoop ndFilter)
{
OptimizerPatterns patt = OptimizerPatterns.Read(ndFilter);
LocalBuilder locIter;
XmlNodeKindFlags kinds;
QilName? name;
QilNode input, step;
bool isFilterElements;
// Handle FilterElements and FilterContentKind patterns
isFilterElements = patt.MatchesPattern(OptimizerPatternName.FilterElements);
if (isFilterElements || patt.MatchesPattern(OptimizerPatternName.FilterContentKind))
{
if (isFilterElements)
{
// FilterElements pattern, so Kind = Element and Name = Argument
kinds = XmlNodeKindFlags.Element;
name = (QilName)patt.GetArgument(OptimizerPatternArgument.ElementQName);
}
else
{
// FilterKindTest pattern, so Kind = Argument and Name = null
kinds = ((XmlQueryType)patt.GetArgument(OptimizerPatternArgument.KindTestType)).NodeKinds;
name = null;
}
step = (QilNode)patt.GetArgument(OptimizerPatternArgument.StepNode);
input = (QilNode)patt.GetArgument(OptimizerPatternArgument.StepInput);
switch (step.NodeType)
{
case QilNodeType.Content:
if (isFilterElements)
{
// Iterator iter;
locIter = _helper.DeclareLocal("$$$iterElemContent", typeof(ElementContentIterator));
// iter.Create(navCtxt, locName, ns);
_helper.Emit(OpCodes.Ldloca, locIter);
NestedVisitEnsureStack(input);
_helper.CallGetAtomizedName(_helper.StaticData.DeclareName(name!.LocalName));
_helper.CallGetAtomizedName(_helper.StaticData.DeclareName(name.NamespaceUri));
_helper.Call(XmlILMethods.ElemContentCreate);
GenerateSimpleIterator(typeof(XPathNavigator), locIter, XmlILMethods.ElemContentNext, XmlILMethods.ElemContentCurrent);
}
else
{
if (kinds == XmlNodeKindFlags.Content)
{
CreateSimpleIterator(input, "$$$iterContent", typeof(ContentIterator), XmlILMethods.ContentCreate, XmlILMethods.ContentNext, XmlILMethods.ContentCurrent);
}
else
{
// Iterator iter;
locIter = _helper.DeclareLocal("$$$iterContent", typeof(NodeKindContentIterator));
// iter.Create(navCtxt, nodeType);
_helper.Emit(OpCodes.Ldloca, locIter);
NestedVisitEnsureStack(input);
_helper.LoadInteger((int)QilXmlToXPathNodeType(kinds));
_helper.Call(XmlILMethods.KindContentCreate);
GenerateSimpleIterator(typeof(XPathNavigator), locIter, XmlILMethods.KindContentNext, XmlILMethods.KindContentCurrent);
}
}
return true;
case QilNodeType.Parent:
CreateFilteredIterator(input, "$$$iterPar", typeof(ParentIterator), XmlILMethods.ParentCreate, XmlILMethods.ParentNext, XmlILMethods.ParentCurrent,
kinds, name, TriState.Unknown, null);
return true;
case QilNodeType.Ancestor:
case QilNodeType.AncestorOrSelf:
CreateFilteredIterator(input, "$$$iterAnc", typeof(AncestorIterator), XmlILMethods.AncCreate, XmlILMethods.AncNext, XmlILMethods.AncCurrent,
kinds, name, (step.NodeType == QilNodeType.Ancestor) ? TriState.False : TriState.True, null);
return true;
case QilNodeType.Descendant:
case QilNodeType.DescendantOrSelf:
CreateFilteredIterator(input, "$$$iterDesc", typeof(DescendantIterator), XmlILMethods.DescCreate, XmlILMethods.DescNext, XmlILMethods.DescCurrent,
kinds, name, (step.NodeType == QilNodeType.Descendant) ? TriState.False : TriState.True, null);
return true;
case QilNodeType.Preceding:
CreateFilteredIterator(input, "$$$iterPrec", typeof(PrecedingIterator), XmlILMethods.PrecCreate, XmlILMethods.PrecNext, XmlILMethods.PrecCurrent,
kinds, name, TriState.Unknown, null);
return true;
case QilNodeType.FollowingSibling:
CreateFilteredIterator(input, "$$$iterFollSib", typeof(FollowingSiblingIterator), XmlILMethods.FollSibCreate, XmlILMethods.FollSibNext, XmlILMethods.FollSibCurrent,
kinds, name, TriState.Unknown, null);
return true;
case QilNodeType.PrecedingSibling:
CreateFilteredIterator(input, "$$$iterPreSib", typeof(PrecedingSiblingIterator), XmlILMethods.PreSibCreate, XmlILMethods.PreSibNext, XmlILMethods.PreSibCurrent,
kinds, name, TriState.Unknown, null);
return true;
case QilNodeType.NodeRange:
CreateFilteredIterator(input, "$$$iterRange", typeof(NodeRangeIterator), XmlILMethods.NodeRangeCreate, XmlILMethods.NodeRangeNext, XmlILMethods.NodeRangeCurrent,
kinds, name, TriState.Unknown, ((QilBinary)step).Right);
return true;
case QilNodeType.XPathFollowing:
CreateFilteredIterator(input, "$$$iterFoll", typeof(XPathFollowingIterator), XmlILMethods.XPFollCreate, XmlILMethods.XPFollNext, XmlILMethods.XPFollCurrent,
kinds, name, TriState.Unknown, null);
return true;
case QilNodeType.XPathPreceding:
CreateFilteredIterator(input, "$$$iterPrec", typeof(XPathPrecedingIterator), XmlILMethods.XPPrecCreate, XmlILMethods.XPPrecNext, XmlILMethods.XPPrecCurrent,
kinds, name, TriState.Unknown, null);
return true;
default:
Debug.Fail($"Pattern {step.NodeType} should have been handled.");
break;
}
}
else if (patt.MatchesPattern(OptimizerPatternName.FilterAttributeKind))
{
// Handle FilterAttributeKind pattern
input = (QilNode)patt.GetArgument(OptimizerPatternArgument.StepInput);
CreateSimpleIterator(input, "$$$iterAttr", typeof(AttributeIterator), XmlILMethods.AttrCreate, XmlILMethods.AttrNext, XmlILMethods.AttrCurrent);
return true;
}
else if (patt.MatchesPattern(OptimizerPatternName.EqualityIndex))
{
// Handle EqualityIndex pattern
Label lblOnEnd = _helper.DefineLabel();
Label lblLookup = _helper.DefineLabel();
QilIterator nodes = (QilIterator)patt.GetArgument(OptimizerPatternArgument.IndexedNodes);
QilNode keys = (QilNode)patt.GetArgument(OptimizerPatternArgument.KeyExpression);
// XmlILIndex index;
// if (runtime.FindIndex(navCtxt, indexId, out index)) goto LabelLookup;
LocalBuilder locIndex = _helper.DeclareLocal("$$$index", typeof(XmlILIndex));
_helper.LoadQueryRuntime();
_helper.Emit(OpCodes.Ldarg_1);
_helper.LoadInteger(_indexId);
_helper.Emit(OpCodes.Ldloca, locIndex);
_helper.Call(XmlILMethods.FindIndex);
_helper.Emit(OpCodes.Brtrue, lblLookup);
// runtime.AddNewIndex(navCtxt, indexId, [build index]);
_helper.LoadQueryRuntime();
_helper.Emit(OpCodes.Ldarg_1);
_helper.LoadInteger(_indexId);
_helper.Emit(OpCodes.Ldloc, locIndex);
// Generate code to iterate over the nodes which are being indexed ($iterNodes in the pattern)
StartNestedIterator(nodes, lblOnEnd);
StartBinding(nodes);
// Generate code to iterate over the keys for each node ($bindingKeys in the pattern)
Visit(keys);
// index.Add(key, value);
_iterCurr.EnsureStackNoCache();
VisitFor(nodes);
_iterCurr.EnsureStackNoCache();
_iterCurr.EnsureItemStorageType(nodes.XmlType!, typeof(XPathNavigator));
_helper.Call(XmlILMethods.IndexAdd);
_helper.Emit(OpCodes.Ldloc, locIndex);
// LabelOnEnd:
_iterCurr.LoopToEnd(lblOnEnd);
EndBinding(nodes);
EndNestedIterator(nodes);
// runtime.AddNewIndex(navCtxt, indexId, [build index]);
_helper.Call(XmlILMethods.AddNewIndex);
// LabelLookup:
// results = index.Lookup(keyValue);
_helper.MarkLabel(lblLookup);
_helper.Emit(OpCodes.Ldloc, locIndex);
_helper.Emit(OpCodes.Ldarg_2);
_helper.Call(XmlILMethods.IndexLookup);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathNavigator), true);
_indexId++;
return true;
}
return false;
}
/// <summary>
/// Generate code for a Let, For, or Parameter iterator. Bind iterated value to a variable.
/// </summary>
private void StartBinding(QilIterator ndIter)
{
OptimizerPatterns patt = OptimizerPatterns.Read(ndIter);
Debug.Assert(ndIter != null);
// DebugInfo: Sequence point just before generating code for the bound expression
if (_qil.IsDebug && ndIter.SourceLine != null)
_helper.DebugSequencePoint(ndIter.SourceLine);
// Treat cardinality one Let iterators as if they were For iterators (no nesting necessary)
if (ndIter.NodeType == QilNodeType.For || ndIter.XmlType!.IsSingleton)
{
StartForBinding(ndIter, patt);
}
else
{
Debug.Assert(ndIter.NodeType == QilNodeType.Let || ndIter.NodeType == QilNodeType.Parameter);
Debug.Assert(!patt.MatchesPattern(OptimizerPatternName.IsPositional));
// Bind Let values (nested iterator) to variable
StartLetBinding(ndIter);
}
// Attach IteratorDescriptor to the iterator
XmlILAnnotation.Write(ndIter).CachedIteratorDescriptor = _iterNested;
}
/// <summary>
/// Bind values produced by the "ndFor" expression to a non-stack location that can later
/// be referenced.
/// </summary>
private void StartForBinding(QilIterator ndFor, OptimizerPatterns patt)
{
LocalBuilder? locPos = null;
Debug.Assert(ndFor.XmlType!.IsSingleton);
// For expression iterator will be unnested as part of parent iterator
if (_iterCurr.HasLabelNext)
StartNestedIterator(ndFor.Binding, _iterCurr.GetLabelNext());
else
StartNestedIterator(ndFor.Binding);
if (patt.MatchesPattern(OptimizerPatternName.IsPositional))
{
// Need to track loop index so initialize it to 0 before starting loop
locPos = _helper.DeclareLocal("$$$pos", typeof(int));
_helper.Emit(OpCodes.Ldc_I4_0);
_helper.Emit(OpCodes.Stloc, locPos);
}
// Allow base internal class to dispatch based on QilExpression node type
Visit(ndFor.Binding!);
// DebugInfo: Open variable scope
// DebugInfo: Ensure that for variable is stored in a local and tag it with the user-defined name
if (_qil.IsDebug && ndFor.DebugName != null)
{
_helper.DebugStartScope();
// Ensure that values are stored in a local variable with a user-defined name
_iterCurr.EnsureLocalNoCache("$$$for");
}
else
{
// Ensure that values are not stored on the stack
_iterCurr.EnsureNoStackNoCache("$$$for");
}
if (patt.MatchesPattern(OptimizerPatternName.IsPositional))
{
// Increment position
_helper.Emit(OpCodes.Ldloc, locPos!);
_helper.Emit(OpCodes.Ldc_I4_1);
_helper.Emit(OpCodes.Add);
_helper.Emit(OpCodes.Stloc, locPos!);
if (patt.MatchesPattern(OptimizerPatternName.MaxPosition))
{
// Short-circuit rest of loop if max position has already been reached
_helper.Emit(OpCodes.Ldloc, locPos!);
_helper.LoadInteger((int)patt.GetArgument(OptimizerPatternArgument.MaxPosition));
_helper.Emit(OpCodes.Bgt, _iterCurr.ParentIterator!.GetLabelNext());
}
_iterCurr.LocalPosition = locPos;
}
EndNestedIterator(ndFor.Binding!);
_iterCurr.SetIterator(_iterNested!);
}
/// <summary>
/// Bind values in the "ndLet" expression to a non-stack location that can later be referenced.
/// </summary>
public void StartLetBinding(QilIterator ndLet)
{
Debug.Assert(!ndLet.XmlType!.IsSingleton);
// Construct nested iterator
StartNestedIterator(ndLet);
// Allow base internal class to dispatch based on QilExpression node type
NestedVisit(ndLet.Binding!, GetItemStorageType(ndLet), !ndLet.XmlType.IsSingleton);
// DebugInfo: Open variable scope
// DebugInfo: Ensure that for variable is stored in a local and tag it with the user-defined name
if (_qil.IsDebug && ndLet.DebugName != null)
{
_helper.DebugStartScope();
// Ensure that cache is stored in a local variable with a user-defined name
_iterCurr.EnsureLocal("$$$cache");
}
else
{
// Ensure that cache is not stored on the stack
_iterCurr.EnsureNoStack("$$$cache");
}
EndNestedIterator(ndLet);
}
/// <summary>
/// Mark iterator variables as out-of-scope.
/// </summary>
private void EndBinding(QilIterator ndIter)
{
Debug.Assert(ndIter != null);
// Variables go out of scope here
if (_qil.IsDebug && ndIter.DebugName != null)
_helper.DebugEndScope();
}
/// <summary>
/// Generate code for QilNodeType.PositionOf.
/// </summary>
protected override QilNode VisitPositionOf(QilUnary ndPos)
{
QilIterator ndIter = (ndPos.Child as QilIterator)!;
LocalBuilder locPos;
Debug.Assert(ndIter.NodeType == QilNodeType.For);
locPos = XmlILAnnotation.Write(ndIter).CachedIteratorDescriptor!.LocalPosition!;
Debug.Assert(locPos != null);
_iterCurr.Storage = StorageDescriptor.Local(locPos, typeof(int), false);
return ndPos;
}
/// <summary>
/// Generate code for QilNodeType.Sort.
/// </summary>
protected override QilNode VisitSort(QilLoop ndSort)
{
Type itemStorageType = GetItemStorageType(ndSort);
LocalBuilder locCache, locKeys;
Label lblOnEndSort = _helper.DefineLabel();
Debug.Assert(ndSort.Variable.NodeType == QilNodeType.For);
// XmlQuerySequence<T> cache;
// cache = XmlQuerySequence.CreateOrReuse(cache);
XmlILStorageMethods methods = XmlILMethods.StorageMethods[itemStorageType];
locCache = _helper.DeclareLocal("$$$cache", methods.SeqType);
_helper.Emit(OpCodes.Ldloc, locCache);
_helper.Call(methods.SeqReuse);
_helper.Emit(OpCodes.Stloc, locCache);
_helper.Emit(OpCodes.Ldloc, locCache);
// XmlSortKeyAccumulator keys;
// keys.Create(runtime);
locKeys = _helper.DeclareLocal("$$$keys", typeof(XmlSortKeyAccumulator));
_helper.Emit(OpCodes.Ldloca, locKeys);
_helper.Call(XmlILMethods.SortKeyCreate);
// Construct nested iterator
// foreach (item in sort-expr) {
StartNestedIterator(ndSort.Variable, lblOnEndSort);
StartBinding(ndSort.Variable);
Debug.Assert(!_iterNested!.Storage.IsCached);
// cache.Add(item);
_iterCurr.EnsureStackNoCache();
_iterCurr.EnsureItemStorageType(ndSort.Variable.XmlType!, GetItemStorageType(ndSort.Variable));
_helper.Call(methods.SeqAdd);
_helper.Emit(OpCodes.Ldloca, locKeys);
// Add keys to accumulator (there may be several keys)
foreach (QilSortKey ndKey in ndSort.Body)
VisitSortKey(ndKey, locKeys);
// keys.FinishSortKeys();
_helper.Call(XmlILMethods.SortKeyFinish);
// }
_helper.Emit(OpCodes.Ldloc, locCache);
_iterCurr.LoopToEnd(lblOnEndSort);
// Remove cache reference from stack
_helper.Emit(OpCodes.Pop);
// cache.SortByKeys(keys.Keys);
_helper.Emit(OpCodes.Ldloc, locCache);
_helper.Emit(OpCodes.Ldloca, locKeys);
_helper.Call(XmlILMethods.SortKeyKeys);
_helper.Call(methods.SeqSortByKeys);
// End nested iterator
_iterCurr.Storage = StorageDescriptor.Local(locCache, itemStorageType, true);
EndBinding(ndSort.Variable);
EndNestedIterator(ndSort.Variable);
_iterCurr.SetIterator(_iterNested);
return ndSort;
}
/// <summary>
/// Generate code to add a (value, collation) sort key to the XmlSortKeyAccumulator.
/// </summary>
private void VisitSortKey(QilSortKey ndKey, LocalBuilder locKeys)
{
Label lblOnEndKey;
Debug.Assert(ndKey.Key.XmlType!.IsAtomicValue, "Sort key must be an atomic value.");
// Push collation onto the stack
_helper.Emit(OpCodes.Ldloca, locKeys);
if (ndKey.Collation.NodeType == QilNodeType.LiteralString)
{
// collation = runtime.GetCollation(idx);
_helper.CallGetCollation(_helper.StaticData.DeclareCollation((string)(QilLiteral)ndKey.Collation));
}
else
{
// collation = runtime.CreateCollation(str);
_helper.LoadQueryRuntime();
NestedVisitEnsureStack(ndKey.Collation);
_helper.Call(XmlILMethods.CreateCollation);
}
if (ndKey.XmlType!.IsSingleton)
{
NestedVisitEnsureStack(ndKey.Key);
// keys.AddSortKey(collation, value);
_helper.AddSortKey(ndKey.Key.XmlType);
}
else
{
lblOnEndKey = _helper.DefineLabel();
StartNestedIterator(ndKey.Key, lblOnEndKey);
Visit(ndKey.Key);
_iterCurr.EnsureStackNoCache();
_iterCurr.EnsureItemStorageType(ndKey.Key.XmlType, GetItemStorageType(ndKey.Key));
// Non-empty sort key
// keys.AddSortKey(collation, value);
_helper.AddSortKey(ndKey.Key.XmlType);
// goto LabelDone;
// LabelOnEnd:
Label lblDone = _helper.DefineLabel();
_helper.EmitUnconditionalBranch(OpCodes.Br_S, lblDone);
_helper.MarkLabel(lblOnEndKey);
// Empty sequence key
// keys.AddSortKey(collation);
_helper.AddSortKey(null);
_helper.MarkLabel(lblDone);
EndNestedIterator(ndKey.Key);
}
}
/// <summary>
/// Generate code for QilNodeType.DocOrderDistinct.
/// </summary>
protected override QilNode VisitDocOrderDistinct(QilUnary ndDod)
{
// DocOrderDistinct applied to a singleton is a no-op
if (ndDod.XmlType!.IsSingleton)
return Visit(ndDod.Child);
// Handle any special-case patterns that are rooted at DocOrderDistinct
if (HandleDodPatterns(ndDod))
return ndDod;
// Sort results of child expression by document order and remove duplicate nodes
// cache = runtime.DocOrderDistinct(cache);
_helper.LoadQueryRuntime();
NestedVisitEnsureCache(ndDod.Child, typeof(XPathNavigator));
_iterCurr.EnsureStack();
_helper.Call(XmlILMethods.DocOrder);
return ndDod;
}
/// <summary>
/// There are a number of path patterns that can be rooted at DocOrderDistinct nodes. Determine whether one of these
/// patterns has been previously matched on "ndDod". If so, generate code for the pattern and return true. Otherwise,
/// just return false.
/// </summary>
private bool HandleDodPatterns(QilUnary ndDod)
{
OptimizerPatterns pattDod = OptimizerPatterns.Read(ndDod);
XmlNodeKindFlags kinds;
QilName? name;
QilNode input, step;
bool isJoinAndDod;
// Handle JoinAndDod and DodReverse patterns
isJoinAndDod = pattDod.MatchesPattern(OptimizerPatternName.JoinAndDod);
if (isJoinAndDod || pattDod.MatchesPattern(OptimizerPatternName.DodReverse))
{
OptimizerPatterns pattStep = OptimizerPatterns.Read((QilNode)pattDod.GetArgument(OptimizerPatternArgument.DodStep));
if (pattStep.MatchesPattern(OptimizerPatternName.FilterElements))
{
// FilterElements pattern, so Kind = Element and Name = Argument
kinds = XmlNodeKindFlags.Element;
name = (QilName)pattStep.GetArgument(OptimizerPatternArgument.ElementQName);
}
else if (pattStep.MatchesPattern(OptimizerPatternName.FilterContentKind))
{
// FilterKindTest pattern, so Kind = Argument and Name = null
kinds = ((XmlQueryType)pattStep.GetArgument(OptimizerPatternArgument.KindTestType)).NodeKinds;
name = null;
}
else
{
Debug.Assert(pattStep.MatchesPattern(OptimizerPatternName.Axis), "Dod patterns should only match if step is FilterElements or FilterKindTest or Axis");
kinds = ((ndDod.XmlType!.NodeKinds & XmlNodeKindFlags.Attribute) != 0) ? XmlNodeKindFlags.Any : XmlNodeKindFlags.Content;
name = null;
}
step = (QilNode)pattStep.GetArgument(OptimizerPatternArgument.StepNode);
if (isJoinAndDod)
{
switch (step.NodeType)
{
case QilNodeType.Content:
CreateContainerIterator(ndDod, "$$$iterContent", typeof(ContentMergeIterator), XmlILMethods.ContentMergeCreate, XmlILMethods.ContentMergeNext, XmlILMethods.ContentMergeCurrent,
kinds, name, TriState.Unknown);
return true;
case QilNodeType.Descendant:
case QilNodeType.DescendantOrSelf:
CreateContainerIterator(ndDod, "$$$iterDesc", typeof(DescendantMergeIterator), XmlILMethods.DescMergeCreate, XmlILMethods.DescMergeNext, XmlILMethods.DescMergeCurrent,
kinds, name, (step.NodeType == QilNodeType.Descendant) ? TriState.False : TriState.True);
return true;
case QilNodeType.XPathFollowing:
CreateContainerIterator(ndDod, "$$$iterFoll", typeof(XPathFollowingMergeIterator), XmlILMethods.XPFollMergeCreate, XmlILMethods.XPFollMergeNext, XmlILMethods.XPFollMergeCurrent,
kinds, name, TriState.Unknown);
return true;
case QilNodeType.FollowingSibling:
CreateContainerIterator(ndDod, "$$$iterFollSib", typeof(FollowingSiblingMergeIterator), XmlILMethods.FollSibMergeCreate, XmlILMethods.FollSibMergeNext, XmlILMethods.FollSibMergeCurrent,
kinds, name, TriState.Unknown);
return true;
case QilNodeType.XPathPreceding:
CreateContainerIterator(ndDod, "$$$iterPrec", typeof(XPathPrecedingMergeIterator), XmlILMethods.XPPrecMergeCreate, XmlILMethods.XPPrecMergeNext, XmlILMethods.XPPrecMergeCurrent,
kinds, name, TriState.Unknown);
return true;
default:
Debug.Fail($"Pattern {step.NodeType} should have been handled.");
break;
}
}
else
{
input = (QilNode)pattStep.GetArgument(OptimizerPatternArgument.StepInput);
switch (step.NodeType)
{
case QilNodeType.Ancestor:
case QilNodeType.AncestorOrSelf:
CreateFilteredIterator(input, "$$$iterAnc", typeof(AncestorDocOrderIterator), XmlILMethods.AncDOCreate, XmlILMethods.AncDONext, XmlILMethods.AncDOCurrent,
kinds, name, (step.NodeType == QilNodeType.Ancestor) ? TriState.False : TriState.True, null);
return true;
case QilNodeType.PrecedingSibling:
CreateFilteredIterator(input, "$$$iterPreSib", typeof(PrecedingSiblingDocOrderIterator), XmlILMethods.PreSibDOCreate, XmlILMethods.PreSibDONext, XmlILMethods.PreSibDOCurrent,
kinds, name, TriState.Unknown, null);
return true;
case QilNodeType.XPathPreceding:
CreateFilteredIterator(input, "$$$iterPrec", typeof(XPathPrecedingDocOrderIterator), XmlILMethods.XPPrecDOCreate, XmlILMethods.XPPrecDONext, XmlILMethods.XPPrecDOCurrent,
kinds, name, TriState.Unknown, null);
return true;
default:
Debug.Fail($"Pattern {step.NodeType} should have been handled.");
break;
}
}
}
else if (pattDod.MatchesPattern(OptimizerPatternName.DodMerge))
{
// DodSequenceMerge dodMerge;
LocalBuilder locMerge = _helper.DeclareLocal("$$$dodMerge", typeof(DodSequenceMerge));
Label lblOnEnd = _helper.DefineLabel();
// dodMerge.Create(runtime);
_helper.Emit(OpCodes.Ldloca, locMerge);
_helper.LoadQueryRuntime();
_helper.Call(XmlILMethods.DodMergeCreate);
_helper.Emit(OpCodes.Ldloca, locMerge);
StartNestedIterator(ndDod.Child, lblOnEnd);
// foreach (seq in expr) {
Visit(ndDod.Child);
// dodMerge.AddSequence(seq);
Debug.Assert(_iterCurr.Storage.IsCached, "DodMerge pattern should only be matched when cached sequences are returned from loop");
_iterCurr.EnsureStack();
_helper.Call(XmlILMethods.DodMergeAdd);
_helper.Emit(OpCodes.Ldloca, locMerge);
// }
_iterCurr.LoopToEnd(lblOnEnd);
EndNestedIterator(ndDod.Child);
// mergedSequence = dodMerge.MergeSequences();
_helper.Call(XmlILMethods.DodMergeSeq);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathNavigator), true);
return true;
}
return false;
}
/// <summary>
/// Generate code for QilNodeType.Invoke.
/// </summary>
protected override QilNode VisitInvoke(QilInvoke ndInvoke)
{
QilFunction ndFunc = ndInvoke.Function;
MethodInfo methInfo = XmlILAnnotation.Write(ndFunc).FunctionBinding!;
bool useWriter = (XmlILConstructInfo.Read(ndFunc).ConstructMethod == XmlILConstructMethod.Writer);
Debug.Assert(!XmlILConstructInfo.Read(ndInvoke).PushToWriterFirst || useWriter);
// Push XmlQueryRuntime onto the stack as the first parameter
_helper.LoadQueryRuntime();
// Generate code to push each Invoke argument onto the stack
for (int iArg = 0; iArg < ndInvoke.Arguments.Count; iArg++)
{
QilNode ndActualArg = ndInvoke.Arguments[iArg];
QilNode ndFormalArg = ndInvoke.Function.Arguments[iArg];
NestedVisitEnsureStack(ndActualArg, GetItemStorageType(ndFormalArg), !ndFormalArg.XmlType!.IsSingleton);
}
// Check whether this call should compiled using the .tailcall instruction
if (OptimizerPatterns.Read(ndInvoke).MatchesPattern(OptimizerPatternName.TailCall))
_helper.TailCall(methInfo);
else
_helper.Call(methInfo);
// If function's results are not pushed to Writer,
if (!useWriter)
{
// Return value is on the stack; ensure it has the correct storage type
_iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(ndInvoke), !ndInvoke.XmlType!.IsSingleton);
}
else
{
_iterCurr.Storage = StorageDescriptor.None();
}
return ndInvoke;
}
/// <summary>
/// Generate code for QilNodeType.Content.
/// </summary>
protected override QilNode VisitContent(QilUnary ndContent)
{
CreateSimpleIterator(ndContent.Child, "$$$iterAttrContent", typeof(AttributeContentIterator), XmlILMethods.AttrContentCreate, XmlILMethods.AttrContentNext, XmlILMethods.AttrContentCurrent);
return ndContent;
}
/// <summary>
/// Generate code for QilNodeType.Attribute.
/// </summary>
protected override QilNode VisitAttribute(QilBinary ndAttr)
{
QilName? ndName = ndAttr.Right as QilName;
Debug.Assert(ndName != null, "Attribute node must have a literal QName as its second argument");
// XPathNavigator navAttr;
LocalBuilder locNav = _helper.DeclareLocal("$$$navAttr", typeof(XPathNavigator));
// navAttr = SyncToNavigator(navAttr, navCtxt);
SyncToNavigator(locNav, ndAttr.Left);
// if (!navAttr.MoveToAttribute(localName, namespaceUri)) goto LabelNextCtxt;
_helper.Emit(OpCodes.Ldloc, locNav);
_helper.CallGetAtomizedName(_helper.StaticData.DeclareName(ndName.LocalName));
_helper.CallGetAtomizedName(_helper.StaticData.DeclareName(ndName.NamespaceUri));
_helper.Call(XmlILMethods.NavMoveAttr);
_helper.Emit(OpCodes.Brfalse, _iterCurr.GetLabelNext());
_iterCurr.Storage = StorageDescriptor.Local(locNav, typeof(XPathNavigator), false);
return ndAttr;
}
/// <summary>
/// Generate code for QilNodeType.Parent.
/// </summary>
protected override QilNode VisitParent(QilUnary ndParent)
{
// XPathNavigator navParent;
LocalBuilder locNav = _helper.DeclareLocal("$$$navParent", typeof(XPathNavigator));
// navParent = SyncToNavigator(navParent, navCtxt);
SyncToNavigator(locNav, ndParent.Child);
// if (!navParent.MoveToParent()) goto LabelNextCtxt;
_helper.Emit(OpCodes.Ldloc, locNav);
_helper.Call(XmlILMethods.NavMoveParent);
_helper.Emit(OpCodes.Brfalse, _iterCurr.GetLabelNext());
_iterCurr.Storage = StorageDescriptor.Local(locNav, typeof(XPathNavigator), false);
return ndParent;
}
/// <summary>
/// Generate code for QilNodeType.Root.
/// </summary>
protected override QilNode VisitRoot(QilUnary ndRoot)
{
// XPathNavigator navRoot;
LocalBuilder locNav = _helper.DeclareLocal("$$$navRoot", typeof(XPathNavigator));
// navRoot = SyncToNavigator(navRoot, navCtxt);
SyncToNavigator(locNav, ndRoot.Child);
// navRoot.MoveToRoot();
_helper.Emit(OpCodes.Ldloc, locNav);
_helper.Call(XmlILMethods.NavMoveRoot);
_iterCurr.Storage = StorageDescriptor.Local(locNav, typeof(XPathNavigator), false);
return ndRoot;
}
/// <summary>
/// Generate code for QilNodeType.XmlContext.
/// </summary>
/// <remarks>
/// Generates code to retrieve the default document using the XmlResolver.
/// </remarks>
protected override QilNode VisitXmlContext(QilNode ndCtxt)
{
// runtime.ExternalContext.DefaultDataSource
_helper.LoadQueryContext();
_helper.Call(XmlILMethods.GetDefaultDataSource);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathNavigator), false);
return ndCtxt;
}
/// <summary>
/// Find physical query plan for QilNodeType.Descendant.
/// </summary>
protected override QilNode VisitDescendant(QilUnary ndDesc)
{
CreateFilteredIterator(ndDesc.Child, "$$$iterDesc", typeof(DescendantIterator), XmlILMethods.DescCreate, XmlILMethods.DescNext, XmlILMethods.DescCurrent,
XmlNodeKindFlags.Any, null, TriState.False, null);
return ndDesc;
}
/// <summary>
/// Generate code for QilNodeType.DescendantOrSelf.
/// </summary>
protected override QilNode VisitDescendantOrSelf(QilUnary ndDesc)
{
CreateFilteredIterator(ndDesc.Child, "$$$iterDesc", typeof(DescendantIterator), XmlILMethods.DescCreate, XmlILMethods.DescNext, XmlILMethods.DescCurrent,
XmlNodeKindFlags.Any, null, TriState.True, null);
return ndDesc;
}
/// <summary>
/// Find physical query plan for QilNodeType.Ancestor.
/// </summary>
protected override QilNode VisitAncestor(QilUnary ndAnc)
{
CreateFilteredIterator(ndAnc.Child, "$$$iterAnc", typeof(AncestorIterator), XmlILMethods.AncCreate, XmlILMethods.AncNext, XmlILMethods.AncCurrent,
XmlNodeKindFlags.Any, null, TriState.False, null);
return ndAnc;
}
/// <summary>
/// Find physical query plan for QilNodeType.AncestorOrSelf.
/// </summary>
protected override QilNode VisitAncestorOrSelf(QilUnary ndAnc)
{
CreateFilteredIterator(ndAnc.Child, "$$$iterAnc", typeof(AncestorIterator), XmlILMethods.AncCreate, XmlILMethods.AncNext, XmlILMethods.AncCurrent,
XmlNodeKindFlags.Any, null, TriState.True, null);
return ndAnc;
}
/// <summary>
/// Find physical query plan for QilNodeType.Preceding.
/// </summary>
protected override QilNode VisitPreceding(QilUnary ndPrec)
{
CreateFilteredIterator(ndPrec.Child, "$$$iterPrec", typeof(PrecedingIterator), XmlILMethods.PrecCreate, XmlILMethods.PrecNext, XmlILMethods.PrecCurrent,
XmlNodeKindFlags.Any, null, TriState.Unknown, null);
return ndPrec;
}
/// <summary>
/// Find physical query plan for QilNodeType.FollowingSibling.
/// </summary>
protected override QilNode VisitFollowingSibling(QilUnary ndFollSib)
{
CreateFilteredIterator(ndFollSib.Child, "$$$iterFollSib", typeof(FollowingSiblingIterator), XmlILMethods.FollSibCreate, XmlILMethods.FollSibNext, XmlILMethods.FollSibCurrent,
XmlNodeKindFlags.Any, null, TriState.Unknown, null);
return ndFollSib;
}
/// <summary>
/// Find physical query plan for QilNodeType.PrecedingSibling.
/// </summary>
protected override QilNode VisitPrecedingSibling(QilUnary ndPreSib)
{
CreateFilteredIterator(ndPreSib.Child, "$$$iterPreSib", typeof(PrecedingSiblingIterator), XmlILMethods.PreSibCreate, XmlILMethods.PreSibNext, XmlILMethods.PreSibCurrent,
XmlNodeKindFlags.Any, null, TriState.Unknown, null);
return ndPreSib;
}
/// <summary>
/// Find physical query plan for QilNodeType.NodeRange.
/// </summary>
protected override QilNode VisitNodeRange(QilBinary ndRange)
{
CreateFilteredIterator(ndRange.Left, "$$$iterRange", typeof(NodeRangeIterator), XmlILMethods.NodeRangeCreate, XmlILMethods.NodeRangeNext, XmlILMethods.NodeRangeCurrent,
XmlNodeKindFlags.Any, null, TriState.Unknown, ndRange.Right);
return ndRange;
}
/// <summary>
/// Generate code for QilNodeType.Deref.
/// </summary>
protected override QilNode VisitDeref(QilBinary ndDeref)
{
// IdIterator iterId;
LocalBuilder locIter = _helper.DeclareLocal("$$$iterId", typeof(IdIterator));
// iterId.Create(navCtxt, value);
_helper.Emit(OpCodes.Ldloca, locIter);
NestedVisitEnsureStack(ndDeref.Left);
NestedVisitEnsureStack(ndDeref.Right);
_helper.Call(XmlILMethods.IdCreate);
GenerateSimpleIterator(typeof(XPathNavigator), locIter, XmlILMethods.IdNext, XmlILMethods.IdCurrent);
return ndDeref;
}
/// <summary>
/// Generate code for QilNodeType.ElementCtor.
/// </summary>
protected override QilNode VisitElementCtor(QilBinary ndElem)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(ndElem);
bool callChk;
GenerateNameType nameType;
Debug.Assert(XmlILConstructInfo.Read(ndElem).PushToWriterFirst, "Element contruction should always be pushed to writer.");
// Runtime checks must be made in the following cases:
// 1. Xml state is not known at compile-time, or is illegal
// 2. Element's namespace must be declared
// 3. Element's attributes might be duplicates of one another, or namespaces might follow attributes
callChk = CheckWithinContent(info) || !info.IsNamespaceInScope || ElementCachesAttributes(info);
// If it is not known whether element content was output, then make this check at run-time
if (XmlILConstructInfo.Read(ndElem.Right).FinalStates == PossibleXmlStates.Any)
callChk = true;
// If runtime state after EndElement is called is not known, then call XmlQueryOutput.WriteEndElementChk
if (info.FinalStates == PossibleXmlStates.Any)
callChk = true;
// If WriteStartElementChk will *not* be called, then code must be generated to ensure valid state transitions
if (!callChk)
BeforeStartChecks(ndElem);
// Generate call to WriteStartElement
nameType = LoadNameAndType(XPathNodeType.Element, ndElem.Left, true, callChk);
_helper.CallWriteStartElement(nameType, callChk);
// Recursively construct content
NestedVisit(ndElem.Right);
// If runtime state is guaranteed to be EnumAttrs, and an element is being constructed, call XmlQueryOutput.StartElementContent
if (XmlILConstructInfo.Read(ndElem.Right).FinalStates == PossibleXmlStates.EnumAttrs && !callChk)
_helper.CallStartElementContent();
// Generate call to WriteEndElement
nameType = LoadNameAndType(XPathNodeType.Element, ndElem.Left, false, callChk);
_helper.CallWriteEndElement(nameType, callChk);
if (!callChk)
AfterEndChecks(ndElem);
_iterCurr.Storage = StorageDescriptor.None();
return ndElem;
}
/// <summary>
/// Generate code for QilNodeType.AttributeCtor.
/// </summary>
protected override QilNode VisitAttributeCtor(QilBinary ndAttr)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(ndAttr);
bool callChk;
GenerateNameType nameType;
Debug.Assert(XmlILConstructInfo.Read(ndAttr).PushToWriterFirst, "Attribute construction should always be pushed to writer.");
// Runtime checks must be made in the following cases:
// 1. Xml state is not known at compile-time, or is illegal
// 2. Attribute's namespace must be declared
callChk = CheckEnumAttrs(info) || !info.IsNamespaceInScope;
// If WriteStartAttributeChk will *not* be called, then code must be generated to ensure well-formedness
// and track namespace scope.
if (!callChk)
BeforeStartChecks(ndAttr);
// Generate call to WriteStartAttribute
nameType = LoadNameAndType(XPathNodeType.Attribute, ndAttr.Left, true, callChk);
_helper.CallWriteStartAttribute(nameType, callChk);
// Recursively construct content
NestedVisit(ndAttr.Right);
// Generate call to WriteEndAttribute
_helper.CallWriteEndAttribute(callChk);
if (!callChk)
AfterEndChecks(ndAttr);
_iterCurr.Storage = StorageDescriptor.None();
return ndAttr;
}
/// <summary>
/// Generate code for QilNodeType.CommentCtor.
/// </summary>
protected override QilNode VisitCommentCtor(QilUnary ndComment)
{
Debug.Assert(XmlILConstructInfo.Read(ndComment).PushToWriterFirst, "Comment construction should always be pushed to writer.");
// Always call XmlQueryOutput.WriteStartComment
_helper.CallWriteStartComment();
// Recursively construct content
NestedVisit(ndComment.Child);
// Always call XmlQueryOutput.WriteEndComment
_helper.CallWriteEndComment();
_iterCurr.Storage = StorageDescriptor.None();
return ndComment;
}
/// <summary>
/// Generate code for QilNodeType.PICtor.
/// </summary>
protected override QilNode VisitPICtor(QilBinary ndPI)
{
Debug.Assert(XmlILConstructInfo.Read(ndPI).PushToWriterFirst, "PI construction should always be pushed to writer.");
// Always call XmlQueryOutput.WriteStartPI
_helper.LoadQueryOutput();
NestedVisitEnsureStack(ndPI.Left);
_helper.CallWriteStartPI();
// Recursively construct content
NestedVisit(ndPI.Right);
// Always call XmlQueryOutput.WriteEndPI
_helper.CallWriteEndPI();
_iterCurr.Storage = StorageDescriptor.None();
return ndPI;
}
/// <summary>
/// Generate code for QilNodeType.TextCtor.
/// </summary>
protected override QilNode VisitTextCtor(QilUnary ndText)
{
return VisitTextCtor(ndText, false);
}
/// <summary>
/// Generate code for QilNodeType.RawTextCtor.
/// </summary>
protected override QilNode VisitRawTextCtor(QilUnary ndText)
{
return VisitTextCtor(ndText, true);
}
/// <summary>
/// Generate code for QilNodeType.TextCtor and QilNodeType.RawTextCtor.
/// </summary>
private QilNode VisitTextCtor(QilUnary ndText, bool disableOutputEscaping)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(ndText);
bool callChk;
Debug.Assert(info.PushToWriterFirst, "Text construction should always be pushed to writer.");
// Write out text in different contexts (within attribute, within element, within comment, etc.)
switch (info.InitialStates)
{
case PossibleXmlStates.WithinAttr:
case PossibleXmlStates.WithinComment:
case PossibleXmlStates.WithinPI:
callChk = false;
break;
default:
callChk = CheckWithinContent(info);
break;
}
if (!callChk)
BeforeStartChecks(ndText);
_helper.LoadQueryOutput();
// Push string value of text onto IL stack
NestedVisitEnsureStack(ndText.Child);
// Write out text in different contexts (within attribute, within element, within comment, etc.)
switch (info.InitialStates)
{
case PossibleXmlStates.WithinAttr:
// Ignore hints when writing out attribute text
_helper.CallWriteString(false, callChk);
break;
case PossibleXmlStates.WithinComment:
// Call XmlQueryOutput.WriteCommentString
_helper.Call(XmlILMethods.CommentText);
break;
case PossibleXmlStates.WithinPI:
// Call XmlQueryOutput.WriteProcessingInstructionString
_helper.Call(XmlILMethods.PIText);
break;
default:
// Call XmlQueryOutput.WriteTextBlockChk, XmlQueryOutput.WriteTextBlockNoEntities, or XmlQueryOutput.WriteTextBlock
_helper.CallWriteString(disableOutputEscaping, callChk);
break;
}
if (!callChk)
AfterEndChecks(ndText);
_iterCurr.Storage = StorageDescriptor.None();
return ndText;
}
/// <summary>
/// Generate code for QilNodeType.DocumentCtor.
/// </summary>
protected override QilNode VisitDocumentCtor(QilUnary ndDoc)
{
Debug.Assert(XmlILConstructInfo.Read(ndDoc).PushToWriterFirst, "Document root construction should always be pushed to writer.");
// Generate call to XmlQueryOutput.WriteStartRootChk
_helper.CallWriteStartRoot();
// Recursively construct content
NestedVisit(ndDoc.Child);
// Generate call to XmlQueryOutput.WriteEndRootChk
_helper.CallWriteEndRoot();
_iterCurr.Storage = StorageDescriptor.None();
return ndDoc;
}
/// <summary>
/// Generate code for QilNodeType.NamespaceDecl.
/// </summary>
protected override QilNode VisitNamespaceDecl(QilBinary ndNmsp)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(ndNmsp);
bool callChk;
Debug.Assert(info.PushToWriterFirst, "Namespace construction should always be pushed to writer.");
// Runtime checks must be made in the following cases:
// 1. Xml state is not known at compile-time, or is illegal
// 2. Namespaces might be added to element after attributes have already been added
callChk = CheckEnumAttrs(info) || MightHaveNamespacesAfterAttributes(info);
// If WriteNamespaceDeclarationChk will *not* be called, then code must be generated to ensure well-formedness
// and track namespace scope.
if (!callChk)
BeforeStartChecks(ndNmsp);
_helper.LoadQueryOutput();
// Recursively construct prefix and ns
NestedVisitEnsureStack(ndNmsp.Left);
NestedVisitEnsureStack(ndNmsp.Right);
// Generate call to WriteNamespaceDecl
_helper.CallWriteNamespaceDecl(callChk);
if (!callChk)
AfterEndChecks(ndNmsp);
_iterCurr.Storage = StorageDescriptor.None();
return ndNmsp;
}
/// <summary>
/// Generate code for QilNodeType.RtfCtor.
/// </summary>
protected override QilNode VisitRtfCtor(QilBinary ndRtf)
{
OptimizerPatterns patt = OptimizerPatterns.Read(ndRtf);
string baseUri = (string)(QilLiteral)ndRtf.Right;
if (patt.MatchesPattern(OptimizerPatternName.SingleTextRtf))
{
// Special-case Rtf containing a root node and a single text node child
_helper.LoadQueryRuntime();
NestedVisitEnsureStack((QilNode)patt.GetArgument(OptimizerPatternArgument.RtfText));
_helper.Emit(OpCodes.Ldstr, baseUri);
_helper.Call(XmlILMethods.RtfConstr);
}
else
{
// Start nested construction of an Rtf
_helper.CallStartRtfConstruction(baseUri);
// Write content of Rtf to writer
NestedVisit(ndRtf.Left);
// Get the result Rtf
_helper.CallEndRtfConstruction();
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathNavigator), false);
return ndRtf;
}
/// <summary>
/// Generate code for QilNodeType.NameOf.
/// </summary>
protected override QilNode VisitNameOf(QilUnary ndName)
{
return VisitNodeProperty(ndName);
}
/// <summary>
/// Generate code for QilNodeType.LocalNameOf.
/// </summary>
protected override QilNode VisitLocalNameOf(QilUnary ndName)
{
return VisitNodeProperty(ndName);
}
/// <summary>
/// Generate code for QilNodeType.NamespaceUriOf.
/// </summary>
protected override QilNode VisitNamespaceUriOf(QilUnary ndName)
{
return VisitNodeProperty(ndName);
}
/// <summary>
/// Generate code for QilNodeType.PrefixOf.
/// </summary>
protected override QilNode VisitPrefixOf(QilUnary ndName)
{
return VisitNodeProperty(ndName);
}
/// <summary>
/// Generate code to push the local name, namespace uri, or qname of the context navigator.
/// </summary>
private QilNode VisitNodeProperty(QilUnary ndProp)
{
// Generate code to push argument onto stack
NestedVisitEnsureStack(ndProp.Child);
switch (ndProp.NodeType)
{
case QilNodeType.NameOf:
// push new XmlQualifiedName(navigator.LocalName, navigator.NamespaceURI);
_helper.Emit(OpCodes.Dup);
_helper.Call(XmlILMethods.NavLocalName);
_helper.Call(XmlILMethods.NavNmsp);
_helper.Construct(XmlILConstructors.QName);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XmlQualifiedName), false);
break;
case QilNodeType.LocalNameOf:
// push navigator.Name;
_helper.Call(XmlILMethods.NavLocalName);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
break;
case QilNodeType.NamespaceUriOf:
// push navigator.NamespaceURI;
_helper.Call(XmlILMethods.NavNmsp);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
break;
case QilNodeType.PrefixOf:
// push navigator.Prefix;
_helper.Call(XmlILMethods.NavPrefix);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
break;
default:
Debug.Fail($"Unexpected node type {ndProp.NodeType}");
break;
}
return ndProp;
}
/// <summary>
/// Find physical query plan for QilNodeType.TypeAssert.
/// </summary>
protected override QilNode VisitTypeAssert(QilTargetType ndTypeAssert)
{
if (!ndTypeAssert.Source.XmlType!.IsSingleton && ndTypeAssert.XmlType!.IsSingleton && !_iterCurr.HasLabelNext)
{
// This case occurs when a non-singleton expression is treated as cardinality One.
// The trouble is that the expression will branch to an end label when it's done iterating, so
// an end label must be provided. But there is no next label in the current iteration context,
// so we've got to create a dummy label instead (IL requires it). This creates an infinite loop,
// but since it's known statically that the expression is cardinality One, this branch will never
// be taken.
Label lblDummy = _helper.DefineLabel();
_helper.MarkLabel(lblDummy);
NestedVisit(ndTypeAssert.Source, lblDummy);
}
else
{
// Generate code for child expression
Visit(ndTypeAssert.Source);
}
_iterCurr.EnsureItemStorageType(ndTypeAssert.Source.XmlType, GetItemStorageType(ndTypeAssert));
return ndTypeAssert;
}
/// <summary>
/// Generate code for QilNodeType.IsType.
/// </summary>
protected override QilNode VisitIsType(QilTargetType ndIsType)
{
XmlQueryType typDerived, typBase;
XmlTypeCode codeBase;
typDerived = ndIsType.Source.XmlType!;
typBase = ndIsType.TargetType;
Debug.Assert(!typDerived!.NeverSubtypeOf(typBase), "Normalizer should have eliminated IsType where source can never be a subtype of destination type.");
// Special Case: Test whether singleton item is a Node
if (typDerived.IsSingleton && (object)typBase == (object)TypeFactory.Node)
{
NestedVisitEnsureStack(ndIsType.Source);
Debug.Assert(_iterCurr.Storage.ItemStorageType == typeof(XPathItem), "If !IsNode, then storage type should be Item");
// if (item.IsNode op true) goto LabelBranch;
_helper.Call(XmlILMethods.ItemIsNode);
ZeroCompare(QilNodeType.Ne, true);
return ndIsType;
}
// Special Case: Source value is a singleton Node, and we're testing whether it is an Element, Attribute, PI, etc.
if (MatchesNodeKinds(ndIsType, typDerived, typBase))
return ndIsType;
// Special Case: XmlTypeCode is sufficient to describe destination type
if ((object)typBase == (object)TypeFactory.Double) codeBase = XmlTypeCode.Double;
else if ((object)typBase == (object)TypeFactory.String) codeBase = XmlTypeCode.String;
else if ((object)typBase == (object)TypeFactory.Boolean) codeBase = XmlTypeCode.Boolean;
else if ((object)typBase == (object)TypeFactory.Node) codeBase = XmlTypeCode.Node;
else codeBase = XmlTypeCode.None;
if (codeBase != XmlTypeCode.None)
{
// if (runtime.MatchesXmlType(value, code) op true) goto LabelBranch;
_helper.LoadQueryRuntime();
NestedVisitEnsureStack(ndIsType.Source, typeof(XPathItem), !typDerived.IsSingleton);
_helper.LoadInteger((int)codeBase);
_helper.Call(typDerived.IsSingleton ? XmlILMethods.ItemMatchesCode : XmlILMethods.SeqMatchesCode);
ZeroCompare(QilNodeType.Ne, true);
return ndIsType;
}
// if (runtime.MatchesXmlType(value, idxType) op true) goto LabelBranch;
_helper.LoadQueryRuntime();
NestedVisitEnsureStack(ndIsType.Source, typeof(XPathItem), !typDerived.IsSingleton);
_helper.LoadInteger(_helper.StaticData.DeclareXmlType(typBase));
_helper.Call(typDerived.IsSingleton ? XmlILMethods.ItemMatchesType : XmlILMethods.SeqMatchesType);
ZeroCompare(QilNodeType.Ne, true);
return ndIsType;
}
/// <summary>
/// Faster code can be generated if type test is just a node kind test. If this special case is detected, then generate code and return true.
/// Otherwise, return false, and a call to MatchesXmlType will be generated instead.
/// </summary>
private bool MatchesNodeKinds(QilTargetType ndIsType, XmlQueryType typDerived, XmlQueryType typBase)
{
XmlNodeKindFlags kinds;
bool allowKinds = true;
XPathNodeType kindsRuntime;
int kindsUnion;
// If not checking whether typDerived is some kind of singleton node, then fallback to MatchesXmlType
if (!typBase.IsNode || !typBase.IsSingleton)
return false;
// If typDerived is not statically guaranteed to be a singleton node (and not an rtf), then fallback to MatchesXmlType
if (!typDerived.IsNode || !typDerived.IsSingleton || !typDerived.IsNotRtf)
return false;
// Now we are guaranteed that typDerived is a node, and typBase is a node, so check node kinds
// Ensure that typBase is only composed of kind-test prime types (no name-test, no schema-test, etc.)
kinds = XmlNodeKindFlags.None;
foreach (XmlQueryType typItem in typBase)
{
if ((object)typItem == (object)TypeFactory.Element) kinds |= XmlNodeKindFlags.Element;
else if ((object)typItem == (object)TypeFactory.Attribute) kinds |= XmlNodeKindFlags.Attribute;
else if ((object)typItem == (object)TypeFactory.Text) kinds |= XmlNodeKindFlags.Text;
else if ((object)typItem == (object)TypeFactory.Document) kinds |= XmlNodeKindFlags.Document;
else if ((object)typItem == (object)TypeFactory.Comment) kinds |= XmlNodeKindFlags.Comment;
else if ((object)typItem == (object)TypeFactory.PI) kinds |= XmlNodeKindFlags.PI;
else if ((object)typItem == (object)TypeFactory.Namespace) kinds |= XmlNodeKindFlags.Namespace;
else return false;
}
Debug.Assert((typDerived.NodeKinds & kinds) != XmlNodeKindFlags.None, "Normalizer should have taken care of case where node kinds are disjoint.");
kinds = typDerived.NodeKinds & kinds;
// Attempt to allow or disallow exactly one kind
if (!Bits.ExactlyOne((uint)kinds))
{
// Not possible to allow one kind, so try to disallow one kind
kinds = ~kinds & XmlNodeKindFlags.Any;
allowKinds = !allowKinds;
}
switch (kinds)
{
case XmlNodeKindFlags.Element: kindsRuntime = XPathNodeType.Element; break;
case XmlNodeKindFlags.Attribute: kindsRuntime = XPathNodeType.Attribute; break;
case XmlNodeKindFlags.Namespace: kindsRuntime = XPathNodeType.Namespace; break;
case XmlNodeKindFlags.PI: kindsRuntime = XPathNodeType.ProcessingInstruction; break;
case XmlNodeKindFlags.Comment: kindsRuntime = XPathNodeType.Comment; break;
case XmlNodeKindFlags.Document: kindsRuntime = XPathNodeType.Root; break;
default:
// Union of several types (when testing for Text, we need to test for Whitespace as well)
// if (((1 << navigator.NodeType) & nodesDisallow) op 0) goto LabelBranch;
_helper.Emit(OpCodes.Ldc_I4_1);
kindsRuntime = XPathNodeType.All;
break;
}
// Push navigator.NodeType onto the stack
NestedVisitEnsureStack(ndIsType.Source);
_helper.Call(XmlILMethods.NavType);
if (kindsRuntime == XPathNodeType.All)
{
// if (((1 << navigator.NodeType) & kindsUnion) op 0) goto LabelBranch;
_helper.Emit(OpCodes.Shl);
kindsUnion = 0;
if ((kinds & XmlNodeKindFlags.Document) != 0) kindsUnion |= (1 << (int)XPathNodeType.Root);
if ((kinds & XmlNodeKindFlags.Element) != 0) kindsUnion |= (1 << (int)XPathNodeType.Element);
if ((kinds & XmlNodeKindFlags.Attribute) != 0) kindsUnion |= (1 << (int)XPathNodeType.Attribute);
if ((kinds & XmlNodeKindFlags.Text) != 0)
kindsUnion |= (1 << (int)(int)XPathNodeType.Text) |
(1 << (int)(int)XPathNodeType.SignificantWhitespace) |
(1 << (int)(int)XPathNodeType.Whitespace);
if ((kinds & XmlNodeKindFlags.Comment) != 0) kindsUnion |= (1 << (int)XPathNodeType.Comment);
if ((kinds & XmlNodeKindFlags.PI) != 0) kindsUnion |= (1 << (int)XPathNodeType.ProcessingInstruction);
if ((kinds & XmlNodeKindFlags.Namespace) != 0) kindsUnion |= (1 << (int)XPathNodeType.Namespace);
_helper.LoadInteger(kindsUnion);
_helper.Emit(OpCodes.And);
ZeroCompare(allowKinds ? QilNodeType.Ne : QilNodeType.Eq, false);
}
else
{
// if (navigator.NodeType op runtimeItem) goto LabelBranch;
_helper.LoadInteger((int)kindsRuntime);
ClrCompare(allowKinds ? QilNodeType.Eq : QilNodeType.Ne, XmlTypeCode.Int);
}
return true;
}
/// <summary>
/// Generate code for QilNodeType.IsEmpty.
/// </summary>
/// <remarks>
/// BranchingContext.OnFalse context: is-empty(expr)
/// ==> foreach (item in expr)
/// goto LabelBranch;
///
/// BranchingContext.OnTrue context: is-empty(expr)
/// ==> foreach (item in expr)
/// break;
/// ...
/// LabelOnEnd: (called if foreach is empty)
/// goto LabelBranch;
///
/// BranchingContext.None context: is-empty(expr)
/// ==> foreach (item in expr)
/// break;
/// push true();
/// ...
/// LabelOnEnd: (called if foreach is empty)
/// push false();
/// </remarks>
protected override QilNode VisitIsEmpty(QilUnary ndIsEmpty)
{
Label lblTrue;
// If the child expression returns a cached result,
if (CachesResult(ndIsEmpty.Child))
{
// Then get the count directly from the cache
NestedVisitEnsureStack(ndIsEmpty.Child);
_helper.CallCacheCount(_iterNested!.Storage.ItemStorageType);
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
// Take false path if count != 0
_helper.TestAndBranch(0, _iterCurr.LabelBranch, OpCodes.Bne_Un);
break;
case BranchingContext.OnTrue:
// Take true path if count == 0
_helper.TestAndBranch(0, _iterCurr.LabelBranch, OpCodes.Beq);
break;
default:
Debug.Assert(_iterCurr.CurrentBranchingContext == BranchingContext.None);
// if (count == 0) goto LabelTrue;
lblTrue = _helper.DefineLabel();
_helper.Emit(OpCodes.Brfalse_S, lblTrue);
// Convert branch targets into push of true/false
_helper.ConvBranchToBool(lblTrue, true);
break;
}
}
else
{
Label lblOnEnd = _helper.DefineLabel();
IteratorDescriptor iterParent = _iterCurr;
// Forward any LabelOnEnd jumps to LabelBranch if BranchingContext.OnTrue
if (iterParent.CurrentBranchingContext == BranchingContext.OnTrue)
StartNestedIterator(ndIsEmpty.Child, _iterCurr.LabelBranch);
else
StartNestedIterator(ndIsEmpty.Child, lblOnEnd);
Visit(ndIsEmpty.Child);
// Pop value of IsEmpty expression from the stack if necessary
_iterCurr.EnsureNoCache();
_iterCurr.DiscardStack();
switch (iterParent.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
// Reverse polarity of iterator
_helper.EmitUnconditionalBranch(OpCodes.Br, iterParent.LabelBranch);
_helper.MarkLabel(lblOnEnd);
break;
case BranchingContext.OnTrue:
// Nothing to do
break;
case BranchingContext.None:
// Convert branch targets into push of true/false
_helper.ConvBranchToBool(lblOnEnd, true);
break;
}
// End nested iterator
EndNestedIterator(ndIsEmpty.Child);
}
if (_iterCurr.IsBranching)
_iterCurr.Storage = StorageDescriptor.None();
else
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
return ndIsEmpty;
}
/// <summary>
/// Generate code for QilNodeType.XPathNodeValue.
/// </summary>
protected override QilNode VisitXPathNodeValue(QilUnary ndVal)
{
Label lblOnEnd, lblDone;
Debug.Assert(ndVal.Child.XmlType!.IsNode, "XPathNodeValue node may only be applied to a sequence of Nodes.");
// If the expression is a singleton,
if (ndVal.Child.XmlType.IsSingleton)
{
// Then generate code to push expresion result onto the stack
NestedVisitEnsureStack(ndVal.Child, typeof(XPathNavigator), false);
// navigator.Value;
_helper.Call(XmlILMethods.Value);
}
else
{
lblOnEnd = _helper.DefineLabel();
// Construct nested iterator and iterate over results
StartNestedIterator(ndVal.Child, lblOnEnd);
Visit(ndVal.Child);
_iterCurr.EnsureStackNoCache();
// navigator.Value;
_helper.Call(XmlILMethods.Value);
// Handle empty sequence by pushing empty string onto the stack
lblDone = _helper.DefineLabel();
_helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
_helper.MarkLabel(lblOnEnd);
_helper.Emit(OpCodes.Ldstr, "");
_helper.MarkLabel(lblDone);
// End nested iterator
EndNestedIterator(ndVal.Child);
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
return ndVal;
}
/// <summary>
/// Find physical query plan for QilNodeType.XPathFollowing.
/// </summary>
protected override QilNode VisitXPathFollowing(QilUnary ndFoll)
{
CreateFilteredIterator(ndFoll.Child, "$$$iterFoll", typeof(XPathFollowingIterator), XmlILMethods.XPFollCreate, XmlILMethods.XPFollNext, XmlILMethods.XPFollCurrent,
XmlNodeKindFlags.Any, null, TriState.Unknown, null);
return ndFoll;
}
/// <summary>
/// Find physical query plan for QilNodeType.XPathPreceding.
/// </summary>
protected override QilNode VisitXPathPreceding(QilUnary ndPrec)
{
CreateFilteredIterator(ndPrec.Child, "$$$iterPrec", typeof(XPathPrecedingIterator), XmlILMethods.XPPrecCreate, XmlILMethods.XPPrecNext, XmlILMethods.XPPrecCurrent,
XmlNodeKindFlags.Any, null, TriState.Unknown, null);
return ndPrec;
}
/// <summary>
/// Find physical query plan for QilNodeType.XPathNamespace.
/// </summary>
protected override QilNode VisitXPathNamespace(QilUnary ndNmsp)
{
CreateSimpleIterator(ndNmsp.Child, "$$$iterNmsp", typeof(NamespaceIterator), XmlILMethods.NmspCreate, XmlILMethods.NmspNext, XmlILMethods.NmspCurrent);
return ndNmsp;
}
/// <summary>
/// Generate code for QilNodeType.XsltGenerateId.
/// </summary>
protected override QilNode VisitXsltGenerateId(QilUnary ndGenId)
{
Label lblOnEnd, lblDone;
_helper.LoadQueryRuntime();
// If the expression is a singleton,
if (ndGenId.Child.XmlType!.IsSingleton)
{
// Then generate code to push expresion result onto the stack
NestedVisitEnsureStack(ndGenId.Child, typeof(XPathNavigator), false);
// runtime.GenerateId(value);
_helper.Call(XmlILMethods.GenId);
}
else
{
lblOnEnd = _helper.DefineLabel();
// Construct nested iterator and iterate over results
StartNestedIterator(ndGenId.Child, lblOnEnd);
Visit(ndGenId.Child);
_iterCurr.EnsureStackNoCache();
_iterCurr.EnsureItemStorageType(ndGenId.Child.XmlType, typeof(XPathNavigator));
// runtime.GenerateId(value);
_helper.Call(XmlILMethods.GenId);
// Handle empty sequence by pushing empty string onto the stack
lblDone = _helper.DefineLabel();
_helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
_helper.MarkLabel(lblOnEnd);
_helper.Emit(OpCodes.Pop);
_helper.Emit(OpCodes.Ldstr, "");
_helper.MarkLabel(lblDone);
// End nested iterator
EndNestedIterator(ndGenId.Child);
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
return ndGenId;
}
/// <summary>
/// Generate code for QilNodeType.XsltInvokeLateBound.
/// </summary>
protected override QilNode VisitXsltInvokeLateBound(QilInvokeLateBound ndInvoke)
{
LocalBuilder locArgs = _helper.DeclareLocal("$$$args", typeof(IList<XPathItem>[]));
QilName ndName = (QilName)ndInvoke.Name;
Debug.Assert(XmlILConstructInfo.Read(ndInvoke).ConstructMethod != XmlILConstructMethod.Writer);
// runtime.ExternalContext.InvokeXsltLateBoundFunction(name, ns, args);
_helper.LoadQueryContext();
_helper.Emit(OpCodes.Ldstr, ndName.LocalName);
_helper.Emit(OpCodes.Ldstr, ndName.NamespaceUri);
// args = new IList<XPathItem>[argCount];
_helper.LoadInteger(ndInvoke.Arguments.Count);
_helper.Emit(OpCodes.Newarr, typeof(IList<XPathItem>));
_helper.Emit(OpCodes.Stloc, locArgs);
for (int iArg = 0; iArg < ndInvoke.Arguments.Count; iArg++)
{
QilNode ndArg = ndInvoke.Arguments[iArg];
// args[0] = arg0;
// ...
// args[N] = argN;
_helper.Emit(OpCodes.Ldloc, locArgs);
_helper.LoadInteger(iArg);
_helper.Emit(OpCodes.Ldelema, typeof(IList<XPathItem>));
NestedVisitEnsureCache(ndArg, typeof(XPathItem));
_iterCurr.EnsureStack();
_helper.Emit(OpCodes.Stobj, typeof(IList<XPathItem>));
}
_helper.Emit(OpCodes.Ldloc, locArgs);
_helper.Call(XmlILMethods.InvokeXsltLate);
// Returned item sequence is on the stack
_iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathItem), true);
return ndInvoke;
}
/// <summary>
/// Generate code for QilNodeType.XsltInvokeEarlyBound.
/// </summary>
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:RequiresUnreferencedCode",
Justification = "Supressing warning about not having the RequiresUnreferencedCode attribute since we added " +
"the attribute to this subclass' constructor. This allows us to not have to annotate the whole QilNode hirerarchy.")]
protected override QilNode VisitXsltInvokeEarlyBound(QilInvokeEarlyBound ndInvoke)
{
QilName ndName = ndInvoke.Name;
XmlExtensionFunction extFunc;
Type clrTypeRetSrc, clrTypeRetDst;
// Retrieve metadata from the extension function
extFunc = new XmlExtensionFunction(ndName.LocalName, ndName.NamespaceUri, ndInvoke.ClrMethod);
clrTypeRetSrc = extFunc.ClrReturnType;
clrTypeRetDst = GetStorageType(ndInvoke);
// Prepare to call runtime.ChangeTypeXsltResult
if (clrTypeRetSrc != clrTypeRetDst && !ndInvoke.XmlType!.IsEmpty)
{
_helper.LoadQueryRuntime();
_helper.LoadInteger(_helper.StaticData.DeclareXmlType(ndInvoke.XmlType));
}
// If this is not a static method, then get the instance object
if (!extFunc.Method.IsStatic)
{
// Special-case the XsltLibrary object
if (ndName.NamespaceUri.Length == 0)
_helper.LoadXsltLibrary();
else
_helper.CallGetEarlyBoundObject(_helper.StaticData.DeclareEarlyBound(ndName.NamespaceUri, extFunc.Method.DeclaringType!), extFunc.Method.DeclaringType!);
}
// Generate code to push each Invoke argument onto the stack
for (int iArg = 0; iArg < ndInvoke.Arguments.Count; iArg++)
{
QilNode ndActualArg;
XmlQueryType xmlTypeFormalArg;
Type clrTypeActualArg, clrTypeFormalArg;
ndActualArg = ndInvoke.Arguments[iArg];
// Infer Xml type and Clr type of formal argument
xmlTypeFormalArg = extFunc.GetXmlArgumentType(iArg);
clrTypeFormalArg = extFunc.GetClrArgumentType(iArg);
Debug.Assert(ndActualArg.XmlType!.IsSubtypeOf(xmlTypeFormalArg), "Xml type of actual arg must be a subtype of the Xml type of the formal arg");
// Use different conversion rules for internal Xslt libraries. If the actual argument is
// stored using Clr type T, then library must use type T, XPathItem, IList<T>, or IList<XPathItem>.
// If the actual argument is stored using Clr type IList<T>, then library must use type
// IList<T> or IList<XPathItem>. This is to ensure that there will not be unnecessary
// conversions that take place when calling into an internal library.
if (ndName.NamespaceUri.Length == 0)
{
Type itemType = GetItemStorageType(ndActualArg);
if (clrTypeFormalArg == XmlILMethods.StorageMethods[itemType].IListType)
{
// Formal type is IList<T>
NestedVisitEnsureStack(ndActualArg, itemType, true);
}
else if (clrTypeFormalArg == XmlILMethods.StorageMethods[typeof(XPathItem)].IListType)
{
// Formal type is IList<XPathItem>
NestedVisitEnsureStack(ndActualArg, typeof(XPathItem), true);
}
else if ((ndActualArg.XmlType.IsSingleton && clrTypeFormalArg == itemType) || ndActualArg.XmlType.TypeCode == XmlTypeCode.None)
{
// Formal type is T
NestedVisitEnsureStack(ndActualArg, clrTypeFormalArg, false);
}
else if (ndActualArg.XmlType.IsSingleton && clrTypeFormalArg == typeof(XPathItem))
{
// Formal type is XPathItem
NestedVisitEnsureStack(ndActualArg, typeof(XPathItem), false);
}
else
Debug.Fail("Internal Xslt library may not use parameters of type " + clrTypeFormalArg);
}
else
{
// There is an implicit upcast to the Xml type of the formal argument. This can change the Clr storage type.
clrTypeActualArg = GetStorageType(xmlTypeFormalArg);
// If the formal Clr type is typeof(object) or if it is not a supertype of the actual Clr type, then call ChangeTypeXsltArgument
if (xmlTypeFormalArg.TypeCode == XmlTypeCode.Item || !clrTypeFormalArg.IsAssignableFrom(clrTypeActualArg))
{
// (clrTypeFormalArg) runtime.ChangeTypeXsltArgument(xmlTypeFormalArg, (object) value, clrTypeFormalArg);
_helper.LoadQueryRuntime();
_helper.LoadInteger(_helper.StaticData.DeclareXmlType(xmlTypeFormalArg));
NestedVisitEnsureStack(ndActualArg, GetItemStorageType(xmlTypeFormalArg), !xmlTypeFormalArg.IsSingleton);
_helper.TreatAs(clrTypeActualArg, typeof(object));
_helper.LoadType(clrTypeFormalArg);
_helper.Call(XmlILMethods.ChangeTypeXsltArg);
_helper.TreatAs(typeof(object), clrTypeFormalArg);
}
else
{
NestedVisitEnsureStack(ndActualArg, GetItemStorageType(xmlTypeFormalArg), !xmlTypeFormalArg.IsSingleton);
}
}
}
// Invoke the target method
_helper.Call(extFunc.Method);
// Return value is on the stack; convert it to canonical ILGen storage type
if (ndInvoke.XmlType!.IsEmpty)
{
_helper.Emit(OpCodes.Ldsfld, XmlILMethods.StorageMethods[typeof(XPathItem)].SeqEmpty);
}
else if (clrTypeRetSrc != clrTypeRetDst)
{
// (T) runtime.ChangeTypeXsltResult(idxType, (object) value);
_helper.TreatAs(clrTypeRetSrc, typeof(object));
_helper.Call(XmlILMethods.ChangeTypeXsltResult);
_helper.TreatAs(typeof(object), clrTypeRetDst);
}
else if (ndName.NamespaceUri.Length != 0 && !clrTypeRetSrc.IsValueType)
{
// Check for null if a user-defined extension function returns a reference type
Label lblSkip = _helper.DefineLabel();
_helper.Emit(OpCodes.Dup);
_helper.Emit(OpCodes.Brtrue, lblSkip);
_helper.LoadQueryRuntime();
_helper.Emit(OpCodes.Ldstr, SR.Xslt_ItemNull);
_helper.Call(XmlILMethods.ThrowException);
_helper.MarkLabel(lblSkip);
}
_iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(ndInvoke), !ndInvoke.XmlType.IsSingleton);
return ndInvoke;
}
/// <summary>
/// Generate code for QilNodeType.XsltCopy.
/// </summary>
protected override QilNode VisitXsltCopy(QilBinary ndCopy)
{
Label lblSkipContent = _helper.DefineLabel();
Debug.Assert(XmlILConstructInfo.Read(ndCopy).PushToWriterFirst);
// if (!xwrtChk.StartCopyChk(navCopy)) goto LabelSkipContent;
_helper.LoadQueryOutput();
NestedVisitEnsureStack(ndCopy.Left);
Debug.Assert(ndCopy.Left.XmlType!.IsNode);
_helper.Call(XmlILMethods.StartCopy);
_helper.Emit(OpCodes.Brfalse, lblSkipContent);
// Recursively construct content
NestedVisit(ndCopy.Right);
// xwrtChk.EndCopyChk(navCopy);
_helper.LoadQueryOutput();
NestedVisitEnsureStack(ndCopy.Left);
Debug.Assert(ndCopy.Left.XmlType.IsNode);
_helper.Call(XmlILMethods.EndCopy);
// LabelSkipContent:
_helper.MarkLabel(lblSkipContent);
_iterCurr.Storage = StorageDescriptor.None();
return ndCopy;
}
/// <summary>
/// Generate code for QilNodeType.XsltCopyOf.
/// </summary>
protected override QilNode VisitXsltCopyOf(QilUnary ndCopyOf)
{
Debug.Assert(XmlILConstructInfo.Read(ndCopyOf).PushToWriterFirst, "XsltCopyOf should always be pushed to writer.");
_helper.LoadQueryOutput();
// XmlQueryOutput.XsltCopyOf(navigator);
NestedVisitEnsureStack(ndCopyOf.Child);
_helper.Call(XmlILMethods.CopyOf);
_iterCurr.Storage = StorageDescriptor.None();
return ndCopyOf;
}
/// <summary>
/// Generate code for QilNodeType.XsltConvert.
/// </summary>
protected override QilNode VisitXsltConvert(QilTargetType ndConv)
{
XmlQueryType typSrc, typDst;
MethodInfo? meth;
typSrc = ndConv.Source.XmlType!;
typDst = ndConv.TargetType;
if (GetXsltConvertMethod(typSrc, typDst, out meth))
{
NestedVisitEnsureStack(ndConv.Source);
}
else
{
// If a conversion could not be found, then convert the source expression to item or item* and try again
NestedVisitEnsureStack(ndConv.Source, typeof(XPathItem), !typSrc.IsSingleton);
if (!GetXsltConvertMethod(typSrc.IsSingleton ? TypeFactory.Item : TypeFactory.ItemS, typDst, out meth))
Debug.Fail("Conversion from " + ndConv.Source.XmlType + " to " + ndConv.TargetType + " is not supported.");
}
// XsltConvert.XXXToYYY(value);
if (meth != null)
_helper.Call(meth);
_iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(typDst), !typDst.IsSingleton);
return ndConv;
}
/// <summary>
/// Get the XsltConvert method that converts from "typSrc" to "typDst". Return false if no
/// such method exists. This conversion matrix should match the one in XsltConvert.ExternalValueToExternalValue.
/// </summary>
private bool GetXsltConvertMethod(XmlQueryType typSrc, XmlQueryType typDst, out MethodInfo? meth)
{
meth = null;
// Note, Ref.Equals is OK to use here, since we will always fall back to Item or Item* in the
// case where the source or destination types do not match the static types exposed on the
// XmlQueryTypeFactory. This is bad for perf if it accidentally occurs, but the results
// should still be correct.
// => xs:boolean
if ((object)typDst == (object)TypeFactory.BooleanX)
{
if ((object)typSrc == (object)TypeFactory.Item) meth = XmlILMethods.ItemToBool;
else if ((object)typSrc == (object)TypeFactory.ItemS) meth = XmlILMethods.ItemsToBool;
}
// => xs:dateTime
else if ((object)typDst == (object)TypeFactory.DateTimeX)
{
if ((object)typSrc == (object)TypeFactory.StringX) meth = XmlILMethods.StrToDT;
}
// => xs:decimal
else if ((object)typDst == (object)TypeFactory.DecimalX)
{
if ((object)typSrc == (object)TypeFactory.DoubleX) meth = XmlILMethods.DblToDec;
}
// => xs:double
else if ((object)typDst == (object)TypeFactory.DoubleX)
{
if ((object)typSrc == (object)TypeFactory.DecimalX) meth = XmlILMethods.DecToDbl;
else if ((object)typSrc == (object)TypeFactory.IntX) meth = XmlILMethods.IntToDbl;
else if ((object)typSrc == (object)TypeFactory.Item) meth = XmlILMethods.ItemToDbl;
else if ((object)typSrc == (object)TypeFactory.ItemS) meth = XmlILMethods.ItemsToDbl;
else if ((object)typSrc == (object)TypeFactory.LongX) meth = XmlILMethods.LngToDbl;
else if ((object)typSrc == (object)TypeFactory.StringX) meth = XmlILMethods.StrToDbl;
}
// => xs:int
else if ((object)typDst == (object)TypeFactory.IntX)
{
if ((object)typSrc == (object)TypeFactory.DoubleX) meth = XmlILMethods.DblToInt;
}
// => xs:long
else if ((object)typDst == (object)TypeFactory.LongX)
{
if ((object)typSrc == (object)TypeFactory.DoubleX) meth = XmlILMethods.DblToLng;
}
// => node
else if ((object)typDst == (object)TypeFactory.NodeNotRtf)
{
if ((object)typSrc == (object)TypeFactory.Item) meth = XmlILMethods.ItemToNode;
else if ((object)typSrc == (object)TypeFactory.ItemS) meth = XmlILMethods.ItemsToNode;
}
// => node*
else if ((object)typDst == (object)TypeFactory.NodeSDod ||
(object)typDst == (object)TypeFactory.NodeNotRtfS)
{
if ((object)typSrc == (object)TypeFactory.Item) meth = XmlILMethods.ItemToNodes;
else if ((object)typSrc == (object)TypeFactory.ItemS) meth = XmlILMethods.ItemsToNodes;
}
// => xs:string
else if ((object)typDst == (object)TypeFactory.StringX)
{
if ((object)typSrc == (object)TypeFactory.DateTimeX) meth = XmlILMethods.DTToStr;
else if ((object)typSrc == (object)TypeFactory.DoubleX) meth = XmlILMethods.DblToStr;
else if ((object)typSrc == (object)TypeFactory.Item) meth = XmlILMethods.ItemToStr;
else if ((object)typSrc == (object)TypeFactory.ItemS) meth = XmlILMethods.ItemsToStr;
}
return meth != null;
}
//-----------------------------------------------
// Helper methods
//-----------------------------------------------
/// <summary>
/// Ensure that the "locNav" navigator is positioned to the context node "ndCtxt".
/// </summary>
private void SyncToNavigator(LocalBuilder locNav, QilNode ndCtxt)
{
_helper.Emit(OpCodes.Ldloc, locNav);
NestedVisitEnsureStack(ndCtxt);
_helper.CallSyncToNavigator();
_helper.Emit(OpCodes.Stloc, locNav);
}
/// <summary>
/// Generate boiler-plate code to create a simple Xml iterator.
/// </summary>
/// <remarks>
/// Iterator iter;
/// iter.Create(navCtxt);
/// LabelNext:
/// if (!iter.MoveNext())
/// goto LabelNextCtxt;
/// </remarks>
private void CreateSimpleIterator(QilNode ndCtxt, string iterName, Type iterType, MethodInfo methCreate, MethodInfo methNext, MethodInfo methCurrent)
{
// Iterator iter;
LocalBuilder locIter = _helper.DeclareLocal(iterName, iterType);
// iter.Create(navCtxt);
_helper.Emit(OpCodes.Ldloca, locIter);
NestedVisitEnsureStack(ndCtxt);
_helper.Call(methCreate);
GenerateSimpleIterator(typeof(XPathNavigator), locIter, methNext, methCurrent);
}
/// <summary>
/// Generate boiler-plate code to create an Xml iterator that uses an XmlNavigatorFilter to filter items.
/// </summary>
/// <remarks>
/// Iterator iter;
/// iter.Create(navCtxt, filter [, orSelf] [, navEnd]);
/// LabelNext:
/// if (!iter.MoveNext())
/// goto LabelNextCtxt;
/// </remarks>
private void CreateFilteredIterator(QilNode ndCtxt, string iterName, Type iterType, MethodInfo methCreate, MethodInfo methNext, MethodInfo methCurrent,
XmlNodeKindFlags kinds, QilName? ndName, TriState orSelf, QilNode? ndEnd)
{
// Iterator iter;
LocalBuilder locIter = _helper.DeclareLocal(iterName, iterType);
// iter.Create(navCtxt, filter [, orSelf], [, navEnd]);
_helper.Emit(OpCodes.Ldloca, locIter);
NestedVisitEnsureStack(ndCtxt);
LoadSelectFilter(kinds, ndName);
if (orSelf != TriState.Unknown)
_helper.LoadBoolean(orSelf == TriState.True);
if (ndEnd != null)
NestedVisitEnsureStack(ndEnd);
_helper.Call(methCreate);
GenerateSimpleIterator(typeof(XPathNavigator), locIter, methNext, methCurrent);
}
/// <summary>
/// Generate boiler-plate code to create an Xml iterator that controls a nested iterator.
/// </summary>
/// <remarks>
/// Iterator iter;
/// iter.Create(filter [, orSelf]);
/// ...nested iterator...
/// navInput = nestedNested;
/// goto LabelCall;
/// LabelNext:
/// navInput = null;
/// LabelCall:
/// switch (iter.MoveNext(navInput)) {
/// case IteratorState.NoMoreNodes: goto LabelNextCtxt;
/// case IteratorState.NextInputNode: goto LabelNextNested;
/// }
/// </remarks>
private void CreateContainerIterator(QilUnary ndDod, string iterName, Type iterType, MethodInfo methCreate, MethodInfo methNext, MethodInfo methCurrent,
XmlNodeKindFlags kinds, QilName? ndName, TriState orSelf)
{
// Iterator iter;
LocalBuilder locIter = _helper.DeclareLocal(iterName, iterType);
Label lblOnEndNested;
QilLoop ndLoop = (QilLoop)ndDod.Child;
Debug.Assert(ndDod.NodeType == QilNodeType.DocOrderDistinct && ndLoop != null);
// iter.Create(filter [, orSelf]);
_helper.Emit(OpCodes.Ldloca, locIter);
LoadSelectFilter(kinds, ndName);
if (orSelf != TriState.Unknown)
_helper.LoadBoolean(orSelf == TriState.True);
_helper.Call(methCreate);
// Generate nested iterator (branch to lblOnEndNested when iteration is complete)
lblOnEndNested = _helper.DefineLabel();
StartNestedIterator(ndLoop, lblOnEndNested);
StartBinding(ndLoop.Variable);
EndBinding(ndLoop.Variable);
EndNestedIterator(ndLoop.Variable);
_iterCurr.Storage = _iterNested!.Storage;
GenerateContainerIterator(ndDod, locIter, lblOnEndNested, methNext, methCurrent, typeof(XPathNavigator));
}
/// <summary>
/// Generate boiler-plate code that calls MoveNext on a simple Xml iterator. Iterator should have already been
/// created by calling code.
/// </summary>
/// <remarks>
/// ...
/// LabelNext:
/// if (!iter.MoveNext())
/// goto LabelNextCtxt;
/// </remarks>
private void GenerateSimpleIterator(Type itemStorageType, LocalBuilder locIter, MethodInfo methNext, MethodInfo methCurrent)
{
Label lblNext;
// LabelNext:
lblNext = _helper.DefineLabel();
_helper.MarkLabel(lblNext);
// if (!iter.MoveNext()) goto LabelNextCtxt;
_helper.Emit(OpCodes.Ldloca, locIter);
_helper.Call(methNext);
_helper.Emit(OpCodes.Brfalse, _iterCurr.GetLabelNext());
_iterCurr.SetIterator(lblNext, StorageDescriptor.Current(locIter, methCurrent, itemStorageType));
}
/// <summary>
/// Generate boiler-plate code that calls MoveNext on an Xml iterator that controls a nested iterator. Iterator should
/// have already been created by calling code.
/// </summary>
/// <remarks>
/// ...
/// goto LabelCall;
/// LabelNext:
/// navCtxt = null;
/// LabelCall:
/// switch (iter.MoveNext(navCtxt)) {
/// case IteratorState.NoMoreNodes: goto LabelNextCtxt;
/// case IteratorState.NextInputNode: goto LabelNextNested;
/// }
/// </remarks>
private void GenerateContainerIterator(QilNode nd, LocalBuilder locIter, Label lblOnEndNested,
MethodInfo methNext, MethodInfo methCurrent, Type itemStorageType)
{
Label lblCall;
// Define labels that will be used
lblCall = _helper.DefineLabel();
// iter.MoveNext(input);
// goto LabelCall;
_iterCurr.EnsureNoStackNoCache(nd.XmlType!.IsNode ? "$$$navInput" : "$$$itemInput");
_helper.Emit(OpCodes.Ldloca, locIter);
_iterCurr.PushValue();
_helper.EmitUnconditionalBranch(OpCodes.Br, lblCall);
// LabelNext:
// iterSet.MoveNext(null);
_helper.MarkLabel(lblOnEndNested);
_helper.Emit(OpCodes.Ldloca, locIter);
_helper.Emit(OpCodes.Ldnull);
// LabelCall:
// result = iter.MoveNext(input);
_helper.MarkLabel(lblCall);
_helper.Call(methNext);
// If this iterator always returns a single node, then NoMoreNodes will never be returned
if (nd.XmlType.IsSingleton)
{
// if (result == IteratorResult.NeedInputNode) goto LabelNextInput;
_helper.LoadInteger((int)IteratorResult.NeedInputNode);
_helper.Emit(OpCodes.Beq, _iterNested!.GetLabelNext());
_iterCurr.Storage = StorageDescriptor.Current(locIter, methCurrent, itemStorageType);
}
else
{
// switch (iter.MoveNext(input)) {
// case IteratorResult.NoMoreNodes: goto LabelNextCtxt;
// case IteratorResult.NeedInputNode: goto LabelNextInput;
// }
_helper.Emit(OpCodes.Switch, new Label[] { _iterCurr.GetLabelNext(), _iterNested!.GetLabelNext() });
_iterCurr.SetIterator(lblOnEndNested, StorageDescriptor.Current(locIter, methCurrent, itemStorageType));
}
}
/// <summary>
/// Load XmlQueryOutput, load a name (computed or literal) and load an index to an Xml schema type.
/// Return an enumeration that specifies what kind of name was loaded.
/// </summary>
private GenerateNameType LoadNameAndType(XPathNodeType nodeType, QilNode ndName, bool isStart, bool callChk)
{
QilName ndLiteralName;
string prefix, localName, ns;
GenerateNameType nameType;
Debug.Assert(ndName.XmlType!.TypeCode == XmlTypeCode.QName, "Element or attribute name must have QName type.");
_helper.LoadQueryOutput();
// 0. Default is to pop names off stack
nameType = GenerateNameType.StackName;
// 1. Literal names
if (ndName.NodeType == QilNodeType.LiteralQName)
{
// If checks need to be made on End construction, then always pop names from stack
if (isStart || !callChk)
{
ndLiteralName = (ndName as QilName)!;
prefix = ndLiteralName.Prefix;
localName = ndLiteralName.LocalName;
ns = ndLiteralName.NamespaceUri;
// Check local name, namespace parts in debug code
Debug.Assert(ValidateNames.ValidateName(prefix, localName, ns, nodeType, ValidateNames.Flags.AllExceptPrefixMapping));
// If the namespace is empty,
if (ndLiteralName.NamespaceUri.Length == 0)
{
// Then always call method on XmlQueryOutput
_helper.Emit(OpCodes.Ldstr, ndLiteralName.LocalName);
return GenerateNameType.LiteralLocalName;
}
// If prefix is not valid for the node type,
if (!ValidateNames.ValidateName(prefix, localName, ns, nodeType, ValidateNames.Flags.CheckPrefixMapping))
{
// Then construct a new prefix at run-time
if (isStart)
{
_helper.Emit(OpCodes.Ldstr, localName);
_helper.Emit(OpCodes.Ldstr, ns);
_helper.Construct(XmlILConstructors.QName);
nameType = GenerateNameType.QName;
}
}
else
{
// Push string parts
_helper.Emit(OpCodes.Ldstr, prefix);
_helper.Emit(OpCodes.Ldstr, localName);
_helper.Emit(OpCodes.Ldstr, ns);
nameType = GenerateNameType.LiteralName;
}
}
}
else
{
if (isStart)
{
// 2. Copied names
if (ndName.NodeType == QilNodeType.NameOf)
{
// Preserve prefix of source node, so just push navigator onto stack
NestedVisitEnsureStack((ndName as QilUnary)!.Child);
nameType = GenerateNameType.CopiedName;
}
// 3. Parsed tag names (foo:bar)
else if (ndName.NodeType == QilNodeType.StrParseQName)
{
// Preserve prefix from parsed tag name
VisitStrParseQName((ndName as QilBinary)!, true);
// Type of name depends upon data-type of name argument
if ((ndName as QilBinary)!.Right.XmlType!.TypeCode == XmlTypeCode.String)
nameType = GenerateNameType.TagNameAndNamespace;
else
nameType = GenerateNameType.TagNameAndMappings;
}
// 4. Other computed qnames
else
{
// Push XmlQualifiedName onto the stack
NestedVisitEnsureStack(ndName);
nameType = GenerateNameType.QName;
}
}
}
return nameType;
}
/// <summary>
/// If the first argument is a constant value that evaluates to zero, then a more optimal instruction sequence
/// can be generated that does not have to push the zero onto the stack. Instead, a Brfalse or Brtrue instruction
/// can be used.
/// </summary>
private bool TryZeroCompare(QilNodeType relOp, QilNode ndFirst, QilNode ndSecond)
{
Debug.Assert(relOp == QilNodeType.Eq || relOp == QilNodeType.Ne);
switch (ndFirst.NodeType)
{
case QilNodeType.LiteralInt64:
if ((int)(QilLiteral)ndFirst != 0) return false;
break;
case QilNodeType.LiteralInt32:
if ((int)(QilLiteral)ndFirst != 0) return false;
break;
case QilNodeType.False:
break;
case QilNodeType.True:
// Inverse of QilNodeType.False
relOp = (relOp == QilNodeType.Eq) ? QilNodeType.Ne : QilNodeType.Eq;
break;
default:
return false;
}
// Generate code to push second argument on stack
NestedVisitEnsureStack(ndSecond);
// Generate comparison code -- op == 0 or op != 0
ZeroCompare(relOp, ndSecond.XmlType!.TypeCode == XmlTypeCode.Boolean);
return true;
}
/// <summary>
/// If the comparison involves a qname, then perform comparison using atoms and return true.
/// Otherwise, return false (caller will perform comparison).
/// </summary>
private bool TryNameCompare(QilNodeType relOp, QilNode ndFirst, QilNode ndSecond)
{
Debug.Assert(relOp == QilNodeType.Eq || relOp == QilNodeType.Ne);
if (ndFirst.NodeType == QilNodeType.NameOf)
{
switch (ndSecond.NodeType)
{
case QilNodeType.NameOf:
case QilNodeType.LiteralQName:
{
_helper.LoadQueryRuntime();
// Push left navigator onto the stack
NestedVisitEnsureStack((ndFirst as QilUnary)!.Child);
// Push the local name and namespace uri of the right argument onto the stack
if (ndSecond.NodeType == QilNodeType.LiteralQName)
{
QilName ndName = (ndSecond as QilName)!;
_helper.LoadInteger(_helper.StaticData.DeclareName(ndName.LocalName));
_helper.LoadInteger(_helper.StaticData.DeclareName(ndName.NamespaceUri));
// push runtime.IsQNameEqual(navigator, localName, namespaceUri)
_helper.Call(XmlILMethods.QNameEqualLit);
}
else
{
// Generate code to locate the navigator argument of NameOf operator
Debug.Assert(ndSecond.NodeType == QilNodeType.NameOf);
NestedVisitEnsureStack(ndSecond);
// push runtime.IsQNameEqual(nav1, nav2)
_helper.Call(XmlILMethods.QNameEqualNav);
}
// Branch based on boolean result or push boolean value
ZeroCompare((relOp == QilNodeType.Eq) ? QilNodeType.Ne : QilNodeType.Eq, true);
return true;
}
}
}
// Caller must perform comparison
return false;
}
/// <summary>
/// For QilExpression types that map directly to CLR primitive types, the built-in CLR comparison operators can
/// be used to perform the specified relational operation.
/// </summary>
private void ClrCompare(QilNodeType relOp, XmlTypeCode code)
{
OpCode opcode;
Label lblTrue;
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnFalse:
// Reverse the comparison operator
// Use Bxx_Un OpCodes to handle NaN case for double and single types
if (code == XmlTypeCode.Double || code == XmlTypeCode.Float)
{
switch (relOp)
{
case QilNodeType.Gt: opcode = OpCodes.Ble_Un; break;
case QilNodeType.Ge: opcode = OpCodes.Blt_Un; break;
case QilNodeType.Lt: opcode = OpCodes.Bge_Un; break;
case QilNodeType.Le: opcode = OpCodes.Bgt_Un; break;
case QilNodeType.Eq: opcode = OpCodes.Bne_Un; break;
case QilNodeType.Ne: opcode = OpCodes.Beq; break;
default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
}
}
else
{
switch (relOp)
{
case QilNodeType.Gt: opcode = OpCodes.Ble; break;
case QilNodeType.Ge: opcode = OpCodes.Blt; break;
case QilNodeType.Lt: opcode = OpCodes.Bge; break;
case QilNodeType.Le: opcode = OpCodes.Bgt; break;
case QilNodeType.Eq: opcode = OpCodes.Bne_Un; break;
case QilNodeType.Ne: opcode = OpCodes.Beq; break;
default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
}
}
_helper.Emit(opcode, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
break;
case BranchingContext.OnTrue:
switch (relOp)
{
case QilNodeType.Gt: opcode = OpCodes.Bgt; break;
case QilNodeType.Ge: opcode = OpCodes.Bge; break;
case QilNodeType.Lt: opcode = OpCodes.Blt; break;
case QilNodeType.Le: opcode = OpCodes.Ble; break;
case QilNodeType.Eq: opcode = OpCodes.Beq; break;
case QilNodeType.Ne: opcode = OpCodes.Bne_Un; break;
default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
}
_helper.Emit(opcode, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
break;
default:
Debug.Assert(_iterCurr.CurrentBranchingContext == BranchingContext.None);
switch (relOp)
{
case QilNodeType.Gt: _helper.Emit(OpCodes.Cgt); break;
case QilNodeType.Lt: _helper.Emit(OpCodes.Clt); break;
case QilNodeType.Eq: _helper.Emit(OpCodes.Ceq); break;
default:
switch (relOp)
{
case QilNodeType.Ge: opcode = OpCodes.Bge_S; break;
case QilNodeType.Le: opcode = OpCodes.Ble_S; break;
case QilNodeType.Ne: opcode = OpCodes.Bne_Un_S; break;
default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
}
// Push "true" if comparison succeeds, "false" otherwise
lblTrue = _helper.DefineLabel();
_helper.Emit(opcode, lblTrue);
_helper.ConvBranchToBool(lblTrue, true);
break;
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
break;
}
}
/// <summary>
/// Generate code to compare the top stack value to 0 by using the Brfalse or Brtrue instructions,
/// which avoid pushing zero onto the stack. Both of these instructions test for null/zero/false.
/// </summary>
private void ZeroCompare(QilNodeType relOp, bool isBoolVal)
{
Label lblTrue;
Debug.Assert(relOp == QilNodeType.Eq || relOp == QilNodeType.Ne);
// Test to determine if top stack value is zero (if relOp is Eq) or is not zero (if relOp is Ne)
switch (_iterCurr.CurrentBranchingContext)
{
case BranchingContext.OnTrue:
// If relOp is Eq, jump to true label if top value is zero (Brfalse)
// If relOp is Ne, jump to true label if top value is non-zero (Brtrue)
_helper.Emit((relOp == QilNodeType.Eq) ? OpCodes.Brfalse : OpCodes.Brtrue, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
break;
case BranchingContext.OnFalse:
// If relOp is Eq, jump to false label if top value is non-zero (Brtrue)
// If relOp is Ne, jump to false label if top value is zero (Brfalse)
_helper.Emit((relOp == QilNodeType.Eq) ? OpCodes.Brtrue : OpCodes.Brfalse, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
break;
default:
Debug.Assert(_iterCurr.CurrentBranchingContext == BranchingContext.None);
// Since (boolval != 0) = boolval, value on top of the stack is already correct
if (!isBoolVal || relOp == QilNodeType.Eq)
{
// If relOp is Eq, push "true" if top value is zero, "false" otherwise
// If relOp is Ne, push "true" if top value is non-zero, "false" otherwise
lblTrue = _helper.DefineLabel();
_helper.Emit((relOp == QilNodeType.Eq) ? OpCodes.Brfalse : OpCodes.Brtrue, lblTrue);
_helper.ConvBranchToBool(lblTrue, true);
}
_iterCurr.Storage = StorageDescriptor.Stack(typeof(bool), false);
break;
}
}
/// <summary>
/// Construction within a loop is starting. If transition from non-Any to Any state occurs, then ensure
/// that runtime state will be set.
/// </summary>
private void StartWriterLoop(QilNode nd, out bool hasOnEnd, out Label lblOnEnd)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(nd);
// By default, do not create a new iteration label
hasOnEnd = false;
lblOnEnd = default;
// If loop is not involved in Xml construction, or if loop returns exactly one value, then do nothing
if (!info.PushToWriterLast || nd.XmlType!.IsSingleton)
return;
if (!_iterCurr.HasLabelNext)
{
// Iterate until all items are constructed
hasOnEnd = true;
lblOnEnd = _helper.DefineLabel();
_iterCurr.SetIterator(lblOnEnd, StorageDescriptor.None());
}
}
/// <summary>
/// Construction within a loop is ending. If transition from non-Any to Any state occurs, then ensure that
/// runtime state will be set.
/// </summary>
private void EndWriterLoop(QilNode nd, bool hasOnEnd, Label lblOnEnd)
{
XmlILConstructInfo info = XmlILConstructInfo.Read(nd);
// If loop is not involved in Xml construction, then do nothing
if (!info.PushToWriterLast)
return;
// Since results of construction were pushed to writer, there are no values to return
_iterCurr.Storage = StorageDescriptor.None();
// If loop returns exactly one value, then do nothing further
if (nd.XmlType!.IsSingleton)
return;
if (hasOnEnd)
{
// Loop over all items in the list, sending each to the output writer
_iterCurr.LoopToEnd(lblOnEnd);
}
}
/// <summary>
/// Returns true if the specified node's owner element might have local namespaces added to it
/// after attributes have already been added.
/// </summary>
private bool MightHaveNamespacesAfterAttributes(XmlILConstructInfo? info)
{
// Get parent element
if (info != null)
info = info.ParentElementInfo;
// If a parent element has not been statically identified, then assume that the runtime
// element will have namespaces added after attributes.
if (info == null)
return true;
return info.MightHaveNamespacesAfterAttributes;
}
/// <summary>
/// Returns true if the specified element should cache attributes.
/// </summary>
private bool ElementCachesAttributes(XmlILConstructInfo info)
{
// Attributes will be cached if namespaces might be constructed after the attributes
return info.MightHaveDuplicateAttributes || info.MightHaveNamespacesAfterAttributes;
}
/// <summary>
/// This method is called before calling any WriteEnd??? method. It generates code to perform runtime
/// construction checks separately. This should only be called if the XmlQueryOutput::StartElementChk
/// method will *not* be called.
/// </summary>
private void BeforeStartChecks(QilNode ndCtor)
{
switch (XmlILConstructInfo.Read(ndCtor).InitialStates)
{
case PossibleXmlStates.WithinSequence:
// If runtime state is guaranteed to be WithinSequence, then call XmlQueryOutput.StartTree
_helper.CallStartTree(QilConstructorToNodeType(ndCtor.NodeType));
break;
case PossibleXmlStates.EnumAttrs:
switch (ndCtor.NodeType)
{
case QilNodeType.ElementCtor:
case QilNodeType.TextCtor:
case QilNodeType.RawTextCtor:
case QilNodeType.PICtor:
case QilNodeType.CommentCtor:
// If runtime state is guaranteed to be EnumAttrs, and content is being constructed, call
// XmlQueryOutput.StartElementContent
_helper.CallStartElementContent();
break;
}
break;
}
}
/// <summary>
/// This method is called after calling any WriteEnd??? method. It generates code to perform runtime
/// construction checks separately. This should only be called if the XmlQueryOutput::EndElementChk
/// method will *not* be called.
/// </summary>
private void AfterEndChecks(QilNode ndCtor)
{
if (XmlILConstructInfo.Read(ndCtor).FinalStates == PossibleXmlStates.WithinSequence)
{
// If final runtime state is guaranteed to be WithinSequence, then call XmlQueryOutput.StartTree
_helper.CallEndTree();
}
}
/// <summary>
/// Return true if a runtime check needs to be made in order to transition into the WithinContent state.
/// </summary>
private bool CheckWithinContent(XmlILConstructInfo info)
{
switch (info.InitialStates)
{
case PossibleXmlStates.WithinSequence:
case PossibleXmlStates.EnumAttrs:
case PossibleXmlStates.WithinContent:
// Transition to WithinContent can be ensured at compile-time
return false;
}
return true;
}
/// <summary>
/// Return true if a runtime check needs to be made in order to transition into the EnumAttrs state.
/// </summary>
private bool CheckEnumAttrs(XmlILConstructInfo info)
{
switch (info.InitialStates)
{
case PossibleXmlStates.WithinSequence:
case PossibleXmlStates.EnumAttrs:
// Transition to EnumAttrs can be ensured at compile-time
return false;
}
return true;
}
/// <summary>
/// Map the XmlNodeKindFlags enumeration into the XPathNodeType enumeration.
/// </summary>
private XPathNodeType QilXmlToXPathNodeType(XmlNodeKindFlags xmlTypes)
{
switch (xmlTypes)
{
case XmlNodeKindFlags.Element: return XPathNodeType.Element;
case XmlNodeKindFlags.Attribute: return XPathNodeType.Attribute;
case XmlNodeKindFlags.Text: return XPathNodeType.Text;
case XmlNodeKindFlags.Comment: return XPathNodeType.Comment;
}
Debug.Assert(xmlTypes == XmlNodeKindFlags.PI);
return XPathNodeType.ProcessingInstruction;
}
/// <summary>
/// Map a QilExpression constructor type into the XPathNodeType enumeration.
/// </summary>
private XPathNodeType QilConstructorToNodeType(QilNodeType typ)
{
switch (typ)
{
case QilNodeType.DocumentCtor: return XPathNodeType.Root;
case QilNodeType.ElementCtor: return XPathNodeType.Element;
case QilNodeType.TextCtor: return XPathNodeType.Text;
case QilNodeType.RawTextCtor: return XPathNodeType.Text;
case QilNodeType.PICtor: return XPathNodeType.ProcessingInstruction;
case QilNodeType.CommentCtor: return XPathNodeType.Comment;
case QilNodeType.AttributeCtor: return XPathNodeType.Attribute;
case QilNodeType.NamespaceDecl: return XPathNodeType.Namespace;
}
Debug.Fail($"Cannot map QilNodeType {typ} to an XPathNodeType");
return XPathNodeType.All;
}
/// <summary>
/// Load an XmlNavigatorFilter that matches only the specified name and types onto the stack.
/// </summary>
private void LoadSelectFilter(XmlNodeKindFlags xmlTypes, QilName? ndName)
{
if (ndName != null)
{
// Push NameFilter
Debug.Assert(xmlTypes == XmlNodeKindFlags.Element);
_helper.CallGetNameFilter(_helper.StaticData.DeclareNameFilter(ndName.LocalName, ndName.NamespaceUri));
}
else
{
// Either type cannot be a union, or else it must be >= union of all Content types
bool isXmlTypeUnion = IsNodeTypeUnion(xmlTypes);
Debug.Assert(!isXmlTypeUnion || (xmlTypes & XmlNodeKindFlags.Content) == XmlNodeKindFlags.Content);
if (isXmlTypeUnion)
{
if ((xmlTypes & XmlNodeKindFlags.Attribute) != 0)
{
// Union includes attributes, so allow all node kinds
_helper.CallGetTypeFilter(XPathNodeType.All);
}
else
{
// Filter attributes
_helper.CallGetTypeFilter(XPathNodeType.Attribute);
}
}
else
{
// Filter nodes of all but one type
_helper.CallGetTypeFilter(QilXmlToXPathNodeType(xmlTypes));
}
}
}
/// <summary>
/// Return true if more than one node type is set.
/// </summary>
private static bool IsNodeTypeUnion(XmlNodeKindFlags xmlTypes)
{
return ((int)xmlTypes & ((int)xmlTypes - 1)) != 0;
}
/// <summary>
/// Start construction of a new nested iterator. If this.iterCurr == null, then the new iterator
/// is a top-level, or root iterator. Otherwise, the new iterator will be nested within the
/// current iterator.
/// </summary>
[MemberNotNull(nameof(_iterCurr))]
private void StartNestedIterator(QilNode? nd)
{
IteratorDescriptor? iterParent = _iterCurr;
// Create a new, nested iterator
if (iterParent == null)
{
// Create a "root" iterator info that has no parernt
_iterCurr = new IteratorDescriptor(_helper);
}
else
{
// Create a nested iterator
_iterCurr = new IteratorDescriptor(iterParent);
}
_iterNested = null;
}
/// <summary>
/// Calls StartNestedIterator(nd) and also sets up the nested iterator to branch to "lblOnEnd" when iteration
/// is complete.
/// </summary>
private void StartNestedIterator(QilNode? nd, Label lblOnEnd)
{
StartNestedIterator(nd);
_iterCurr.SetIterator(lblOnEnd, StorageDescriptor.None());
}
/// <summary>
/// End construction of the current iterator.
/// </summary>
private void EndNestedIterator(QilNode nd)
{
Debug.Assert(_iterCurr.Storage.Location == ItemLocation.None ||
_iterCurr.Storage.ItemStorageType == GetItemStorageType(nd) ||
_iterCurr.Storage.ItemStorageType == typeof(XPathItem) ||
nd.XmlType!.TypeCode == XmlTypeCode.None,
"QilNodeType " + nd.NodeType + " cannot be stored using type " + _iterCurr.Storage.ItemStorageType + ".");
// If the nested iterator was constructed in branching mode,
if (_iterCurr.IsBranching)
{
// Then if branching hasn't already taken place, do so now
if (_iterCurr.Storage.Location != ItemLocation.None)
{
_iterCurr.EnsureItemStorageType(nd.XmlType!, typeof(bool));
_iterCurr.EnsureStackNoCache();
if (_iterCurr.CurrentBranchingContext == BranchingContext.OnTrue)
_helper.Emit(OpCodes.Brtrue, _iterCurr.LabelBranch);
else
_helper.Emit(OpCodes.Brfalse, _iterCurr.LabelBranch);
_iterCurr.Storage = StorageDescriptor.None();
}
}
// Save current iterator as nested iterator
_iterNested = _iterCurr;
// Update current iterator to be parent iterator
_iterCurr = _iterCurr.ParentIterator!;
}
/// <summary>
/// Recursively generate code to iterate over the results of the "nd" expression. If "nd" is pushed
/// to the writer, then there are no results. If "nd" is a singleton expression and isCached is false,
/// then generate code to construct the singleton. Otherwise, cache the sequence in an XmlQuerySequence
/// object. Ensure that all items are converted to the specified "itemStorageType".
/// </summary>
private void NestedVisit(QilNode nd, Type itemStorageType, bool isCached)
{
if (XmlILConstructInfo.Read(nd).PushToWriterLast)
{
// Push results to output, so nothing is left to store
StartNestedIterator(nd);
Visit(nd);
EndNestedIterator(nd);
_iterCurr.Storage = StorageDescriptor.None();
}
else if (!isCached && nd.XmlType!.IsSingleton)
{
// Storage of result will be a non-cached singleton
StartNestedIterator(nd);
Visit(nd);
_iterCurr.EnsureNoCache();
_iterCurr.EnsureItemStorageType(nd.XmlType, itemStorageType);
EndNestedIterator(nd);
_iterCurr.Storage = _iterNested!.Storage;
}
else
{
NestedVisitEnsureCache(nd, itemStorageType);
}
}
/// <summary>
/// Calls NestedVisit(QilNode, Type, bool), storing result in the default storage type for "nd".
/// </summary>
private void NestedVisit(QilNode nd)
{
NestedVisit(nd, GetItemStorageType(nd), !nd.XmlType!.IsSingleton);
}
/// <summary>
/// Recursively generate code to iterate over the results of the "nd" expression. When the expression
/// has been fully iterated, it will jump to "lblOnEnd".
/// </summary>
private void NestedVisit(QilNode nd, Label lblOnEnd)
{
Debug.Assert(!XmlILConstructInfo.Read(nd).PushToWriterLast);
StartNestedIterator(nd, lblOnEnd);
Visit(nd);
_iterCurr.EnsureNoCache();
_iterCurr.EnsureItemStorageType(nd.XmlType!, GetItemStorageType(nd));
EndNestedIterator(nd);
_iterCurr.Storage = _iterNested!.Storage;
}
/// <summary>
/// Call NestedVisit(QilNode) and ensure that result is pushed onto the IL stack.
/// </summary>
private void NestedVisitEnsureStack(QilNode nd)
{
Debug.Assert(!XmlILConstructInfo.Read(nd).PushToWriterLast);
NestedVisit(nd);
_iterCurr.EnsureStack();
}
/// <summary>
/// Generate code for both QilExpression nodes and ensure that each result is pushed onto the IL stack.
/// </summary>
private void NestedVisitEnsureStack(QilNode ndLeft, QilNode ndRight)
{
NestedVisitEnsureStack(ndLeft);
NestedVisitEnsureStack(ndRight);
}
/// <summary>
/// Call NestedVisit(QilNode, Type, bool) and ensure that result is pushed onto the IL stack.
/// </summary>
private void NestedVisitEnsureStack(QilNode nd, Type itemStorageType, bool isCached)
{
Debug.Assert(!XmlILConstructInfo.Read(nd).PushToWriterLast);
NestedVisit(nd, itemStorageType, isCached);
_iterCurr.EnsureStack();
}
/// <summary>
/// Call NestedVisit(QilNode) and ensure that result is stored in local variable "loc".
/// </summary>
private void NestedVisitEnsureLocal(QilNode nd, LocalBuilder loc)
{
Debug.Assert(!XmlILConstructInfo.Read(nd).PushToWriterLast);
NestedVisit(nd);
_iterCurr.EnsureLocal(loc);
}
/// <summary>
/// Start a nested iterator in a branching context and recursively generate code for the specified QilExpression node.
/// </summary>
private void NestedVisitWithBranch(QilNode nd, BranchingContext brctxt, Label lblBranch)
{
Debug.Assert(nd.XmlType!.IsSingleton && !XmlILConstructInfo.Read(nd).PushToWriterLast);
StartNestedIterator(nd);
_iterCurr.SetBranching(brctxt, lblBranch);
Visit(nd);
EndNestedIterator(nd);
_iterCurr.Storage = StorageDescriptor.None();
}
/// <summary>
/// Generate code for the QilExpression node and ensure that results are fully cached as an XmlQuerySequence. All results
/// should be converted to "itemStorageType" before being added to the cache.
/// </summary>
private void NestedVisitEnsureCache(QilNode nd, Type itemStorageType)
{
Debug.Assert(!XmlILConstructInfo.Read(nd).PushToWriterLast);
bool cachesResult = CachesResult(nd);
LocalBuilder locCache;
Label lblOnEnd = _helper.DefineLabel();
Type cacheType;
XmlILStorageMethods methods;
// If bound expression will already be cached correctly, then don't create an XmlQuerySequence
if (cachesResult)
{
StartNestedIterator(nd);
Visit(nd);
EndNestedIterator(nd);
_iterCurr.Storage = _iterNested!.Storage;
Debug.Assert(_iterCurr.Storage.IsCached, "Expression result should be cached. CachesResult() might have a bug in it.");
// If type of items in the cache matches "itemStorageType", then done
if (_iterCurr.Storage.ItemStorageType == itemStorageType)
return;
// If the cache has navigators in it, or if converting to a cache of navigators, then EnsureItemStorageType
// can directly convert without needing to create a new cache.
if (_iterCurr.Storage.ItemStorageType == typeof(XPathNavigator) || itemStorageType == typeof(XPathNavigator))
{
_iterCurr.EnsureItemStorageType(nd.XmlType!, itemStorageType);
return;
}
_iterCurr.EnsureNoStack("$$$cacheResult");
}
// Always store navigators in XmlQueryNodeSequence (which implements IList<XPathItem>)
cacheType = (GetItemStorageType(nd) == typeof(XPathNavigator)) ? typeof(XPathNavigator) : itemStorageType;
// XmlQuerySequence<T> cache;
methods = XmlILMethods.StorageMethods[cacheType];
locCache = _helper.DeclareLocal("$$$cache", methods.SeqType);
_helper.Emit(OpCodes.Ldloc, locCache);
// Special case non-navigator singletons to use overload of CreateOrReuse
if (nd.XmlType!.IsSingleton)
{
// cache = XmlQuerySequence.CreateOrReuse(cache, item);
NestedVisitEnsureStack(nd, cacheType, false);
_helper.Call(methods.SeqReuseSgl);
_helper.Emit(OpCodes.Stloc, locCache);
}
else
{
// XmlQuerySequence<T> cache;
// cache = XmlQuerySequence.CreateOrReuse(cache);
_helper.Call(methods.SeqReuse);
_helper.Emit(OpCodes.Stloc, locCache);
_helper.Emit(OpCodes.Ldloc, locCache);
StartNestedIterator(nd, lblOnEnd);
if (cachesResult)
_iterCurr.Storage = _iterCurr.ParentIterator!.Storage;
else
Visit(nd);
// cache.Add(item);
_iterCurr.EnsureItemStorageType(nd.XmlType, cacheType);
_iterCurr.EnsureStackNoCache();
_helper.Call(methods.SeqAdd);
_helper.Emit(OpCodes.Ldloc, locCache);
// }
_iterCurr.LoopToEnd(lblOnEnd);
EndNestedIterator(nd);
// Remove cache reference from stack
_helper.Emit(OpCodes.Pop);
}
_iterCurr.Storage = StorageDescriptor.Local(locCache, itemStorageType, true);
}
/// <summary>
/// Returns true if the specified QilExpression node type is *guaranteed* to cache its results in an XmlQuerySequence,
/// where items in the cache are stored using the default storage type.
/// </summary>
private bool CachesResult(QilNode nd)
{
OptimizerPatterns patt;
switch (nd.NodeType)
{
case QilNodeType.Let:
case QilNodeType.Parameter:
case QilNodeType.Invoke:
case QilNodeType.XsltInvokeLateBound:
case QilNodeType.XsltInvokeEarlyBound:
return !nd.XmlType!.IsSingleton;
case QilNodeType.Filter:
// EqualityIndex pattern caches results
patt = OptimizerPatterns.Read(nd);
return patt.MatchesPattern(OptimizerPatternName.EqualityIndex);
case QilNodeType.DocOrderDistinct:
if (nd.XmlType!.IsSingleton)
return false;
// JoinAndDod and DodReverse patterns don't cache results
patt = OptimizerPatterns.Read(nd);
return !patt.MatchesPattern(OptimizerPatternName.JoinAndDod) && !patt.MatchesPattern(OptimizerPatternName.DodReverse);
case QilNodeType.TypeAssert:
QilTargetType ndTypeAssert = (QilTargetType)nd;
// Check if TypeAssert would be no-op
return CachesResult(ndTypeAssert.Source) && GetItemStorageType(ndTypeAssert.Source) == GetItemStorageType(ndTypeAssert);
}
return false;
}
/// <summary>
/// Shortcut call to XmlILTypeHelper.GetStorageType.
/// </summary>
private Type GetStorageType(QilNode nd)
{
return XmlILTypeHelper.GetStorageType(nd.XmlType!);
}
/// <summary>
/// Shortcut call to XmlILTypeHelper.GetStorageType.
/// </summary>
private Type GetStorageType(XmlQueryType typ)
{
return XmlILTypeHelper.GetStorageType(typ);
}
/// <summary>
/// Shortcut call to XmlILTypeHelper.GetStorageType, using an expression's prime type.
/// </summary>
private Type GetItemStorageType(QilNode nd)
{
return XmlILTypeHelper.GetStorageType(nd.XmlType!.Prime);
}
/// <summary>
/// Shortcut call to XmlILTypeHelper.GetStorageType, using the prime type.
/// </summary>
private Type GetItemStorageType(XmlQueryType typ)
{
return XmlILTypeHelper.GetStorageType(typ.Prime);
}
}
}
| 42.236568 | 213 | 0.564113 | [
"MIT"
] | C-xC-c/runtime | src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlIlVisitor.cs | 210,676 | C# |
using System.Collections.Generic;
namespace AcreeBlog.ViewModels.Home
{
public class TopicsViewModel
{
public IEnumerable<TopicWithBlogCountViewModel> Topics { get; set; }
}
public class TopicWithBlogCountViewModel
{
public long Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public int BlogCount { get; set; }
}
}
| 23.235294 | 72 | 0.696203 | [
"MIT"
] | Chris-Acree/AcreeBlog | src/AcreeBlog/ViewModels/Home/TopicsViewModel.cs | 397 | C# |
using System;
using System.Runtime.Serialization;
namespace dapi_client_csharp.RPC
{
[Serializable]
public class RpcInternalServerErrorException : Exception
{
public RpcInternalServerErrorException()
{
}
public RpcInternalServerErrorException(string customMessage) : base(customMessage)
{
}
public RpcInternalServerErrorException(string customMessage, Exception exception) : base(customMessage, exception)
{
}
public RpcErrorCode? RpcErrorCode { get; set; }
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException("info");
}
info.AddValue("RpcErrorCode", RpcErrorCode, typeof(RpcErrorCode));
base.GetObjectData(info, context);
}
}
} | 26.970588 | 122 | 0.633588 | [
"MIT"
] | 10xcryptodev/dapi-client-csharp | dapi-client-csharp/RPC/RpcInternalServerErrorException.cs | 917 | C# |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.WindowsAzure.Storage.Queue;
namespace Dashboard.EndToEndTests
{
public class QueueArgumentsDisplayFunctions
{
public static readonly MethodInfo NullOutputMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("NullOutput");
public static readonly MethodInfo ByteMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("Byte");
public static readonly MethodInfo StringMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("String");
public static readonly MethodInfo ICollectorMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("ICollector");
public static readonly MethodInfo PocoMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("POCO");
public static readonly MethodInfo CloudQueueMessageMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("CloudQueueMessage");
public static readonly MethodInfo SingletonMethodInfo = typeof(QueueArgumentsDisplayFunctions).GetMethod("Singleton");
[Singleton("TestScope")]
public static void Singleton(
[QueueTrigger("queue-singleton-in")] string input,
[Queue("queue-singleton-out")] out string output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
output = input;
done = "x";
}
public static void NullOutput(
[QueueTrigger("queue-nulloutput-in")] string input,
[Queue("queue-nulloutput-out")] out string output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
output = null;
done = "x";
}
public static void Byte(
[QueueTrigger("queue-byte-in")] byte[] input,
[Queue("queue-byte-out")] out byte[] output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
output = input;
done = "x";
}
public static void String(
[QueueTrigger("queue-string-in")] string input,
[Queue("queue-string-out")] out string output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
output = input;
done = "x";
}
public static void ICollector(
[QueueTrigger("queue-icollector-in")] string input,
[Queue("queue-icollector-out")] ICollector<string> output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
foreach (char c in input)
{
output.Add(c.ToString());
}
done = "x";
}
public static void POCO(
[QueueTrigger("queue-poco-in")] POCO input,
[Queue("queue-poco-out")] out POCO output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
output = input;
done = "x";
}
public static void CloudQueueMessage(
[QueueTrigger("queue-cloudqueuemessage-in")] CloudQueueMessage input,
[Queue("queue-cloudqueuemessage-out")] out CloudQueueMessage output,
[Queue(DoneNotificationFunction.DoneQueueName)] out string done)
{
output = input;
done = "x";
}
}
}
| 39.351064 | 142 | 0.640443 | [
"Apache-2.0"
] | Azure/azure-webjobs-sdk-dashboard-tests | test/Dashboard.EndToEndTests/Tests/ArgumentsDisplay/QueueArgumentsDisplayFunctions.cs | 3,701 | C# |
// ********************************************************
// Copyright (C) 2022 Louis S. Berman (louis@squideyes.com)
//
// This file is part of JonesRovers
//
// The use of this source code is licensed under the terms
// of the MIT License (https://opensource.org/licenses/MIT)
// ********************************************************
using Common;
using Microsoft.Azure.Cosmos;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace BackEnd;
public class Program
{
public static void Main()
{
var host = new HostBuilder()
.ConfigureAppConfiguration((c, b) =>
{
if (c.HostingEnvironment.IsDevelopment())
b.AddUserSecrets<Program>();
})
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices((c, s) =>
{
var options = new CosmosClientOptions
{
Serializer = new CosmosJsonSerializer(
JsonHelper.GetJsonSerializerOptions())
};
var client = new CosmosClient(
c.Configuration["CosmosConnString"], options);
s.AddSingleton(
client.GetContainer("JonesRovers", "Manifests"));
})
.Build();
host.Run();
}
} | 30.06383 | 69 | 0.522293 | [
"MIT"
] | squideyes/JonesRovers | BackEnd/Program.cs | 1,413 | C# |
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DataAccess.Models
{
public class HotelFeature
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[MaxLength(200)]
public string Name { get; set; }
[Required]
[MaxLength(200)]
public string Category { get; set; }
[MaxLength(200)]
public string Icon { get; set; }
public virtual ICollection<HotelRoomFeature> RoomFeatures { get; set; }
}
}
| 23.285714 | 79 | 0.630368 | [
"MIT"
] | boicualexandru/Food-Fusion-BE | DataAccess/Models/HotelFeature.cs | 654 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Azure.Storage.Queues.Models
{
internal partial class DequeuedMessageItem
{
}
}
| 19.9 | 61 | 0.728643 | [
"MIT"
] | 93mishra/azure-sdk-for-net | sdk/storage/Azure.Storage.Queues/src/Models/Internal/DequeuedMessageItem.cs | 201 | C# |
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Newtonsoft.Json;
using RiotSharp.Endpoints.ClientEndpoint.ActivePlayer;
using RiotSharp.Endpoints.ClientEndpoint.GameEvents;
using RiotSharp.Endpoints.ClientEndpoint.PlayerList;
using RiotSharp.Endpoints.Interfaces.Client;
using RiotSharp.Http;
using RiotSharp.Http.Interfaces;
namespace RiotSharp.Endpoints.ClientEndpoint
{
/// <inheritdoc cref="IClientEndpoint" />
public class ClientEndpoint : IClientEndpoint
{
private const string ClientCertificateThumbprint = "8259aafd8f71a809d2b154dd1cdb492981e448bd";
private const string Host = "127.0.0.1:2999";
private const string ClientDataRootUrl = "/liveclientdata";
private const string GameDataUrl = "/allgamedata";
private const string ActivePlayerUrl = "/activeplayer";
private const string ActivePlayerSummonerNameUrl = "/activeplayername";
private const string ActivePlayerAbilitiesUrl = "/activeplayerabilities";
private const string ActivePlayerRunesUrl = "/activeplayerrunes";
private const string PlayerListUrl = "/playerlist";
private const string PlayerItemsBySummonerNameUrl = "/playeritems?summonername={0}";
private const string PlayerMainRunesBySummonerNameUrl = "/playermainrunes?summonername={0}";
private const string PlayerSummonerSpellsBySummonerNameUrl = "/playersummonerspells?summonername={0}";
private const string PlayerScoresBySummonerNameUrl = "/playerscores?summonername={0}";
private const string GameEventListUrl = "/eventdata";
private const string GameStatsUrl = "/gamestats";
private static ClientEndpoint _instance;
private readonly IRequester _requester;
/// <summary>
/// Initializes a new instance of the <see cref="ClientEndpoint" /> class.
/// </summary>
/// <param name="requester">The <see cref="IRequester" /> to use for API requests.</param>
internal ClientEndpoint(IRequester requester)
{
_requester = requester ?? throw new ArgumentNullException(nameof(requester));
}
/// <inheritdoc />
public async Task<GameData> GetGameDataAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{GameDataUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<GameData>(json);
}
/// <inheritdoc />
public async Task<ActivePlayer.ActivePlayer> GetActivePlayerAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{ActivePlayerUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<ActivePlayer.ActivePlayer>(json);
}
/// <inheritdoc />
public async Task<string> GetActivePlayerSummonerNameAsync()
{
return await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{ActivePlayerSummonerNameUrl}").ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<ActivePlayerAbilities> GetActivePlayerAbilitiesAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{ActivePlayerAbilitiesUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<ActivePlayerAbilities>(json);
}
/// <inheritdoc />
public async Task<ActivePlayerFullRunes> GetActivePlayerRunesAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{ActivePlayerRunesUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<ActivePlayerFullRunes>(json);
}
/// <inheritdoc />
public async Task<List<Player>> GetPlayerListAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{PlayerListUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<List<Player>>(json);
}
/// <inheritdoc />
public async Task<List<PlayerItem>> GetPlayerItemsAsync(string summonerName)
{
var json = await _requester.CreateGetRequestAsync(Host, string.Format($"{ClientDataRootUrl}{PlayerItemsBySummonerNameUrl}", summonerName))
.ConfigureAwait(false);
return JsonConvert.DeserializeObject<List<PlayerItem>>(json);
}
/// <inheritdoc />
public async Task<PlayerMainRunes> GetPlayerMainRunesAsync(string summonerName)
{
var json = await _requester.CreateGetRequestAsync(Host, string.Format($"{ClientDataRootUrl}{PlayerMainRunesBySummonerNameUrl}", summonerName))
.ConfigureAwait(false);
return JsonConvert.DeserializeObject<PlayerMainRunes>(json);
}
/// <inheritdoc />
public async Task<PlayerSummonerSpellList> GetPlayerSummonerSpellsAsync(string summonerName)
{
var json = await _requester.CreateGetRequestAsync(Host, string.Format($"{ClientDataRootUrl}{PlayerSummonerSpellsBySummonerNameUrl}", summonerName))
.ConfigureAwait(false);
return JsonConvert.DeserializeObject<PlayerSummonerSpellList>(json);
}
/// <inheritdoc />
public async Task<PlayerScores> GetPlayerScoresAsync(string summonerName)
{
var json = await _requester.CreateGetRequestAsync(Host, string.Format($"{ClientDataRootUrl}{PlayerScoresBySummonerNameUrl}", summonerName))
.ConfigureAwait(false);
return JsonConvert.DeserializeObject<PlayerScores>(json);
}
/// <inheritdoc />
public async Task<GameEventList> GetGameEventListAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{GameEventListUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<GameEventList>(json);
}
/// <inheritdoc />
public async Task<GameStats> GetGameStatsAsync()
{
var json = await _requester.CreateGetRequestAsync(Host, $"{ClientDataRootUrl}{GameStatsUrl}").ConfigureAwait(false);
return JsonConvert.DeserializeObject<GameStats>(json);
}
/// <summary>
/// Gets the singleton instance of the <see cref="ClientEndpoint" /> class.
/// </summary>
/// <returns>The singleton instance of the <see cref="ClientEndpoint" /> class.</returns>
public static IClientEndpoint GetInstance()
{
if (Requesters.ClientApiRequester == null)
{
var clientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = ValidateClientCertificate
};
Requesters.ClientApiRequester = new Requester(clientHandler);
}
return _instance ?? (_instance = new ClientEndpoint(Requesters.ClientApiRequester));
}
private static bool ValidateClientCertificate(HttpRequestMessage message, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors errors)
{
if (errors == SslPolicyErrors.None)
{
return true;
}
if (certificate?.Thumbprint?.Equals(ClientCertificateThumbprint, StringComparison.OrdinalIgnoreCase) == true)
{
return true;
}
return false;
}
}
} | 45.9 | 159 | 0.659234 | [
"MIT"
] | Johannes-Schneider/RiotSharp | RiotSharp/Endpoints/ClientEndpoint/ClientEndpoint.cs | 7,805 | C# |
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
// **NOTE** This file was generated by a tool and any changes will be overwritten.
// <auto-generated/>
// Template Source: MethodRequest.cs.tt
namespace Microsoft.Graph
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading;
/// <summary>
/// The type UnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest.
/// </summary>
public partial class UnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest : BaseRequest, IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest
{
/// <summary>
/// Constructs a new UnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest.
/// </summary>
public UnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest(
string requestUrl,
IBaseClient client,
IEnumerable<Option> options)
: base(requestUrl, client, options)
{
}
/// <summary>
/// Issues the GET request.
/// </summary>
public System.Threading.Tasks.Task<IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserCollectionPage> GetAsync()
{
return this.GetAsync(CancellationToken.None);
}
/// <summary>
/// Issues the GET request.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The task to await for async call.</returns>
public async System.Threading.Tasks.Task<IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserCollectionPage> GetAsync(
CancellationToken cancellationToken)
{
this.Method = "GET";
var response = await this.SendAsync<UnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserCollectionResponse>(null, cancellationToken).ConfigureAwait(false);
if (response != null && response.Value != null && response.Value.CurrentPage != null)
{
if (response.AdditionalData != null)
{
response.Value.AdditionalData = response.AdditionalData;
object nextPageLink;
response.AdditionalData.TryGetValue("@odata.nextLink", out nextPageLink);
var nextPageLinkString = nextPageLink as string;
if (!string.IsNullOrEmpty(nextPageLinkString))
{
response.Value.InitializeNextPageRequest(
this.Client,
nextPageLinkString);
}
}
return response.Value;
}
return null;
}
/// <summary>
/// Adds the specified expand value to the request.
/// </summary>
/// <param name="value">The expand value.</param>
/// <returns>The request object to send.</returns>
public IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest Expand(string value)
{
this.QueryOptions.Add(new QueryOption("$expand", value));
return this;
}
/// <summary>
/// Adds the specified select value to the request.
/// </summary>
/// <param name="value">The select value.</param>
/// <returns>The request object to send.</returns>
public IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest Select(string value)
{
this.QueryOptions.Add(new QueryOption("$select", value));
return this;
}
/// <summary>
/// Adds the specified top value to the request.
/// </summary>
/// <param name="value">The top value.</param>
/// <returns>The request object to send.</returns>
public IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest Top(int value)
{
this.QueryOptions.Add(new QueryOption("$top", value.ToString()));
return this;
}
/// <summary>
/// Adds the specified filter value to the request.
/// </summary>
/// <param name="value">The filter value.</param>
/// <returns>The request object to send.</returns>
public IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest Filter(string value)
{
this.QueryOptions.Add(new QueryOption("$filter", value));
return this;
}
/// <summary>
/// Adds the specified skip value to the request.
/// </summary>
/// <param name="value">The skip value.</param>
/// <returns>The request object to send.</returns>
public IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest Skip(int value)
{
this.QueryOptions.Add(new QueryOption("$skip", value.ToString()));
return this;
}
/// <summary>
/// Adds the specified orderby value to the request.
/// </summary>
/// <param name="value">The orderby value.</param>
/// <returns>The request object to send.</returns>
public IUnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest OrderBy(string value)
{
this.QueryOptions.Add(new QueryOption("$orderby", value));
return this;
}
}
}
| 39.524138 | 171 | 0.595708 | [
"MIT"
] | larslynch/msgraph-beta-sdk-dotnet | src/Microsoft.Graph/Generated/requests/UnifiedRoleAssignmentScheduleInstanceFilterByCurrentUserRequest.cs | 5,731 | C# |
using System;
using WebMoney.Services.Contracts.BasicTypes;
using WebMoney.Services.Contracts.BusinessObjects;
namespace WMBusinessTools.Extensions.BusinessObjects
{
internal sealed class AuthenticationSettings : IAuthenticationSettings
{
private readonly byte[] _keeperKey;
public AuthenticationMethod AuthenticationMethod { get; }
public long Identifier { get; }
public string CertificateThumbprint { get; }
public IRequestNumberSettings RequestNumberSettings => null;
public IConnectionSettings ConnectionSettings { get; set; }
public IProxySettings ProxySettings => null;
public AuthenticationSettings(long identifier, byte[] keeperKey)
{
Identifier = identifier;
_keeperKey = keeperKey ?? throw new ArgumentNullException(nameof(keeperKey));
AuthenticationMethod = AuthenticationMethod.KeeperClassic;
}
public AuthenticationSettings(long identifier, string certificateThumbprint)
{
Identifier = identifier;
CertificateThumbprint = certificateThumbprint ??
throw new ArgumentNullException(nameof(certificateThumbprint));
AuthenticationMethod = AuthenticationMethod.KeeperLight;
}
public byte[] GetKeeperKey()
{
return _keeperKey;
}
}
}
| 36.025641 | 99 | 0.67758 | [
"MIT"
] | MarketKernel/webmoney-business-tools | Src/WMBusinessTools.Extensions/BusinessObjects/AuthenticationSettings.cs | 1,407 | C# |
using System;
using System.Xml;
namespace MvcSitemapBuilder
{
/// <summary>
/// Xml Sitemap builder.
/// Attention: Without support of exceeding 50,000 entries and size of 10 MB.
/// </summary>
public class SitemapBuilder
{
#region fields, constructor
private const string SITEMAP_NAMESPACE = "http://www.sitemaps.org/schemas/sitemap/0.9"; // Protocol: http://www.sitemaps.org/protocol.html
private const string DATETIME_PATTERN = "yyyy-MM-ddTHH:mm:sszzz"; // W3.org (http://www.w3.org/TR/NOTE-datetime) pattern: YYYY-MM-DDThh:mm:ssTZD
private XmlDocument _doc;
/// <summary>
/// Gets Sitemap XmlDocument
/// </summary>
public XmlDocument XmlDocument
{
get { return _doc; }
}
/// <summary>
/// New instance of Sitemap builder
/// </summary>
public SitemapBuilder()
{
_doc = new XmlDocument();
// declaration
XmlDeclaration xmldecl;
xmldecl = _doc.CreateXmlDeclaration("1.0", null, null);
xmldecl.Encoding = "UTF-8";
_doc.AppendChild(xmldecl);
// root document node
_doc.AppendChild(_doc.CreateElement("urlset", SITEMAP_NAMESPACE));
}
#endregion
/// <summary>
/// Append new Url into Sitemap.
/// </summary>
/// <param name="loc">URL of the page.</param>
public void AppendUrl(string loc)
{
_doc.DocumentElement.AppendChild(CreateUrlElement(loc));
}
/// <summary>
/// Append new Url into Sitemap with last modification date.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="lastmod">The date of last modification of the file.</param>
public void AppendUrl(string loc, DateTime lastmod)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreateLastmodElement(lastmod));
_doc.DocumentElement.AppendChild(url_node);
}
/// <summary>
/// Append new Url into Sitemap with refresh rate.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="changefreq">How frequently the page is likely to change.</param>
public void AppendUrl(string loc, ChangefreqEnum changefreq)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreateChangefreqElement(changefreq));
_doc.DocumentElement.AppendChild(url_node);
}
/// <summary>
/// Append new Url into Sitemap with priority.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="priority">The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.</param>
public void AppendUrl(string loc, double priority)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreatePriorityElement(priority));
_doc.DocumentElement.AppendChild(url_node);
}
/// <summary>
/// Append new Url into Sitemap with last modification date and refresh rate.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="lastmod">The date of last modification of the file.</param>
/// <param name="changefreq">How frequently the page is likely to change.</param>
public void AppendUrl(string loc, DateTime lastmod, ChangefreqEnum changefreq)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreateLastmodElement(lastmod));
url_node.AppendChild(CreateChangefreqElement(changefreq));
_doc.DocumentElement.AppendChild(url_node);
}
/// <summary>
/// Append new Url into Sitemap with last modification date and priority.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="lastmod">The date of last modification of the file.</param>
/// <param name="priority">The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.</param>
public void AppendUrl(string loc, DateTime lastmod, double priority)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreateLastmodElement(lastmod));
url_node.AppendChild(CreatePriorityElement(priority));
_doc.DocumentElement.AppendChild(url_node);
}
/// <summary>
/// Append new Url into Sitemap with refresh rate and priority.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="changefreq">How frequently the page is likely to change.</param>
/// <param name="priority">The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.</param>
public void AppendUrl(string loc, ChangefreqEnum changefreq, double priority)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreateChangefreqElement(changefreq));
url_node.AppendChild(CreatePriorityElement(priority));
_doc.DocumentElement.AppendChild(url_node);
}
/// <summary>
/// Append new Url into Sitemap with refresh rate, priority and last modification date.
/// </summary>
/// <param name="loc">URL of the page.</param>
/// <param name="changefreq">How frequently the page is likely to change.</param>
/// <param name="priority">The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.</param>
/// <param name="lastmod">The date of last modification of the file.</param>
public void AppendUrl(string loc, ChangefreqEnum changefreq, double priority, DateTime lastmod)
{
XmlElement url_node = CreateUrlElement(loc);
url_node.AppendChild(CreateChangefreqElement(changefreq));
url_node.AppendChild(CreatePriorityElement(priority));
url_node.AppendChild(CreateLastmodElement(lastmod));
_doc.DocumentElement.AppendChild(url_node);
}
#region helpers
private XmlElement CreateUrlElement(string loc)
{
XmlElement url_node = _doc.CreateElement("url", SITEMAP_NAMESPACE);
XmlElement loc_node = _doc.CreateElement("loc", SITEMAP_NAMESPACE);
loc_node.InnerText = loc;
url_node.AppendChild(loc_node);
return url_node;
}
private XmlElement CreateLastmodElement(DateTime lastmod)
{
XmlElement lastmod_node = _doc.CreateElement("lastmod", SITEMAP_NAMESPACE);
lastmod_node.InnerText = lastmod.ToString(DATETIME_PATTERN);
return lastmod_node;
}
private XmlElement CreateChangefreqElement(ChangefreqEnum changefreq)
{
XmlElement changefreq_node = _doc.CreateElement("changefreq", SITEMAP_NAMESPACE);
changefreq_node.InnerText = changefreq.ToString();
return changefreq_node;
}
private XmlElement CreatePriorityElement(double priority)
{
XmlElement changefreq_node = _doc.CreateElement("priority", SITEMAP_NAMESPACE);
changefreq_node.InnerText = priority.ToString(System.Globalization.CultureInfo.InvariantCulture);
return changefreq_node;
}
#endregion
}
} | 40.104167 | 174 | 0.621299 | [
"MIT"
] | Verhov/MvcSitemapBuilder | sources/SitemapBuilder.cs | 7,702 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Azure.Messaging.EventGrid.SystemEvents
{
public partial class MachineLearningServicesModelDeployedEventData
{
internal static MachineLearningServicesModelDeployedEventData DeserializeMachineLearningServicesModelDeployedEventData(JsonElement element)
{
Optional<string> serviceName = default;
Optional<string> serviceComputeType = default;
Optional<string> modelIds = default;
Optional<object> serviceTags = default;
Optional<object> serviceProperties = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("serviceName"))
{
serviceName = property.Value.GetString();
continue;
}
if (property.NameEquals("serviceComputeType"))
{
serviceComputeType = property.Value.GetString();
continue;
}
if (property.NameEquals("modelIds"))
{
modelIds = property.Value.GetString();
continue;
}
if (property.NameEquals("serviceTags"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
serviceTags = property.Value.GetObject();
continue;
}
if (property.NameEquals("serviceProperties"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
serviceProperties = property.Value.GetObject();
continue;
}
}
return new MachineLearningServicesModelDeployedEventData(serviceName.Value, serviceComputeType.Value, modelIds.Value, serviceTags.Value, serviceProperties.Value);
}
}
}
| 37.4375 | 174 | 0.535893 | [
"MIT"
] | 0rland0Wats0n/azure-sdk-for-net | sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/MachineLearningServicesModelDeployedEventData.Serialization.cs | 2,396 | C# |
using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using Aop.Api.Domain;
namespace Aop.Api.Response
{
/// <summary>
/// AlipayFundAccountBillQueryResponse.
/// </summary>
public class AlipayFundAccountBillQueryResponse : AopResponse
{
/// <summary>
/// 账单详情
/// </summary>
[XmlArray("acc_detail_list")]
[XmlArrayItem("trusteeship_account_bill_query_response")]
public List<TrusteeshipAccountBillQueryResponse> AccDetailList { get; set; }
/// <summary>
/// 结果页数
/// </summary>
[XmlElement("page_num")]
public string PageNum { get; set; }
/// <summary>
/// 结果页大小
/// </summary>
[XmlElement("page_size")]
public string PageSize { get; set; }
/// <summary>
/// 每页元素数
/// </summary>
[XmlElement("total_item_count")]
public string TotalItemCount { get; set; }
}
}
| 26.179487 | 85 | 0.557297 | [
"Apache-2.0"
] | 554393109/alipay-sdk-net-all | AlipaySDKNet.Standard/Response/AlipayFundAccountBillQueryResponse.cs | 1,057 | 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.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void FusedAddHalving_Vector64_UInt32()
{
var test = new SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates basic functionality works, using Load
test.RunBasicScenario_Load();
}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates calling via reflection works, using Load
test.RunReflectionScenario_Load();
}
// Validates passing a static member works
test.RunClsVarScenario();
if (AdvSimd.IsSupported)
{
// Validates passing a static member works, using pinning and Load
test.RunClsVarScenario_Load();
}
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates passing a local works, using Load
test.RunLclVarScenario_Load();
}
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local class works, using pinning and Load
test.RunClassLclFldScenario_Load();
}
// Validates passing an instance member of a class works
test.RunClassFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a class works, using pinning and Load
test.RunClassFldScenario_Load();
}
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local struct works, using pinning and Load
test.RunStructLclFldScenario_Load();
}
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a struct works, using pinning and Load
test.RunStructFldScenario_Load();
}
}
else
{
// Validates we throw on unsupported hardware
test.RunUnsupportedScenario();
}
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle inHandle2;
private GCHandle outHandle;
private ulong alignment;
public DataTable(UInt32[] inArray1, UInt32[] inArray2, UInt32[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt32>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.inArray2 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt32, byte>(ref inArray2[0]), (uint)sizeOfinArray2);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector64<UInt32> _fld1;
public Vector64<UInt32> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32 testClass)
{
var result = AdvSimd.FusedAddHalving(_fld1, _fld2);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32 testClass)
{
fixed (Vector64<UInt32>* pFld1 = &_fld1)
fixed (Vector64<UInt32>* pFld2 = &_fld2)
{
var result = AdvSimd.FusedAddHalving(
AdvSimd.LoadVector64((UInt32*)(pFld1)),
AdvSimd.LoadVector64((UInt32*)(pFld2))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 8;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<UInt32>>() / sizeof(UInt32);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<UInt32>>() / sizeof(UInt32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt32>>() / sizeof(UInt32);
private static UInt32[] _data1 = new UInt32[Op1ElementCount];
private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector64<UInt32> _clsVar1;
private static Vector64<UInt32> _clsVar2;
private Vector64<UInt32> _fld1;
private Vector64<UInt32> _fld2;
private DataTable _dataTable;
static SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
}
public SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); }
_dataTable = new DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = AdvSimd.FusedAddHalving(
Unsafe.Read<Vector64<UInt32>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<UInt32>>(_dataTable.inArray2Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.FusedAddHalving(
AdvSimd.LoadVector64((UInt32*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((UInt32*)(_dataTable.inArray2Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.FusedAddHalving), new Type[] { typeof(Vector64<UInt32>), typeof(Vector64<UInt32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector64<UInt32>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<UInt32>>(_dataTable.inArray2Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt32>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.FusedAddHalving), new Type[] { typeof(Vector64<UInt32>), typeof(Vector64<UInt32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector64((UInt32*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((UInt32*)(_dataTable.inArray2Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt32>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.FusedAddHalving(
_clsVar1,
_clsVar2
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector64<UInt32>* pClsVar1 = &_clsVar1)
fixed (Vector64<UInt32>* pClsVar2 = &_clsVar2)
{
var result = AdvSimd.FusedAddHalving(
AdvSimd.LoadVector64((UInt32*)(pClsVar1)),
AdvSimd.LoadVector64((UInt32*)(pClsVar2))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector64<UInt32>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector64<UInt32>>(_dataTable.inArray2Ptr);
var result = AdvSimd.FusedAddHalving(op1, op2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector64((UInt32*)(_dataTable.inArray1Ptr));
var op2 = AdvSimd.LoadVector64((UInt32*)(_dataTable.inArray2Ptr));
var result = AdvSimd.FusedAddHalving(op1, op2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32();
var result = AdvSimd.FusedAddHalving(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleBinaryOpTest__FusedAddHalving_Vector64_UInt32();
fixed (Vector64<UInt32>* pFld1 = &test._fld1)
fixed (Vector64<UInt32>* pFld2 = &test._fld2)
{
var result = AdvSimd.FusedAddHalving(
AdvSimd.LoadVector64((UInt32*)(pFld1)),
AdvSimd.LoadVector64((UInt32*)(pFld2))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.FusedAddHalving(_fld1, _fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector64<UInt32>* pFld1 = &_fld1)
fixed (Vector64<UInt32>* pFld2 = &_fld2)
{
var result = AdvSimd.FusedAddHalving(
AdvSimd.LoadVector64((UInt32*)(pFld1)),
AdvSimd.LoadVector64((UInt32*)(pFld2))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.FusedAddHalving(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.FusedAddHalving(
AdvSimd.LoadVector64((UInt32*)(&test._fld1)),
AdvSimd.LoadVector64((UInt32*)(&test._fld2))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector64<UInt32> op1, Vector64<UInt32> op2, void* result, [CallerMemberName] string method = "")
{
UInt32[] inArray1 = new UInt32[Op1ElementCount];
UInt32[] inArray2 = new UInt32[Op2ElementCount];
UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), op2);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "")
{
UInt32[] inArray1 = new UInt32[Op1ElementCount];
UInt32[] inArray2 = new UInt32[Op2ElementCount];
UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt32>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.FusedAddHalving(left[i], right[i]) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.FusedAddHalving)}<UInt32>(Vector64<UInt32>, Vector64<UInt32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})");
TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| 42.419962 | 188 | 0.588235 | [
"MIT"
] | 06needhamt/runtime | src/coreclr/tests/src/JIT/HardwareIntrinsics/Arm/AdvSimd/FusedAddHalving.Vector64.UInt32.cs | 22,525 | C# |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// Generation date: 10/4/2020 2:55:10 PM
namespace Microsoft.Dynamics.DataEntities
{
/// <summary>
/// There are no comments for RetailCatalogProductSingle in the schema.
/// </summary>
public partial class RetailCatalogProductSingle : global::Microsoft.OData.Client.DataServiceQuerySingle<RetailCatalogProduct>
{
/// <summary>
/// Initialize a new RetailCatalogProductSingle object.
/// </summary>
public RetailCatalogProductSingle(global::Microsoft.OData.Client.DataServiceContext context, string path)
: base(context, path) {}
/// <summary>
/// Initialize a new RetailCatalogProductSingle object.
/// </summary>
public RetailCatalogProductSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable)
: base(context, path, isComposable) {}
/// <summary>
/// Initialize a new RetailCatalogProductSingle object.
/// </summary>
public RetailCatalogProductSingle(global::Microsoft.OData.Client.DataServiceQuerySingle<RetailCatalogProduct> query)
: base(query) {}
/// <summary>
/// There are no comments for RetailCatalog in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.Dynamics.DataEntities.RetailCatalogSingle RetailCatalog
{
get
{
if (!this.IsComposable)
{
throw new global::System.NotSupportedException("The previous function is not composable.");
}
if ((this._RetailCatalog == null))
{
this._RetailCatalog = new global::Microsoft.Dynamics.DataEntities.RetailCatalogSingle(this.Context, GetPath("RetailCatalog"));
}
return this._RetailCatalog;
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.Dynamics.DataEntities.RetailCatalogSingle _RetailCatalog;
/// <summary>
/// There are no comments for RetailCatalogProductAttributeValue in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.Dynamics.DataEntities.RetailCatalogProductAttributeValueSingle RetailCatalogProductAttributeValue
{
get
{
if (!this.IsComposable)
{
throw new global::System.NotSupportedException("The previous function is not composable.");
}
if ((this._RetailCatalogProductAttributeValue == null))
{
this._RetailCatalogProductAttributeValue = new global::Microsoft.Dynamics.DataEntities.RetailCatalogProductAttributeValueSingle(this.Context, GetPath("RetailCatalogProductAttributeValue"));
}
return this._RetailCatalogProductAttributeValue;
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.Dynamics.DataEntities.RetailCatalogProductAttributeValueSingle _RetailCatalogProductAttributeValue;
/// <summary>
/// There are no comments for RetailCatalogInternalOrganizationProductAttributeValue2 in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.OData.Client.DataServiceQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2> RetailCatalogInternalOrganizationProductAttributeValue2
{
get
{
if (!this.IsComposable)
{
throw new global::System.NotSupportedException("The previous function is not composable.");
}
if ((this._RetailCatalogInternalOrganizationProductAttributeValue2 == null))
{
this._RetailCatalogInternalOrganizationProductAttributeValue2 = Context.CreateQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2>(GetPath("RetailCatalogInternalOrganizationProductAttributeValue2"));
}
return this._RetailCatalogInternalOrganizationProductAttributeValue2;
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.OData.Client.DataServiceQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2> _RetailCatalogInternalOrganizationProductAttributeValue2;
/// <summary>
/// There are no comments for RetailCatalogProductCategory in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.OData.Client.DataServiceQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory> RetailCatalogProductCategory
{
get
{
if (!this.IsComposable)
{
throw new global::System.NotSupportedException("The previous function is not composable.");
}
if ((this._RetailCatalogProductCategory == null))
{
this._RetailCatalogProductCategory = Context.CreateQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory>(GetPath("RetailCatalogProductCategory"));
}
return this._RetailCatalogProductCategory;
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.OData.Client.DataServiceQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory> _RetailCatalogProductCategory;
/// <summary>
/// There are no comments for RetailCatalogInternalOrganizationProductAttributeValue in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.OData.Client.DataServiceQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue> RetailCatalogInternalOrganizationProductAttributeValue
{
get
{
if (!this.IsComposable)
{
throw new global::System.NotSupportedException("The previous function is not composable.");
}
if ((this._RetailCatalogInternalOrganizationProductAttributeValue == null))
{
this._RetailCatalogInternalOrganizationProductAttributeValue = Context.CreateQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue>(GetPath("RetailCatalogInternalOrganizationProductAttributeValue"));
}
return this._RetailCatalogInternalOrganizationProductAttributeValue;
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.OData.Client.DataServiceQuery<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue> _RetailCatalogInternalOrganizationProductAttributeValue;
}
/// <summary>
/// There are no comments for RetailCatalogProduct in the schema.
/// </summary>
/// <KeyProperties>
/// CatalogNumber
/// DisplayProductNumber
/// </KeyProperties>
[global::Microsoft.OData.Client.Key("CatalogNumber", "DisplayProductNumber")]
[global::Microsoft.OData.Client.EntitySet("RetailCatalogProducts")]
public partial class RetailCatalogProduct : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged
{
/// <summary>
/// Create a new RetailCatalogProduct object.
/// </summary>
/// <param name="catalogNumber">Initial value of CatalogNumber.</param>
/// <param name="displayProductNumber">Initial value of DisplayProductNumber.</param>
/// <param name="displayOrder">Initial value of DisplayOrder.</param>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public static RetailCatalogProduct CreateRetailCatalogProduct(string catalogNumber, string displayProductNumber, decimal displayOrder)
{
RetailCatalogProduct retailCatalogProduct = new RetailCatalogProduct();
retailCatalogProduct.CatalogNumber = catalogNumber;
retailCatalogProduct.DisplayProductNumber = displayProductNumber;
retailCatalogProduct.DisplayOrder = displayOrder;
return retailCatalogProduct;
}
/// <summary>
/// There are no comments for Property CatalogNumber in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual string CatalogNumber
{
get
{
return this._CatalogNumber;
}
set
{
this.OnCatalogNumberChanging(value);
this._CatalogNumber = value;
this.OnCatalogNumberChanged();
this.OnPropertyChanged("CatalogNumber");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private string _CatalogNumber;
partial void OnCatalogNumberChanging(string value);
partial void OnCatalogNumberChanged();
/// <summary>
/// There are no comments for Property DisplayProductNumber in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual string DisplayProductNumber
{
get
{
return this._DisplayProductNumber;
}
set
{
this.OnDisplayProductNumberChanging(value);
this._DisplayProductNumber = value;
this.OnDisplayProductNumberChanged();
this.OnPropertyChanged("DisplayProductNumber");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private string _DisplayProductNumber;
partial void OnDisplayProductNumberChanging(string value);
partial void OnDisplayProductNumberChanged();
/// <summary>
/// There are no comments for Property DisplayOrder in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual decimal DisplayOrder
{
get
{
return this._DisplayOrder;
}
set
{
this.OnDisplayOrderChanging(value);
this._DisplayOrder = value;
this.OnDisplayOrderChanged();
this.OnPropertyChanged("DisplayOrder");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private decimal _DisplayOrder;
partial void OnDisplayOrderChanging(decimal value);
partial void OnDisplayOrderChanged();
/// <summary>
/// There are no comments for Property UseHierarchy in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::System.Nullable<global::Microsoft.Dynamics.DataEntities.NoYes> UseHierarchy
{
get
{
return this._UseHierarchy;
}
set
{
this.OnUseHierarchyChanging(value);
this._UseHierarchy = value;
this.OnUseHierarchyChanged();
this.OnPropertyChanged("UseHierarchy");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::System.Nullable<global::Microsoft.Dynamics.DataEntities.NoYes> _UseHierarchy;
partial void OnUseHierarchyChanging(global::System.Nullable<global::Microsoft.Dynamics.DataEntities.NoYes> value);
partial void OnUseHierarchyChanged();
/// <summary>
/// There are no comments for Property RetailCatalog in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.Dynamics.DataEntities.RetailCatalog RetailCatalog
{
get
{
return this._RetailCatalog;
}
set
{
this.OnRetailCatalogChanging(value);
this._RetailCatalog = value;
this.OnRetailCatalogChanged();
this.OnPropertyChanged("RetailCatalog");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.Dynamics.DataEntities.RetailCatalog _RetailCatalog;
partial void OnRetailCatalogChanging(global::Microsoft.Dynamics.DataEntities.RetailCatalog value);
partial void OnRetailCatalogChanged();
/// <summary>
/// There are no comments for Property RetailCatalogProductAttributeValue in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.Dynamics.DataEntities.RetailCatalogProductAttributeValue RetailCatalogProductAttributeValue
{
get
{
return this._RetailCatalogProductAttributeValue;
}
set
{
this.OnRetailCatalogProductAttributeValueChanging(value);
this._RetailCatalogProductAttributeValue = value;
this.OnRetailCatalogProductAttributeValueChanged();
this.OnPropertyChanged("RetailCatalogProductAttributeValue");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.Dynamics.DataEntities.RetailCatalogProductAttributeValue _RetailCatalogProductAttributeValue;
partial void OnRetailCatalogProductAttributeValueChanging(global::Microsoft.Dynamics.DataEntities.RetailCatalogProductAttributeValue value);
partial void OnRetailCatalogProductAttributeValueChanged();
/// <summary>
/// There are no comments for Property RetailCatalogInternalOrganizationProductAttributeValue2 in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2> RetailCatalogInternalOrganizationProductAttributeValue2
{
get
{
return this._RetailCatalogInternalOrganizationProductAttributeValue2;
}
set
{
this.OnRetailCatalogInternalOrganizationProductAttributeValue2Changing(value);
this._RetailCatalogInternalOrganizationProductAttributeValue2 = value;
this.OnRetailCatalogInternalOrganizationProductAttributeValue2Changed();
this.OnPropertyChanged("RetailCatalogInternalOrganizationProductAttributeValue2");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2> _RetailCatalogInternalOrganizationProductAttributeValue2 = new global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2>(null, global::Microsoft.OData.Client.TrackingMode.None);
partial void OnRetailCatalogInternalOrganizationProductAttributeValue2Changing(global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue2> value);
partial void OnRetailCatalogInternalOrganizationProductAttributeValue2Changed();
/// <summary>
/// There are no comments for Property RetailCatalogProductCategory in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory> RetailCatalogProductCategory
{
get
{
return this._RetailCatalogProductCategory;
}
set
{
this.OnRetailCatalogProductCategoryChanging(value);
this._RetailCatalogProductCategory = value;
this.OnRetailCatalogProductCategoryChanged();
this.OnPropertyChanged("RetailCatalogProductCategory");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory> _RetailCatalogProductCategory = new global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory>(null, global::Microsoft.OData.Client.TrackingMode.None);
partial void OnRetailCatalogProductCategoryChanging(global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogProductCategory> value);
partial void OnRetailCatalogProductCategoryChanged();
/// <summary>
/// There are no comments for Property RetailCatalogInternalOrganizationProductAttributeValue in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public virtual global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue> RetailCatalogInternalOrganizationProductAttributeValue
{
get
{
return this._RetailCatalogInternalOrganizationProductAttributeValue;
}
set
{
this.OnRetailCatalogInternalOrganizationProductAttributeValueChanging(value);
this._RetailCatalogInternalOrganizationProductAttributeValue = value;
this.OnRetailCatalogInternalOrganizationProductAttributeValueChanged();
this.OnPropertyChanged("RetailCatalogInternalOrganizationProductAttributeValue");
}
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
private global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue> _RetailCatalogInternalOrganizationProductAttributeValue = new global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue>(null, global::Microsoft.OData.Client.TrackingMode.None);
partial void OnRetailCatalogInternalOrganizationProductAttributeValueChanging(global::Microsoft.OData.Client.DataServiceCollection<global::Microsoft.Dynamics.DataEntities.RetailCatalogInternalOrganizationProductAttributeValue> value);
partial void OnRetailCatalogInternalOrganizationProductAttributeValueChanged();
/// <summary>
/// This event is raised when the value of the property is changed
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// The value of the property is changed
/// </summary>
/// <param name="property">property name</param>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
protected virtual void OnPropertyChanged(string property)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property));
}
}
}
}
| 58.176166 | 435 | 0.680264 | [
"MIT"
] | NathanClouseAX/AAXDataEntityPerfTest | Projects/AAXDataEntityPerfTest/ConsoleApp1/Connected Services/D365/RetailCatalogProduct.cs | 22,458 | 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
*
* https://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.Globalization;
using System.IO;
using Avro.IO;
using Avro.Generic;
namespace Avro.File
{
public class DataFileWriter<T> : IFileWriter<T>
{
private Schema _schema;
private Codec _codec;
private Stream _stream;
private MemoryStream _blockStream;
private Encoder _encoder, _blockEncoder;
private DatumWriter<T> _writer;
private byte[] _syncData;
private bool _isOpen;
private bool _headerWritten;
private int _blockCount;
private int _syncInterval;
private IDictionary<string, byte[]> _metaData;
/// <summary>
/// Open a new writer instance to write
/// to a file path, using a Null codec
/// </summary>
/// <param name="writer"></param>
/// <param name="path"></param>
/// <returns></returns>
public static IFileWriter<T> OpenWriter(DatumWriter<T> writer, string path)
{
return OpenWriter(writer, new FileStream(path, FileMode.Create), Codec.CreateCodec(Codec.Type.Null));
}
/// <summary>
/// Open a new writer instance to write
/// to an output stream, using a Null codec
/// </summary>
/// <param name="writer"></param>
/// <param name="outStream"></param>
/// <returns></returns>
public static IFileWriter<T> OpenWriter(DatumWriter<T> writer, Stream outStream)
{
return OpenWriter(writer, outStream, Codec.CreateCodec(Codec.Type.Null));
}
/// <summary>
/// Open a new writer instance to write
/// to a file path with a specified codec
/// </summary>
/// <param name="writer"></param>
/// <param name="path"></param>
/// <param name="codec"></param>
/// <returns></returns>
public static IFileWriter<T> OpenWriter(DatumWriter<T> writer, string path, Codec codec)
{
return OpenWriter(writer, new FileStream(path, FileMode.Create), codec);
}
/// <summary>
/// Open a new writer instance to write
/// to an output stream with a specified codec
/// </summary>
/// <param name="writer"></param>
/// <param name="outStream"></param>
/// <param name="codec"></param>
/// <returns></returns>
public static IFileWriter<T> OpenWriter(DatumWriter<T> writer, Stream outStream, Codec codec)
{
return new DataFileWriter<T>(writer).Create(writer.Schema, outStream, codec);
}
DataFileWriter(DatumWriter<T> writer)
{
_writer = writer;
_syncInterval = DataFileConstants.DefaultSyncInterval;
}
public bool IsReservedMeta(string key)
{
return key.StartsWith(DataFileConstants.MetaDataReserved);
}
public void SetMeta(String key, byte[] value)
{
if (IsReservedMeta(key))
{
throw new AvroRuntimeException("Cannot set reserved meta key: " + key);
}
_metaData.Add(key, value);
}
public void SetMeta(String key, long value)
{
try
{
SetMeta(key, GetByteValue(value.ToString(CultureInfo.InvariantCulture)));
}
catch (Exception e)
{
throw new AvroRuntimeException(e.Message, e);
}
}
public void SetMeta(String key, string value)
{
try
{
SetMeta(key, GetByteValue(value));
}
catch (Exception e)
{
throw new AvroRuntimeException(e.Message, e);
}
}
public void SetSyncInterval(int syncInterval)
{
if (syncInterval < 32 || syncInterval > (1 << 30))
{
throw new AvroRuntimeException("Invalid sync interval value: " + syncInterval);
}
_syncInterval = syncInterval;
}
public void Append(T datum)
{
AssertOpen();
EnsureHeader();
long usedBuffer = _blockStream.Position;
try
{
_writer.Write(datum, _blockEncoder);
}
catch (Exception e)
{
_blockStream.Position = usedBuffer;
throw new AvroRuntimeException("Error appending datum to writer", e);
}
_blockCount++;
WriteIfBlockFull();
}
private void EnsureHeader()
{
if (!_headerWritten)
{
WriteHeader();
_headerWritten = true;
}
}
public void Flush()
{
EnsureHeader();
Sync();
}
public long Sync()
{
AssertOpen();
WriteBlock();
return _stream.Position;
}
public void Close()
{
EnsureHeader();
Flush();
_stream.Flush();
_stream.Close();
_isOpen = false;
}
private void WriteHeader()
{
_encoder.WriteFixed(DataFileConstants.Magic);
WriteMetaData();
WriteSyncData();
}
private void Init()
{
_blockCount = 0;
_encoder = new BinaryEncoder(_stream);
_blockStream = new MemoryStream();
_blockEncoder = new BinaryEncoder(_blockStream);
if (_codec == null)
_codec = Codec.CreateCodec(Codec.Type.Null);
_isOpen = true;
}
private void AssertOpen()
{
if (!_isOpen) throw new AvroRuntimeException("Cannot complete operation: avro file/stream not open");
}
private IFileWriter<T> Create(Schema schema, Stream outStream, Codec codec)
{
_codec = codec;
_stream = outStream;
_metaData = new Dictionary<string, byte[]>();
_schema = schema;
Init();
return this;
}
private void WriteMetaData()
{
// Add sync, code & schema to metadata
GenerateSyncData();
//SetMetaInternal(DataFileConstants.MetaDataSync, _syncData); - Avro 1.5.4 C
SetMetaInternal(DataFileConstants.MetaDataCodec, GetByteValue(_codec.GetName()));
SetMetaInternal(DataFileConstants.MetaDataSchema, GetByteValue(_schema.ToString()));
// write metadata
int size = _metaData.Count;
_encoder.WriteInt(size);
foreach (KeyValuePair<String, byte[]> metaPair in _metaData)
{
_encoder.WriteString(metaPair.Key);
_encoder.WriteBytes(metaPair.Value);
}
_encoder.WriteMapEnd();
}
private void WriteIfBlockFull()
{
if (BufferInUse() >= _syncInterval)
WriteBlock();
}
private long BufferInUse()
{
return _blockStream.Position;
}
private void WriteBlock()
{
if (_blockCount > 0)
{
byte[] dataToWrite = _blockStream.ToArray();
// write count
_encoder.WriteLong(_blockCount);
// write data
_encoder.WriteBytes(_codec.Compress(dataToWrite));
// write sync marker
_encoder.WriteFixed(_syncData);
// reset / re-init block
_blockCount = 0;
_blockStream = new MemoryStream();
_blockEncoder = new BinaryEncoder(_blockStream);
}
}
private void WriteSyncData()
{
_encoder.WriteFixed(_syncData);
}
private void GenerateSyncData()
{
_syncData = new byte[16];
Random random = new Random();
random.NextBytes(_syncData);
}
private void SetMetaInternal(string key, byte[] value)
{
_metaData.Add(key, value);
}
private byte[] GetByteValue(string value)
{
return System.Text.Encoding.UTF8.GetBytes(value);
}
public void Dispose()
{
Close();
}
}
}
| 29.46519 | 113 | 0.540866 | [
"Apache-2.0"
] | busbey/avro | lang/csharp/src/apache/main/File/DataFileWriter.cs | 9,313 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
static void Main()
{
double balance = double.Parse(Console.ReadLine());
string command = Console.ReadLine();
double price = 0;
double totalPrice = 0;
bool ranOutOfMoney = false;
while (command != "Game Time")
{
bool notFound = false;
switch (command)
{
case "OutFall 4":
price = 39.99;
break;
case "CS: OG":
price = 15.99;
break;
case "Zplinter Zell":
price = 19.99;
break;
case "Honored 2":
price = 59.99;
break;
case "RoverWatch":
price = 29.99;
break;
case "RoverWatch Origins Edition":
price = 39.99;
break;
default:
Console.WriteLine("Not Found");
notFound = true;
break;
}
if (!notFound)
{
if (balance < price)
{
Console.WriteLine("Too Expensive");
}
else
{
balance -= price;
Console.WriteLine($"Bought {command}");
if (balance <= 0)
{
Console.WriteLine("Out of money!");
ranOutOfMoney = true;
break;
}
totalPrice += price;
}
}
command = Console.ReadLine();
}
if (!ranOutOfMoney)
{
Console.WriteLine($"Total spent: ${totalPrice:0.00}. Remaining: ${balance:0.00}");
}
}
}
| 26.576923 | 94 | 0.374337 | [
"MIT"
] | radoslavvv/Programming-Fundamentals-Extended-May-2017 | Exercises/03.CSharpBasicSyntaxMoreExercises/02.VaporStore/02.VaporStore.cs | 2,075 | C# |
using GaliciaSeguros.IaaS.Service.Chassis.Storage.EF.Implementation;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GaliciaSeguros.IaaS.Service.Chassis.Storage.EF.Contracts
{
public class BaseRepository<TEntity, TContext> : IRepository<TEntity>
where TEntity : class
where TContext : DbContext
{
protected readonly TContext _dbContext;
protected readonly DbSet<TEntity> _dbSet;
public BaseRepository(TContext context)
{
_dbContext = context;
_dbSet = _dbContext.Set<TEntity>();
}
public void Add(TEntity item)
{
_dbContext.Set<TEntity>().Add(item);
}
public void Delete(TEntity item)
{
_dbSet.Remove(item);
}
public IEnumerable<TEntity> GetAll()
{
return _dbContext.Set<TEntity>().Where(t => true);
}
public void Update(TEntity item)
{
_dbContext.Set<TEntity>().Attach(item);
_dbContext.Entry(item).State = EntityState.Modified;
}
}
}
| 26.777778 | 73 | 0.624066 | [
"MIT"
] | lighuenlacamoire/NetCoreSvcChassis | src/GaliciaSeguros.IaaS.Service.Chassis.Storage.EF/Contracts/BaseRepository.cs | 1,207 | C# |
namespace Fortnox.SDK.Search
{
public class SupplierInvoiceAccrualSearch : BaseSearch
{
[SearchParameter("sortby")]
public Sort.By.SupplierInvoiceAccrual? SortBy { get; set; }
[SearchParameter("filter")]
public Filter.SupplierInvoiceAccrual? FilterBy { get; set; }
}
}
| 20.857143 | 62 | 0.719178 | [
"Unlicense",
"MIT"
] | LukasLonnroth/csharp-api-sdk | FortnoxSDK/Search/SupplierInvoiceAccrualSearch.cs | 292 | C# |
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class SkinShadingLookupTexture : MonoBehaviour
{
//public float intensity = 1.0f;
public float topLayerStrength = 0.3333f;
public float epiLayerStrength = 0.3333f;
public float subLayerStrength = 0.3333f;
public float sssssBlurDistance = 1.5f;
public float epiRelative = 0.3f;
public bool fadeWithDistance = true;
public bool isEyes = false;
//public float diffuseIntensity = 0.8f;
public Color keyColor = ColorRGB (150, 150, 150);
public Color epiColor = ColorRGB (148, 175, 175);
public Color scatterColor = ColorRGB (179, 148, 148);
public float saturation = 1.0f;
public float reflectivityAt0 = 0.075f;
public float reflectivityAt90 = 0.55f;
public float reflectivityFalloff = 3.5f;
public float specularIntensity = 1.0f;
public float specularShininess = 0.7f;
public float specularIntensity2 = 1.0f;
public float specularShininess2 = 0.4f;
public int lookupTextureWidth = 32;
public int lookupTextureHeight = 256;
public Texture2D lookupTexture;
private Material[] _skinFallbackMaterials = null;
private Material[] _skin1stPassMaterials = null;
private Material[] _skin2ndPassMaterials = null;
public Material[] skinFallbackMaterials { get { return _skinFallbackMaterials; } }
public Material[] skin1stPassMaterials { get { return _skin1stPassMaterials; } }
public Material[] skin2ndPassMaterials { get { return _skin2ndPassMaterials; } }
private Material[] _skinKeywordMaterials = null;
public Material[] skinKeywordMaterials { get { return _skinKeywordMaterials; } }
static public ArrayList allSkinShadingComponents = new ArrayList();
void OnEnable ()
{
allSkinShadingComponents.Add (this);
}
void OnDisable ()
{
allSkinShadingComponents.Remove (this);
}
void Awake ()
{
parametersAreDirty = true;
if (!lookupTexture)
Bake ();
}
public void SetupMaterials(CameraSkinScattering c)
{
if (Application.isPlaying && GetComponent<Renderer>() && _skin1stPassMaterials == null)
{
var count = GetComponent<Renderer>().sharedMaterials.Length;
_skin1stPassMaterials = new Material[count];
_skin2ndPassMaterials = new Material[count];
_skinFallbackMaterials = new Material[count];
_skinKeywordMaterials = new Material[count];
for (int q = 0; q < count; ++q)
{
_skin2ndPassMaterials[q] = GetComponent<Renderer>().sharedMaterials[q];
SetParameters(_skin2ndPassMaterials[q]);
}
for (int q = 0; q < count; ++q)
_skin1stPassMaterials[q] = c.Create1stPassMaterial(_skin2ndPassMaterials[q], isEyes);
for (int q = 0; q < count; ++q)
_skinFallbackMaterials[q] = c.CreateFallbackMaterial(_skin2ndPassMaterials[q]);
for (int q = 0; q < count; ++q)
_skinKeywordMaterials[q] = c.CreateKeywordMaterial(_skin2ndPassMaterials[q]);
}
}
#if UNITY_EDITOR
// Necessary to process Scene/Preview cameras in Editor
void OnWillRenderObject ()
{
CameraSkinScattering sssCamera = GameObject.FindObjectOfType (typeof(CameraSkinScattering)) as CameraSkinScattering;
if (sssCamera)
sssCamera.EditorCameraOnPreRender (Camera.current);
}
#endif
static Color ColorRGB (int r, int g, int b) {
return new Color ((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 0.0f);
}
public float GetDistanceFade(Camera c)
{
if(!fadeWithDistance)
return 1.0f;
return 1.0f/(1.0f + Mathf.Max(0.0f, c.WorldToViewportPoint(GetComponent<Renderer>().bounds.center).z));
}
void CheckConsistency () {
specularIntensity = Mathf.Max (0.0f, specularIntensity);
specularShininess = Mathf.Clamp (specularShininess, 0.01f, 1.0f);
specularIntensity2 = Mathf.Max (0.0f, specularIntensity2);
specularShininess2 = Mathf.Clamp (specularShininess2, 0.01f, 1.0f);
}
float PHBeckmann(float ndoth, float m)
{
//ndoth*=4.0f;
//if(ndoth>1.0f)ndoth=1.0f;
float roughness = m;
float mSq = roughness * roughness;
// though original Beckmann doesn't have division by 4
// in Engel's book and other implementations on the web have it
// it makes specular look right as well, so what do I know?
float a = 1.0f / (4.0f * mSq * Mathf.Pow (ndoth, 4.0f) + 1e-5f);
float b = ndoth * ndoth - 1.0f;
float c = mSq * ndoth * ndoth + 1e-5f;
float r = a * Mathf.Exp (b / c);
return r;
/*
float mSq = roughness * roughness;
// though original Beckmann doesn't have division by 4
// in Engel's book and other implementations on the web have it
// it makes specular look right as well, so what do I know?
float a = 1.0 / (4.0 * mSq * pow (NdotH, 4.0) + 1e-5f);
float b = NdotH * NdotH - 1.0f;
float c = mSq * NdotH * NdotH + 1e-5f;
return a * pow (3, b / c);
*/
}
Color PixelFunc (float ndotv, float ndoth)
{
/*
float ndoth = ndotl2*2.0f;
if(ndoth>1.0f) ndoth = ndoth-1.0f;
float modDiffuseIntensity = diffuseIntensity;//(1f + metalic * 0.25f) * Mathf.Max (0f, diffuseIntensity - (1f-ndoth) * metalic);
// diffuse light
float t0 = Mathf.Clamp01 (Mathf.InverseLerp (-wrapAround, 1f, ndotl * 2f - 1f));
float t0s = Mathf.Clamp01 (Mathf.InverseLerp (-wrapAround-scatter, 1f, ndotl * 2f - 1f));
//float t1 = Mathf.Clamp01 (Mathf.InverseLerp (-1f, Mathf.Max(-0.99f,-wrapAround), ndotl * 2f - 1f));
Color diffuse = modDiffuseIntensity * Color.Lerp (backColor, keyColor, t0);
//diffuse += backColor * (1f - modDiffuseIntensity) * Mathf.Clamp01 (diffuseIntensity);
Color diffuseScatter = modDiffuseIntensity * Color.Lerp (backColor, scatterColor, t0);
diffuse = Color.Lerp(diffuse, diffuseScatter, Mathf.Clamp01(4.0f*(ndotl2*2.0f-ndotl*1.0f)));
// schlick
float fresnel = Mathf.Pow( Mathf.Abs( 1.0f - (ndoth*2.0f-1.0f)), reflectivityFalloff);
fresnel = reflectivityAt0 * (1.0f-Mathf.Clamp01(fresnel)) + Mathf.Clamp01(fresnel) * reflectivityAt90;
//diffuse = Color.Lerp(diffuse, scatterColor, ndotl2 * scatter * Mathf.Max(0.0f, 1.0f-(ndotl*0.5f+0.5f) ) );
// Blinn-Phong specular (with energy conservation)
float n = specularShininess * 128f;
float energyConservationTerm = ((n + 2f)*(n + 4f)) / (8f * Mathf.PI * (Mathf.Pow (2f, -n/2f) + n)); // by ryg
//float energyConservationTerm = (n + 8f) / (8f * Mathf.PI); // from Real-Time Rendering
float specular = specularIntensity * energyConservationTerm * Mathf.Pow (ndoth, n);
// fresnel energy conservation
Color c = (ndotl2 > 0.5f ? diffuseScatter : (1.0f-fresnel * 0.0f) * diffuse) * intensity + (ndotl2 > 0.5f ? new Color(0f,0f,0f, fresnel) : new Color(0f,0f,0f, specular));
return c * intensity;
*/
// OLD CYAN BLEED SHIT:
//float ndoth = ndotl2;// *2.0f;
//if(ndoth>1.0f) ndoth = ndoth-1.0f;
// pseudo metalic falloff
//ndotl *= 1.0f;//Mathf.Pow (ndoth, metalic);
//float modDiffuseIntensity = diffuseIntensity;//(1f + metalic * 0.25f) * Mathf.Max (0f, diffuseIntensity - (1f-ndoth) * metalic);
// diffuse light
//float t0 = Mathf.Clamp01 (Mathf.InverseLerp (-wrapAround, 1f, ndotl * 2f - 1f));
//float t0s = Mathf.Clamp01 (Mathf.InverseLerp (-wrapAround-scatter, 1f, ndotl * 2f - 1f));
//float t1 = Mathf.Clamp01 (Mathf.InverseLerp (-1f, Mathf.Max(-0.99f,-wrapAround), ndotl * 2f - 1f));
//Color diffuse = modDiffuseIntensity * Color.Lerp (backColor, keyColor, t0);
//diffuse += backColor * (1f - modDiffuseIntensity) * Mathf.Clamp01 (diffuseIntensity);
//Color diffuseScatter = modDiffuseIntensity * Color.Lerp (backColor, scatterColor, t0s);
// schlick // *2.0f-1.0f
float fresnel = Mathf.Pow( Mathf.Abs( 1.0f - (ndotv)), reflectivityFalloff);
fresnel = reflectivityAt0 * (1.0f-Mathf.Clamp01(fresnel)) + Mathf.Clamp01(fresnel) * reflectivityAt90;
float specular = 0.0f;
float specular2 = 0.0f;
float fMaxSpecMod = 2.0f;// * Mathf.Max(reflectivityAt90, reflectivityAt0);
float fNormalizationSpec1 = 1.0f;
float fNormalizationSpec2 = 1.0f;
fNormalizationSpec1 = Mathf.Clamp(PHBeckmann(1.0f, specularShininess) * fMaxSpecMod, 0.25f, 2.0f);
fNormalizationSpec2 = Mathf.Clamp(PHBeckmann(1.0f, specularShininess2) * fMaxSpecMod, 0.25f, 2.0f);
specular = PHBeckmann(ndoth, specularShininess) / fNormalizationSpec1;
specular2 = PHBeckmann(ndoth, specularShininess2) / fNormalizationSpec2;
// fresnel energy conservation
Color c = new Color(1.0f-fresnel, specular * fresnel, specular2 * fresnel, fresnel);
return c;
}
void TextureFunc (Texture2D tex)
{
for (int y = 0; y < tex.height; ++y)
for (int x = 0; x < tex.width; ++x)
{
float w = tex.width-1;
float h = tex.height-1;
float vx = x / w;
float vy = y / h;
float NdotV = vx;
float NdotH = vy;
Color c = PixelFunc (NdotV, NdotH);
tex.SetPixel(x, y, c);
}
}
void GenerateLookupTexture (int width, int height) {
Texture2D tex;
if (lookupTexture && lookupTexture.width == width && lookupTexture.height == height)
tex = lookupTexture;
else
tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
CheckConsistency ();
TextureFunc (tex);
tex.Apply();
tex.wrapMode = TextureWrapMode.Clamp;
if (lookupTexture != tex)
DestroyImmediate (lookupTexture);
lookupTexture = tex;
}
public void Preview () {
GenerateLookupTexture (16, 128);
}
public void Bake () {
GenerateLookupTexture (lookupTextureWidth, lookupTextureHeight);
}
float normalizationFactor;
Color mixedTopLayerColor;
Color mixedSubLayerColor;
float fMaxSpecMod;
float fNormalizationSpec1;
float fNormalizationSpec2;
public bool parametersAreDirty = true;
public void SetParameters (Material m)
{
if (parametersAreDirty)
{
Color keyColor_ = keyColor;
float colorLum = keyColor_.r * 0.3f + keyColor_.g * 0.59f + keyColor_.b * 0.11f;
Vector4 v = new Vector4(colorLum * (1.0f-saturation)+keyColor_.r*saturation,colorLum * (1.0f-saturation)+keyColor_.g*saturation,colorLum * (1.0f-saturation)+keyColor_.b*saturation,1.0f );
keyColor_ = Color.Lerp(new Color(colorLum,colorLum,colorLum), keyColor_, saturation);
keyColor_ = v;
Color epiColor_ = epiColor;
colorLum = epiColor_.r * 0.3f + epiColor_.g * 0.59f + epiColor_.b * 0.11f;
v = new Vector4(colorLum * (1.0f-saturation)+epiColor_.r*saturation,colorLum * (1.0f-saturation)+epiColor_.g*saturation,colorLum * (1.0f-saturation)+epiColor_.b*saturation,1.0f );
epiColor_ = Color.Lerp(new Color(colorLum,colorLum,colorLum), epiColor_, saturation);
epiColor_ = v;
Color scatterColor_ = scatterColor;
colorLum = scatterColor_.r * 0.3f + scatterColor_.g * 0.59f + scatterColor_.b * 0.11f;
v = new Vector4(colorLum * (1.0f-saturation)+scatterColor_.r*saturation,colorLum * (1.0f-saturation)+scatterColor_.g*saturation,colorLum * (1.0f-saturation)+scatterColor_.b*saturation,1.0f );
scatterColor_ = v;
// the 2 layer model mixes epi into top & sub layers (optimization)
/*float*/ normalizationFactor = 1.0f/(Mathf.Epsilon + epiLayerStrength + topLayerStrength + subLayerStrength);
/*Color*/ mixedTopLayerColor = (epiColor_ * (1.0f - epiRelative) * epiLayerStrength + keyColor_ * topLayerStrength) * normalizationFactor;
/*Color*/ mixedSubLayerColor = (epiColor_ * epiRelative * epiLayerStrength + scatterColor_ * subLayerStrength) * normalizationFactor;
/*float*/ fMaxSpecMod = 2.0f;// * Mathf.Max(reflectivityAt90, reflectivityAt0);;//2.0f * Mathf.Max(specularIntensity,specularIntensity2);
/*float*/ fNormalizationSpec1 = Mathf.Clamp(PHBeckmann(1.0f, specularShininess) * fMaxSpecMod, 0.25f, 2.0f) * specularIntensity;
/*float*/ fNormalizationSpec2 = Mathf.Clamp(PHBeckmann(1.0f, specularShininess2) * fMaxSpecMod, 0.25f, 2.0f) * specularIntensity2;
parametersAreDirty = false;
}
if(m)
{
m.SetColor("_SkinSubLayerColor", mixedSubLayerColor);
m.SetColor("_SkinTopLayerColor", mixedTopLayerColor);
m.SetColor("_SkinEpiLayerColor", new Color(0,0,0,0));
m.SetColor("_SkinFbDiffuse", mixedSubLayerColor+mixedTopLayerColor);
m.SetVector("_SkinReflectivityMod", new Vector3(fNormalizationSpec1,fNormalizationSpec2,0.25f) );
m.SetVector("_Roughness", new Vector4(specularShininess,specularShininess2, specularIntensity,specularIntensity2));
}
}
/*
public void OnRenderObject ()
{
// the 2 layer model mixes epi into top & sub layers (optimization)
float normalizationFactor = 1.0f/(Mathf.Epsilon + epiLayerStrength + topLayerStrength + subLayerStrength);
Color mixedTopLayerColor = (epiColor * 0.35f * epiLayerStrength + keyColor * topLayerStrength) * normalizationFactor;
Color mixedSubLayerColor = (epiColor * 0.65f * epiLayerStrength + scatterColor * subLayerStrength) * normalizationFactor;
Shader.SetGlobalColor("_SkinSubLayerColor", mixedSubLayerColor);
Shader.SetGlobalColor("_SkinTopLayerColor", mixedTopLayerColor);
Shader.SetGlobalColor("_SkinEpiLayerColor", new Color(0,0,0,0)); // mixed in to other players
float fMaxSpecMod = 2.0f * Mathf.Max(specularIntensity,specularIntensity2);
Shader.SetGlobalFloat("_SkinReflectivityMod", fMaxSpecMod);
}
*/
} | 39.179941 | 195 | 0.6947 | [
"MIT"
] | communityus-branch/thechase-demo-2013 | Assets/MobileSkin/SkinShadingLookupTexture.cs | 13,282 | 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.Network.V20190901.Inputs
{
/// <summary>
/// Route resource.
/// </summary>
public sealed class RouteArgs : Pulumi.ResourceArgs
{
/// <summary>
/// The destination CIDR to which the route applies.
/// </summary>
[Input("addressPrefix")]
public Input<string>? AddressPrefix { get; set; }
/// <summary>
/// Resource ID.
/// </summary>
[Input("id")]
public Input<string>? Id { get; set; }
/// <summary>
/// The name of the resource that is unique within a resource group. This name can be used to access the resource.
/// </summary>
[Input("name")]
public Input<string>? Name { get; set; }
/// <summary>
/// The IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance.
/// </summary>
[Input("nextHopIpAddress")]
public Input<string>? NextHopIpAddress { get; set; }
/// <summary>
/// The type of Azure hop the packet should be sent to.
/// </summary>
[Input("nextHopType", required: true)]
public InputUnion<string, Pulumi.AzureNative.Network.V20190901.RouteNextHopType> NextHopType { get; set; } = null!;
public RouteArgs()
{
}
}
}
| 31.792453 | 146 | 0.604748 | [
"Apache-2.0"
] | polivbr/pulumi-azure-native | sdk/dotnet/Network/V20190901/Inputs/RouteArgs.cs | 1,685 | C# |
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BTCPayServer.Models;
namespace BTCPayServer.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View("Home");
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
| 22.184211 | 112 | 0.599051 | [
"MIT"
] | ch4ot1c/btcpayserver | BTCPayServer/Controllers/HomeController.cs | 845 | C# |
namespace Recipes.Desktop
{
partial class RecipeDetailsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.recipeTitleLabel = new System.Windows.Forms.Label();
this.recipeImagePictureBox = new System.Windows.Forms.PictureBox();
this.recipeDescriptionTextBox = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.recipeImagePictureBox)).BeginInit();
this.SuspendLayout();
//
// recipeTitleLabel
//
this.recipeTitleLabel.AutoSize = true;
this.recipeTitleLabel.Location = new System.Drawing.Point(34, 33);
this.recipeTitleLabel.Name = "recipeTitleLabel";
this.recipeTitleLabel.Size = new System.Drawing.Size(38, 15);
this.recipeTitleLabel.TabIndex = 0;
this.recipeTitleLabel.Text = "label1";
//
// recipeImagePictureBox
//
this.recipeImagePictureBox.Cursor = System.Windows.Forms.Cursors.No;
this.recipeImagePictureBox.Location = new System.Drawing.Point(34, 73);
this.recipeImagePictureBox.Name = "recipeImagePictureBox";
this.recipeImagePictureBox.Size = new System.Drawing.Size(283, 319);
this.recipeImagePictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.recipeImagePictureBox.TabIndex = 1;
this.recipeImagePictureBox.TabStop = false;
//
// recipeDescriptionTextBox
//
this.recipeDescriptionTextBox.Location = new System.Drawing.Point(34, 420);
this.recipeDescriptionTextBox.Multiline = true;
this.recipeDescriptionTextBox.Name = "recipeDescriptionTextBox";
this.recipeDescriptionTextBox.ReadOnly = true;
this.recipeDescriptionTextBox.Size = new System.Drawing.Size(481, 181);
this.recipeDescriptionTextBox.TabIndex = 2;
//
// RecipeDetails
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(564, 636);
this.Controls.Add(this.recipeDescriptionTextBox);
this.Controls.Add(this.recipeImagePictureBox);
this.Controls.Add(this.recipeTitleLabel);
this.Name = "RecipeDetails";
this.Text = "RecipeDetails";
((System.ComponentModel.ISupportInitialize)(this.recipeImagePictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label recipeTitleLabel;
private System.Windows.Forms.TextBox recipeDescriptionTextBox;
private System.Windows.Forms.PictureBox recipeImagePictureBox;
}
} | 42.75 | 107 | 0.617225 | [
"MIT"
] | veronicakolarska/recipes-app | Recipes.Desktop/RecipeDetailsForm.Designer.cs | 3,764 | C# |
namespace Plivo.Resource
{
public class DeleteResponse<T> : BaseResponse
{
}
} | 15 | 49 | 0.666667 | [
"MIT"
] | KoushikShetty/plivo-dotnet | src/Plivo/Resource/DeleteResponse.cs | 90 | C# |
using System;
namespace Twilio
{
/// <summary>
/// An Queue instance resource
/// </summary>
public class Queue : TwilioBase
{
/// <summary>
/// A 34 character string that uniquely identifies this resource.
/// </summary>
public string Sid { get; set; }
/// <summary>
/// A user provided string that identifies this queue.
/// </summary>
public string FriendlyName { get; set; }
/// <summary>
/// A count of the current number of calls in the Queue
/// </summary>
public int? CurrentSize { get; set; }
/// <summary>
/// The average (in seconds) that all calls in the queue have waited
/// </summary>
public int? AverageWaitTime { get; set; }
/// <summary>
/// The maximum number of calls allowed in this queue
/// </summary>
public int? MaxSize { get; set; }
/// <summary>
/// The date that this resource was created, given as GMT
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// The date that this resource was last updated, given as GMT
/// </summary>
public DateTime DateUpdated { get; set; }
}
}
| 27.326087 | 76 | 0.552904 | [
"Apache-2.0"
] | ArashMotamedi/Twilio.NetCore | src/Twilio.NetCore/Model/Queue.cs | 1,259 | C# |
//------------------------------------------------------------------------------
// <auto-generated>
// Bu kod araç tarafından oluşturuldu.
// Çalışma Zamanı Sürümü:4.0.30319.42000
//
// Bu dosyada yapılacak değişiklikler yanlış davranışa neden olabilir ve
// kod yeniden oluşturulursa kaybolur.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Dapper_Micro_ORM_Web_API")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Dapper_Micro_ORM_Web_API")]
[assembly: System.Reflection.AssemblyTitleAttribute("Dapper_Micro_ORM_Web_API")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// MSBuild WriteCodeFragment sınıfı tarafından oluşturuldu.
| 43.708333 | 82 | 0.675882 | [
"MIT"
] | Akbank-Full-Stack-Development-Bootcamp/BusraAltun_Odev2 | Dapper/Dapper_Micro_ORM/Dapper_Micro_ORM_Web_API/Dapper_Micro_ORM_Web_API/obj/Release/net5.0/Dapper_Micro_ORM_Web_API.AssemblyInfo.cs | 1,072 | 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;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Authentication.Cookies
{
/// <summary>
/// Configuration options for <see cref="CookieAuthenticationOptions"/>.
/// </summary>
public class CookieAuthenticationOptions : AuthenticationSchemeOptions
{
private CookieBuilder _cookieBuilder = new RequestPathBaseCookieBuilder
{
// the default name is configured in PostConfigureCookieAuthenticationOptions
// To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231.
SameSite = SameSiteMode.Lax,
HttpOnly = true,
SecurePolicy = CookieSecurePolicy.SameAsRequest,
IsEssential = true,
};
/// <summary>
/// Create an instance of the options initialized with the default values
/// </summary>
public CookieAuthenticationOptions()
{
ExpireTimeSpan = TimeSpan.FromDays(14);
ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
SlidingExpiration = true;
Events = new CookieAuthenticationEvents();
}
/// <summary>
/// <para>
/// Determines the settings used to create the cookie.
/// </para>
/// <para>
/// <see cref="CookieBuilder.SameSite"/> defaults to <see cref="SameSiteMode.Lax"/>.
/// <see cref="CookieBuilder.HttpOnly"/> defaults to <c>true</c>.
/// <see cref="CookieBuilder.SecurePolicy"/> defaults to <see cref="CookieSecurePolicy.SameAsRequest"/>.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The default value for cookie <see cref="CookieBuilder.Name"/> is ".AspNetCore.Cookies".
/// This value should be changed if you change the name of the <c>AuthenticationScheme</c>, especially if your
/// system uses the cookie authentication handler multiple times.
/// </para>
/// <para>
/// <see cref="CookieBuilder.SameSite"/> determines if the browser should allow the cookie to be attached to same-site or cross-site requests.
/// The default is <c>Lax</c>, which means the cookie is only allowed to be attached to cross-site requests using safe HTTP methods and same-site requests.
/// </para>
/// <para>
/// <see cref="CookieBuilder.HttpOnly"/> determines if the browser should allow the cookie to be accessed by client-side javascript.
/// The default is true, which means the cookie will only be passed to http requests and is not made available to script on the page.
/// </para>
/// <para>
/// <see cref="CookieBuilder.Expiration"/> is currently ignored. Use <see cref="ExpireTimeSpan"/> to control lifetime of cookie authentication.
/// </para>
/// </remarks>
public CookieBuilder Cookie
{
get => _cookieBuilder;
set => _cookieBuilder = value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
/// If set this will be used by the CookieAuthenticationHandler for data protection.
/// </summary>
public IDataProtectionProvider? DataProtectionProvider { get; set; }
/// <summary>
/// The SlidingExpiration is set to true to instruct the handler to re-issue a new cookie with a new
/// expiration time any time it processes a request which is more than halfway through the expiration window.
/// </summary>
public bool SlidingExpiration { get; set; }
/// <summary>
/// The LoginPath property is used by the handler for the redirection target when handling ChallengeAsync.
/// The current url which is added to the LoginPath as a query string parameter named by the ReturnUrlParameter.
/// Once a request to the LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect
/// the browser back to the original url.
/// </summary>
public PathString LoginPath { get; set; }
/// <summary>
/// If the LogoutPath is provided the handler then a request to that path will redirect based on the ReturnUrlParameter.
/// </summary>
public PathString LogoutPath { get; set; }
/// <summary>
/// The AccessDeniedPath property is used by the handler for the redirection target when handling ForbidAsync.
/// </summary>
public PathString AccessDeniedPath { get; set; }
/// <summary>
/// The ReturnUrlParameter determines the name of the query string parameter which is appended by the handler
/// when during a Challenge. This is also the query string parameter looked for when a request arrives on the
/// login path or logout path, in order to return to the original url after the action is performed.
/// </summary>
public string ReturnUrlParameter { get; set; }
/// <summary>
/// The Provider may be assigned to an instance of an object created by the application at startup time. The handler
/// calls methods on the provider which give the application control at certain points where processing is occurring.
/// If it is not provided a default instance is supplied which does nothing when the methods are called.
/// </summary>
public new CookieAuthenticationEvents Events
{
get => (CookieAuthenticationEvents)base.Events!;
set => base.Events = value;
}
/// <summary>
/// The TicketDataFormat is used to protect and unprotect the identity and other properties which are stored in the
/// cookie value. If not provided one will be created using <see cref="DataProtectionProvider"/>.
/// </summary>
public ISecureDataFormat<AuthenticationTicket> TicketDataFormat { get; set; } = default!;
/// <summary>
/// The component used to get cookies from the request or set them on the response.
///
/// ChunkingCookieManager will be used by default.
/// </summary>
public ICookieManager CookieManager { get; set; } = default!;
/// <summary>
/// An optional container in which to store the identity across requests. When used, only a session identifier is sent
/// to the client. This can be used to mitigate potential problems with very large identities.
/// </summary>
public ITicketStore? SessionStore { get; set; }
/// <summary>
/// <para>
/// Controls how much time the authentication ticket stored in the cookie will remain valid from the point it is created
/// The expiration information is stored in the protected cookie ticket. Because of that an expired cookie will be ignored
/// even if it is passed to the server after the browser should have purged it.
/// </para>
/// <para>
/// This is separate from the value of <see cref="CookieOptions.Expires"/>, which specifies
/// how long the browser will keep the cookie.
/// </para>
/// </summary>
public TimeSpan ExpireTimeSpan { get; set; }
}
}
| 49.675497 | 163 | 0.646047 | [
"Apache-2.0"
] | 1n5an1ty/aspnetcore | src/Security/Authentication/Cookies/src/CookieAuthenticationOptions.cs | 7,501 | 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.Media.V20180330Preview
{
public static class ListStreamingLocatorPaths
{
/// <summary>
/// Class of response for listPaths action
/// </summary>
public static Task<ListStreamingLocatorPathsResult> InvokeAsync(ListStreamingLocatorPathsArgs args, InvokeOptions? options = null)
=> Pulumi.Deployment.Instance.InvokeAsync<ListStreamingLocatorPathsResult>("azure-native:media/v20180330preview:listStreamingLocatorPaths", args ?? new ListStreamingLocatorPathsArgs(), options.WithVersion());
}
public sealed class ListStreamingLocatorPathsArgs : Pulumi.InvokeArgs
{
/// <summary>
/// The Media Services account name.
/// </summary>
[Input("accountName", required: true)]
public string AccountName { get; set; } = null!;
/// <summary>
/// The name of the resource group within the Azure subscription.
/// </summary>
[Input("resourceGroupName", required: true)]
public string ResourceGroupName { get; set; } = null!;
/// <summary>
/// The Streaming Locator name.
/// </summary>
[Input("streamingLocatorName", required: true)]
public string StreamingLocatorName { get; set; } = null!;
public ListStreamingLocatorPathsArgs()
{
}
}
[OutputType]
public sealed class ListStreamingLocatorPathsResult
{
/// <summary>
/// Download Paths supported by current Streaming Locator
/// </summary>
public readonly ImmutableArray<string> DownloadPaths;
/// <summary>
/// Streaming Paths supported by current Streaming Locator
/// </summary>
public readonly ImmutableArray<Outputs.StreamingPathResponse> StreamingPaths;
[OutputConstructor]
private ListStreamingLocatorPathsResult(
ImmutableArray<string> downloadPaths,
ImmutableArray<Outputs.StreamingPathResponse> streamingPaths)
{
DownloadPaths = downloadPaths;
StreamingPaths = streamingPaths;
}
}
}
| 34.309859 | 220 | 0.657635 | [
"Apache-2.0"
] | polivbr/pulumi-azure-native | sdk/dotnet/Media/V20180330Preview/ListStreamingLocatorPaths.cs | 2,436 | C# |
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace BuildVision.Common
{
public class GenericXmlSerializer<T> where T : class, new()
{
public virtual T Deserialize(string xml)
{
var serializer = new XmlSerializer(typeof(T));
using (TextReader reader = new StringReader(xml))
{
return serializer.Deserialize(reader) as T;
}
}
public virtual string Serialize(T settings)
{
using (var ms = new MemoryStream())
using (var tw = new XmlTextWriter(ms, null))
{
new XmlSerializer(typeof(T)).Serialize(tw, settings);
return Encoding.UTF8.GetString(ms.ToArray());
}
}
}
}
| 26.677419 | 69 | 0.56711 | [
"MIT"
] | Stelzi79/BuildVision | src/BuildVision.Common/GenericXmlSerializer.cs | 829 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
public class GameManager : MonoBehaviour {
public static GameManager instance;
public Board board;
public GameObject[] gameplayUIElements, gameOverUIElements;
public GameObject additionUI, shuffleUI, nextRoundUI;
[HideInInspector] public int score, totalScore, round, scoreRoundGoal;
[HideInInspector] public float timer;
[HideInInspector] public bool isSelected;
private int selectedXCor_1, selectedYCor_1, selectedXCor_2, selectedYCor_2;
private bool isSwitching = false;
private bool gameover = false;
private const int ROUND_GOAL_INCREASE = 35;
private const int RESET_TIMER = 120;
private const int ROUND_ONE_GOAL = 10;
void Awake() {
instance = this;
Setup();
}
void Update() => Timer();
/*
* Initial Conditions
*/
void Setup() {
round = 1;
timer = RESET_TIMER;
scoreRoundGoal = ROUND_ONE_GOAL;
isSelected = false;
}
/*
* Handles timer
* When timer reaches 0, the game is over
*/
void Timer() {
if (timer <= 0 && !gameover) {
GameOver();
} else {
timer -= Time.deltaTime;
}
}
/*
* Called by a gem object to apply a move if possible
*/
public void CheckIfPossibleMove() {
if (PerpendicularMove() && !isSwitching) {
if (board.CheckIfSwitchIsPossible(selectedXCor_1, selectedYCor_1, selectedXCor_2, selectedYCor_2, true)) {
AudioManager.instance.Play("Swap");
board.MakeSpriteSwitch(selectedXCor_1, selectedYCor_1, selectedXCor_2, selectedYCor_2);
isSwitching = true;
ResetCoordinates();
isSelected = false;
}
}
}
/*
* Check if selected gems are a legal movement.
* A swap can only happen up, down, right and left
* No diagonal swap
*/
bool PerpendicularMove() {
if ((selectedXCor_1 + 1 == selectedXCor_2 && selectedYCor_1 == selectedYCor_2) || //Right
(selectedXCor_1 - 1 == selectedXCor_2 && selectedYCor_1 == selectedYCor_2) || //Left
(selectedXCor_1 == selectedXCor_2 && selectedYCor_1 + 1 == selectedYCor_2) || //Up
(selectedXCor_1 == selectedXCor_2 && selectedYCor_1 - 1 == selectedYCor_2)) { //Down
return true;
} else {
return false;
}
}
/*
* Calculate score
* Call UI effects
* Manages round transition
*/
public void AddScore(int sequenceCount, int combo = 1) {
score += (sequenceCount * combo);
totalScore += (sequenceCount * combo);
UI.instance.AdditionPopUp(additionUI, 1.0f, (sequenceCount * combo));
if (score >= scoreRoundGoal) {
StartCoroutine(UI.instance.PopUpFadeAway(nextRoundUI, 3.0f));
scoreRoundGoal += ROUND_GOAL_INCREASE;
round += 1;
score = 0;
timer = RESET_TIMER;
}
}
public void SetIsSelected(bool status) {
AudioManager.instance.Play("Select");
isSelected = status;
}
public void SetIsSwitching(bool status) {
isSwitching = status;
}
public void SetSelectedCoordinates(bool firstSelection, int x, int y) {
if (firstSelection) {
selectedXCor_1 = x;
selectedYCor_1 = y;
} else {
selectedXCor_2 = x;
selectedYCor_2 = y;
}
}
void ResetCoordinates() {
selectedXCor_1 = 0;
selectedYCor_1 = 0;
selectedXCor_2 = 0;
selectedYCor_2 = 0;
}
void GameOver() {
gameover = true;
board.DeactivateBoard();
UI.instance.DisplayGameOverText();
foreach (var item in gameplayUIElements) item.SetActive(false);
foreach (var item in gameOverUIElements) item.SetActive(true);
}
public void ButtonRestartGame() {
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
public void ButtonReturnMenu() {
SceneManager.LoadScene(0);
}
}
| 29.625 | 118 | 0.597046 | [
"MIT"
] | FabioPBrigagao/match3-test | Assets/Scripts/GameManager.cs | 4,268 | 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.Tsf.V20180326.Models
{
using Newtonsoft.Json;
using System.Collections.Generic;
using TencentCloud.Common;
public class TsfPageConfigReleaseLog : AbstractModel
{
/// <summary>
/// 总条数
/// 注意:此字段可能返回 null,表示取不到有效值。
/// </summary>
[JsonProperty("TotalCount")]
public long? TotalCount{ get; set; }
/// <summary>
/// 配置项发布日志数组
/// 注意:此字段可能返回 null,表示取不到有效值。
/// </summary>
[JsonProperty("Content")]
public ConfigReleaseLog[] Content{ 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 + "TotalCount", this.TotalCount);
this.SetParamArrayObj(map, prefix + "Content.", this.Content);
}
}
}
| 30.245283 | 81 | 0.635059 | [
"Apache-2.0"
] | TencentCloud/tencentcloud-sdk-dotnet | TencentCloud/Tsf/V20180326/Models/TsfPageConfigReleaseLog.cs | 1,707 | C# |
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Vanara.InteropServices;
using static Vanara.PInvoke.Ole32;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
public static partial class OleAut32
{
/// <summary>
/// Provides a quick means by which applications can look up the standard Windows Image Acquisition (WIA) property name from the WIA
/// property ID (or vice versa). If the <c>propid</c> does not exist in this array, it is likely not a standard WIA property. Other
/// ways to get the property name from the property ID include using the <c>IEnumSTATPROPSTG</c> retrieved by calling
/// IWiaPropertyStorage::Enum on a particular item.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/ns-wia_xp-wia_propid_to_name typedef struct _WIA_PROPID_TO_NAME {
// PROPID propid; LPOLESTR pszName; } WIA_PROPID_TO_NAME, *PWIA_PROPID_TO_NAME;
[PInvokeData("wia_xp.h")]
public static Dictionary<WIA_PROPID, string> WIA_PROPID_TO_NAME = new Dictionary<WIA_PROPID, string>
{
{ WIA_PROPID.WIA_DIP_BAUDRATE , "BaudRate" },
{ WIA_PROPID.WIA_DIP_DEV_DESC , "Description" },
{ WIA_PROPID.WIA_DIP_DEV_ID , "Unique Device ID" },
{ WIA_PROPID.WIA_DIP_DEV_NAME , "Name" },
{ WIA_PROPID.WIA_DIP_DEV_TYPE , "Type" },
{ WIA_PROPID.WIA_DIP_DRIVER_VERSION , "Driver Version" },
{ WIA_PROPID.WIA_DIP_HW_CONFIG , "Hardware Configuration" },
{ WIA_PROPID.WIA_DIP_PNP_ID , "PnP ID String" },
{ WIA_PROPID.WIA_DIP_PORT_NAME , "Port" },
{ WIA_PROPID.WIA_DIP_REMOTE_DEV_ID , "Remote Device ID" },
{ WIA_PROPID.WIA_DIP_SERVER_NAME , "Server" },
{ WIA_PROPID.WIA_DIP_STI_DRIVER_VERSION , "STI Driver Version" },
{ WIA_PROPID.WIA_DIP_STI_GEN_CAPABILITIES , "STI Generic Capabilities" },
{ WIA_PROPID.WIA_DIP_UI_CLSID , "UI Class ID" },
{ WIA_PROPID.WIA_DIP_VEND_DESC , "Manufacturer" },
{ WIA_PROPID.WIA_DIP_WIA_VERSION , "WIA Version" },
{ WIA_PROPID.WIA_DPA_CONNECT_STATUS , "Connect Status" },
{ WIA_PROPID.WIA_DPA_DEVICE_TIME , "Device Time" },
{ WIA_PROPID.WIA_DPA_FIRMWARE_VERSION , "Firmware Version" },
{ WIA_PROPID.WIA_DPC_ARTIST , "Artist" },
{ WIA_PROPID.WIA_DPC_BATTERY_STATUS , "Battery Status" },
{ WIA_PROPID.WIA_DPC_BURST_INTERVAL , "Burst Interval" },
{ WIA_PROPID.WIA_DPC_BURST_NUMBER , "Burst Number" },
{ WIA_PROPID.WIA_DPC_CAPTURE_DELAY , "Capture Delay" },
{ WIA_PROPID.WIA_DPC_CAPTURE_MODE , "Capture Mode" },
{ WIA_PROPID.WIA_DPC_COMPRESSION_SETTING , "Compression Setting" },
{ WIA_PROPID.WIA_DPC_CONTRAST , "Contrast" },
{ WIA_PROPID.WIA_DPC_COPYRIGHT_INFO , "Copyright Info" },
{ WIA_PROPID.WIA_DPC_DIGITAL_ZOOM , "Digital Zoom" },
{ WIA_PROPID.WIA_DPC_DIMENSION , "Dimension" },
{ WIA_PROPID.WIA_DPC_EFFECT_MODE , "Effect Mode" },
{ WIA_PROPID.WIA_DPC_EXPOSURE_COMP , "Exposure Compensation" },
{ WIA_PROPID.WIA_DPC_EXPOSURE_INDEX , "Exposure Index" },
{ WIA_PROPID.WIA_DPC_EXPOSURE_METERING_MODE , "Exposure Metering Mode" },
{ WIA_PROPID.WIA_DPC_EXPOSURE_MODE , "Exposure Mode" },
{ WIA_PROPID.WIA_DPC_EXPOSURE_TIME , "Exposure Time" },
{ WIA_PROPID.WIA_DPC_FLASH_MODE , "Flash Mode" },
{ WIA_PROPID.WIA_DPC_FNUMBER , "F Number" },
{ WIA_PROPID.WIA_DPC_FOCAL_LENGTH , "Focus Length" },
{ WIA_PROPID.WIA_DPC_FOCUS_DISTANCE , "Focus Distance" },
{ WIA_PROPID.WIA_DPC_FOCUS_MANUAL_DIST , "Focus Manual Dist" },
{ WIA_PROPID.WIA_DPC_FOCUS_METERING , "Focus Metering Mode" },
{ WIA_PROPID.WIA_DPC_FOCUS_METERING_MODE , "Focus Metering Mode" },
{ WIA_PROPID.WIA_DPC_FOCUS_MODE , "Focus Mode" },
{ WIA_PROPID.WIA_DPC_PAN_POSITION , "Pan Position" },
{ WIA_PROPID.WIA_DPC_PICT_HEIGHT , "Picture Height" },
{ WIA_PROPID.WIA_DPC_PICT_WIDTH , "Picture Width" },
{ WIA_PROPID.WIA_DPC_PICTURES_REMAINING , "Pictures Remaining" },
{ WIA_PROPID.WIA_DPC_PICTURES_TAKEN , "Pictures Taken" },
{ WIA_PROPID.WIA_DPC_POWER_MODE , "Power Mode" },
{ WIA_PROPID.WIA_DPC_RGB_GAIN , "RGB Gain" },
{ WIA_PROPID.WIA_DPC_SHARPNESS , "Sharpness" },
{ WIA_PROPID.WIA_DPC_THUMB_HEIGHT , "Thumbnail Height" },
{ WIA_PROPID.WIA_DPC_THUMB_WIDTH , "Thumbnail Width" },
{ WIA_PROPID.WIA_DPC_TILT_POSITION , "Tilt Position" },
{ WIA_PROPID.WIA_DPC_TIMELAPSE_INTERVAL , "Timelapse Interval" },
{ WIA_PROPID.WIA_DPC_TIMELAPSE_NUMBER , "Timelapse Number" },
{ WIA_PROPID.WIA_DPC_TIMER_MODE , "Timer Mode" },
{ WIA_PROPID.WIA_DPC_TIMER_VALUE , "Timer Value" },
{ WIA_PROPID.WIA_DPC_UPLOAD_URL , "Upload URL" },
{ WIA_PROPID.WIA_DPC_WHITE_BALANCE , "White Balance" },
{ WIA_PROPID.WIA_DPC_ZOOM_POSITION , "Zoom Position" },
{ WIA_PROPID.WIA_DPF_MOUNT_POINT , "Directory mount point" },
{ WIA_PROPID.WIA_DPS_DEVICE_ID , "Device ID" },
{ WIA_PROPID.WIA_DPS_DITHER_PATTERN_DATA , "Dither Pattern Data" },
{ WIA_PROPID.WIA_DPS_DITHER_SELECT , "Dither Select" },
{ WIA_PROPID.WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES , "Document Handling Capabilities" },
{ WIA_PROPID.WIA_DPS_DOCUMENT_HANDLING_CAPACITY , "Document Handling Capacity" },
{ WIA_PROPID.WIA_DPS_DOCUMENT_HANDLING_SELECT , "Document Handling Select" },
{ WIA_PROPID.WIA_DPS_DOCUMENT_HANDLING_STATUS , "Document Handling Status" },
{ WIA_PROPID.WIA_DPS_ENDORSER_CHARACTERS , "Endorser Characters" },
{ WIA_PROPID.WIA_DPS_ENDORSER_STRING , "Endorser String" },
{ WIA_PROPID.WIA_DPS_FILTER_SELECT , "Filter Select" },
{ WIA_PROPID.WIA_DPS_GLOBAL_IDENTITY , "Global Identity" },
{ WIA_PROPID.WIA_DPS_HORIZONTAL_BED_REGISTRATION , "Horizontal Bed Registration" },
{ WIA_PROPID.WIA_DPS_HORIZONTAL_BED_SIZE , "Horizontal Bed Size" },
{ WIA_PROPID.WIA_DPS_HORIZONTAL_SHEET_FEED_SIZE , "Horizontal Sheet Feed Size" },
{ WIA_PROPID.WIA_DPS_MAX_SCAN_TIME , "Max Scan Time" },
{ WIA_PROPID.WIA_DPS_MIN_HORIZONTAL_SHEET_FEED_SIZE , "Minimum Horizontal Sheet Feed Size" },
{ WIA_PROPID.WIA_DPS_MIN_VERTICAL_SHEET_FEED_SIZE , "Minimum Vertical Sheet Feed Size" },
{ WIA_PROPID.WIA_DPS_OPTICAL_XRES , "Horizontal Optical Resolution" },
{ WIA_PROPID.WIA_DPS_OPTICAL_YRES , "Vertical Optical Resolution" },
{ WIA_PROPID.WIA_DPS_PAD_COLOR , "Pad Color" },
{ WIA_PROPID.WIA_DPS_PAGE_HEIGHT , "Page Height" },
{ WIA_PROPID.WIA_DPS_PAGE_SIZE , "Page Size" },
{ WIA_PROPID.WIA_DPS_PAGE_WIDTH , "Page Width" },
{ WIA_PROPID.WIA_DPS_PAGES , "Pages" },
{ WIA_PROPID.WIA_DPS_PLATEN_COLOR , "Platen Color" },
{ WIA_PROPID.WIA_DPS_PREVIEW , "Preview" },
{ WIA_PROPID.WIA_DPS_SCAN_AHEAD_PAGES , "Scan Ahead Pages" },
{ WIA_PROPID.WIA_DPS_SCAN_AVAILABLE_ITEM , "Scan Available Item" },
{ WIA_PROPID.WIA_DPS_SERVICE_ID , "Service ID" },
{ WIA_PROPID.WIA_DPS_SHEET_FEEDER_REGISTRATION , "Sheet Feeder Registration" },
{ WIA_PROPID.WIA_DPS_SHOW_PREVIEW_CONTROL , "Show preview control" },
{ WIA_PROPID.WIA_DPS_TRANSPARENCY , "Transparency Adapter" },
{ WIA_PROPID.WIA_DPS_TRANSPARENCY_CAPABILITIES , "Transparency Adapter Capabilities" },
{ WIA_PROPID.WIA_DPS_TRANSPARENCY_SELECT , "Transparency Adapter Select" },
{ WIA_PROPID.WIA_DPS_TRANSPARENCY_STATUS , "Transparency Adapter Status" },
{ WIA_PROPID.WIA_DPS_USER_NAME , "User Name" },
{ WIA_PROPID.WIA_DPS_VERTICAL_BED_REGISTRATION , "Vertical Bed Registration" },
{ WIA_PROPID.WIA_DPS_VERTICAL_BED_SIZE , "Vertical Bed Size" },
{ WIA_PROPID.WIA_DPS_VERTICAL_SHEET_FEED_SIZE , "Vertical Sheet Feed Size" },
{ WIA_PROPID.WIA_DPV_DSHOW_DEVICE_PATH , "Directshow Device Path" },
{ WIA_PROPID.WIA_DPV_IMAGES_DIRECTORY , "Images Directory" },
{ WIA_PROPID.WIA_DPV_LAST_PICTURE_TAKEN , "Last Picture Taken" },
{ WIA_PROPID.WIA_IPA_ACCESS_RIGHTS , "Access Rights" },
{ WIA_PROPID.WIA_IPA_APP_COLOR_MAPPING , "Application Applies Color Mapping" },
{ WIA_PROPID.WIA_IPA_BITS_PER_CHANNEL , "Bits Per Channel" },
{ WIA_PROPID.WIA_IPA_BUFFER_SIZE , "Buffer Size" },
{ WIA_PROPID.WIA_IPA_BYTES_PER_LINE , "Bytes Per Line" },
{ WIA_PROPID.WIA_IPA_CHANNELS_PER_PIXEL , "Channels Per Pixel" },
{ WIA_PROPID.WIA_IPA_COLOR_PROFILE , "Color Profiles" },
{ WIA_PROPID.WIA_IPA_COMPRESSION , "Compression" },
{ WIA_PROPID.WIA_IPA_DATATYPE , "Data Type" },
{ WIA_PROPID.WIA_IPA_DEPTH , "Bits Per Pixel" },
{ WIA_PROPID.WIA_IPA_FILENAME_EXTENSION , "Filename extension" },
{ WIA_PROPID.WIA_IPA_FORMAT , "Format" },
{ WIA_PROPID.WIA_IPA_FULL_ITEM_NAME , "Full Item Name" },
{ WIA_PROPID.WIA_IPA_GAMMA_CURVES , "Gamma Curves" },
{ WIA_PROPID.WIA_IPA_ICM_PROFILE_NAME , "Color Profile Name" },
{ WIA_PROPID.WIA_IPA_ITEM_CATEGORY , "Item Category" },
{ WIA_PROPID.WIA_IPA_ITEM_FLAGS , "Item Flags" },
{ WIA_PROPID.WIA_IPA_ITEM_NAME , "Item Name" },
{ WIA_PROPID.WIA_IPA_ITEM_SIZE , "Item Size" },
{ WIA_PROPID.WIA_IPA_ITEM_TIME , "Item Time Stamp" },
{ WIA_PROPID.WIA_IPA_ITEMS_STORED , "Items Stored" },
{ WIA_PROPID.WIA_IPA_NUMBER_OF_LINES , "Number of Lines" },
{ WIA_PROPID.WIA_IPA_PIXELS_PER_LINE , "Pixels Per Line" },
{ WIA_PROPID.WIA_IPA_PLANAR , "Planar" },
{ WIA_PROPID.WIA_IPA_PREFERRED_FORMAT , "Preferred Format" },
{ WIA_PROPID.WIA_IPA_PROP_STREAM_COMPAT_ID , "Stream Compatibility ID" },
{ WIA_PROPID.WIA_IPA_RAW_BITS_PER_CHANNEL , "Raw Bits Per Channel" },
{ WIA_PROPID.WIA_IPA_REGION_TYPE , "Region Type" },
{ WIA_PROPID.WIA_IPA_SUPPRESS_PROPERTY_PAGE , "Suppress a property page" },
{ WIA_PROPID.WIA_IPA_TYMED , "Media Type" },
{ WIA_PROPID.WIA_IPA_UPLOAD_ITEM_SIZE , "Upload Item Size" },
{ WIA_PROPID.WIA_IPC_AUDIO_AVAILABLE , "Audio Available" },
{ WIA_PROPID.WIA_IPC_AUDIO_DATA , "Audio Data" },
{ WIA_PROPID.WIA_IPC_AUDIO_DATA_FORMAT , "Audio Format" },
{ WIA_PROPID.WIA_IPC_NUM_PICT_PER_ROW , "Pictures per Row" },
{ WIA_PROPID.WIA_IPC_SEQUENCE , "Sequence Number" },
{ WIA_PROPID.WIA_IPC_THUMB_HEIGHT , "Thumbnail Height" },
{ WIA_PROPID.WIA_IPC_THUMB_WIDTH , "Thumbnail Width" },
{ WIA_PROPID.WIA_IPC_THUMBNAIL , "Thumbnail Data" },
{ WIA_PROPID.WIA_IPC_TIMEDELAY , "Time Delay" },
{ WIA_PROPID.WIA_IPS_ALARM , "Alarm" },
{ WIA_PROPID.WIA_IPS_AUTO_CROP , "Auto-Crop" },
{ WIA_PROPID.WIA_IPS_BARCODE_READER , "Barcode Reader" },
{ WIA_PROPID.WIA_IPS_BARCODE_SEARCH_DIRECTION , "Barcode Search Direction" },
{ WIA_PROPID.WIA_IPS_BARCODE_SEARCH_TIMEOUT , "Barcode Search Timeout" },
{ WIA_PROPID.WIA_IPS_BLANK_PAGES , "Blank Pages" },
{ WIA_PROPID.WIA_IPS_BLANK_PAGES_SENSITIVITY , "Blank Pages Sensitivity" },
{ WIA_PROPID.WIA_IPS_BRIGHTNESS , "Brightness" },
{ WIA_PROPID.WIA_IPS_COLOR_DROP , "Color Drop" },
{ WIA_PROPID.WIA_IPS_COLOR_DROP_BLUE , "Color Drop Blue" },
{ WIA_PROPID.WIA_IPS_COLOR_DROP_GREEN , "Color Drop Green" },
{ WIA_PROPID.WIA_IPS_COLOR_DROP_MULTI , "Color Drop Multiple" },
{ WIA_PROPID.WIA_IPS_COLOR_DROP_RED , "Color Drop Red" },
{ WIA_PROPID.WIA_IPS_CONTRAST , "Contrast" },
{ WIA_PROPID.WIA_IPS_CUR_INTENT , "Current Intent" },
{ WIA_PROPID.WIA_IPS_DESKEW_X , "DeskewX" },
{ WIA_PROPID.WIA_IPS_DESKEW_Y , "DeskewY" },
{ WIA_PROPID.WIA_IPS_ENABLED_BARCODE_TYPES , "Enabled Barcode Types" },
{ WIA_PROPID.WIA_IPS_ENABLED_PATCH_CODE_TYPES , "Enabled Path Code Types" },
{ WIA_PROPID.WIA_IPS_FEEDER_CONTROL , "Feeder Control" },
{ WIA_PROPID.WIA_IPS_FILM_NODE_NAME , "Film Node Name" },
{ WIA_PROPID.WIA_IPS_INVERT , "Invert" },
{ WIA_PROPID.WIA_IPS_JOB_SEPARATORS , "Job Separators" },
{ WIA_PROPID.WIA_IPS_LONG_DOCUMENT , "Long Document" },
{ WIA_PROPID.WIA_IPS_MAX_HORIZONTAL_SIZE , "Maximum Horizontal Scan Size" },
{ WIA_PROPID.WIA_IPS_MAX_VERTICAL_SIZE , "Maximum Vertical Scan Size" },
{ WIA_PROPID.WIA_IPS_MAXIMUM_BARCODE_SEARCH_RETRIES , "Barcode Search Retries" },
{ WIA_PROPID.WIA_IPS_MAXIMUM_BARCODES_PER_PAGE , "Maximum Barcodes Per Page" },
{ WIA_PROPID.WIA_IPS_MICR_READER , "MICR Reader" },
{ WIA_PROPID.WIA_IPS_MIN_HORIZONTAL_SIZE , "Minimum Horizontal Scan Size" },
{ WIA_PROPID.WIA_IPS_MIN_VERTICAL_SIZE , "Minimum Vertical Scan Size" },
{ WIA_PROPID.WIA_IPS_MIRROR , "Mirror" },
{ WIA_PROPID.WIA_IPS_MULTI_FEED , "Multi-Feed" },
{ WIA_PROPID.WIA_IPS_MULTI_FEED_DETECT_METHOD , "Multi-Feed Detection Method" },
{ WIA_PROPID.WIA_IPS_MULTI_FEED_SENSITIVITY , "Multi-Feed Sensitivity" },
{ WIA_PROPID.WIA_IPS_ORIENTATION , "Orientation" },
{ WIA_PROPID.WIA_IPS_OVER_SCAN , "Overscan" },
{ WIA_PROPID.WIA_IPS_OVER_SCAN_BOTTOM , "Overscan Bottom" },
{ WIA_PROPID.WIA_IPS_OVER_SCAN_LEFT , "Overscan Left" },
{ WIA_PROPID.WIA_IPS_OVER_SCAN_RIGHT , "Overscan Right" },
{ WIA_PROPID.WIA_IPS_OVER_SCAN_TOP , "Overscan Top" },
{ WIA_PROPID.WIA_IPS_PATCH_CODE_READER , "Patch Code Reader" },
{ WIA_PROPID.WIA_IPS_PHOTOMETRIC_INTERP , "Photometric Interpretation" },
{ WIA_PROPID.WIA_IPS_PREVIEW_TYPE , "Preview Type" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER , "Printer/Endorser" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_CHARACTER_ROTATION , "Printer/Endorser Character Rotation" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_COUNTER , "Printer/Endorser Counter" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_COUNTER_DIGITS , "Printer/Endorser Counter Digits" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_FONT_TYPE , "Printer/Endorser Font Type" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS , "Printer/Endorser Graphics" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_DOWNLOAD , "Printer/Endorser Graphics Download" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MAX_HEIGHT , "Printer/Endorser Graphics Maximum Height" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MAX_WIDTH , "Printer/Endorser Graphics Maximum Width" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MIN_HEIGHT , "Printer/Endorser Graphics Minimum Height" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MIN_WIDTH , "Printer/Endorser Graphics Minimum Width" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_POSITION , "Printer/Endorser Graphics Position" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_GRAPHICS_UPLOAD , "Printer/Endorser Graphics Upload" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_INK , "Printer/Endorser Ink" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_MAX_CHARACTERS , "Printer/Endorser Maximum Characters" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_MAX_GRAPHICS , "Printer/Endorser Maximum Graphics" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_NUM_LINES , "Printer/Endorser Lines" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_ORDER , "Printer/Endorser Order" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_PADDING , "Printer/Endorser Padding" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_STEP , "Printer/Endorser Step" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_STRING , "Printer/Endorser String" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_TEXT_DOWNLOAD , "Printer/Endorser Text Download" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_TEXT_UPLOAD , "Printer/Endorser Text Upload" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_VALID_CHARACTERS , "Printer/Endorser Valid Characters" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_VALID_FORMAT_SPECIFIERS , "Printer/Endorser Valid Format Specifiers" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_XOFFSET , "Printer/Endorser Horizontal Offset" },
{ WIA_PROPID.WIA_IPS_PRINTER_ENDORSER_YOFFSET , "Printer/Endorser Vertical Offset" },
{ WIA_PROPID.WIA_IPS_ROTATION , "Rotation" },
{ WIA_PROPID.WIA_IPS_SCAN_AHEAD , "Scan Ahead" },
{ WIA_PROPID.WIA_IPS_SCAN_AHEAD_CAPACITY , "Scan Ahead Capacity" },
{ WIA_PROPID.WIA_IPS_SEGMENTATION , "Segmentation" },
{ WIA_PROPID.WIA_IPS_SUPPORTED_BARCODE_TYPES , "Supported Barcode Types" },
{ WIA_PROPID.WIA_IPS_SUPPORTED_PATCH_CODE_TYPES , "Supported Patch Code Types" },
{ WIA_PROPID.WIA_IPS_SUPPORTS_CHILD_ITEM_CREATION , "Supports Child Item Creation" },
{ WIA_PROPID.WIA_IPS_THRESHOLD , "Threshold" },
{ WIA_PROPID.WIA_IPS_TRANSFER_CAPABILITIES , "Transfer Capabilities" },
{ WIA_PROPID.WIA_IPS_WARM_UP_TIME , "Lamp Warm up Time" },
{ WIA_PROPID.WIA_IPS_XEXTENT , "Horizontal Extent" },
{ WIA_PROPID.WIA_IPS_XPOS , "Horizontal Start Position" },
{ WIA_PROPID.WIA_IPS_XRES , "Horizontal Resolution" },
{ WIA_PROPID.WIA_IPS_XSCALING , "Horizontal Scaling" },
{ WIA_PROPID.WIA_IPS_YEXTENT , "Vertical Extent" },
{ WIA_PROPID.WIA_IPS_YPOS , "Vertical Start Position" },
{ WIA_PROPID.WIA_IPS_YRES , "Vertical Resolution" },
{ WIA_PROPID.WIA_IPS_YSCALING , "Vertical Scaling" },
};
/// <summary>IWiaDataCallback and IWiaMiniDrvCallBack message ID constants</summary>
[PInvokeData("wiadef.h")]
public enum IT_MSG
{
/// <summary>The application is receiving a header prior to receiving the actual data.</summary>
IT_MSG_DATA_HEADER = 0x0001,
/// <summary>The WIA system is transferring data to the application.</summary>
IT_MSG_DATA = 0x0002,
/// <summary>This invocation of the callback is sending only status information.</summary>
IT_MSG_STATUS = 0x0003,
/// <summary>The data transfer is complete.</summary>
IT_MSG_TERMINATION = 0x0004,
/// <summary>The data transfer is beginning a new page.</summary>
IT_MSG_NEW_PAGE = 0x0005,
/// <summary>The WIA system is transferring preview data to the application.</summary>
IT_MSG_FILE_PREVIEW_DATA = 0x0006,
/// <summary>The application is receiving a header prior to receiving the actual preview data.</summary>
IT_MSG_FILE_PREVIEW_DATA_HEADER = 0x0007,
/// <summary>Windows Vista or later. Status at the device has changed.</summary>
IT_MSG_DEVICE_STATUS = 8
}
/// <summary>IWiaDataCallback and IWiaMiniDrvCallBack status flag constants</summary>
[PInvokeData("wiadef.h")]
[Flags]
public enum IT_STATUS
{
/// <summary>Data is currently being transferred from the WIA device.</summary>
IT_STATUS_TRANSFER_FROM_DEVICE = 0x0001,
/// <summary>Data is currently being processed.</summary>
IT_STATUS_PROCESSING_DATA = 0x0002,
/// <summary>Data is currently being transferred to the client's data buffer.</summary>
IT_STATUS_TRANSFER_TO_CLIENT = 0x0004,
/// <summary>Mask</summary>
IT_STATUS_MASK = 0x0007,
}
/// <summary>WIA property identifiers.</summary>
[PInvokeData("wiadef.h")]
public enum WIA_PROPID : uint
{
/// <summary>Unique Device ID</summary>
WIA_DIP_DEV_ID = 2,
/// <summary>Manufacturer</summary>
WIA_DIP_VEND_DESC = 3,
/// <summary>Description</summary>
WIA_DIP_DEV_DESC = 4,
/// <summary>Type</summary>
WIA_DIP_DEV_TYPE = 5,
/// <summary>Port</summary>
WIA_DIP_PORT_NAME = 6,
/// <summary>Name</summary>
WIA_DIP_DEV_NAME = 7,
/// <summary>Server</summary>
WIA_DIP_SERVER_NAME = 8,
/// <summary>Remote Device ID</summary>
WIA_DIP_REMOTE_DEV_ID = 9,
/// <summary>UI Class ID</summary>
WIA_DIP_UI_CLSID = 10,
/// <summary>Hardware Configuration</summary>
WIA_DIP_HW_CONFIG = 11,
/// <summary>BaudRate</summary>
WIA_DIP_BAUDRATE = 12,
/// <summary>STI Generic Capabilities</summary>
WIA_DIP_STI_GEN_CAPABILITIES = 13,
/// <summary>WIA Version</summary>
WIA_DIP_WIA_VERSION = 14,
/// <summary>Driver Version</summary>
WIA_DIP_DRIVER_VERSION = 15,
/// <summary>PnP ID String</summary>
WIA_DIP_PNP_ID = 16,
/// <summary>STI Driver Version</summary>
WIA_DIP_STI_DRIVER_VERSION = 17,
/// <summary>Firmware Version</summary>
WIA_DPA_FIRMWARE_VERSION = 1026,
/// <summary>Connect Status</summary>
WIA_DPA_CONNECT_STATUS = 1027,
/// <summary>Device Time</summary>
WIA_DPA_DEVICE_TIME = 1028,
/// <summary>Pictures Taken</summary>
WIA_DPC_PICTURES_TAKEN = 2050,
/// <summary>Pictures Remaining</summary>
WIA_DPC_PICTURES_REMAINING = 2051,
/// <summary>Exposure Mode</summary>
WIA_DPC_EXPOSURE_MODE = 2052,
/// <summary>Exposure Compensation</summary>
WIA_DPC_EXPOSURE_COMP = 2053,
/// <summary>Exposure Time</summary>
WIA_DPC_EXPOSURE_TIME = 2054,
/// <summary>F Number</summary>
WIA_DPC_FNUMBER = 2055,
/// <summary>Flash Mode</summary>
WIA_DPC_FLASH_MODE = 2056,
/// <summary>Focus Mode</summary>
WIA_DPC_FOCUS_MODE = 2057,
/// <summary>Focus Manual Dist</summary>
WIA_DPC_FOCUS_MANUAL_DIST = 2058,
/// <summary>Zoom Position</summary>
WIA_DPC_ZOOM_POSITION = 2059,
/// <summary>Pan Position</summary>
WIA_DPC_PAN_POSITION = 2060,
/// <summary>Tilt Position</summary>
WIA_DPC_TILT_POSITION = 2061,
/// <summary>Timer Mode</summary>
WIA_DPC_TIMER_MODE = 2062,
/// <summary>Timer Value</summary>
WIA_DPC_TIMER_VALUE = 2063,
/// <summary>Power Mode</summary>
WIA_DPC_POWER_MODE = 2064,
/// <summary>Battery Status</summary>
WIA_DPC_BATTERY_STATUS = 2065,
/// <summary>Thumbnail Width</summary>
WIA_DPC_THUMB_WIDTH = 2066,
/// <summary>Thumbnail Height</summary>
WIA_DPC_THUMB_HEIGHT = 2067,
/// <summary>Picture Width</summary>
WIA_DPC_PICT_WIDTH = 2068,
/// <summary>Picture Height</summary>
WIA_DPC_PICT_HEIGHT = 2069,
/// <summary>Dimension</summary>
WIA_DPC_DIMENSION = 2070,
/// <summary>Compression Setting</summary>
WIA_DPC_COMPRESSION_SETTING = 2071,
/// <summary>Focus Metering Mode</summary>
WIA_DPC_FOCUS_METERING = 2072,
/// <summary>Timelapse Interval</summary>
WIA_DPC_TIMELAPSE_INTERVAL = 2073,
/// <summary>Timelapse Number</summary>
WIA_DPC_TIMELAPSE_NUMBER = 2074,
/// <summary>Burst Interval</summary>
WIA_DPC_BURST_INTERVAL = 2075,
/// <summary>Burst Number</summary>
WIA_DPC_BURST_NUMBER = 2076,
/// <summary>Effect Mode</summary>
WIA_DPC_EFFECT_MODE = 2077,
/// <summary>Digital Zoom</summary>
WIA_DPC_DIGITAL_ZOOM = 2078,
/// <summary>Sharpness</summary>
WIA_DPC_SHARPNESS = 2079,
/// <summary>Contrast</summary>
WIA_DPC_CONTRAST = 2080,
/// <summary>Capture Mode</summary>
WIA_DPC_CAPTURE_MODE = 2081,
/// <summary>Capture Delay</summary>
WIA_DPC_CAPTURE_DELAY = 2082,
/// <summary>Exposure Index</summary>
WIA_DPC_EXPOSURE_INDEX = 2083,
/// <summary>Exposure Metering Mode</summary>
WIA_DPC_EXPOSURE_METERING_MODE = 2084,
/// <summary>Focus Metering Mode</summary>
WIA_DPC_FOCUS_METERING_MODE = 2085,
/// <summary>Focus Distance</summary>
WIA_DPC_FOCUS_DISTANCE = 2086,
/// <summary>Focus Length</summary>
WIA_DPC_FOCAL_LENGTH = 2087,
/// <summary>RGB Gain</summary>
WIA_DPC_RGB_GAIN = 2088,
/// <summary>White Balance</summary>
WIA_DPC_WHITE_BALANCE = 2089,
/// <summary>Upload URL</summary>
WIA_DPC_UPLOAD_URL = 2090,
/// <summary>Artist</summary>
WIA_DPC_ARTIST = 2091,
/// <summary>Copyright Info</summary>
WIA_DPC_COPYRIGHT_INFO = 2092,
/// <summary>Horizontal Bed Size</summary>
WIA_DPS_HORIZONTAL_BED_SIZE = 3074,
/// <summary>Vertical Bed Size</summary>
WIA_DPS_VERTICAL_BED_SIZE = 3075,
/// <summary>Horizontal Sheet Feed Size</summary>
WIA_DPS_HORIZONTAL_SHEET_FEED_SIZE = 3076,
/// <summary>Vertical Sheet Feed Size</summary>
WIA_DPS_VERTICAL_SHEET_FEED_SIZE = 3077,
/// <summary>Sheet Feeder Registration</summary>
WIA_DPS_SHEET_FEEDER_REGISTRATION = 3078,
/// <summary>Horizontal Bed Registration</summary>
WIA_DPS_HORIZONTAL_BED_REGISTRATION = 3079,
/// <summary>Vertical Bed Registration</summary>
WIA_DPS_VERTICAL_BED_REGISTRATION = 3080,
/// <summary>Platen Color</summary>
WIA_DPS_PLATEN_COLOR = 3081,
/// <summary>Pad Color</summary>
WIA_DPS_PAD_COLOR = 3082,
/// <summary>Filter Select</summary>
WIA_DPS_FILTER_SELECT = 3083,
/// <summary>Dither Select</summary>
WIA_DPS_DITHER_SELECT = 3084,
/// <summary>Dither Pattern Data</summary>
WIA_DPS_DITHER_PATTERN_DATA = 3085,
/// <summary>Document Handling Capabilities</summary>
WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES = 3086,
/// <summary>Document Handling Status</summary>
WIA_DPS_DOCUMENT_HANDLING_STATUS = 3087,
/// <summary>Document Handling Select</summary>
WIA_DPS_DOCUMENT_HANDLING_SELECT = 3088,
/// <summary>Document Handling Capacity</summary>
WIA_DPS_DOCUMENT_HANDLING_CAPACITY = 3089,
/// <summary>Horizontal Optical Resolution</summary>
WIA_DPS_OPTICAL_XRES = 3090,
/// <summary>Vertical Optical Resolution</summary>
WIA_DPS_OPTICAL_YRES = 3091,
/// <summary>Endorser Characters</summary>
WIA_DPS_ENDORSER_CHARACTERS = 3092,
/// <summary>Endorser String</summary>
WIA_DPS_ENDORSER_STRING = 3093,
/// <summary>Scan Ahead Pages</summary>
WIA_DPS_SCAN_AHEAD_PAGES = 3094,
/// <summary>Max Scan Time</summary>
WIA_DPS_MAX_SCAN_TIME = 3095,
/// <summary>Pages</summary>
WIA_DPS_PAGES = 3096,
/// <summary>Page Size</summary>
WIA_DPS_PAGE_SIZE = 3097,
/// <summary>Page Width</summary>
WIA_DPS_PAGE_WIDTH = 3098,
/// <summary>Page Height</summary>
WIA_DPS_PAGE_HEIGHT = 3099,
/// <summary>Preview</summary>
WIA_DPS_PREVIEW = 3100,
/// <summary>Transparency Adapter</summary>
WIA_DPS_TRANSPARENCY = 3101,
/// <summary>Transparency Adapter Select</summary>
WIA_DPS_TRANSPARENCY_SELECT = 3102,
/// <summary>Show preview control</summary>
WIA_DPS_SHOW_PREVIEW_CONTROL = 3103,
/// <summary>Minimum Horizontal Sheet Feed Size</summary>
WIA_DPS_MIN_HORIZONTAL_SHEET_FEED_SIZE = 3104,
/// <summary>Minimum Vertical Sheet Feed Size</summary>
WIA_DPS_MIN_VERTICAL_SHEET_FEED_SIZE = 3105,
/// <summary>Transparency Adapter Capabilities</summary>
WIA_DPS_TRANSPARENCY_CAPABILITIES = 3106,
/// <summary>Transparency Adapter Status</summary>
WIA_DPS_TRANSPARENCY_STATUS = 3107,
/// <summary>Directory mount point</summary>
WIA_DPF_MOUNT_POINT = 3330,
/// <summary>Last Picture Taken</summary>
WIA_DPV_LAST_PICTURE_TAKEN = 3586,
/// <summary>Images Directory</summary>
WIA_DPV_IMAGES_DIRECTORY = 3587,
/// <summary>Directshow Device Path</summary>
WIA_DPV_DSHOW_DEVICE_PATH = 3588,
/// <summary>Item Name</summary>
WIA_IPA_ITEM_NAME = 4098,
/// <summary>Full Item Name</summary>
WIA_IPA_FULL_ITEM_NAME = 4099,
/// <summary>Item Time Stamp</summary>
WIA_IPA_ITEM_TIME = 4100,
/// <summary>Item Flags</summary>
WIA_IPA_ITEM_FLAGS = 4101,
/// <summary>Access Rights</summary>
WIA_IPA_ACCESS_RIGHTS = 4102,
/// <summary>Data Type</summary>
WIA_IPA_DATATYPE = 4103,
/// <summary>Bits Per Pixel</summary>
WIA_IPA_DEPTH = 4104,
/// <summary>Preferred Format</summary>
WIA_IPA_PREFERRED_FORMAT = 4105,
/// <summary>Format</summary>
WIA_IPA_FORMAT = 4106,
/// <summary>Compression</summary>
WIA_IPA_COMPRESSION = 4107,
/// <summary>Media Type</summary>
WIA_IPA_TYMED = 4108,
/// <summary>Channels Per Pixel</summary>
WIA_IPA_CHANNELS_PER_PIXEL = 4109,
/// <summary>Bits Per Channel</summary>
WIA_IPA_BITS_PER_CHANNEL = 4110,
/// <summary>Planar</summary>
WIA_IPA_PLANAR = 4111,
/// <summary>Pixels Per Line</summary>
WIA_IPA_PIXELS_PER_LINE = 4112,
/// <summary>Bytes Per Line</summary>
WIA_IPA_BYTES_PER_LINE = 4113,
/// <summary>Number of Lines</summary>
WIA_IPA_NUMBER_OF_LINES = 4114,
/// <summary>Gamma Curves</summary>
WIA_IPA_GAMMA_CURVES = 4115,
/// <summary>Item Size</summary>
WIA_IPA_ITEM_SIZE = 4116,
/// <summary>Color Profiles</summary>
WIA_IPA_COLOR_PROFILE = 4117,
/// <summary>Buffer Size</summary>
WIA_IPA_MIN_BUFFER_SIZE = 4118,
/// <summary>Buffer Size</summary>
WIA_IPA_BUFFER_SIZE = 4118,
/// <summary>Region Type</summary>
WIA_IPA_REGION_TYPE = 4119,
/// <summary>Color Profile Name</summary>
WIA_IPA_ICM_PROFILE_NAME = 4120,
/// <summary>Application Applies Color Mapping</summary>
WIA_IPA_APP_COLOR_MAPPING = 4121,
/// <summary>Stream Compatibility ID</summary>
WIA_IPA_PROP_STREAM_COMPAT_ID = 4122,
/// <summary>Filename extension</summary>
WIA_IPA_FILENAME_EXTENSION = 4123,
/// <summary>Suppress a property page</summary>
WIA_IPA_SUPPRESS_PROPERTY_PAGE = 4124,
/// <summary>Thumbnail Data</summary>
WIA_IPC_THUMBNAIL = 5122,
/// <summary>Thumbnail Width</summary>
WIA_IPC_THUMB_WIDTH = 5123,
/// <summary>Thumbnail Height</summary>
WIA_IPC_THUMB_HEIGHT = 5124,
/// <summary>Audio Available</summary>
WIA_IPC_AUDIO_AVAILABLE = 5125,
/// <summary>Audio Format</summary>
WIA_IPC_AUDIO_DATA_FORMAT = 5126,
/// <summary>Audio Data</summary>
WIA_IPC_AUDIO_DATA = 5127,
/// <summary>Pictures per Row</summary>
WIA_IPC_NUM_PICT_PER_ROW = 5128,
/// <summary>Sequence Number</summary>
WIA_IPC_SEQUENCE = 5129,
/// <summary>Time Delay</summary>
WIA_IPC_TIMEDELAY = 5130,
/// <summary>Current Intent</summary>
WIA_IPS_CUR_INTENT = 6146,
/// <summary>Horizontal Resolution</summary>
WIA_IPS_XRES = 6147,
/// <summary>Vertical Resolution</summary>
WIA_IPS_YRES = 6148,
/// <summary>Horizontal Start Position</summary>
WIA_IPS_XPOS = 6149,
/// <summary>Vertical Start Position</summary>
WIA_IPS_YPOS = 6150,
/// <summary>Horizontal Extent</summary>
WIA_IPS_XEXTENT = 6151,
/// <summary>Vertical Extent</summary>
WIA_IPS_YEXTENT = 6152,
/// <summary>Photometric Interpretation</summary>
WIA_IPS_PHOTOMETRIC_INTERP = 6153,
/// <summary>Brightness</summary>
WIA_IPS_BRIGHTNESS = 6154,
/// <summary>Contrast</summary>
WIA_IPS_CONTRAST = 6155,
/// <summary>Orientation</summary>
WIA_IPS_ORIENTATION = 6156,
/// <summary>Rotation</summary>
WIA_IPS_ROTATION = 6157,
/// <summary>Mirror</summary>
WIA_IPS_MIRROR = 6158,
/// <summary>Threshold</summary>
WIA_IPS_THRESHOLD = 6159,
/// <summary>Invert</summary>
WIA_IPS_INVERT = 6160,
/// <summary>Lamp Warm up Time</summary>
WIA_IPS_WARM_UP_TIME = 6161,
/// <summary>User Name</summary>
WIA_DPS_USER_NAME = 3112,
/// <summary>Service ID</summary>
WIA_DPS_SERVICE_ID = 3113,
/// <summary>Device ID</summary>
WIA_DPS_DEVICE_ID = 3114,
/// <summary>Global Identity</summary>
WIA_DPS_GLOBAL_IDENTITY = 3115,
/// <summary>Scan Available Item</summary>
WIA_DPS_SCAN_AVAILABLE_ITEM = 3116,
/// <summary>DeskewX</summary>
WIA_IPS_DESKEW_X = 6162,
/// <summary>DeskewY</summary>
WIA_IPS_DESKEW_Y = 6163,
/// <summary>Segmentation</summary>
WIA_IPS_SEGMENTATION = 6164,
/// <summary>Maximum Horizontal Scan Size</summary>
WIA_IPS_MAX_HORIZONTAL_SIZE = 6165,
/// <summary>Maximum Vertical Scan Size</summary>
WIA_IPS_MAX_VERTICAL_SIZE = 6166,
/// <summary>Minimum Horizontal Scan Size</summary>
WIA_IPS_MIN_HORIZONTAL_SIZE = 6167,
/// <summary>Minimum Vertical Scan Size</summary>
WIA_IPS_MIN_VERTICAL_SIZE = 6168,
/// <summary>Transfer Capabilities</summary>
WIA_IPS_TRANSFER_CAPABILITIES = 6169,
/// <summary>Sheet Feeder Registration</summary>
WIA_IPS_SHEET_FEEDER_REGISTRATION = 3078,
/// <summary>Document Handling Select</summary>
WIA_IPS_DOCUMENT_HANDLING_SELECT = 3088,
/// <summary>Horizontal Optical Resolution</summary>
WIA_IPS_OPTICAL_XRES = 3090,
/// <summary>Vertical Optical Resolution</summary>
WIA_IPS_OPTICAL_YRES = 3091,
/// <summary>Pages</summary>
WIA_IPS_PAGES = 3096,
/// <summary>Page Size</summary>
WIA_IPS_PAGE_SIZE = 3097,
/// <summary>Page Width</summary>
WIA_IPS_PAGE_WIDTH = 3098,
/// <summary>Page Height</summary>
WIA_IPS_PAGE_HEIGHT = 3099,
/// <summary>Preview</summary>
WIA_IPS_PREVIEW = 3100,
/// <summary>Show preview control</summary>
WIA_IPS_SHOW_PREVIEW_CONTROL = 3103,
/// <summary>Film Scan Mode</summary>
WIA_IPS_FILM_SCAN_MODE = 3104,
/// <summary>Lamp</summary>
WIA_IPS_LAMP = 3105,
/// <summary>Lamp Auto Off</summary>
WIA_IPS_LAMP_AUTO_OFF = 3106,
/// <summary>Automatic Deskew</summary>
WIA_IPS_AUTO_DESKEW = 3107,
/// <summary>Supports Child Item Creation</summary>
WIA_IPS_SUPPORTS_CHILD_ITEM_CREATION = 3108,
/// <summary>Horizontal Scaling</summary>
WIA_IPS_XSCALING = 3109,
/// <summary>Vertical Scaling</summary>
WIA_IPS_YSCALING = 3110,
/// <summary>Preview Type</summary>
WIA_IPS_PREVIEW_TYPE = 3111,
/// <summary>Item Category</summary>
WIA_IPA_ITEM_CATEGORY = 4125,
/// <summary>Upload Item Size</summary>
WIA_IPA_UPLOAD_ITEM_SIZE = 4126,
/// <summary>Items Stored</summary>
WIA_IPA_ITEMS_STORED = 4127,
/// <summary>Raw Bits Per Channel</summary>
WIA_IPA_RAW_BITS_PER_CHANNEL = 4128,
/// <summary>Film Node Name</summary>
WIA_IPS_FILM_NODE_NAME = 4129,
/// <summary>Printer/Endorser</summary>
WIA_IPS_PRINTER_ENDORSER = 4130,
/// <summary>Printer/Endorser Order</summary>
WIA_IPS_PRINTER_ENDORSER_ORDER = 4131,
/// <summary>Printer/Endorser Counter</summary>
WIA_IPS_PRINTER_ENDORSER_COUNTER = 4132,
/// <summary>Printer/Endorser Step</summary>
WIA_IPS_PRINTER_ENDORSER_STEP = 4133,
/// <summary>Printer/Endorser Horizontal Offset</summary>
WIA_IPS_PRINTER_ENDORSER_XOFFSET = 4134,
/// <summary>Printer/Endorser Vertical Offset</summary>
WIA_IPS_PRINTER_ENDORSER_YOFFSET = 4135,
/// <summary>Printer/Endorser Lines</summary>
WIA_IPS_PRINTER_ENDORSER_NUM_LINES = 4136,
/// <summary>Printer/Endorser String</summary>
WIA_IPS_PRINTER_ENDORSER_STRING = 4137,
/// <summary>Printer/Endorser Valid Characters</summary>
WIA_IPS_PRINTER_ENDORSER_VALID_CHARACTERS = 4138,
/// <summary>Printer/Endorser Valid Format Specifiers</summary>
WIA_IPS_PRINTER_ENDORSER_VALID_FORMAT_SPECIFIERS = 4139,
/// <summary>Printer/Endorser Text Upload</summary>
WIA_IPS_PRINTER_ENDORSER_TEXT_UPLOAD = 4140,
/// <summary>Printer/Endorser Text Download</summary>
WIA_IPS_PRINTER_ENDORSER_TEXT_DOWNLOAD = 4141,
/// <summary>Printer/Endorser Graphics</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS = 4142,
/// <summary>Printer/Endorser Graphics Position</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_POSITION = 4143,
/// <summary>Printer/Endorser Graphics Minimum Width</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MIN_WIDTH = 4144,
/// <summary>Printer/Endorser Graphics Maximum Width</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MAX_WIDTH = 4145,
/// <summary>Printer/Endorser Graphics Minimum Height</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MIN_HEIGHT = 4146,
/// <summary>Printer/Endorser Graphics Maximum Height</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_MAX_HEIGHT = 4147,
/// <summary>Printer/Endorser Graphics Upload</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_UPLOAD = 4148,
/// <summary>Printer/Endorser Graphics Download</summary>
WIA_IPS_PRINTER_ENDORSER_GRAPHICS_DOWNLOAD = 4149,
/// <summary>Barcode Reader</summary>
WIA_IPS_BARCODE_READER = 4150,
/// <summary>Maximum Barcodes Per Page</summary>
WIA_IPS_MAXIMUM_BARCODES_PER_PAGE = 4151,
/// <summary>Barcode Search Direction</summary>
WIA_IPS_BARCODE_SEARCH_DIRECTION = 4152,
/// <summary>Barcode Search Retries</summary>
WIA_IPS_MAXIMUM_BARCODE_SEARCH_RETRIES = 4153,
/// <summary>Barcode Search Timeout</summary>
WIA_IPS_BARCODE_SEARCH_TIMEOUT = 4154,
/// <summary>Supported Barcode Types</summary>
WIA_IPS_SUPPORTED_BARCODE_TYPES = 4155,
/// <summary>Enabled Barcode Types</summary>
WIA_IPS_ENABLED_BARCODE_TYPES = 4156,
/// <summary>Patch Code Reader</summary>
WIA_IPS_PATCH_CODE_READER = 4157,
/// <summary>Supported Patch Code Types</summary>
WIA_IPS_SUPPORTED_PATCH_CODE_TYPES = 4162,
/// <summary>Enabled Path Code Types</summary>
WIA_IPS_ENABLED_PATCH_CODE_TYPES = 4163,
/// <summary>MICR Reader</summary>
WIA_IPS_MICR_READER = 4164,
/// <summary>Job Separators</summary>
WIA_IPS_JOB_SEPARATORS = 4165,
/// <summary>Long Document</summary>
WIA_IPS_LONG_DOCUMENT = 4166,
/// <summary>Blank Pages</summary>
WIA_IPS_BLANK_PAGES = 4167,
/// <summary>Multi-Feed</summary>
WIA_IPS_MULTI_FEED = 4168,
/// <summary>Multi-Feed Sensitivity</summary>
WIA_IPS_MULTI_FEED_SENSITIVITY = 4169,
/// <summary>Auto-Crop</summary>
WIA_IPS_AUTO_CROP = 4170,
/// <summary>Overscan</summary>
WIA_IPS_OVER_SCAN = 4171,
/// <summary>Overscan Left</summary>
WIA_IPS_OVER_SCAN_LEFT = 4172,
/// <summary>Overscan Right</summary>
WIA_IPS_OVER_SCAN_RIGHT = 4173,
/// <summary>Overscan Top</summary>
WIA_IPS_OVER_SCAN_TOP = 4174,
/// <summary>Overscan Bottom</summary>
WIA_IPS_OVER_SCAN_BOTTOM = 4175,
/// <summary>Color Drop</summary>
WIA_IPS_COLOR_DROP = 4176,
/// <summary>Color Drop Red</summary>
WIA_IPS_COLOR_DROP_RED = 4177,
/// <summary>Color Drop Green</summary>
WIA_IPS_COLOR_DROP_GREEN = 4178,
/// <summary>Color Drop Blue</summary>
WIA_IPS_COLOR_DROP_BLUE = 4179,
/// <summary>Scan Ahead</summary>
WIA_IPS_SCAN_AHEAD = 4180,
/// <summary>Scan Ahead Capacity</summary>
WIA_IPS_SCAN_AHEAD_CAPACITY = 4181,
/// <summary>Feeder Control</summary>
WIA_IPS_FEEDER_CONTROL = 4182,
/// <summary>Printer/Endorser Padding</summary>
WIA_IPS_PRINTER_ENDORSER_PADDING = 4183,
/// <summary>Printer/Endorser Font Type</summary>
WIA_IPS_PRINTER_ENDORSER_FONT_TYPE = 4184,
/// <summary>Alarm</summary>
WIA_IPS_ALARM = 4185,
/// <summary>Printer/Endorser Ink</summary>
WIA_IPS_PRINTER_ENDORSER_INK = 4186,
/// <summary>Printer/Endorser Character Rotation</summary>
WIA_IPS_PRINTER_ENDORSER_CHARACTER_ROTATION = 4187,
/// <summary>Printer/Endorser Maximum Characters</summary>
WIA_IPS_PRINTER_ENDORSER_MAX_CHARACTERS = 4188,
/// <summary>Printer/Endorser Maximum Graphics</summary>
WIA_IPS_PRINTER_ENDORSER_MAX_GRAPHICS = 4189,
/// <summary>Printer/Endorser Counter Digits</summary>
WIA_IPS_PRINTER_ENDORSER_COUNTER_DIGITS = 4190,
/// <summary>Color Drop Multiple</summary>
WIA_IPS_COLOR_DROP_MULTI = 4191,
/// <summary>Blank Pages Sensitivity</summary>
WIA_IPS_BLANK_PAGES_SENSITIVITY = 4192,
/// <summary>Multi-Feed Detection Method</summary>
WIA_IPS_MULTI_FEED_DETECT_METHOD = 4193,
}
/// <summary>Selects the type of capabilities to enumerate in IWiaItem.EnumDeviceCapabilities.</summary>
[PInvokeData("wiadef.h")]
public enum WiaDevCap
{
/// <summary>Enumerate device commands.</summary>
WIA_DEVICE_COMMANDS = 1,
/// <summary>Enumerate device events.</summary>
WIA_DEVICE_EVENTS = 2
}
/// <summary>Options for IWiaItem.DeviceDlg.</summary>
[PInvokeData("wiadef.h")]
[Flags]
public enum WiaDevDlg
{
/// <summary>Restrict image selection to a single image in the device image acquisition dialog box.</summary>
WIA_DEVICE_DIALOG_SINGLE_IMAGE = 0x00000002,
/// <summary>
/// Use the system UI, if available, rather than the vendor-supplied UI. If the system UI is not available, the vendor UI is
/// used. If neither UI is available, the function returns E_NOTIMPL.
/// </summary>
WIA_DEVICE_DIALOG_USE_COMMON_UI = 0x00000004,
}
/// <summary>Image Intent Constants.</summary>
[PInvokeData("wiadef.h")]
[Flags]
public enum WiaImageIntent
{
/// <summary/>
WIA_INTENT_NONE = 0,
/// <summary>Preset properties for color content.</summary>
WIA_INTENT_IMAGE_TYPE_COLOR = 0x00000001,
/// <summary>Preset properties for grayscale content.</summary>
WIA_INTENT_IMAGE_TYPE_GRAYSCALE = 0x00000002,
/// <summary>Preset properties for text content.</summary>
WIA_INTENT_IMAGE_TYPE_TEXT = 0x00000004,
/// <summary>Preset properties to minimize image size.</summary>
WIA_INTENT_MINIMIZE_SIZE = 0x00010000,
/// <summary>Preset properties to maximize image quality.</summary>
WIA_INTENT_MAXIMIZE_QUALITY = 0x00020000,
/// <summary>Specifies the best quality preview.</summary>
WIA_INTENT_BEST_PREVIEW = 0x00040000,
}
/// <summary>Specify the Windows Image Acquisition (WIA) item type.</summary>
// https://docs.microsoft.com/en-us/windows/win32/wia/-wia-wia-item-type-flags
[PInvokeData("wiadef.h", MSDNShortId = "7961f692-088a-4f3b-84e9-5fabb0373c3c")]
public enum WiaItemType : uint
{
/// <summary>The item is uninitialized or has been deleted.</summary>
WiaItemTypeFree = 0x00000000,
/// <summary>The item is an image file. Only valid for items that also have the WiaItemTypeFile attribute.</summary>
WiaItemTypeImage = 0x00000001,
/// <summary>The item is a file.</summary>
WiaItemTypeFile = 0x00000002,
/// <summary>The item is a folder.</summary>
WiaItemTypeFolder = 0x00000004,
/// <summary>
/// Identifies the root item in the device's tree of item objects. This constant is supported only by Windows Vista and later.
/// </summary>
WiaItemTypeRoot = 0x00000008,
/// <summary>This item supports the IWiaItem::AnalyzeItem method. This constant is not supported by Windows Vista and later.</summary>
WiaItemTypeAnalyze = 0x00000010,
/// <summary>The item is an audio file. Only valid for items that also have the WiaItemTypeFile attribute.</summary>
WiaItemTypeAudio = 0x00000020,
/// <summary>The item represents a connected device.</summary>
WiaItemTypeDevice = 0x00000040,
/// <summary>The item is marked as deleted from the tree.</summary>
WiaItemTypeDeleted = 0x00000080,
/// <summary>The item represents a disconnected device.</summary>
WiaItemTypeDisconnected = 0x00000100,
/// <summary>The item represents a horizontal panoramic image. This constant is not supported by Windows Vista and later.</summary>
WiaItemTypeHPanorama = 0x00000200,
/// <summary>The item represents a vertical panoramic image. This constant is not supported by Windows Vista and later.</summary>
WiaItemTypeVPanorama = 0x00000400,
/// <summary>
/// For folders only. Images in this folder were taken in a continuous time sequence. This constant is not supported by Windows
/// Vista and later.
/// </summary>
WiaItemTypeBurst = 0x00000800,
/// <summary>The item represents a storage medium.</summary>
WiaItemTypeStorage = 0x00001000,
/// <summary>The item can be transferred.</summary>
WiaItemTypeTransfer = 0x00002000,
/// <summary>
/// This item was created by the application or the driver, and does not have a corresponding item in the driver item tree.
/// </summary>
WiaItemTypeGenerated = 0x00004000,
/// <summary>The item has file attachments. This constant is not supported by Windows Vista and later.</summary>
WiaItemTypeHasAttachments = 0x00008000,
/// <summary>
/// The item represents streaming video. This constant is not supported by either Windows Server 2003*,* Windows Vista*, or later.*
/// </summary>
WiaItemTypeVideo = 0x00010000,
/// <summary>
/// This type indicates that the WIA device is capable of receiving TWAIN capability data from the TWAIN compatibility layer. If
/// this type is set, any TWAIN capability that isn't understood by the TWAIN compatibility layer, during a TWAIN session, will
/// be passed to the WIA driver.
/// </summary>
WiaItemTypeTwainCapabilityPassThrough = 0x00020000,
/// <summary>The item has been removed from the device.</summary>
WiaItemTypeRemoved = 0x80000000,
/// <summary>The item represents a document. This constant is supported only by Windows Vista and later.</summary>
WiaItemTypeDocument = 0x00040000,
/// <summary>The item represents a programmable data source. This constant is supported only by Windows Vista and later.</summary>
WiaItemTypeProgrammableDataSource = 0x00080000,
}
/// <summary>
/// The <c>IEnumWIA_DEV_CAPS</c> interface enumerates the currently available Windows Image Acquisition (WIA) hardware device
/// capabilities. Device capabilities include commands and events that the device supports.
/// </summary>
/// <remarks>
/// <para>
/// The <c>IEnumWIA_DEV_CAPS</c> interface is a specific implementation for WIA of the standard OLE enumeration interface. For
/// details, see IEnumXXXX.
/// </para>
/// <para>
/// Applications obtain a pointer to the <c>IEnumWIA_DEV_CAPS</c> interface by invoking the IWiaItem::EnumDeviceCapabilities method.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-ienumwia_dev_caps
[PInvokeData("wia_xp.h")]
[ComImport, Guid("1fcc4287-aca6-11d2-a093-00c04f72dc3c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumWIA_DEV_CAPS : Vanara.Collections.ICOMEnum<WIA_DEV_CAP>
{
/// <summary>The <c>IEnumWIA_DEV_CAPS::Next</c> method fills an array of pointers to WIA_DEV_CAP structures.</summary>
/// <param name="celt">Specifies the number of array elements in the array indicated by the rgelt parameter.</param>
/// <param name="rgelt">Pointer to an array of WIA_DEV_CAP structures. IEnumWIA_DEV_CAPS::Next fills this array of structures.</param>
/// <param name="pceltFetched">
/// On output, this parameter contains the number of structure pointers actually stored in the array indicated by the rgelt parameter.
/// </param>
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
/// <remarks>
/// <para>
/// Applications use this method to query the capabilities of each available Windows Image Acquisition (WIA) hardware device. To
/// do so, the application passes a pointer to an array of WIA_DEV_CAP structures that it allocates. It also passes in the
/// number of array elements in the parameter celt. The <c>IEnumWIA_DEV_CAPS::Next</c> method fills the array with structures.
/// Applications then use the structures to enumerate WIA hardware device capabilities.
/// </para>
/// <para>
/// WIA device capabilities are defined as events and commands that the device supports. Using the rgelt array,
/// <c>IEnumWIA_DEV_CAPS::Next</c> passes a single structure to the application for each event and command that the device supports.
/// </para>
/// <para>
/// Note that <c>IEnumWIA_DEV_CAPS::Next</c> dynamically allocates the WIA_DEV_CAP structures it provides to applications.
/// Therefore, applications must delete the <c>WIA_DEV_CAP</c> structures they receive through the rgelt parameter. Applications
/// should use SysFreeString to free the bstrName, bstrDescription, and bstrIcon fields of all <c>WIA_DEV_CAP</c> structures.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_caps-next HRESULT Next( ULONG celt,
// WIA_DEV_CAP *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] WIA_DEV_CAP[] rgelt, out uint pceltFetched);
/// <summary>
/// The <c>IEnumWIA_DEV_CAPS::Skip</c> method skips the specified number of hardware device capabilities during an enumeration
/// of available device capabilities.
/// </summary>
/// <param name="celt">Specifies the number of items to skip.</param>
/// <returns>
/// If the method succeeds, the method returns S_OK. It returns S_FALSE if it could not skip the specified number of device
/// capabilities. If the method fails, it returns a standard COM error code.
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_caps-skip
[PreserveSig]
HRESULT Skip(uint celt);
/// <summary>The <c>IEnumWIA_DEV_CAPS::Reset</c> method is used by applications to restart the enumeration of device capabilities.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_caps-reset
void Reset();
/// <summary>
/// The <c>IEnumWIA_DEV_CAPS::Clone</c> method creates an additional instance of the IEnumWIA_DEV_CAPS interface and sends back
/// a pointer to it.
/// </summary>
/// <returns>Contains the address of a pointer to the instance of IEnumWIA_DEV_CAPS that IEnumWIA_DEV_CAPS::Clone creates.</returns>
/// <remarks>Applications must call the IUnknown::Release method on the pointers they receive through the ppIEnum parameter.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_caps-clone
IEnumWIA_DEV_CAPS Clone();
/// <summary>The <c>IEnumWIA_DEV_CAPS::GetCount</c> method returns the number of elements stored by this enumerator.</summary>
/// <returns>The number of elements in the enumeration.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_caps-getcount
uint GetCount();
}
/// <summary>
/// The <c>IEnumWIA_DEV_INFO</c> interface enumerates the currently available Windows Image Acquisition (WIA) hardware devices and
/// their properties. Device information properties describe the installation and configuration of WIA hardware devices.
/// </summary>
/// <remarks>
/// <para>
/// The <c>IEnumWIA_DEV_INFO</c> interface is a specific implementation for WIA of the standard OLE enumeration interface. For
/// details, see IEnumXXXX.
/// </para>
/// <para>Applications obtain a pointer to the <c>IEnumWIA_DEV_INFO</c> interface by invoking the IWiaDevMgr::EnumDeviceInfo method.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-ienumwia_dev_info
[PInvokeData("wia_xp.h")]
[ComImport, Guid("5e38b83c-8cf1-11d1-bf92-0060081ed811"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumWIA_DEV_INFO : Vanara.Collections.ICOMEnum<IWiaPropertyStorage>
{
/// <summary>The <c>IEnumWIA_DEV_INFO::Next</c> method fills an array of pointers to IWiaPropertyStorage interfaces.</summary>
/// <param name="celt">Specifies the number of array elements in the array indicated by the rgelt parameter.</param>
/// <param name="rgelt">
/// Receives the address of an array of IWiaPropertyStorage interface pointers. IEnumWIA_DEV_INFO::Next fills this array with
/// interface pointers.
/// </param>
/// <param name="pceltFetched">
/// On output, this parameter contains the number of interface pointers actually stored in the array indicated by the rgelt parameter.
/// </param>
/// <returns>
/// While there are devices left to enumerate, this method returns S_OK. It returns S_FALSE when the enumeration is finished. If
/// the method fails, it returns a standard COM error code.
/// </returns>
/// <remarks>
/// <para>
/// Applications use this method to query the properties of each available Windows Image Acquisition (WIA) hardware device. To
/// do so, the application passes an array of IWiaPropertyStorage interface pointers that it allocates. It also passes the
/// number of array elements in the parameter celt. The <c>IEnumWIA_DEV_INFO::Next</c> method fills the array with pointers to
/// <c>IWiaPropertyStorage</c> interfaces. Applications can query the interfaces for the properties that the device supports.
/// </para>
/// <para>Applications must call the IUnknown::Release method on the interface pointers they receive through the rgelt parameter.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_info-next HRESULT Next( ULONG celt,
// IWiaPropertyStorage **rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] IWiaPropertyStorage[] rgelt, out uint pceltFetched);
/// <summary>
/// The <c>IEnumWIA_DEV_INFO::Skip</c> method skips the specified number of hardware devices during an enumeration of available devices.
/// </summary>
/// <param name="celt">Specifies the number of devices to skip.</param>
/// <returns>
/// If the method succeeds, the method returns S_OK. If it is unable to skip the specified number of devices, it returns
/// S_FALSE. If the method fails, it returns a standard COM error code.
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_info-skip HRESULT Skip( ULONG celt );
[PreserveSig]
HRESULT Skip(uint celt);
/// <summary>The <c>IEnumWIA_DEV_INFO::Reset</c> method is used by applications to restart the enumeration of device information.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_info-reset HRESULT Reset();
void Reset();
/// <summary>
/// The <c>IEnumWIA_DEV_INFO::Clone</c> method creates an additional instance of the IEnumWIA_DEV_INFO interface and sends back
/// a pointer to it.
/// </summary>
/// <returns>
/// Pointer to an IEnumWIA_DEV_INFO interface. This parameter contains a pointer to the IEnumWIA_DEV_INFO interface instance
/// that IEnumWIA_DEV_INFO::Clone creates.
/// </returns>
/// <remarks>Applications must call the IUnknown::Release method on the pointers they receive through the ppIEnum parameter.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_info-clone HRESULT Clone( IEnumWIA_DEV_INFO
// **ppIEnum );
IEnumWIA_DEV_INFO Clone();
/// <summary>The <c>IEnumWIA_DEV_INFO::GetCount</c> method returns the number of elements stored by this enumerator.</summary>
/// <returns>The number of elements in the enumeration.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_info-getcount HRESULT GetCount( ULONG *celt );
uint GetCount();
}
/// <summary>Use the <c>IEnumWIA_FORMAT_INFO</c> interface to enumerate the format and media type information for a device.</summary>
/// <remarks>
/// <para>
/// The <c>IEnumWIA_FORMAT_INFO</c> interface is a specific implementation for Windows Image Acquisition (WIA) of the standard
/// Component Object Model (COM) enumeration interface. For details, see IEnumXXXX.
/// </para>
/// <para>
/// Applications obtain a pointer to the <c>IEnumWIA_FORMAT_INFO</c> interface by invoking the
/// IWiaDataTransfer::idtEnumWIA_FORMAT_INFO method of an item's IWiaDataTransfer interface.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-ienumwia_format_info
[PInvokeData("wia_xp.h")]
[ComImport, Guid("81BEFC5B-656D-44f1-B24C-D41D51B4DC81"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumWIA_FORMAT_INFO : Vanara.Collections.ICOMEnum<WIA_FORMAT_INFO>
{
/// <summary>The <c>IEnumWIA_FORMAT_INFO::Next</c> method returns an array of WIA_FORMAT_INFO structures.</summary>
/// <param name="celt">Specifies the number of elements requested.</param>
/// <param name="rgelt">Receives the address of the array of WIA_FORMAT_INFO structures.</param>
/// <param name="pceltFetched">
/// On output, receives the address of a ULONG that contains the number of WIA_FORMAT_INFO structures actually returned in the
/// rgelt parameter.
/// </param>
/// <returns>
/// If the enumeration is continuing, this method returns S_OK and sets the value pointed to by pceltFetched to the number of
/// capabilities returned. If the enumeration is complete, it returns S_FALSE and sets the value pointed to by pceltFetched to
/// zero. If the method fails, it returns a standard COM error.
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_format_info-next HRESULT Next( ULONG celt,
// WIA_FORMAT_INFO *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] WIA_FORMAT_INFO[] rgelt, out uint pceltFetched);
/// <summary>The <c>IEnumWIA_FORMAT_INFO::Skip</c> method skips the specified number of structures in the enumeration.</summary>
/// <param name="celt">Specifies the number of structures to skip.</param>
/// <returns>
/// This method returns S_OK if it is able to skip the specified number of elements. It returns S_FALSE if it is unable to skip
/// the specified number of elements. If the method fails, it returns a standard COM error.
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_format_info-skip HRESULT Skip( ULONG celt );
[PreserveSig]
HRESULT Skip(uint celt);
/// <summary>The <c>IEnumWIA_FORMAT_INFO::Reset</c> method sets the enumeration back to the first WIA_FORMAT_INFO structure.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_format_info-reset HRESULT Reset();
void Reset();
/// <summary>
/// The <c>IEnumWIA_FORMAT_INFO::Clone</c> method creates an additional instance of the IEnumWIA_FORMAT_INFO interface and
/// returns an interface pointer to the new interface.
/// </summary>
/// <returns>Pointer to a new IEnumWIA_FORMAT_INFO interface.</returns>
/// <remarks>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIEnum parameter.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_format_info-clone HRESULT Clone(
// IEnumWIA_FORMAT_INFO **ppIEnum );
IEnumWIA_DEV_INFO Clone();
/// <summary>The <c>IEnumWIA_FORMAT_INFO::GetCount</c> method returns the number of elements stored by this enumerator.</summary>
/// <returns>The number of elements in the enumeration.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_format_info-getcount HRESULT GetCount( ULONG
// *pcelt );
uint GetCount();
}
/// <summary>
/// <para>
/// The <c>IEnumWiaItem</c> interface is used by applications to enumerate IWiaItem objects in the tree's current folder. The
/// Windows Image Acquisition (WIA) run-time system represents every WIA hardware device to applications as a hierarchical tree of
/// <c>IWiaItem</c> objects.
/// </para>
/// <para><c>Note</c> For Windows Vista applications, use IEnumWiaItem2 instead of <c>IEnumWiaItem</c>.</para>
/// </summary>
/// <remarks>
/// <para>
/// The <c>IEnumWiaItem</c> interface is a specific implementation for WIA of the standard Component Object Model (COM) enumeration
/// interface. For details, see IEnumXXXX.
/// </para>
/// <para>Applications obtain a pointer to the <c>IEnumWiaItem</c> interface by invoking the IWiaItem::EnumChildItems method.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-ienumwiaitem
[PInvokeData("wia_xp.h")]
[ComImport, Guid("5e8383fc-3391-11d2-9a33-00c04fa36145"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumWiaItem : Vanara.Collections.ICOMEnum<IWiaItem>
{
/// <summary>The <c>IEnumWiaItem::Next</c> method fills an array of pointers to IWiaItem interfaces.</summary>
/// <param name="celt">Specifies the number of array elements in the array indicated by the ppIWiaItem parameter.</param>
/// <param name="rgelt">
/// Receives the address of an array of IWiaItem interface pointers. IEnumWiaItem::Next fills this array with interface pointers.
/// </param>
/// <param name="pceltFetched">
/// On output, this parameter receives the number of interface pointers actually stored in the array indicated by the ppIWiaItem
/// parameter. When the enumeration is complete, this parameter will contain zero.
/// </param>
/// <returns>
/// If the method succeeds, the method returns S_OK. When the enumeration is complete, it returns S_FALSE. If the method fails,
/// it returns a standard COM error code.
/// </returns>
/// <remarks>
/// <para>
/// The Windows Image Acquisition (WIA) run-time system represents WIA hardware devices as a hierarchical tree of IWiaItem
/// objects. Applications use the <c>IEnumWiaItem::Next</c> method to obtain an <c>IWiaItem</c> interface pointer for each item
/// in the current folder of a hardware device's <c>IWiaItem</c> object tree.
/// </para>
/// <para>
/// To obtain the list of pointers, the application passes an array of IWiaItem interface pointers that it allocates. It also
/// passes the number of array elements in the celt parameter. The <c>IEnumWiaItem::Next</c> method fills the array with
/// pointers to <c>IWiaItem</c> interfaces.
/// </para>
/// <para>
/// Until the enumeration process completes, the <c>IEnumWiaItem::Next</c> method returns S_OK. Each time it does, it sets the
/// value pointed to by pceltFetched to the number of items it inserted into the array. When <c>IEnumWiaItem::Next</c> finishes
/// the process of enumerating IWiaItem objects, it returns S_FALSE and sets the memory location pointed to by pceltFetched to zero.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIWiaItem parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwiaitem-next HRESULT Next( ULONG celt, IWiaItem
// **ppIWiaItem, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IWiaItem[] rgelt, out uint pceltFetched);
/// <summary>
/// The <c>IEnumWiaItem::Skip</c> method skips the specified number of items during an enumeration of available IWiaItem objects.
/// </summary>
/// <param name="celt">Specifies the number of items to skip.</param>
/// <returns>
/// If the method succeeds, the method returns S_OK. If it is unable to skip the specified number of items, it returns S_FALSE.
/// If the method fails, it returns a standard COM error code.
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwiaitem-skip HRESULT Skip( ULONG celt );
[PreserveSig]
HRESULT Skip(uint celt);
/// <summary>The <c>IEnumWiaItem::Reset</c> method is used by applications to restart the enumeration of item information.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwiaitem-reset HRESULT Reset();
void Reset();
/// <summary>
/// The <c>IEnumWiaItem::Clone</c> method creates an additional instance of the IEnumWiaItem interface and sends back a pointer
/// to it.
/// </summary>
/// <returns>
/// Pointer to the IEnumWiaItem interface. Receives the address of the IEnumWiaItem interface instance that IEnumWiaItem::Clone creates.
/// </returns>
/// <remarks>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIEnum parameter.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwiaitem-clone HRESULT Clone( IEnumWiaItem **ppIEnum );
IEnumWIA_DEV_INFO Clone();
/// <summary>The <c>IEnumWiaItem::GetCount</c> method returns the number of elements stored by this enumerator.</summary>
/// <returns>The number of elements in the enumeration.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwiaitem-getcount HRESULT GetCount( ULONG *celt );
uint GetCount();
}
/// <summary>
/// <para>
/// Provides an application callback mechanism during data transfers from Windows Image Acquisition (WIA) hardware devices to applications.
/// </para>
/// <para><c>Note</c> For Windows Vista applications, use IWiaTransferCallback instead of <c>IWiaDataCallback</c>.</para>
/// </summary>
/// <remarks>
/// <para>
/// The <c>IWiaDataCallback</c> interface, like all Component Object Model (COM) interfaces, inherits the IUnknown interface methods.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>IUnknown Methods</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>IUnknown::QueryInterface</term>
/// <term>Returns pointers to supported interfaces.</term>
/// </item>
/// <item>
/// <term>IUnknown::AddRef</term>
/// <term>Increments reference count.</term>
/// </item>
/// <item>
/// <term>IUnknown::Release</term>
/// <term>Decrements reference count.</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiadatacallback
[PInvokeData("wia_xp.h")]
[ComImport, Guid("a558a866-a5b0-11d2-a08f-00c04f72dc3c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaDataCallback
{
/// <summary>
/// Provides data transfer status notifications. Windows Image Acquisition (WIA) data transfer methods of the IWiaDataTransfer
/// interface periodically call this method.
/// </summary>
/// <param name="lMessage">
/// <para>Type: <c>int</c></para>
/// <para>Specifies a constant that indicates the reason for the callback. Can be one of the following values:</para>
/// <para>IT_MSG_DATA</para>
/// <para>The WIA system is transferring data to the application.</para>
/// <para>IT_MSG_DATA_HEADER</para>
/// <para>The application is receiving a header prior to receiving the actual data.</para>
/// <para>IT_MSG_DEVICE_STATUS</para>
/// <para>Windows Vista or later. Status at the device has changed.</para>
/// <para>IT_MSG_FILE_PREVIEW_DATA</para>
/// <para>The WIA system is transferring preview data to the application.</para>
/// <para>IT_MSG_FILE_PREVIEW_DATA_HEADER</para>
/// <para>The application is receiving a header prior to receiving the actual preview data.</para>
/// <para>IT_MSG_NEW_PAGE</para>
/// <para>The data transfer is beginning a new page.</para>
/// <para>IT_MSG_STATUS</para>
/// <para>This invocation of the callback is sending only status information.</para>
/// <para>IT_MSG_TERMINATION</para>
/// <para>The data transfer is complete.</para>
/// </param>
/// <param name="lStatus">
/// <para>Type: <c>int</c></para>
/// <para>Specifies a constant that indicates the status of the WIA device. Can be set to a combination of the following:</para>
/// <para>IT_STATUS_TRANSFER_FROM_DEVICE</para>
/// <para>Data is currently being transferred from the WIA device.</para>
/// <para>IT_STATUS_PROCESSING_DATA</para>
/// <para>Data is currently being processed.</para>
/// <para>IT_STATUS_TRANSFER_TO_CLIENT</para>
/// <para>Data is currently being transferred to the client's data buffer.</para>
/// </param>
/// <param name="lPercentComplete">
/// <para>Type: <c>int</c></para>
/// <para>Specifies the percentage of the total data that has been transferred so far.</para>
/// </param>
/// <param name="lOffset">
/// <para>Type: <c>int</c></para>
/// <para>Specifies an offset, in bytes, from the beginning of the buffer where the current band of data begins.</para>
/// </param>
/// <param name="lLength">
/// <para>Type: <c>int</c></para>
/// <para>Specifies the length, in bytes, of the current band of data.</para>
/// </param>
/// <param name="lReserved">
/// <para>Type: <c>int</c></para>
/// <para>Reserved for internal use by the WIA run-time system.</para>
/// </param>
/// <param name="lResLength">
/// <para>Type: <c>int</c></para>
/// <para>Reserved for internal use by the WIA run-time system.</para>
/// </param>
/// <param name="pbBuffer">
/// <para>Type: <c>BYTE*</c></para>
/// <para>Pointer to the data buffer.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>
/// If the method succeeds, the method returns S_OK. To cancel the data transfer, it returns S_FALSE. If the method fails, it
/// returns a standard COM error code.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// Your application must provide the <c>IWiaDataCallback::BandedDataCallback</c> method. This method is periodically invoked by
/// the data transfer methods of the IWiaDataTransfer interface. It provides status messages to the application during the data
/// transfer. By returning S_FALSE, your program can also use this method to prematurely terminate the data transfer.
/// </para>
/// <para>
/// When this method is invoked, the lMessage parameter will contain the reason for the call. Not all parameters will contain
/// data on all calls. For example, when <c>IWiaDataCallback::BandedDataCallback</c> is invoked with a message of
/// IT_MSG_TERMINATION, it should not attempt to use the values in the pbBuffer, lOffset, and lLength parameters.
/// </para>
/// <para>
/// If the value of lMessage is IT_MSG_DATA, the buffer pointed to by pbBuffer contains a band of image data. The lOffset
/// parameter contains an offset in bytes from the beginning of the buffer where the current band of data begins. The lLength
/// parameter specified the length in bytes of the current band of data.
/// </para>
/// <para>
/// During calls where lMessage is set to IT_MSG_DATA or IT_MSG_STATUS, the lStatus parameter contains a valid value. Its
/// contents should not be used when lMessage contains other values.
/// </para>
/// <para>If lMessage is IT_MSG_DATA_HEADER, the pbBuffer parameter points to a WIA_DATA_CALLBACK_HEADER structure.</para>
/// <para>
/// When an error has occurred during an image data transfer, the driver sets lMessage to IT_MSG_DEVICE_STATUS. The proxy
/// callback object calls ReportStatus, which handles the error and displays messages to the user.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows one possible way to implement the <c>IWiaDataCallback::BandedDataCallback</c> method.</para>
/// <para>
/// The example application code defines the <c>CDataCallback</c> object that it derives from the IWiaDataCallback interface.
/// The application must instantiate a <c>CDataCallback</c> object. It then calls <c>CDataCallback::QueryInterface</c> to obtain
/// an <c>IWiaDataCallback</c> interface pointer. When the application is ready to receive data, it invokes the idtGetBandedData
/// method and passes the method a pointer to the <c>IWiaDataCallback</c> interface.
/// </para>
/// <para>
/// Periodically, the idtGetBandedData method uses the IWiaDataCallback interface pointer to invoke the
/// <c>CDataCallback::BandedDataCallback</c> method of the application. The first invocations send status messages. These are
/// followed by a call that transfers a data header to the callback method. After the application receives the data header,
/// <c>idtGetBandedData</c> invokes <c>CDataCallback::BandedDataCallback</c> to transfer data to the application. When the data
/// transfer is complete, it calls the callback method a final time to transmit a termination message.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadatacallback-bandeddatacallback
[PreserveSig]
HRESULT BandedDataCallback(IT_MSG lMessage, IT_STATUS lStatus, int lPercentComplete, int lOffset, int lLength, [Optional] int lReserved, [Optional] int lResLength, IntPtr pbBuffer);
}
/// <summary>
/// <para>
/// The <c>IWiaDataTransfer</c> interface is a high performance data transfer interface. This interface supports a shared memory
/// window to transfer data from the device object to the application, and eliminates unnecessary data copies during marshalling. A
/// callback mechanism is provided in the form of the IWiaDataCallback interface. It enables applications to obtain data transfer
/// status notification, transfer data from the Windows Image Acquisition (WIA) device to the application, and cancel pending data transfers.
/// </para>
/// <para><c>Note</c> For Windows Vista applications, use IWiaTransfer instead of <c>IWiaDataTransfer</c>.</para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiadatatransfer
[PInvokeData("wia_xp.h")]
[ComImport, Guid("a6cef998-a5b0-11d2-a08f-00c04f72dc3c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaDataTransfer
{
/// <summary>
/// The <c>IWiaDataTransfer::idtGetData</c> method retrieves complete files from a Windows Image Acquisition (WIA) device.
/// </summary>
/// <param name="pMedium">
/// <para>Type: <c>LPSTGMEDIUM</c></para>
/// <para>Pointer to the STGMEDIUM structure.</para>
/// </param>
/// <param name="pIWiaDataCallback">
/// <para>Type: <c>IWiaDataCallback*</c></para>
/// <para>Pointer to the IWiaDataCallback interface.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>This method can return any one of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Return Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>One or more parameters to this method contain invalid data.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>This method cannot allocate enough memory to complete its operation.</term>
/// </item>
/// <item>
/// <term>E_UNEXPECTED</term>
/// <term>An unknown error occurred.</term>
/// </item>
/// <item>
/// <term>S_FALSE</term>
/// <term>The application canceled the operation.</term>
/// </item>
/// <item>
/// <term>S_OK</term>
/// <term>The image was successfully acquired.</term>
/// </item>
/// <item>
/// <term>STG_E_MEDIUMFULL</term>
/// <term>The storage medium the application is using to acquire the image is full.</term>
/// </item>
/// <item>
/// <term>WIA_S_NO_DEVICE_AVAILABLE</term>
/// <term>There are no WIA hardware devices attached to the user's computer.</term>
/// </item>
/// </list>
/// <para>
/// This method will return a value specified in Error Codes, or a standard COM error if it fails for any reason other than
/// those specified in the preceding table.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// In most respects, this method operates identically to the IDataObject::GetData method. The primary difference is that
/// <c>IWiaDataTransfer::idtGetData</c> provides an additional parameter for a pointer to the IWiaDataCallback interface.
/// Applications use this optional parameter to obtain status notifications during the data transfer. If no status notifications
/// are needed, it should be set to zero.
/// </para>
/// <para>
/// The format of the data transfer is determined by the values of the item's WIA_IPA_FORMAT and <c>WIA_IPA_TYMED</c>
/// properties. The application sets these properties with calls to the IWiaPropertyStorage::WriteMultiple method.
/// </para>
/// <para>
/// Unlike the IWiaDataTransfer::idtGetBandedData method, <c>IWiaDataTransfer::idtGetData</c> transfers a complete file from a
/// WIA device to an application rather than just a single band of data. The pMedium parameter is a pointer to the STGMEDIUM
/// structure which contains information on the storage medium to be used for the data transfer. Programs use the
/// pIWiaDataCallback parameter to pass this method a pointer to the IWiaDataCallback interface. Periodically, this method will
/// use the interface pointer to invoke the BandedDataCallback method and provide the application with status information about
/// the data transfer in progress.
/// </para>
/// <para>
/// Pass <c>NULL</c> as the value of the <c>lpszFileName</c> member of the pMedium structure to allow WIA to determine the file
/// name and location for the new file. Upon return, the <c>lpszFileName</c> member of the pMedium structure contains the
/// location and name of the new file.
/// </para>
/// <para>
/// If the value returned by this method is a COM SUCCESS value or the transfer is a multipage file transfer, and the error code
/// returned is WIA_ERROR_PAPER_JAM, WIA_ERROR_PAPER_EMPTY, or WIA_ERROR_PAPER_PROBLEM, WIA does not delete the file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadatatransfer-idtgetdata HRESULT idtGetData(
// LPSTGMEDIUM pMedium, IWiaDataCallback *pIWiaDataCallback );
[PreserveSig]
HRESULT idtGetData(ref STGMEDIUM pMedium, IWiaDataCallback pIWiaDataCallback);
/// <summary>
/// The <c>IWiaDataTransfer::idtGetBandedData</c> method transfers a band of data from a hardware device to an application. For
/// efficiency, applications retrieve data from Windows Image Acquisition (WIA) hardware devices in successive bands.
/// </summary>
/// <param name="pWiaDataTransInfo">
/// <para>Type: <c>PWIA_DATA_TRANSFER_INFO</c></para>
/// <para>Pointer to the WIA_DATA_TRANSFER_INFO structure.</para>
/// </param>
/// <param name="pIWiaDataCallback">
/// <para>Type: <c>IWiaDataCallback*</c></para>
/// <para>
/// Pointer to the IWiaDataCallback interface. Periodically, this method will call the BandedDataCallback method to provide the
/// application with data transfer status notification.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>This method can return any one of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Return Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>One or more parameters to this method contain invalid data.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>This method cannot allocate enough memory to complete its operation.</term>
/// </item>
/// <item>
/// <term>E_UNEXPECTED</term>
/// <term>An unknown error occurred.</term>
/// </item>
/// <item>
/// <term>S_FALSE</term>
/// <term>The application canceled the operation.</term>
/// </item>
/// <item>
/// <term>S_OK</term>
/// <term>The image was successfully acquired.</term>
/// </item>
/// <item>
/// <term>STG_E_MEDIUMFULL</term>
/// <term>The storage medium the application is using to acquire the image is full.</term>
/// </item>
/// <item>
/// <term>WIA_S_NO_DEVICE_AVAILABLE</term>
/// <term>There are no WIA hardware devices attached to the user's computer.</term>
/// </item>
/// </list>
/// <para>
/// This method will return a value specified in Error Codes, or a standard COM error if it fails for any reason other than
/// those specified in the preceding table.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>IWiaDataTransfer::idtGetBandedData</c> method allocates a section of memory to transfer data without requiring an
/// extra data copy through the Component Object Model/Remote Procedure Call (COM/RPC) marshalling layer. This memory section is
/// shared between the application and the hardware device's item tree.
/// </para>
/// <para>
/// Optionally, the application can pass in a pointer to a block of memory that <c>IWiaDataTransfer::idtGetBandedData</c> will
/// use as its shared section. The application passes this handle by storing the pointer in the <c>ulSection</c> member of the
/// WIA_DATA_TRANSFER_INFO structure prior to calling <c>IWiaDataTransfer::idtGetBandedData</c>.
/// </para>
/// <para>
/// Applications can improve performance by using double buffering. To do this, applications must set the <c>bDoubleBuffer</c>
/// member of the WIA_DATA_TRANSFER_INFO structure to <c>TRUE</c>. The <c>IWiaDataTransfer::idtGetBandedData</c> method will
/// divide the data buffer in half. When one half of the buffer is full, <c>IWiaDataTransfer::idtGetBandedData</c> will send a
/// notification to the application using the IWiaDataCallback pointer passed in through the pIWiaDataCallback parameter. While
/// the application is retrieving the data from the full half of the buffer, the device driver can fill the other half with data.
/// </para>
/// <para>
/// The format of the data transfer is determined by the values of the item's WIA_IPA_FORMAT and <c>WIA_IPA_TYMED</c>
/// properties. The application sets these properties with calls to the IWiaPropertyStorage::WriteMultiple method.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadatatransfer-idtgetbandeddata HRESULT
// idtGetBandedData( PWIA_DATA_TRANSFER_INFO pWiaDataTransInfo, IWiaDataCallback *pIWiaDataCallback );
[PreserveSig]
HRESULT idtGetBandedData(in WIA_DATA_TRANSFER_INFO pWiaDataTransInfo, IWiaDataCallback pIWiaDataCallback);
/// <summary>
/// The <c>IWiaDataTransfer::idtQueryGetData</c> method is used by applications to query a Windows Image Acquisition (WIA)
/// device to determine what types of data formats it supports.
/// </summary>
/// <param name="pfe">
/// <para>Type: <c>WIA_FORMAT_INFO*</c></para>
/// <para>Pointer to a WIA_FORMAT_INFO structure.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>
/// If this method succeeds, it returns S_OK. Otherwise it returns a value specified in Error Codes, or a standard COM error.
/// </para>
/// </returns>
/// <remarks>
/// This method queries a device to determine the data formats it supports. Prior to a data transfer, an application can fill in
/// the WIA_FORMAT_INFO structure with the intended medium and data format information. It then calls
/// <c>IWiaDataTransfer::idtQueryGetData</c> and receives a return value of S_OK if the data format and media type are supported
/// by this device.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadatatransfer-idtquerygetdata HRESULT idtQueryGetData(
// WIA_FORMAT_INFO *pfe );
void idtQueryGetData(in WIA_FORMAT_INFO pfe);
/// <summary>
/// The <c>IWiaDataTransfer::idtEnumWIA_FORMAT_INFO</c> method creates a banded transfer implementation of the
/// IEnumWIA_FORMAT_INFO interface.
/// </summary>
/// <returns>Receives the address of a pointer to the IEnumWIA_FORMAT_INFO interface.</returns>
/// <remarks>
/// <para>
/// This method creates the IEnumWIA_FORMAT_INFO interface that applications use to enumerate an array of WIA_FORMAT_INFO
/// structures. This provides applications with the ability to determine the formats and media types of incoming data when
/// transferring banded data.
/// </para>
/// <para>
/// Note that applications must call IUnknown::Release method on the interface pointers they receive through the ppEnum parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadatatransfer-idtenumwia_format_info HRESULT
// idtEnumWIA_FORMAT_INFO( IEnumWIA_FORMAT_INFO **ppEnum );
IEnumWIA_FORMAT_INFO idtEnumWIA_FORMAT_INFO();
/// <summary>
/// The <c>IWiaDataTransfer::idtGetExtendedTransferInfo</c> retrieves extended information relating to data transfer buffers in
/// the case of banded data transfers. Applications typically use this method to retrieve driver recommended settings for
/// minimum buffer size, maximum buffer size, and optimal buffer size for banded data transfers.
/// </summary>
/// <param name="pExtendedTransferInfo">
/// <para>Type: <c>PWIA_EXTENDED_TRANSFER_INFO</c></para>
/// <para>Pointer to a WIA_EXTENDED_TRANSFER_INFO structure containing the extended information.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadatatransfer-idtgetextendedtransferinfo HRESULT
// idtGetExtendedTransferInfo( PWIA_EXTENDED_TRANSFER_INFO pExtendedTransferInfo );
void idtGetExtendedTransferInfo(out WIA_EXTENDED_TRANSFER_INFO pExtendedTransferInfo);
}
/// <summary>
/// <para>
/// Applications use the <c>IWiaDevMgr</c> interface to create and manage image acquisition devices. They also use it to register to
/// receive device events.
/// </para>
/// <para><c>Note</c> For Windows Vista applications, use IWiaDevMgr2 instead of <c>IWiaDevMgr</c>.</para>
/// </summary>
/// <remarks>
/// <para>The <c>IWiaDevMgr</c> interface, like all Component Object Model (COM) interfaces, inherits the IUnknown interface methods.</para>
/// <list type="table">
/// <listheader>
/// <term>IUnknown Methods</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>IUnknown::QueryInterface</term>
/// <term>Returns pointers to supported interfaces.</term>
/// </item>
/// <item>
/// <term>IUnknown::AddRef</term>
/// <term>Increments reference count.</term>
/// </item>
/// <item>
/// <term>IUnknown::Release</term>
/// <term>Decrements reference count.</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiadevmgr
[PInvokeData("wia_xp.h")]
[ComImport, Guid("5eb2502a-8cf1-11d1-bf92-0060081ed811"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaDevMgr
{
/// <summary>
/// Applications use the <c>IWiaDevMgr::EnumDeviceInfo</c> method to enumerate property information for each available Windows
/// Image Acquisition (WIA) device.
/// </summary>
/// <param name="lFlag">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies the types of WIA devices to enumerate. Should be set to WIA_DEVINFO_ENUM_LOCAL.</para>
/// </param>
/// <returns>
/// <para>Type: <c>IEnumWIA_DEV_INFO**</c></para>
/// <para>Receives the address of a pointer to the IEnumWIA_DEV_INFO interface.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>IWiaDevMgr::EnumDeviceInfo</c> method creates an enumerator object, that supports the IEnumWIA_DEV_INFO interface.
/// <c>IWiaDevMgr::EnumDeviceInfo</c> stores a pointer to the <c>IEnumWIA_DEV_INFO</c> interface in the parameter ppIEnum.
/// Applications can use the <c>IEnumWIA_DEV_INFO</c> interface pointer to enumerate the properties of each WIA device attached
/// to the user's computer.
/// </para>
/// <para>Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIEnum parameter.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-enumdeviceinfo HRESULT EnumDeviceInfo( LONG
// lFlag, IEnumWIA_DEV_INFO **ppIEnum );
IEnumWIA_DEV_INFO EnumDeviceInfo(int lFlag);
/// <summary>
/// The <c>IWiaDevMgr::CreateDevice</c> creates a hierarchical tree of IWiaItem objects for a Windows Image Acquisition (WIA) device.
/// </summary>
/// <param name="bstrDeviceID">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the unique identifier of the WIA device.</para>
/// </param>
/// <returns>
/// <para>Type: <c>IWiaItem**</c></para>
/// <para>Pointer to a pointer to the IWiaItem interface of the root item in the hierarchical tree for the WIA device.</para>
/// </returns>
/// <remarks>
/// <para>
/// Applications use the <c>IWiaDevMgr::CreateDevice</c> method to create a device object for the WIA devices specified by the
/// bstrDeviceID parameter.
/// </para>
/// <para>
/// When it returns, the <c>IWiaDevMgr::CreateDevice</c> method stores an address of a pointer in the parameter ppWiaItemRoot.
/// The pointer points to the root item of the tree of IWiaItem objects created by <c>IWiaDevMgr::CreateDevice</c>. Applications
/// can use this tree of objects to control and retrieve data from the WIA device.
/// </para>
/// <para>
/// Note that applications must call the IUnknown::Release method on the pointers they receive through the ppWiaItemRoot parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-createdevice HRESULT CreateDevice( BSTR
// bstrDeviceID, IWiaItem **ppWiaItemRoot );
IWiaItem CreateDevice([MarshalAs(UnmanagedType.BStr)] string bstrDeviceID);
/// <summary>
/// The <c>IWiaDevMgr::SelectDeviceDlg</c> displays a dialog box that enables the user to select a hardware device for image acquisition.
/// </summary>
/// <param name="hwndParent">
/// <para>Type: <c>HWND</c></para>
/// <para>Handle of the window that owns the <c>Select Device</c> dialog box.</para>
/// </param>
/// <param name="lDeviceType">
/// <para>Type: <c>LONG</c></para>
/// <para>
/// Specifies which type of WIA device to use. Can be set to <c>StiDeviceTypeDefault</c>, <c>StiDeviceTypeScanner</c>, or <c>StiDeviceTypeDigitalCamera</c>.
/// </para>
/// </param>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies dialog box behavior. Can be set to any of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Constant</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>Use the default behavior.</term>
/// </item>
/// <item>
/// <term>WIA_SELECT_DEVICE_NODEFAULT</term>
/// <term>
/// Display the dialog box even if there is only one matching device. For more information, see the Remarks section of this
/// reference page.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="pbstrDeviceID">
/// <para>Type: <c>BSTR*</c></para>
/// <para>
/// On output, receives a string which contains the device's identifier string. On input, pass the address of a pointer if this
/// information is needed, or <c>NULL</c> if it is not needed.
/// </para>
/// </param>
/// <param name="ppItemRoot">
/// <para>Type: <c>IWiaItem**</c></para>
/// <para>
/// Receives the address of a pointer to the IWiaItem interface of the root item of the tree that represents the selected WIA
/// device. If no devices are found, it contains the value <c>NULL</c>.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>This method returns the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Return Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>A device was successfully selected.</term>
/// </item>
/// <item>
/// <term>S_FALSE</term>
/// <term>The user canceled the dialog box.</term>
/// </item>
/// <item>
/// <term>WIA_S_NO_DEVICE_AVAILABLE</term>
/// <term>There are no WIA hardware devices that match the specifications given in the lDeviceType parameter.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This method creates and displays the <c>Select Device</c> dialog box so the user can select a WIA device for image
/// acquisition. If a device is successfully selected, the <c>IWiaDevMgr::SelectDeviceDlg</c> method creates a hierarchical tree
/// of IWiaItem objects for the device. It stores a pointer to the <c>IWiaItem</c> interface of the root item in the parameter ppItemRoot.
/// </para>
/// <para>
/// Particular types of devices may be displayed to the user by specifying the device types through the lDeviceType parameter.
/// If only one device meets the specification, <c>IWiaDevMgr::SelectDeviceDlg</c> does not display the <c>Select Device</c>
/// dialog box. Instead it creates the IWiaItem tree for the device and store a pointer to the <c>IWiaItem</c> interface of the
/// root item in the parameter ppItemRoot. You can override this behavior and force <c>IWiaDevMgr::SelectDeviceDlg</c> to
/// display the <c>Select Device</c> dialog box by passing WIA_SELECT_DEVICE_NODEFAULT as the value for the lFlags parameter.
/// </para>
/// <para>
/// If more than one WIA device matches the specification, all matching devices are displayed in the <c>Select Device</c> dialog
/// box so the user may choose one.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppItemRoot parameter.
/// </para>
/// <para>
/// It is recommended that applications make device and image selection available through a menu item named <c>From scanner or
/// camera</c> on the <c>File</c> menu.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-selectdevicedlg HRESULT SelectDeviceDlg( HWND
// hwndParent, LONG lDeviceType, LONG lFlags, BSTR *pbstrDeviceID, IWiaItem **ppItemRoot );
[PreserveSig]
HRESULT SelectDeviceDlg(HWND hwndParent, int lDeviceType, int lFlags, [MarshalAs(UnmanagedType.BStr)] ref string pbstrDeviceID, out IWiaItem ppItemRoot);
/// <summary>
/// The <c>IWiaDevMgr::SelectDeviceDlgID</c> method displays a dialog box that enables the user to select a hardware device for
/// image acquisition.
/// </summary>
/// <param name="hwndParent">
/// <para>Type: <c>HWND</c></para>
/// <para>Handle of the window that owns the <c>Select Device</c> dialog box.</para>
/// </param>
/// <param name="lDeviceType">
/// <para>Type: <c>LONG</c></para>
/// <para>
/// Specifies which type of WIA device to use. Can be set to <c>StiDeviceTypeDefault</c>, <c>StiDeviceTypeScanner</c>, or <c>StiDeviceTypeDigitalCamera</c>.
/// </para>
/// </param>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies dialog box behavior. Can be set to any of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Constant</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>Use the default behavior.</term>
/// </item>
/// <item>
/// <term>WIA_SELECT_DEVICE_NODEFAULT</term>
/// <term>
/// Display the dialog box even if there is only one matching device. For more information, see the Remarks section of this
/// reference page.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="pbstrDeviceID">
/// <para>Type: <c>BSTR*</c></para>
/// <para>Pointer to a string that receives the identifier string of the device.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>This method returns the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Return Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>A device was successfully selected.</term>
/// </item>
/// <item>
/// <term>S_FALSE</term>
/// <term>The user canceled the dialog box.</term>
/// </item>
/// <item>
/// <term>WIA_S_NO_DEVICE_AVAILABLE</term>
/// <term>There are no WIA hardware devices attached to the user's computer that match the specifications.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This method works in a similar manner to IWiaDevMgr::SelectDeviceDlg. The primary difference is that if it finds a matching
/// device, it does not create the hierarchical tree of IWiaItem objects for the device.
/// </para>
/// <para>
/// Like IWiaDevMgr::SelectDeviceDlg, the <c>IWiaDevMgr::SelectDeviceDlgID</c> method creates and displays the <c>Select
/// Device</c> dialog box. This enables the user to select a WIA device for image acquisition. If a device is successfully
/// selected, the <c>IWiaDevMgr::SelectDeviceDlgID</c> method passes its identifier string to the application through its
/// pbstrDeviceID parameter.
/// </para>
/// <para>
/// Particular types of devices may be displayed to the user by specifying the device types through the lDeviceType parameter.
/// If only one device meets the specification, <c>IWiaDevMgr::SelectDeviceDlgID</c> does not display the <c>Select Device</c>
/// dialog box. Instead it passes the device's identifier string to the application without displaying the dialog box. You can
/// override this behavior and force <c>IWiaDevMgr::SelectDeviceDlgID</c> to display the <c>Select Device</c> dialog box by
/// passing WIA_SELECT_DEVICE_NODEFAULT as the value for the lFlags parameter.
/// </para>
/// <para>
/// If more than one WIA device matches the specification, all matching devices are displayed in the <c>Select Device</c> dialog
/// box so the user may choose one.
/// </para>
/// <para>
/// It is recommended that applications make device and image selection available through a menu item named <c>From scanner or
/// camera</c> on the <c>File</c> menu.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-selectdevicedlgid HRESULT SelectDeviceDlgID(
// HWND hwndParent, LONG lDeviceType, LONG lFlags, BSTR *pbstrDeviceID );
[PreserveSig]
HRESULT SelectDeviceDlgID(HWND hwndParent, int lDeviceType, int lFlags, [MarshalAs(UnmanagedType.BStr)] out string pbstrDeviceID);
/// <summary>
/// The <c>IWiaDevMgr::GetImageDlg</c> method displays one or more dialog boxes that enable a user to acquire an image from a
/// Windows Image Acquisition (WIA) device and write the image to a specified file. This method combines the functionality of
/// IWiaDevMgr::SelectDeviceDlg to completely encapsulate image acquisition within a single API call.
/// </summary>
/// <param name="hwndParent">
/// <para>Type: <c>HWND</c></para>
/// <para>Handle of the window that owns the <c>Get Image</c> dialog box.</para>
/// </param>
/// <param name="lDeviceType">
/// <para>Type: <c>LONG</c></para>
/// <para>
/// Specifies which type of WIA device to use. Is set to <c>StiDeviceTypeDefault</c>, <c>StiDeviceTypeScanner</c>, or <c>StiDeviceTypeDigitalCamera</c>.
/// </para>
/// </param>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies dialog box behavior. Can be set to the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Flag</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>Default behavior.</term>
/// </item>
/// <item>
/// <term>WIA_SELECT_DEVICE_NODEFAULT</term>
/// <term>
/// Force this method to display the Select Device dialog box. For more information, see the Remarks section of this reference page.
/// </term>
/// </item>
/// <item>
/// <term>WIA_DEVICE_DIALOG_SINGLE_IMAGE</term>
/// <term>Restrict image selection to a single image in the device image acquisition dialog box.</term>
/// </item>
/// <item>
/// <term>WIA_DEVICE_DIALOG_USE_COMMON_UI</term>
/// <term>
/// Use the system UI, if available, rather than the vendor-supplied UI. If the system UI is not available, the vendor UI is
/// used. If neither UI is available, the function returns E_NOTIMPL.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="lIntent">
/// <para>Type: <c>LONG</c></para>
/// <para>
/// Specifies what type of data the image is intended to represent. For a list of image intent values, see Image Intent Constants.
/// </para>
/// </param>
/// <param name="pItemRoot">
/// <para>Type: <c>IWiaItem*</c></para>
/// <para>Pointer to the interface of the hierarchical tree of IWiaItem objects returned by IWiaDevMgr::CreateDevice.</para>
/// </param>
/// <param name="bstrFilename">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the name of the file to which the image data is written.</para>
/// </param>
/// <param name="pguidFormat">
/// <para>Type: <c>GUID*</c></para>
/// <para>
/// On input, contains a pointer to a GUID that specifies the format to use. On output, holds the format used. Pass IID_NULL to
/// use the default format.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>
/// <c>IWiaDevMgr::GetImageDlg</c> returns S_FALSE if the user cancels the device selection or image acquisition dialog boxes,
/// WIA_S_NO_DEVICE_AVAILABLE if no WIA device is currently available, E_NOTIMPL if no UI is available, and S_OK if the data is
/// transferred successfully.
/// </para>
/// <para>
/// <c>IWiaDevMgr::GetImageDlg</c> returns a value specified in Error Codes, or a standard COM error if it fails for any reason
/// other than those specified.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// Invoking this method displays a dialog box that enables users to acquire images. It can also display the <c>Select
/// Device</c> dialog box created by the IWiaDevMgr::SelectDeviceDlg method.
/// </para>
/// <para>
/// If the application passes <c>NULL</c> for the value of the pItemRoot parameter, <c>IWiaDevMgr::GetImageDlg</c> displays the
/// <c>Select Device</c> dialog box that lets the user select the WIA input device. If the application specifies a WIA input
/// device by passing a pointer to the device's item tree through the pItemRoot parameter, <c>IWiaDevMgr::GetImageDlg</c> does
/// not display the <c>Select Device</c> dialog box. Instead, it will use the specified input device to acquire the image.
/// </para>
/// <para>
/// When using the <c>Select Device</c> dialog box, applications can specify types of WIA input devices. To do so, they must set
/// the pItemRoot parameter to <c>NULL</c> and pass the appropriate constants through the lDeviceType parameter. If more than
/// one device of the specified type is present, the <c>IWiaDevMgr::GetImageDlg</c> displays the <c>Select Device</c> dialog box
/// to let the user select which device will be used.
/// </para>
/// <para>
/// If <c>IWiaDevMgr::GetImageDlg</c> finds only one matching device, it will not display the <c>Select Device</c> dialog box.
/// Instead, it will select the matching device. You can override this behavior and force <c>IWiaDevMgr::GetImageDlg</c> to
/// display the <c>Select Device</c> dialog box by passing WIA_SELECT_DEVICE_NODEFAULT as the value for the lFlags parameter.
/// </para>
/// <para>
/// It is recommended that applications make device and image selection available through a menu item named <c>From scanner or
/// camera</c> on the <c>File</c> menu.
/// </para>
/// <para>
/// The dialog must have sufficient rights to the folder for bstrFilename that it can save the file with a unique file name. The
/// folder should also be protected with an access control list (ACL) because it contains user data.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-getimagedlg HRESULT GetImageDlg( HWND
// hwndParent, LONG lDeviceType, LONG lFlags, LONG lIntent, IWiaItem *pItemRoot, BSTR bstrFilename, GUID *pguidFormat );
[PreserveSig]
HRESULT GetImageDlg(HWND hwndParent, int lDeviceType, int lFlags, int lIntent, IWiaItem pItemRoot, [MarshalAs(UnmanagedType.BStr)] string bstrFilename, ref Guid pguidFormat);
/// <summary>
/// The <c>IWiaDevMgr::RegisterEventCallbackProgram</c> method registers an application to receive device events. It is
/// primarily provided for backward compatibility with applications that were not written for WIA.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies registration flags. Can be set to the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Registration Flag</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>WIA_REGISTER_EVENT_CALLBACK</term>
/// <term>Register for the event.</term>
/// </item>
/// <item>
/// <term>WIA_UNREGISTER_EVENT_CALLBACK</term>
/// <term>Delete the registration for the event.</term>
/// </item>
/// <item>
/// <term>WIA_SET_DEFAULT_HANDLER</term>
/// <term>Set the application as the default event handler.</term>
/// </item>
/// </list>
/// </param>
/// <param name="bstrDeviceID">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies a device identifier. Pass <c>NULL</c> to register for the event on all WIA devices.</para>
/// </param>
/// <param name="pEventGUID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>Specifies the event for which the application is registering. For a list of valid event GUIDs, see WIA Event Identifiers.</para>
/// </param>
/// <param name="bstrCommandline">
/// <para>Type: <c>BSTR</c></para>
/// <para>
/// Specifies a string that contains the full path name and the appropriate command-line arguments needed to invoke the
/// application. Two pairs of quotation marks should be used, for example, ""C:\Program Files\MyExe.exe" /arg1".
/// </para>
/// </param>
/// <param name="bstrName">
/// <para>Type: <c>BSTR</c></para>
/// <para>
/// Specifies the name of the application. This name is displayed to the user when multiple applications register for the same event.
/// </para>
/// </param>
/// <param name="bstrDescription">
/// <para>Type: <c>BSTR</c></para>
/// <para>
/// Specifies the description of the application. This description is displayed to the user when multiple applications register
/// for the same event.
/// </para>
/// </param>
/// <param name="bstrIcon">
/// <para>Type: <c>BSTR</c></para>
/// <para>
/// Specifies the icon that represents the application. The icon is displayed to the user when multiple applications register
/// for the same event. The string contains the name of the application and the 0-based index of the icon (there may be more
/// than one icon that represent application) separated by a comma. For example, "MyApp, 0".
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// Use <c>IWiaDevMgr::RegisterEventCallbackProgram</c> to register for hardware device events of the type WIA_ACTION_EVENT.
/// When an event occurs for which an application is registered, the application is launched and the event information is
/// transmitted to the application.
/// </para>
/// <para>
/// Applications use the EnumRegisterEventInfo method to retrieve a pointer to an enumerator object for event registration properties.
/// </para>
/// <para>
/// An application can find whether an event is an action type or notification type (or both) event by examinging the
/// <c>ulFlags</c> value of a WIA_DEV_CAP structure returned by event enumeration.
/// </para>
/// <para>
/// Programs should only use the <c>IWiaDevMgr::RegisterEventCallbackProgram</c> method for backward compatibility with
/// applications not written for the WIA architecture. New applications should use the Component Object Model (COM) interfaces
/// provided by the WIA architecture. Specifically, they should call IWiaDevMgr::RegisterEventCallbackInterface or
/// IWiaDevMgr::RegisterEventCallbackCLSID to register for device events.
/// </para>
/// <para>
/// Typically, this method is called by an install program or a script. The install program or script registers the application
/// to receive WIA device events. When the event occurs, the application will be started by the WIA run-time system.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-registereventcallbackprogram HRESULT
// RegisterEventCallbackProgram( LONG lFlags, BSTR bstrDeviceID, const GUID *pEventGUID, BSTR bstrCommandline, BSTR bstrName,
// BSTR bstrDescription, BSTR bstrIcon );
void RegisterEventCallbackProgram(int lFlags, [MarshalAs(UnmanagedType.BStr)] string bstrDeviceID, in Guid pEventGUID, [MarshalAs(UnmanagedType.BStr)] string bstrCommandline,
[MarshalAs(UnmanagedType.BStr)] string bstrName, [MarshalAs(UnmanagedType.BStr)] string bstrDescription, [MarshalAs(UnmanagedType.BStr)] string bstrIcon);
/// <summary>
/// The <c>IWiaDevMgr::RegisterEventCallbackInterface</c> method registers a running application Windows Image Acquisition (WIA)
/// event notification.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Currently unused. Should be set to zero.</para>
/// </param>
/// <param name="bstrDeviceID">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies a device identifier. Pass <c>NULL</c> to register for the event on all WIA devices.</para>
/// </param>
/// <param name="pEventGUID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>Specifies the event for which the application is registering. For a list of standard events, see WIA Event Identifiers.</para>
/// </param>
/// <param name="pIWiaEventCallback">
/// <para>Type: <c>IWiaEventCallback*</c></para>
/// <para>Pointer to the IWiaEventCallback interface that the WIA system used to send the event notification.</para>
/// </param>
/// <returns>
/// <para>Type: <c>IUnknown**</c></para>
/// <para>Receives the address of a pointer to the IUnknown interface.</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>Warning</c> Using the <c>IWiaDevMgr::RegisterEventCallbackInterface</c>, IWiaDevMgr2::RegisterEventCallbackInterface, and
/// DeviceManager.RegisterEvent methods from the same process after the Still Image Service is restarted may cause an access
/// violation, if the functions were used before the service was stopped.
/// </para>
/// <para>
/// When they begin executing, WIA applications use this method to register to receive hardware device events of the type
/// WIA_NOTIFICATION_EVENT. This prevents the application from being restarted when another event for which it is registered
/// occurs. Once a program invokes <c>IWiaDevMgr::RegisterEventCallbackInterface</c> to register itself to receive WIA events
/// from a device, the registered events are routed to the program by the WIA system.
/// </para>
/// <para>
/// Applications use the EnumRegisterEventInfo method to retrieve a pointer to an enumerator object for event registration properties.
/// </para>
/// <para>
/// An application can find whether an event is an action type or notification type (or both) event by examinging the
/// <c>ulFlags</c> value of a WIA_DEV_CAP structure returned by event enumeration.
/// </para>
/// <para>
/// Applications can unregister for events by using the IUnknown pointer returned through the pEventObject parameter to call the
/// IUnknown::Release method.
/// </para>
/// <para>
/// <c>Note</c> In a multi-threaded application, there is no guarantee that the event notification callback will come in on the
/// same thread that registered the callback.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-registereventcallbackinterface HRESULT
// RegisterEventCallbackInterface( LONG lFlags, BSTR bstrDeviceID, const GUID *pEventGUID, IWiaEventCallback
// *pIWiaEventCallback, IUnknown **pEventObject );
[return: MarshalAs(UnmanagedType.IUnknown)]
object RegisterEventCallbackInterface(int lFlags, [MarshalAs(UnmanagedType.BStr), Optional] string bstrDeviceID, in Guid pEventGUID, IWiaEventCallback pIWiaEventCallback);
/// <summary>
/// The <c>IWiaDevMgr::RegisterEventCallbackCLSID</c> method registers an application to receive events even if the application
/// may not be running.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies registration flags. Can be set to the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Registration Flag</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>WIA_REGISTER_EVENT_CALLBACK</term>
/// <term>Register for the event.</term>
/// </item>
/// <item>
/// <term>WIA_UNREGISTER_EVENT_CALLBACK</term>
/// <term>Delete the registration for the event.</term>
/// </item>
/// <item>
/// <term>WIA_SET_DEFAULT_HANDLER</term>
/// <term>Set the application as the default event handler.</term>
/// </item>
/// </list>
/// </param>
/// <param name="bstrDeviceID">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies a device identifier. Pass <c>NULL</c> to register for the event on all WIA devices.</para>
/// </param>
/// <param name="pEventGUID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>Specifies the event for which the application is registering. For a list of standard events, see WIA Event Identifiers.</para>
/// </param>
/// <param name="pClsID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>
/// Pointer to the application's class ID ( <c>CLSID</c>). The WIA run-time system uses the application's <c>CLSID</c> to start
/// the application when an event occurs for which it is registered.
/// </para>
/// </param>
/// <param name="bstrName">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the name of the application that registers for the event.</para>
/// </param>
/// <param name="bstrDescription">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies a text description of the application that registers for the event.</para>
/// </param>
/// <param name="bstrIcon">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the name of an image file to be used for the icon for the application that registers for the event.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// WIA applications use this method to register to receive hardware device events of the type WIA_ACTION_EVENT. Once programs
/// call <c>IWiaDevMgr::RegisterEventCallbackCLSID</c>, they are registered to receive WIA device events even if they are not running.
/// </para>
/// <para>
/// When the event occurs, the WIA system determines which application is registered to receive the event. It uses the
/// CoCreateInstance function and the class ID specified in the pClsID parameter to create an instance of the application. It
/// then calls the application's ImageEventCallback method to transmit the event information.
/// </para>
/// <para>An application can invoke the EnumRegisterEventInfo method to enumerate event registration information.</para>
/// <para>
/// An application can find whether an event is an action type or notification type (or both) event by examinging the
/// <c>ulFlags</c> value of a WIA_DEV_CAP structure returned by event enumeration.
/// </para>
/// <para>
/// If the application is not a registered Component Object Model (COM) component and is not compatible with the WIA
/// architecture, developers should use IWiaDevMgr::RegisterEventCallbackProgram instead of this method.
/// </para>
/// <para>
/// <c>Note</c> In a multi-threaded application, there is no guarantee that the event notification callback will come in on the
/// same thread that registered the callback.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-registereventcallbackclsid HRESULT
// RegisterEventCallbackCLSID( LONG lFlags, BSTR bstrDeviceID, const GUID *pEventGUID, const GUID *pClsID, BSTR bstrName, BSTR
// bstrDescription, BSTR bstrIcon );
void RegisterEventCallbackCLSID(int lFlags, [MarshalAs(UnmanagedType.BStr), Optional] string bstrDeviceID, in Guid pEventGUID, in Guid pClsID,
[MarshalAs(UnmanagedType.BStr)] string bstrName, [MarshalAs(UnmanagedType.BStr)] string bstrDescription, [MarshalAs(UnmanagedType.BStr)] string bstrIcon);
/// <summary>This method is not implemented.</summary>
/// <param name="hwndParent">Type: <c>HWND</c></param>
/// <param name="lFlags">Type: <c>LONG</c></param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiadevmgr-adddevicedlg HRESULT AddDeviceDlg( HWND
// hwndParent, LONG lFlags );
void AddDeviceDlg(HWND hwndParent, int lFlags);
}
/// <summary>
/// The <c>IWiaEventCallback</c> interface is used by applications to receive notification of Windows Image Acquisition (WIA)
/// hardware device events. An application registers itself to receive event notifications by passing a pointer to the
/// <c>IWiaEventCallback</c> interface to the IWiaDevMgr::RegisterEventCallbackInterface method.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiaeventcallback
[PInvokeData("wia_xp.h")]
[ComImport, Guid("ae6287b0-0084-11d2-973b-00a0c9068f2e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaEventCallback
{
/// <summary>
/// The <c>IWiaEventCallback::ImageEventCallback</c> method is invoked by the Windows Image Acquisition (WIA) run-time system
/// when a hardware device event occurs.
/// </summary>
/// <param name="pEventGUID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>Specifies the unique identifier of the event. For a complete list of device events, see WIA Event Identifiers.</para>
/// </param>
/// <param name="bstrEventDescription">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the string description of the event.</para>
/// </param>
/// <param name="bstrDeviceID">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the unique identifier of the WIA device.</para>
/// </param>
/// <param name="bstrDeviceDescription">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the string description of the device.</para>
/// </param>
/// <param name="dwDeviceType">
/// <para>Type: <c>DWORD</c></para>
/// <para>Specifies the type of the device. See WIA Device Type Specifiers for a list of possible values.</para>
/// </param>
/// <param name="bstrFullItemName">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the full name of the WIA item that represents the device.</para>
/// </param>
/// <param name="pulEventType">
/// <para>Type: <c>ULONG*</c></para>
/// <para>
/// Pointer to a <c>ULONG</c> that specifies whether an event is a notification event, an action event, or both. A value of 1
/// indicates a notification event, a value of 2 indicates an action event, and a value of 3 indicates that the event is of both
/// notification and action type.
/// </para>
/// </param>
/// <param name="ulReserved">
/// <para>Type: <c>ULONG</c></para>
/// <para>Reserved for user information.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// To receive notification of WIA hardware device events, applications pass a pointer to the IWiaEventCallback interface to the
/// RegisterEventCallbackInterface method. The WIA run-time system then uses that interface pointer to invoke the
/// <c>IWiaEventCallback::ImageEventCallback</c> method whenever a WIA hardware device event occurs.
/// </para>
/// <para>
/// Note that there is no guarantee the callback will be invoked on the same thread that registered the IWiaEventCallback interface.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaeventcallback-imageeventcallback HRESULT
// ImageEventCallback( const GUID *pEventGUID, BSTR bstrEventDescription, BSTR bstrDeviceID, BSTR bstrDeviceDescription, DWORD
// dwDeviceType, BSTR bstrFullItemName, ULONG *pulEventType, ULONG ulReserved );
void ImageEventCallback(in Guid pEventGUID, [MarshalAs(UnmanagedType.BStr)] string bstrEventDescription, [MarshalAs(UnmanagedType.BStr)] string bstrDeviceID,
[MarshalAs(UnmanagedType.BStr)] string bstrDeviceDescription, uint dwDeviceType, [MarshalAs(UnmanagedType.BStr)] string bstrFullItemName, ref uint pulEventType, uint ulReserved = 0);
}
/// <summary>
/// Each Windows Image Acquisition (WIA) hardware device is represented to an application as a hierarchical tree of <c>IWiaItem</c>
/// objects. The <c>IWiaItem</c> interface provides applications with the ability to query devices to discover their capabilities.
/// It also provides access to data transfer interfaces and item properties. In addition, the <c>IWiaItem</c> interface provides
/// methods to enable applications to control the device.
/// </summary>
/// <remarks>
/// <para>
/// Some of the methods of the <c>IWiaItem</c> interface are valid only on the root item of the device's tree. Other methods are
/// valid on all items. The methods are grouped as follows:
/// </para>
/// <list type="table">
/// <item>
/// <term>Valid On Root Item Only</term>
/// <term>IWiaItem::DeviceCommand</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::DeviceDlg</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::EnumDeviceCapabilities</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::EnumRegisterEventInfo</term>
/// </item>
/// <item>
/// <term>Valid On All Items</term>
/// <term>IWiaItem::AnalyzeItem</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::CreateChildItem</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::DeleteItem</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::EnumChildItems</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::FindItemByName</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::GetItemType</term>
/// </item>
/// <item>
/// <term/>
/// <term>IWiaItem::GetRootItem</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiaitem
[PInvokeData("wia_xp.h")]
[ComImport, Guid("4db1ad10-3391-11d2-9a33-00c04fa36145"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaItem
{
/// <summary>The <c>IWiaItem::GetItemType</c> method is called by applications to obtain the type information of an item.</summary>
/// <returns>
/// <para>Type: <c>LONG*</c></para>
/// <para>Receives the address of a <c>LONG</c> variable that contains a combination of WIA Item Type Flags.</para>
/// </returns>
/// <remarks>
/// <para>
/// Every IWiaItem object in the hierarchical tree of objects associated with a Windows Image Acquisition (WIA) hardware device
/// has a specific data type. Item objects represent folders and files. Folders contain file objects. File objects contain data
/// acquired by the device such as images and sounds. This method enables applications to identify the type of any item in a
/// hierarchical tree of item objects in a device.
/// </para>
/// <para>
/// An item may have more than one type. For example, an item that represents an audio file will have the type attributes
/// WiaItemTypeAudio | <c>WiaItemTypeFile</c>.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-getitemtype HRESULT GetItemType( LONG *pItemType );
WiaItemType GetItemType();
/// <summary>
/// The <c>IWiaItem::AnalyzeItem</c> method causes the Windows Image Acquisition (WIA) hardware device to acquire and try to
/// detect what data types are present.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Currently unused. Should be set to zero.</para>
/// </param>
/// <remarks>
/// <para>
/// This method is used with scanners to detect what type of data is on a page. When an application calls this method, the WIA
/// hardware device driver scans and analyzes the current page. For each data type it detects, it creates an IWiaItem object to
/// represent the region on the page the data occupies.
/// </para>
/// <para>
/// Image processing and OCR software can use this capability to detect graphics and text on a page. This method adds the
/// regions it creates into the WIA device's IWiaItem tree. The application can select the individual regions and use the
/// standard data transfer methods to acquire data from them.
/// </para>
/// <para>If necessary, applications can override the regions created by this method.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-analyzeitem HRESULT AnalyzeItem( LONG lFlags );
void AnalyzeItem(int lFlags = 0);
/// <summary>
/// The <c>IWiaItem::EnumChildItems</c> method creates an enumerator object and passes back a pointer to its IEnumWiaItem
/// interface for non-empty folders in a IWiaItem tree of a Windows Image Acquisition (WIA) device.
/// </summary>
/// <returns>
/// <para>Type: <c>IEnumWiaItem**</c></para>
/// <para>Receives the address of a pointer to the IEnumWiaItem interface that <c>IWiaItem::EnumChildItems</c> creates.</para>
/// </returns>
/// <remarks>
/// <para>
/// The WIA run-time system represents each WIA hardware device as a hierarchical tree of IWiaItem objects. The
/// <c>IWiaItem::EnumChildItems</c> method enables applications to enumerate child items in the current item. However, it can
/// only be applied to items that are folders.
/// </para>
/// <para>
/// If the folder is not empty, it contains a subtree of IWiaItem objects. The <c>IWiaItem::EnumChildItems</c> method enumerates
/// all of the items contained in the folder. It stores a pointer to an enumerator in the ppIEnumWiaItem parameter. Applications
/// use the enumerator pointer to perform the enumeration of an object's child items.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIEnumWiaItem parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-enumchilditems HRESULT EnumChildItems(
// IEnumWiaItem **ppIEnumWiaItem );
IEnumWiaItem EnumChildItems();
/// <summary>The <c>IWiaItem::DeleteItem</c> method removes the current IWiaItem object from the object tree of the device.</summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Currently unused. Should be set to zero.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>
/// This method returns S_OK regardless of how many items were deleted. If the method fails, it returns a standard COM error code.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// The Windows Image Acquisition (WIA) run-time system represents each WIA hardware device connected to the user's computer as
/// a hierarchical tree of IWiaItem objects. A given WIA device may or may not allow applications to delete <c>IWiaItem</c>
/// objects from its tree. Use the IEnumWIA_DEV_CAPS interface to query the device for item deletion capability.
/// </para>
/// <para>
/// If the device supports item deletion in its IWiaItem tree, invoke the <c>IWiaItem::DeleteItem</c> method to remove the
/// <c>IWiaItem</c> object. Note that this method will only delete an object after all references to the object have been released.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-deleteitem HRESULT DeleteItem( LONG lFlags );
void DeleteItem(int lFlags = 0);
/// <summary>
/// The <c>IWiaItem::CreateChildItem</c> method is used by applications to add IWiaItem objects to the <c>IWiaItem</c> tree of a device.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies the WIA item type. Must be set to one of the values listed in WIA Item Type Flags.</para>
/// </param>
/// <param name="bstrItemName">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the WIA item name, such as "Top". You can think of this parameter as being equivalent to a file name.</para>
/// </param>
/// <param name="bstrFullItemName">
/// <para>Type: <c>BSTR</c></para>
/// <para>
/// Specifies the full WIA item name. You can think of this parameter as equivalent to a full path to a file, such as "003\Root\Top".
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>IWiaItem**</c></para>
/// <para>Receives the address of a pointer to the IWiaItem interface that sets the <c>IWiaItem::CreateChildItem</c> method.</para>
/// </returns>
/// <remarks>
/// <para>
/// Some WIA hardware devices allow applications to create new items in the IWiaItem tree that represents the device.
/// Applications must test the devices to see if they support this capability. Use the IEnumWIA_DEV_CAPS interface to enumerate
/// the current device's capabilities.
/// </para>
/// <para>
/// If the device allows the creation of new items in the IWiaItem tree, invoking <c>IWiaItem::CreateChildItem</c> creates a new
/// <c>IWiaItem</c> that is a child of the current node. <c>IWiaItem::CreateChildItem</c> passes a pointer to the new node to
/// the application through the ppIWiaItem parameter.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIWiaItem parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-createchilditem HRESULT CreateChildItem( LONG
// lFlags, BSTR bstrItemName, BSTR bstrFullItemName, IWiaItem **ppIWiaItem );
IWiaItem CreateChildItem(WiaItemType lFlags, [MarshalAs(UnmanagedType.BStr)] string bstrItemName, [MarshalAs(UnmanagedType.BStr)] string bstrFullItemName);
/// <summary>
/// The <c>IWiaItem::EnumRegisterEventInfo</c> method creates an enumerator used to obtain information about events for which an
/// application is registered.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Currently unused. Should be set to zero.</para>
/// </param>
/// <param name="pEventGUID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>Pointer to an identifier that specifies the hardware event for which you want registration information.</para>
/// </param>
/// <returns>
/// <para>Type: <c>IEnumWIA_DEV_CAPS**</c></para>
/// <para>Receives the address of a pointer to the IEnumWIA_DEV_CAPS interface.</para>
/// </returns>
/// <remarks>
/// <para>
/// An application invokes this method to create an enumerator object for the event information.
/// <c>IWiaItem::EnumRegisterEventInfo</c> stores the address of the IEnumWIA_DEV_CAPS interface of the enumerator object in the
/// ppIEnum parameter. The program then uses the interface pointer to enumerate the properties of the event for which it is registered.
/// </para>
/// <para>
/// Each WIA_DEV_CAP structure includes an indication of whether the event is of type WIA_NOTIFICATION_EVENT or WIA_ACTION_EVENT
/// or both.
/// </para>
/// <para>Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIEnum parameter.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-enumregistereventinfo HRESULT
// EnumRegisterEventInfo( LONG lFlags, const GUID *pEventGUID, IEnumWIA_DEV_CAPS **ppIEnum );
IEnumWIA_DEV_CAPS EnumRegisterEventInfo([Optional] int lFlags, in Guid pEventGUID);
/// <summary>
/// The <c>IWiaItem::FindItemByName</c> method searches an item's tree of sub-items using the name as the search key. Each
/// IWiaItem object has a name as one of its standard properties.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Currently unused. Should be set to zero.</para>
/// </param>
/// <param name="bstrFullItemName">
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies the name of the item for which to search.</para>
/// </param>
/// <param name="ppIWiaItem">
/// <para>Type: <c>IWiaItem**</c></para>
/// <para>Pointer to the IWiaItem interface.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>
/// This method returns S_OK if it finds the item, or S_FALSE if it does not find the item. If the method fails, it returns a
/// standard COM error code.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// This method searches the current item's tree of sub-items using the name as the search key. If
/// <c>IWiaItem::FindItemByName</c> finds the item specified by bstrFullItemName, it stores the address of a pointer to the
/// IWiaItem interface of the item in the ppIWiaItem parameter.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIWiaItem parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-finditembyname HRESULT FindItemByName( LONG
// lFlags, BSTR bstrFullItemName, IWiaItem **ppIWiaItem );
[PreserveSig]
HRESULT FindItemByName([Optional] int lFlags, [MarshalAs(UnmanagedType.BStr)] string bstrFullItemName, out IWiaItem ppIWiaItem);
/// <summary>
/// The <c>IWiaItem::DeviceDlg</c> method is used by applications to display a dialog box to the user to prepare for image acquisition.
/// </summary>
/// <param name="hwndParent">
/// <para>Type: <c>HWND</c></para>
/// <para>Handle of the parent window of the dialog box.</para>
/// </param>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies a set of flags that control the dialog box's operation. Can be set to any of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Flag</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>Default behavior.</term>
/// </item>
/// <item>
/// <term>WIA_DEVICE_DIALOG_SINGLE_IMAGE</term>
/// <term>Restrict image selection to a single image in the device image acquisition dialog box.</term>
/// </item>
/// <item>
/// <term>WIA_DEVICE_DIALOG_USE_COMMON_UI</term>
/// <term>
/// Use the system UI, if available, rather than the vendor-supplied UI. If the system UI is not available, the vendor UI is
/// used. If neither UI is available, the function returns E_NOTIMPL.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="lIntent">
/// <para>Type: <c>LONG</c></para>
/// <para>
/// Specifies what type of data the image is intended to represent. For a list of image intent values, see Image Intent Constants.
/// </para>
/// <para><c>Note</c> This method ignores all WIA_INTENT_IMAGE_* image intents.</para>
/// </param>
/// <param name="plItemCount">
/// <para>Type: <c>LONG*</c></para>
/// <para>Receives the number of items in the array indicated by the ppIWiaItem parameter.</para>
/// </param>
/// <param name="ppIWiaItem">
/// <para>Type: <c>IWiaItem***</c></para>
/// <para>Receives the address of an array of pointers to IWiaItem interfaces.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// This method displays a dialog box to the user that an application uses to gather all the information required for image
/// acquisition. For instance, this dialog box enables the user to select images to download from a camera. When using a
/// scanner, it is also used to specify image scan properties such as brightness and contrast.
/// </para>
/// <para>After this method returns, the application can use the IWiaDataTransfer interface to acquire the image.</para>
/// <para>
/// Applications must call the IUnknown::Release method for each element in the array of interface pointers they receive through
/// the ppIWiaItem parameter. Applications must also free the array using CoTaskMemFree.
/// </para>
/// <para>
/// It is recommended that applications make device and image selection available through a menu item named <c>From scanner or
/// camera</c> on the <c>File</c> menu.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-devicedlg HRESULT DeviceDlg( HWND hwndParent,
// LONG lFlags, LONG lIntent, LONG *plItemCount, IWiaItem ***ppIWiaItem );
void DeviceDlg(HWND hwndParent, WiaDevDlg lFlags, WiaImageIntent lIntent, out int plItemCount, out SafeCoTaskMemHandle ppIWiaItem);
/// <summary>The <c>IWiaItem::DeviceCommand</c> issues a command to a Windows Image Acquisition (WIA) hardware device.</summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Currently unused. Should be set to zero.</para>
/// </param>
/// <param name="pCmdGUID">
/// <para>Type: <c>const GUID*</c></para>
/// <para>
/// Specifies a unique identifier that specifies the command to send to the WIA hardware device. For a list of valid device
/// commands, see WIA Device Commands.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>IWiaItem**</c></para>
/// <para>On output, this pointer points to the item created by the command, if any.</para>
/// </returns>
/// <remarks>
/// <para>Applications use this method to send WIA commands to hardware devices.</para>
/// <para>
/// When the application sends the WIA_CMD_TAKE_PICTURE command to the device, <c>IWiaItem::DeviceCommand</c>, the WIA run-time
/// system creates the IWiaItem object to represent the image. The <c>IWiaItem::DeviceCommand</c> method stores the address of
/// the interface in the pIWiaItem parameter.
/// </para>
/// <para>Applications must call the IUnknown::Release method on the interface pointers they receive through the pIWiaItem parameter.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-devicecommand HRESULT DeviceCommand( LONG
// lFlags, const GUID *pCmdGUID, IWiaItem **pIWiaItem );
IWiaItem DeviceCommand([Optional] int lFlags, in Guid pCmdGUID);
/// <summary>
/// The <c>IWiaItem::GetRootItem</c> method retrieves the root item of a tree of item objects used to represent a Windows Image
/// Acquisition (WIA) hardware device.
/// </summary>
/// <returns>
/// <para>Type: <c>IWiaItem**</c></para>
/// <para>
/// Receives the address of a pointer to the IWiaItem interface that contains a pointer to the <c>IWiaItem</c> interface of the
/// root item.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// Given any IWiaItem object in the object tree of a WIA hardware device, the application retrieves a pointer to the root item
/// by calling this function.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIWiaItem parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-getrootitem HRESULT GetRootItem( IWiaItem
// **ppIWiaItem );
IWiaItem GetRootItem();
/// <summary>
/// The <c>IWiaItem::EnumDeviceCapabilities</c> method creates an enumerator that is used to ascertain the commands and events a
/// Windows Image Acquisition (WIA) device supports.
/// </summary>
/// <param name="lFlags">
/// <para>Type: <c>LONG</c></para>
/// <para>Specifies a flag that selects the type of capabilities to enumerate. Can be set to one or more of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Flag</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>WIA_DEVICE_COMMANDS</term>
/// <term>Enumerate device commands.</term>
/// </item>
/// <item>
/// <term>WIA_DEVICE_EVENTS</term>
/// <term>Enumerate device events.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>Type: <c>IEnumWIA_DEV_CAPS**</c></para>
/// <para>Pointer to IEnumWIA_DEV_CAPS interface created by <c>IWiaItem::EnumDeviceCapabilities</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// Use this method to create an enumerator object to obtain the set of commands and events that a WIA device supports. You can
/// use the lFlags parameter to specify which kinds of device capabilities to enumerate. The
/// <c>IWiaItem::EnumDeviceCapabilities</c> method stores the address of the interface of the enumerator object in the
/// ppIEnumWIA_DEV_CAPS parameter.
/// </para>
/// <para>
/// Applications must call the IUnknown::Release method on the interface pointers they receive through the ppIEnumWIA_DEV_CAPS parameter.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-enumdevicecapabilities HRESULT
// EnumDeviceCapabilities( LONG lFlags, IEnumWIA_DEV_CAPS **ppIEnumWIA_DEV_CAPS );
IEnumWIA_DEV_CAPS EnumDeviceCapabilities(WiaDevCap lFlags);
/// <summary>This method is not supported.</summary>
/// <returns>Type: <c>BSTR*</c></returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-dumpitemdata HRESULT DumpItemData( BSTR
// *bstrData );
[return: MarshalAs(UnmanagedType.BStr)]
string DumpItemData();
/// <summary>This method is not supported.</summary>
/// <returns>Type: <c>BSTR*</c></returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-dumpdrvitemdata HRESULT DumpDrvItemData( BSTR
// *bstrData );
[return: MarshalAs(UnmanagedType.BStr)]
string DumpDrvItemData();
/// <summary>This method is not supported.</summary>
/// <returns>Type: <c>BSTR*</c></returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-dumptreeitemdata HRESULT DumpTreeItemData( BSTR
// *bstrData );
[return: MarshalAs(UnmanagedType.BStr)]
string DumpTreeItemData();
/// <summary>This method is not supported.</summary>
/// <param name="ulSize">Type: <c>ULONG</c></param>
/// <param name="pBuffer">Type: <c>BYTE*</c></param>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitem-diagnostic HRESULT Diagnostic( ULONG ulSize,
// BYTE *pBuffer );
void Diagnostic(uint ulSize, IntPtr pBuffer);
}
/// <summary>
/// The <c>IWiaItemExtras</c> interface provides several methods that enable applications to communicate with hardware drivers.
/// </summary>
/// <remarks>
/// <para>
/// The <c>IWiaItemExtras</c> interface, like all Component Object Model (COM) interfaces, inherits the IUnknown interface methods.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>IUnknown Methods</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>IUnknown::QueryInterface</term>
/// <term>Returns pointers to supported interfaces.</term>
/// </item>
/// <item>
/// <term>IUnknown::AddRef</term>
/// <term>Increments reference count.</term>
/// </item>
/// <item>
/// <term>IUnknown::Release</term>
/// <term>Decrements reference count.</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiaitemextras
[PInvokeData("wia_xp.h")]
[ComImport, Guid("6291ef2c-36ef-4532-876a-8e132593778d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaItemExtras
{
/// <summary>
/// The <c>IWiaItemExtras::GetExtendedErrorInfo</c> method gets a string from the device driver that contains information about
/// the most recent error. Call this method after an error during an operation on a Windows Image Acquisition (WIA) item (such
/// as data transfer).
/// </summary>
/// <returns>
/// <para>Type: <c>BSTR*</c></para>
/// <para>Pointer to a string that contains the error information.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitemextras-getextendederrorinfo HRESULT
// GetExtendedErrorInfo( BSTR *bstrErrorText );
[return: MarshalAs(UnmanagedType.BStr)]
string GetExtendedErrorInfo();
/// <summary>
/// The <c>IWiaItemExtras::Escape</c> method sends a request for a vendor-specific I/O operation to a still image device.
/// </summary>
/// <param name="dwEscapeCode">
/// <para>Type: <c>DWORD</c></para>
/// <para>Calling application-supplied, vendor-defined, DWORD-sized value that represents an I/O operation.</para>
/// </param>
/// <param name="lpInData">
/// <para>Type: <c>BYTE*</c></para>
/// <para>Pointer to a calling application-supplied buffer that contains data to be sent to the device.</para>
/// </param>
/// <param name="cbInDataSize">
/// <para>Type: <c>DWORD</c></para>
/// <para>Calling application-supplied length, in bytes, of the data contained in the buffer pointed to by lpInData.</para>
/// </param>
/// <param name="pOutData">
/// <para>Type: <c>BYTE*</c></para>
/// <para>Pointer to a calling application-supplied memory buffer to receive data from the device.</para>
/// </param>
/// <param name="dwOutDataSize">
/// <para>Type: <c>DWORD</c></para>
/// <para>Calling application-supplied length, in bytes, of the buffer pointed to by pOutData.</para>
/// </param>
/// <param name="pdwActualDataSize">
/// <para>Type: <c>DWORD*</c></para>
/// <para>Receives the number of bytes actually written to pOutData.</para>
/// </param>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitemextras-escape HRESULT Escape( DWORD dwEscapeCode,
// BYTE *lpInData, DWORD cbInDataSize, BYTE *pOutData, DWORD dwOutDataSize, DWORD *pdwActualDataSize );
void Escape(uint dwEscapeCode, IntPtr lpInData, uint cbInDataSize, IntPtr pOutData, uint dwOutDataSize, out uint pdwActualDataSize);
/// <summary>The <c>IWiaItemExtras::CancelPendingIO</c> method cancels all pending input/output operations on the driver.</summary>
/// <remarks>Drivers are not required to support this method.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitemextras-cancelpendingio HRESULT CancelPendingIO();
void CancelPendingIO();
}
/// <summary>
/// The <c>IWiaPropertyStorage</c> interface is used to access information about the IWiaItem object's properties. Applications must
/// query an item to obtain its <c>IWiaPropertyStorage</c> interface.
/// </summary>
/// <remarks>
/// <para>
/// The <c>IWiaPropertyStorage</c> interface includes several methods that are very similar to the following methods from the <see
/// cref="IPropertyStorage"/> interface. The descriptions and remarks for the IPropertyStorage version of these methods applies to
/// the <c>IWiaPropertyStorage</c> as well.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>IPropertyStorage Methods</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>IPropertyStorage::ReadMultiple</term>
/// <term>Reads property values in a property set.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::WriteMultiple</term>
/// <term>Writes property values in a property set.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::DeleteMultiple</term>
/// <term>Deletes properties in a property set.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::ReadPropertyNames</term>
/// <term>Gets string names that correspond to given property identifiers.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::WritePropertyNames</term>
/// <term>Creates or changes string names that corresponds to given property identifiers.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::DeletePropertyNames</term>
/// <term>Deletes string names for given property identifiers.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::SetClass</term>
/// <term>Assigns a CLSID to the property set.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::Commit</term>
/// <term>As in IStorage::Commit, flushes or commits changes to the property storage object.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::Revert</term>
/// <term>When the property storage is opened in transacted mode, discards all changes since the last commit.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::Enum</term>
/// <term>Creates and gets a pointer to an enumerator for properties within this set.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::Stat</term>
/// <term>Receives statistics about this property set.</term>
/// </item>
/// <item>
/// <term>IPropertyStorage::SetTimes</term>
/// <term>Sets modification, creation, and access times for the property set.</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nn-wia_xp-iwiapropertystorage
[PInvokeData("wia_xp.h")]
[ComImport, Guid("98B5E8A0-29CC-491a-AAC0-E6DB4FDCCEB6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWiaPropertyStorage
{
/// <summary>
/// <para>The <c>ReadMultiple</c> method reads specified properties from the current property set.</para>
/// </summary>
/// <param name="cpspec">
/// <para>
/// The numeric count of properties to be specified in the array. The value of this parameter can be set to zero; however, that
/// defeats the purpose of the method as no properties are thereby read, regardless of the values set in .
/// </para>
/// </param>
/// <param name="rgpspec">
/// <para>
/// An array of PROPSPEC structures specifies which properties are read. Properties can be specified either by a property ID or
/// by an optional string name. It is not necessary to specify properties in any particular order in the array. The array can
/// contain duplicate properties, resulting in duplicate property values on return for simple properties. Nonsimple properties
/// should return access denied on an attempt to open them a second time. The array can contain a mixture of property IDs and
/// string IDs.
/// </para>
/// </param>
/// <param name="rgpropvar">
/// <para>
/// Caller-allocated array of a PROPVARIANT structure that, on return, contains the values of the properties specified by the
/// corresponding elements in the array. The array must be at least large enough to hold values of the parameter of the
/// <c>PROPVARIANT</c> structure. The parameter specifies the number of properties set in the array. The caller is not required
/// to initialize these <c>PROPVARIANT</c> structure values in any specific order. However, the implementation must fill all
/// members correctly on return. If there is no other appropriate value, the implementation must set the <c>vt</c> member of
/// each <c>PROPVARIANT</c> structure to <c>VT_EMPTY</c>.
/// </para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value <c>E_UNEXPECTED</c>, as well as the following:</para>
/// <para>
/// This function can also return any file system errors or Win32 errors wrapped in an <c>HRESULT</c> data type. For more
/// information, see Error Handling Strategies.
/// </para>
/// <para>For more information, see Property Storage Considerations.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-readmultiple
[PreserveSig]
HRESULT ReadMultiple(uint cpspec, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPSPEC[] rgpspec, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPVARIANT[] rgpropvar);
/// <summary>
/// <para>
/// The <c>WriteMultiple</c> method writes a specified group of properties to the current property set. If a property with a
/// specified name or property identifier already exists, it is replaced, even when the old and new types for the property value
/// are different. If a property of a given name or property ID does not exist, it is created.
/// </para>
/// </summary>
/// <param name="cpspec">
/// <para>
/// The number of properties set. The value of this parameter can be set to zero; however, this defeats the purpose of the
/// method as no properties are then written.
/// </para>
/// </param>
/// <param name="rgpspec">
/// <para>
/// An array of the property IDs (PROPSPEC) to which properties are set. These need not be in any particular order, and may
/// contain duplicates, however the last specified property ID is the one that takes effect. A mixture of property IDs and
/// string names is permitted.
/// </para>
/// </param>
/// <param name="rgpropvar">
/// <para>
/// An array (of size ) of PROPVARIANT structures that contain the property values to be written. The array must be the size
/// specified by .
/// </para>
/// </param>
/// <param name="propidNameFirst">
/// <para>
/// The minimum value for the property IDs that the method must assign if the parameter specifies string-named properties for
/// which no property IDs currently exist. If all string-named properties specified already exist in this set, and thus already
/// have property IDs, this value is ignored. When not ignored, this value must be greater than, or equal to, two and less than
/// 0x80000000. Property IDs 0 and 1 and greater than 0x80000000 are reserved for special use.
/// </para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// <para>
/// This function can also return any file system errors or Win32 errors wrapped in an <c>HRESULT</c> data type. For more
/// information, see Error Handling Strategies.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// If a specified property already exists, its value is replaced with the one specified in , even when the old and new types
/// for the property value are different. If the specified property does not already exist, that property is created. The
/// changes are not persisted to the underlying storage until IPropertyStorage::Commit has been called.
/// </para>
/// <para>
/// Property names are stored in a special dictionary section of the property set, which maps such names to property IDs. All
/// properties have an ID, but names are optional. A string name is supplied by specifying PRSPEC_LPWSTR in the <c>ulKind</c>
/// member of the PROPSPEC structure. If a string name is supplied for a property, and the name does not already exist in the
/// dictionary, the method will allocate a property ID, and add the property ID and the name to the dictionary. The property ID
/// is allocated in such a way that it does not conflict with other IDs in the property set. The value of the property ID also
/// is no less than the value specified by the parameter. If the parameter specifies string-named properties for which no
/// property IDs currently exist, the parameter specifies the minimum value for the property IDs that the <c>WriteMultiple</c>
/// method must assign.
/// </para>
/// <para>
/// When a new property set is created, the special <c>codepage (</c> Property ID 1 <c>)</c> and <c>Locale ID (</c> Property ID
/// 0x80000000 <c>)</c> properties are written to the property set automatically. These properties can subsequently be read,
/// using the IPropertyStorage::ReadMultiple method, by specifying property IDs with the header-defined PID_CODEPAGE and
/// PID_LOCALE values, respectively. If a property set is non-empty — has one or more properties in addition to the
/// <c>codepage</c> and <c>Locale ID</c> properties or has one or more names in its dictionary — the special <c>codepage</c> and
/// <c>Locale ID</c> properties cannot be modified by calling <c>IPropertyStorage::WriteMultiple</c>. However, if the property
/// set is empty, one or both of these special properties can be modified.
/// </para>
/// <para>
/// If an element in the array is set with a PRSPEC_PROPID value of 0xffffffff (PID_ILLEGAL), the corresponding value in the
/// array is ignored by <c>IPropertyStorage::WriteMultiple</c>. For example, if this method is called with the parameter set to
/// 3, but is set to PRSPEC_PROPID and is set to PID_ILLEGAL, only two properties will be written. The element is silently ignored.
/// </para>
/// <para>Use the PropVariantInit macro to initialize PROPVARIANT structures.</para>
/// <para>
/// Property sets, not including the data for nonsimple properties, are limited to 256 KB in size for Windows NT 4.0 and
/// earlier. For Windows 2000, Windows XP and Windows Server 2003, OLE property sets are limited to 1 MB. If these limits are
/// exceeded, the operation fails and the caller receives an error message. There is no possibility of a memory leak or overrun.
/// For more information, see Managing Property Sets.
/// </para>
/// <para>
/// Unless PROPSETFLAG_CASE_SENSITIVE is passed to IPropertySetStorage::Create, property set names are case insensitive.
/// Specifying a property by its name in <c>IPropertyStorage::WriteMultiple</c> will result in a case-insensitive search of the
/// names in the property set. To compare case-insensitive strings, the locale of the strings must be known. For more
/// information, see IPropertyStorage::WritePropertyNames.
/// </para>
/// <para>For more information, see Property Storage Considerations.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-writemultiple
[PreserveSig]
HRESULT WriteMultiple(uint cpspec, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPSPEC[] rgpspec, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPVARIANT[] rgpropvar, uint propidNameFirst);
/// <summary>
/// <para>The <c>DeleteMultiple</c> method deletes as many of the indicated properties as exist in this property set.</para>
/// </summary>
/// <param name="cpspec">
/// <para>
/// The numerical count of properties to be deleted. The value of this parameter can legally be set to zero, however that
/// defeats the purpose of the method as no properties are thereby deleted, regardless of the value set in .
/// </para>
/// </param>
/// <param name="rgpspec">
/// <para>
/// Properties to be deleted. A mixture of property identifiers and string-named properties is permitted. There may be
/// duplicates, and there is no requirement that properties be specified in any order.
/// </para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>IPropertyStorage::DeleteMultiple</c> must delete as many of the indicated properties as are in the current property set.
/// If a deletion of a stream- or storage-valued property occurs while that property is open, the deletion will succeed and
/// place the previously returned IStream or IStorage pointer in the reverted state.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-deletemultiple
[PreserveSig]
HRESULT DeleteMultiple(uint cpspec, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPSPEC[] rgpspec);
/// <summary>
/// <para>The <c>ReadPropertyNames</c> method retrieves any existing string names for the specified property IDs.</para>
/// </summary>
/// <param name="cpropid">
/// <para>
/// The number of elements on input of the array . The value of this parameter can be set to zero, however that defeats the
/// purpose of this method as no property names are thereby read.
/// </para>
/// </param>
/// <param name="rgpropid">
/// <para>An array of property IDs for which names are to be retrieved.</para>
/// </param>
/// <param name="rglpwstrName">
/// <para>
/// A caller-allocated array of size of <c>LPWSTR</c> members. On return, the implementation fills in this array. A given entry
/// contains either the corresponding string name of a property ID or it can be empty if the property ID has no string names.
/// </para>
/// <para>Each <c>LPWSTR</c> member of the array should be freed using the CoTaskMemFree function.</para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// For each property ID in the list of property IDs supplied in the array, <c>ReadPropertyNames</c> retrieves the corresponding
/// string name, if there is one. String names are created either by specifying the names in calls to
/// IPropertyStorage::WriteMultiple when creating the property, or through a call to IPropertyStorage::WritePropertyNames. In
/// either case, the string name is optional, however all properties must have a property ID.
/// </para>
/// <para>String names mapped to property IDs must be unique within the set.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-readpropertynames
[PreserveSig]
HRESULT ReadPropertyNames(uint cpropid, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] uint[] rgpropid, [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0)] string[] rglpwstrName);
/// <summary>
/// <para>
/// The <c>WritePropertyNames</c> method assigns string IPropertyStoragenames to a specified array of property IDs in the
/// current property set.
/// </para>
/// </summary>
/// <param name="cpropid">
/// <para>The size on input of the array . Can be zero. However, making it zero causes this method to become non-operational.</para>
/// </param>
/// <param name="rgpropid">
/// <para>An array of the property IDs for which names are to be set.</para>
/// </param>
/// <param name="rglpwstrName">
/// <para>
/// An array of new names to be assigned to the corresponding property IDs in the array. These names may not exceed 255
/// characters (not including the <c>NULL</c> terminator).
/// </para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value <c>E_UNEXPECTED</c>, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>For more information about property sets and memory management, see Managing Property Sets.</para>
/// <para>
/// <c>IPropertyStorage::WritePropertyNames</c> assigns string names to property IDs passed to the method in the array. It
/// associates each string name in the array with the respective property ID in . It is explicitly valid to define a name for a
/// property ID that is not currently present in the property storage object.
/// </para>
/// <para>
/// It is also valid to change the mapping for an existing string name (determined by a case-insensitive match). That is, you
/// can use the <c>WritePropertyNames</c> method to map an existing name to a new property ID, or to map a new name to a
/// property ID that already has a name in the dictionary. In either case, the original mapping is deleted. Property names must
/// be unique (as are property IDs) within the property set.
/// </para>
/// <para>
/// The storage of string property names preserves the case. Unless <c>PROPSETFLAG_CASE_SENSITIVE</c> is passed to
/// IPropertySetStorage::Create, property set names are case insensitive by default. With case-insensitive property sets, the
/// name strings passed by the caller are interpreted according to the locale of the property set, as specified by the
/// <c>PID_LOCALE</c> property. If the property set has no locale property, the current user is assumed by default. String
/// property names are limited in length to 128 characters. Property names that begin with the binary Unicode characters 0x0001
/// through 0x001F are reserved for future use.
/// </para>
/// <para>
/// If the value of an element in the array parameter is set to 0xffffffff (PID_ILLEGAL), the corresponding name is ignored by
/// <c>IPropertyStorage::WritePropertyNames</c>. For example, if this method is called with a parameter of 3, but the first
/// element of the array, , is set to <c>PID_ILLEGAL</c>, then only two property names are written. The element is ignored.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-writepropertynames
[PreserveSig]
HRESULT WritePropertyNames(uint cpropid, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] uint[] rgpropid, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0)] string[] rglpwstrName);
/// <summary>
/// <para>The <c>DeletePropertyNames</c> method deletes specified string names from the current property set.</para>
/// </summary>
/// <param name="cpropid">
/// <para>The size on input of the array . If 0, no property names are deleted.</para>
/// </param>
/// <param name="rgpropid">
/// <para>Property identifiers for which string names are to be deleted.</para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// For each property identifier in , <c>IPropertyStorage::DeletePropertyNames</c> removes any corresponding name-to-property ID
/// mapping. An attempt is silently ignored to delete the name of a property that either does not exist or does not currently
/// have a string name associated with it. This method has no effect on the properties themselves.
/// </para>
/// <para>
/// <c>Note</c> All the stored string property names can be deleted by deleting property identifier zero, but must be equal to 1
/// for this to be a valid parameter error.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-deletepropertynames
[PreserveSig]
HRESULT DeletePropertyNames(uint cpropid, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] uint[] rgpropid);
/// <summary>
/// <para>The <c>IPropertyStorage::Commit</c> method saves changes made to a property storage object to the parent storage object.</para>
/// </summary>
/// <param name="grfCommitFlags">
/// <para>
/// The flags that specify the conditions under which the commit is to be performed. For more information about specific flags
/// and their meanings, see the Remarks section.
/// </para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, as well as the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// Like IStorage::Commit, the <c>IPropertyStorage::Commit</c> method ensures that any changes made to a property storage object
/// are reflected in the parent storage.
/// </para>
/// <para>
/// In direct mode in the compound file implementation, a call to this method causes any changes currently in the memory buffers
/// to be flushed to the underlying property stream. In the compound-file implementation for nonsimple property sets,
/// IStorage::Commit is also called on the underlying substorage object with the passed parameter.
/// </para>
/// <para>
/// In transacted mode, this method causes the changes to be permanently reflected in the persistent image of the storage
/// object. The changes that are committed must have been made to this property set since it was opened or since the last commit
/// on this opening of the property set. The <c>commit</c> method publishes the changes made on one object level to the next
/// level. Of course, this remains subject to any outer-level transaction that may be present on the object in which this
/// property set is contained. Write permission must be specified when the property set is opened (through IPropertySetStorage)
/// on the property set opening for the commit operation to succeed.
/// </para>
/// <para>
/// If the commit operation fails for any reason, the state of the property storage object remains as it was before the commit.
/// </para>
/// <para>
/// This call has no effect on existing storage- or stream-valued properties opened from this property storage, but it does
/// commit them.
/// </para>
/// <para>Valid values for the parameter are listed in the following table.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>STGC_DEFAULT</term>
/// <term>Commits per the usual transaction semantics. Last writer wins. This flag may not be specified with other flag values.</term>
/// </item>
/// <item>
/// <term>STGC_ONLYIFCURRENT</term>
/// <term>
/// Commits the changes only if the current persistent contents of the property set are the ones on which the changes about to
/// be committed are based. That is, does not commit changes if the contents of the property set have been changed by a commit
/// from another opening of the property set. The error STG_E_NOTCURRENT is returned if the commit does not succeed for this reason.
/// </term>
/// </item>
/// <item>
/// <term>STGC_OVERWRITE</term>
/// <term>
/// Useful only when committing a transaction that has no further outer nesting level of transactions, though acceptable in all cases.
/// </term>
/// </item>
/// </list>
/// <para>
/// <c>Note</c> Using <c>IPropertyStorage::Commit</c> to write properties to image files on Windows XP does not work. Affected
/// image file formats include:Due to a bug in the image file property handler on Windows XP, calling
/// <c>IPropertyStorage::Commit</c> actually discards any changes made rather than persisting them.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-commit
[PreserveSig]
HRESULT Commit(uint grfCommitFlags);
/// <summary>
/// <para>
/// The <c>Revert</c> method discards all changes to the named property set since it was last opened or discards changes that
/// were last committed to the property set. This method has no effect on a direct-mode property set.
/// </para>
/// </summary>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// For transacted-mode property sets, this method discards all changes that have been made in this property set since the set
/// was opened or since the time it was last committed, (whichever is later). After this operation, any existing storage- or
/// stream-valued properties that have been opened from the property set being reverted are no longer valid and cannot be used.
/// The error STG_E_REVERTED will be returned on all calls, except those to <c>Release</c>, using these streams or storages.
/// </para>
/// <para>For direct-mode property sets, this request is ignored and returns S_OK.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-revert
[PreserveSig]
HRESULT Revert();
/// <summary>
/// <para>
/// The <c>Enum</c> method creates an enumerator object designed to enumerate data of type STATPROPSTG, which contains
/// information on the current property set. On return, this method supplies a pointer to the IEnumSTATPROPSTG pointer on this object.
/// </para>
/// </summary>
/// <param name="ppenum">
/// <para>Pointer to IEnumSTATPROPSTG pointer variable that receives the interface pointer to the new enumerator object.</para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>IPropertyStorage::Enum</c> creates an enumeration object that can be used to iterate STATPROPSTG structures. On return,
/// this method supplies a pointer to an instance of the IEnumSTATPROPSTG interface on this object, whose methods you can call
/// to obtain information about the current property set.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-enum
[PreserveSig]
HRESULT Enum(out IEnumSTATPROPSTG ppenum);
/// <summary>
/// <para>
/// The <c>SetTimes</c> method sets the modification, access, and creation times of this property set, if supported by the
/// implementation. Not all implementations support all these time values.
/// </para>
/// </summary>
/// <param name="pctime">
/// <para>
/// Pointer to the new creation time for the property set. May be <c>NULL</c>, indicating that this time is not to be modified
/// by this call.
/// </para>
/// </param>
/// <param name="patime">
/// <para>
/// Pointer to the new access time for the property set. May be <c>NULL</c>, indicating that this time is not to be modified by
/// this call.
/// </para>
/// </param>
/// <param name="pmtime">
/// <para>
/// Pointer to the new modification time for the property set. May be <c>NULL</c>, indicating that this time is not to be
/// modified by this call.
/// </para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// Sets the modification, access, and creation times of the current open property set, if supported by the implementation (not
/// all implementations support all these time values). Unsupported time stamps are always reported as zero, enabling the caller
/// to test for support. A call to IPropertyStorage::Stat supplies (among other data) time-stamp information.
/// </para>
/// <para>
/// Notice that this functionality is provided as an IPropertyStorage method on a property-storage object that is already open,
/// in contrast to being provided as a method in IPropertySetStorage. Normally, when the <c>SetTimes</c> method is not
/// explicitly called, the access and modification times are updated as a side effect of reading and writing the property set.
/// When <c>SetTimes</c> is used, the latest specified times supersede either default times or time values specified in previous
/// calls to <c>SetTimes</c>.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-settimes
[PreserveSig]
HRESULT SetTimes(in FILETIME pctime, in FILETIME patime, in FILETIME pmtime);
/// <summary>
/// <para>
/// The <c>SetClass</c> method assigns a new CLSID to the current property storage object, and persistently stores the CLSID
/// with the object.
/// </para>
/// </summary>
/// <param name="clsid">
/// <para>New CLSID to be associated with the property set.</para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// Assigns a CLSID to the current property storage object. The CLSID has no relationship to the stored property IDs. Assigning
/// a CLSID allows a piece of code to be associated with a given instance of a property set; such code, for example, might
/// manage the user interface (UI). Different CLSIDs can be associated with different property set instances that have the same FMTID.
/// </para>
/// <para>
/// If the property set is created with the parameter of the IPropertySetStorage::Create method specified as <c>NULL</c>, the
/// CLSID is set to all zeroes.
/// </para>
/// <para>
/// The current CLSID on a property storage object can be retrieved with a call to IPropertyStorage::Stat. The initial value for
/// the CLSID can be specified at the time that the storage is created with a call to IPropertySetStorage::Create.
/// </para>
/// <para>
/// Setting the CLSID on a nonsimple property set (one that can legally contain storage- or stream-valued properties, as
/// described in IPropertySetStorage::Create) also sets the CLSID on the underlying sub-storage.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-setclass
[PreserveSig]
HRESULT SetClass(in Guid clsid);
/// <summary>
/// <para>The <c>Stat</c> method retrieves information about the current open property set.</para>
/// </summary>
/// <param name="pstatpsstg">
/// <para>Pointer to a STATPROPSETSTG structure, which contains statistics about the current open property set.</para>
/// </param>
/// <returns>
/// <para>This method supports the standard return value E_UNEXPECTED, in addition to the following:</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>IPropertyStorage::Stat</c> fills in and returns a pointer to a STATPROPSETSTG structure, containing statistics about the
/// current property set.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/propidl/nf-propidl-ipropertystorage-stat
[PreserveSig]
HRESULT Stat(out STATPROPSETSTG pstatpsstg);
/// <summary>
/// The <c>IWiaPropertyStorage::GetPropertyAttributes</c> method retrieves access rights and legal value information for a
/// specified set of properties.
/// </summary>
/// <param name="cpspec">
/// <para>Type: <c>ULONG</c></para>
/// <para>Specifies the number of property attributes to query.</para>
/// </param>
/// <param name="rgpspec">
/// <para>Type: <c>PROPSPEC[]</c></para>
/// <para>Specifies an array of Device Information Property Constants. Each constant in the array selects a property to query.</para>
/// </param>
/// <param name="rgflags">
/// <para>Type: <c>ULONG[]</c></para>
/// <para>
/// An array that receives a property attribute descriptor for each property specified in the rgpspec array. Each element in the
/// array is one or more descriptor values combined with a bitwise <c>OR</c> operation.
/// </para>
/// </param>
/// <param name="rgpropvar">
/// <para>Type: <c>PROPVARIANT[]</c></para>
/// <para>
/// An array that receives a property attribute descriptor for each property specified in the pPROPSPEC array. For more
/// information, see PROPVARIANT.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>This method returns one of the following values or a standard COM error code:</para>
/// <list type="table">
/// <listheader>
/// <term>Return Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>This method succeeded.</term>
/// </item>
/// <item>
/// <term>S_FALSE</term>
/// <term>The specified property names do not exist. No attributes were retrieved.</term>
/// </item>
/// <item>
/// <term>STG_E_ACCESSDENIED</term>
/// <term>The application does not have access to the property stream or the stream may already be open.</term>
/// </item>
/// <item>
/// <term>STG_E_INSUFFICIENTMEMORY</term>
/// <term>There is not enough memory to complete the operation.</term>
/// </item>
/// <item>
/// <term>ERROR_NOT_SUPPORTED</term>
/// <term>The property type is not supported.</term>
/// </item>
/// <item>
/// <term>STG_E_INVALIDPARAMETER</term>
/// <term>One or more parameters are invalid. One or more of the PROPSPEC structures contain invalid data.</term>
/// </item>
/// <item>
/// <term>STG_E_INVALIDPOINTER</term>
/// <term>One or more of the pointers passed to this method are invalid.</term>
/// </item>
/// <item>
/// <term>ERROR_NO_UNICODE_TRANSLATION</term>
/// <term>A translation from Unicode to ANSI or ANSI to Unicode failed.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This method retrieves both property access rights and valid property values. Access rights report whether the property is
/// readable, writeable, or both. Valid property values are specified as a range of values, a list of values, or a group of flag
/// values. For more information, see Property Attributes.
/// </para>
/// <para>
/// If the property access rights flag has the <c>WIA_PROP_NONE</c> bit set, no legal value information is available for this
/// property. Read only properties and properties with a binary data type are examples of properties that would have the
/// <c>WIA_PROP_NONE</c> bit set.
/// </para>
/// <para>
/// If the property has a range of valid values, they can be determined through the rgpropvar parameter upon completion of this
/// method. The ppvValidValues parameter specifies an array of PROPVARIANT structures.
/// </para>
/// <para>
/// For example, if the property range is specified as VT_VECTOR | VT_UI4, range information can be retrieved through the
/// structure member
/// </para>
/// <para>rgpropvar[n].caul.pElems[range_specifier]</para>
/// <para>where n is the index number of the property that is inspected and range_specifier is one of the following:</para>
/// <list type="table">
/// <listheader>
/// <term>Range Specifier</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>WIA_RANGE_MAX</term>
/// <term>Maximum value to which the property may be set.</term>
/// </item>
/// <item>
/// <term>WIA_RANGE_MIN</term>
/// <term>Minimum value to which the property may be set.</term>
/// </item>
/// <item>
/// <term>WIA_RANGE_NOM</term>
/// <term>Normal or default property value.</term>
/// </item>
/// <item>
/// <term>WIA_RANGE_STEP</term>
/// <term>Increment or decrement between property values.</term>
/// </item>
/// </list>
/// <para>
/// If the property has a list of valid values, applications determine them through the ppvValidValues parameter upon completion
/// of this method.
/// </para>
/// <para>
/// For example, if the property range is specified as VT_VECTOR | VT_UI4, the list of valid property values can be retrieved
/// through the structure member
/// </para>
/// <para>rgpropspecValues[n].caul.pElems[list_specifier]</para>
/// <para>where n is the index number of the property that is inspected and list_specifier is one of the following:</para>
/// <list type="table">
/// <listheader>
/// <term>Range Specifier</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>WIA_LIST_COUNT</term>
/// <term>Total number of list elements excluding the nominal value.</term>
/// </item>
/// <item>
/// <term>WIA_LIST_NOM</term>
/// <term>Nominal value for the property.</term>
/// </item>
/// <item>
/// <term>WIA_LIST_VALUES</term>
/// <term>The index number of the first value.</term>
/// </item>
/// </list>
/// <para>
/// Programs also use the ppvValidValues parameter to retrieve valid flag values. For instance, if the property flags are
/// specified as VT_UI4, valid flag values can be determined through the structure member
/// </para>
/// <para>rgpropspec[n].caul.pElems[flag_specifier]</para>
/// <para>where n is the index number of the property that is inspected, and flag_specifier is one of the following:</para>
/// <list type="table">
/// <listheader>
/// <term>Range Specifier</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>WIA_FLAG_NOM</term>
/// <term>The nominal value for the property.</term>
/// </item>
/// <item>
/// <term>WIA_FLAG_NUM_ELEMS</term>
/// <term>Total number of list elements excluding the nominal value.</term>
/// </item>
/// <item>
/// <term>WIA_FLAG_VALUES</term>
/// <term>All values with all valid flag bits set.</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiapropertystorage-getpropertyattributes HRESULT
// GetPropertyAttributes( ULONG cpspec, PROPSPEC [] rgpspec, ULONG [] rgflags, PROPVARIANT [] rgpropvar );
HRESULT GetPropertyAttributes(uint cpspec, [In, MarshalAs(UnmanagedType.LPArray)] PROPSPEC[] rgpspec, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] rgflags, [Out, MarshalAs(UnmanagedType.LPArray)] PROPVARIANT[] rgpropvar);
/// <summary>The <c>IWiaPropertyStorage::GetCount</c> method returns the number of properties stored in the property storage.</summary>
/// <returns>
/// <para>Type: <c>ULONG*</c></para>
/// <para>Receives the number of properties stored in the property storage.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiapropertystorage-getcount HRESULT GetCount( ULONG
// *pulNumProps );
uint GetCount();
/// <summary>The <c>IWiaPropertyStorage::GetPropertyStream</c> method retrieves the property stream of an item.</summary>
/// <param name="pCompatibilityId">
/// <para>Type: <c>GUID*</c></para>
/// <para>Receives a unique identifier for a set of property values.</para>
/// </param>
/// <returns>
/// <para>Type: <c>IStream**</c></para>
/// <para>Pointer to a stream that receives the item properties. For more information, see IStream.</para>
/// </returns>
/// <remarks>
/// <para>
/// Applications use this method to get a snapshot of the current properties of an item. These are subsequently restored by
/// calling IWiaPropertyStorage::SetPropertyStream.
/// </para>
/// <para>
/// Applications can use the pCompatibilityID parameter to check if a device supports a specific set of property values before
/// attempting to write these values to the device.
/// </para>
/// <para>When it is finished using the item's property stream, the application must release it.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiapropertystorage-getpropertystream HRESULT
// GetPropertyStream( GUID *pCompatibilityId, IStream **ppIStream );
IStream GetPropertyStream(in Guid pCompatibilityId);
/// <summary>
/// The <c>IWiaPropertyStorage::SetPropertyStream</c> sets the property stream of an item in the tree of IWiaItem objects of a
/// Windows Image Acquisition (WIA) hardware device.
/// </summary>
/// <param name="pCompatibilityId">
/// <para>Type: <c>GUID*</c></para>
/// <para>Specifies a unique identifier for a set of property values.</para>
/// </param>
/// <param name="pIStream">
/// <para>Type: <c>IStream*</c></para>
/// <para>Pointer to the property stream that is used to set the current item's property stream.</para>
/// </param>
/// <remarks>
/// <para>
/// Applications use the pCompatibilityID parameter to check whether a device supports a specific set of property values before
/// attempting to write these values to the device.
/// </para>
/// <para>Set pIStream to <c>NULL</c> to check whether the device driver accepts the CompatibilityID specified by pCompatibilityID.</para>
/// <para>
/// If the application obtained the property stream of the item using the IWiaPropertyStorage::GetPropertyStream method, the
/// application must release it. For more information, see IStream.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiapropertystorage-setpropertystream HRESULT
// SetPropertyStream( GUID *pCompatibilityId, IStream *pIStream );
void SetPropertyStream(in Guid pCompatibilityId, IStream pIStream);
}
/// <summary>Frees resources on the server side when called by RPC stub files.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">The safe array to free.</param>
/// <returns>This function does not return a value.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_userfree void LPSAFEARRAY_UserFree( unsigned long
// *, LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "87dc42de-70dc-4ae7-9bd0-89add31a5976")]
public static extern void LPSAFEARRAY_UserFree(IntPtr arg1, IntPtr arg2);
/// <summary>Frees resources on the server side when called by RPC stub files.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">The safe array to free.</param>
/// <returns>This function does not return a value.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_userfree64 void LPSAFEARRAY_UserFree64( unsigned
// long *, LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "79D73C90-4F31-4F18-B47D-2FBB4D9ED45C")]
public static extern void LPSAFEARRAY_UserFree64(IntPtr arg1, IntPtr arg2);
/// <summary>Marshals data from the specified SAFEARRAY object to the user's RPC buffer on the client or server side.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">
/// The current buffer. This pointer may or may not be aligned on entry. The function aligns the buffer pointer, marshals the data,
/// and returns the new buffer position, which is the address of the first byte after the marshaled object.
/// </param>
/// <param name="arg3">The safe array that contains the data to marshal.</param>
/// <returns>
/// <para>The value obtained from the returned <c>HRESULT</c> value is one of the following.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success.</term>
/// </item>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>The ppSafeArray parameter is not a valid safe array.</term>
/// </item>
/// <item>
/// <term>E_UNEXPECTED</term>
/// <term>The array could not be locked.</term>
/// </item>
/// </list>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_usermarshal unsigned char *
// LPSAFEARRAY_UserMarshal( unsigned long *, unsigned char *, LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "8255d1a0-b102-443d-a10f-8c6bd9047703")]
public static extern IntPtr LPSAFEARRAY_UserMarshal(IntPtr arg1, IntPtr arg2, IntPtr arg3);
/// <summary>Marshals data from the specified SAFEARRAY object to the user's RPC buffer on the client or server side.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">
/// The current buffer. This pointer may or may not be aligned on entry. The function aligns the buffer pointer, marshals the data,
/// and returns the new buffer position, which is the address of the first byte after the marshaled object.
/// </param>
/// <param name="arg3">The safe array that contains the data to marshal.</param>
/// <returns>
/// <para>The value obtained from the returned <c>HRESULT</c> value is one of the following.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success.</term>
/// </item>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>The ppSafeArray parameter is not a valid safe array.</term>
/// </item>
/// <item>
/// <term>E_UNEXPECTED</term>
/// <term>The array could not be locked.</term>
/// </item>
/// </list>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_usermarshal64 unsigned char *
// LPSAFEARRAY_UserMarshal64( unsigned long *, unsigned char *, LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "532CE1FB-FDE0-491A-90D2-CC6F45DB7FDF")]
public static extern IntPtr LPSAFEARRAY_UserMarshal64(IntPtr arg1, IntPtr arg2, IntPtr arg3);
/// <summary>Calculates the wire size of the SAFEARRAY object, and gets its handle and data.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">Sets the buffer offset so that the SAFEARRAY object is properly aligned when it is marshaled to the buffer.</param>
/// <param name="arg3">The safe array that contains the data to marshal.</param>
/// <returns>The value obtained from the returned <c>HRESULT</c> value is <c>S_OK</c>.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_usersize unsigned long LPSAFEARRAY_UserSize(
// unsigned long *, unsigned long , LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "85cb5bc1-5dab-4b50-950e-0d18c403f996")]
public static extern uint LPSAFEARRAY_UserSize(IntPtr arg1, uint arg2, IntPtr arg3);
/// <summary>Calculates the wire size of the SAFEARRAY object, and gets its handle and data.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">Sets the buffer offset so that the SAFEARRAY object is properly aligned when it is marshaled to the buffer.</param>
/// <param name="arg3">The safe array that contains the data to marshal.</param>
/// <returns>The value obtained from the returned <c>HRESULT</c> value is <c>S_OK</c>.</returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_usersize64 unsigned long LPSAFEARRAY_UserSize64(
// unsigned long *, unsigned long , LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "5F41D197-027E-4640-833A-4F6239F0DFB0")]
public static extern uint LPSAFEARRAY_UserSize64(IntPtr arg1, uint arg2, IntPtr arg3);
/// <summary>Unmarshals a SAFEARRAY object from the RPC buffer.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">
/// The current buffer. This pointer may or may not be aligned on entry. The function aligns the buffer pointer, marshals the data,
/// and returns the new buffer position, which is the address of the first byte after the marshaled object.
/// </param>
/// <param name="arg3">Receives the safe array that contains the data.</param>
/// <returns>
/// <para>The value obtained from the returned <c>HRESULT</c> value is one of the following.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success.</term>
/// </item>
/// <item>
/// <term>RPC_X_BAD_STUB_DATA</term>
/// <term>The stub has received bad data.</term>
/// </item>
/// <item>
/// <term>E_UNEXPECTED</term>
/// <term>The array could not be found.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>Insufficient memory for this function to perform.</term>
/// </item>
/// <item>
/// <term>DISP_E_BADCALLEE</term>
/// <term>The SAFEARRAY object does not have the correct dimensions, does not have the correct features, or memory cannot be reallocated.</term>
/// </item>
/// </list>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_userunmarshal unsigned char *
// LPSAFEARRAY_UserUnmarshal( unsigned long *, unsigned char *, LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h", MSDNShortId = "8798b8c1-d1c0-4729-b7bd-0329e8b71b0d")]
public static extern IntPtr LPSAFEARRAY_UserUnmarshal(IntPtr arg1, IntPtr arg2, IntPtr arg3);
/// <summary>Unmarshals a SAFEARRAY object from the RPC buffer.</summary>
/// <param name="arg1">The data used by RPC.</param>
/// <param name="arg2">
/// The current buffer. This pointer may or may not be aligned on entry. The function aligns the buffer pointer, marshals the data,
/// and returns the new buffer position, which is the address of the first byte after the marshaled object.
/// </param>
/// <param name="arg3">Receives the safe array that contains the data.</param>
/// <returns>
/// <para>The value obtained from the returned <c>HRESULT</c> value is one of the following.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success.</term>
/// </item>
/// <item>
/// <term>RPC_X_BAD_STUB_DATA</term>
/// <term>The stub has received bad data.</term>
/// </item>
/// <item>
/// <term>E_UNEXPECTED</term>
/// <term>The array could not be found.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>Insufficient memory for this function to perform.</term>
/// </item>
/// <item>
/// <term>DISP_E_BADCALLEE</term>
/// <term>The SAFEARRAY object does not have the correct dimensions, does not have the correct features, or memory cannot be reallocated.</term>
/// </item>
/// </list>
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-lpsafearray_userunmarshal unsigned char *
// LPSAFEARRAY_UserUnmarshal( unsigned long *, unsigned char *, LPSAFEARRAY * );
[DllImport(Lib.OleAut32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wia_xp.h")]
public static extern IntPtr LPSAFEARRAY_UserUnmarshal64(IntPtr arg1, IntPtr arg2, IntPtr arg3);
/// <summary>
/// The <c>WIA_DATA_CALLBACK_HEADER</c> is transmitted to an application during a series of calls by the Windows Image Acquisition
/// (WIA) run-time system to the IWiaDataCallback::BandedDataCallback method.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/ns-wia_xp-wia_data_callback_header typedef struct
// _WIA_DATA_CALLBACK_HEADER { int lSize; GUID guidFormatID; int lBufferSize; int lPageCount; } WIA_DATA_CALLBACK_HEADER, *PWIA_DATA_CALLBACK_HEADER;
[PInvokeData("wia_xp.h")]
[StructLayout(LayoutKind.Sequential)]
public struct WIA_DATA_CALLBACK_HEADER
{
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Must contain the size of this structure in bytes. Should be initialized to <c>sizeof(WIA_DATA_CALLBACK_HEADER)</c>.</para>
/// </summary>
public int lSize;
/// <summary>
/// <para>Type: <c>GUID</c></para>
/// <para>
/// Indicates the image clipboard format. For a list of clipboard formats, see SetClipboardData Function. This parameter is
/// queried during a callback to the IWiaDataCallback::BandedDataCallback method with the lMessage parameter set to IT_MSG_DATA_HEADER.
/// </para>
/// </summary>
public Guid guidFormatID;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Specifies the size in bytes of the buffer needed for a complete data transfer. This value can be zero, which indicates that
/// the total image size is unknown. (when using compressed data formats, for example). In this case, the application should
/// dynamically increase the size of its buffer. For more information, see Common WIA Item Property Constants in WIA_IPA_ITEM_SIZE.
/// </para>
/// </summary>
public int lBufferSize;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Specifies the page count. Indicates the number of callbacks to the IWiaDataCallback::BandedDataCallback method with the
/// lMessage parameter set to IT_MSG_NEW_PAGE.
/// </para>
/// </summary>
public int lPageCount;
}
/// <summary>
/// The <c>WIA_DATA_TRANSFER_INFO</c> structure is used by applications to describe the buffer used to retrieve bands of data from
/// Windows Image Acquisition (WIA) devices. It is primarily used in conjunction with the methods of the IWiaDataTransfer interface.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/ns-wia_xp-wia_data_transfer_info typedef struct _WIA_DATA_TRANSFER_INFO
// { ULONG ulSize; ULONG ulSection; ULONG ulBufferSize; BOOL bDoubleBuffer; ULONG ulReserved1; ULONG ulReserved2; ULONG ulReserved3;
// } WIA_DATA_TRANSFER_INFO, *PWIA_DATA_TRANSFER_INFO;
[PInvokeData("wia_xp.h")]
[StructLayout(LayoutKind.Sequential)]
public struct WIA_DATA_TRANSFER_INFO
{
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>
/// Contains the size of this structure. Must be set to <c>sizeof(WIA_DATA_TRANSFER_INFO)</c> before your application passes
/// this structure to any WIA interface methods.
/// </para>
/// </summary>
public uint ulSize;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>
/// Specifies an optional handle to a shared section of memory allocated by the application. If this member is set to
/// <c>NULL</c>, IWiaDataTransfer::idtGetBandedData allocates the shared memory itself.
/// </para>
/// </summary>
public uint ulSection;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>The size in bytes of the buffer that is used for the data transfer.</para>
/// </summary>
public uint ulBufferSize;
/// <summary>
/// <para>Type: <c>BOOL</c></para>
/// <para>Contains <c>TRUE</c> if the device is double buffered, <c>FALSE</c> if the device is not double buffered.</para>
/// </summary>
[MarshalAs(UnmanagedType.Bool)] public bool bDoubleBuffer;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>Reserved for use by the WIA system DLLs. Must be set to zero.</para>
/// </summary>
public uint ulReserved1;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>Reserved for use by the WIA system DLLs. Must be set to zero.</para>
/// </summary>
public uint ulReserved2;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>Reserved for use by the WIA system DLLs. Must be set to zero.</para>
/// </summary>
public uint ulReserved3;
}
/// <summary>
/// Applications use the WIA_DEV_CAP structure to enumerate device capabilities. A device capability is defined by an event or
/// command that the device supports. For more information, see IEnumWIA_DEV_CAPS.
/// </summary>
[PInvokeData("wia_xp.h")]
[StructLayout(LayoutKind.Sequential)]
public struct WIA_DEV_CAP
{
/// <summary>
/// Specifies a GUID that identifies the device capability. This member can be set to any of the values specified in WIA Device
/// Commands or WIA Event Identifiers.
/// </summary>
public Guid guid;
/// <summary>Used when enumerating event handlers.</summary>
public uint ulFlags;
/// <summary>Specifies a string that contains a short version of the capability name.</summary>
[MarshalAs(UnmanagedType.BStr)] public string bstrName;
/// <summary>Specifies a string that contains a description of the capability that is displayed to the user.</summary>
[MarshalAs(UnmanagedType.BStr)] public string bstrDescription;
/// <summary>
/// Specifies a string that represents the location and resource ID of the icon that represents this capability or handler. The
/// string must be of the following form: <c>drive:path module,n</c>, where n is the icon's negated resource ID (that is, if the
/// resource ID of the icon is 100, then n is -100).
/// </summary>
[MarshalAs(UnmanagedType.BStr)] public string bstrIcon;
/// <summary>Specifies a string that represents command line arguments.</summary>
[MarshalAs(UnmanagedType.BStr)] public string bstrCommandline;
}
/// <summary>
/// The <c>WIA_DITHER_PATTERN_DATA</c> structure specifies a dither pattern for scanners. It is used in conjunction with the scanner
/// device property constant WIA_DPS_DITHER_PATTERN_DATA.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/ns-wia_xp-wia_dither_pattern_data typedef struct
// _WIA_DITHER_PATTERN_DATA { int lSize; BSTR bstrPatternName; int lPatternWidth; int lPatternLength; int cbPattern; BYTE
// *pbPattern; } WIA_DITHER_PATTERN_DATA, *PWIA_DITHER_PATTERN_DATA;
[PInvokeData("wia_xp.h")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct WIA_DITHER_PATTERN_DATA
{
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Specifies the size of this structure in bytes. Should be set to <c>sizeof(WIA_DITHER_PATTERN_DATA)</c>.</para>
/// </summary>
public int lSize;
/// <summary>
/// <para>Type: <c>BSTR</c></para>
/// <para>Specifies a string that contains the name of this dither pattern.</para>
/// </summary>
[MarshalAs(UnmanagedType.BStr)] public string bstrPatternName;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Indicates the width of the dither pattern in bytes.</para>
/// </summary>
public int lPatternWidth;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Indicates the length of the dither pattern in bytes.</para>
/// </summary>
public int lPatternLength;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Specifies the total number of bytes in the array pointed to by the <c>pbPattern</c> member.</para>
/// </summary>
public int cbPattern;
/// <summary>
/// <para>Type: <c>BYTE*</c></para>
/// <para>Specifies a pointer to a buffer that contains the dither pattern.</para>
/// </summary>
public IntPtr pbPattern;
}
/// <summary>
/// The <c>WIA_EXTENDED_TRANSFER_INFO</c> structure specifies extended transfer information for the
/// IWiaDataTransfer::idtGetExtendedTransferInfo method.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/ns-wia_xp-wia_extended_transfer_info typedef struct
// _WIA_EXTENDED_TRANSFER_INFO { ULONG ulSize; ULONG ulMinBufferSize; ULONG ulOptimalBufferSize; ULONG ulMaxBufferSize; ULONG
// ulNumBuffers; } WIA_EXTENDED_TRANSFER_INFO, *PWIA_EXTENDED_TRANSFER_INFO;
[PInvokeData("wia_xp.h")]
[StructLayout(LayoutKind.Sequential)]
public struct WIA_EXTENDED_TRANSFER_INFO
{
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>Size of this structure.</para>
/// </summary>
public uint ulSize;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>Minimum buffer size the application should request in a call to IWiaDataTransfer::idtGetBandedData.</para>
/// </summary>
public uint ulMinBufferSize;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>Driver-recommended buffer size the application should request in a call to IWiaDataTransfer::idtGetBandedData.</para>
/// </summary>
public uint ulOptimalBufferSize;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>
/// Driver-recommended maximum buffer size the application could request in a call to IWiaDataTransfer::idtGetBandedData. Going
/// over this limit is not detrimental, however, the driver can simply not use the whole buffer and limit each band of data to
/// this maximum size.
/// </para>
/// </summary>
public uint ulMaxBufferSize;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>This value is not used and should be ignored.</para>
/// </summary>
public uint ulNumBuffers;
}
/// <summary>The <c>WIA_FORMAT_INFO</c> structure specifies valid format and media type pairs for a device.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/ns-wia_xp-wia_format_info typedef struct _WIA_FORMAT_INFO { GUID
// guidFormatID; int lTymed; } WIA_FORMAT_INFO, *PWIA_FORMAT_INFO;
[PInvokeData("wia_xp.h")]
[StructLayout(LayoutKind.Sequential)]
public struct WIA_FORMAT_INFO
{
/// <summary>
/// <para>Type: <c>GUID</c></para>
/// <para>GUID that identifies the format.</para>
/// </summary>
public Guid guidFormatID;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>The media type that corresponds to the <c>guidFormatID</c> member.</para>
/// </summary>
public int lTymed;
}
}
} | 49.45436 | 243 | 0.67399 | [
"MIT"
] | AndreGleichner/Vanara | PInvoke/Ole/OleAut32/Wia_xp.cs | 217,803 | C# |
using AutoMapper;
using StockTradingAnalysis.Interfaces.Domain;
using StockTradingAnalysis.Web.Models;
namespace StockTradingAnalysis.Web.AutoMapperProfiles
{
/// <summary>
/// The ImageProfile contains the auto mapper configuration for an image, <see cref="IImage"/>.
/// </summary>
/// <seealso cref="Profile" />
public class ImageProfile : Profile
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageProfile"/> class.
/// </summary>
public ImageProfile()
{
CreateMap<IImage, ImageViewModel>()
.ForMember(t => t.Id, source => source.MapFrom(s => s.Id))
.ForMember(t => t.Description, source => source.MapFrom(s => s.Description))
.ForMember(t => t.ContentType, source => source.MapFrom(s => s.ContentType))
.ForMember(t => t.OriginalName, source => source.MapFrom(s => s.OriginalName))
.ForMember(t => t.Data, source => source.MapFrom(s => s.Data));
}
}
} | 35.346154 | 96 | 0.682263 | [
"Unlicense"
] | BenjaminBest/StockTradingAnalysisWebsite | StockTradingAnalysisWebsite/StockTradingAnalysis.Web/App_Start/AutoMapperProfiles/ImageProfile.cs | 921 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.ADF.Deployment.AdfKeyVaultDeployment.Models
{
public class Subscription
{
public string FriendlyName { get; set; }
public string Id { get; set; }
}
}
| 21.066667 | 63 | 0.71519 | [
"MIT"
] | Azure/Azure-DataFactory | SamplesV1/ADFSecurePublish/AdfKeyVaultDeployment/Models/Subscription.cs | 318 | C# |
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System.Collections.Generic;
using Stride.Core.Shaders.Ast;
namespace Stride.Core.Shaders.Ast.Stride
{
/// <summary>
/// For statement.
/// </summary>
public partial class ForEachStatement : Statement, IScopeContainer
{
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref = "ForStatement" /> class.
/// </summary>
public ForEachStatement()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ForEachStatement"/> class.
/// </summary>
/// <param name="variable">The variable.</param>
/// <param name="collection">The collection.</param>
public ForEachStatement(Variable variable, Expression collection)
{
Variable = variable;
Collection = collection;
}
#endregion
#region Public Properties
/// <summary>
/// Gets or sets the condition.
/// </summary>
/// <value>
/// The condition.
/// </value>
public Expression Collection { get; set; }
/// <summary>
/// Gets or sets the initializer.
/// </summary>
/// <value>
/// The initializer.
/// </value>
public Variable Variable { get; set; }
/// <summary>
/// Gets or sets the condition.
/// </summary>
/// <value>
/// The condition.
/// </value>
public Statement Body { get; set; }
#endregion
#region Public Methods
/// <inheritdoc />
public override IEnumerable<Node> Childrens()
{
ChildrenList.Clear();
ChildrenList.Add(Collection);
ChildrenList.Add(Variable);
ChildrenList.Add(Body);
return ChildrenList;
}
/// <inheritdoc />
public override string ToString()
{
return string.Format("foreach({0} in {1}) {{...}}", Variable, Collection);
}
#endregion
}
}
| 27.952941 | 163 | 0.546296 | [
"MIT"
] | Alan-love/xenko | sources/shaders/Stride.Core.Shaders/Ast/Stride/ForEachStatement.cs | 2,376 | C# |
using System;
using FluentNHibernate.Diagnostics;
using FluentNHibernate.Testing.Utils;
using NUnit.Framework;
using Rhino.Mocks;
namespace FluentNHibernate.Testing.Diagnostics
{
[TestFixture]
public class DiagnosticMessageDespatcherTests
{
IDiagnosticMessageDespatcher despatcher;
[SetUp]
public void CreateDespatcher()
{
despatcher = new DefaultDiagnosticMessageDespatcher();
}
[Test]
public void should_publish_results_to_all_listeners()
{
var firstListener = Mock<IDiagnosticListener>.Create();
var secondListener = Mock<IDiagnosticListener>.Create();
var results = new DiagnosticResults(new ScannedSource[0], new Type[0], new Type[0], new SkippedAutomappingType[0], new Type[0], new AutomappingType[0]);
despatcher.RegisterListener(firstListener);
despatcher.RegisterListener(secondListener);
despatcher.Publish(results);
firstListener.AssertWasCalled(x => x.Receive(results));
secondListener.AssertWasCalled(x => x.Receive(results));
}
}
}
| 32.861111 | 165 | 0.655114 | [
"BSD-3-Clause"
] | ashmind/fluent-nhibernate | src/FluentNHibernate.Testing/Diagnostics/DiagnosticMessageDespatcherTests.cs | 1,185 | C# |
using Noyau;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Navigation;
using DataObject = System.Windows.DataObject;
using DragDropEffects = System.Windows.DragDropEffects;
using System.ComponentModel;
using System.Windows.Data;
namespace WpfApp2
{
/// <summary>
/// Logique d'interaction pour Gate.xaml
/// </summary>
public partial class Gate : UserControl
{
protected string data;
public Outils outil;
// Pour classifier les entrees selon la direction
private List<ClasseEntree> E_Left = new List<ClasseEntree>();
private List<ClasseEntree> E_Up = new List<ClasseEntree>();
private List<ClasseEntree> E_Right = new List<ClasseEntree>();
private List<ClasseEntree> E_Down = new List<ClasseEntree>();
// Pour classifier les sorties selon la direction
private List<Sortie> S_Left = new List<Sortie>();
private List<Sortie> S_Up = new List<Sortie>();
private List<Sortie> S_Right = new List<Sortie>();
private List<Sortie> S_Down = new List<Sortie>();
public Gate(Outils outils)
{
this.outil = outils;
this.data = "M0.5,0.5 L38.611,0.5 L38.611,51.944 L0.5,51.944 z";
path.Data = StreamGeometry.Parse(data);
path.StrokeThickness = 1;
path.Fill = Brushes.White;
}
public Gate(Outils outil, String ph)
{
InputOutputs = new List<InputOutput>();
this.data = ph;
this.outil = outil;
this.InitializeComponent();
ToolTip = outil.getLabel();
path.Data = StreamGeometry.Parse(ph);
path.StrokeThickness = 1;
path.Fill = Brushes.White;
Classification();
Creation();
MAJ_Path();
//Fréquences de l'horloge
if (outil is Horloge)
{
MenuItem mi = new MenuItem();
BindingGroup bindingGroup = new BindingGroup();
RadioButton propo1 = new RadioButton();
propo1.BindingGroup = bindingGroup;
propo1.Checked += (object s, RoutedEventArgs e) => { (outil as Horloge).setTUp(1000, 500); };
propo1.Content = "T = 1s DutyCycle = 500 ms";
RadioButton propo5 = new RadioButton();
propo5.BindingGroup = bindingGroup;
propo5.Checked += (object s, RoutedEventArgs e) => { (outil as Horloge).setTUp(1000, 200); };
propo5.Content = "T = 1s DutyCycle = 200 ms";
RadioButton propo2 = new RadioButton();
propo2.IsChecked = true;
propo2.BindingGroup = bindingGroup;
propo2.Checked += (object s, RoutedEventArgs e) => { (outil as Horloge).setTUp(2000, 1000); };
propo2.Content = "T = 2s DutyCycle = 1s";
RadioButton propo6 = new RadioButton();
propo6.BindingGroup = bindingGroup;
propo6.Checked += (object s, RoutedEventArgs e) => { (outil as Horloge).setTUp(2000, 500); };
propo6.Content = "T = 2s DutyCycle = 500 ms";
RadioButton propo3 = new RadioButton();
propo3.BindingGroup = bindingGroup;
propo3.Checked += (object s, RoutedEventArgs e) => { (outil as Horloge).setTUp(3000, 1500); };
propo3.Content = "T = 3s DutyCycle = 1,5s";
RadioButton propo4 = new RadioButton();
propo4.BindingGroup = bindingGroup;
propo4.Checked += (object s, RoutedEventArgs e) => { (outil as Horloge).setTUp(4000, 2000); };
propo4.Content = "T = 4s DutyCycle = 2s";
mi.Items.Add(propo5);
mi.Items.Add(propo1);
mi.Items.Add(propo6);
mi.Items.Add(propo2);
mi.Items.Add(propo3);
mi.Items.Add(propo4);
mi.Header = "Fréquences";
menu.Items.Add(mi);
}
}
/// <summary>
/// Fonction qui separe les entrees et sorties selon la disposition
/// </summary>
public void Classification()
{
int nE = 0;
int nS = 0;
while (nE < outil.getnbrentrees())
{
switch (outil.getListeentrees()[nE].GetDisposition())
{
case Disposition.up:
E_Up.Add(outil.getListeentrees()[nE]);
break;
case Disposition.down:
E_Down.Add(outil.getListeentrees()[nE]);
break;
case Disposition.left:
E_Left.Add(outil.getListeentrees()[nE]);
break;
case Disposition.right:
E_Right.Add(outil.getListeentrees()[nE]);
break;
}
nE++;
}
while (nS < outil.getnbrsoryies())
{
switch (outil.getListesorties()[nS].GetDisposition())
{
case Disposition.up:
S_Up.Add(outil.getListesorties()[nS]);
break;
case Disposition.down:
S_Down.Add(outil.getListesorties()[nS]);
break;
case Disposition.left:
S_Left.Add(outil.getListesorties()[nS]);
break;
case Disposition.right:
S_Right.Add(outil.getListesorties()[nS]);
break;
}
nS++;
}
E_Left.Reverse();
S_Down.Reverse();
E_Up.Reverse();
}
/// <summary>
/// Pour la creaction de tt les IO du gate
/// </summary>
public void Creation()
{
// Les entrees :
int i = 0;
foreach (ClasseEntree Er in E_Right)
{
AjouterIO(RightGate, Er, i);
i++;
}
i = 0;
foreach (ClasseEntree El in E_Left)
{
AjouterIO(LeftGate, El, i);
i++;
}
i = 0;
foreach (ClasseEntree Ed in E_Down)
{
AjouterIO(BottomGate, Ed, i);
i++;
}
i = 0;
foreach (ClasseEntree Eu in E_Up)
{
AjouterIO(TopGate, Eu, i);
i++;
}
// Les sorties :
i = 0;
foreach (Sortie Sr in S_Right)
{
AjouterIO(RightGate, Sr, i);
i++;
}
i = 0;
foreach (Sortie Sl in S_Left)
{
AjouterIO(LeftGate, Sl, i);
i++;
}
i = 0;
foreach (Sortie Sd in S_Down)
{
AjouterIO(BottomGate, Sd, i);
i++;
}
i = 0;
foreach (Sortie Su in S_Up)
{
AjouterIO(TopGate, Su, i);
i++;
}
}
/// <summary>
/// ajouter et créer les i/o
/// </summary>
/// <param name="grid"></param>
/// <param name="myt"></param>
/// <param name="n"></param>
public void AjouterIO(Grid grid, InputOutput myt, int n)
{
ColumnDefinition cd = new ColumnDefinition();
cd.Width = new GridLength(1, GridUnitType.Star);
grid.ColumnDefinitions.Add(cd);
grid.Children.Add(myt);
Grid.SetColumn(myt, n);
//Liaison
InputOutputs.Add(myt);
}
/// <summary>
/// Lors de l'ajout ou suppression, on refait tout le travail
/// Donc il faut supprimer tous les children et columndefinitions du gate
/// Pour qu'après on puisse ajouter ces derniers comme besoin
/// </summary>
public void MAJ()
{
InputOutputs = new List<InputOutput>();
LeftGate.Children.Clear(); RightGate.Children.Clear(); BottomGate.Children.Clear(); TopGate.Children.Clear();
LeftGate.ColumnDefinitions.Clear(); RightGate.ColumnDefinitions.Clear(); BottomGate.ColumnDefinitions.Clear(); TopGate.ColumnDefinitions.Clear();
}
/// <summary>
/// Mise a jour du path apres ajout ou suppression d'une entrée ou sortie
/// </summary>
public void MAJ_Path()
{
int taille = 20;
int ver = Math.Max(Math.Max(E_Left.Count, S_Left.Count), Math.Max(E_Right.Count, S_Right.Count));
int hor = Math.Max(Math.Max(E_Up.Count, S_Up.Count), Math.Max(E_Down.Count, S_Down.Count));
//mettre à jour la taille du path
if (ver > 0) { path.Height = ver * taille; }
if (hor > 0) { path.Width = hor * taille; }
OutilShape.Width = path.Width + 44;
OutilShape.Height = path.Height + 44;
}
#region ContextMenu
/// <summary>
/// Ajout d'une entrée
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AjouterEntrée(object sender, RoutedEventArgs e)
{
Type type = outil.GetType();
AddEntree(type);
}
public void AddEntree(Type type)
{
if ((type.Name == "ET") || (type.Name == "OU") || (type.Name == "NAND") || (type.Name == "OUX") || (type.Name == "NOR"))
{
if (outil.getnbrentrees() < 5)
{
string i = (outil.getnbrentrees() + 1).ToString();
string etiq = ("Entrée " + i);
ClasseEntree classeEntree = new ClasseEntree(etiq, 1, Disposition.left, false, false);
outil.AjoutEntree(classeEntree);
E_Left.Insert(0, classeEntree);
}
}
if (type.Name == "Encodeur")
{
int entree = 0;
if (outil.getnbrentrees() == 2) { entree = 2; }
if (outil.getnbrentrees() == 4) { entree = 4; }
for (int i = 0; i < entree; i++)
{
string ee = (outil.getnbrentrees() + 1).ToString();
string etiq_e = ("Entrée " + ee);
ClasseEntree classeEntree = new ClasseEntree(etiq_e, 1, Disposition.left, false, false);
outil.AjoutEntree(classeEntree);
E_Left.Insert(0, classeEntree);
}
string es = (outil.getnbrsoryies() + 1).ToString();
string etiq_s = ("Sortie " + es);
Sortie sortie = new Sortie(etiq_s, 1, Disposition.right, false, new List<OutStruct>());
outil.AjoutSortie(sortie);
S_Right.Add(sortie);
}
if (type.Name == "Decodeur")
{
int nbr_sortie = 0;
if (outil.getnbrsoryies() == 2) { nbr_sortie = 2; }
if (outil.getnbrsoryies() == 4) { nbr_sortie = 4; }
for (int i = 0; i < nbr_sortie; i++)
{
string es = (outil.getnbrsoryies() + 1).ToString();
string etiq_s = ("Sortie " + es);
Sortie sortie = new Sortie(etiq_s, 1, Disposition.right, false, new List<OutStruct>());
outil.AjoutSortie(sortie);
S_Right.Add(sortie);
}
string ee = (outil.getnbrentrees() + 1).ToString();
string etiq_e = ("Entrée " + ee);
ClasseEntree classeEntree = new ClasseEntree(etiq_e, 1, Disposition.left, false, false);
outil.AjoutEntree(classeEntree);
E_Left.Insert(0, classeEntree);
}
if (type.Name == "AddNbits")
{
if (outil.getnbrentrees() < 10)
{
string ee = (outil.getnbrsoryies()).ToString();
string A = ("A" + ee);
ClasseEntree classeEntreeA = new ClasseEntree(A, 1, Disposition.up, false, false);
outil.AjoutEntreeSpe(classeEntreeA, outil.getnbrsoryies() - 1);
E_Up.Insert((outil.getnbrsoryies()) - 1, classeEntreeA);
string B = ("B" + ee);
ClasseEntree classeEntreeB = new ClasseEntree(B, 1, Disposition.up, false, false);
outil.AjoutEntreeSpe(classeEntreeB, 2 * (outil.getnbrsoryies()) - 1);
E_Up.Insert(0, classeEntreeB);
string es = (outil.getnbrsoryies()).ToString();
string etiq_s = ("Somme" + es);
Sortie sortie = new Sortie(etiq_s, 1, Disposition.down, false, new List<OutStruct>());
outil.AjoutSortieSpe(sortie, outil.getnbrsoryies() - 1);
S_Down.Insert(1, sortie);
}
}
if (type.Name == "Multiplexeur")
{
if (outil.getnbrentrees() < 11)
{
int entree = 0; string etiq = ""; int a = 0; int b = 0;
if (outil.getnbrentrees() == 3) { entree = 2; etiq = "Controle 2"; a = 1; }
if (outil.getnbrentrees() == 6) { entree = 4; etiq = "Controle 3"; a = 2; b = 1; }
for (int i = 0; i < entree; i++)
{
string ee = (outil.getnbrentrees() - b).ToString();
string etiq_e = ("Entrée " + ee);
ClasseEntree classeEntree = new ClasseEntree(etiq_e, 1, Disposition.left, false, false);
outil.AjoutEntree(classeEntree);
E_Left.Insert(0, classeEntree);
}
ClasseEntree Controle = new ClasseEntree(etiq, 1, Disposition.up, false, false);
outil.AjoutEntreeSpe(Controle, a);
E_Up.Insert(0, Controle);
}
}
if (type.Name == "Demultiplexeur")
{
if (outil.getnbrsoryies() < 8)
{
int nsortie = 0; string etiq = ""; int a = 0;
if (outil.getnbrentrees() == 2) { nsortie = 2; etiq = "Controle 2"; a = 1; }
if (outil.getnbrentrees() == 3) { nsortie = 4; etiq = "Controle 3"; a = 2; }
for (int i = 0; i < nsortie; i++)
{
string es = (outil.getnbrsoryies() + 1).ToString();
string etiq_s = ("Sortie " + es);
Sortie sortie = new Sortie(etiq_s, 1, Disposition.right, false, new List<OutStruct>());
outil.AjoutSortie(sortie);
S_Right.Add(sortie);
}
ClasseEntree Controle = new ClasseEntree(etiq, 1, Disposition.up, false, false);
outil.AjoutEntreeSpe(Controle, a);
E_Up.Insert(0, Controle);
}
}
if (type.Name == "Compteur")
{
if (outil.getnbrsoryies() < 5)
{
string es = (outil.getnbrsoryies() + 1).ToString();
string etiq_s = ("Sortie" + es);
Sortie sortie = new Sortie(etiq_s, 1, Disposition.down, false, new List<OutStruct>());
outil.AjoutSortie(sortie);
S_Down.Insert(0, sortie);
}
}
if (type.Name == "Reg_Dec")
{
if (outil.getnbrsoryies() < 8)
{
string ee = (outil.getnbrsoryies() + 1).ToString();
string Entree = ("Entrée" + ee);
ClasseEntree classeEntree = new ClasseEntree(Entree, 1, Disposition.up, false, false);
outil.AjoutEntree(classeEntree);
E_Up.Insert(0, classeEntree);
string es = (outil.getnbrsoryies() + 1).ToString();
string etiq_s = ("Sortie" + es);
Sortie sortie = new Sortie(etiq_s, 1, Disposition.down, false, new List<OutStruct>());
outil.AjoutSortie(sortie);
S_Down.Insert(0, sortie);
}
}
MAJ();
Creation();
MAJ_Path();
}
/// <summary>
/// Supprimer une entrée
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SupprimerEntrée(object sender, RoutedEventArgs e)
{
Type type = outil.GetType();
if ((type.Name == "ET") || (type.Name == "OU") || (type.Name == "NAND") || (type.Name == "OUX") || (type.Name == "NOR"))
{
if (outil.getnbrentrees() > 2)
{
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
}
}
if (type.Name == "Encodeur")
{
if (outil.getnbrentrees() == 4)
{
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
}
if (outil.getnbrentrees() == 8)
{
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
}
}
if (type.Name == "Decodeur")
{
if (outil.getnbrentrees() == 2)
{
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
}
if (outil.getnbrentrees() == 3)
{
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
S_Right.Remove(S_Right[S_Right.Count - 1]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
E_Left.Remove(E_Left[0]);
}
}
if (type.Name == "AddNbits")
{
if (outil.getnbrentrees() > 2)
{
int entree = 0, sortie = 0;
if (outil.getnbrentrees() == 4) { entree = 1; sortie = 3; }
if (outil.getnbrentrees() == 6) { entree = 2; sortie = 5; }
if (outil.getnbrentrees() == 8) { entree = 3; sortie = 7; }
if (outil.getnbrentrees() == 10) { entree = 4; sortie = 9; }
if (outil.getListeentrees()[sortie].getRelated()) { outil.getListeentrees()[sortie].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[sortie]);
if (outil.getListeentrees()[entree].getRelated()) { outil.getListeentrees()[entree].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[entree]);
if (outil.getListesorties()[entree].getSortie() != null) { outil.getListesorties()[entree].Supprimer(); }
outil.SupprimerSortie(outil.getListesorties()[entree]);
E_Up.Remove(E_Up[outil.getnbrsoryies()]);
E_Up.Remove(E_Up[0]);
S_Down.Remove(S_Down[1]);
}
}
if (type.Name == "Multiplexeur")
{
if (outil.getnbrentrees() > 3)
{
int entree = 0, id = 0;
if (outil.getnbrentrees() == 11) { entree = 4; id = 2; }
if (outil.getnbrentrees() == 6) { entree = 2; id = 1; }
for (int i = 0; i < entree; i++)
{
E_Left.Remove(E_Left[0]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
}
E_Up.Remove(E_Up[0]);
if (outil.getListeentrees()[id].getRelated()) { outil.getListeentrees()[id].Supprimer(); }
outil.SupprimerEntree(outil.getListeentrees()[id]);
}
}
if (type.Name == "Demultiplexeur")
{
if (outil.getnbrsoryies() > 2)
{
int sortie = 0, id = 0;
if (outil.getnbrsoryies() == 8) { sortie = 4; id = 2; }
if (outil.getnbrsoryies() == 4) { sortie = 2; id = 1; }
for (int i = 0; i < sortie; i++)
{
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
S_Right.Remove(S_Right[S_Right.Count - 1]);
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
}
if (outil.getListeentrees()[id].getRelated()) { outil.getListeentrees()[id].Supprimer(); }
E_Up.Remove(E_Up[0]);
outil.SupprimerEntree(outil.getListeentrees()[id]);
}
}
if (type.Name == "Compteur")
{
if (outil.getnbrsoryies() > 2)
{
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
S_Down.Remove(S_Down[0]);
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
}
}
if (type.Name == "Reg_Dec")
{
if (outil.getnbrsoryies() > 4)
{
if (outil.getListesorties()[outil.getnbrsoryies() - 1].getSortie() != null) { outil.getListesorties()[outil.getnbrsoryies() - 1].Supprimer(); }
S_Down.Remove(S_Down[0]);
outil.SupprimerSortie(outil.getListesorties()[outil.getnbrsoryies() - 1]);
if (outil.getListeentrees()[outil.getnbrentrees() - 1].getRelated()) { outil.getListeentrees()[outil.getnbrentrees() - 1].Supprimer(); }
E_Up.Remove(E_Up[0]);
outil.SupprimerEntree(outil.getListeentrees()[outil.getnbrentrees() - 1]);
}
}
MAJ_Path();
MAJ();
Creation();
}
/// <summary>
/// Ajoyter une étiquette au composant
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AjouterLabel(object sender, MouseButtonEventArgs e)
{
AjoutLabel ajoutLabel = new AjoutLabel();
ajoutLabel.InputChanged += OnDialogInputChanged;
ajoutLabel.Show();
}
private void OnDialogInputChanged(object sender, DialogInputEventArgs e)
{
System.Windows.Controls.ToolTip tt = new System.Windows.Controls.ToolTip();
tt.Content = e.Input;
outil.setLabel(e.Input);
path.ToolTip = tt;
}
//Suppression
//**************************************************************
/// <summary>
/// Supprimer le composant
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Supprimer(object sender, MouseButtonEventArgs e)
{
RaiseEvent(new RoutedEventArgs(DeletingGateEvent));
}
public static readonly RoutedEvent DeletingGateEvent = EventManager.RegisterRoutedEvent(
"DeletingGate", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Gate));
public event RoutedEventHandler DeletingGate
{
add { AddHandler(DeletingGateEvent, value); }
remove { RemoveHandler(DeletingGateEvent, value); }
}
//Fin Suppression
//*************************************************************
#endregion
#region Drag&Drop
//Drag Drop
//les attributs
public bool added;
public Point currentPoint;
public TranslateTransform transform = new TranslateTransform();
public Point anchorPoint;
protected override void OnGiveFeedback(System.Windows.GiveFeedbackEventArgs e)
{
base.OnGiveFeedback(e);
// These Effects values are set in the drop target's
// DragOver event handler.
if (e.Effects.HasFlag(System.Windows.DragDropEffects.Copy))
{
Mouse.SetCursor(System.Windows.Input.Cursors.Cross);
}
else if (e.Effects.HasFlag(System.Windows.DragDropEffects.Move))
{
Mouse.SetCursor(System.Windows.Input.Cursors.Pen);
}
else
{
Mouse.SetCursor(System.Windows.Input.Cursors.No);
}
e.Handled = true;
}
private void path_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
Gate gate;
Canvas a = new Canvas();
if (this.Parent.GetType().IsInstanceOfType(a))//le cas de la grille
{ gate = this; }
else { gate = this.Copier(); }//le cas du menu
//transfert de l'information
DataObject data = new DataObject();
data.SetData("String", "Gate");
data.SetData("Object", gate);//l'outils à copier
// Inititate the drag-and-drop operation.
DragDrop.DoDragDrop(this, data, DragDropEffects.All);
}
}
private Gate Copier()
{
Gate o = this;
Gate outils = new Et();
//porte logique
if (o is Et) { outils = new Et(); }
if (o is Ou) { outils = new Ou(); }
if (o is Non) { outils = new Non(); }
if (o is Nand) { outils = new Nand(); }
if (o is Nor) { outils = new Nor(); }
if (o is Oux) { outils = new Oux(); }
if (o is Add_C) { outils = new Add_C(); }
if (o is Add_N) { outils = new Add_N(); }
if (o is Cpt) { outils = new Cpt(); }
if (o is BasculeD) { outils = new BasculeD(); }
if (o is Decod) { outils = new Decod(); }
if (o is D_Add) { outils = new D_Add(); }
if (o is Demux) { outils = new Demux(); }
if (o is Encod) { outils = new Encod(); }
if (o is horloge) { outils = new horloge(); }
if (o is BasculeJk) { outils = new BasculeJk(); }
if (o is Mux) { outils = new Mux(); }
if (o is Reg) { outils = new Reg(); }
if (o is BasculeRst) { outils = new BasculeRst(); }
if (o is BasculeT) { outils = new BasculeT(); }
//à ajouter less pins
if (o is pin_entree) { outils = new pin_entree(); }
if (o is pin_sortie) { outils = new pin_sortie(); }
if (o is constantetrue) { outils = new constantetrue(); }
if (o is constantefalse) { outils = new constantefalse(); }
//le circuits personalisé aussi
return outils;
}
public List<ClasseEntree> getE_left() { return this.E_Left; }
public List<Sortie> getS_right() { return this.S_Right; }
public Outils GetOutil()
{
return outil;
}
//Liaison
public List<InputOutput> InputOutputs;
#endregion
}
#region Les paths de chaque outil spécifique
//la partie portes logiques
[Serializable]
public class Et : Gate
{
public Et() : base(new ET(), "M 17,17 v 30 h 15 a 2,2 1 0 0 0,-30 h -15") { }
}
class Ou : Gate
{
public Ou() : base(new OU(), "M 15,17 h 10 c 10,0 20,5 25,15 c -5,10 -15,15 -25,15 h -10 c 5,-10 5,-20 0,-30") { }
}
[Serializable]
public class Non : Gate
{
public Non() : base(new NON(), "M 15,17 v 30 l 30,-15 l -30,-15 M 46,33.5 a 3,3 1 1 1 0.1,0.1") { }
}
[Serializable]
public class Nor : Gate
{
public Nor() : base(new NOR(), "M 15,17 h 5 c 10,0 20,5 25,15 c -5,10 -15,15 -25,15 h -5 c 5,-10 5,-20 0,-30 M 46,33.5 a 3,3 1 1 1 0.1,0.1") { }
}
[Serializable]
public class Nand : Gate
{
public Nand() : base(new NAND(), "M 15,17 v 30 h 15 a 2,2 1 0 0 0,-30 h -15 M 46,33.5 a 3,3 1 1 1 0.1,0.1") { }
}
[Serializable]
public class Oux : Gate
{
public Oux() : base(new OUX(), "M 13,47 c 5,-10 5,-20 0,-30 M 13,17 c 5,10 5,20 0,30 M 18,17 h 7 c 10,0 20,5 25,15 c -5,10 -15,15 -25,15 h -7 c 5,-10 5,-20 0,-30") { }
}
//la partie Combinatoires
[Serializable]
public class Add_C : Gate
{ //need to fix writting:too small
public Add_C() : base(new AddComplet(), "M0.5,0.5 L78.833,0.5 L78.833,95.5 L0.5,95.5 z M14.163449,21.874763 L12.598018,26.673256 L15.735716,26.673256 z M13.363644,20.494 L15.031614,20.494 L18.463258,30.672 L17.034545,30.672 L16.111693,27.828449 L12.222041,27.828449 L11.299189,30.672 L9.932,30.672 z M20.779445,21.656028 L20.779445,29.509972 L21.811672,29.509972 C22.413235,29.509972 22.939603,29.462124 23.390775,29.366427 C23.841947,29.270731 24.254382,29.093009 24.628081,28.833261 C25.097482,28.514273 25.450672,28.089336 25.687652,27.558448 C25.924631,27.02756 26.043121,26.36566 26.043121,25.572747 C26.043121,24.788948 25.913238,24.120212 25.653472,23.566539 C25.393707,23.012868 25.008614,22.581094 24.498198,22.27122 C24.138171,22.052485 23.75308,21.895269 23.342924,21.799573 C22.932767,21.703876 22.422349,21.656028 21.811672,21.656028 z M19.425928,20.494 L21.743313,20.494 C22.700345,20.494 23.451159,20.565772 23.995756,20.709317 C24.540352,20.852862 25.004058,21.049951 25.386871,21.300584 C26.043121,21.733497 26.551258,22.308815 26.911286,23.026538 C27.271312,23.744261 27.451326,24.599833 27.451326,25.593253 C27.451326,26.522876 27.263337,27.361359 26.88736,28.108702 C26.511383,28.856046 26.006662,29.439339 25.373199,29.85858 C24.858224,30.182125 24.335274,30.398582 23.80435,30.507949 C23.273424,30.617316 22.595526,30.672 21.770657,30.672 L19.425928,30.672 z M30.276119,21.656028 L30.276119,29.509972 L31.308347,29.509972 C31.90991,29.509972 32.436277,29.462124 32.88745,29.366427 C33.338622,29.270731 33.751056,29.093009 34.124755,28.833261 C34.594156,28.514273 34.947346,28.089336 35.184327,27.558448 C35.421305,27.02756 35.539796,26.36566 35.539796,25.572747 C35.539796,24.788948 35.409913,24.120212 35.150147,23.566539 C34.890381,23.012868 34.505289,22.581094 33.994872,22.27122 C33.634845,22.052485 33.249755,21.895269 32.839598,21.799573 C32.429441,21.703876 31.919023,21.656028 31.308347,21.656028 z M28.922602,20.494 L31.239987,20.494 C32.197019,20.494 32.947832,20.565772 33.492431,20.709317 C34.037027,20.852862 34.500732,21.049951 34.883545,21.300584 C35.539796,21.733497 36.047933,22.308815 36.40796,23.026538 C36.767986,23.744261 36.948,24.599833 36.948,25.593253 C36.948,26.522876 36.760012,27.361359 36.384035,28.108702 C36.008058,28.856046 35.503337,29.439339 34.869873,29.85858 C34.354898,30.182125 33.831948,30.398582 33.301024,30.507949 C32.770098,30.617316 32.092201,30.672 31.267331,30.672 L28.922602,30.672 z M15.031084,42.209435 C15.372881,42.209435 15.693031,42.2345 15.991534,42.28463 C16.290037,42.33476 16.566892,42.398561 16.822102,42.476034 C17.040852,42.544393 17.265299,42.629841 17.495442,42.732379 C17.725586,42.834917 17.952311,42.947709 18.175619,43.070755 L18.175619,44.704529 L18.066244,44.704529 C17.947754,44.595155 17.795084,44.462995 17.608235,44.308048 C17.421386,44.153103 17.193521,44.000434 16.924641,43.850045 C16.664875,43.708771 16.382322,43.592561 16.076984,43.501415 C15.771644,43.410271 15.418454,43.364698 15.017412,43.364698 C14.584469,43.364698 14.174312,43.453564 13.786942,43.631297 C13.399571,43.80903 13.060053,44.071072 12.768386,44.417422 C12.481276,44.763774 12.257968,45.198991 12.098463,45.723074 C11.938958,46.247158 11.859205,46.837322 11.859205,47.493566 C11.859205,48.190825 11.943515,48.791242 12.112135,49.294819 C12.280755,49.798395 12.510898,50.223358 12.802565,50.569709 C13.085118,50.906946 13.417801,51.161013 13.800614,51.331909 C14.183427,51.502806 14.589026,51.588255 15.017412,51.588255 C15.409339,51.588255 15.771644,51.540404 16.104327,51.444701 C16.437009,51.348999 16.733234,51.228232 16.993,51.0824 C17.243652,50.941125 17.460123,50.796433 17.642415,50.648322 C17.824706,50.500211 17.968261,50.373747 18.07308,50.268931 L18.175619,50.268931 L18.175619,51.882197 C17.952311,51.987014 17.741536,52.087274 17.543294,52.182976 C17.345052,52.278678 17.104654,52.372102 16.822102,52.463247 C16.525877,52.558949 16.2513,52.631865 15.99837,52.681995 C15.74544,52.732124 15.416175,52.757189 15.010576,52.757189 C14.34521,52.757189 13.733393,52.645537 13.175124,52.422231 C12.616855,52.198926 12.134921,51.866247 11.729322,51.424194 C11.323722,50.98214 11.009269,50.430714 10.785961,49.769912 C10.562654,49.109111 10.451,48.350329 10.451,47.493566 C10.451,46.641361 10.559236,45.898529 10.775707,45.265071 C10.992179,44.631613 11.307772,44.080186 11.722486,43.610789 C12.128085,43.155065 12.60888,42.807574 13.164871,42.568318 C13.720861,42.329063 14.342932,42.209435 15.031084,42.209435 z M22.214127,45.832448 C21.544204,45.832448 21.02809,46.072844 20.665785,46.553633 C20.30348,47.034423 20.122327,47.769279 20.122327,48.758203 C20.122327,49.715225 20.30348,50.440967 20.665785,50.935429 C21.02809,51.42989 21.544204,51.677121 22.214127,51.677121 C22.874935,51.677121 23.386491,51.434448 23.748797,50.9491 C24.111102,50.463753 24.292254,49.733454 24.292254,48.758203 C24.292254,47.769279 24.112241,47.034423 23.752215,46.553633 C23.392188,46.072844 22.879492,45.832448 22.214127,45.832448 z M22.214127,44.725037 C23.244076,44.725037 24.068946,45.077084 24.688739,45.781179 C25.308532,46.485274 25.618428,47.477616 25.618428,48.758203 C25.618428,50.043347 25.308532,51.035689 24.688739,51.735226 C24.068946,52.434764 23.244076,52.784533 22.214127,52.784533 C21.152277,52.784533 20.317152,52.423371 19.708753,51.701047 C19.100353,50.978722 18.796154,49.997774 18.796154,48.758203 C18.796154,47.482173 19.109468,46.490971 19.736096,45.784597 C20.362725,45.078224 21.188735,44.725037 22.214127,44.725037 z M30.31316,44.725037 C30.764332,44.725037 31.164235,44.827575 31.512868,45.032651 C31.861502,45.237727 32.126965,45.574964 32.309256,46.044361 C32.696626,45.611422 33.074882,45.2833 33.444023,45.059995 C33.813164,44.83669 34.214206,44.725037 34.64715,44.725037 C34.975275,44.725037 35.273777,44.776306 35.542658,44.878844 C35.81154,44.981382 36.046239,45.146583 36.246761,45.374445 C36.451839,45.606865 36.610205,45.896251 36.721859,46.242601 C36.833514,46.588952 36.88934,47.024169 36.88934,47.548253 L36.88934,52.572621 L35.604182,52.572621 L35.604182,48.156646 C35.604182,47.805738 35.59051,47.481034 35.563166,47.182534 C35.535823,46.884033 35.478856,46.650475 35.392268,46.481857 C35.301121,46.299567 35.171238,46.165128 35.002619,46.07854 C34.833999,45.991953 34.606134,45.948659 34.319024,45.948658 C34.054701,45.948659 33.77101,46.02955 33.467949,46.191332 C33.164888,46.353115 32.851575,46.586673 32.528006,46.892009 C32.532563,46.969482 32.53826,47.061766 32.545096,47.168862 C32.551932,47.275958 32.55535,47.402421 32.55535,47.548253 L32.55535,52.572621 L31.270192,52.572621 L31.270192,48.156646 C31.270192,47.805738 31.25652,47.481034 31.229176,47.182534 C31.201833,46.884033 31.144866,46.650475 31.058278,46.481857 C30.967131,46.299567 30.837248,46.165128 30.668629,46.07854 C30.50001,45.991953 30.272144,45.948659 29.985034,45.948658 C29.70704,45.948659 29.415372,46.035246 29.110033,46.208422 C28.804695,46.381597 28.50847,46.602624 28.22136,46.871501 L28.22136,52.572621 L26.936202,52.572621 L26.936202,44.936949 L28.22136,44.936949 L28.22136,45.784597 C28.558601,45.447361 28.892422,45.186458 29.222826,45.00189 C29.553231,44.817321 29.916675,44.725037 30.31316,44.725037 z M42.001485,45.948658 C41.636899,45.948659 41.284847,46.02955 40.945329,46.191332 C40.605811,46.353115 40.283381,46.561609 39.978043,46.816814 L39.978043,51.143923 C40.315284,51.307984 40.603532,51.419636 40.84279,51.478881 C41.082048,51.538125 41.356625,51.567747 41.666522,51.567747 C42.331888,51.567747 42.849142,51.323934 43.218283,50.836309 C43.587421,50.348683 43.771991,49.635473 43.771995,48.69668 C43.771991,47.826245 43.632995,47.150633 43.355002,46.669843 C43.077006,46.189054 42.625833,45.948659 42.001485,45.948658 z M42.315938,44.725037 C43.19094,44.725037 43.873394,45.071388 44.363304,45.76409 C44.853211,46.456792 45.098169,47.38647 45.098169,48.553126 C45.098169,49.824599 44.793969,50.837448 44.18557,51.591673 C43.577171,52.345897 42.808127,52.72301 41.878436,52.72301 C41.50018,52.72301 41.165218,52.679716 40.873552,52.593128 C40.581886,52.50654 40.283381,52.372102 39.978043,52.189812 L39.978043,55.389 L38.692885,55.389 L38.692885,44.936949 L39.978043,44.936949 L39.978043,45.736746 C40.297053,45.449639 40.651384,45.209245 41.041033,45.015561 C41.430682,44.821879 41.855649,44.725037 42.315938,44.725037 z M46.456904,41.936 L47.742062,41.936 L47.742062,52.572621 L46.456904,52.572621 z M52.562186,45.784597 C52.220389,45.784598 51.929861,45.835867 51.690603,45.938405 C51.451345,46.040943 51.233735,46.190193 51.03777,46.386154 C50.846364,46.586673 50.700531,46.808839 50.60027,47.052652 C50.500008,47.296465 50.436207,47.580154 50.408863,47.903718 L54.448907,47.903718 C54.439794,47.557367 54.398778,47.258868 54.32586,47.008219 C54.252942,46.75757 54.148126,46.545658 54.011407,46.372483 C53.861016,46.181078 53.668469,46.035246 53.433769,45.934987 C53.19907,45.834728 52.908542,45.784598 52.562186,45.784597 z M52.637382,44.725037 C53.111339,44.725037 53.530613,44.793396 53.895196,44.930113 C54.259778,45.066831 54.57879,45.281021 54.852228,45.572685 C55.125666,45.86435 55.335303,46.220955 55.481135,46.6425 C55.626967,47.064045 55.699885,47.580154 55.699885,48.190825 L55.699885,48.888084 L50.408863,48.888084 C50.408863,49.776748 50.632172,50.455778 51.078786,50.925175 C51.5254,51.394572 52.142916,51.62927 52.931327,51.62927 C53.213878,51.62927 53.490734,51.597369 53.761895,51.533568 C54.033055,51.469767 54.278009,51.387736 54.496759,51.287476 C54.729181,51.18266 54.925146,51.08126 55.08465,50.98328 C55.244154,50.885299 55.376319,50.793015 55.481135,50.706427 L55.556331,50.706427 L55.556331,52.107781 C55.40594,52.167026 55.219092,52.241081 54.995783,52.329947 C54.772474,52.418813 54.571954,52.488312 54.39422,52.538441 C54.143567,52.6068 53.916844,52.659209 53.714043,52.695666 C53.511242,52.732124 53.254894,52.750353 52.944999,52.750353 C51.728201,52.750353 50.7837,52.40742 50.1115,51.721554 C49.439299,51.035689 49.103197,50.061576 49.103197,48.799218 C49.103197,47.555089 49.429046,46.565027 50.080738,45.829031 C50.73243,45.093035 51.584646,44.725037 52.637382,44.725037 z M57.081605,42.742633 L58.366763,42.742633 L58.366763,44.936949 L60.732,44.936949 L60.732,46.003345 L58.366763,46.003345 L58.366763,49.633195 C58.366763,50.020561 58.373599,50.31906 58.387271,50.528694 C58.400942,50.738328 58.453353,50.934289 58.544497,51.116579 C58.62197,51.276083 58.747298,51.395711 58.920474,51.475463 C59.09365,51.555215 59.328354,51.595091 59.624577,51.595091 C59.834214,51.595091 60.037011,51.564329 60.232976,51.502806 C60.428941,51.441283 60.570215,51.390014 60.656805,51.348999 L60.732,51.348999 L60.732,52.504262 C60.490465,52.572621 60.245507,52.626168 59.997136,52.664905 C59.748764,52.703642 59.51976,52.72301 59.310123,52.72301 C58.608298,52.72301 58.061422,52.52363 57.669496,52.124871 C57.27757,51.726112 57.081605,51.096072 57.081605,50.234752 L57.081605,46.003345 L56.21344,46.003345 L56.21344,44.936949 L57.081605,44.936949 z") { }
}
[Serializable]
public class Add_N : Gate
{ //need to fix writting: too small
public Add_N() : base(new AddNbits(), "M0.5, 0.5 L65.5, 0.5 L65.5, 85.5 L0.5, 85.5 z M20.28717, 19.56749 C20.248107, 19.805762 20.203185, 19.993254 20.152403, 20.129967 L18.845746, 23.709898 L21.757891, 23.709898 L20.439516, 20.129967 C20.396546, 20.012784 20.353577, 19.825292 20.310608, 19.56749 z M19.806696, 18.548 L20.826239, 18.548 L24.060654, 26.95 L22.970797, 26.95 L22.080161, 24.594628 L18.517617, 24.594628 L17.679717, 26.95 L16.584, 26.95 z M26.281149, 19.438589 L26.281149, 26.059411 L27.535071, 26.059411 C28.636647, 26.059411 29.494079, 25.764502 30.107368, 25.174682 C30.720657, 24.584862 31.027301, 23.748959 31.027301, 22.666972 C31.027301, 20.514717 29.882756, 19.438589 27.593665, 19.438589 z M25.296762, 18.548 L27.617103, 18.548 C30.578077, 18.548 32.058564, 19.913179 32.058564, 22.643536 C32.058564, 23.940358 31.647426, 24.982307 30.82515, 25.769384 C30.002874, 26.556461 28.902275, 26.95 27.523352, 26.95 L25.296762, 26.95 z M34.694586, 19.438589 L34.694586, 26.059411 L35.948507, 26.059411 C37.050083, 26.059411 37.907516, 25.764502 38.520804, 25.174682 C39.134093, 24.584862 39.440737, 23.748959 39.440737, 22.666972 C39.440737, 20.514717 38.296192, 19.438589 36.007102, 19.438589 z M33.710199, 18.548 L36.03054, 18.548 C38.991513, 18.548 40.472, 19.913179 40.472, 22.643536 C40.472, 23.940358 40.060862, 24.982307 39.238587, 25.769384 C38.416311, 26.556461 37.315712, 26.95 35.936788, 26.95 L33.710199, 26.95 z M20.3811, 41.769827 C21.037344, 41.769828 21.539293, 41.981739 21.886946, 42.405561 C22.2346, 42.829384 22.408426, 43.441682 22.408426, 44.242453 L22.408426, 47.910377 L21.447497, 47.910377 L21.447497, 44.488544 C21.447497, 43.215122 20.982657, 42.578411 20.052978, 42.578411 C19.572513, 42.578411 19.175055, 42.759073 18.860605, 43.120396 C18.546155, 43.48172 18.388929, 43.937769 18.388929, 44.488544 L18.388929, 47.910377 L17.428, 47.910377 L17.428, 41.91045 L18.388929, 41.91045 L18.388929, 42.906532 L18.412367, 42.906532 C18.865488, 42.148729 19.521732, 41.769828 20.3811, 41.769827 z M28.617853, 43.996362 L28.617853, 47.019763 L29.953779, 47.019763 C30.531899, 47.019763 30.980137, 46.883046 31.298494, 46.609611 C31.616851, 46.336177 31.776029, 45.961182 31.776029, 45.484625 C31.776029, 44.49245 31.100254, 43.996362 29.748703, 43.996362 z M28.617853, 40.39875 L28.617853, 43.111607 L29.625657, 43.111607 C30.164715, 43.111607 30.588539, 42.981726 30.89713, 42.721964 C31.205721, 42.462201 31.360017, 42.095995 31.360017, 41.623345 C31.360017, 40.806949 30.822912, 40.398751 29.748703, 40.39875 z M27.633486, 39.508136 L30.024091, 39.508136 C30.750647, 39.508136 31.326814, 39.685868 31.752592, 40.041333 C32.178369, 40.396798 32.391258, 40.859682 32.391258, 41.429988 C32.391258, 41.906544 32.262353, 42.320602 32.004543, 42.67216 C31.746732, 43.023718 31.391267, 43.273715 30.938146, 43.422151 L30.938146, 43.445588 C31.504547, 43.511993 31.957668, 43.725858 32.297509, 44.087181 C32.637349, 44.448505 32.807269, 44.918226 32.807271, 45.496344 C32.807269, 46.215085 32.549459, 46.797109 32.033839, 47.242416 C31.518219, 47.687723 30.867834, 47.910377 30.082684, 47.910377 L27.633486, 47.910377 z M34.384523, 41.91045 L35.345452, 41.91045 L35.345452, 47.910377 L34.384523, 47.910377 z M34.876706, 39.139 C35.052486, 39.139 35.201898, 39.19857 35.324944, 39.317709 C35.44799, 39.436848 35.509513, 39.58626 35.509513, 39.765945 C35.509513, 39.937819 35.44799, 40.084301 35.324944, 40.205393 C35.201898, 40.326486 35.052486, 40.387032 34.876706, 40.387032 C34.704832, 40.387032 34.558349, 40.328439 34.437256, 40.211252 C34.316164, 40.094067 34.255617, 39.945631 34.255617, 39.765945 C34.255617, 39.58626 34.316164, 39.436848 34.437256, 39.317709 C34.558349, 39.19857 34.704832, 39.139 34.876706, 39.139 z M38.562637, 40.135082 L38.562637, 41.91045 L40.074343, 41.91045 L40.074343, 42.730753 L38.562637, 42.730753 L38.562637, 46.111571 C38.562637, 46.513909 38.630996, 46.801015 38.767713, 46.972888 C38.904431, 47.144761 39.130992, 47.230698 39.447395, 47.230698 C39.689581, 47.230698 39.898563, 47.164292 40.074343, 47.031481 L40.074343, 47.851784 C39.847782, 47.976782 39.548957, 48.039281 39.177866, 48.039281 C38.127094, 48.039281 37.601708, 47.453351 37.601708, 46.28149 L37.601708, 42.730753 L36.570467, 42.730753 L36.570467, 41.91045 L37.601708, 41.91045 L37.601708, 40.445625 z M43.303092, 41.769827 C43.822619, 41.769828 44.287459, 41.85967 44.697612, 42.039355 L44.697612, 43.011999 C44.256209, 42.72294 43.748401, 42.578411 43.174187, 42.578411 C42.994501, 42.578411 42.832393, 42.598918 42.687863, 42.639934 C42.543333, 42.680949 42.419311, 42.738565 42.315796, 42.812783 C42.212281, 42.887001 42.132204, 42.975867 42.075564, 43.079381 C42.018924, 43.182896 41.990604, 43.297152 41.990604, 43.422151 C41.990604, 43.578399 42.018924, 43.709256 42.075564, 43.814724 C42.132204, 43.920191 42.215211, 44.01394 42.324585, 44.09597 C42.433959, 44.178001 42.566771, 44.252218 42.723019, 44.318624 C42.879268, 44.385029 43.057001, 44.457294 43.256218, 44.535418 C43.52184, 44.636979 43.76012, 44.74147 43.971055, 44.848891 C44.181991, 44.956311 44.361677, 45.077404 44.510113, 45.212168 C44.65855, 45.346932 44.772806, 45.502203 44.852884, 45.677982 C44.932961, 45.853761 44.973, 46.062743 44.973, 46.304928 C44.973, 46.601799 44.907571, 46.859608 44.776713, 47.078356 C44.645854, 47.297103 44.471051, 47.478741 44.252303, 47.623271 C44.033555, 47.7678 43.781604, 47.875221 43.49645, 47.945533 C43.211296, 48.015844 42.912471, 48.051 42.599973, 48.051 C41.982791, 48.051 41.447639, 47.931861 40.994518, 47.693583 L40.994518, 46.662345 C41.517951, 47.049059 42.094118, 47.242416 42.723019, 47.242416 C43.566762, 47.242416 43.988633, 46.96117 43.988633, 46.398677 C43.988633, 46.238522 43.952501, 46.102782 43.880236, 45.991455 C43.807971, 45.880128 43.710315, 45.781497 43.58727, 45.69556 C43.464224, 45.609624 43.319694, 45.532476 43.15368, 45.464118 C42.987665, 45.395759 42.808956, 45.324471 42.617551, 45.250253 C42.351929, 45.144786 42.118532, 45.038342 41.917362, 44.930921 C41.716192, 44.823501 41.548224, 44.702408 41.41346, 44.567644 C41.278696, 44.43288 41.177134, 44.279562 41.108775, 44.107689 C41.040416, 43.935816 41.006237, 43.734647 41.006237, 43.504181 C41.006237, 43.222934 41.07069, 42.973914 41.199595, 42.75712 C41.3285, 42.540325 41.500373, 42.358687 41.715215, 42.212204 C41.930057, 42.065722 42.175172, 41.955372 42.450561, 41.881154 C42.725949, 41.806936 43.010126, 41.769828 43.303092, 41.769827 z") { }
}
[Serializable]
public class D_Add : Gate
{
public D_Add() : base(new DemiAdd(), "M0.5,0.5 L72.167,0.5 L72.167,89.5 L0.5,89.5 z M19.666508,26.263714 L19.666508,35.091978 L21.338393,35.091978 C22.807151,35.091978 23.950387,34.698743 24.768101,33.912272 C25.585814,33.125802 25.994671,32.011201 25.994671,30.568469 C25.994671,27.698633 24.46862,26.263714 21.416519,26.263714 z M18.354,25.076195 L21.447769,25.076195 C25.395709,25.076195 27.36968,26.896536 27.36968,30.537219 C27.36968,32.266413 26.821499,33.655758 25.725138,34.705253 C24.628777,35.754749 23.16132,36.279497 21.322768,36.279497 L18.354,36.279497 z M32.519399,29.17001 C31.915228,29.17001 31.402204,29.38616 30.980327,29.818458 C30.558449,30.250756 30.298031,30.81587 30.199072,31.513797 L34.519412,31.513797 C34.514203,30.774202 34.335817,30.198673 33.984252,29.787207 C33.632687,29.375743 33.144403,29.17001 32.519399,29.17001 z M32.542836,28.091868 C33.589718,28.091868 34.399618,28.430415 34.972539,29.107509 C35.545459,29.784604 35.83192,30.724722 35.83192,31.927866 L35.83192,32.599751 L30.183447,32.599751 C30.20428,33.490391 30.443865,34.177901 30.902201,34.662284 C31.360537,35.146667 31.99075,35.388858 32.792838,35.388858 C33.693885,35.388858 34.522015,35.091978 35.277229,34.498219 L35.277229,35.701363 C34.574098,36.211787 33.644404,36.467 32.488148,36.467 C31.357934,36.467 30.469907,36.103713 29.82407,35.377139 C29.178233,34.650565 28.855314,33.628414 28.855314,32.310684 C28.855314,31.065874 29.20818,30.051535 29.913914,29.267668 C30.619648,28.483802 31.495955,28.091868 32.542836,28.091868 z M41.565807,28.091868 C42.112685,28.091868 42.58925,28.244214 42.995503,28.548906 C43.401755,28.853599 43.680402,29.253345 43.831445,29.748144 C44.425199,28.643961 45.31062,28.091868 46.487711,28.091868 C48.248138,28.091868 49.128352,29.177822 49.128352,31.349732 L49.128352,36.279497 L47.847095,36.279497 L47.847095,31.685675 C47.847095,30.800245 47.710375,30.159609 47.436936,29.763769 C47.163497,29.36793 46.703857,29.17001 46.058021,29.17001 C45.511143,29.17001 45.046297,29.420014 44.663482,29.920022 C44.280667,30.42003 44.089259,31.018998 44.089259,31.716925 L44.089259,36.279497 L42.808002,36.279497 L42.808002,31.529422 C42.808002,29.956481 42.201227,29.17001 40.987678,29.17001 C40.425175,29.17001 39.961631,29.405691 39.597045,29.877052 C39.232459,30.348414 39.050166,30.961705 39.050166,31.716925 L39.050166,36.279497 L37.768909,36.279497 L37.768909,28.279371 L39.050166,28.279371 L39.050166,29.545016 L39.081417,29.545016 C39.649129,28.57625 40.477257,28.091868 41.565807,28.091868 z M51.548991,28.279371 L52.830249,28.279371 L52.830249,36.279497 L51.548991,36.279497 z M52.205245,24.584 C52.439621,24.584 52.638841,24.663429 52.802905,24.822285 C52.966968,24.981142 53.049,25.180364 53.049,25.419951 C53.049,25.649121 52.966968,25.844437 52.802905,26.005897 C52.638841,26.167359 52.439621,26.248089 52.205245,26.248089 C51.976076,26.248089 51.780762,26.169963 51.619304,26.01371 C51.457846,25.857458 51.377115,25.659538 51.377115,25.419951 C51.377115,25.180364 51.457846,24.981142 51.619304,24.822285 C51.780762,24.663429 51.976076,24.584 52.205245,24.584 z M21.994422,47.71636 C21.94234,48.034065 21.882445,48.284062 21.814738,48.466351 L20.072578,53.239736 L23.955329,53.239736 L22.197544,48.466351 C22.140253,48.310103 22.082963,48.060106 22.025672,47.71636 z M21.353807,46.357 L22.713161,46.357 L27.025593,57.56 L25.572491,57.56 L24.38501,54.41941 L19.635084,54.41941 L18.517915,57.56 L17.057,57.56 z M29.986171,47.544487 L29.986171,56.372513 L31.65802,56.372513 C33.126747,56.372513 34.269958,55.979288 35.087654,55.192839 C35.905348,54.40639 36.314197,53.291819 36.314197,51.849126 C36.314197,48.979367 34.788178,47.544487 31.736144,47.544487 z M28.673692,46.357 L31.767393,46.357 C35.715247,46.357 37.689175,48.177292 37.689175,51.817877 C37.689175,53.547024 37.141006,54.936332 36.04467,55.985799 C34.948332,57.035266 33.480907,57.56 31.642395,57.56 L28.673692,57.56 z M41.205996,47.544487 L41.205996,56.372513 L42.877845,56.372513 C44.346572,56.372513 45.489782,55.979288 46.307478,55.192839 C47.125173,54.40639 47.534022,53.291819 47.534022,51.849126 C47.534022,48.979367 46.008003,47.544487 42.955969,47.544487 z M39.893517,46.357 L42.987218,46.357 C46.935072,46.357 48.909,48.177292 48.909,51.817877 C48.909,53.547024 48.360831,54.936332 47.264495,55.985799 C46.168156,57.035266 44.700732,57.56 42.86222,57.56 L39.893517,57.56 z") { }
}
[Serializable]
public class Mux : Gate
{
public Mux() : base(new Multiplexeur(), "M0.5,0.5 L78.5,0.5 L78.5,143.5 L0.5,143.5 z M17.475,55.684 L20.939329,55.684 L23.085308,61.909565 C23.256204,62.407611 23.380715,62.908097 23.45884,63.411025 L23.502785,63.411025 C23.634619,62.829973 23.773778,62.324603 23.920262,61.894917 L26.066243,55.684 L29.442681,55.684 L29.442681,66.186895 L27.106274,66.186895 L27.106274,59.902736 C27.106274,59.224027 27.13557,58.474518 27.194164,57.654208 L27.13557,57.654208 C27.013501,58.298737 26.903639,58.762603 26.805983,59.045805 L24.345065,66.186895 L22.411485,66.186895 L19.906622,59.119047 C19.838263,58.928618 19.7284,58.440339 19.577034,57.654208 L19.511117,57.654208 C19.574593,58.689361 19.606331,59.597561 19.606331,60.378809 L19.606331,66.186895 L17.475,66.186895 z M35.843678,55.684 L38.216707,55.684 L38.216707,61.77773 C38.216707,63.476943 38.880764,64.32655 40.208879,64.32655 C41.51258,64.32655 42.16443,63.50624 42.16443,61.86562 L42.16443,55.684 L44.530134,55.684 L44.530134,61.63857 C44.530134,64.792857 43.060419,66.37 40.120989,66.37 C37.269449,66.37 35.843678,64.829478 35.843678,61.748433 z M50.079831,55.684 L52.958227,55.684 L54.45968,58.833404 C54.576867,59.082426 54.681846,59.377836 54.774619,59.719631 L54.803916,59.719631 C54.862509,59.514554 54.972371,59.209379 55.133503,58.804107 L56.803412,55.684 L59.44011,55.684 L56.29072,60.891502 L59.528,66.186895 L56.722846,66.186895 L54.913778,62.766496 C54.845419,62.639544 54.774619,62.405169 54.701377,62.063374 L54.672081,62.063374 C54.637901,62.224506 54.557335,62.468646 54.430383,62.795793 L52.613991,66.186895 L49.794189,66.186895 L53.141331,60.935448 z") { }
// public Mux() : base(new Multiplexeur(), " M1.1909967, 0.99999997 L1, 155.905 M3.1909926, 155.90501 L58.028002, 106.76201 M3.1910104, 1.0000038 L58.028007, 55.952005 M60.027998, 57.952004 L60.027998, 105.952 M7.1909979, 61.952003 L11.994512, 61.952003 L14.970052, 74.0897 C15.207012, 75.060715 15.379654, 76.036491 15.487979, 77.017026 L15.548911, 77.017026 C15.731709, 75.884175 15.924662, 74.898879 16.12777, 74.06114 L19.103309, 61.952003 L23.784958, 61.952003 L23.784958, 82.429011 L20.545379, 82.429011 L20.545379, 70.177077 C20.545376, 68.85383 20.585998, 67.392547 20.667244, 65.793227 L20.586, 65.793227 C20.416741, 67.049835 20.26441, 67.954213 20.129006, 68.506359 L16.716785, 82.429011 L14.035753, 82.429011 L10.562598, 68.649155 C10.467814, 68.277885 10.315483, 67.325908 10.105604, 65.793227 L10.014205, 65.793227 C10.102219, 67.811416 10.146226, 69.582092 10.146226, 71.105254 L10.146226, 82.429011 L7.1909979, 82.429011 z M26.923102, 61.952003 L30.213459, 61.952003 L30.213459, 73.832666 C30.213459, 77.145543 31.134217, 78.801982 32.975734, 78.801982 C34.783399, 78.801982 35.687231, 77.202662 35.687231, 74.004022 L35.687231, 61.952003 L38.967433, 61.952003 L38.967433, 73.561353 C38.967433, 79.711119 36.929578, 82.786003 32.853869, 82.786003 C28.900025, 82.786003 26.923102, 79.782517 26.923102, 73.775547 z M40.927504, 61.952003 L44.918585, 61.952003 L47.000446, 68.092249 C47.162933, 68.577757 47.308494, 69.153703 47.437129, 69.820086 L47.477751, 69.820086 C47.558994, 69.420256 47.711326, 68.825271 47.934745, 68.035131 L50.250181, 61.952003 L53.906133, 61.952003 L49.539302, 72.104829 L54.027998, 82.429011 L50.138471, 82.429011 L47.630082, 75.760418 C47.535298, 75.512904 47.437129, 75.055955 47.335575, 74.389572 L47.294953, 74.389572 C47.247561, 74.703724 47.135852, 75.179712 46.959824, 75.817536 L44.44128, 82.429011 L40.531442, 82.429011 L45.17247, 72.190507 z") { }
}
[Serializable]
public class Demux : Gate
{
// public Demux() : base(new Demultiplexeur(), "M64.790005,2.1909962 L64.599009,157.096 M64.782013,157.09601 L0.99999998,103.19 M64.971992,1 L1.8099959,55.952004 M1.0000067,55.571 L1.0000067,103.571 M10.566748,75.514262 L10.566748,82.171955 L11.738633,82.171955 C12.764031,82.171955 13.568481,81.864339 14.151983,81.249106 C14.735483,80.633874 15.027234,79.796474 15.027234,78.736908 C15.027234,77.735934 14.737924,76.948583 14.159307,76.374855 C13.580688,75.801126 12.768914,75.514262 11.723984,75.514262 z M8.2010067,73.587999 L11.92174,73.587999 C15.652239,73.587999 17.517488,75.294536 17.517488,78.707611 C17.517488,80.343348 17.008451,81.649496 15.990376,82.626055 C14.972301,83.602614 13.616089,84.090894 11.92174,84.090894 L8.2010067,84.090894 z M22.322645,77.967867 C21.951548,77.967867 21.630501,78.121675 21.359502,78.429291 C21.088504,78.736908 20.923708,79.120207 20.865114,79.57919 L23.626367,79.57919 C23.626367,78.504975 23.191793,77.967867 22.322645,77.967867 z M22.337293,76.407814 C23.431053,76.407814 24.277007,76.73252 24.875157,77.381932 C25.473304,78.031344 25.772379,78.912688 25.772381,80.025966 L25.772381,81.000084 L20.879762,81.000084 C20.957888,82.088947 21.643928,82.633379 22.937884,82.633379 C23.763085,82.633379 24.488189,82.438067 25.113196,82.047444 L25.113196,83.71736 C24.419829,84.088452 23.518943,84.273999 22.410536,84.273999 C21.199589,84.273999 20.25964,83.938306 19.590689,83.266922 C18.921738,82.595537 18.587263,81.659261 18.587263,80.458093 C18.587263,79.21298 18.948594,78.226655 19.671256,77.499119 C20.393918,76.771582 21.282597,76.407814 22.337293,76.407814 z M31.918881,76.407814 C32.978459,76.407814 33.703563,76.874121 34.094191,77.806735 C34.665485,76.874121 35.505335,76.407814 36.613743,76.407814 C38.244615,76.407814 39.060052,77.41367 39.060052,79.425382 L39.060052,84.090894 L36.752904,84.090894 L36.752904,79.813564 C36.752904,78.724701 36.35251,78.180269 35.551722,78.180269 C35.17086,78.180269 34.860799,78.343842 34.621539,78.67099 C34.382279,78.998137 34.26265,79.405851 34.26265,79.89413 L34.26265,84.090894 L31.948178,84.090894 L31.948178,79.769619 C31.948178,78.710052 31.555108,78.180269 30.768969,78.180269 C30.373458,78.180269 30.057293,78.336518 29.820475,78.649017 C29.583657,78.961516 29.465247,79.38632 29.465247,79.923427 L29.465247,84.090894 L27.150776,84.090894 L27.150776,76.590919 L29.465247,76.590919 L29.465247,77.76279 L29.494545,77.76279 C29.733804,77.3624 30.0695,77.036474 30.501633,76.78501 C30.933765,76.533546 31.406181,76.407814 31.918881,76.407814 z M40.7737,76.590919 L43.080848,76.590919 L43.080848,80.912193 C43.080848,81.97176 43.500773,82.501544 44.340623,82.501544 C44.755666,82.501544 45.0877,82.35628 45.336725,82.065754 C45.585751,81.775228 45.710263,81.380942 45.710263,80.882897 L45.710263,76.590919 L48.017411,76.590919 L48.017411,84.090894 L45.710263,84.090894 L45.710263,82.94832 L45.673642,82.94832 C45.102348,83.832106 44.338182,84.273999 43.381143,84.273999 C41.642848,84.273999 40.7737,83.221756 40.7737,81.117271 z M49.202571,76.590919 L51.883257,76.590919 L52.952601,78.692962 C53.094204,78.971282 53.194302,79.205656 53.252897,79.396085 L53.282194,79.396085 C53.360319,79.166594 53.465301,78.927337 53.597138,78.678314 L54.688455,76.590919 L57.208007,76.590919 L54.732401,80.223719 L57.193358,84.090894 L54.527321,84.090894 L53.443328,82.069416 C53.355436,81.908284 53.250455,81.681234 53.128384,81.388266 L53.099087,81.388266 C53.025844,81.593344 52.925745,81.813069 52.798791,82.047444 L51.707474,84.090894 L49.048761,84.090894 L51.582961,80.355555 z") { }
public Demux() : base(new Demultiplexeur(), "M0.5, 0.5 L99.5, 0.5 L99.5, 142.5 L0.5, 142.5 z M11.128565, 58.15589 L11.128565, 68.08718 L13.009429, 68.08718 C14.661775, 68.08718 15.947911, 67.644813 16.867835, 66.760078 C17.787759, 65.875344 18.24772, 64.621482 18.24772, 62.998492 C18.24772, 59.770091 16.53092, 58.15589 13.097319, 58.15589 z M9.652, 56.82 L13.132476, 56.82 C17.573891, 56.820001 19.794599, 58.86778 19.794599, 62.963337 C19.794599, 64.908581 19.177898, 66.471514 17.944497, 67.652136 C16.711096, 68.832759 15.060214, 69.42307 12.99185, 69.42307 L9.652, 69.42307 z M27.202035, 56.82 L33.600485, 56.82 L33.600485, 58.15589 L28.6786, 58.15589 L28.6786, 62.348125 L33.231344, 62.348125 L33.231344, 63.675226 L28.6786, 63.675226 L28.6786, 68.08718 L33.881736, 68.08718 L33.881736, 69.42307 L27.202035, 69.42307 z M41.23873, 56.82 L43.189906, 56.82 L47.057101, 65.608752 C47.35593, 66.282556 47.549289, 66.786444 47.63718, 67.120417 L47.689915, 67.120417 C47.941868, 66.429035 48.144017, 65.913428 48.296361, 65.573597 L52.242658, 56.82 L54.088365, 56.82 L54.088365, 69.42307 L52.620589, 69.42307 L52.620589, 60.968291 C52.620589, 60.300346 52.661604, 59.482992 52.743636, 58.516229 L52.70848, 58.516229 C52.567854, 59.084568 52.441877, 59.491781 52.330549, 59.737866 L48.0239, 69.42307 L47.303195, 69.42307 L43.005335, 59.808176 C42.882288, 59.526936 42.756311, 59.096287 42.627405, 58.516229 L42.592248, 58.516229 C42.639123, 59.020118 42.662561, 59.843331 42.662561, 60.985868 L42.662561, 69.42307 L41.23873, 69.42307 z M62.173903, 56.82 L63.650469, 56.82 L63.650469, 64.431059 C63.650469, 67.014952 64.740315, 68.306898 66.920007, 68.306898 C69.023526, 68.306898 70.075286, 67.058896 70.075286, 64.56289 L70.075286, 56.82 L71.551852, 56.82 L71.551852, 64.325594 C71.551852, 67.864531 69.955169, 69.634 66.761803, 69.634 C63.703203, 69.634 62.173903, 67.931912 62.173903, 64.527735 z M78.538965, 56.82 L80.349515, 56.82 L82.924716, 61.249531 C83.094638, 61.542489 83.244052, 61.835448 83.372959, 62.128406 L83.408115, 62.128406 C83.595615, 61.741701 83.759678, 61.437024 83.900304, 61.214376 L86.580973, 56.82 L88.277266, 56.82 L84.31339, 63.068802 L88.33, 69.42307 L86.528239, 69.42307 L83.627842, 64.598045 C83.539951, 64.451566 83.443271, 64.243566 83.337802, 63.974044 L83.302646, 63.974044 C83.244052, 64.108805 83.144443, 64.316805 83.003817, 64.598045 L80.01553, 69.42307 L78.20498, 69.42307 L82.423738, 63.08638 z") { }
}
[Serializable]
public class Encod : Gate
{
public Encod() : base(new Encodeur(), "M0.5,0.5 L67.506996,0.5 67.506996,147.088 0.5,147.088 z M24.528501,24.494 L29.860726,24.494 L29.860726,25.607282 L25.759015,25.607282 L25.759015,29.100937 L29.553097,29.100937 L29.553097,30.206895 L25.759015,30.206895 L25.759015,33.883656 L30.095109,33.883656 L30.095109,34.996938 L24.528501,34.996938 z M24.528502,44.444015 L26.125239,44.444015 L31.384218,52.683768 C31.603953,53.025565 31.745559,53.25994 31.809038,53.386893 L31.838336,53.386893 C31.789506,53.084159 31.765091,52.569022 31.765091,51.841482 L31.765091,44.444015 L32.995605,44.444015 L32.995605,54.946953 L31.486761,54.946953 L26.081292,46.575364 C25.944568,46.365403 25.83226,46.145677 25.744366,45.916184 L25.700419,45.916184 C25.739483,46.140794 25.759015,46.621751 25.759015,47.359056 L25.759015,54.946953 L24.528502,54.946953 z M29.201522,64.21825 C30.197651,64.21825 31.022877,64.362294 31.677198,64.65038 L31.677198,65.961416 C30.925217,65.541494 30.095109,65.331533 29.186873,65.331533 C27.980775,65.331533 27.002956,65.734365 26.253417,66.54003 C25.503879,67.345694 25.129109,68.422355 25.129109,69.770013 C25.129109,71.049311 25.479464,72.068599 26.180173,72.827877 C26.880881,73.587155 27.800104,73.966794 28.937841,73.966794 C29.992566,73.966794 30.905685,73.732418 31.677198,73.263668 L31.677198,74.457517 C30.900802,74.867673 29.93397,75.072751 28.776702,75.072751 C27.282507,75.072751 26.086175,74.591794 25.187705,73.629879 C24.289235,72.667964 23.84,71.405756 23.84,69.843255 C23.84,68.163566 24.345389,66.806143 25.356168,65.770986 C26.366947,64.735829 27.648732,64.21825 29.201522,64.21825 z M28.849947,85.28155 C27.746391,85.28155 26.850363,85.679499 26.161861,86.475398 C25.47336,87.271297 25.129109,88.31622 25.129109,89.610166 C25.129109,90.904113 25.464815,91.945373 26.136226,92.733948 C26.807636,93.522523 27.682912,93.91681 28.762053,93.91681 C29.914438,93.91681 30.822674,93.540834 31.486761,92.78888 C32.150848,92.036926 32.482891,90.984679 32.482891,89.632139 C32.482891,88.245419 32.160614,87.173641 31.516059,86.416804 C30.871504,85.659968 29.9828,85.28155 28.849947,85.28155 z M28.937841,84.168267 C30.388088,84.168267 31.556344,84.656549 32.442606,85.633112 C33.328869,86.609676 33.772,87.886532 33.772,89.463682 C33.772,91.17755 33.317882,92.532532 32.409646,93.528626 C31.50141,94.524721 30.285545,95.022768 28.762053,95.022768 C27.272741,95.022768 26.080071,94.532045 25.184043,93.550599 C24.288014,92.569153 23.84,91.292297 23.84,89.72003 C23.84,88.030575 24.296559,86.682918 25.209678,85.677058 C26.122797,84.671197 27.365518,84.168267 28.937841,84.168267 z M25.759015,105.40734 L25.759015,113.68372 L27.326454,113.68372 C28.703457,113.68372 29.775273,113.31507 30.541903,112.57776 C31.308532,111.84045 31.691847,110.79553 31.691847,109.44299 C31.691847,106.75256 30.26113,105.40734 27.399699,105.40734 z M24.528501,104.29406 L27.428997,104.29406 C31.130302,104.29406 32.980956,106.00061 32.980956,109.41369 C32.980956,111.03479 32.467021,112.33728 31.439152,113.32117 C30.411282,114.30506 29.0355,114.797 27.311805,114.797 L24.528501,114.797 z"
)
{ }
}
[Serializable]
public class Decod : Gate
{
public Decod() : base(new Decodeur(), "M0.5,0.5 L67.506996,0.5 L67.506996,147.088 L0.5,147.088 z M23.825041,24.973271 L23.825041,31.630991 L24.99697,31.630991 C26.022407,31.630991 26.826888,31.323374 27.410411,30.708139 C27.993933,30.092904 28.285695,29.255501 28.285695,28.19593 C28.285695,27.194953 27.996375,26.407598 27.417736,25.833867 C26.839095,25.260137 26.02729,24.973271 24.982321,24.973271 z M21.45921,23.047 L25.180084,23.047 C28.910724,23.047 30.776044,24.753544 30.776044,28.166633 C30.776044,29.802377 30.266988,31.10853 29.248874,32.085093 C28.230761,33.061657 26.874497,33.549938 25.180084,33.549938 L21.45921,33.549938 z M21.45921,42.997015 L27.516617,42.997015 L27.516617,44.923286 L23.825041,44.923286 L23.825041,47.259714 L27.260258,47.259714 L27.260258,49.178661 L23.825041,49.178661 L23.825041,51.581006 L27.758327,51.581006 L27.758327,53.499953 L21.45921,53.499953 z M26.39596,62.77125 C27.421397,62.77125 28.285695,62.900645 28.988853,63.159434 L28.988853,65.437268 C28.285695,65.017346 27.484877,64.807385 26.586399,64.807385 C25.600025,64.807385 24.80409,65.117444 24.198594,65.737561 C23.593097,66.357679 23.290349,67.197524 23.290349,68.257095 C23.290349,69.272721 23.576006,70.082047 24.147322,70.685075 C24.718637,71.288103 25.487715,71.589617 26.454557,71.589617 C27.37745,71.589617 28.222215,71.365007 28.988853,70.915788 L28.988853,73.076435 C28.222215,73.447529 27.221193,73.633076 25.985785,73.633076 C24.374383,73.633076 23.107235,73.159442 22.184341,72.212176 C21.261447,71.26491 20.8,70.002702 20.8,68.425552 C20.8,66.745863 21.318823,65.383557 22.356468,64.338635 C23.394113,63.293712 24.740611,62.77125 26.39596,62.77125 z M26.000434,84.757402 C25.170318,84.757402 24.511108,85.068681 24.022804,85.69124 C23.5345,86.3138 23.290349,87.137775 23.290349,88.163166 C23.290349,89.203206 23.5345,90.025961 24.022804,90.63143 C24.511108,91.236899 25.150786,91.539634 25.941838,91.539634 C26.757304,91.539634 27.404307,91.245444 27.882845,90.657065 C28.361382,90.068685 28.600651,89.252034 28.600651,88.207112 C28.600651,87.118244 28.368707,86.271075 27.904819,85.665606 C27.44093,85.060136 26.806135,84.757402 26.000434,84.757402 z M26.066355,82.721267 C27.565447,82.721267 28.777661,83.21199 29.702997,84.193437 C30.628332,85.174883 31.091,86.468829 31.091,88.075276 C31.091,89.725668 30.611242,91.056235 29.651725,92.066978 C28.692208,93.077721 27.44093,93.583093 25.89789,93.583093 C24.393915,93.583093 23.168273,93.09359 22.220964,92.114585 C21.273655,91.135581 20.8,89.859945 20.8,88.287678 C20.8,86.627521 21.280979,85.284746 22.242938,84.259355 C23.204895,83.233963 24.479368,82.721267 26.066355,82.721267 z M23.825041,104.77333 L23.825041,111.43105 L24.99697,111.43105 C26.022407,111.43105 26.826888,111.12344 27.410411,110.5082 C27.993933,109.89297 28.285695,109.05556 28.285695,107.99599 C28.285695,106.99501 27.996375,106.20766 27.417736,105.63393 C26.839095,105.0602 26.02729,104.77333 24.982321,104.77333 z M21.45921,102.84706 L25.180084,102.84706 C28.910724,102.84706 30.776044,104.55361 30.776044,107.96669 C30.776044,109.60244 30.266988,110.90859 29.248874,111.88516 C28.230761,112.86172 26.874497,113.35 25.180084,113.35 L21.45921,113.35 z") { }
}
//la partie sequentielle
[Serializable]
public class Cpt : Gate
{
public Cpt() : base(new Compteur(), "M0.5,0.5 L56.167,0.5 L56.167,54.167 L0.5,54.167 z M22.455805,21.876 C23.518316,21.876 24.398532,22.029643 25.096456,22.336928 L25.096456,23.735336 C24.294364,23.28743 23.40894,23.063475 22.44018,23.063475 C21.15371,23.063475 20.11073,23.493154 19.311244,24.352511 C18.511757,25.211868 18.112013,26.360282 18.112013,27.797752 C18.112013,29.162308 18.485715,30.249525 19.233118,31.059403 C19.980521,31.869282 20.960999,32.274222 22.174553,32.274222 C23.299564,32.274222 24.273531,32.024227 25.096456,31.524237 L25.096456,32.797649 C24.268323,33.235139 23.237063,33.453885 22.002676,33.453885 C20.408911,33.453885 19.132856,32.940874 18.174514,31.914854 C17.216171,30.888835 16.737,29.542508 16.737,27.875876 C16.737,26.084247 17.276068,24.63636 18.354203,23.532216 C19.432339,22.428073 20.799539,21.876 22.455805,21.876 z M30.964117,26.157161 C30.219318,26.157161 29.620354,26.416271 29.167225,26.934489 C28.714096,27.452708 28.487531,28.102433 28.487531,28.883667 L28.487531,30.000832 C28.487531,30.662277 28.702377,31.223462 29.132068,31.68439 C29.56176,32.145318 30.107339,32.375782 30.768803,32.375782 C31.544852,32.375782 32.152931,32.078913 32.593038,31.485176 C33.033148,30.891438 33.253201,30.065935 33.253201,29.008665 C33.253201,28.118058 33.047471,27.420157 32.636008,26.914958 C32.224547,26.40976 31.667249,26.157161 30.964117,26.157161 z M31.284433,25.079059 C32.315692,25.079059 33.120387,25.437124 33.698518,26.153255 C34.276649,26.869387 34.565714,27.829002 34.565714,29.032102 C34.565714,30.370616 34.240191,31.442208 33.589142,32.246879 C32.938095,33.05155 32.047461,33.453885 30.917242,33.453885 C29.880774,33.453885 29.081287,33.005978 28.518781,32.110163 L28.487531,32.110163 L28.487531,36.946 L27.206268,36.946 L27.206268,25.266555 L28.487531,25.266555 L28.487531,26.672776 L28.518781,26.672776 C29.148995,25.610298 30.070879,25.079059 31.284433,25.079059 z M38.308355,22.899416 L38.308355,25.266555 L40.324,25.266555 L40.324,26.360282 L38.308355,26.360282 L38.308355,30.868001 C38.308355,31.404449 38.399503,31.787253 38.581796,32.016415 C38.764088,32.245576 39.066175,32.360158 39.488054,32.360158 C39.810974,32.360158 40.089623,32.271618 40.324,32.094538 L40.324,33.188265 C40.021913,33.354928 39.623472,33.43826 39.128676,33.43826 C37.727621,33.43826 37.027093,32.657026 37.027093,31.094559 L37.027093,26.360282 L35.65208,26.360282 L35.65208,25.266555 L37.027093,25.266555 L37.027093,23.31347 z") { }
}
[Serializable]
public class BasculeJk : Gate
{
public BasculeJk() : base(new JK(), "M0.5,0.5 L66.167,0.5 L66.167,64.975999 L0.5,64.975999 z M22.627459,19.048 L27.658775,19.048 L27.658775,31.605025 C27.658774,34.392249 26.963453,36.526218 25.57281,38.006931 C24.182167,39.487644 22.169119,40.228 19.533668,40.228 C18.356569,40.228 17.268013,40.039282 16.268,39.661845 L16.268,35.263257 C17.132595,35.872962 18.101357,36.177815 19.174288,36.177815 C21.476402,36.177815 22.627459,34.590645 22.627459,31.416307 z M32.565756,19.048 L37.612698,19.048 L37.612698,28.890385 L37.690824,28.890385 C37.815825,28.619406 38.024161,28.232291 38.315832,27.729042 L44.503412,19.048 L50.519116,19.048 L42.706513,28.977486 L51.191,39.86508 L44.815916,39.86508 L38.284582,30.821119 C38.15958,30.646917 37.96166,30.264642 37.690824,29.674292 L37.612698,29.674292 L37.612698,39.86508 L32.565756,39.86508 z") { }
}
[Serializable]
public class BasculeD : Gate
{
public BasculeD() : base(new D(), "M0.5,0.5 L66.167,0.5 66.167,64.975999 0.5,64.975999 z M28.365093,26.209089 L28.365093,36.86163 L30.240061,36.86163 C31.880659,36.86163 33.167747,36.369434 34.101325,35.38504 C35.034902,34.400647 35.501691,33.060778 35.501692,31.365434 C35.501691,29.763842 35.038808,28.504053 34.113043,27.586067 C33.187278,26.668082 31.888471,26.20909 30.216624,26.209089 z M24.58,23.127 L30.533025,23.127 C36.501674,23.127 39.486,25.85752 39.486,31.318559 C39.486,33.935795 38.671561,36.025677 37.042682,37.588206 C35.413803,39.150735 33.243917,39.932 30.533025,39.932 L24.58,39.932 z") { }
}
[Serializable]
public class BasculeRst : Gate
{
public BasculeRst() : base(new RST(), "M0.5,0.5 L66.167,0.5 66.167,64.975999 0.5,64.975999 z M18.947176,27.153204 L18.947176,31.829011 L20.58781,31.829011 C21.400314,31.829011 22.052662,31.594635 22.544852,31.125882 C23.044854,30.649317 23.294856,30.05947 23.294856,29.356341 C23.294856,27.887584 22.415945,27.153205 20.658123,27.153204 z M15.162,24.317252 L21.162032,24.317252 C25.240177,24.317252 27.27925,25.840698 27.279252,28.887589 C27.27925,29.473529 27.189406,30.014548 27.009719,30.510644 C26.830029,31.006741 26.576121,31.454009 26.247997,31.852448 C25.919868,32.250888 25.523381,32.59464 25.058537,32.883704 C24.593691,33.172768 24.07611,33.399332 23.505794,33.563395 L23.505794,33.61027 C23.755796,33.688396 23.997985,33.81535 24.232361,33.991132 C24.466737,34.166914 24.693301,34.371993 24.912052,34.60637 C25.130803,34.840746 25.339789,35.0927 25.539008,35.362233 C25.738226,35.631766 25.919868,35.895439 26.083933,36.153253 L29.259731,41.12203 L24.912052,41.12203 L22.298757,36.797788 C22.103443,36.469661 21.915942,36.17669 21.736254,35.918877 C21.556565,35.661063 21.374924,35.440358 21.191329,35.256764 C21.007734,35.073169 20.816327,34.932543 20.617107,34.834886 C20.417887,34.73723 20.201089,34.688401 19.966713,34.688401 L18.947176,34.688401 L18.947176,41.12203 L15.162,41.12203 z M36.582686,24.036 C37.457691,24.036 38.233086,24.088735 38.908871,24.194204 C39.584655,24.299673 40.207706,24.461784 40.778021,24.680535 L40.778021,28.18446 C40.49677,27.989147 40.190127,27.817271 39.858094,27.668832 C39.526061,27.520395 39.184263,27.397347 38.832698,27.299689 C38.481134,27.202034 38.131523,27.129768 37.783865,27.082891 C37.436207,27.036017 37.106127,27.01258 36.793625,27.012579 C36.363935,27.01258 35.973308,27.053595 35.621744,27.135626 C35.270179,27.217659 34.973303,27.332894 34.731114,27.481331 C34.488925,27.62977 34.301424,27.807506 34.168611,28.014537 C34.035798,28.22157 33.969391,28.453994 33.969391,28.711806 C33.969391,28.993058 34.04361,29.245012 34.192049,29.46767 C34.340487,29.690327 34.551426,29.901266 34.824864,30.100486 C35.098303,30.299706 35.430336,30.495019 35.820964,30.686427 C36.211591,30.877834 36.652999,31.0751 37.145189,31.278227 C37.817068,31.559478 38.420587,31.858308 38.955746,32.174716 C39.490905,32.491124 39.949892,32.848548 40.332706,33.246987 C40.715521,33.645427 41.008491,34.100507 41.211617,34.612229 C41.414743,35.12395 41.516306,35.719657 41.516306,36.399348 C41.516306,37.336853 41.338571,38.123967 40.9831,38.760689 C40.62763,39.397411 40.145205,39.913039 39.535827,40.307572 C38.926449,40.702106 38.217461,40.98531 37.408863,41.157186 C36.600265,41.329062 35.746744,41.415 34.848302,41.415 C33.926422,41.415 33.049464,41.336875 32.217429,41.180624 C31.385393,41.024373 30.664686,40.789997 30.055308,40.477495 L30.055308,36.727475 C30.734999,37.29779 31.473284,37.725527 32.270163,38.010685 C33.067043,38.295843 33.871734,38.438421 34.684239,38.438421 C35.160804,38.438421 35.576822,38.395452 35.932292,38.309514 C36.287763,38.223577 36.584639,38.104435 36.822922,37.952091 C37.061205,37.799746 37.23894,37.620058 37.356128,37.413025 C37.473316,37.205993 37.53191,36.981382 37.53191,36.739194 C37.53191,36.411067 37.43816,36.118096 37.250659,35.860283 C37.063158,35.602469 36.807297,35.364186 36.483076,35.145435 C36.158856,34.926684 35.774088,34.715745 35.328773,34.512619 C34.883459,34.309493 34.402987,34.102461 33.887359,33.891522 C32.574853,33.344644 31.596332,32.676672 30.951797,31.887605 C30.307262,31.098538 29.984995,30.145408 29.984995,29.028214 C29.984995,28.153211 30.160777,27.401253 30.512342,26.772343 C30.863906,26.143434 31.342424,25.625853 31.947896,25.2196 C32.553368,24.813348 33.254544,24.514518 34.051423,24.323111 C34.848302,24.131704 35.692057,24.036 36.582686,24.036 z M42.723554,24.317252 L56.083,24.317252 L56.083,27.399299 L51.290006,27.399299 L51.290006,41.12203 L47.493111,41.12203 L47.493111,27.399299 L42.723554,27.399299 z") { }
}
[Serializable]
public class BasculeT : Gate
{
public BasculeT() : base(new T(), "M0.5,0.5 L66.167,0.5 66.167,64.975999 0.5,64.975999 z M23.021,23.127 L36.381,23.127 L36.381,26.209089 L31.587807,26.209089 L31.587807,39.932 L27.790754,39.932 L27.790754,26.209089 L23.021,26.209089 z") { }
}
[Serializable]
public class Reg : Gate
{
public Reg() : base(new Reg_Dec(), "M0.5,0.5 L77.5,0.5 L77.5,53.5 L0.5,53.5 z M12.114488,21.249441 L12.114488,25.311737 L13.895721,25.311737 C14.223843,25.311737 14.527226,25.262261 14.805869,25.163307 C15.084512,25.064354 15.325396,24.922434 15.528519,24.737547 C15.731642,24.552661 15.890494,24.32611 16.005077,24.057894 C16.119659,23.789678 16.17695,23.488912 16.17695,23.155595 C16.17695,22.556667 15.982941,22.089242 15.594924,21.753322 C15.206907,21.417401 14.645714,21.249441 13.911346,21.249441 z M10.802,20.062 L14.145719,20.062 C14.635298,20.062 15.087117,20.123195 15.501175,20.245585 C15.915234,20.367975 16.274606,20.554163 16.57929,20.80415 C16.883975,21.054138 17.122254,21.36532 17.294127,21.737697 C17.466001,22.110075 17.551938,22.546251 17.551938,23.046225 C17.551938,23.436831 17.493344,23.794886 17.376158,24.12039 C17.258972,24.445896 17.092306,24.736245 16.876163,24.991441 C16.660018,25.246637 16.399604,25.464073 16.09492,25.643752 C15.790235,25.82343 15.44779,25.962746 15.067586,26.061699 L15.067586,26.092948 C15.255084,26.176278 15.417843,26.271325 15.555862,26.37809 C15.693882,26.484856 15.825391,26.611151 15.95039,26.756977 C16.075389,26.902804 16.199085,27.06816 16.32148,27.253046 C16.443875,27.437933 16.580592,27.652766 16.731633,27.897545 L18.833176,31.264564 L17.27069,31.264564 L15.395708,28.124096 C15.223834,27.832445 15.057169,27.583759 14.895712,27.37804 C14.734255,27.172321 14.568892,27.004361 14.399623,26.874159 C14.230354,26.743957 14.048064,26.64891 13.852753,26.589017 C13.657442,26.529124 13.437392,26.499177 13.192603,26.499177 L12.114488,26.499177 L12.114488,31.264564 L10.802,31.264564 z M22.847202,24.155545 C22.24304,24.155545 21.730024,24.371681 21.308153,24.80395 C20.886282,25.23622 20.625868,25.801296 20.52691,26.499177 L24.847183,26.499177 C24.841974,25.759631 24.663591,25.18414 24.312032,24.772701 C23.960473,24.361264 23.472196,24.155545 22.847202,24.155545 z M22.870639,23.077474 C23.917504,23.077474 24.727392,23.415999 25.300304,24.093048 C25.873215,24.770098 26.159671,25.710154 26.159671,26.913219 L26.159671,27.585061 L20.511286,27.585061 C20.532118,28.475641 20.771699,29.163106 21.230029,29.647457 C21.688358,30.131808 22.31856,30.373983 23.120637,30.373983 C24.021669,30.373983 24.849787,30.077123 25.604989,29.483403 L25.604989,30.686468 C24.90187,31.196858 23.972191,31.452054 22.815952,31.452054 C21.685753,31.452054 20.797741,31.088791 20.151914,30.362265 C19.506087,29.635739 19.183173,28.613655 19.183173,27.296013 C19.183173,26.051284 19.536034,25.037011 20.241757,24.253196 C20.947479,23.469382 21.823774,23.077474 22.870639,23.077474 z M31.393477,24.155545 C30.601818,24.155545 29.982031,24.443291 29.534119,25.018783 C29.086207,25.594276 28.86225,26.400224 28.86225,27.43663 C28.86225,28.327211 29.077092,29.039415 29.506776,29.573242 C29.936459,30.107069 30.505464,30.373983 31.213791,30.373983 C31.932534,30.373983 32.517164,30.118787 32.967681,29.608397 C33.418196,29.098006 33.643456,28.444392 33.643456,27.647557 L33.643456,26.467929 C33.643456,25.832545 33.428614,25.288301 32.998931,24.835198 C32.569247,24.382096 32.034096,24.155545 31.393477,24.155545 z M31.213791,23.077474 C32.291906,23.077474 33.091377,23.509744 33.612206,24.374284 L33.643456,24.374284 L33.643456,23.264965 L34.924694,23.264965 L34.924694,30.623971 C34.924694,33.561324 33.518457,35.03 30.705983,35.03 C29.716408,35.03 28.851834,34.842509 28.112257,34.467528 L28.112257,33.186342 C29.01329,33.686317 29.872657,33.936305 30.690358,33.936305 C32.65909,33.936305 33.643456,32.889482 33.643456,30.795837 L33.643456,29.920881 L33.612206,29.920881 C33.002837,30.941664 32.086178,31.452054 30.862232,31.452054 C29.86745,31.452054 29.066676,31.096603 28.45991,30.385701 C27.853144,29.6748 27.549762,28.720421 27.549762,27.522564 C27.549762,26.163257 27.876582,25.082582 28.530222,24.280539 C29.183862,23.478496 30.078385,23.077474 31.213791,23.077474 z M36.223014,32.655119 L42.863578,32.655119 L42.863578,33.58476 L36.223014,33.58476 z M45.644177,21.249441 L45.644177,30.077123 L47.316036,30.077123 C48.784773,30.077123 49.927989,29.683913 50.745692,28.897495 C51.563392,28.111076 51.972243,26.996549 51.972243,25.553912 C51.972243,22.684265 50.446214,21.249441 47.394161,21.249441 z M44.331689,20.062 L47.42541,20.062 C51.373288,20.062 53.347231,21.882221 53.347231,25.522664 C53.347231,27.251744 52.799056,28.640998 51.702715,29.690424 C50.606369,30.73985 49.138934,31.264564 47.300411,31.264564 L44.331689,31.264564 z M58.496872,24.155545 C57.892709,24.155545 57.379695,24.371681 56.957823,24.80395 C56.535952,25.23622 56.275537,25.801296 56.176581,26.499177 L60.496853,26.499177 C60.491646,25.759631 60.313261,25.18414 59.961702,24.772701 C59.610143,24.361264 59.121866,24.155545 58.496872,24.155545 z M58.520309,23.077474 C59.567174,23.077474 60.377061,23.415999 60.949974,24.093048 C61.522887,24.770098 61.809341,25.710154 61.809341,26.913219 L61.809341,27.585061 L56.160956,27.585061 C56.181788,28.475641 56.421371,29.163106 56.879699,29.647457 C57.338027,30.131808 57.968232,30.373983 58.770307,30.373983 C59.671341,30.373983 60.499459,30.077123 61.254659,29.483403 L61.254659,30.686468 C60.55154,31.196858 59.621861,31.452054 58.465622,31.452054 C57.335425,31.452054 56.44741,31.088791 55.801584,30.362265 C55.155758,29.635739 54.832843,28.613655 54.832843,27.296013 C54.832843,26.051284 55.185703,25.037011 55.891427,24.253196 C56.597151,23.469382 57.473444,23.077474 58.520309,23.077474 z M67.355642,23.077474 C68.058761,23.077474 68.678548,23.207676 69.215,23.468079 L69.215,24.780514 C68.621255,24.363868 67.985843,24.155545 67.308768,24.155545 C66.491068,24.155545 65.8205,24.448499 65.297067,25.034407 C64.773635,25.620315 64.511918,26.389808 64.511918,27.342885 C64.511918,28.280338 64.75801,29.019885 65.250193,29.561524 C65.742376,30.103163 66.402526,30.373983 67.230643,30.373983 C67.928555,30.373983 68.584799,30.142223 69.199375,29.678706 L69.199375,30.897395 C68.584799,31.267167 67.855638,31.452054 67.011895,31.452054 C65.871281,31.452054 64.950715,31.080979 64.250202,30.338829 C63.549689,29.596678 63.199431,28.634487 63.199431,27.452255 C63.199431,26.134613 63.577033,25.076072 64.332233,24.276633 C65.087433,23.477194 66.095236,23.077474 67.355642,23.077474 z") { }
}
// Liaisons
//Les pin et l'horloge
[Serializable]
public class pin_entree : Gate
{
public pin_entree() : base(new PinIn(), "M57.5,29 C57.5,44.740115 44.740115,57.5 29,57.5 C13.259885,57.5 0.5,44.740115 0.5,29 C0.5,13.259885 13.259885,0.5 29,0.5 C44.740115,0.5 57.5,13.259885 57.5,29 z M35.5,28 C35.5,31.589851 32.365993,34.5 28.5,34.5 C24.634007,34.5 21.5,31.589851 21.5,28 C21.5,24.410149 24.634007,21.5 28.5,21.5 C32.365993,21.5 35.5,24.410149 35.5,28 z")
{
path.Height = 25;
path.Width = 29;
path.Fill = Brushes.Red;
this.MouseDoubleClick += new MouseButtonEventHandler(OnClick);
}
public void OnClick(object sender, MouseEventArgs e)
{
if (this.outil.getListeentrees()[0].getEtat().Equals(true))
{
this.outil.getListeentrees()[0].setEtat(false);
//le calcul automatique
path.Fill = Brushes.Red;
((PinIn)(this.outil)).Calcul();
}
else
{
this.outil.getListeentrees()[0].setEtat(true);
path.Fill = Brushes.Green;
((PinIn)(this.outil)).Calcul();
}
}
}
[Serializable]
public class pin_sortie : Gate
{
public pin_sortie() : base(new PinOut(), "M0.5, 0.5 L79.5, 0.5 L79.5, 79.5 L0.5, 79.5 z M71.166003, 39.285999 C71.166003, 54.131966 56.67928, 66.166999 38.809002, 66.166999 C20.938723, 66.166999 6.452, 54.131966 6.452, 39.285999 C6.452, 24.440033 20.938723, 12.405 38.809002, 12.405 C56.67928, 12.405 71.166003, 24.440033 71.166003, 39.285999 z")
{
path.Height = 25;
path.Width = 29;
(outil as PinOut).PropertyChanged += new PropertyChangedEventHandler((sender, e) =>
{
Application.Current.Dispatcher.Invoke(() => {
if (outil.getEntreeSpecifique(0).getEtat()) path.Fill = Brushes.Green;
else path.Fill = Brushes.Red;
});
});
}
}
[Serializable]
public class horloge : Gate
{
public horloge() : base(new Horloge(), "M1.0000047, 1.0000005 L83.333005, 1.0000005 L83.333005, 27.571001 L1.0000047, 27.571001 z M0.99999997, 28.570993 L13.095017, 1 M15.094999, 1 L27.380993, 28.570993 M29.381017, 28.570993 L40.476016, 1 M42.476016, 1 L54.761992, 28.570993 M56.762006, 28.570993 L69.047004, 1 M71.047003, 1 L84.332993, 28.570993")
{
path.Height = 25;
path.Width = 29;
this.MouseDoubleClick += new MouseButtonEventHandler(OnClick);
}
public void OnClick(object sender, MouseEventArgs e)
{
((Horloge)this.outil).Demmarer();
}
}
public class constantetrue : Gate
{
public constantetrue() : base(new ConstanteTrue(), "M0.5,0.5 L38.611,0.5 L38.611,51.944 L0.5,51.944 z")
{
path.Fill = Brushes.Green;
path.Height = 25;
path.Width = 29;
}
}
public class constantefalse : Gate
{
public constantefalse() : base(new ConstanteFalse(), "M0.5,0.5 L38.611,0.5 L38.611,51.944 L0.5,51.944 z")
{
path.Fill = Brushes.Red;
path.Height = 25;
path.Width = 29;
}
}
//le circuit perssonalisé
public class CircuitComplet : Gate
{
public CircuitComplet(CircuitPersonnalise c) : base(c, "M0.5,0.5 L38.611,0.5 L38.611,51.944 L0.5,51.944 z") { }
public CircuitComplet() : base(new CircuitPersonnalise(), "M0.5,0.5 L38.611,0.5 L38.611,51.944 L0.5,51.944 z") { }
}
#endregion
}
| 87.579655 | 10,984 | 0.662791 | [
"MIT"
] | OussamaBenakmoum/DigiX | WpfApp2/Graphique/Gate.xaml.cs | 91,281 | C# |
using Grpc.Core;
using MediaContract;
namespace GrpcAgent
{
/// <summary>
/// 实时视频播放事件处理
/// </summary>
/// <param name="msg"></param>
/// <param name="state"></param>
public delegate void LivePlayRequestHandler(StartLiveRequest request, ServerCallContext context);
/// <summary>
/// 视频回放播放事件处理
/// </summary>
/// <param name="cata"></param>
public delegate void PlaybackRequestHandler(StartPlaybackRequest request, ServerCallContext context);
public class MediaEventSource
{
public event LivePlayRequestHandler LivePlayRequestReceived = null;
public event PlaybackRequestHandler PlaybackRequestReceived = null;
internal void FileLivePlayRequestEvent(StartLiveRequest request, ServerCallContext context)
{
LivePlayRequestReceived?.Invoke(request, context);
}
internal void FilePlaybackRequestEvent(StartPlaybackRequest request, ServerCallContext context)
{
PlaybackRequestReceived?.Invoke(request, context);
}
}
}
| 30.138889 | 105 | 0.674654 | [
"BSD-2-Clause"
] | BretGui/GB28181.Platform2016 | GrpcAgent/MediaEventSource.cs | 1,127 | C# |
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MadsKristensen.EditorExtensions.Settings;
using Microsoft.Ajax.Utilities;
using Microsoft.VisualStudio.Utilities;
using WebMarkupMin.Core.Minifiers;
using WebMarkupMin.Core.Settings;
namespace MadsKristensen.EditorExtensions.Optimization.Minification
{
public interface IFileMinifier
{
///<summary>Minifies an existing file, creating or overwriting the target.</summary>
///<returns>True if the minified file has changed from the old version on disk.</returns>
Task<bool> MinifyFile(string sourcePath, string targetPath);
///<summary>Minifies an existing file, creating or overwriting the target.</summary>
///<returns>True if the minified file has changed from the old version on disk.</returns>
Task<bool> MinifyFile(string sourcePath, string targetPath, bool compilerNeedsSourceMap);
///<summary>Minifies a string in-memory.</summary>
string MinifyString(string source);
///<summary>Indicates whether the minifier will emit a source map file next to the minified output.</summary>
bool GenerateSourceMap { get; }
}
///<summary>An <see cref="IFileMinifier"/> that minifies files in-memory, then writes the results to disk.</summary>
public abstract class InMemoryMinifier : IFileMinifier
{
public virtual bool GenerateSourceMap { get { return false; } }
public virtual bool SaveWithBOM { get; set; }
public async virtual Task<bool> MinifyFile(string sourcePath, string targetPath)
{
var result = MinifyString(await FileHelpers.ReadAllTextRetry(sourcePath));
if (result != null && (!File.Exists(targetPath) || result != await FileHelpers.ReadAllTextRetry(targetPath)))
{
ProjectHelpers.CheckOutFileFromSourceControl(targetPath);
await FileHelpers.WriteAllTextRetry(targetPath, result, SaveWithBOM);
ProjectHelpers.AddFileToProject(sourcePath, targetPath);
return true;
}
return false;
}
public async virtual Task<bool> MinifyFile(string sourcePath, string targetPath, bool compilerNeedsSourceMap)
{
return await MinifyFile(sourcePath, targetPath);
}
public abstract string MinifyString(string source);
}
[Export(typeof(IFileMinifier))]
[ContentType("HTMLX")]
public class HtmlFileMinifier : InMemoryMinifier
{
public override string MinifyString(string source)
{
var weHtmlSettings = WESettings.Instance.Html;
var settings = new HtmlMinificationSettings
{
// Tags
RemoveOptionalEndTags = false,
//EmptyTagRenderMode = HtmlEmptyTagRenderMode.Slash,
// Attributes
AttributeQuotesRemovalMode = weHtmlSettings.AttributeQuotesRemovalMode,
RemoveRedundantAttributes = false,
// JavaScript templating
ProcessableScriptTypeList = weHtmlSettings.ProcessableScriptTypeList,
MinifyKnockoutBindingExpressions = weHtmlSettings.MinifyKnockoutBindingExpressions,
MinifyAngularBindingExpressions = weHtmlSettings.MinifyAngularBindingExpressions,
CustomAngularDirectiveList = weHtmlSettings.CustomAngularDirectiveList
};
var minifier = new HtmlMinifier(settings);
MarkupMinificationResult result = minifier.Minify(source, generateStatistics: true);
if (result.Errors.Count == 0)
{
WebEssentialsPackage.DTE.StatusBar.Text = "Web Essentials: HTML minified by " + result.Statistics.SavedInPercent + "%";
return result.MinifiedContent;
}
else
{
WebEssentialsPackage.DTE.StatusBar.Text = "Web Essentials: Cannot minify the current selection. See Output Window for details.";
Logger.ShowMessage("Cannot minify the selection:\r\n\r\n" + String.Join(Environment.NewLine, result.Errors.Select(e => e.Message)));
return null;
}
}
}
[Export(typeof(IFileMinifier))]
[ContentType("CSS")]
public class CssFileMinifier : InMemoryMinifier
{
public override bool SaveWithBOM { get { return true; } }
public override string MinifyString(string source)
{
Minifier minifier = new Minifier();
var settings = new Microsoft.Ajax.Utilities.CssSettings
{
CommentMode = WESettings.Instance.General.KeepImportantComments ? CssComment.Hacks : CssComment.Important
};
return minifier.MinifyStyleSheet(source, settings);
}
}
[Export(typeof(IFileMinifier))]
[ContentType("JavaScript")]
[ContentType("node.js")]
public class JavaScriptFileMinifier : InMemoryMinifier
{
public override bool GenerateSourceMap { get { return false; } }// WESettings.Instance.JavaScript.GenerateSourceMaps; } }
public override bool SaveWithBOM { get { return true; } }
static CodeSettings CreateSettings()
{
return new CodeSettings()
{
EvalTreatment = WESettings.Instance.JavaScript.EvalTreatment,
TermSemicolons = WESettings.Instance.JavaScript.TermSemicolons,
PreserveImportantComments = WESettings.Instance.General.KeepImportantComments
};
}
public override string MinifyString(string source)
{
return new Minifier().MinifyJavaScript(source, CreateSettings());
}
public async override Task<bool> MinifyFile(string sourcePath, string targetPath)
{
if (GenerateSourceMap)
return await MinifyFileWithSourceMap(sourcePath, targetPath);
else
return await base.MinifyFile(sourcePath, targetPath);
}
public async override Task<bool> MinifyFile(string sourcePath, string targetPath, bool compilerNeedsSourceMap)
{
if (GenerateSourceMap && compilerNeedsSourceMap)
return await MinifyFileWithSourceMap(sourcePath, targetPath);
else
return await base.MinifyFile(sourcePath, targetPath);
}
private async static Task<bool> MinifyFileWithSourceMap(string file, string minFile)
{
bool result;
string mapPath = minFile + ".map";
StringWriter writer = new StringWriter();
ProjectHelpers.CheckOutFileFromSourceControl(mapPath);
using (V3SourceMap sourceMap = new V3SourceMap(writer))
{
var settings = CreateSettings();
settings.SymbolsMap = sourceMap;
sourceMap.StartPackage(minFile, mapPath);
// This fails when debugger is attached. Bug raised with Ron Logan
result = await MinifyFile(file, minFile, settings);
}
await FileHelpers.WriteAllTextRetry(mapPath, writer.ToString(), false);
ProjectHelpers.AddFileToProject(minFile, mapPath);
return result;
}
private async static Task<bool> MinifyFile(string file, string minFile, CodeSettings settings)
{
Minifier minifier = new Minifier();
// If the source file is not itself mapped, add the filename for mapping
// TODO: Make sure this works for compiled output too. (check for .map?)
if (!((await FileHelpers.ReadAllLinesRetry(file))
.SkipWhile(string.IsNullOrWhiteSpace)
.FirstOrDefault() ?? "")
.Trim()
.StartsWith("///#source", StringComparison.CurrentCulture))
{
minifier.FileName = file;
}
string content = minifier.MinifyJavaScript(await FileHelpers.ReadAllTextRetry(file), settings);
content += "\r\n/*\r\n//# sourceMappingURL=" + Path.GetFileName(minFile) + ".map\r\n*/";
if (File.Exists(minFile) && content == await FileHelpers.ReadAllTextRetry(minFile))
return false;
ProjectHelpers.CheckOutFileFromSourceControl(minFile);
await FileHelpers.WriteAllTextRetry(minFile, content);
ProjectHelpers.AddFileToProject(file, minFile);
return true;
}
}
} | 40.291667 | 148 | 0.633575 | [
"Apache-2.0"
] | GProulx/WebEssentials2015 | EditorExtensions/Misc/Minification/IFileMinifier.cs | 8,705 | C# |
using System;
using XamMvvmAndWebServices.Interfaces;
namespace XamMvvmAndWebServices.Services
{
/// <summary>
/// The login service.
/// </summary>
public class LoginService : ILoginService
{
/// <summary>Initializes a new instance of the <see cref="LoginService"/> class.</summary>
public LoginService() // e.g. LoginService(IMyApiClient client)
{
// this constructor would most likely contain some form of API Client that performs
// the message creation, sending and deals with the response from a remote API
}
/// <summary>
/// Gets a value indicating whether the user is authenticated.
/// </summary>
public bool IsAuthenticated { get; private set; }
/// <summary>Gets the error message.</summary>
/// <value>The error message.</value>
public string ErrorMessage { get; private set; }
/// <summary>
/// Attempts to log the user in using stored credentials if present
/// </summary>
/// <returns> <see langword="true"/> if the login is successful, false otherwise </returns>
public bool Login()
{
// get the stored username from previous sessions
// var username = Settings.UserName;
// var username = _settingsService.GetValue<string>(Constants.UserNameKey);
// force return of false just for demo purposes
IsAuthenticated = false;
return IsAuthenticated;
}
/// <summary>The login method to retrieve OAuth2 access tokens from an API. </summary>
/// <param name="userName">The user Name (email address) </param>
/// <param name="password">The users <paramref name="password"/>. </param>
/// <param name="scope">The required scopes. </param>
/// <returns>The <see cref="bool"/>. </returns>
public bool Login(string userName, string password, string scope)
{
try
{
//IsAuthenticated = _apiClient.ExchangeUserCredentialsForTokens(userName, password, scope);
return IsAuthenticated;
}
catch (ArgumentException argex)
{
ErrorMessage = argex.Message;
IsAuthenticated = false;
return IsAuthenticated;
}
}
/// <summary>
/// Logins the specified user name.
/// </summary>
/// <param name="userName">Name of the user.</param>
/// <param name="password">The users password.</param>
/// <returns></returns>
public bool Login(string userName, string password)
{
if (userName.Equals("admin") && password.Equals("admin"))
// this simply returns true to mock a real login service call
return true;
else
return false;
}
}
} | 38.220779 | 107 | 0.577642 | [
"MIT"
] | karolzak/Xamarin-MVVMCross-And-Web-Service-Sample | XamMvvmAndWebServices.Client/XamMvvmAndWebServices.Core/Services/LoginService.cs | 2,945 | C# |
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace AspNet.Security.OAuth.WordPress
{
public class WordPressAuthenticationHandler : OAuthHandler<WordPressAuthenticationOptions>
{
public WordPressAuthenticationHandler(
[NotNull] IOptionsMonitor<WordPressAuthenticationOptions> options,
[NotNull] ILoggerFactory logger,
[NotNull] UrlEncoder encoder,
[NotNull] ISystemClock clock)
: base(options, logger, encoder, clock)
{
}
protected override async Task<AuthenticationTicket> CreateTicketAsync(
[NotNull] ClaimsIdentity identity,
[NotNull] AuthenticationProperties properties,
[NotNull] OAuthTokenResponse tokens)
{
using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserInformationEndpoint);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted);
if (!response.IsSuccessStatusCode)
{
Logger.LogError("An error occurred while retrieving the user profile: the remote server " +
"returned a {Status} response with the following payload: {Headers} {Body}.",
/* Status: */ response.StatusCode,
/* Headers: */ response.Headers.ToString(),
/* Body: */ await response.Content.ReadAsStringAsync());
throw new HttpRequestException("An error occurred while retrieving the user profile.");
}
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
var principal = new ClaimsPrincipal(identity);
var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
context.RunClaimActions();
await Options.Events.CreatingTicket(context);
return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name);
}
}
}
| 46.125 | 148 | 0.683266 | [
"Apache-2.0"
] | AaqibAhamed/AspNet.Security.OAuth.Providers | src/AspNet.Security.OAuth.WordPress/WordPressAuthenticationHandler.cs | 2,954 | C# |
using Artemis.UI.Shared.Modules;
namespace Artemis.Plugins.Modules.General.ViewModels
{
public class GeneralViewModel : ModuleViewModel
{
public GeneralViewModel(GeneralModule module) : base(module, "General")
{
GeneralModule = module;
}
public GeneralModule GeneralModule { get; }
public void ShowTimeInDataModel()
{
GeneralModule.ShowProperty(model => model.TimeDataModel.CurrentTime);
}
public void HideTimeInDataModel()
{
GeneralModule.HideProperty(model => model.TimeDataModel.CurrentTime);
}
}
} | 26.416667 | 81 | 0.637224 | [
"MIT"
] | skedgyedgy/Artemis.Plugins | src/Modules/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs | 636 | C# |
/*
* SOCOMAP
*
* This API is for the new Socomap Protocol
*
* OpenAPI spec version: 0.0.1
* Contact: development@infotech.de
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// Target Inbox for the Transmission
/// </summary>
[DataContract]
public partial class TransmissionsCreateRequest : IEquatable<TransmissionsCreateRequest>
{
/// <summary>
/// Gets or Sets Party
/// </summary>
[Required]
[DataMember(Name="party")]
public string Party { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class TransmissionsCreateRequest {\n");
sb.Append(" Party: ").Append(Party).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((TransmissionsCreateRequest)obj);
}
/// <summary>
/// Returns true if TransmissionsCreateRequest instances are equal
/// </summary>
/// <param name="other">Instance of TransmissionsCreateRequest to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(TransmissionsCreateRequest other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Party == other.Party ||
Party != null &&
Party.Equals(other.Party)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Party != null)
hashCode = hashCode * 59 + Party.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(TransmissionsCreateRequest left, TransmissionsCreateRequest right)
{
return Equals(left, right);
}
public static bool operator !=(TransmissionsCreateRequest left, TransmissionsCreateRequest right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}
| 30.201681 | 105 | 0.560378 | [
"MIT"
] | infotech-gmbh/socomap | src/dotnet/App/Models/TransmissionsCreateRequest.cs | 3,594 | C# |
// Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using System;
namespace osu.Framework.Graphics.Visualisation
{
class FlashyBox : Box
{
Drawable target;
Func<Drawable, Quad> getScreenSpaceQuad;
public FlashyBox(Func<Drawable, Quad> getScreenSpaceQuad)
{
this.getScreenSpaceQuad = getScreenSpaceQuad;
}
public Drawable Target { set { target = value; } }
public override Quad ScreenSpaceDrawQuad => target == null ? new Quad() : getScreenSpaceQuad(target);
}
} | 31.541667 | 110 | 0.669749 | [
"MIT"
] | ColdVolcano/Touhosu | osu-framework/osu.Framework/Graphics/Visualisation/FlashyBox.cs | 759 | C# |
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using Musoq.Evaluator.Helpers;
using Musoq.Evaluator.Resources;
using Musoq.Evaluator.Utils;
using Musoq.Evaluator.Utils.Symbols;
using Musoq.Parser;
using Musoq.Parser.Nodes;
using Musoq.Plugins.Attributes;
namespace Musoq.Evaluator.Visitors
{
public class RewriteQueryVisitor : IScopeAwareExpressionVisitor
{
private readonly List<JoinFromNode> _joinedTables = new List<JoinFromNode>();
private int _queryIndex = 0;
private Scope _scope;
protected Stack<Node> Nodes { get; } = new Stack<Node>();
public RootNode RootScript { get; private set; }
public void Visit(Node node)
{
}
public void Visit(DescNode node)
{
var from = (SchemaFromNode) Nodes.Pop();
Nodes.Push(new DescNode(from, node.Type));
}
public void Visit(StarNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new StarNode(left, right));
}
public void Visit(FSlashNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new FSlashNode(left, right));
}
public void Visit(ModuloNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new ModuloNode(left, right));
}
public void Visit(AddNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new AddNode(left, right));
}
public void Visit(HyphenNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new HyphenNode(left, right));
}
public void Visit(AndNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new AndNode(left, right));
}
public void Visit(OrNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new OrNode(left, right));
}
public void Visit(ShortCircuitingNodeLeft node)
{
Nodes.Push(new ShortCircuitingNodeLeft(Nodes.Pop(), node.UsedFor));
}
public void Visit(ShortCircuitingNodeRight node)
{
Nodes.Push(new ShortCircuitingNodeRight(Nodes.Pop(), node.UsedFor));
}
public void Visit(EqualityNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new EqualityNode(left, right));
}
public void Visit(GreaterOrEqualNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new GreaterOrEqualNode(left, right));
}
public void Visit(LessOrEqualNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new LessOrEqualNode(left, right));
}
public void Visit(GreaterNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new GreaterNode(left, right));
}
public void Visit(LessNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new LessNode(left, right));
}
public void Visit(DiffNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new DiffNode(left, right));
}
public void Visit(NotNode node)
{
Nodes.Push(new NotNode(Nodes.Pop()));
}
public void Visit(LikeNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new LikeNode(left, right));
}
public void Visit(RLikeNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new RLikeNode(left, right));
}
public void Visit(InNode node)
{
var right = (ArgsListNode)Nodes.Pop();
var left = Nodes.Pop();
Node exp = new EqualityNode(left, right.Args[0]);
for (var i = 1; i < right.Args.Length; i++)
{
exp = new OrNode(exp, new EqualityNode(left, right.Args[i]));
}
Nodes.Push(exp);
}
public virtual void Visit(FieldNode node)
{
Nodes.Push(new FieldNode(Nodes.Pop(), node.FieldOrder, node.FieldName));
}
public void Visit(FieldOrderedNode node)
{
Nodes.Push(new FieldOrderedNode(Nodes.Pop(), node.FieldOrder, node.FieldName, node.Order));
}
public virtual void Visit(SelectNode node)
{
var fields = CreateFields(node.Fields);
Nodes.Push(new SelectNode(fields.ToArray()));
}
public void Visit(GroupSelectNode node)
{
}
public void Visit(StringNode node)
{
Nodes.Push(new StringNode(node.Value));
}
public void Visit(DecimalNode node)
{
Nodes.Push(new DecimalNode(node.Value));
}
public void Visit(IntegerNode node)
{
Nodes.Push(new IntegerNode(node.ObjValue.ToString()));
}
public void Visit(BooleanNode node)
{
Nodes.Push(new BooleanNode(node.Value));
}
public void Visit(WordNode node)
{
Nodes.Push(new WordNode(node.Value));
}
public void Visit(ContainsNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new ContainsNode(left, right as ArgsListNode));
}
public virtual void Visit(AccessMethodNode node)
{
VisitAccessMethod(node);
}
public void Visit(AccessRawIdentifierNode node)
{
Nodes.Push(new AccessRawIdentifierNode(node.Name, node.ReturnType));
}
public void Visit(IsNullNode node)
{
Nodes.Push(new IsNullNode(Nodes.Pop(), node.IsNegated));
}
public void Visit(AccessRefreshAggreationScoreNode node)
{
VisitAccessMethod(node);
}
public virtual void Visit(AccessColumnNode node)
{
Nodes.Push(new AccessColumnNode(node.Name, node.Alias, node.ReturnType, node.Span));
}
public void Visit(AllColumnsNode node)
{
Nodes.Push(new AllColumnsNode());
}
public void Visit(IdentifierNode node)
{
Nodes.Push(new IdentifierNode(node.Name));
}
public void Visit(AccessObjectArrayNode node)
{
Nodes.Push(new AccessObjectArrayNode(node.Token, node.PropertyInfo));
}
public void Visit(AccessObjectKeyNode node)
{
Nodes.Push(new AccessObjectKeyNode(node.Token, node.PropertyInfo));
}
public void Visit(PropertyValueNode node)
{
Nodes.Push(new PropertyValueNode(node.Name, node.PropertyInfo));
}
public virtual void Visit(DotNode node)
{
var exp = Nodes.Pop();
var root = Nodes.Pop();
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(node.ReturnType))
{
Nodes.Push(new DotNode(root, exp, node.IsOuter, node.Name, typeof(IDynamicMetaObjectProvider)));
}
else
{
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(root.ReturnType))
Nodes.Push(new DotNode(root, exp, node.IsOuter, node.Name, typeof(IDynamicMetaObjectProvider)));
else
Nodes.Push(new DotNode(root, exp, node.IsOuter, node.Name, exp.ReturnType));
}
}
public virtual void Visit(AccessCallChainNode node)
{
}
public void Visit(ArgsListNode node)
{
var args = new Node[node.Args.Length];
for (var i = node.Args.Length - 1; i >= 0; --i)
args[i] = Nodes.Pop();
Nodes.Push(new ArgsListNode(args));
}
public virtual void Visit(WhereNode node)
{
Nodes.Push(new WhereNode(Nodes.Pop()));
}
public virtual void Visit(GroupByNode node)
{
var having = Nodes.Peek() as HavingNode;
if (having != null)
Nodes.Pop();
var fields = new FieldNode[node.Fields.Length];
for (var i = node.Fields.Length - 1; i >= 0; --i)
fields[i] = Nodes.Pop() as FieldNode;
Nodes.Push(new GroupByNode(fields, having));
}
public void Visit(HavingNode node)
{
Nodes.Push(new HavingNode(Nodes.Pop()));
}
public void Visit(SkipNode node)
{
Nodes.Push(new SkipNode((IntegerNode) node.Expression));
}
public void Visit(TakeNode node)
{
Nodes.Push(new TakeNode((IntegerNode) node.Expression));
}
public void Visit(SchemaFromNode node)
{
Nodes.Push(new SchemaFromNode(node.Schema, node.Method, (ArgsListNode)Nodes.Pop(), node.Alias));
}
public void Visit(JoinSourcesTableFromNode node)
{
}
public void Visit(JoinFromNode node)
{
var exp = Nodes.Pop();
var right = (FromNode) Nodes.Pop();
var left = (FromNode) Nodes.Pop();
Nodes.Push(new JoinFromNode(left, right, exp, node.JoinType));
_joinedTables.Add(node);
}
public void Visit(ExpressionFromNode node)
{
Nodes.Push(new ExpressionFromNode((FromNode) Nodes.Pop()));
}
public void Visit(InMemoryTableFromNode node)
{
Nodes.Push(new InMemoryTableFromNode(node.VariableName, node.Alias));
}
public void Visit(CreateTransformationTableNode node)
{
var fields = CreateFields(node.Fields);
Nodes.Push(new CreateTransformationTableNode(node.Name, node.Keys, fields, node.ForGrouping));
}
public void Visit(RenameTableNode node)
{
Nodes.Push(new RenameTableNode(node.TableSourceName, node.TableDestinationName));
}
public void Visit(TranslatedSetTreeNode node)
{
}
public void Visit(IntoNode node)
{
Nodes.Push(new IntoNode(node.Name));
}
public void Visit(QueryScope node)
{
}
public void Visit(ShouldBePresentInTheTable node)
{
Nodes.Push(new ShouldBePresentInTheTable(node.Table, node.ExpectedResult, node.Keys));
}
public void Visit(TranslatedSetOperatorNode node)
{
}
public void Visit(QueryNode node)
{
var orderBy = node.OrderBy != null ? Nodes.Pop() as OrderByNode : null;
var groupBy = node.GroupBy != null ? Nodes.Pop() as GroupByNode : null;
var skip = node.Skip != null ? Nodes.Pop() as SkipNode : null;
var take = node.Take != null ? Nodes.Pop() as TakeNode : null;
var select = Nodes.Pop() as SelectNode;
var where = node.Where != null ? Nodes.Pop() as WhereNode : null;
var from = Nodes.Pop() as ExpressionFromNode;
var scoreSelect = select;
var scoreWhere = where;
QueryNode query;
var splittedNodes = new List<Node>();
var source = from.Alias.ToRowsSource().WithRowsUsage();
QueryNode lastJoinQuery = null;
_scope[MetaAttributes.MethodName] = $"ComputeTable_{from.Alias}_{_queryIndex++}";
IReadOnlyList<AccessMethodNode> usedRefreshMethods = null;
if (_scope.ScopeSymbolTable.SymbolIsOfType<RefreshMethodsSymbol>(from.Alias.ToRefreshMethodsSymbolName()))
usedRefreshMethods = _scope.ScopeSymbolTable
.GetSymbol<RefreshMethodsSymbol>(from.Alias.ToRefreshMethodsSymbolName()).RefreshMethods;
var aliasIndex = 0;
var aliasesPositionsSymbol = new AliasesPositionsSymbol();
if (from.Expression is JoinsNode)
{
var current = _joinedTables[0];
var left = _scope.ScopeSymbolTable.GetSymbol<TableSymbol>(current.Source.Alias);
var right = _scope.ScopeSymbolTable.GetSymbol<TableSymbol>(current.With.Alias);
var scopeCreateTable = _scope.AddScope("Table");
var scopeJoinedQuery = _scope.AddScope("Query");
var bothForCreateTable = CreateAndConcatFields(left, current.Source.Alias, right, current.With.Alias,
(name, alias) => NamingHelper.ToColumnName(alias, name));
var bothForSelect = CreateAndConcatFields(left, current.Source.Alias, right, current.With.Alias,
(name, alias) => name);
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(current.Source.Alias, left);
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(current.With.Alias, right);
var targetTableName = $"{current.Source.Alias}{current.With.Alias}";
aliasesPositionsSymbol.AliasesPositions.Add(current.Source.Alias, aliasIndex++);
aliasesPositionsSymbol.AliasesPositions.Add(current.With.Alias, aliasIndex++);
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(targetTableName,
_scope.ScopeSymbolTable.GetSymbol(targetTableName));
scopeJoinedQuery[MetaAttributes.SelectIntoVariableName] = targetTableName.ToTransitionTable();
scopeJoinedQuery[MetaAttributes.OriginAlias] = targetTableName;
scopeJoinedQuery[MetaAttributes.Contexts] = $"{current.Source.Alias},{current.With.Alias}";
scopeCreateTable[MetaAttributes.CreateTableVariableName] = targetTableName.ToTransitionTable();
var joinedQuery = new InternalQueryNode(
new SelectNode(bothForSelect),
new ExpressionFromNode(
new JoinSourcesTableFromNode(
current.Source,
current.With,
current.Expression,
current.JoinType)),
null,
null,
null,
null,
null,
new RefreshNode(new AccessMethodNode[0]));
var targetTable = new CreateTransformationTableNode(targetTableName, new string[0], bothForCreateTable, false);
splittedNodes.Add(targetTable);
splittedNodes.Add(joinedQuery);
lastJoinQuery = joinedQuery;
source = targetTableName.ToTransitionTable().ToTransformedRowsSource();
var usedTables = new Dictionary<string, string>
{
{current.Source.Alias, targetTableName},
{current.With.Alias, targetTableName}
};
for (var i = 1; i < _joinedTables.Count; i++)
{
current = _joinedTables[i];
left = _scope.ScopeSymbolTable.GetSymbol<TableSymbol>(current.Source.Alias);
right = _scope.ScopeSymbolTable.GetSymbol<TableSymbol>(current.With.Alias);
targetTableName = $"{current.Source.Alias}{current.With.Alias}";
aliasesPositionsSymbol.AliasesPositions.Add(current.Source.Alias, aliasIndex++);
aliasesPositionsSymbol.AliasesPositions.Add(current.With.Alias, aliasIndex++);
scopeCreateTable = _scope.AddScope("Table");
scopeJoinedQuery = _scope.AddScope("Query");
bothForCreateTable = CreateAndConcatFields(left, current.Source.Alias, right, current.With.Alias,
(name, alias) => NamingHelper.ToColumnName(alias, name));
bothForSelect = CreateAndConcatFields(
left,
current.Source.Alias,
right,
current.With.Alias,
(name, alias) => NamingHelper.ToColumnName(alias, name),
(name, alias) => name,
(name, alias) => NamingHelper.ToColumnName(alias, name),
(name, alias) => name);
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(current.Source.Alias, left);
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(current.With.Alias, right);
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(targetTableName,
_scope.ScopeSymbolTable.GetSymbol(targetTableName));
scopeJoinedQuery[MetaAttributes.SelectIntoVariableName] = targetTableName.ToTransitionTable();
scopeJoinedQuery[MetaAttributes.OriginAlias] = targetTableName;
scopeJoinedQuery[MetaAttributes.Contexts] = $"{current.Source.Alias},{current.With.Alias}";
scopeCreateTable[MetaAttributes.CreateTableVariableName] = targetTableName.ToTransitionTable();
scopeJoinedQuery.ScopeSymbolTable.AddSymbol(
MetaAttributes.OuterJoinSelect,
new FieldsNamesSymbol(bothForSelect.Select(f => f.FieldName).ToArray()));
var expressionUpdater = new RewriteWhereConditionWithUpdatedColumnAccess(usedTables);
var traverser = new CloneTraverseVisitor(expressionUpdater);
new WhereNode(current.Expression).Accept(traverser);
foreach (var key in usedTables.Keys.ToArray())
usedTables[key] = targetTableName;
usedTables[current.Source.Alias] = targetTableName;
usedTables.Add(current.With.Alias, targetTableName);
joinedQuery = new InternalQueryNode(
new SelectNode(bothForSelect),
new ExpressionFromNode(
new JoinInMemoryWithSourceTableFromNode(
current.Source.Alias,
current.With,
expressionUpdater.Where.Expression,
current.JoinType)),
null,
null,
null,
null,
null,
new RefreshNode(new AccessMethodNode[0]));
targetTable = new CreateTransformationTableNode(targetTableName, new string[0], bothForCreateTable, false);
splittedNodes.Add(targetTable);
splittedNodes.Add(joinedQuery);
lastJoinQuery = joinedQuery;
source = targetTableName.ToTransitionTable().ToTransformedRowsSource();
}
var rewriter = new RewritePartsToUseJoinTransitionTable();
var partsTraverser = new CloneTraverseVisitor(rewriter);
select.Accept(partsTraverser);
where?.Accept(partsTraverser);
scoreSelect = rewriter.ChangedSelect;
scoreWhere = rewriter.ChangedWhere;
}
if (groupBy != null)
{
var nestedFrom = splittedNodes.Count > 0
? new ExpressionFromNode(new InMemoryGroupedFromNode(lastJoinQuery.From.Alias))
: from;
var splitted = SplitBetweenAggreateAndNonAggreagate(select.Fields, groupBy.Fields, true);
var refreshMethods = CreateRefreshMethods(usedRefreshMethods);
var aggSelect = new SelectNode(ConcatAggregateFieldsWithGroupByFields(splitted[0], groupBy.Fields)
.Reverse().ToArray());
var outSelect = new SelectNode(splitted[1]);
var scopeCreateTranformingTable = _scope.AddScope("Table");
var scopeTransformedQuery = _scope.AddScope("Query");
var scopeCreateResultTable = _scope.AddScope("Table");
var scopeResultQuery = _scope.AddScope("Query");
scopeCreateTranformingTable[MetaAttributes.CreateTableVariableName] = nestedFrom.Alias.ToGroupingTable();
scopeCreateResultTable[MetaAttributes.CreateTableVariableName] = nestedFrom.Alias.ToScoreTable();
var destination = nestedFrom.Alias.ToGroupingTable().ToTransformedRowsSource();
scopeTransformedQuery[MetaAttributes.SelectIntoVariableName] = destination;
scopeTransformedQuery[MetaAttributes.SourceName] = splittedNodes.Count > 0
? nestedFrom.Alias.ToTransitionTable().ToTransformedRowsSource()
: nestedFrom.Alias.ToRowsSource().WithRowsUsage();
scopeTransformedQuery[MetaAttributes.OriginAlias] = nestedFrom.Alias;
scopeTransformedQuery.ScopeSymbolTable.AddSymbol(nestedFrom.Alias,
_scope.ScopeSymbolTable.GetSymbol(nestedFrom.Alias));
scopeTransformedQuery[MetaAttributes.Contexts] = $"{nestedFrom.Alias}";
if (splittedNodes.Count > 0)
{
var selectRewriter = new RewritePartsToUseJoinTransitionTable(nestedFrom.Alias);
var selectTraverser = new CloneTraverseVisitor(selectRewriter);
groupBy.Accept(selectTraverser);
groupBy = selectRewriter.ChangedGroupBy;
scopeTransformedQuery.ScopeSymbolTable.AddSymbol("groupFields",
new FieldsNamesSymbol(groupBy.Fields.Select(f => f.FieldName).ToArray()));
var newRefreshMethods = new List<AccessMethodNode>();
foreach (var method in refreshMethods.Nodes)
{
var newNodes = new List<Node>();
foreach (var arg in method.Arguments.Args)
{
arg.Accept(selectTraverser);
newNodes.Add(selectRewriter.RewrittenNode);
}
var newArgs = new ArgsListNode(newNodes.ToArray());
newRefreshMethods.Add(new AccessMethodNode(method.FToken, newArgs,
method.ExtraAggregateArguments, method.CanSkipInjectSource, method.Method));
}
refreshMethods = new RefreshNode(newRefreshMethods.ToArray());
}
else
{
scopeTransformedQuery.ScopeSymbolTable.AddSymbol("groupFields",
new FieldsNamesSymbol(groupBy.Fields.Select(f => f.Expression.ToString()).ToArray()));
}
var transformingQuery = new InternalQueryNode(aggSelect, nestedFrom, where, groupBy, null, null, null,
refreshMethods);
var returnScore = nestedFrom.Alias.ToScoreTable();
scopeResultQuery[MetaAttributes.SelectIntoVariableName] = returnScore;
scopeResultQuery[MetaAttributes.SourceName] = destination;
scopeResultQuery[MetaAttributes.Contexts] = $"{nestedFrom.Alias}";
aliasesPositionsSymbol.AliasesPositions.Add(nestedFrom.Alias, aliasIndex++);
aliasesPositionsSymbol.AliasesPositions.Add(returnScore, aliasIndex++);
query = new DetailedQueryNode(
outSelect,
new ExpressionFromNode(
new InMemoryGroupedFromNode(returnScore)),
null,
null,
null,
skip,
take,
returnScore);
splittedNodes.Add(new CreateTransformationTableNode(destination, new string[0], transformingQuery.Select.Fields, true));
splittedNodes.Add(transformingQuery);
splittedNodes.Add(new CreateTransformationTableNode(query.From.Alias, new string[0], query.Select.Fields, false));
splittedNodes.Add(query);
Nodes.Push(
new MultiStatementNode(
splittedNodes.ToArray(),
null));
}
else
{
var splitted = SplitBetweenAggreateAndNonAggreagate(select.Fields, new FieldNode[0], true);
if (IsQueryWithMixedAggregateAndNonAggregateMethods(splitted))
{
query = new InternalQueryNode(select, from, where, null, null, skip, take,
CreateRefreshMethods(usedRefreshMethods));
}
else
{
var scopeCreateResultTable = _scope.AddScope("Table");
var scopeResultQuery = _scope.AddScope("Query");
scopeCreateResultTable[MetaAttributes.CreateTableVariableName] = from.Alias.ToScoreTable();
scopeCreateResultTable[MetaAttributes.OriginAlias] = from.Alias;
scopeResultQuery[MetaAttributes.SelectIntoVariableName] = from.Alias.ToScoreTable();
scopeResultQuery[MetaAttributes.Contexts] = from.Alias;
scopeResultQuery[MetaAttributes.SourceName] = source;
var newFrom = lastJoinQuery != null
? new ExpressionFromNode(
new InMemoryGroupedFromNode(lastJoinQuery.From.Alias))
: from;
aliasesPositionsSymbol.AliasesPositions.Add(newFrom.Alias, aliasIndex++);
splittedNodes.Add(new CreateTransformationTableNode(scopeResultQuery[MetaAttributes.SelectIntoVariableName], new string[0], select.Fields, false));
splittedNodes.Add(new DetailedQueryNode(scoreSelect, newFrom, scoreWhere, null, null, skip, take,
scopeResultQuery[MetaAttributes.SelectIntoVariableName]));
Nodes.Push(
new MultiStatementNode(
splittedNodes.ToArray(),
null));
}
}
_scope.ScopeSymbolTable.AddSymbol(MetaAttributes.AllQueryContexts, aliasesPositionsSymbol);
_joinedTables.Clear();
}
public void Visit(JoinInMemoryWithSourceTableFromNode node)
{
var exp = Nodes.Pop();
var from = (FromNode) Nodes.Pop();
Nodes.Push(new JoinInMemoryWithSourceTableFromNode(node.InMemoryTableAlias, from, exp, node.JoinType));
}
public void Visit(InternalQueryNode node)
{
throw new NotSupportedException();
}
public void Visit(RootNode node)
{
RootScript = new RootNode(Nodes.Pop());
}
public void Visit(SingleSetNode node)
{
var query = (InternalQueryNode) Nodes.Pop();
var nodes = new Node[] {new CreateTransformationTableNode(query.From.Alias, new string[0], query.Select.Fields, false), query};
Nodes.Push(new MultiStatementNode(nodes, null));
}
public void Visit(RefreshNode node)
{
}
public void Visit(UnionNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new UnionNode(node.ResultTableName, node.Keys, left, right, node.IsNested, node.IsTheLastOne));
}
public void Visit(UnionAllNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new UnionAllNode(node.ResultTableName, node.Keys, left, right, node.IsNested,
node.IsTheLastOne));
}
public void Visit(ExceptNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(new ExceptNode(node.ResultTableName, node.Keys, left, right, node.IsNested, node.IsTheLastOne));
}
public void Visit(IntersectNode node)
{
var right = Nodes.Pop();
var left = Nodes.Pop();
Nodes.Push(
new IntersectNode(node.ResultTableName, node.Keys, left, right, node.IsNested, node.IsTheLastOne));
}
public void Visit(PutTrueNode node)
{
Nodes.Push(new PutTrueNode());
}
public void Visit(MultiStatementNode node)
{
var items = new Node[node.Nodes.Length];
for (var i = node.Nodes.Length - 1; i >= 0; --i)
items[i] = Nodes.Pop();
Nodes.Push(new MultiStatementNode(items, node.ReturnType));
}
public void Visit(CteExpressionNode node)
{
var sets = new CteInnerExpressionNode[node.InnerExpression.Length];
var set = Nodes.Pop();
for (var i = node.InnerExpression.Length - 1; i >= 0; --i)
sets[i] = (CteInnerExpressionNode) Nodes.Pop();
Nodes.Push(new CteExpressionNode(sets, set));
}
public void Visit(CteInnerExpressionNode node)
{
Nodes.Push(new CteInnerExpressionNode(Nodes.Pop(), node.Name));
}
public void Visit(JoinsNode node)
{
Nodes.Push(new JoinsNode((JoinFromNode) Nodes.Pop()));
}
public void Visit(JoinNode node)
{
}
public void Visit(OrderByNode node)
{
var fields = new FieldOrderedNode[node.Fields.Length];
for (var i = node.Fields.Length - 1; i >= 0; --i)
fields[i] = (FieldOrderedNode)Nodes.Pop();
Nodes.Push(new OrderByNode(fields));
}
public void SetScope(Scope scope)
{
_scope = scope;
}
private bool IsQueryWithMixedAggregateAndNonAggregateMethods(FieldNode[][] splitted)
{
return splitted[0].Length > 0 && splitted[0].Length != splitted[1].Length;
}
private FieldNode[] ConcatAggregateFieldsWithGroupByFields(FieldNode[] selectFields, FieldNode[] groupByFields)
{
var fields = new List<FieldNode>(selectFields);
var nextOrder = -1;
if (selectFields.Length > 0)
nextOrder = selectFields.Max(f => f.FieldOrder);
foreach (var groupField in groupByFields)
{
var hasField =
selectFields.Any(field => field.Expression.ToString() == groupField.Expression.ToString());
if (!hasField) fields.Add(new FieldNode(groupField.Expression, ++nextOrder, string.Empty));
}
return fields.ToArray();
}
private void VisitAccessMethod(AccessMethodNode node)
{
var args = Nodes.Pop() as ArgsListNode;
Nodes.Push(new AccessMethodNode(node.FToken, args, null, node.CanSkipInjectSource, node.Method, node.Alias));
}
private FieldNode[][] SplitBetweenAggreateAndNonAggreagate(FieldNode[] fieldsToSplit, FieldNode[] groupByFields,
bool useOuterFields)
{
var nestedFields = new List<FieldNode>();
var outerFields = new List<FieldNode>();
var rawNestedFields = new List<FieldNode>();
var fieldOrder = 0;
foreach (var root in fieldsToSplit)
{
var subNodes = new Stack<Node>();
subNodes.Push(root.Expression);
while (subNodes.Count > 0)
{
var subNode = subNodes.Pop();
if (subNode is AccessMethodNode aggregateMethod && aggregateMethod.IsAggregateMethod)
{
var subNodeStr = subNode.ToString();
if (nestedFields.Select(f => f.Expression.ToString()).Contains(subNodeStr))
continue;
var nameArg = (WordNode) aggregateMethod.Arguments.Args[0];
nestedFields.Add(new FieldNode(subNode, fieldOrder, nameArg.Value));
rawNestedFields.Add(new FieldNode(subNode, fieldOrder, string.Empty));
fieldOrder += 1;
}
else if (subNode is AccessMethodNode method)
{
foreach (var arg in method.Arguments.Args)
subNodes.Push(arg);
}
else if (subNode is BinaryNode binary)
{
subNodes.Push(binary.Left);
subNodes.Push(binary.Right);
}
}
if (!useOuterFields)
continue;
var rewriter = new RewriteFieldWithGroupMethodCall(groupByFields);
var traverser = new CloneTraverseVisitor(rewriter);
root.Accept(traverser);
outerFields.Add(rewriter.Expression);
}
var retFields = new FieldNode[3][];
retFields[0] = nestedFields.ToArray();
retFields[1] = outerFields.ToArray();
retFields[2] = rawNestedFields.ToArray();
return retFields;
}
private FieldNode[] CreateFields(FieldNode[] oldFields)
{
var reorderedList = new FieldNode[oldFields.Length];
var fields = new List<FieldNode>(reorderedList.Length);
for (var i = reorderedList.Length - 1; i >= 0; i--) reorderedList[i] = Nodes.Pop() as FieldNode;
for (int i = 0, j = reorderedList.Length, p = 0; i < j; ++i)
{
var field = reorderedList[i];
if (field.Expression is AllColumnsNode)
{
fields.AddRange(new FieldNode[0]);
continue;
}
fields.Add(new FieldNode(field.Expression, p++, field.FieldName));
}
return fields.ToArray();
}
private FieldNode[] CreateAndConcatFields(TableSymbol left, string lAlias, TableSymbol right, string rAlias,
Func<string, string, string> func)
{
return CreateAndConcatFields(left, lAlias, right, rAlias, func, func, (name, alias) => name,
(name, alias) => name);
}
private FieldNode[] CreateAndConcatFields(TableSymbol left, string lAlias, TableSymbol right, string rAlias,
Func<string, string, string> lfunc, Func<string, string, string> rfunc, Func<string, string, string> lcfunc,
Func<string, string, string> rcfunc)
{
var fields = new List<FieldNode>();
var i = 0;
foreach (var compoundTable in left.CompoundTables)
foreach (var column in left.GetColumns(compoundTable))
fields.Add(
new FieldNode(
new AccessColumnNode(
lcfunc(column.ColumnName, compoundTable),
lAlias,
column.ColumnType,
TextSpan.Empty),
i++,
lfunc(column.ColumnName, compoundTable)));
foreach (var compoundTable in right.CompoundTables)
foreach (var column in right.GetColumns(compoundTable))
fields.Add(
new FieldNode(
new AccessColumnNode(
rcfunc(column.ColumnName, compoundTable),
rAlias,
column.ColumnType,
TextSpan.Empty),
i++,
rfunc(column.ColumnName, compoundTable)));
return fields.ToArray();
}
private RefreshNode CreateRefreshMethods(IReadOnlyList<AccessMethodNode> refreshMethods)
{
var methods = new List<AccessMethodNode>();
foreach (var method in refreshMethods)
{
if (method.Method.GetCustomAttribute<AggregateSetDoNotResolveAttribute>() != null)
continue;
if (!HasMethod(methods, method))
methods.Add(method);
}
return new RefreshNode(methods.ToArray());
}
public void Visit(CreateTableNode node)
{
}
public void Visit(CoupleNode node)
{
}
public void Visit(SchemaMethodFromNode node)
{
}
public void Visit(AliasedFromNode node)
{
}
private bool HasMethod(IEnumerable<AccessMethodNode> methods, AccessMethodNode node)
{
return methods.Any(f => f.ToString() == node.ToString());
}
public void Visit(StatementsArrayNode node)
{
}
public void Visit(StatementNode node)
{
}
public void Visit(CaseNode node)
{
var whenThenPairs = new List<(Node When, Node Then)>();
for (int i = 0; i < node.WhenThenPairs.Length; ++i)
{
var then = Nodes.Pop();
var when = Nodes.Pop();
whenThenPairs.Add((when, then));
}
var elseNode = Nodes.Pop();
Nodes.Push(new CaseNode(whenThenPairs.ToArray(), elseNode, node.ReturnType));
}
public void Visit(FieldLinkNode node)
{
Nodes.Push(new FieldLinkNode($"::{node.Index}", node.ReturnType));
}
}
} | 36.3082 | 167 | 0.55328 | [
"MIT"
] | JTOne123/Musoq | Musoq.Evaluator/Visitors/RewriteQueryVisitor.cs | 38,525 | C# |
using LineageServer.Interfaces;
using LineageServer.Models;
using System.Collections.Generic;
namespace LineageServer.william
{
class ItemPrice
{
private static ILogger _log = Logger.GetLogger(nameof(ItemPrice));
private static ItemPrice _instance;
private readonly Dictionary<int, L1WilliamItemPrice> _itemIdIndex = new Dictionary<int, L1WilliamItemPrice>();
public static ItemPrice Instance
{
get
{
if (_instance == null)
{
_instance = new ItemPrice();
}
return _instance;
}
}
private ItemPrice()
{
loadItemPrice();
}
private void loadItemPrice()
{
IList<IDataSourceRow> dataSourceRows =
Container.Instance.Resolve<IDataSourceFactory>()
.Factory(Enum.DataSourceTypeEnum.WilliamItemPrice)
.Select()
.Query();
fillItemPrice(dataSourceRows);
}
private void fillItemPrice(IList<IDataSourceRow> dataSourceRows)
{
for (int i = 0; i < dataSourceRows.Count; i++)
{
IDataSourceRow dataSourceRow = dataSourceRows[i];
int itemId = dataSourceRow.getInt("item_id");
int price = dataSourceRow.getInt("price");
L1WilliamItemPrice item_price = new L1WilliamItemPrice(itemId, price);
_itemIdIndex[itemId] = item_price;
}
}
public virtual L1WilliamItemPrice getTemplate(int itemId)
{
return _itemIdIndex[itemId];
}
}
} | 27.031746 | 118 | 0.559601 | [
"Unlicense"
] | TaiwanSpring/L1CSharpTW | LineageServer/william/ItemPrice.cs | 1,705 | C# |
// <auto-generated>
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Microsoft.Azure.Management.AlertsManagement.Models
{
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Target scope for a given action rule. By default scope will be the
/// subscription. User can also provide list of resource groups or list of
/// resources from the scope subscription as well.
/// </summary>
public partial class Scope
{
/// <summary>
/// Initializes a new instance of the Scope class.
/// </summary>
public Scope()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Scope class.
/// </summary>
/// <param name="scopeType">type of target scope. Possible values
/// include: 'ResourceGroup', 'Resource'</param>
/// <param name="values">list of ARM IDs of the given scope type which
/// will be the target of the given action rule.</param>
public Scope(string scopeType = default(string), IList<string> values = default(IList<string>))
{
ScopeType = scopeType;
Values = values;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets type of target scope. Possible values include:
/// 'ResourceGroup', 'Resource'
/// </summary>
[JsonProperty(PropertyName = "scopeType")]
public string ScopeType { get; set; }
/// <summary>
/// Gets or sets list of ARM IDs of the given scope type which will be
/// the target of the given action rule.
/// </summary>
[JsonProperty(PropertyName = "values")]
public IList<string> Values { get; set; }
}
}
| 33.720588 | 103 | 0.611426 | [
"MIT"
] | Azkel/azure-sdk-for-net | sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Scope.cs | 2,293 | C# |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using DurableTask.Core;
using DurableTask.Emulator;
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
{
internal class EmulatorDurabilityProviderFactory : IDurabilityProviderFactory
{
private readonly DurabilityProvider provider;
public EmulatorDurabilityProviderFactory()
{
var service = new LocalOrchestrationService();
this.provider = new DurabilityProvider("emulator", service, service, "emulator");
}
public bool SupportsEntities => false;
public DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute)
{
return this.provider;
}
public DurabilityProvider GetDurabilityProvider()
{
return this.provider;
}
}
}
| 29.4375 | 93 | 0.68896 | [
"MIT"
] | AtOMiCNebula/azure-functions-durable-extension | test/FunctionsV2/EmulatorDurabilityProviderFactory.cs | 944 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.iOS;
public class ARKitPlaneMeshRender : MonoBehaviour {
[SerializeField]
private MeshFilter meshFilter;
[SerializeField]
private LineRenderer lineRenderer;
private Mesh planeMesh;
public void InitiliazeMesh(ARPlaneAnchor arPlaneAnchor)
{
planeMesh = new Mesh ();
UpdateMesh (arPlaneAnchor);
meshFilter.mesh = planeMesh;
}
public void UpdateMesh(ARPlaneAnchor arPlaneAnchor)
{
if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) //otherwise we cannot access planeGeometry
{
planeMesh.vertices = arPlaneAnchor.planeGeometry.vertices;
planeMesh.uv = arPlaneAnchor.planeGeometry.textureCoordinates;
planeMesh.triangles = arPlaneAnchor.planeGeometry.triangleIndices;
lineRenderer.positionCount = arPlaneAnchor.planeGeometry.boundaryVertexCount;
lineRenderer.SetPositions(arPlaneAnchor.planeGeometry.boundaryVertices);
// Assign the mesh object and update it.
planeMesh.RecalculateBounds();
planeMesh.RecalculateNormals();
}
}
void PrintOutMesh()
{
string outputMessage = "\n";
outputMessage += "Vertices = " + planeMesh.vertices.GetLength (0);
outputMessage += "\nVertices = [";
foreach (Vector3 v in planeMesh.vertices) {
outputMessage += v.ToString ();
outputMessage += ",";
}
outputMessage += "]\n Triangles = " + planeMesh.triangles.GetLength (0);
outputMessage += "\n Triangles = [";
foreach (int i in planeMesh.triangles) {
outputMessage += i;
outputMessage += ",";
}
outputMessage += "]\n";
Debug.Log (outputMessage);
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
| 27.2 | 110 | 0.671744 | [
"MIT"
] | oliverellmers/SharedSpheres | Assets/UnityARKitPlugin/Examples/ARKit1.5/UnityARPlaneMesh/ARKitPlaneMeshRender.cs | 1,906 | C# |
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class Blaze : ModuleRules
{
public Blaze(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
| 33.666667 | 129 | 0.731436 | [
"MIT"
] | Mandey4172/Blaze | Source/Blaze/Blaze.Build.cs | 808 | C# |
using System;
using System.Collections.Generic;
namespace MahApps.Metro.IconPacks
{
/// ******************************************
/// This code is auto generated. Do not amend.
/// ******************************************
public static class PackIconMaterialLightDataFactory
{
public static Lazy<IDictionary<PackIconMaterialLightKind, string>> DataIndex { get; }
static PackIconMaterialLightDataFactory()
{
if (DataIndex == null)
{
DataIndex = new Lazy<IDictionary<PackIconMaterialLightKind, string>>(PackIconMaterialLightDataFactory.Create);
}
}
public static IDictionary<PackIconMaterialLightKind, string> Create()
{
return new Dictionary<PackIconMaterialLightKind, string>
{
{PackIconMaterialLightKind.None, ""},
{PackIconMaterialLightKind.Account, "M 11.5,14C 15.6421,14 19,15.567 19,17.5L 19,20L 4,20L 4,17.5C 4,15.567 7.35786,14 11.5,14 Z M 18,17.5C 18,16.1193 15.0898,15 11.5,15C 7.91015,15 5,16.1193 5,17.5L 5,19L 18,19L 18,17.5 Z M 11.5,5.00001C 13.433,5.00001 15,6.56701 15,8.50001C 15,10.433 13.433,12 11.5,12C 9.567,12 8,10.433 8,8.50001C 8,6.56701 9.567,5.00001 11.5,5.00001 Z M 11.5,6.00001C 10.1193,6.00001 9,7.1193 9,8.50001C 9,9.88072 10.1193,11 11.5,11C 12.8807,11 14,9.88072 14,8.50001C 14,7.1193 12.8807,6.00001 11.5,6.00001 Z "},
{PackIconMaterialLightKind.Alarm, "M 11.5,6C 15.6421,6 19,9.35786 19,13.5C 19,17.6421 15.6421,21 11.5,21C 7.35786,21 4,17.6421 4,13.5C 4,9.35786 7.35786,6 11.5,6 Z M 11.5,7.00001C 7.91015,7.00001 5,9.91015 5,13.5C 5,17.0899 7.91015,20 11.5,20C 15.0898,20 18,17.0899 18,13.5C 18,9.91016 15.0898,7.00001 11.5,7.00001 Z M 11,9L 12,9L 12,13.3629L 15.0478,14.7842L 14.6252,15.6905L 11,14L 11,9 Z M 15.25,5.25L 15.8928,4.48395L 19.723,7.69789L 19.0802,8.46393L 15.25,5.25 Z M 7.74999,5.25L 3.91976,8.46394L 3.27698,7.69789L 7.1072,4.48395L 7.74999,5.25 Z "},
{PackIconMaterialLightKind.AlarmPlus, "M 11.5,6C 15.6421,6 19,9.35786 19,13.5C 19,17.6421 15.6421,21 11.5,21C 7.35786,21 4,17.6421 4,13.5C 4,9.35786 7.35786,6 11.5,6 Z M 11.5,7.00001C 7.91014,7.00001 5,9.91016 5,13.5C 5,17.0899 7.91014,20 11.5,20C 15.0898,20 18,17.0899 18,13.5C 18,9.91016 15.0898,7.00001 11.5,7.00001 Z M 15.25,5.25L 15.8928,4.48395L 19.723,7.69789L 19.0802,8.46394L 15.25,5.25 Z M 7.74998,5.25L 3.91976,8.46394L 3.27698,7.69789L 7.1072,4.48396L 7.74998,5.25 Z M 11,11L 12,11L 12,13L 14,13L 14,14L 12,14L 12,16L 11,16L 11,14L 9,14L 9,13L 11,13L 11,11 Z "},
{PackIconMaterialLightKind.Alert, "M 1,21L 11.5,2.81347L 22,21L 1,21 Z M 20.2679,20L 11.5,4.81347L 2.73205,20L 20.2679,20 Z M 11,14L 11,10L 12,10L 12,14L 11,14 Z M 11,16L 12,16L 12,18L 11,18L 11,16 Z "},
{PackIconMaterialLightKind.AlertCircle, "M 11.5,3C 16.7467,3 21,7.25329 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5C 2,7.25329 6.25329,3 11.5,3 Z M 11.5,4C 6.80557,4 3,7.80558 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80558 16.1944,4 11.5,4 Z M 11,17L 11,15L 12,15L 12,17L 11,17 Z M 11,13L 11,8.00001L 12,8.00001L 12,13L 11,13 Z "},
{PackIconMaterialLightKind.AlertOctagon, "M 3,16.0112L 3,8.97919L 7.97919,4L 15.0208,4L 20,8.97918L 20,16.0255L 15.0255,21L 7.98881,21L 3,16.0112 Z M 8.39339,5.00002L 3.99999,9.39342L 3.99999,15.597L 8.40301,20L 14.6113,20L 19,15.6113L 19,9.3934L 14.6066,5.00002L 8.39339,5.00002 Z M 11,8.00002L 12,8.00002L 12,13L 11,13L 11,8.00002 Z M 11,15L 12,15L 12,17L 11,17L 11,15 Z "},
{PackIconMaterialLightKind.ArrangeBringForward, "M 8,9L 12,9L 12,10L 9.70708,10L 16.4246,16.7175L 15.7175,17.4246L 9,10.7071L 9,13L 8,13L 8,9 Z M 3.00002,4.00003L 15,4.00003L 15,13L 14,12L 14,5.00002L 4.00002,5.00002L 4.00002,15L 11,15L 12,16L 3.00002,16L 3.00002,4.00003 Z M 20,9.00003L 20,21L 8.00002,21L 8.00002,18L 9.00002,18L 9.00002,20L 19,20L 19,10L 17,10L 17,9.00003L 20,9.00003 Z "},
{PackIconMaterialLightKind.ArrangeBringToFront, "M 9,7L 9,5.00001L 4,5.00001L 4,10L 6,10L 6,11L 3,11L 3,4L 10,4L 10,7L 9,7 Z M 13,21L 13,18L 14,18L 14,20L 19,20L 19,15L 17,15L 17,14L 20,14L 20,21L 13,21 Z M 7.99999,9.00002L 15,9.00002L 15,16L 7.99999,16L 7.99999,9.00002 Z M 9,10L 9,15L 14,15L 14,10L 9,10 Z "},
{PackIconMaterialLightKind.ArrangeSendBackward, "M 6,7L 10,7L 10,8L 7.70708,8L 14.4246,14.7175L 13.7175,15.4246L 7,8.70714L 7,11L 6,11L 6,7 Z M 20,21L 7.99998,21L 8,12L 8.99997,13L 8.99997,20L 19,20L 19,10L 12,10L 11,9L 20,9.00001L 20,21 Z M 3,16L 2.99999,4.00001L 15,4.00001L 15,7.00001L 14,7.00001L 14,5.00001L 3.99998,5.00001L 3.99997,15L 5.99998,15L 5.99998,16L 3,16 Z "},
{PackIconMaterialLightKind.ArrangeSendToBack, "M 9,5.00001L 4,5.00002L 4,10L 9,10L 9,5.00001 Z M 10,11L 3,11L 3,4.00001L 10,4.00001L 10,11 Z M 13,21L 13,14L 20,14L 20,21L 13,21 Z M 14,20L 19,20L 19,15L 14,15L 14,20 Z M 16,8.00004L 16,12L 15,12L 15,9.00003L 12,9.00002L 12,8.00004L 16,8.00004 Z M 6.99998,17L 6.99998,13L 7.99999,13L 7.99999,16L 11,16L 11,17L 6.99998,17 Z "},
{PackIconMaterialLightKind.ArrowDown, "M 12,5L 12,17.25L 17.2501,12L 18,12.6643L 11.5,19.1642L 5,12.6642L 5.75001,12L 11,17.25L 11,5L 12,5 Z "},
{PackIconMaterialLightKind.ArrowDownCircle, "M 12.0031,6.99999L 12.0031,15.25L 15.2531,12L 16.0031,12.6642L 11.5031,17.1642L 7.00307,12.6642L 7.75308,12L 11.0031,15.25L 11.0031,6.99999L 12.0031,6.99999 Z M 11.503,22C 6.25634,22 2.00305,17.7467 2.00305,12.5C 2.00305,7.25329 6.25634,2.99999 11.503,2.99999C 16.7497,2.99999 21.003,7.25329 21.003,12.5C 21.003,17.7467 16.7498,22 11.503,22 Z M 11.5031,21C 16.1975,21 20.003,17.1944 20.003,12.5C 20.003,7.80557 16.1975,3.99999 11.5031,3.99999C 6.80863,3.99999 3.00305,7.80557 3.00305,12.5C 3.00305,17.1944 6.80863,21 11.5031,21 Z "},
{PackIconMaterialLightKind.ArrowLeft, "M 19,13L 6.74998,13L 12,18.2501L 11.3357,19L 4.83579,12.5L 11.3358,6L 12,6.75001L 6.75,12L 19,12L 19,13 Z "},
{PackIconMaterialLightKind.ArrowLeftCircle, "M 17,13L 8.74999,13L 12,16.2501L 11.3358,17L 6.83579,12.5L 11.3358,8.00003L 12,8.75003L 8.75001,12L 17,12L 17,13 Z M 2,12.5C 2,7.25329 6.25329,3 11.5,3C 16.7467,3 21,7.2533 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5 Z M 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80558 16.1944,4 11.5,4C 6.80558,4 3,7.80558 3,12.5 Z "},
{PackIconMaterialLightKind.ArrowRight, "M 4,12L 16.25,12L 11,6.74994L 11.6643,6L 18.1642,12.5L 11.6642,19L 11,18.25L 16.25,13L 4,13L 4,12 Z "},
{PackIconMaterialLightKind.ArrowRightCircle, "M 6.00304,12L 14.2531,12L 11.003,8.74993L 11.6673,7.99999L 16.1672,12.5L 11.6672,17L 11.003,16.25L 14.253,13L 6.00304,13L 6.00304,12 Z M 21.003,12.5C 21.003,17.7467 16.7497,22 11.503,22C 6.25634,22 2.00304,17.7467 2.00304,12.5C 2.00304,7.25329 6.25634,3 11.503,3C 16.7497,3 21.003,7.25329 21.003,12.5 Z M 20.003,12.5C 20.003,7.80557 16.1975,3.99999 11.503,3.99999C 6.80862,3.99999 3.00304,7.80557 3.00304,12.5C 3.00304,17.1944 6.80862,21 11.503,21C 16.1975,21 20.003,17.1944 20.003,12.5 Z "},
{PackIconMaterialLightKind.ArrowUp, "M 11,20L 11,7.74998L 5.74995,13L 5,12.3357L 11.5,5.83578L 18,12.3358L 17.25,13L 12,7.75L 12,20L 11,20 Z "},
{PackIconMaterialLightKind.ArrowUpCircle, "M 11,18L 11,9.74999L 7.74993,13L 6.99999,12.3358L 11.5,7.83579L 16,12.3358L 15.25,13L 12,9.75001L 12,18L 11,18 Z M 11.5,3C 16.7467,3 21,7.2533 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.2533,22 2,17.7467 2,12.5C 2,7.2533 6.25329,3 11.5,3 Z M 11.5,4.00001C 6.80557,4.00001 3,7.80559 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80559 16.1944,4.00001 11.5,4.00001 Z "},
{PackIconMaterialLightKind.Bank, "M 11,2.50002L 20,7.00001L 20,9.00001L 2,9.00001L 2,7.00001L 11,2.50002 Z M 15,10L 19,10L 19,18L 15,18L 15,10 Z M 2,22L 2,19L 20,19L 20,22L 2,22 Z M 8.99999,10L 13,10L 13,18L 8.99999,18L 8.99999,10 Z M 3,10L 6.99999,10L 6.99999,18L 3,18L 3,10 Z M 3,20L 3,21L 19,21L 19,20L 3,20 Z M 4,11L 4,17L 5.99999,17L 5.99999,11L 4,11 Z M 9.99999,11L 9.99999,17L 12,17L 12,11L 9.99999,11 Z M 16,11L 16,17L 18,17L 18,11L 16,11 Z M 3,8.00001L 19,8.00001L 19,7.60087L 11,3.58135L 3,7.60087L 3,8.00001 Z "},
{PackIconMaterialLightKind.Bell, "M 12,4.5C 12,4.22386 11.7761,4 11.5,4C 11.2239,4 11,4.22386 11,4.5L 11,6.02748C 8.75002,6.2762 6.99999,8.18372 6.99999,10.5L 6.99999,16.4142L 5.41421,18L 17.5858,18L 16,16.4142L 16,10.5C 16,8.18372 14.25,6.2762 12,6.02748L 12,4.5 Z M 11.5,3.00002C 12.3284,3.00002 13,3.6716 13,4.50001L 13,5.20704C 15.3085,5.85996 17,7.98245 17,10.5L 17,16L 20,19L 3,19L 6,16L 5.99999,10.5C 5.99999,7.98245 7.69149,5.85996 10,5.20704L 10,4.50001C 10,3.6716 10.6716,3.00002 11.5,3.00002 Z M 11.5,22C 10.2905,22 9.28164,21.1411 9.05001,20L 10.0854,20C 10.2913,20.5826 10.8469,21 11.5,21C 12.1531,21 12.7087,20.5826 12.9146,20L 13.95,20C 13.7184,21.1411 12.7095,22 11.5,22 Z "},
{PackIconMaterialLightKind.BellOff, "M 2.79289,4.45711L 3.5,3.75L 20.25,20.5L 19.5429,21.2071L 17.3358,19L 3,19L 6,16L 5.99999,10.5C 5.99999,9.66999 6.18385,8.88291 6.51307,8.17728L 2.79289,4.45711 Z M 12,4.50001C 12,4.22386 11.7761,4.00001 11.5,4.00001C 11.2239,4.00001 11,4.22386 11,4.5L 11,6.02748C 9.99766,6.13828 9.09455,6.57828 8.40118,7.23697L 7.69388,6.52967C 8.33409,5.91579 9.12247,5.45524 10,5.20704L 10,4.50002C 10,3.6716 10.6716,3.00003 11.5,3.00002C 12.3284,3.00003 13,3.6716 13,4.50002L 13,5.20704C 15.3085,5.85997 17,7.98246 17,10.5L 17,15.8358L 16,14.8358L 16,10.5C 16,8.18372 14.25,6.2762 12,6.02748L 12,4.50001 Z M 6.99999,10.5L 6.99999,16.4142L 5.41421,18L 16.3358,18L 7.27721,8.94143C 7.09791,9.42705 6.99999,9.95209 6.99999,10.5 Z M 11.5,22C 10.2905,22 9.28164,21.1411 9.05001,20L 10.0853,20C 10.2913,20.5826 10.8469,21 11.5,21C 12.1531,21 12.7087,20.5826 12.9146,20L 13.95,20C 13.7183,21.1411 12.7095,22 11.5,22 Z "},
{PackIconMaterialLightKind.Bluetooth, "M 11,3L 12,3L 16.8535,7.85356L 12.2071,12.5L 16.8536,17.1464L 12,22L 11,22L 11,13.7071L 6.55024,18.1569L 5.84314,17.4498L 10.7929,12.5L 5.84314,7.55024L 6.55025,6.84313L 11,11.2929L 11,3 Z M 12,4.41423L 12,11.2929L 15.4393,7.85356L 12,4.41423 Z M 12,20.5858L 15.4393,17.1464L 12,13.7071L 12,20.5858 Z "},
{PackIconMaterialLightKind.Book, "M 7,3L 16,3C 17.6569,3 19,4.34315 19,6L 19,19C 19,20.6569 17.6569,22 16,22L 7,22C 5.34314,22 4,20.6569 4,19L 4,6C 4,4.34315 5.34314,3 7,3 Z M 7,4.00001C 5.89543,4.00001 5,4.89544 5,6.00001L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,6.00001C 18,4.89544 17.1046,4.00001 16,4.00001L 13,4L 13,10.7002L 10,8.59959L 6.99999,10.7002L 7,4.00001 Z M 12,4L 8,4.00001L 7.99999,8.77923L 10,7.37882L 12,8.77923L 12,4 Z "},
{PackIconMaterialLightKind.Bookmark, "M 8,3L 16,3C 17.6569,3 19,4.34315 19,6L 19,21L 12,18L 5,21L 5,6C 5,4.34315 6.34314,3 8,3 Z M 8,4.00001C 6.89543,4.00001 6,4.89544 6,6.00001L 6,19.4892L 12,16.9423L 18,19.4892L 18,6.00001C 18,4.89544 17.1046,4.00001 16,4.00001L 8,4.00001 Z "},
{PackIconMaterialLightKind.BookMultiple, "M 8,3L 17,3C 18.6569,3 20,4.34315 20,6L 20,19C 20,20.6569 18.6569,22 17,22L 8,22C 6.34314,22 5,20.6569 5,19L 5,6C 5,4.34315 6.34314,3 8,3 Z M 8,4.00001C 6.89543,4.00001 6,4.89544 6,6.00001L 6,19C 6,20.1046 6.89543,21 8,21L 17,21C 18.1046,21 19,20.1046 19,19L 19,6.00001C 19,4.89544 18.1046,4.00001 17,4.00001L 14,4.00001L 14,10.7002L 11,8.59959L 7.99999,10.7002L 8,4.00001 Z M 13,4.00001L 9,4.00001L 8.99999,8.77923L 11,7.37882L 13,8.77923L 13,4.00001 Z M 8.00001,24C 5.23859,24 3.00001,21.7614 3.00001,19L 3,7L 4.00001,7L 4.00002,19C 4.00002,21.2091 5.79088,23 8.00002,23L 16,23L 16,24L 8.00001,24 Z "},
{PackIconMaterialLightKind.BookPlus, "M 7,3L 16,3C 17.6569,3 19,4.34315 19,6L 19,19C 19,20.6569 17.6569,22 16,22L 7,22C 5.34314,22 4,20.6569 4,19L 4,6C 4,4.34315 5.34314,3 7,3 Z M 7,4.00001C 5.89543,4.00001 5,4.89544 5,6.00001L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,6.00001C 18,4.89544 17.1046,4.00001 16,4.00001L 13,4.00001L 13,10.7002L 9.99999,8.59959L 6.99999,10.7002L 7,4.00001 Z M 12,4.00001L 8,4.00001L 7.99999,8.77923L 10,7.37882L 12,8.77923L 12,4.00001 Z M 9.00001,19L 9.00001,17L 7.00002,17L 7.00002,16L 9.00001,16L 9.00001,14L 10,14L 10,16L 12,16L 12,17L 10,17L 10,19L 9.00001,19 Z "},
{PackIconMaterialLightKind.BorderAll, "M 3,4L 20,4L 20,21L 3,21L 3,4 Z M 4,5L 4,12L 11,12L 11,5L 4,5 Z M 19,12L 19,5L 12,5L 12,12L 19,12 Z M 4,20L 11,20L 11,13L 4,13L 4,20 Z M 19,20L 19,13L 12,13L 12,20L 19,20 Z "},
{PackIconMaterialLightKind.BorderBottom, "M 3,20L 11,20L 11,19L 12,19L 12,20L 20,20L 20,21L 3,21L 3,20 Z M 20,18L 19,18L 19,16L 20,16L 20,18 Z M 3.99999,14L 2.99999,14L 2.99999,11L 3.99999,11L 3.99999,12L 5,12L 5,13L 3.99999,13L 3.99999,14 Z M 3.99999,18L 2.99999,18L 2.99999,16L 3.99999,16L 3.99999,18 Z M 12,13L 11,13L 11,12L 12,12L 12,13 Z M 3,5.00002L 3,4.00002L 4,4.00002L 4,5.00002L 3,5.00002 Z M 3,7.00002L 4,7.00002L 4,9.00002L 3,9.00002L 3,7.00002 Z M 15,5.00002L 15,4.00002L 17,4.00002L 17,5.00002L 15,5.00002 Z M 5.99999,5.00002L 5.99999,4.00002L 7.99999,4.00002L 7.99999,5.00002L 5.99999,5.00002 Z M 9.99999,5.00001L 9.99999,4.00001L 13,4.00001L 13,5.00001L 12,5.00001L 12,6.00001L 11,6.00001L 11,5.00001L 9.99999,5.00001 Z M 19,14L 19,13L 18,13L 18,12L 19,12L 19,11L 20,11L 20,14L 19,14 Z M 20,9.00001L 19,9.00001L 19,7.00001L 20,7.00001L 20,9.00001 Z M 19,5.00001L 19,4.00001L 20,4.00001L 20,5.00001L 19,5.00001 Z M 14,13L 14,12L 16,12L 16,13L 14,13 Z M 12,17L 11,17L 11,15L 12,15L 12,17 Z M 12,10L 11,10L 11,8L 12,8L 12,10 Z M 7,13L 7,12L 9,12L 9,13L 7,13 Z "},
{PackIconMaterialLightKind.BorderHorizontal, "M 20,18L 19,18L 19,16L 20,16L 20,18 Z M 4,14L 3,14L 3,11L 4,11L 4,12L 19,12L 19,11L 20,11L 20,14L 19,14L 19,13L 4,13L 4,14 Z M 4,18L 3,18L 3,16L 4,16L 4,18 Z M 3,5.00001L 3,4.00001L 4,4.00001L 4,5.00001L 3,5.00001 Z M 3,7.00001L 4,7.00001L 4,9.00001L 3,9.00001L 3,7.00001 Z M 15,5.00001L 15,4.00001L 17,4.00001L 17,5.00001L 15,5.00001 Z M 5.99999,5.00001L 5.99999,4.00001L 7.99999,4.00001L 7.99999,5.00001L 5.99999,5.00001 Z M 9.99999,5.00001L 9.99999,4.00001L 13,4.00001L 13,5.00001L 12,5.00001L 12,6L 11,6L 11,5.00001L 9.99999,5.00001 Z M 20,9L 19,9L 19,7.00001L 20,7.00001L 20,9 Z M 19,5L 19,4L 20,4L 20,5L 19,5 Z M 12,17L 11,17L 11,15L 12,15L 12,17 Z M 12,10L 11,10L 11,8L 12,8L 12,10 Z M 3,20L 4,20L 4,21L 3,21L 3,20 Z M 15,20L 17,20L 17,21L 15,21L 15,20 Z M 5.99999,20L 7.99999,20L 7.99999,21L 5.99999,21L 5.99999,20 Z M 10,20L 11,20L 11,19L 12,19L 12,20L 13,20L 13,21L 10,21L 10,20 Z M 19,20L 20,20L 20,21L 19,21L 19,20 Z "},
{PackIconMaterialLightKind.BorderInside, "M 17,4.00002L 17,5.00002L 15,5.00002L 15,4.00002L 17,4.00002 Z M 13,20L 13,21L 10,21L 10,20L 11,20L 11,13L 4,13L 4,14L 3,14L 3,11L 4,11L 4,12L 11,12L 11,5.00003L 9.99999,5.00003L 9.99999,4.00003L 13,4.00003L 13,5.00003L 12,5.00003L 12,12L 19,12L 19,11L 20,11L 20,14L 19,14L 19,13L 12,13L 12,20L 13,20 Z M 17,20L 17,21L 15,21L 15,20L 17,20 Z M 4,21L 3,21L 3,20L 4,20L 4,21 Z M 6,21L 6,20L 7.99999,20L 7.99999,21L 6,21 Z M 4,9.00003L 3,9.00003L 3,7.00003L 4,7.00003L 4,9.00003 Z M 4,18L 3,18L 3,16L 4,16L 4,18 Z M 7.99999,4.00002L 7.99999,5.00002L 5.99999,5.00002L 5.99999,4.00002L 7.99999,4.00002 Z M 3.99999,5.00002L 2.99999,5.00002L 2.99999,4.00002L 3.99999,4.00002L 3.99999,5.00002 Z M 19,21L 19,20L 20,20L 20,21L 19,21 Z M 19,9.00002L 19,7.00002L 20,7.00002L 20,9.00002L 19,9.00002 Z M 19,18L 19,16L 20,16L 20,18L 19,18 Z M 19,5.00001L 19,4.00001L 20,4.00001L 20,5.00001L 19,5.00001 Z "},
{PackIconMaterialLightKind.BorderLeft, "M 3.99999,4.00001L 3.99999,12L 4.99999,12L 4.99999,13L 3.99999,13L 3.99999,21L 2.99999,21L 2.99999,4.00001L 3.99999,4.00001 Z M 6.00001,21L 6.00001,20L 8.00001,20L 8.00001,21L 6.00001,21 Z M 10,5.00003L 10,4.00003L 13,4.00003L 13,5.00003L 12,5.00003L 12,6.00004L 11,6.00004L 11,5.00003L 10,5.00003 Z M 6.00001,5.00003L 6.00001,4.00003L 8,4.00003L 8,5.00003L 6.00001,5.00003 Z M 11,13L 11,12L 12,12L 12,13L 11,13 Z M 19,4.00003L 20,4.00003L 20,5.00003L 19,5.00003L 19,4.00003 Z M 17,4.00003L 17,5.00003L 15,5.00003L 15,4.00003L 17,4.00003 Z M 19,16L 20,16L 20,18L 19,18L 19,16 Z M 19,7.00002L 20,7.00002L 20,9.00002L 19,9.00002L 19,7.00002 Z M 19,11L 20,11L 20,14L 19,14L 19,13L 18,13L 18,12L 19,12L 19,11 Z M 10,20L 11,20L 11,19L 12,19L 12,20L 13,20L 13,21L 10,21L 10,20 Z M 15,21L 15,20L 17,20L 17,21L 15,21 Z M 19,20L 20,20L 20,21L 19,21L 19,20 Z M 11,15L 12,15L 12,17L 11,17L 11,15 Z M 6.99999,13L 6.99999,12L 8.99999,12L 8.99999,13L 6.99999,13 Z M 14,13L 14,12L 16,12L 16,13L 14,13 Z M 11,8.00001L 12,8.00001L 12,10L 11,10L 11,8.00001 Z "},
{PackIconMaterialLightKind.BorderNone, "M 20,18L 19,18L 19,16L 20,16L 20,18 Z M 3.99999,14L 2.99999,14L 2.99999,11L 3.99999,11L 3.99999,12L 5,12L 5,13L 3.99999,13L 3.99999,14 Z M 19,12L 19,11L 20,11L 20,14L 19,14L 19,13L 18,13L 18,12L 19,12 Z M 14,13L 14,12L 16,12L 16,13L 14,13 Z M 11,13L 11,12L 12,12L 12,13L 11,13 Z M 7,13L 7,12L 9,12L 9,13L 7,13 Z M 3.99999,18L 2.99999,18L 2.99999,16L 3.99999,16L 3.99999,18 Z M 2.99999,5.00002L 2.99999,4.00002L 3.99999,4.00002L 3.99999,5.00002L 2.99999,5.00002 Z M 2.99999,7.00002L 3.99999,7.00002L 3.99999,9.00002L 2.99999,9.00002L 2.99999,7.00002 Z M 15,5.00002L 15,4.00002L 17,4.00002L 17,5.00002L 15,5.00002 Z M 5.99999,5.00002L 5.99999,4.00002L 7.99999,4.00002L 7.99999,5.00002L 5.99999,5.00002 Z M 9.99999,5.00001L 9.99999,4.00001L 13,4.00001L 13,5.00001L 12,5.00001L 12,6.00001L 11,6.00001L 11,5.00001L 9.99999,5.00001 Z M 20,9.00001L 19,9.00001L 19,7.00001L 20,7.00001L 20,9.00001 Z M 19,5.00001L 19,4.00001L 20,4.00001L 20,5.00001L 19,5.00001 Z M 12,17L 11,17L 11,15L 12,15L 12,17 Z M 12,10L 11,10L 11,8L 12,8L 12,10 Z M 3,20L 4,20L 4,21L 3,21L 3,20 Z M 15,20L 17,20L 17,21L 15,21L 15,20 Z M 5.99999,20L 7.99999,20L 7.99999,21L 5.99999,21L 5.99999,20 Z M 9.99999,20L 11,20L 11,19L 12,19L 12,20L 13,20L 13,21L 9.99999,21L 9.99999,20 Z M 19,20L 20,20L 20,21L 19,21L 19,20 Z "},
{PackIconMaterialLightKind.BorderOutside, "M 3,4L 20,4L 20,21L 3,21L 3,4 Z M 4,5.00001L 4,12L 5,12L 5,13L 4,13L 4,20L 11,20L 11,19L 12,19L 12,20L 19,20L 19,13L 18,13L 18,12L 19,12L 19,5.00001L 12,5L 12,6L 11,6L 11,5L 4,5.00001 Z M 6.99999,12L 9,12L 9,13L 6.99999,13L 6.99999,12 Z M 11,12L 12,12L 12,13L 11,13L 11,12 Z M 11,15L 12,15L 12,17L 11,17L 11,15 Z M 14,12L 16,12L 16,13L 14,13L 14,12 Z M 11,10L 11,8L 12,8L 12,10L 11,10 Z "},
{PackIconMaterialLightKind.BorderRight, "M 19,21L 19,13L 18,13L 18,12L 19,12L 19,4L 20,4L 20,21L 19,21 Z M 17,4.00005L 17,5.00005L 15,5.00005L 15,4.00005L 17,4.00005 Z M 13,20L 13,21L 10,21L 10,20L 11,20L 11,19L 12,19L 12,20L 13,20 Z M 17,20L 17,21L 15,21L 15,20L 17,20 Z M 12,12L 12,13L 11,13L 11,12L 12,12 Z M 4,21L 3,21L 3,20L 4,20L 4,21 Z M 6,21L 6,20L 8,20L 8,21L 6,21 Z M 4,9.00003L 3,9.00003L 3,7.00003L 4,7.00003L 4,9.00003 Z M 4,18L 3,18L 3,16L 4,16L 4,18 Z M 4,14L 3,14L 3,11L 4,11L 4,12L 4.99999,12L 4.99999,13L 4,13L 4,14 Z M 13,5.00002L 12,5.00002L 12,6.00002L 11,6.00002L 11,5.00002L 9.99999,5.00002L 9.99999,4.00002L 13,4.00002L 13,5.00002 Z M 8,4.00002L 8,5.00002L 6,5.00002L 6,4.00002L 8,4.00002 Z M 4,5.00002L 3,5.00002L 3,4.00002L 4,4.00002L 4,5.00002 Z M 12,10L 11,10L 11,8.00001L 12,8.00001L 12,10 Z M 16,12L 16,13L 14,13L 14,12L 16,12 Z M 8.99999,12L 8.99999,13L 6.99999,13L 6.99999,12L 8.99999,12 Z M 12,17L 11,17L 11,15L 12,15L 12,17 Z "},
{PackIconMaterialLightKind.BorderTop, "M 20,5.00001L 12,5.00001L 12,6.00001L 11,6.00001L 11,5.00001L 2.99999,5.00001L 2.99999,4.00001L 20,4.00001L 20,5.00001 Z M 3.00002,7.00004L 4.00002,7.00004L 4.00002,9.00004L 3.00002,9.00004L 3.00002,7.00004 Z M 19,11L 20,11L 20,14L 19,14L 19,13L 18,13L 18,12L 19,12L 19,11 Z M 19,7.00004L 20,7.00004L 20,9.00004L 19,9.00004L 19,7.00004 Z M 11,12L 12,12L 12,13L 11,13L 11,12 Z M 20,20L 20,21L 19,21L 19,20L 20,20 Z M 20,18L 19,18L 19,16L 20,16L 20,18 Z M 8.00001,20L 8.00001,21L 6.00001,21L 6.00001,20L 8.00001,20 Z M 17,20L 17,21L 15,21L 15,20L 17,20 Z M 13,20L 13,21L 10,21L 10,20L 11,20L 11,19L 12,19L 12,20L 13,20 Z M 4.00001,11L 4.00001,12L 5,12L 5,13L 4.00001,13L 4.00001,14L 3.00001,14L 3.00001,11L 4.00001,11 Z M 3,16L 4,16L 4,18L 3,18L 3,16 Z M 4,20L 4,21L 3,21L 3,20L 4,20 Z M 8.99999,12L 8.99999,13L 6.99999,13L 6.99999,12L 8.99999,12 Z M 11,8.00002L 12,8.00002L 12,10L 11,10L 11,8.00002 Z M 11,15L 12,15L 12,17L 11,17L 11,15 Z M 16,12L 16,13L 14,13L 14,12L 16,12 Z "},
{PackIconMaterialLightKind.BorderVertical, "M 17,4.00002L 17,5.00002L 15,5.00002L 15,4.00002L 17,4.00002 Z M 13,20L 13,21L 10,21L 10,20L 11,20L 11,5.00003L 9.99999,5.00003L 9.99999,4.00003L 13,4.00003L 13,5.00003L 12,5.00003L 12,20L 13,20 Z M 17,20L 17,21L 15,21L 15,20L 17,20 Z M 4,21L 3,21L 3,20L 4,20L 4,21 Z M 6,21L 6,20L 8,20L 8,21L 6,21 Z M 4,9.00003L 3,9.00003L 3,7.00003L 4,7.00003L 4,9.00003 Z M 4,18L 3,18L 3,16L 4,16L 4,18 Z M 4,14L 3,14L 3,11L 4,11L 4,12L 4.99999,12L 4.99999,13L 4,13L 4,14 Z M 7.99999,4.00002L 7.99999,5.00002L 5.99999,5.00002L 5.99999,4.00002L 7.99999,4.00002 Z M 3.99999,5.00002L 2.99999,5.00002L 2.99999,4.00002L 3.99999,4.00002L 3.99999,5.00002 Z M 16,12L 16,13L 14,13L 14,12L 16,12 Z M 8.99999,12L 8.99999,13L 6.99999,13L 6.99999,12L 8.99999,12 Z M 19,21L 19,20L 20,20L 20,21L 19,21 Z M 19,9.00002L 19,7.00002L 20,7.00002L 20,9.00002L 19,9.00002 Z M 19,18L 19,16L 20,16L 20,18L 19,18 Z M 19,14L 19,13L 18,13L 18,12L 19,12L 19,11L 20,11L 20,14L 19,14 Z M 19,5.00001L 19,4.00001L 20,4.00001L 20,5.00001L 19,5.00001 Z "},
{PackIconMaterialLightKind.Briefcase, "M 5,7.00001L 8,7L 8,5L 9.99999,3.00001L 13,3.00001L 15,5L 15,7L 18,7.00002C 19.6568,7.00002 21,8.34316 21,10L 21,18C 21,19.6569 19.6568,21 18,21L 5,21C 3.34315,21 2,19.6569 2,18L 2,10C 2,8.34316 3.34314,7.00001 5,7.00001 Z M 10.4142,4.00001L 9,5.41422L 9,7L 14,7L 14,5.41422L 12.5858,4.00001L 10.4142,4.00001 Z M 5,8.00001C 3.89543,8.00001 3,8.89544 3,10L 3,18C 3,19.1046 3.89543,20 5,20L 18,20C 19.1046,20 20,19.1046 20,18L 20,10C 20,8.89545 19.1046,8.00002 18,8.00002L 5,8.00001 Z "},
{PackIconMaterialLightKind.Calendar, "M 7,2.00001L 8,2.00001C 8.55228,2.00001 9,2.44772 9,3.00001L 9,4L 14,4L 14,3C 14,2.44771 14.4477,2 15,2L 16,2C 16.5523,2 17,2.44771 17,3L 17,4C 18.6569,4 20,5.34315 20,7L 20,18C 20,19.6569 18.6569,21 17,21L 6,21C 4.34315,21 3,19.6569 3,18L 3,7C 3,5.34315 4.34314,4 6,4L 6,3.00001C 6,2.44772 6.44771,2.00001 7,2.00001 Z M 15,4L 16,4L 16,2.99999L 15,2.99999L 15,4 Z M 8,4L 8,3L 7,3L 7,4L 8,4 Z M 6,5.00001C 4.89543,5.00001 4,5.89544 4,7.00001L 4,8.00001L 19,8.00001L 19,7.00001C 19,5.89544 18.1046,5.00001 17,5.00001L 6,5.00001 Z M 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,9.00001L 4,9.00001L 4,18 Z M 12,13L 17,13L 17,18L 12,18L 12,13 Z M 13,14L 13,17L 16,17L 16,14L 13,14 Z "},
{PackIconMaterialLightKind.Camcorder, "M 5,7.00001L 14,7.00001C 15.1046,7.00001 16,7.89544 16,9.00001L 16,11.5L 20,7.50002L 20,17.5L 16,13.5L 16,16C 16,17.1046 15.1046,18 14,18L 5,18C 3.89543,18 3,17.1046 3,16L 3,9.00001C 3,7.89544 3.89543,7.00001 5,7.00001 Z M 5,8.00002C 4.44771,8.00002 4,8.44773 4,9.00002L 4,16C 4,16.5523 4.44771,17 5,17L 14,17C 14.5523,17 15,16.5523 15,16L 15,9.00002C 15,8.44774 14.5523,8.00002 14,8.00002L 5,8.00002 Z M 19,9.91422L 16.4142,12.5L 19,15.0858L 19,9.91422 Z "},
{PackIconMaterialLightKind.Camera, "M 11.5,8C 13.9853,8 16,10.0147 16,12.5C 16,14.9853 13.9853,17 11.5,17C 9.01472,17 7,14.9853 7,12.5C 7,10.0147 9.01472,8 11.5,8 Z M 11.5,9.00001C 9.567,9.00001 8,10.567 8,12.5C 8,14.433 9.567,16 11.5,16C 13.433,16 15,14.433 15,12.5C 15,10.567 13.433,9.00001 11.5,9.00001 Z M 5,5.00001L 6.99999,5.00001L 9,3.00001L 14,3.00001L 16,5.00001L 18,5.00001C 19.6568,5.00001 21,6.34315 21,8.00001L 21,17C 21,18.6569 19.6568,20 18,20L 5,20C 3.34314,20 2,18.6569 2,17L 2,8.00001C 2,6.34315 3.34314,5.00001 5,5.00001 Z M 9.4142,4.00001L 7.4142,6.00001L 5,6.00001C 3.89543,6.00001 3,6.89544 3,8.00001L 3,17C 3,18.1046 3.89543,19 5,19L 18,19C 19.1046,19 20,18.1046 20,17L 20,8.00001C 20,6.89544 19.1046,6.00001 18,6.00001L 15.5858,6.00001L 13.5858,4.00001L 9.4142,4.00001 Z "},
{PackIconMaterialLightKind.Cancel, "M 11.503,22C 6.25634,22 2.00305,17.7467 2.00305,12.5C 2.00305,7.25329 6.25634,2.99999 11.503,2.99999C 16.7497,2.99999 21.003,7.25329 21.003,12.5C 21.003,17.7467 16.7498,22 11.503,22 Z M 11.5031,21C 16.1975,21 20.003,17.1944 20.003,12.5C 20.003,10.3319 19.1913,8.35344 17.8552,6.85187L 5.85494,18.8522C 7.35651,20.1883 9.33499,21 11.5031,21 Z M 11.5031,3.99999C 6.80863,3.99999 3.00305,7.80557 3.00305,12.5C 3.00305,14.6665 3.81361,16.6437 5.14801,18.1449L 17.1479,6.14495C 15.6468,4.81054 13.6696,3.99999 11.5031,3.99999 Z "},
{PackIconMaterialLightKind.Cart, "M 16,18C 17.1046,18 18,18.8954 18,20C 18,21.1046 17.1046,22 16,22C 14.8954,22 14,21.1046 14,20C 14,18.8954 14.8954,18 16,18 Z M 16,19C 15.4477,19 15,19.4477 15,20C 15,20.5523 15.4477,21 16,21C 16.5523,21 17,20.5523 17,20C 17,19.4477 16.5523,19 16,19 Z M 7,18C 8.10457,18 9,18.8954 9,20C 9,21.1046 8.10457,22 7,22C 5.89543,22 5,21.1046 5,20C 5,18.8954 5.89543,18 7,18 Z M 7,19C 6.44771,19 6,19.4477 6,20C 6,20.5523 6.44771,21 7,21C 7.55228,21 8,20.5523 8,20C 8,19.4477 7.55228,19 7,19 Z M 18,6L 4.27342,6L 6.82026,12L 15,12C 15.3279,12 15.619,11.8422 15.8004,11.5976L 18.8003,7.59758L 18.8013,7.59834C 18.9261,7.43149 19,7.22438 19,7.00001C 19,6.44772 18.5523,6 18,6 Z M 15,13L 6.8655,13L 6.10138,14.5608L 6,15C 6,15.5523 6.44771,16 7,16L 18,16L 18,17L 7,17C 5.89543,17 5,16.1046 5,15C 5,14.6482 5.09086,14.3175 5.25038,14.0303L 5.9697,12.5555L 2.33811,4L 1,4L 1,3L 2.99999,3.00001L 3.84894,5L 18,5C 19.1046,5.00001 20,5.89544 20,7.00001C 20,7.47749 19.8327,7.91589 19.5535,8.25977L 16.6392,12.1462C 16.2776,12.6624 15.6782,13 15,13 Z "},
{PackIconMaterialLightKind.ChartAreaspline, "M 3,4L 4,4L 4,17.9787L 9.57042,8.33041L 15.5797,11.7998L 19.1955,5.5371L 20.0615,6.0371L 15.9457,13.1659L 9.93645,9.69644L 4,19.9787L 4,20L 6.29708,20L 10.1685,13.2945L 10.6685,12.4285L 11.5345,12.9285L 16.6777,15.8979L 20,10.1436L 20,21L 3,21L 3,4 Z M 17.0438,17.2639L 11.0345,13.7945L 7.45178,20L 19,20L 19,13.8756L 17.0438,17.2639 Z "},
{PackIconMaterialLightKind.ChartBar, "M 2,4L 3,4L 3,20L 5,20L 5,10L 9,10L 9,20L 11,20L 11,6L 15,6L 15,20L 17,20L 17,14L 21,14L 21,21L 2,21L 2,4 Z M 18,15L 18,20L 20,20L 20,15L 18,15 Z M 12,7.00001L 12,20L 14,20L 14,7.00001L 12,7.00001 Z M 6,11L 6,20L 8,20L 8,11L 6,11 Z "},
{PackIconMaterialLightKind.ChartHistogram, "M 3,4L 4,4L 4,13L 7,13L 7,7L 8,7L 12,7L 12,11L 16,11L 16,15L 20,15L 20,21L 3,21L 3,4 Z M 16,16L 16,20L 19,20L 19,16L 16,16 Z M 12,12L 12,20L 15,20L 15,12L 12,12 Z M 8,8.00001L 8,20L 11,20L 11,8.00001L 8,8.00001 Z M 4,14L 4,20L 6.99999,20L 6.99999,14L 4,14 Z "},
{PackIconMaterialLightKind.ChartLine, "M 3,4L 4,4L 4,18L 9.58109,8.33327L 15.5903,11.8027L 19.2061,5.53996L 20.0721,6.03996L 15.9563,13.1687L 9.94712,9.69929L 4,20L 20,20L 20,21L 3,21L 3,4 Z "},
{PackIconMaterialLightKind.ChartPie, "M 12,3L 13,3C 17.4183,3 21,6.58172 21,11L 21,12L 12,12L 12,3 Z M 13,11L 20,11C 20,7.13401 16.866,4 13,4L 13,11 Z M 10,14L 18,14C 18,18.4183 14.4183,22 10,22C 5.58172,22 2,18.4183 2,14C 2,9.58173 5.58172,6 10,6L 10,14 Z M 9,15L 9,7.07089C 5.6077,7.55612 3,10.4735 3,14C 3,17.866 6.13401,21 10,21C 13.5265,21 16.4439,18.3923 16.9291,15L 9,15 Z "},
{PackIconMaterialLightKind.Check, "M 18.8995,8.1005L 9,18L 4.05025,13.0503L 4.75736,12.3431L 9,16.5858L 18.1924,7.3934L 18.8995,8.1005 Z "},
{PackIconMaterialLightKind.CheckBold, "M 9,19L 3.34315,13.3431L 5.46447,11.2218L 9,14.7574L 17.4853,6.27208L 19.6066,8.3934L 9,19 Z M 5.46447,12.636L 4.75736,13.3431L 9,17.5858L 18.1924,8.3934L 17.4853,7.68629L 9,16.1716L 5.46447,12.636 Z "},
{PackIconMaterialLightKind.ChevronDoubleDown, "M 17.1569,7.59315L 11.5,13.25L 5.84314,7.59315L 6.55025,6.88604L 11.5,11.8358L 16.4497,6.88604L 17.1569,7.59315 Z M 17.1569,11.5931L 11.5,17.25L 5.84315,11.5931L 6.55025,10.886L 11.5,15.8358L 16.4498,10.886L 17.1569,11.5931 Z "},
{PackIconMaterialLightKind.ChevronDoubleLeft, "M 16.4069,18.1569L 10.75,12.5L 16.4069,6.84314L 17.114,7.55025L 12.1642,12.5L 17.114,17.4497L 16.4069,18.1569 Z M 12.4069,18.1569L 6.75,12.5L 12.4069,6.84315L 13.114,7.55025L 8.16421,12.5L 13.114,17.4497L 12.4069,18.1569 Z "},
{PackIconMaterialLightKind.ChevronDoubleRight, "M 6.59315,6.84315L 12.25,12.5L 6.59315,18.1569L 5.88604,17.4497L 10.8358,12.5L 5.88604,7.55025L 6.59315,6.84315 Z M 10.5931,6.84314L 16.25,12.5L 10.5931,18.1569L 9.88604,17.4497L 14.8358,12.5L 9.88604,7.55025L 10.5931,6.84314 Z "},
{PackIconMaterialLightKind.ChevronDoubleUp, "M 5.84314,17.4069L 11.5,11.75L 17.1569,17.4069L 16.4497,18.114L 11.5,13.1642L 6.55025,18.114L 5.84314,17.4069 Z M 5.84314,13.4069L 11.5,7.75L 17.1569,13.4069L 16.4497,14.114L 11.5,9.16421L 6.55025,14.114L 5.84314,13.4069 Z "},
{PackIconMaterialLightKind.ChevronDown, "M 5.84314,9.59315L 11.5,15.25L 17.1569,9.59315L 16.4497,8.88604L 11.5,13.8358L 6.55025,8.88604L 5.84314,9.59315 Z "},
{PackIconMaterialLightKind.ChevronLeft, "M 14.4069,18.1569L 8.75,12.5L 14.4069,6.84314L 15.114,7.55025L 10.1642,12.5L 15.114,17.4497L 14.4069,18.1569 Z "},
{PackIconMaterialLightKind.ChevronRight, "M 8.59314,18.1569L 14.25,12.5L 8.59314,6.84314L 7.88603,7.55025L 12.8358,12.5L 7.88604,17.4497L 8.59314,18.1569 Z "},
{PackIconMaterialLightKind.ChevronUp, "M 5.84314,15.4069L 11.5,9.75L 17.1569,15.4069L 16.4497,16.114L 11.5,11.1642L 6.55025,16.114L 5.84314,15.4069 Z "},
{PackIconMaterialLightKind.Clipboard, "M 6,5.00001L 8.5,5.00001C 8.5,3.34316 9.84314,2.00001 11.5,2.00001C 13.1568,2.00001 14.5,3.34316 14.5,5.00001L 17,5.00001C 18.6568,5.00001 20,6.34315 20,8.00001L 20,19C 20,20.6569 18.6568,22 17,22L 6,22C 4.34314,22 3,20.6569 3,19L 3,8.00001C 3,6.34315 4.34314,5.00001 6,5.00001 Z M 5.99999,6.00002C 4.89543,6.00002 4,6.89544 4,8.00002L 4,19C 4,20.1046 4.89543,21 5.99999,21L 17,21C 18.1046,21 19,20.1046 19,19L 19,8.00002C 19,6.89544 18.1046,6.00002 17,6.00002L 16,6.00001L 16,9.00002L 6.99999,9.00002L 6.99999,6.00001L 5.99999,6.00002 Z M 8,8L 15,8L 15,6L 8,6L 8,8 Z M 11.5,3C 10.3954,3 9.5,3.89544 9.5,5L 13.5,5C 13.5,3.89544 12.6046,3 11.5,3 Z "},
{PackIconMaterialLightKind.ClipboardCheck, "M 6,5.00001L 8.5,5.00001C 8.5,3.34316 9.84314,2.00001 11.5,2.00001C 13.1568,2.00001 14.5,3.34316 14.5,5.00001L 17,5.00001C 18.6568,5.00001 20,6.34315 20,8.00001L 20,19C 20,20.6569 18.6568,22 17,22L 6,22C 4.34314,22 3,20.6569 3,19L 3,8.00001C 3,6.34315 4.34314,5.00001 6,5.00001 Z M 5.99999,6.00002C 4.89543,6.00002 4,6.89545 4,8.00002L 4,19C 4,20.1046 4.89543,21 5.99999,21L 17,21C 18.1046,21 19,20.1046 19,19L 19,8.00002C 19,6.89545 18.1046,6.00002 17,6.00002L 16,6.00002L 16,9.00002L 6.99999,9.00002L 6.99999,6.00002L 5.99999,6.00002 Z M 8,8L 15,8L 15,6L 8,6L 8,8 Z M 11.5,3C 10.3954,3 9.5,3.89544 9.5,5.00001L 13.5,5.00001C 13.5,3.89544 12.6046,3 11.5,3 Z M 17.1495,11.6005L 10,18.75L 6.80024,15.5503L 7.50735,14.8432L 10,17.3358L 16.4424,10.8934L 17.1495,11.6005 Z "},
{PackIconMaterialLightKind.ClipboardPlus, "M 6,5.00001L 8.5,5.00001C 8.5,3.34316 9.84314,2.00001 11.5,2.00001C 13.1568,2.00001 14.5,3.34316 14.5,5.00001L 17,5.00001C 18.6568,5.00001 20,6.34315 20,8.00001L 20,19C 20,20.6569 18.6568,22 17,22L 6,22C 4.34314,22 3,20.6569 3,19L 3,8.00001C 3,6.34315 4.34314,5.00001 6,5.00001 Z M 5.99999,6.00002C 4.89543,6.00002 3.99999,6.89545 3.99999,8.00002L 3.99999,19C 3.99999,20.1046 4.89543,21 5.99999,21L 17,21C 18.1045,21 19,20.1046 19,19L 19,8.00002C 19,6.89545 18.1045,6.00002 17,6.00002L 16,6.00002L 16,9.00002L 6.99999,9.00002L 6.99999,6.00002L 5.99999,6.00002 Z M 8,8.00001L 15,8.00001L 15,6.00001L 8,6.00001L 8,8.00001 Z M 11.5,3.00001C 10.3954,3.00001 9.5,3.89544 9.5,5.00001L 13.5,5.00001C 13.5,3.89544 12.6046,3.00001 11.5,3.00001 Z M 8,19L 8,17L 6.00001,17L 6.00001,16L 8,16L 8,14L 9,14L 9,16L 11,16L 11,17L 9,17L 9,19L 8,19 Z "},
{PackIconMaterialLightKind.ClipboardText, "M 6,5.00001L 8.5,5.00001C 8.5,3.34316 9.84314,2.00001 11.5,2.00001C 13.1568,2.00001 14.5,3.34316 14.5,5.00001L 17,5.00001C 18.6568,5.00001 20,6.34315 20,8.00001L 20,19C 20,20.6569 18.6568,22 17,22L 6,22C 4.34314,22 3,20.6569 3,19L 3,8.00001C 3,6.34315 4.34314,5.00001 6,5.00001 Z M 5.99999,6.00002C 4.89543,6.00002 3.99999,6.89545 3.99999,8.00002L 3.99999,19C 3.99999,20.1046 4.89543,21 5.99999,21L 17,21C 18.1045,21 19,20.1046 19,19L 19,8.00002C 19,6.89545 18.1045,6.00002 17,6.00002L 16,6.00002L 16,9.00002L 6.99999,9.00002L 6.99999,6.00002L 5.99999,6.00002 Z M 8,8.00001L 15,8.00001L 15,6.00001L 8,6.00001L 8,8.00001 Z M 11.5,3.00001C 10.3954,3.00001 9.5,3.89544 9.5,5.00001L 13.5,5.00001C 13.5,3.89544 12.6046,3.00001 11.5,3.00001 Z M 6,11L 17,11L 17,12L 6,12L 6,11 Z M 6,14L 17,14L 17,15L 6,15L 6,14 Z M 6,17L 15,17L 15,18L 6,18L 6,17 Z "},
{PackIconMaterialLightKind.Clock, "M 11.5,3C 16.7467,3 21,7.2533 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.2533,22 2,17.7467 2,12.5C 2,7.2533 6.25329,3 11.5,3 Z M 11.5,4.00001C 6.80558,4.00001 3,7.80558 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80558 16.1944,4.00001 11.5,4.00001 Z M 11,7L 12,7L 12,12.4226L 16.6961,15.134L 16.1961,16L 11,13L 11,7 Z "},
{PackIconMaterialLightKind.ClosedCaption, "M 4,5.00001L 19,5.00001C 20.6568,5.00001 22,6.34315 22,8.00001L 22,17C 22,18.6569 20.6568,20 19,20L 4,20C 2.34314,20 0.999998,18.6569 0.999998,17L 0.999999,8.00001C 0.999999,6.34315 2.34314,5.00001 4,5.00001 Z M 3.99999,6.00002C 2.89543,6.00002 2,6.89545 2,8.00002L 1.99999,17C 1.99999,18.1046 2.89542,19 3.99999,19L 19,19C 20.1045,19 21,18.1046 21,17L 21,8.00002C 21,6.89545 20.1045,6.00002 19,6.00002L 3.99999,6.00002 Z M 8.5,8C 9.48936,8 10.4042,8.31928 11.147,8.86043L 10.5587,9.66923C 9.98101,9.24833 9.2695,9 8.5,9C 6.567,9 5,10.567 5,12.5C 5,14.433 6.567,16 8.5,16C 9.2695,16 9.98101,15.7517 10.5587,15.3308L 11.147,16.1396C 10.4042,16.6807 9.48936,17 8.5,17C 6.01472,17 4,14.9853 4,12.5C 4,10.0147 6.01472,8 8.5,8 Z M 16.353,8C 17.3424,8 18.2572,8.31929 19,8.86043L 18.4118,9.66923C 17.8341,9.24833 17.1225,9 16.353,9C 14.42,9 12.853,10.567 12.853,12.5C 12.853,14.433 14.42,16 16.353,16C 17.1225,16 17.834,15.7517 18.4118,15.3308L 19,16.1396C 18.2572,16.6807 17.3424,17 16.353,17C 13.8678,17 11.853,14.9853 11.853,12.5C 11.853,10.0147 13.8678,8 16.353,8 Z "},
{PackIconMaterialLightKind.Cloud, "M 5.5,20C 2.46243,20 0,17.5376 0,14.5C 0,11.463 2.46144,9.00099 5.49816,9C 6.47772,6.65105 8.79605,5 11.5,5C 14.9316,5 17.7421,7.6592 17.9832,11.0294L 18.5,11C 20.9853,11 23,13.0147 23,15.5C 23,17.9853 20.9853,20 18.5,20L 5.5,20 Z M 5.5,10C 3.01472,10 0.999999,12.0147 0.999999,14.5C 0.999999,16.9853 3.01472,19 5.5,19C 7.22096,19 16.6464,19 18.5,19C 20.433,19 22,17.433 22,15.5C 22,13.567 20.433,12 18.5,12C 17.9361,12 17.4033,12.1334 16.9315,12.3703C 16.9766,12.0868 17,11.7961 17,11.5C 17,8.46244 14.5376,6 11.5,6C 8.96324,6 6.8276,7.7174 6.19235,10.0529L 5.5,10 Z "},
{PackIconMaterialLightKind.CloudDownload, "M 5.5,20C 2.46243,20 0,17.5376 0,14.5C 0,11.463 2.46144,9.00099 5.49816,9C 6.47772,6.65105 8.79605,5 11.5,5C 14.9316,5 17.7421,7.6592 17.9832,11.0294L 18.5,11C 20.9853,11 23,13.0147 23,15.5C 23,17.9853 20.9853,20 18.5,20L 5.5,20 Z M 5.5,10C 3.01472,10 0.999999,12.0147 0.999999,14.5C 0.999999,16.9853 3.01472,19 5.5,19L 18.5,19C 20.433,19 22,17.433 22,15.5C 22,13.567 20.433,12 18.5,12C 17.9361,12 17.4033,12.1334 16.9315,12.3703L 17,11.5C 17,8.46244 14.5376,6 11.5,6C 8.96324,6 6.8276,7.7174 6.19234,10.0529L 5.5,10 Z M 12,10L 12,15.25L 14.25,13L 15,13.6643L 11.5,17.1642L 7.99998,13.6642L 8.74999,13L 11,15.25L 11,10L 12,10 Z "},
{PackIconMaterialLightKind.CloudUpload, "M 5.5,20C 2.46243,20 0,17.5376 0,14.5C 0,11.463 2.46144,9.00099 5.49816,9C 6.47772,6.65105 8.79605,5 11.5,5C 14.9316,5 17.7421,7.6592 17.9832,11.0294L 18.5,11C 20.9853,11 23,13.0147 23,15.5C 23,17.9853 20.9853,20 18.5,20L 5.5,20 Z M 5.5,10C 3.01472,10 0.999999,12.0147 0.999999,14.5C 0.999999,16.9853 3.01472,19 5.5,19L 18.5,19C 20.433,19 22,17.433 22,15.5C 22,13.567 20.433,12 18.5,12C 17.9361,12 17.4033,12.1334 16.9315,12.3703L 17,11.5C 17,8.46244 14.5376,6 11.5,6C 8.96324,6 6.8276,7.7174 6.19234,10.0529L 5.5,10 Z M 12,17L 12,11.75L 14.25,14L 15,13.3358L 11.5,9.83582L 8.00001,13.3358L 8.75001,14L 11,11.75L 11,17L 12,17 Z "},
{PackIconMaterialLightKind.Cog, "M 19.5885,15.4916L 17.774,14.2015C 18.068,13.1221 18.087,11.9525 17.7686,10.7808L 19.5885,9.5065L 18.1359,6.99258L 16.1115,7.91891C 15.3236,7.12459 14.3202,6.52334 13.1463,6.21321L 12.9527,4L 10.0473,4L 9.85366,6.21321C 8.67978,6.52334 7.67635,7.12459 6.88854,7.91891L 4.86405,6.99258L 3.41152,9.5065L 5.23139,10.7808C 4.91304,11.9525 4.93202,13.1221 5.22601,14.2015L 3.41154,15.4916L 4.86405,17.9928L 6.88854,17.0664C 7.67635,17.8607 8.67978,18.462 9.85366,18.7721L 10.0473,20.9853L 12.9527,20.9853L 13.1463,18.7721C 14.3202,18.462 15.3236,17.8607 16.1115,17.0664L 18.1359,17.9928L 19.5885,15.4916 Z M 13.5051,2.98533C 13.7733,2.98533 13.9922,3.19651 14.0045,3.46167L 14.1826,5.49676C 14.9377,5.78489 15.6237,6.18605 16.226,6.67526L 18.0763,5.81248C 18.3121,5.69061 18.6044,5.77457 18.7385,6.00685L 20.7434,9.47752C 20.8775,9.7098 20.8041,10.005 20.5806,10.1482L 18.9072,11.32C 19.0352,12.118 19.0308,12.9126 18.9083,13.6789L 20.5806,14.8499C 20.8041,14.9931 20.8775,15.2883 20.7434,15.5206L 18.7385,18.9785C 18.6044,19.2108 18.3121,19.2947 18.0763,19.1728L 16.226,18.3101C 15.6237,18.7993 14.9377,19.2004 14.1826,19.4886L 14.0045,21.5237C 13.9922,21.7888 13.7733,22 13.5051,22L 9.49493,22C 9.22672,22 9.00783,21.7888 8.99548,21.5237L 8.81743,19.4886C 8.06233,19.2004 7.37633,18.7993 6.77398,18.3101L 4.92374,19.1728C 4.68794,19.2947 4.3956,19.2108 4.2615,18.9785L 2.2566,15.5206C 2.12249,15.2883 2.19594,14.9931 2.4194,14.8499L 4.0917,13.6789C 3.96921,12.9126 3.96479,12.118 4.09281,11.32L 2.4194,10.1482C 2.19594,10.005 2.12249,9.7098 2.2566,9.47752L 4.2615,6.00685C 4.3956,5.77457 4.68794,5.69061 4.92374,5.81249L 6.77398,6.67526C 7.37633,6.18605 8.06233,5.78489 8.81743,5.49676L 8.99548,3.46167C 9.00783,3.19651 9.22672,2.98533 9.49493,2.98533L 13.5051,2.98533 Z M 11.5,9C 13.433,9 15,10.567 15,12.5C 15,14.433 13.433,16 11.5,16C 9.567,16 8,14.433 8,12.5C 8,10.567 9.567,9 11.5,9 Z M 11.5,10C 10.1193,10 9,11.1193 9,12.5C 9,13.8807 10.1193,15 11.5,15C 12.8807,15 14,13.8807 14,12.5C 14,11.1193 12.8807,10 11.5,10 Z "},
{PackIconMaterialLightKind.Comment, "M 5,3.00002L 18,3.00003C 19.6568,3.00003 21,4.34316 21,6.00002L 21,15C 21,16.6569 19.6568,18 18,18L 13.4142,18L 9.7071,21.7071C 9.52614,21.8881 9.27614,22 9,22C 8.44771,22 8,21.5523 8,21L 8,18L 5,18C 3.34315,18 2,16.6569 2,15L 2,6.00001C 2,4.34316 3.34314,3.00002 5,3.00002 Z M 18,4.00002L 5,4.00002C 3.89543,4.00002 3,4.89545 3,6.00002L 3,15C 3,16.1046 3.89543,17 5,17L 9,17L 9,21L 13,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,6.00002C 20,4.89545 19.1045,4.00002 18,4.00002 Z "},
{PackIconMaterialLightKind.CommentAlert, "M 5,3.00002L 18,3.00003C 19.6568,3.00003 21,4.34316 21,6.00002L 21,15C 21,16.6569 19.6568,18 18,18L 13.4142,18L 9.7071,21.7071C 9.52614,21.8881 9.27614,22 9,22C 8.44771,22 8,21.5523 8,21L 8,18L 5,18C 3.34315,18 2,16.6569 2,15L 2,6.00001C 2,4.34316 3.34314,3.00002 5,3.00002 Z M 18,4.00003L 4.99999,4.00002C 3.89543,4.00002 2.99999,4.89545 2.99999,6.00002L 3,15C 3,16.1046 3.89543,17 5,17L 9,17L 9,21L 13,17L 18,17C 19.1045,17 20,16.1046 20,15L 20,6.00003C 20,4.89546 19.1045,4.00003 18,4.00003 Z M 11,6L 12,6L 12,11L 11,11L 11,6 Z M 11,13L 12,13L 12,15L 11,15L 11,13 Z "},
{PackIconMaterialLightKind.CommentText, "M 5,3.00002L 18,3.00003C 19.6568,3.00003 21,4.34316 21,6.00002L 21,15C 21,16.6569 19.6568,18 18,18L 13.4142,18L 9.7071,21.7071C 9.52614,21.8881 9.27614,22 9,22C 8.44771,22 8,21.5523 8,21L 8,18L 5,18C 3.34315,18 2,16.6569 2,15L 2,6.00001C 2,4.34316 3.34314,3.00002 5,3.00002 Z M 18,4.00003L 4.99999,4.00002C 3.89542,4.00002 2.99999,4.89546 2.99999,6.00002L 3,15C 3,16.1046 3.89543,17 5,17L 9,17L 9,21L 13,17L 18,17C 19.1045,17 20,16.1046 20,15L 20,6.00003C 20,4.89546 19.1045,4.00003 18,4.00003 Z M 5,7.00001L 18,7.00001L 18,8.00001L 5,8.00001L 5,7.00001 Z M 5,10L 17,10L 17,11L 5,11L 5,10 Z M 5,13L 13,13L 13,14L 5,14L 5,13 Z "},
{PackIconMaterialLightKind.Console, "M 5,4L 18,4C 19.6569,4 21,5.34315 21,7L 21,18C 21,19.6569 19.6569,21 18,21L 5,21C 3.34315,21 2,19.6569 2,18L 2,7C 2,5.34315 3.34315,4 5,4 Z M 5,5.00001C 3.89543,5.00001 3,5.89544 3,7.00001L 20,7.00001C 20,5.89544 19.1046,5.00001 18,5.00001L 5,5.00001 Z M 3,18C 3,19.1046 3.89543,20 5,20L 18,20C 19.1046,20 20,19.1046 20,18L 20,8.00001L 3,8.00001L 3,18 Z M 17,18L 12,18L 12,17L 17,17L 17,18 Z M 6,10.5L 6.7071,9.7929L 10.9142,14L 6.7071,18.2071L 6,17.5L 9.5,14L 6,10.5 Z "},
{PackIconMaterialLightKind.ContentCut, "M 9,6.5C 9,7.28617 8.7408,8.0118 8.30319,8.59609L 20,20.2929L 20,21L 19.2929,21L 11.5,13.2071L 8.30319,16.4039C 8.7408,16.9882 9,17.7138 9,18.5C 9,20.433 7.433,22 5.5,22C 3.567,22 2,20.433 2,18.5C 2,16.567 3.56701,15 5.5,15C 6.28617,15 7.0118,15.2592 7.59609,15.6968L 10.7929,12.5L 7.59609,9.30319C 7.0118,9.7408 6.28617,10 5.5,10C 3.56701,10 2,8.433 2,6.5C 2,4.567 3.56701,3 5.5,3C 7.433,3 9,4.56701 9,6.5 Z M 8,6.5C 8,5.11929 6.88071,4 5.5,4C 4.11929,4 3,5.11929 3,6.5C 3,7.88071 4.11929,9 5.5,9C 6.88071,9 8,7.88071 8,6.5 Z M 19.2929,4L 20,4L 20,4.70712L 12.8536,11.8536L 12.1464,11.1465L 19.2929,4 Z M 5.5,16C 4.11929,16 3,17.1193 3,18.5C 3,19.8807 4.11929,21 5.5,21C 6.88071,21 8,19.8807 8,18.5C 8,17.1193 6.88071,16 5.5,16 Z "},
{PackIconMaterialLightKind.ContentDuplicate, "M 9,6.00006L 17,6.00002C 18.6569,6.00002 20,7.34316 20,9.00001L 20,20C 20,21.6568 18.6569,23 17,23L 9,23C 7.34315,23 6,21.6569 6,20L 6,19L 7,19L 7,20C 7,21.1046 7.89543,22 9,22L 17,22C 18.1046,22 19,21.1046 19,20L 19,9.00001C 19,7.89544 18.1046,7.00001 17,7.00001L 9,7.00006C 7.89543,7.00006 7,7.89548 7,9.00003L 7,14L 6,14L 6,9.00003C 6,7.3432 7.34314,6.00006 9,6.00006 Z M 5,2.00001L 15,2.00001L 15,3L 5,3C 3.89543,3 3,3.89543 3,5L 3,14C 3,15.1046 3.89543,16 5,16L 12.25,16L 9.99997,13.75L 10.6642,13L 14.1642,16.5L 10.6642,20L 9.99997,19.25L 12.25,17L 5,17C 3.34314,17 2,15.6569 2,14L 2,5.00001C 2,3.34315 3.34314,2.00001 5,2.00001 Z "},
{PackIconMaterialLightKind.ContentPaste, "M 11.5,1C 12.7095,1 13.7184,1.85888 13.95,3L 17,3C 18.6569,3 20,4.34315 20,6L 20,19C 20,20.6569 18.6569,22 17,22L 6,22C 4.34315,22 3,20.6569 3,19L 3,6C 3,4.34315 4.34315,3 6,3L 9.05001,3C 9.28165,1.85888 10.2905,1 11.5,1 Z M 12.9146,3.00001C 12.7087,2.41742 12.1531,2.00002 11.5,2.00002C 10.8469,2.00002 10.2913,2.41742 10.0854,3.00001L 12.9146,3.00001 Z M 6,4.00001C 4.89543,4.00001 4,4.89544 4,6.00001L 4,19C 4,20.1046 4.89543,21 6,21L 17,21C 18.1046,21 19,20.1046 19,19L 19,6.00001C 19,4.89544 18.1046,4.00001 17,4.00001L 16,4L 16,7L 7,7.00001L 7,4.00001L 6,4.00001 Z M 8,4.00001L 8,6L 15,6L 15,4L 8,4.00001 Z "},
{PackIconMaterialLightKind.ContentSave, "M 6.00001,4L 16.5858,4L 20,7.41422L 20,18C 20,19.6569 18.6569,21 17,21L 6.00001,21C 4.34315,21 3.00001,19.6569 3.00001,18L 3.00001,7C 3.00001,5.34315 4.34315,4 6.00001,4 Z M 6,5.00001C 4.89543,5.00001 4,5.89544 4,7.00001L 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,7.91421L 16.0858,5.00001L 15,5L 15,9L 15,10L 6,10L 6,9.00001L 6,5.00001 Z M 7,5.00001L 7,9.00001L 14,9L 14,5L 7,5.00001 Z M 12,12C 13.6568,12 15,13.3432 15,15C 15,16.6569 13.6568,18 12,18C 10.3431,18 8.99999,16.6569 8.99999,15C 8.99999,13.3432 10.3431,12 12,12 Z M 12,13C 10.8954,13 9.99999,13.8954 9.99999,15C 9.99999,16.1046 10.8954,17 12,17C 13.1046,17 14,16.1046 14,15C 14,13.8954 13.1046,13 12,13 Z "},
{PackIconMaterialLightKind.ContentSaveAll, "M 6,3L 16.5858,3L 20,6.41422L 20,17C 20,18.6569 18.6569,20 17,20L 6,20C 4.34315,20 3,18.6569 3,17L 3,6C 3,4.34315 4.34315,3 6,3 Z M 6,4.00001C 4.89543,4.00001 4,4.89544 4,6.00001L 4,17C 4,18.1046 4.89543,19 6,19L 17,19C 18.1046,19 19,18.1046 19,17L 19,6.91421L 16.0858,4.00001L 15,4L 15,8L 15,9L 6,9L 6,8.00001L 6,4.00001 Z M 7,4.00001L 7,8.00001L 14,8L 14,4L 7,4.00001 Z M 12,11C 13.6568,11 15,12.3432 15,14C 15,15.6569 13.6568,17 12,17C 10.3431,17 8.99999,15.6569 8.99999,14C 8.99999,12.3432 10.3431,11 12,11 Z M 12,12C 10.8954,12 9.99999,12.8954 9.99999,14C 9.99999,15.1046 10.8954,16 12,16C 13.1046,16 14,15.1046 14,14C 14,12.8954 13.1046,12 12,12 Z M 6,22C 3.23858,22 1,19.7614 1,17L 0.999991,7.00001L 2,7.00001L 2.00002,17C 2.00002,19.2091 3.79088,21 6.00002,21L 16,21L 16,22L 6,22 Z "},
{PackIconMaterialLightKind.CreditCard, "M 5,5L 18,5C 19.6569,5 21,6.34315 21,8L 21,17C 21,18.6569 19.6568,20 18,20L 5,20C 3.34314,20 2,18.6569 2,17L 2,8C 2,6.34315 3.34315,5 5,5 Z M 5,6.00001C 3.89543,6.00001 3,6.89544 3,8.00001L 3,9.00001L 20,9.00001L 20,8.00001C 20,6.89544 19.1046,6.00001 18,6.00001L 5,6.00001 Z M 2.99999,17C 2.99999,18.1046 3.89543,19 4.99999,19L 18,19C 19.1045,19 20,18.1046 20,17L 20,12L 3,12L 2.99999,17 Z M 5,16L 9,16L 9,17L 5,17L 5,16 Z M 11,16L 14,16L 14,17L 11,17L 11,16 Z M 3,10L 3,11L 20,11L 20,10L 3,10 Z "},
{PackIconMaterialLightKind.Crop, "M 8,6L 15,6C 16.6569,6 18,7.34315 18,9L 18,16L 17,16L 17,9C 17,7.89543 16.1046,7 15,7L 8,7L 8,6 Z M 8,19C 6.34314,19 5,17.6569 5,16L 5,7L 1,7L 1,6L 5,6L 5,2L 6,2L 6,16C 6,17.1046 6.89543,18 8,18L 21,18L 21,19L 18,19L 18,23L 17,23L 17,19L 8,19 Z "},
{PackIconMaterialLightKind.CropFree, "M 6,4L 8,4L 8,5.00001L 6,5.00001C 4.89543,5.00001 4,5.89544 4,7.00001L 4,9L 3,9L 3,7C 3,5.34315 4.34315,4 6,4 Z M 4,18C 4,19.1046 4.89543,20 6,20L 8,20L 8,21L 6,21C 4.34314,21 3,19.6569 3,18L 3,16L 4,16L 4,18 Z M 17,4C 18.6569,4 20,5.34315 20,7L 20,9L 19,9L 19,7.00001C 19,5.89544 18.1046,5.00001 17,5.00001L 15,5.00002L 15,4.00001L 17,4 Z M 20,18C 20,19.6569 18.6569,21 17,21L 15,21L 15,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,16L 20,16L 20,18 Z "},
{PackIconMaterialLightKind.CurrencyEur, "M 2,11L 2.5,10L 5.3736,10C 6.44117,6.52567 9.67563,4 13.5,4C 15.6301,4 17.5772,4.78352 19.0688,6.07808L 18.6724,7.06895C 17.3268,5.78699 15.5053,5 13.5,5C 10.2345,5 7.45636,7.08702 6.42677,10L 17.5,10L 17.1,11L 6.15003,11C 6.05165,11.4847 6,11.9863 6,12.5C 6,13.0137 6.05165,13.5153 6.15003,14L 15.9,14L 15.5,15L 6.42677,15C 7.45636,17.913 10.2345,20 13.5,20C 15.6731,20 17.6303,19.0758 19,17.5991L 19,18.981C 17.5176,20.2403 15.5975,21 13.5,21C 9.67563,21 6.44117,18.4743 5.3736,15L 2,15L 2.5,14L 5.13193,14C 5.04524,13.5131 5,13.0118 5,12.5C 5,11.9882 5.04524,11.4869 5.13193,11L 2,11 Z "},
{PackIconMaterialLightKind.CurrencyGbp, "M 7,13L 7,12L 9.82264,12C 9.7471,11.5257 9.65689,11.0997 9.57161,10.6967C 9.38481,9.81641 9.20878,8.98499 9.25118,7.97913C 9.32597,6.17765 9.92322,4.92838 11.0253,4.26628C 12.7112,3.25488 15.0531,3.98093 16.0233,4.36011L 15.8547,5.37197C 15.2061,5.09996 12.9588,4.26795 11.5384,5.12508C 10.7434,5.60348 10.3097,6.57739 10.2498,8.02071C 10.2134,8.901 10.3692,9.63668 10.5495,10.4889C 10.6477,10.9515 10.7519,11.4426 10.8353,12L 15,12L 15,13L 10.9507,13C 10.9817,13.3834 11,13.7979 11,14.2513C 11,17.4284 9.52734,18.9844 8.34574,20L 17,20L 17,21L 6.5,21L 6.5,20L 7.30534,19.5677C 8.44267,18.6237 10,17.332 10,14.2513C 10,13.7968 9.97996,13.3826 9.94652,13L 7,13 Z "},
{PackIconMaterialLightKind.CurrencyRub, "M 7,21L 7,16L 6,16L 6,15L 7,15L 7,12L 6,12L 6,11L 7,11L 7,4L 14,4C 16.2091,4 18,5.79086 18,8C 18,10.2091 16.2091,12 14,12L 8,12L 8,15L 14,15L 14,16L 8,16L 8,21L 7,21 Z M 8,11L 14,11C 15.6568,11 17,9.65684 17,7.99998C 17,6.34313 15.6568,4.99998 14,4.99998L 8,4.99998L 8,11 Z "},
{PackIconMaterialLightKind.CurrencyUsd, "M 11,4L 12,4L 12,6.0104C 15.2904,6.15117 16,7.69522 16,9L 15,9C 15,7.67322 13.8223,7 11.5,7C 10.6791,7 8,7.1628 8,9.24882C 8,10.1212 8,11.1093 11.6211,12.0151L 13.2272,12.5C 15.7599,13.4348 16,14.5721 16,15.7512C 16,17.632 14.4815,18.844 12,18.986L 12,21L 11,21L 11,18.9896C 7.70962,18.8488 7,17.3048 7,16L 8,16C 8,17.3268 9.17773,18 11.5,18C 12.3209,18 15,17.8372 15,15.7512C 15,14.8788 15,13.8907 11.3789,12.9849L 9.77282,12.5C 7.2401,11.5652 7,10.4279 7,9.24882C 7,7.36802 8.5185,6.15596 11,6.01401L 11,4 Z "},
{PackIconMaterialLightKind.Delete, "M 18,19C 18,20.6569 16.6568,22 15,22L 7.99999,22C 6.34314,22 5,20.6569 5,19L 4.99999,7.00003L 4,7.00001L 4,4.00002L 8.49999,4.00001L 9.49999,3.00001L 13.5,3.00002L 14.5,4.00002L 19,4.00002L 19,7.00001L 18,7.00003L 18,19 Z M 5.99998,7.00003L 5.99999,19C 5.99999,20.1046 6.89542,21 7.99999,21L 15,21C 16.1046,21 17,20.1046 17,19L 17,7.00003L 5.99998,7.00003 Z M 18,6.00002L 18,5.00002L 14,5.00001L 13,4.00001L 10,4.00001L 8.99999,5.00001L 4.99999,5.00002L 4.99999,6.00002L 18,6.00002 Z M 7.99999,9.00001L 8.99999,9.00001L 8.99999,19L 7.99999,19L 7.99999,9.00001 Z M 14,9.00001L 15,9.00001L 15,19L 14,19L 14,9.00001 Z "},
{PackIconMaterialLightKind.Diamond, "M 6,3L 17,3L 20.902,8.5726L 11.5,22L 2.09803,8.5726L 6,3 Z M 10.1619,4L 8.46399,8L 14.536,8L 12.8381,4L 10.1619,4 Z M 8.3275,9L 11.5,18.7639L 14.6725,9L 8.3275,9 Z M 3.71974,8L 7.37762,8L 9.07552,4L 6.52057,4L 3.71974,8 Z M 3.61807,9L 10.4431,18.7471L 7.27604,9L 3.61807,9 Z M 19.2803,8L 16.4794,4L 13.9245,4L 15.6224,8L 19.2803,8 Z M 19.3819,9L 15.724,9L 12.5569,18.7471L 19.3819,9 Z "},
{PackIconMaterialLightKind.DotsHorizontal, "M 16,12C 16,10.8954 16.8954,10 18,10C 19.1046,10 20,10.8954 20,12C 20,13.1046 19.1046,14 18,14C 16.8954,14 16,13.1046 16,12 Z M 10,12C 10,10.8954 10.8954,10 12,10C 13.1046,10 14,10.8954 14,12C 14,13.1046 13.1046,14 12,14C 10.8954,14 10,13.1046 10,12 Z M 4,12C 4,10.8954 4.89543,10 6,10C 7.10457,10 8,10.8954 8,12C 8,13.1046 7.10457,14 6,14C 4.89543,14 4,13.1046 4,12 Z M 6,11C 5.44771,11 5,11.4477 5,12C 5,12.5523 5.44771,13 6,13C 6.55228,13 7,12.5523 7,12C 7,11.4477 6.55228,11 6,11 Z M 12,11C 11.4477,11 11,11.4477 11,12C 11,12.5523 11.4477,13 12,13C 12.5523,13 13,12.5523 13,12C 13,11.4477 12.5523,11 12,11 Z M 18,11C 17.4477,11 17,11.4477 17,12C 17,12.5523 17.4477,13 18,13C 18.5523,13 19,12.5523 19,12C 19,11.4477 18.5523,11 18,11 Z "},
{PackIconMaterialLightKind.DotsVertical, "M 12,16C 13.1046,16 14,16.8954 14,18C 14,19.1046 13.1046,20 12,20C 10.8954,20 10,19.1046 10,18C 10,16.8954 10.8954,16 12,16 Z M 12,10C 13.1046,10 14,10.8954 14,12C 14,13.1046 13.1046,14 12,14C 10.8954,14 10,13.1046 10,12C 10,10.8954 10.8954,10 12,10 Z M 12,4.00001C 13.1046,4.00001 14,4.89544 14,6.00001C 14,7.10458 13.1046,8.00001 12,8.00001C 10.8954,8.00001 10,7.10458 10,6.00001C 10,4.89544 10.8954,4.00001 12,4.00001 Z M 12,5.00001C 11.4477,5.00001 11,5.44772 11,6.00001C 11,6.55229 11.4477,7.00001 12,7.00001C 12.5523,7.00001 13,6.55229 13,6.00001C 13,5.44772 12.5523,5.00001 12,5.00001 Z M 12,11C 11.4477,11 11,11.4477 11,12C 11,12.5523 11.4477,13 12,13C 12.5523,13 13,12.5523 13,12C 13,11.4477 12.5523,11 12,11 Z M 12,17C 11.4477,17 11,17.4477 11,18C 11,18.5523 11.4477,19 12,19C 12.5523,19 13,18.5523 13,18C 13,17.4477 12.5523,17 12,17 Z "},
{PackIconMaterialLightKind.Download, "M 12,4L 12,16.25L 17.2501,11L 18,11.6643L 11.5,18.1642L 5,11.6642L 5.75001,11L 11,16.25L 11,4L 12,4 Z M 3,19L 4,19L 4,21L 19,21L 19,19L 20,19L 20,22L 3,22L 3,19 Z "},
{PackIconMaterialLightKind.Eject, "M 5.33,15L 11.5,5.74962L 17.67,15L 5.33,15 Z M 5,18L 18,18L 18,19L 5,19L 5,18 Z M 6.9802,14.0252L 16.0198,14.0252L 11.5,7.24888L 6.9802,14.0252 Z "},
{PackIconMaterialLightKind.Email, "M 5,5.00001L 18,5.00001C 19.6568,5.00001 21,6.34316 21,8.00001L 21,17C 21,18.6569 19.6568,20 18,20L 5,20C 3.34315,20 2,18.6569 2,17L 2,8.00001C 2,6.34315 3.34314,5.00001 5,5.00001 Z M 5,6.00001C 4.51172,6.00001 4.0643,6.17499 3.71704,6.46566L 11.5,11.52L 19.2829,6.46566C 18.9357,6.17499 18.4883,6.00001 18,6.00001L 5,6.00001 Z M 11.5,12.7123L 3.1338,7.27926C 3.04738,7.50287 3,7.74591 3,8.00001L 3,17C 3,18.1046 3.89543,19 5,19L 18,19C 19.1046,19 20,18.1046 20,17L 20,8.00001C 20,7.74591 19.9526,7.50287 19.8662,7.27926L 11.5,12.7123 Z "},
{PackIconMaterialLightKind.EmailOpen, "M 21,9.00001L 21,18C 21,19.6569 19.6568,21 18,21L 5,21C 3.34315,21 2,19.6569 2,18L 2,9.00001C 2,7.88989 2.60296,6.92061 3.49924,6.40179L 3.497,6.39791L 11.498,1.77853L 19.5049,6.40133L 19.5037,6.4035C 20.3983,6.92273 21,7.89111 21,9.00001 Z M 3.71704,7.46567L 11.5,12.52L 19.2829,7.46567L 11.498,2.93324L 3.71704,7.46567 Z M 11.5,13.7123L 3.1338,8.27927C 3.04738,8.50288 3,8.74591 3,9.00001L 3,18C 3,19.1046 3.89543,20 5,20L 18,20C 19.1046,20 20,19.1046 20,18L 20,9.00002C 20,8.74592 19.9526,8.50288 19.8662,8.27927L 11.5,13.7123 Z "},
{PackIconMaterialLightKind.Ereader, "M 6.99999,3L 16,3C 17.6569,3 19,4.34315 19,6L 19,19C 19,20.6569 17.6569,22 16,22L 6.99999,22C 5.34314,22 3.99999,20.6569 3.99999,19L 3.99999,6C 3.99999,4.34315 5.34314,3 6.99999,3 Z M 7,4.00001C 5.89543,4.00001 5,4.89544 5,6.00001L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,6.00001C 18,4.89544 17.1046,4.00001 16,4.00001L 7,4.00001 Z M 6.99999,5.00001L 16,5.00001C 16.5523,5.00001 17,5.44773 17,6.00001L 17,18C 17,18.5523 16.5523,19 16,19L 6.99999,19C 6.44771,19 5.99999,18.5523 5.99999,18L 5.99999,6.00001C 5.99999,5.44773 6.44771,5.00001 6.99999,5.00001 Z M 7,6.00001L 7,18L 16,18L 16,6.00001L 7,6.00001 Z M 9,8L 14,8L 14,9L 9,9L 9,8 Z M 9,11L 14,11L 14,12L 9,12L 9,11 Z M 9,14L 12,14L 12,15L 9,15L 9,14 Z "},
{PackIconMaterialLightKind.Eye, "M 11.5,18C 15.4888,18 18.9581,15.7758 20.7354,12.5C 18.9581,9.22419 15.4888,7 11.5,7C 7.5112,7 4.04188,9.22419 2.26462,12.5C 4.04188,15.7758 7.5112,18 11.5,18 Z M 11.5,6C 16.0593,6 19.999,8.65327 21.8591,12.5C 19.999,16.3467 16.0593,19 11.5,19C 6.94066,19 3.00102,16.3467 1.14091,12.5C 3.00102,8.65328 6.94066,6 11.5,6 Z M 11.5,8C 13.9853,8 16,10.0147 16,12.5C 16,14.9853 13.9853,17 11.5,17C 9.01472,17 7,14.9853 7,12.5C 7,10.0147 9.01472,8 11.5,8 Z M 11.5,9C 9.567,9 8,10.567 8,12.5C 8,14.433 9.567,16 11.5,16C 13.433,16 15,14.433 15,12.5C 15,10.567 13.433,9 11.5,9 Z "},
{PackIconMaterialLightKind.EyeOff, "M 2.54289,4.70711L 3.25,4L 20,20.75L 19.2929,21.4571L 15.9452,18.1094C 14.5777,18.683 13.0758,19 11.5,19C 6.94066,19 3.00102,16.3467 1.14091,12.5C 2.10647,10.5032 3.63235,8.82803 5.51437,7.67858L 2.54289,4.70711 Z M 11.5,18C 12.7928,18 14.031,17.7664 15.1748,17.339L 14.0465,16.2107C 13.3223,16.7086 12.4452,17 11.5,17C 9.01472,17 7,14.9853 7,12.5C 7,11.5548 7.29142,10.6777 7.78931,9.95352L 6.24398,8.4082C 4.57001,9.37802 3.18863,10.7969 2.26462,12.5C 4.04188,15.7758 7.5112,18 11.5,18 Z M 20.7354,12.5C 18.9581,9.22419 15.4888,7 11.5,7C 10.3453,7 9.23413,7.18639 8.19494,7.53073L 7.41201,6.7478C 8.68223,6.26459 10.0602,6 11.5,6C 16.0593,6 19.999,8.65328 21.8591,12.5C 20.9465,14.3873 19.5333,15.9873 17.7919,17.1277L 17.068,16.4038C 18.6017,15.4426 19.8694,14.0961 20.7354,12.5 Z M 11.5,8C 13.9853,8 16,10.0147 16,12.5C 16,13.3154 15.7831,14.0801 15.4039,14.7397L 14.6635,13.9993C 14.8793,13.5449 15,13.0365 15,12.5C 15,10.567 13.433,9.00001 11.5,9.00001C 10.9635,9.00001 10.4551,9.12073 10.0007,9.33649L 9.26029,8.59608C 9.91985,8.21688 10.6846,8 11.5,8 Z M 8,12.5C 8,14.433 9.567,16 11.5,16C 12.1682,16 12.7926,15.8128 13.3237,15.4879L 8.51209,10.6763C 8.18723,11.2074 8,11.8318 8,12.5 Z "},
{PackIconMaterialLightKind.Factory, "M 2,8L 9,12.0415L 9,8L 16,12L 16,3.00001L 21,3.00001L 21.0018,12L 21,12L 21,22L 2,22L 2,8 Z M 17,14L 10,9.73206L 10,13.7735L 3,9.73206L 3,21L 20,21L 20,12L 20.0018,12L 20,4.00001L 17,4.00001L 17,14 Z M 5,15L 8,15L 8,16L 5,16L 5,15 Z M 5,18L 10,18L 10,19L 5,19L 5,18 Z M 12,15L 15,15L 15,16L 12,16L 12,15 Z M 12,18L 18,18L 18,19L 12,19L 12,18 Z "},
{PackIconMaterialLightKind.FastForward, "M 21.4022,12.5L 12,18.3751L 11,19L 11,13.3762L 3,18.3751L 2,19L 2,6L 11,11.6238L 11,6L 21.4022,12.5 Z M 19.5151,12.5L 12,7.80405L 12,17.196L 19.5151,12.5 Z M 10.5151,12.5L 3,7.80405L 3,17.196L 10.5151,12.5 Z "},
{PackIconMaterialLightKind.File, "M 14,11C 12.3431,11 11,9.65686 11,8L 11,4.00001L 7,4.00001C 5.89543,4.00001 5,4.89544 5,6.00001L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,11L 14,11 Z M 12,8C 12,9.10457 12.8954,10 14,10L 17.5858,10L 12,4.41421L 12,8 Z M 7,3L 12,3.00001L 19,10L 19,19C 19,20.6569 17.6569,22 16,22L 7,22C 5.34314,22 4,20.6569 4,19L 4,6C 4,4.34315 5.34314,3 7,3 Z "},
{PackIconMaterialLightKind.FileMultiple, "M 15,11C 13.3431,11 12,9.65686 12,8L 12,4.00001L 8,4.00001C 6.89543,4.00001 6,4.89544 6,6.00001L 6,19C 6,20.1046 6.89543,21 8,21L 17,21C 18.1046,21 19,20.1046 19,19L 19,11L 15,11 Z M 13,8C 13,9.10457 13.8954,10 15,10L 18.5858,10L 13,4.41421L 13,8 Z M 8,3L 13,3.00001L 20,10L 20,19C 20,20.6569 18.6569,22 17,22L 8,22C 6.34314,22 5,20.6569 5,19L 5,6C 5,4.34315 6.34314,3 8,3 Z M 8,24C 5.23858,24 3,21.7614 3,19L 2.99999,7L 4,7L 4.00001,19C 4.00001,21.2091 5.79087,23 8.00001,23L 16,23L 16,24L 8,24 Z "},
{PackIconMaterialLightKind.FilePlus, "M 14,11C 12.3431,11 11,9.65686 11,8L 11,4.00001L 7,4.00001C 5.89543,4.00001 5,4.89544 5,6.00001L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,11L 14,11 Z M 12,8C 12,9.10457 12.8954,10 14,10L 17.5858,10L 12,4.41421L 12,8 Z M 7,3.00001L 12,3.00001L 19,10L 19,19C 19,20.6569 17.6568,22 16,22L 7,22C 5.34314,22 4,20.6569 4,19L 4,6.00001C 4,4.34315 5.34314,3.00001 7,3.00001 Z M 9,19L 9,17L 7,17L 7,16L 9,16L 9,14L 10,14L 10,16L 12,16L 12,17L 10,17L 10,19L 9,19 Z "},
{PackIconMaterialLightKind.Filmstrip, "M 4,4L 5,4L 5,6L 7,6L 7,4L 16,4L 16,6.00001L 18,6.00001L 18,4.00001L 19,4.00001L 19,21L 18,21L 18,19L 16,19L 16,21L 7,21L 7,19L 5,19L 5,21L 4,21L 4,4 Z M 7,7L 5,7L 5,10L 7,10L 7,7 Z M 7,11L 5,11L 5,14L 7,14L 7,11 Z M 7,15L 5,15L 5,18L 7,18L 7,15 Z M 16,18L 18,18L 18,15L 16,15L 16,18 Z M 16,14L 18,14L 18,11L 16,11L 16,14 Z M 16,10L 18,10L 18,7.00001L 16,7.00001L 16,10 Z M 8,5L 8,12L 15,12L 15,5L 8,5 Z M 8,13L 8,20L 15,20L 15,13L 8,13 Z "},
{PackIconMaterialLightKind.Flag, "M 5,5L 13.4227,5.00001L 14.5774,7L 19,7.00001L 19,16L 13,16L 11.8453,14L 6,14L 6,21L 5,21L 5,5 Z M 18,15L 18,8L 14,8L 12.8453,6.00001L 6,6L 6,13L 12.4227,13L 13.5774,15L 18,15 Z "},
{PackIconMaterialLightKind.Flash, "M 16,3L 12.5099,10L 16,10L 10,22.0341L 10,14L 7,14L 7,3L 16,3 Z M 10.894,11L 14.384,4L 8,4L 8,13L 11,13L 11,17.7873L 14.384,11L 10.894,11 Z "},
{PackIconMaterialLightKind.Flask, "M 13,6.00001L 14,6.00001L 14,5.00001C 14,4.44772 13.5523,4.00001 13,4.00001L 10,4.00001C 9.44771,4.00001 9,4.44772 9,5.00001L 9,6.00001L 10,6.00001L 10,8.07181L 4.28544,17.9697C 4.10423,18.2706 4,18.6231 4,19C 4,20.1046 4.89543,21 6,21L 17,21C 18.1046,21 19,20.1046 19,19C 19,18.6232 18.8958,18.2707 18.7146,17.9698L 13,8.07181L 13,6.00001 Z M 5.99999,22C 4.34314,22 3,20.6569 3,19C 3,18.3969 3.17795,17.8354 3.48423,17.3651L 8.99999,7.81149L 8.99999,7.00003C 8.4477,7.00003 7.99999,6.55232 7.99999,6.00003L 7.99999,5.00003C 7.99999,3.89547 8.89542,3.00005 9.99999,3.00005L 13,3.00005C 14.1045,3.00005 15,3.89546 15,5.00003L 15,6.00002C 15,6.55231 14.5523,7.00003 14,7.00003L 14,7.81149L 19.5157,17.3651C 19.822,17.8354 20,18.3969 20,19C 20,20.6568 18.6568,22 17,22L 5.99999,22 Z M 12.2937,15.2921L 13.9202,13.6656L 17,19L 6,19L 9.66087,12.6592L 12.2937,15.2921 Z M 12.2937,16.7063L 9.87528,14.2878L 7.73205,18L 15.268,18L 13.7058,15.2942L 12.2937,16.7063 Z M 12,10C 12.5523,10 13,10.4477 13,11C 13,11.5523 12.5523,12 12,12C 11.4477,12 11,11.5523 11,11C 11,10.4477 11.4477,10 12,10 Z "},
{PackIconMaterialLightKind.FlaskEmpty, "M 13,6.00001L 14,6.00001L 14,5.00001C 14,4.44772 13.5523,4.00001 13,4.00001L 10,4.00001C 9.44771,4.00001 9,4.44772 9,5.00001L 9,6.00001L 10,6.00001L 10,8.07181L 4.28544,17.9697C 4.10423,18.2706 4,18.6231 4,19C 4,20.1046 4.89543,21 6,21L 17,21C 18.1046,21 19,20.1046 19,19C 19,18.6232 18.8958,18.2707 18.7146,17.9698L 13,8.07181L 13,6.00001 Z M 5.99999,22C 4.34314,22 2.99999,20.6569 2.99999,19C 2.99999,18.3969 3.17795,17.8354 3.48423,17.3651L 8.99999,7.81149L 8.99998,7.00003C 8.4477,7.00003 7.99998,6.55232 7.99999,6.00003L 7.99998,5.00004C 7.99999,3.89547 8.89542,3.00005 9.99999,3.00005L 13,3.00005C 14.1045,3.00005 15,3.89546 15,5.00003L 15,6.00002C 15,6.55231 14.5523,7.00003 14,7.00003L 14,7.81149L 19.5157,17.3651C 19.822,17.8354 20,18.3969 20,19C 20,20.6568 18.6568,22 17,22L 5.99999,22 Z "},
{PackIconMaterialLightKind.Folder, "M 5,5L 9,5.00001L 12,8.00004L 18,8.00002C 19.6568,8.00002 21,9.34317 21,11L 21,17C 21,18.6569 19.6569,20 18,20L 5,20C 3.34315,20 2,18.6569 2,17L 2,8C 2,6.34315 3.34315,5 5,5 Z M 5,6.00001C 3.89543,6.00001 3,6.89544 3,8L 3,17C 3,18.1046 3.89543,19 5,19L 18,19C 19.1046,19 20,18.1046 20,17L 20,11C 20,9.89546 19.1045,9.00003 18,9.00003L 11.5858,9.00005L 8.58579,6.00002L 5,6.00001 Z "},
{PackIconMaterialLightKind.FolderMultiple, "M 6,5L 8.99999,5.00001L 12,8.00004L 19,8.00002C 20.6568,8.00002 22,9.34317 22,11L 22,17C 22,18.6569 20.6569,20 19,20L 6,20C 4.34315,20 3,18.6569 3,17L 3,8C 3,6.34315 4.34315,5 6,5 Z M 6,6.00001C 4.89543,6.00001 4,6.89544 4,8.00001L 4,17C 4,18.1046 4.89543,19 6,19L 19,19C 20.1046,19 21,18.1046 21,17L 21,11C 21,9.89546 20.1045,9.00003 19,9.00003L 11.5858,9.00006L 8.58579,6.00002L 6,6.00001 Z M 6,22C 3.23858,22 1,19.7614 1,17L 0.999999,9.00001L 2.00001,9.00001L 2.00001,17C 2.00001,19.2091 3.79087,21 6.00001,21L 18,21L 18,22L 6,22 Z "},
{PackIconMaterialLightKind.FolderPlus, "M 5,5L 9,5.00001L 12,8.00004L 18,8.00002C 19.6568,8.00002 21,9.34317 21,11L 21,17C 21,18.6569 19.6569,20 18,20L 5,20C 3.34315,20 2,18.6569 2,17L 2,8C 2,6.34315 3.34315,5 5,5 Z M 5,6.00001C 3.89543,6.00001 3,6.89544 3,8.00001L 3,17C 3,18.1046 3.89543,19 5,19L 18,19C 19.1046,19 20,18.1046 20,17L 20,11C 20,9.89546 19.1045,9.00003 18,9.00003L 11.5858,9.00005L 8.58579,6.00002L 5,6.00001 Z M 7,17L 7,15L 5,15L 5,14L 7,14L 7,12L 8,12L 8,14L 10,14L 10,15L 8,15L 8,17L 7,17 Z "},
{PackIconMaterialLightKind.FormatAlignBottom, "M 3,21L 3,20L 16,20L 16,21L 3,21 Z M 3,17L 3,16L 20,16L 20,17L 3,17 Z M 11,4.00001L 12,4.00001L 12,12.25L 15.25,9.00001L 16,9.66421L 11.5,14.1642L 7,9.66427L 7.74995,9.00001L 11,12.25L 11,4.00001 Z "},
{PackIconMaterialLightKind.FormatAlignCenter, "M 3,4L 20,4L 20,5L 3,5L 3,4 Z M 7,8.00001L 16,8.00001L 16,9.00001L 7,9.00001L 7,8.00001 Z M 3,12L 20,12L 20,13L 3,13L 3,12 Z M 7,16L 16,16L 16,17L 7,17L 7,16 Z M 3,20L 20,20L 20,21L 3,21L 3,20 Z "},
{PackIconMaterialLightKind.FormatAlignJustify, "M 3,5L 3,4L 20,4L 20,5L 3,5 Z M 3,9L 3,8L 20,8L 20,9L 3,9 Z M 3,13L 3,12L 20,12L 20,13L 3,13 Z M 3,17L 3,16L 20,16L 20,17L 3,17 Z M 3,21L 3,20L 20,20L 20,21L 3,21 Z "},
{PackIconMaterialLightKind.FormatAlignLeft, "M 3,21L 3,20L 20,20L 20,21L 3,21 Z M 3,17L 3,16L 14,16L 14,17L 3,17 Z M 3,13L 3,12L 20,12L 20,13L 3,13 Z M 3,9L 3,8L 14,8L 14,9L 3,9 Z M 3,5L 3,4L 20,4L 20,5L 3,5 Z "},
{PackIconMaterialLightKind.FormatAlignMiddle, "M 3,13L 3,12L 20,12L 20,13L 3,13 Z M 11,4.00001L 12,4.00001L 12,8.25003L 14.25,6.00006L 15,6.66426L 11.5,10.1642L 7.99998,6.66431L 8.74993,6.00006L 11,8.25005L 11,4.00001 Z M 11,21L 11,16.75L 8.74994,19L 8,18.3357L 11.5,14.8358L 15,18.3357L 14.25,19L 12,16.75L 12,21L 11,21 Z "},
{PackIconMaterialLightKind.FormatAlignRight, "M 20,4L 20,5L 3,5L 3,4L 20,4 Z M 20,8L 20,9L 9,9L 9,8L 20,8 Z M 20,12L 20,13L 3,13L 3,12L 20,12 Z M 20,16L 20,17L 9,17L 9,16L 20,16 Z M 20,20L 20,21L 3,21L 3,20L 20,20 Z "},
{PackIconMaterialLightKind.FormatAlignTop, "M 3,4L 20,4L 20,5L 3,5L 3,4 Z M 3,8L 16,8L 16,9L 3,9L 3,8 Z M 11,21L 11,12.75L 7.74995,16L 7,15.3357L 11.5,10.8358L 16,15.3358L 15.25,16L 12,12.75L 12,21L 11,21 Z "},
{PackIconMaterialLightKind.FormatBold, "M 16,14.5C 16,16.433 14.433,18 12.5,18L 7,18L 7,5.00001L 11.5,5C 13.433,5 15,6.567 15,8.5C 15,9.59515 14.497,10.5728 13.7094,11.2146C 15.0464,11.707 16,12.9921 16,14.5 Z M 11.5,6.00001L 8,6.00001L 8,11L 11.5,11C 12.8807,11 14,9.88072 14,8.50001C 14,7.1193 12.8807,6.00001 11.5,6.00001 Z M 12.5,12L 8,12L 8,17L 12.5,17C 13.8807,17 15,15.8807 15,14.5C 15,13.1193 13.8807,12 12.5,12 Z "},
{PackIconMaterialLightKind.FormatClear, "M 8,4L 17,4L 17,5L 13.0114,5L 8.50684,17L 7.50684,17L 12.0114,5L 8,5L 8,4 Z M 5,21L 5,20L 13,20L 13,21L 5,21 Z M 16.7929,17.5L 14,14.7071L 14.7071,14L 17.5,16.7929L 20.2929,14L 21,14.7071L 18.2071,17.5L 21,20.2929L 20.2929,21L 17.5,18.2071L 14.7071,21L 14,20.2929L 16.7929,17.5 Z "},
{PackIconMaterialLightKind.FormatFloatCenter, "M 3,4L 20,4L 20,5L 3,5L 3,4 Z M 3,16L 20,16L 20,17L 3,17L 3,16 Z M 16,20L 16,21L 3,21L 3,20L 16,20 Z M 8,7L 15,7L 15,14L 8,14L 8,7 Z M 14,8L 9,8L 9,13L 14,13L 14,8 Z "},
{PackIconMaterialLightKind.FormatFloatLeft, "M 3,4L 20,4L 20,5L 3,5L 3,4 Z M 12,8.00001L 20,8.00001L 20,9.00001L 12,9.00001L 12,8.00001 Z M 12,12L 20,12L 20,13L 12,13L 12,12 Z M 3,16L 16,16L 16,17L 3,17L 3,16 Z M 20,20L 20,21L 3,21L 3,20L 20,20 Z M 3,7L 10,7L 10,14L 3,14L 3,7 Z M 9,8L 4,8L 4,13L 9,13L 9,8 Z "},
{PackIconMaterialLightKind.FormatFloatNone, "M 3,4L 20,4L 20,5L 3,5L 3,4 Z M 12,13L 12,12L 20,12L 20,13L 12,13 Z M 3,7.00001L 10,7.00001L 10,14L 3,14L 3,7.00001 Z M 4,8L 4,13L 9,13L 9,8L 4,8 Z M 3,16L 16,16L 16,17L 3,17L 3,16 Z M 3,20L 20,20L 20,21L 3,21L 3,20 Z "},
{PackIconMaterialLightKind.FormatFloatRight, "M 20,4L 20,5L 3,5L 3,4L 20,4 Z M 11,8.00001L 11,9.00001L 3,9.00001L 3,8.00001L 11,8.00001 Z M 3,12L 8,12L 8,13L 3,13L 3,12 Z M 3,16L 16,16L 16,17L 3,17L 3,16 Z M 3,20L 20,20L 20,21L 3,21L 3,20 Z M 20,7L 20,14L 13,14L 13,7L 20,7 Z M 19,8L 14,8L 14,13L 19,13L 19,8 Z "},
{PackIconMaterialLightKind.FormatIndentDecrease, "M 3,21L 3,20L 20,20L 20,21L 3,21 Z M 11,17L 11,16L 20,16L 20,17L 11,17 Z M 11,13L 11,12L 20,12L 20,13L 11,13 Z M 11,9L 11,8L 20,8L 20,9L 11,9 Z M 3,5L 3,4L 20,4L 20,5L 3,5 Z M 3,12.5L 8.5,18L 8.5,7.00001L 3,12.5 Z M 4.41421,12.5L 7.5,9.41423L 7.5,15.5858L 4.41421,12.5 Z "},
{PackIconMaterialLightKind.FormatIndentIncrease, "M 3,21L 3,20L 20,20L 20,21L 3,21 Z M 11,17L 11,16L 20,16L 20,17L 11,17 Z M 11,13L 11,12L 20,12L 20,13L 11,13 Z M 11,9L 11,8L 20,8L 20,9L 11,9 Z M 3,5L 3,4L 20,4L 20,5L 3,5 Z M 8.5,12.5L 3,18L 3,7.00001L 8.5,12.5 Z M 7.08578,12.5L 4,9.41423L 4,15.5858L 7.08578,12.5 Z "},
{PackIconMaterialLightKind.FormatItalic, "M 6,17L 6,16L 9,16L 13.0107,5L 10,5L 10,4L 17,4L 17,5L 14.0107,5L 10,16L 13,16L 13,17L 6,17 Z "},
{PackIconMaterialLightKind.FormatLineSpacing, "M 21,6L 21,7L 10,7L 10,6L 21,6 Z M 21,12L 21,13L 10,13L 10,12L 21,12 Z M 21,18L 21,19L 10,19L 10,18L 21,18 Z M 5,19.25L 7.25006,17L 8,17.6643L 4.5,21.1642L 1,17.6642L 1.75001,17L 4,19.25L 4,5.75001L 1.75001,8L 1,7.3358L 4.5,3.83579L 8,7.33574L 7.25005,8L 5,5.74999L 5,19.25 Z "},
{PackIconMaterialLightKind.FormatListBulleted, "M 20,18L 20,19L 7,19L 7,18L 20,18 Z M 3.5,17.5C 4.05228,17.5 4.5,17.9477 4.5,18.5C 4.5,19.0523 4.05228,19.5 3.5,19.5C 2.94771,19.5 2.5,19.0523 2.5,18.5C 2.5,17.9477 2.94771,17.5 3.5,17.5 Z M 20,12L 20,13L 7,13L 7,12L 20,12 Z M 3.5,11.5C 4.05229,11.5 4.5,11.9477 4.5,12.5C 4.5,13.0523 4.05229,13.5 3.5,13.5C 2.94772,13.5 2.5,13.0523 2.5,12.5C 2.5,11.9477 2.94772,11.5 3.5,11.5 Z M 20,6L 20,7L 7,7L 7,6L 20,6 Z M 3.5,5.5C 4.05228,5.5 4.5,5.94772 4.5,6.5C 4.5,7.05229 4.05228,7.5 3.5,7.5C 2.94771,7.5 2.5,7.05229 2.5,6.5C 2.5,5.94772 2.94771,5.5 3.5,5.5 Z "},
{PackIconMaterialLightKind.FormatListChecks, "M 20,18L 20,19L 7,19L 7,18L 20,18 Z M 20,12L 20,13L 7,13L 7,12L 20,12 Z M 20,6.00001L 20,7.00001L 7,7.00001L 7,6.00001L 20,6.00001 Z M 2,5L 5,5L 5,8L 2,8L 2,5 Z M 3,6.00001L 3,7.00001L 4,7.00001L 4,6.00001L 3,6.00001 Z M 2,11L 5,11L 5,14L 2,14L 2,11 Z M 3,12L 3,13L 4,13L 4,12L 3,12 Z M 2,17L 5,17L 5,20L 2,20L 2,17 Z M 3,18L 3,19L 4,19L 4,18L 3,18 Z "},
{PackIconMaterialLightKind.FormatListNumbers, "M 1.99938,10.9983L 1.99938,9.99829L 4.99938,9.99829L 4.99938,10.8983L 3.19938,12.9983L 4.99938,12.9983L 4.99938,13.9983L 1.99938,13.9983L 1.99938,13.0983L 3.79938,10.9983L 1.99938,10.9983 Z M 2.99938,7.99833L 2.99938,4.99833L 1.99938,4.99833L 1.99938,3.99833L 3.99938,3.99833L 3.99938,7.99833L 2.99938,7.99833 Z M 1.99938,16.9983L 1.99938,15.9983L 4.99938,15.9983L 4.99938,19.9983L 1.99938,19.9983L 1.99938,18.9983L 3.99938,18.9983L 3.99938,18.4983L 2.99938,18.4983L 2.99938,17.4983L 3.99938,17.4983L 3.99938,16.9983L 1.99938,16.9983 Z M 20,6L 20,7L 7,7L 7,6L 20,6 Z M 20,12L 20,13L 7,13L 7,12L 20,12 Z M 20,18L 20,19L 7,19L 7,18L 20,18 Z "},
{PackIconMaterialLightKind.FormatQuoteClose, "M 18,6L 18,14L 16.0491,18L 11.8487,18L 13.7996,14L 12,14L 12,6L 18,6 Z M 17,13.7691L 17,7.00001L 13,7.00001L 13,13L 15.3999,13L 13.449,17L 15.4242,17L 17,13.7691 Z M 11,6L 11,14L 9.04907,18L 4.84866,18L 6.79959,14L 5,14L 5,6L 11,6 Z M 10,13.7691L 9.99999,7.00001L 5.99999,7.00001L 5.99999,13L 8.39992,13L 6.449,17L 8.4242,17L 10,13.7691 Z "},
{PackIconMaterialLightKind.FormatQuoteOpen, "M 5,18L 5,10L 6.95093,6L 11.1513,6L 9.20041,10L 11,10L 11,18L 5,18 Z M 6,10.2309L 6.00001,17L 10,17L 10,11L 7.60008,11L 9.55101,7L 7.5758,7L 6,10.2309 Z M 12,18L 12,10L 13.9509,6L 18.1513,6L 16.2004,10L 18,10L 18,18L 12,18 Z M 13,10.2309L 13,17L 17,17L 17,11L 14.6001,11L 16.551,7L 14.5758,7L 13,10.2309 Z "},
{PackIconMaterialLightKind.FormatUnderline, "M 17,11.5C 17,14.5376 14.5376,17 11.5,17C 8.46244,17 6.00001,14.5376 6.00001,11.5L 6.00001,4.00001L 7,4.00001L 7,11.5C 7,13.9853 9.01472,16 11.5,16C 13.9853,16 16,13.9853 16,11.5L 16,4.00001L 17,4.00001L 17,11.5 Z M 5,21L 5,20L 18,20L 18,21L 5,21 Z "},
{PackIconMaterialLightKind.FormatWrapInline, "M 20,4L 20,5L 3,5L 3,4L 20,4 Z M 20,16L 20,17L 14,17L 14,16L 20,16 Z M 20,20L 20,21L 3,21L 3,20L 20,20 Z M 7.5,8.00001L 12,17L 3,17L 7.5,8.00001 Z M 7.49999,10.2412L 4.61598,16L 10.384,16L 7.49999,10.2412 Z "},
{PackIconMaterialLightKind.FormatWrapSquare, "M 11.5,8L 16,17L 7,17L 11.5,8 Z M 11.5,10.2412L 8.61598,16L 14.384,16L 11.5,10.2412 Z M 3,16L 5,16L 5,17L 3,17L 3,16 Z M 3,12L 5,12L 5,13L 3,13L 3,12 Z M 3,8.00001L 5,8.00001L 5,9.00001L 3,9.00001L 3,8.00001 Z M 18,8.00001L 20,8.00001L 20,9.00001L 18,9.00001L 18,8.00001 Z M 18,12L 20,12L 20,13L 18,13L 18,12 Z M 18,16L 20,16L 20,17L 18,17L 18,16 Z M 20,20L 20,21L 3,21L 3,20L 20,20 Z M 3,4L 20,4L 20,5L 3,5L 3,4 Z "},
{PackIconMaterialLightKind.FormatWrapTight, "M 11.5,8L 16,17L 7,17L 11.5,8 Z M 11.5,10.2412L 8.61597,16L 14.384,16L 11.5,10.2412 Z M 3,4.00001L 20,4.00001L 20,5.00001L 3,5.00001L 3,4.00001 Z M 14,8.00001L 20,8.00001L 20,9.00001L 14,9.00001L 14,8.00001 Z M 3,8.00001L 9,8.00001L 9,9.00001L 3,9.00001L 3,8.00001 Z M 3,12L 6.99999,12L 6.99999,13L 3,13L 3,12 Z M 3,16L 4.99999,16L 4.99999,17L 3,17L 3,16 Z M 18,16L 20,16L 20,17L 18,17L 18,16 Z M 16,12L 20,12L 20,13L 16,13L 16,12 Z M 3,20L 20,20L 20,21L 3,21L 3,20 Z "},
{PackIconMaterialLightKind.FormatWrapTopBottom, "M 11.5,8L 16,17L 7,17L 11.5,8 Z M 11.5,10.2412L 8.61598,16L 14.384,16L 11.5,10.2412 Z M 3,4L 20,4L 20,5L 3,5L 3,4 Z M 20,20L 20,21L 3,21L 3,20L 20,20 Z "},
{PackIconMaterialLightKind.Forum, "M 2.00001,16.5858L 5.58579,13L 15,13C 16.1046,13 17,12.1046 17,11L 17,6C 17,4.89543 16.1046,4 15,4L 4.00001,3.99999C 2.89544,3.99999 2.00001,4.89542 2.00001,5.99999L 2.00001,16.5858 Z M 2.00001,18L 1.00001,18L 1.00001,6C 1.00001,4.34315 2.34316,3 4.00001,3L 15,3.00001C 16.6569,3.00001 18,4.34315 18,6.00001L 18,11C 18,12.6569 16.6568,14 15,14L 6,14L 2.00001,18 Z M 21,20.5858L 21,10C 21,8.89542 20.1046,7.99999 19,7.99999L 19,7C 20.6568,7 22,8.34315 22,10L 22,22L 21,22L 17,18L 8.00002,18C 6.76027,18 5.69615,17.248 5.23896,16.1753L 6.03577,15.3784C 6.21265,16.3021 7.02482,17 8.00002,17L 17.4142,17L 21,20.5858 Z "},
{PackIconMaterialLightKind.Fullscreen, "M 5,4L 18,4C 19.6569,4 21,5.34315 21,7L 21,18C 21,19.6569 19.6569,21 18,21L 5,21C 3.34315,21 2,19.6569 2,18L 2,7C 2,5.34315 3.34315,4 5,4 Z M 5,5.00001C 3.89543,5.00001 3,5.89544 3,7.00001L 3,18C 3,19.1046 3.89543,20 5,20L 18,20C 19.1046,20 20,19.1046 20,18L 20,7.00001C 20,5.89544 19.1046,5.00001 18,5.00001L 5,5.00001 Z M 10,8L 17,8L 17,15L 16,15L 16,9.7071L 8.85355,16.8535L 8.14644,16.1464L 15.2929,9L 10,9L 10,8 Z "},
{PackIconMaterialLightKind.FullscreenClose, "M 18,21L 5,21C 3.34314,21 2,19.6569 2,18L 2,7.00001C 2,5.34315 3.34314,4.00001 5,4.00001L 18,4.00001C 19.6569,4.00001 21,5.34315 21,7.00001L 21,18C 21,19.6569 19.6569,21 18,21 Z M 18,20C 19.1046,20 20,19.1046 20,18L 20,7C 20,5.89543 19.1046,5 18,5L 5.00001,5C 3.89544,5 3.00001,5.89543 3.00001,7L 3.00001,18C 3.00001,19.1046 3.89544,20 5.00001,20L 18,20 Z M 13,17L 6.00001,17L 6.00001,10L 7,10L 7,15.2929L 14.1465,8.14645L 14.8536,8.85356L 7.70712,16L 13,16L 13,17 Z "},
{PackIconMaterialLightKind.Gift, "M 4,13L 4,21L 11,21L 11,13L 4,13 Z M 12,13L 12,21L 19,21L 19,13L 12,13 Z M 20,13L 20,22L 3,22L 3,13L 2,13L 2,7L 5.03544,7L 5,6.5C 5,4.56701 6.567,3.00001 8.5,3.00001C 9.77316,3.00001 10.8875,3.6798 11.5,4.69621C 12.1124,3.67979 13.2268,3 14.5,3C 16.433,3 18,4.567 18,6.5L 17.9646,7L 21,7L 21,13L 20,13 Z M 3,8L 3,12L 11,12L 11,8L 3,8 Z M 20,12L 20,8L 12,8L 12,12L 20,12 Z M 16.95,7L 17,6.5C 17,5.11929 15.8807,4.00001 14.5,4.00001C 13.1193,4.00001 12,5.1193 12,6.50001L 12,7L 16.95,7 Z M 11,7L 11,6.50001C 11,5.1193 9.88071,4.00001 8.5,4.00001C 7.11929,4.00001 6,5.1193 6,6.50001L 6.05,7L 11,7 Z "},
{PackIconMaterialLightKind.Grid, "M 5,3L 18,3C 19.6569,3 21,4.34315 21,6L 21,19C 21,20.6569 19.6569,22 18,22L 5,22C 3.34315,22 2,20.6569 2,19L 2,6C 2,4.34315 3.34315,3 5,3 Z M 5,4C 3.89543,4 3,4.89543 3,6L 3,9L 8,9L 8,4.00001L 5,4 Z M 3,19C 3,20.1046 3.89543,21 5,21L 8,21L 8,16L 3,16L 3,19 Z M 8,10L 3,10L 3,15L 8,15L 8,10 Z M 18,21C 19.1046,21 20,20.1046 20,19L 20,16L 15,16L 15,21L 18,21 Z M 20,10L 15,10L 15,15L 20,15L 20,10 Z M 20,6C 20,4.89543 19.1046,4 18,4L 15,4.00001L 15,9L 20,9L 20,6 Z M 9,4.00001L 9,9L 14,9L 14,4.00001L 9,4.00001 Z M 9,21L 14,21L 14,16L 9,16L 9,21 Z M 14,10L 9,10L 9,15L 14,15L 14,10 Z "},
{PackIconMaterialLightKind.GridLarge, "M 12,4L 12,12L 20,12L 20,6.00001C 20,4.89544 19.1046,4 18,4L 12,4 Z M 20,13L 12,13L 12,21L 18,21C 19.1046,21 20,20.1046 20,19L 20,13 Z M 11,21L 11,13L 3,13L 3,19C 3,20.1046 3.89543,21 5,21L 11,21 Z M 3,12L 11,12L 11,4L 5,4.00001C 3.89543,4.00001 3,4.89544 3,6.00001L 3,12 Z M 5,3L 18,3C 19.6569,3 21,4.34315 21,6L 21,19C 21,20.6569 19.6569,22 18,22L 5,22C 3.34314,22 2,20.6569 2,19L 2,6C 2,4.34315 3.34314,3 5,3 Z "},
{PackIconMaterialLightKind.GridOff, "M 0.792892,2.45713L 1.5,1.75004L 22.25,22.5L 21.5429,23.2071L 19.7632,21.4274C 19.2683,21.7876 18.6589,22 18,22L 5,22C 3.34314,22 2,20.6569 2,19L 2,6C 2,5.34107 2.21244,4.73175 2.57257,4.23681L 0.792892,2.45713 Z M 5,3L 18,3C 19.6569,3 21,4.34315 21,6L 21,19L 20.9073,19.7431L 20,18.8358L 20,16L 17.1642,16L 16.1642,15L 20,15L 20,10L 15,10L 15,13.8358L 14,12.8358L 14,10L 11.1642,10L 10.1642,9.00001L 14,9.00001L 14,4.00001L 9,4.00001L 9,7.83578L 7.99999,6.83578L 7.99999,4.00001L 5.16422,4L 4.25695,3.09274L 5,3 Z M 3,6.00001L 3,9.00001L 7.33577,9.00001L 3.29301,4.95725C 3.10714,5.26087 3,5.61793 3,6.00001 Z M 8.99999,15L 13.3358,15L 8.99999,10.6642L 8.99999,15 Z M 15,21L 18,21C 18.3821,21 18.7391,20.8929 19.0428,20.707L 15,16.6642L 15,21 Z M 3,19C 3,20.1046 3.89543,21 5,21L 7.99999,21L 7.99999,16L 3,16L 3,19 Z M 7.99999,10L 3,10L 3,15L 7.99999,15L 7.99999,10 Z M 20,6.00001C 20,4.89544 19.1046,4 18,4L 15,4.00001L 15,9.00001L 20,9.00001L 20,6.00001 Z M 8.99999,21L 14,21L 14,16L 8.99999,16L 8.99999,21 Z "},
{PackIconMaterialLightKind.Group, "M 7,8L 7,13L 13,13L 13,8L 7,8 Z M 2,3.00002L 5,3.00002L 5,4.00001L 18,4.00002L 18,3.00002L 21,3.00002L 21,6.00002L 20,6.00002L 20,19L 21,19L 21,22L 18,22L 18,21L 5,21L 5,22L 2,22L 2,19L 3,19L 3,6.00001L 2,6.00001L 2,3.00002 Z M 5,19L 5,20L 18,20L 18,19L 19,19L 19,6.00003L 18,6.00003L 18,5.00003L 4.99999,5.00002L 4.99999,6.00002L 4,6.00002L 4,19L 5,19 Z M 6,7.00001L 14,7.00001L 14,11L 17,11L 17,18L 7.99999,18L 7.99999,14L 5.99999,14L 6,7.00001 Z M 14,14L 8.99999,14L 9,17L 16,17L 16,12L 14,12L 14,14 Z M 3,4.00001L 3,5.00001L 4,5.00001L 4,4.00001L 3,4.00001 Z M 19,4L 19,5L 20,5L 20,4L 19,4 Z M 19,20L 19,21L 20,21L 20,20L 19,20 Z M 3,20L 3,21L 4,21L 4,20L 3,20 Z "},
{PackIconMaterialLightKind.Hamburger, "M 6.99999,3.99999L 16,3.99999C 18.7614,3.99999 21,6.23857 21,8.99999L 2,8.99999C 2,6.23857 4.23857,3.99999 6.99999,3.99999 Z M 16,5.00001L 7,5.00001C 5.13616,5.00001 3.57006,6.27478 3.12602,8L 19.874,8C 19.4299,6.27478 17.8638,5.00001 16,5.00001 Z M 21,16C 21,18.7614 18.7614,21 16,21L 6.99999,21C 4.23857,21 1.99999,18.7614 1.99999,16L 21,16 Z M 7,20L 16,20C 17.8638,20 19.4299,18.7252 19.874,17L 3.12602,17C 3.57006,18.7252 5.13616,20 7,20 Z M 12.5,10L 14.5,12L 16.5,10L 19,10C 20.1046,10 21,10.8954 21,12L 21,13C 21,14.1046 20.1046,15 19,15L 4,15C 2.89543,15 2,14.1046 2,13L 2,12C 2,10.8954 2.89543,10 4,10L 12.5,10 Z M 14.5,13.4142L 12.0858,11L 4,11C 3.44771,11 3,11.4477 3,12L 3,13C 3,13.5523 3.44771,14 4,14L 19,14C 19.5523,14 20,13.5523 20,13L 20,12C 20,11.4477 19.5523,11 19,11L 16.9142,11L 14.5,13.4142 Z "},
{PackIconMaterialLightKind.Heart, "M 4.2439,12.2525C 3.47495,11.4845 3,10.4227 3,9.25001C 3,6.9028 4.90279,5.00001 7.25,5.00001C 8.82976,5.00001 10.2082,5.86193 10.9407,7.14116L 12.0593,7.14116C 12.7918,5.86193 14.1702,5.00001 15.75,5.00001C 18.0972,5.00001 20,6.9028 20,9.25001C 20,10.4227 19.525,11.4845 18.7561,12.2525L 11.5,19.5086L 4.2439,12.2525 Z M 19.4623,12.9623C 20.4124,12.0122 21,10.6997 21,9.25C 21,6.35051 18.6495,4 15.75,4C 14.0024,4 12.4543,4.85386 11.5,6.16716C 10.5457,4.85386 8.99758,4 7.25,4C 4.3505,4 2,6.35051 2,9.25C 2,10.6997 2.58763,12.0122 3.53769,12.9623L 11.5,20.9233L 19.4623,12.9623 Z "},
{PackIconMaterialLightKind.HeartHalf, "M 4.2439,12.2525L 11.5,19.5086L 11.5,20.9233L 3.53769,12.9623C 2.58763,12.0122 2,10.6997 2,9.25C 2,6.35051 4.3505,4 7.25,4C 8.99758,4 10.5457,4.85386 11.5,6.16716L 11.5,7.14116L 10.9407,7.14116C 10.2082,5.86193 8.82976,5.00001 7.25,5.00001C 4.90279,5.00001 3,6.9028 3,9.25001C 3,10.4227 3.47495,11.4845 4.2439,12.2525 Z "},
{PackIconMaterialLightKind.HeartOff, "M 1.7929,3.45712L 2.5,2.75001L 19.25,19.5L 18.5429,20.2071L 15.3799,17.0441L 11.5,20.9233L 3.53769,12.9623C 2.58763,12.0122 2,10.6997 2,9.25C 2,7.71483 2.65892,6.33356 3.70936,5.37357L 1.7929,3.45712 Z M 4.2439,12.2525L 11.5,19.5086L 14.6722,16.3364L 4.41736,6.08157C 3.54748,6.85979 3,7.99096 3,9.25001C 3,10.4227 3.47495,11.4845 4.2439,12.2525 Z M 18.7561,12.2525C 19.525,11.4845 20,10.4227 20,9.25001C 20,6.9028 18.0972,5.00001 15.75,5.00001C 14.1702,5.00001 12.7918,5.86193 12.0593,7.14116L 10.9407,7.14116C 10.2082,5.86193 8.82975,5.00001 7.25,5.00001L 6.27629,5.11207L 5.47269,4.30848C 6.02775,4.10881 6.62617,4.00001 7.25,4.00001C 8.99757,4.00001 10.5457,4.85387 11.5,6.16716C 12.4543,4.85387 14.0024,4.00001 15.75,4.00001C 18.6495,4.00001 21,6.35051 21,9.25C 21,10.6997 20.4124,12.0122 19.4623,12.9623L 16.7942,15.63L 16.0864,14.9222L 18.7561,12.2525 Z "},
{PackIconMaterialLightKind.Help, "M 11,22L 11,20L 12,20L 12,22L 11,22 Z M 11,17.5C 11,13 16,11.5 16,8.50001C 16,6.01473 13.9853,4 11.5,4C 9.18372,4 7.27619,5.75003 7.02746,8L 6.02242,8C 6.27503,5.19675 8.63098,3 11.5,3C 14.5376,3 17,5.46243 17,8.5C 17,12 12,13 12,17.5L 12,18L 11,18L 11,17.5 Z "},
{PackIconMaterialLightKind.HelpCircle, "M 11.5,4C 6.806,4 3,7.806 3,12.5C 3,17.194 6.806,21 11.5,21C 16.194,21 20,17.194 20,12.5C 20,7.806 16.194,4 11.5,4 Z M 11.5,3C 16.747,3 21,7.253 21,12.5C 21,17.747 16.747,22 11.5,22C 6.253,22 2,17.747 2,12.5C 2,7.253 6.253,3 11.5,3 Z M 11,17L 12,17L 12,19L 11,19L 11,17 Z M 11.5,6C 13.433,6 15,7.567 15,9.5C 15,10.397 14.301,11.019 13.561,11.676L 12.626,12.579C 12.038,13.253 11.974,14.534 11.999,14.971L 11.999,15L 11,15C 10.996,14.948 10.898,13.036 11.874,11.921L 12.896,10.929C 13.488,10.403 14,9.948 14,9.5C 14,8.119 12.881,7 11.5,7C 10.119,7 9,8.119 9,9.5L 8,9.5C 8,7.567 9.567,6 11.5,6 Z "},
{PackIconMaterialLightKind.Home, "M 16,8.41421L 11.5,3.91421L 4.41421,11L 6,11L 6,12L 6,19L 9,19L 9,13L 14,13L 14,19L 17,19L 17,11L 18.5858,11L 17,9.41421L 17,6.00001L 16,6.00001L 16,8.41421 Z M 2,12L 11.5,2.50001L 15,6L 15,5L 18,5L 18,9L 21,12L 18,12L 17.9993,19.9983L 12.9993,19.9983L 12.9993,13.9983L 9.99939,13.998L 9.99939,19.998L 4.99939,19.998L 4.99939,12L 2,12 Z "},
{PackIconMaterialLightKind.Inbox, "M 6,4L 17,4C 18.6569,4 20,5.34315 20,7L 20,18C 20,19.6569 18.6569,21 17,21L 6,21C 4.34314,21 3,19.6569 3,18L 3,7C 3,5.34315 4.34314,4 6,4 Z M 6,5C 4.89543,5 4,5.89543 4,7L 4,15L 9,15L 9,15.5C 9,16.8807 10.1193,18 11.5,18C 12.8807,18 14,16.8807 14,15.5L 14,15L 19,15L 19,7C 19,5.89543 18.1046,5 17,5L 6,5 Z M 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,16L 14.9646,16C 14.7219,17.6961 13.2632,19 11.5,19C 9.73676,19 8.27806,17.6961 8.03544,16L 4,16L 4,18 Z "},
{PackIconMaterialLightKind.Information, "M 11.5,3C 16.7467,3 21,7.25329 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5C 2,7.25329 6.25329,3 11.5,3 Z M 11.5,4C 6.80557,4 3,7.80558 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80558 16.1944,4 11.5,4 Z M 11,8.00001L 11,10L 12,10L 12,8.00001L 11,8.00001 Z M 11,12L 11,17L 12,17L 12,12L 11,12 Z "},
{PackIconMaterialLightKind.Label, "M 6,6L 14,6C 14.971,6 15.8343,6.46133 16.3826,7.17676L 20.5416,12.5L 16.3824,17.8234C 15.8341,18.5388 14.9709,19 14,19L 6,19C 4.34314,19 3,17.6569 3,16L 3,9C 3,7.34315 4.34314,6 6,6 Z M 15.5777,17.2292L 19.2725,12.5L 15.5777,7.77081L 15.576,7.76869C 15.21,7.30078 14.6401,7.00001 14,7.00001L 6,7.00001C 4.89543,7.00001 4,7.89544 4,9.00001L 4,16C 4,17.1046 4.89543,18 6,18L 14,18C 14.6401,18 15.2099,17.6992 15.576,17.2313L 15.5777,17.2292 Z "},
{PackIconMaterialLightKind.Layers, "M 2.69918,11.0204L 11.3673,4.2481L 20.3008,11.2277L 11.6327,18L 2.69918,11.0204 Z M 18.7007,11.2089L 11.3914,5.49827L 4.32346,11.0204L 11.6327,16.731L 18.7007,11.2089 Z M 11.6327,21L 2.69921,14.0204L 3.48723,13.4047L 11.6086,19.7498L 19.4887,13.5932L 20.3008,14.2277L 11.6327,21 Z "},
{PackIconMaterialLightKind.Lightbulb, "M 14,20C 14,21.1046 13.1046,22 12,22L 11,22C 9.89543,22 9,21.1046 9,20L 10,20C 10,20.5523 10.4477,21 11,21L 12,21C 12.5523,21 13,20.5523 13,20L 14,20 Z M 15,17C 15,18.1046 14.1046,19 13,19L 10,19C 8.89543,19 8,18.1046 8,17L 8,14.9782C 6.19584,13.8231 5,11.8012 5,9.5C 5,5.91015 7.91015,3 11.5,3C 15.0898,3 18,5.91015 18,9.5C 18,11.8012 16.8041,13.8231 15,14.9782L 15,17 Z M 9,17C 9,17.5523 9.44771,18 10,18L 13,18C 13.5523,18 14,17.5523 14,17L 14,14.4003C 15.7808,13.4899 17,11.6373 17,9.5C 17,6.46244 14.5376,4 11.5,4C 8.46243,4 6,6.46244 6,9.5C 6,11.6373 7.21916,13.4899 9,14.4003L 9,17 Z "},
{PackIconMaterialLightKind.LightbulbOn, "M 14,20C 14,21.1046 13.1046,22 12,22L 11,22C 9.89543,22 9,21.1046 9,20L 10,20C 10,20.5523 10.4477,21 11,21L 12,21C 12.5523,21 13,20.5523 13,20L 14,20 Z M 15,17C 15,18.1046 14.1046,19 13,19L 10,19C 8.89543,19 7.99999,18.1046 7.99999,17L 7.99999,14.9782C 6.19584,13.8231 5,11.8012 5,9.5C 5,5.91015 7.91015,3.00001 11.5,3.00001C 15.0898,3.00001 18,5.91016 18,9.5C 18,11.8012 16.8041,13.8231 15,14.9782L 15,17 Z M 8.99999,17C 8.99999,17.5523 9.44771,18 9.99999,18L 13,18C 13.5523,18 14,17.5523 14,17L 14,14.4003C 15.7808,13.4899 17,11.6373 17,9.50001C 17,6.46244 14.5376,4.00001 11.5,4.00001C 8.46243,4.00001 6,6.46244 6,9.50001C 6,11.6374 7.21916,13.4899 9,14.4003L 8.99999,17 Z M 8.12867,10.1213L 10.5,7.75001L 12.5,9.75L 14.25,8L 14.9571,8.70711L 12.5,11.1642L 10.5,9.16422L 8.83578,10.8284L 8.12867,10.1213 Z "},
{PackIconMaterialLightKind.Link, "M 7.99999,13L 7.99999,12L 15,12L 15,13L 7.99999,13 Z M 15.5,7C 18.5376,7 21,9.46244 21,12.5C 21,15.5376 18.5376,18 15.5,18L 13,18L 13,17L 15.5,17C 17.9853,17 20,14.9853 20,12.5C 20,10.0147 17.9853,8 15.5,8L 13,8.00001L 13,7.00001L 15.5,7 Z M 7.5,18C 4.46243,18 2,15.5376 2,12.5C 2,9.46244 4.46243,7.00001 7.5,7.00001L 9.99999,7.00001L 9.99999,8.00001L 7.5,8.00001C 5.01472,8.00001 3,10.0147 3,12.5C 3,14.9853 5.01472,17 7.5,17L 9.99999,17L 9.99999,18L 7.5,18 Z "},
{PackIconMaterialLightKind.LinkVariant, "M 10.7279,14.965C 10.9782,15.0817 11.0865,15.3792 10.9698,15.6294C 10.8531,15.8797 10.5556,15.988 10.3053,15.8713L 10.3048,15.8724C 9.84155,15.6564 9.40749,15.3572 9.02513,14.9749C 7.26777,13.2175 7.26777,10.3683 9.02513,8.61092L 12.5607,5.07538C 14.318,3.31802 17.1673,3.31802 18.9246,5.07538C 20.682,6.83274 20.682,9.68198 18.9246,11.4393L 17.2915,13.0725L 17.1414,11.8083L 18.2175,10.7322C 19.5843,9.3654 19.5843,7.14932 18.2175,5.78249C 16.8507,4.41565 14.6346,4.41565 13.2678,5.78249L 9.73223,9.31803C 8.3654,10.6849 8.3654,12.9009 9.73223,14.2678C 10.0296,14.5652 10.3672,14.7979 10.7275,14.9658L 10.7279,14.965 Z M 4.07539,19.9246C 2.31803,18.1673 2.31803,15.318 4.07539,13.5607L 5.70851,11.9275L 5.85859,13.1917L 4.78249,14.2678C 3.41566,15.6346 3.41566,17.8507 4.78249,19.2175C 6.14933,20.5843 8.3654,20.5843 9.73224,19.2175L 13.2678,15.682C 14.6346,14.3151 14.6346,12.0991 13.2678,10.7322C 12.9704,10.4348 12.6328,10.2021 12.2725,10.0342L 12.2721,10.035C 12.0218,9.91832 11.9135,9.62084 12.0302,9.37056C 12.1469,9.1203 12.4444,9.01202 12.6947,9.12872L 12.6952,9.12761C 13.1585,9.34359 13.5925,9.64276 13.9749,10.0251C 15.7322,11.7825 15.7322,14.6317 13.9749,16.3891L 10.4393,19.9246C 8.68199,21.682 5.83275,21.682 4.07539,19.9246 Z "},
{PackIconMaterialLightKind.Lock, "M 16,8.00001C 17.6568,8.00001 19,9.34316 19,11L 19,19C 19,20.6569 17.6568,22 16,22L 7,22C 5.34314,22 4,20.6569 4,19L 4,11C 4,9.34316 5.34314,8.00001 7,8.00001L 7,6.50001C 7,4.01473 9.01471,2.00002 11.5,2.00002C 13.9853,2.00002 16,4.01473 16,6.50001L 16,8.00001 Z M 7,9.00001C 5.89543,9.00001 5,9.89544 5,11L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,11C 18,9.89544 17.1046,9.00001 16,9.00001L 7,9.00001 Z M 15,8L 15,6.5C 15,4.56701 13.433,3.00001 11.5,3.00001C 9.567,3.00001 8,4.56701 8,6.5L 8,8L 15,8 Z M 11.5,14C 10.6716,14 10,14.6716 10,15.5C 10,16.3284 10.6716,17 11.5,17C 12.3284,17 13,16.3284 13,15.5C 13,14.6716 12.3284,14 11.5,14 Z M 11.5,13C 12.8807,13 14,14.1193 14,15.5C 14,16.8807 12.8807,18 11.5,18C 10.1193,18 9,16.8807 9,15.5C 9,14.1193 10.1193,13 11.5,13 Z "},
{PackIconMaterialLightKind.LockUnlocked, "M 16,8.00001C 17.6568,8.00001 19,9.34316 19,11L 19,19C 19,20.6569 17.6568,22 16,22L 7,22C 5.34314,22 4,20.6569 4,19L 4,11C 4,9.34316 5.34314,8.00001 7,8.00001L 15,8L 15,6.50001C 15,4.56701 13.433,3.00001 11.5,3.00001C 9.73676,3.00001 8.27806,4.30386 8.03544,6L 7.02746,6C 7.27619,3.75003 9.18372,2.00002 11.5,2.00002C 13.9853,2.00002 16,4.01473 16,6.50001L 16,8.00001 Z M 7,9.00001C 5.89543,9.00001 5,9.89544 5,11L 5,19C 5,20.1046 5.89543,21 7,21L 16,21C 17.1046,21 18,20.1046 18,19L 18,11C 18,9.89544 17.1046,9.00001 16,9.00001L 7,9.00001 Z M 11.5,14C 10.6716,14 10,14.6716 10,15.5C 10,16.3284 10.6716,17 11.5,17C 12.3284,17 13,16.3284 13,15.5C 13,14.6716 12.3284,14 11.5,14 Z M 11.5,13C 12.8807,13 14,14.1193 14,15.5C 14,16.8807 12.8807,18 11.5,18C 10.1193,18 9,16.8807 9,15.5C 9,14.1193 10.1193,13 11.5,13 Z "},
{PackIconMaterialLightKind.Login, "M 15,3L 9,3C 7.34315,3 6,4.34315 6,6L 6,10L 7,10L 7,6C 7,4.89543 7.89543,4 9,4L 15,4C 16.1046,4 17,4.89543 17,6L 17,19C 17,20.1046 16.1046,21 15,21L 9,21C 7.89543,21 7,20.1046 7,19L 7,15L 6,15L 6,19C 6,20.6569 7.34315,22 9,22L 15,22C 16.6569,22 18,20.6569 18,19L 18,6C 18,4.34315 16.6569,3 15,3 Z M 3,12L 13.25,12L 10,8.74995L 10.6643,8L 15.1642,12.5L 10.6642,17L 10,16.25L 13.25,13L 3,13L 3,12 Z "},
{PackIconMaterialLightKind.Logout, "M 5,3L 11,3C 12.6569,3 14,4.34315 14,6L 14,10L 13,10L 13,6C 13,4.89543 12.1046,4 11,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,19C 3,20.1046 3.89543,21 5,21L 11,21C 12.1046,21 13,20.1046 13,19L 13,15L 14,15L 14,19C 14,20.6569 12.6569,22 11,22L 5,22C 3.34315,22 2,20.6569 2,19L 2,6C 2,4.34315 3.34315,3 5,3 Z M 8,12L 19.25,12L 16,8.74995L 16.6643,8L 21.1642,12.5L 16.6642,17L 16,16.25L 19.25,13L 8,13L 8,12 Z "},
{PackIconMaterialLightKind.Magnify, "M 9.5,4C 13.0899,4 16,6.91015 16,10.5C 16,12.1172 15.4094,13.5965 14.4321,14.7339L 20.0764,20.3782L 19.3693,21.0853L 13.7243,15.4403C 12.5882,16.4127 11.1127,17 9.5,17C 5.91015,17 3,14.0899 3,10.5C 3,6.91015 5.91015,4 9.5,4 Z M 9.5,5C 6.46243,5 4,7.46243 4,10.5C 4,13.5376 6.46243,16 9.5,16C 12.5376,16 15,13.5376 15,10.5C 15,7.46243 12.5376,5 9.5,5 Z "},
{PackIconMaterialLightKind.MagnifyMinus, "M 9.5,4C 13.0899,4 16,6.91015 16,10.5C 16,12.1172 15.4094,13.5965 14.4321,14.7339L 20.0764,20.3782L 19.3693,21.0853L 13.7243,15.4403C 12.5882,16.4127 11.1127,17 9.5,17C 5.91015,17 3,14.0899 3,10.5C 3,6.91015 5.91015,4 9.5,4 Z M 9.5,5.00001C 6.46243,5.00001 4,7.46244 4,10.5C 4,13.5376 6.46243,16 9.5,16C 12.5376,16 15,13.5376 15,10.5C 15,7.46244 12.5376,5.00001 9.5,5.00001 Z M 7,10L 12,10L 12,11L 7,11L 7,10 Z "},
{PackIconMaterialLightKind.MagnifyPlus, "M 9.5,4C 13.0899,4 16,6.91015 16,10.5C 16,12.1172 15.4094,13.5965 14.4321,14.7339L 20.0764,20.3782L 19.3693,21.0853L 13.7243,15.4403C 12.5882,16.4127 11.1127,17 9.5,17C 5.91015,17 3,14.0899 3,10.5C 3,6.91015 5.91015,4 9.5,4 Z M 9.5,5.00001C 6.46243,5.00001 4,7.46244 4,10.5C 4,13.5376 6.46243,16 9.5,16C 12.5376,16 15,13.5376 15,10.5C 15,7.46244 12.5376,5.00001 9.5,5.00001 Z M 7,10L 9,10L 9,8L 10,8L 10,10L 12,10L 12,11L 10,11L 10,13L 9,13L 9,11L 7,11L 7,10 Z "},
{PackIconMaterialLightKind.MapMarker, "M 11.5,7C 12.8807,7 14,8.11929 14,9.5C 14,10.8807 12.8807,12 11.5,12C 10.1193,12 9,10.8807 9,9.5C 9,8.11929 10.1193,7 11.5,7 Z M 11.5,8C 10.6716,8 10,8.67158 10,9.5C 10,10.3284 10.6716,11 11.5,11C 12.3284,11 13,10.3284 13,9.5C 13,8.67158 12.3284,8 11.5,8 Z M 6.80047,12.3574L 11.5,20.0867L 16.1995,12.3574L 16.2002,12.3578C 16.7077,11.5249 17,10.5466 17,9.5C 17,6.46244 14.5376,4 11.5,4C 8.46243,4 6,6.46244 6,9.5C 6,10.5466 6.29233,11.5249 6.7998,12.3578L 6.80047,12.3574 Z M 17.054,12.8769L 11.5,22.0116L 5.94601,12.8769L 5.94522,12.8774C 5.34548,11.8931 5,10.7369 5,9.50001C 5,5.91016 7.91015,3.00001 11.5,3.00001C 15.0898,3.00001 18,5.91016 18,9.50001C 18,10.7369 17.6545,11.8931 17.0548,12.8774L 17.054,12.8769 Z "},
{PackIconMaterialLightKind.Memory, "M 8,19C 6.34314,19 5,17.6569 5,16L 5,15L 3,15L 3,14L 5,14L 5,11L 3,11L 3,10L 5,10L 5,9C 5,7.34315 6.34314,6 8,6L 9,6L 9,4L 10,4L 10,6L 13,6L 13,4L 14,4L 14,6L 15,6C 16.6569,6 18,7.34315 18,9L 18,10L 20,10L 20,11L 18,11L 18,14L 20,14L 20,15L 18,15L 18,16C 18,17.6569 16.6569,19 15,19L 14,19L 14,21L 13,21L 13,19L 10,19L 10,21L 9,21L 9,19L 8,19 Z M 7.99999,7.00002C 6.89542,7.00002 5.99999,7.89544 5.99999,9.00002L 5.99999,16C 5.99999,17.1046 6.89542,18 7.99999,18L 15,18C 16.1046,18 17,17.1046 17,16L 17,9.00002C 17,7.89544 16.1046,7.00002 15,7.00002L 7.99999,7.00002 Z M 8.99999,15L 8.99999,10L 14,10L 14,15L 8.99999,15 Z M 9.99999,11L 9.99999,14L 13,14L 13,11L 9.99999,11 Z "},
{PackIconMaterialLightKind.Menu, "M 3,8L 3,7L 20,7L 20,8L 3,8 Z M 20,12L 20,13L 3,13L 3,12L 20,12 Z M 3,17L 20,17L 20,18L 3,18L 3,17 Z "},
{PackIconMaterialLightKind.Message, "M 3,20.5858L 6.58578,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,6C 20,4.89543 19.1046,4 18,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,20.5858 Z M 3,22L 2,22L 2,6C 2,4.34315 3.34315,3 5,3L 18,3C 19.6569,3 21,4.34315 21,6L 21,15C 21,16.6569 19.6569,18 18,18L 7,18L 3,22 Z "},
{PackIconMaterialLightKind.MessageAlert, "M 3,20.5858L 6.58578,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,6C 20,4.89543 19.1046,4 18,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,20.5858 Z M 3,22L 2,22L 2,6.00001C 2,4.34316 3.34314,3.00001 5,3.00001L 18,3.00001C 19.6568,3.00001 21,4.34316 21,6.00001L 21,15C 21,16.6569 19.6568,18 18,18L 6.99999,18L 3,22 Z M 11,6L 12,6L 12,11L 11,11L 11,6 Z M 12,15L 11,15L 11,13L 12,13L 12,15 Z "},
{PackIconMaterialLightKind.MessagePhoto, "M 3,20.5858L 6.58578,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,14.9142L 14.7929,9.70711L 9.79289,14.7071L 7.29289,12.2071L 3,16.5L 3,20.5858 Z M 20,6C 20,4.89543 19.1046,4 18,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,15.0858L 7.29289,10.7929L 9.79289,13.2929L 14.7929,8.29291L 20,13.5L 20,6 Z M 3,22L 2,22L 2,6.00002C 2,4.34316 3.34314,3.00002 5,3.00002L 18,3.00002C 19.6568,3.00002 21,4.34316 21,6.00002L 21,15C 21,16.6569 19.6568,18 18,18L 6.99999,18L 3,22 Z M 9,6C 10.1046,6 11,6.89543 11,8C 11,9.10457 10.1046,10 9,10C 7.89543,10 7,9.10457 7,8C 7,6.89543 7.89543,6 9,6 Z M 9,7C 8.44771,7 8,7.44772 8,8C 8,8.55229 8.44771,9 9,9C 9.55228,9 10,8.55229 10,8C 10,7.44772 9.55228,7 9,7 Z "},
{PackIconMaterialLightKind.MessageProcessing, "M 3,20.5858L 6.58578,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,6C 20,4.89543 19.1046,4 18,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,20.5858 Z M 3,22L 2,22L 2,6.00001C 2,4.34315 3.34314,3.00001 5,3.00001L 18,3.00001C 19.6568,3.00001 21,4.34315 21,6.00001L 21,15C 21,16.6569 19.6568,18 18,18L 7,18L 3,22 Z M 6.5,9C 7.32842,9 8,9.67158 8,10.5C 8,11.3284 7.32842,12 6.5,12C 5.67157,12 5,11.3284 5,10.5C 5,9.67158 5.67157,9 6.5,9 Z M 6.5,10C 6.22385,10 6,10.2239 6,10.5C 6,10.7761 6.22385,11 6.5,11C 6.77614,11 7,10.7761 7,10.5C 7,10.2239 6.77614,10 6.5,10 Z M 11.5,9C 12.3284,9 13,9.67158 13,10.5C 13,11.3284 12.3284,12 11.5,12C 10.6716,12 10,11.3284 10,10.5C 10,9.67158 10.6716,9 11.5,9 Z M 11.5,10C 11.2239,10 11,10.2239 11,10.5C 11,10.7761 11.2239,11 11.5,11C 11.7761,11 12,10.7761 12,10.5C 12,10.2239 11.7761,10 11.5,10 Z M 16.5,9C 17.3284,9 18,9.67157 18,10.5C 18,11.3284 17.3284,12 16.5,12C 15.6716,12 15,11.3284 15,10.5C 15,9.67157 15.6716,9 16.5,9 Z M 16.5,10C 16.2239,10 16,10.2239 16,10.5C 16,10.7761 16.2239,11 16.5,11C 16.7761,11 17,10.7761 17,10.5C 17,10.2239 16.7761,10 16.5,10 Z "},
{PackIconMaterialLightKind.MessageReply, "M 20,20.5858L 16.4142,17L 4.99999,17C 3.89542,17 2.99999,16.1046 2.99999,15L 2.99999,6C 2.99999,4.89543 3.89542,4 4.99999,4L 18,4C 19.1046,4 20,4.89543 20,6L 20,20.5858 Z M 20,22L 21,22L 21,6.00001C 21,4.34315 19.6568,3.00001 18,3.00001L 5,3.00001C 3.34314,3.00001 2,4.34315 2,6.00001L 2,15C 2,16.6569 3.34314,18 5,18L 16,18L 20,22 Z "},
{PackIconMaterialLightKind.MessageText, "M 3,20.5858L 6.58578,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,6C 20,4.89543 19.1046,4 18,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,20.5858 Z M 3,22L 2,22L 2,6.00001C 2,4.34315 3.34314,3.00001 5,3.00001L 18,3.00001C 19.6568,3.00001 21,4.34315 21,6.00001L 21,15C 21,16.6569 19.6568,18 18,18L 7,18L 3,22 Z M 6,7L 17,7L 17,8L 6,8L 6,7 Z M 6,10L 17,10L 17,11L 6,11L 6,10 Z M 6,13L 14,13L 14,14L 6,14L 6,13 Z "},
{PackIconMaterialLightKind.MessageVideo, "M 3,20.5858L 6.58578,17L 18,17C 19.1046,17 20,16.1046 20,15L 20,6C 20,4.89543 19.1046,4 18,4L 5,4C 3.89543,4 3,4.89543 3,6L 3,20.5858 Z M 3,22L 2,22L 2,6.00001C 2,4.34315 3.34314,3.00001 5,3.00001L 18,3.00001C 19.6568,3.00001 21,4.34315 21,6.00001L 21,15C 21,16.6569 19.6568,18 18,18L 6.99999,18L 3,22 Z M 17,7L 17,14L 16,14L 14,12L 14,14L 6,14L 6,7L 14,7L 14,9L 16,7L 17,7 Z M 14,10.4142L 14,10.5858L 16,12.5858L 16,8.41422L 14,10.4142 Z M 7,8.00001L 7,13L 13,13L 13,8.00001L 7,8.00001 Z "},
{PackIconMaterialLightKind.Microphone, "M 11,21L 11,17.9811C 7.64377,17.7258 4.99999,14.9216 4.99999,11.5L 4.99999,11L 6,11L 6,11.5C 6,14.5376 8.46243,17 11.5,17C 14.5376,17 17,14.5376 17,11.5L 17,11L 18,11L 18,11.5C 18,14.9216 15.3562,17.7257 12,17.9811L 12,21L 11,21 Z M 11.5,3.00002C 12.8807,3.00002 14,4.1193 14,5.50002L 14,11.5C 14,12.8807 12.8807,14 11.5,14C 10.1193,14 9,12.8807 9,11.5L 8.99999,5.50002C 8.99999,4.1193 10.1193,3.00002 11.5,3.00002 Z M 11.5,4.00002C 10.6716,4.00002 10,4.67159 10,5.50002L 10,11.5C 10,12.3284 10.6716,13 11.5,13C 12.3284,13 13,12.3284 13,11.5L 13,5.50002C 13,4.67159 12.3284,4.00002 11.5,4.00002 Z "},
{PackIconMaterialLightKind.MicrophoneOff, "M 2.79289,4.45711L 3.5,3.75L 15.2621,15.5121L 15.9695,16.2195L 20.25,20.5L 19.5429,21.2071L 15.1886,16.8528C 14.2693,17.4874 13.1786,17.8914 12,17.9811L 12,21L 11,21L 11,17.9811C 7.64378,17.7258 4.99999,14.9216 4.99999,11.5L 4.99999,11L 6,11L 6,11.5C 6,14.5376 8.46243,17 11.5,17C 12.5929,17 13.6113,16.6812 14.4674,16.1316L 12.2281,13.8923C 11.9977,13.9623 11.7533,14 11.5,14C 10.1193,14 9,12.8807 9,11.5L 8.99999,10.6642L 2.79289,4.45711 Z M 17,11.5L 17,11L 18,11L 18,11.5C 18,12.9982 17.4931,14.378 16.6415,15.4773L 15.9276,14.7634C 16.6016,13.8505 17,12.7218 17,11.5 Z M 11.5,3.00002C 12.8807,3.00002 14,4.11931 14,5.50002L 14,11.5C 14,11.8898 13.9108,12.2587 13.7517,12.5875L 12.969,11.8048L 13,11.5L 13,5.50002C 13,4.67159 12.3284,4.00002 11.5,4.00002C 10.6716,4.00002 9.99999,4.67159 9.99999,5.50002L 10,8.83578L 8.99999,7.83578L 8.99999,5.50002C 8.99999,4.11931 10.1193,3.00002 11.5,3.00002 Z M 10.01,11.6742C 10.0897,12.3634 10.6366,12.9103 11.3258,12.99L 10.01,11.6742 Z "},
{PackIconMaterialLightKind.Minus, "M 5,13.0008L 5,12L 18.01,12L 18,13L 5,13.0008 Z "},
{PackIconMaterialLightKind.MinusBox, "M 7,12L 16,12L 16,13L 7,13L 7,12 Z M 6,4L 17,4C 18.6569,4 20,5.34315 20,7L 20,18C 20,19.6569 18.6569,21 17,21L 6,21C 4.34315,21 3,19.6569 3,18L 3,7C 3,5.34315 4.34315,4 6,4 Z M 6,5C 4.89543,5 4,5.89543 4,7L 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,7C 19,5.89543 18.1046,5 17,5L 6,5 Z "},
{PackIconMaterialLightKind.MinusCircle, "M 7,12L 16,12L 16,13L 7,13L 7,12 Z M 11.5,3C 16.7467,3 21,7.2533 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5C 2,7.2533 6.25329,3 11.5,3 Z M 11.5,4.00001C 6.80558,4.00001 3,7.80559 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80559 16.1944,4.00001 11.5,4.00001 Z "},
{PackIconMaterialLightKind.Monitor, "M 5,4L 18,4C 19.6569,4 21,5.34315 21,7L 21,14C 21,15.6569 19.6569,17 18,17L 13.4917,17L 14,20L 15,20L 15,21L 8,21L 8,20L 9,20L 9.50825,17L 5,17C 3.34315,17 2,15.6569 2,14L 2,7C 2,5.34315 3.34315,4 5,4 Z M 10.5083,17L 10,20L 13,20L 12.4917,17L 10.5083,17 Z M 5,5.00001C 3.89543,5.00001 3,5.89544 3,7.00001L 3,14C 3,15.1046 3.89543,16 5,16L 18,16C 19.1046,16 20,15.1046 20,14L 20,7.00001C 20,5.89544 19.1046,5.00001 18,5.00001L 5,5.00001 Z "},
{PackIconMaterialLightKind.MonitorMultiple, "M 6,5L 19,5C 20.6569,5 22,6.34315 22,8L 22,15C 22,16.6569 20.6569,18 19,18L 14.4917,18L 15,21L 16,21L 16,22L 9,22L 9,21L 10,21L 10.5083,18L 6,18C 4.34315,18 3,16.6569 3,15L 3,8C 3,6.34315 4.34315,5 6,5 Z M 11.5083,18L 11,21L 14,21L 13.4917,18L 11.5083,18 Z M 6,6.00001C 4.89543,6.00001 4,6.89544 4,8.00001L 4,15C 4,16.1046 4.89543,17 6,17L 19,17C 20.1046,17 21,16.1046 21,15L 21,8.00001C 21,6.89544 20.1046,6.00001 19,6.00001L 6,6.00001 Z M 1.00001,8.00001C 1.00001,5.23859 3.23859,3.00001 6.00001,3.00001L 18,3L 18,4.00001L 6.00002,4.00003C 3.79089,4.00003 2.00002,5.79089 2.00002,8.00003L 2.00001,14L 1,14L 1.00001,8.00001 Z "},
{PackIconMaterialLightKind.Music, "M 7.99999,6.10434L 19,4.98701L 19,16C 19,17.6568 17.6569,19 16,19C 14.3431,19 13,17.6568 13,16C 13,14.3431 14.3431,13 16,13C 16.7684,13 17.4692,13.2888 18,13.7639L 18,9.04362L 9,10.0372L 9,17C 9,18.6569 7.65685,20 6,20C 4.34315,20 3,18.6569 3,17C 3,15.3431 4.34315,14 6,14C 6.76835,14 7.46924,14.2889 8,14.7639L 7.99999,6.10434 Z M 9,7.00791L 9,9.03115L 18,8.03754L 18,6.09373L 9,7.00791 Z M 8,17C 8,15.8954 7.10457,15 6,15C 4.89543,15 4,15.8954 4,17C 4,18.1046 4.89543,19 6,19C 7.10457,19 8,18.1046 8,17 Z M 18,16C 18,14.8954 17.1046,14 16,14C 14.8954,14 14,14.8954 14,16C 14,17.1046 14.8954,18 16,18C 17.1046,18 18,17.1046 18,16 Z "},
{PackIconMaterialLightKind.MusicOff, "M 2.79289,4.45711L 3.5,3.75L 20.25,20.5L 19.5429,21.2071L 17.1198,18.784C 16.7738,18.9233 16.3959,19 16,19C 14.3431,19 13,17.6568 13,16C 13,15.6041 13.0767,15.2262 13.216,14.8802L 9,10.6642L 9,17C 9,18.6569 7.65685,20 6,20C 4.34315,20 3,18.6569 3,17C 3,15.3432 4.34315,14 6,14C 6.76835,14 7.46924,14.2888 8,14.7639L 8,9.66421L 2.79289,4.45711 Z M 7.99999,6.10434L 19,4.98701L 19,16C 19,16.5292 18.8629,17.0265 18.6224,17.4582L 17.8714,16.7072C 17.9545,16.4873 18,16.249 18,16C 18,14.8954 17.1046,14 16,14C 15.751,14 15.5127,14.0455 15.2928,14.1286L 14.5418,13.3776C 14.9735,13.137 15.4707,13 16,13C 16.7684,13 17.4692,13.2888 18,13.7639L 18,9.04362L 10.9826,9.81835L 10.0765,8.91231L 18,8.03755L 18,6.09373L 9,7.00792L 9,7.83578L 7.99999,6.83578L 7.99999,6.10434 Z M 14,16C 14,17.1046 14.8954,18 16,18C 16.106,18 16.2101,17.9917 16.3116,17.9759L 14.0241,15.6883C 14.0082,15.7899 14,15.894 14,16 Z M 8,17C 7.99999,15.8954 7.10457,15 5.99999,15C 4.89543,15 4,15.8954 4,17C 4,18.1046 4.89543,19 5.99999,19C 7.10456,19 8,18.1046 8,17 Z "},
{PackIconMaterialLightKind.Nfc, "M 5,3L 18,3C 19.6569,3 21,4.34315 21,6L 21,19C 21,20.6569 19.6569,22 18,22L 5,22C 3.34315,22 2,20.6569 2,19L 2,6C 2,4.34315 3.34315,3 5,3 Z M 5,4C 3.89543,4 3,4.89543 3,6L 3,19C 3,20.1046 3.89543,21 5,21L 18,21C 19.1046,21 20,20.1046 20,19L 20,6C 20,4.89543 19.1046,4 18,4L 5,4 Z M 13,12.5C 13,13.3284 12.3284,14 11.5,14C 10.6716,14 10,13.3284 10,12.5C 10,11.8469 10.4174,11.2913 11,11.0854L 11,8.00001C 11,7.44773 11.4477,7.00001 12,7.00001L 16,7.00002C 16.5523,7.00002 17,7.44773 17,8.00002L 17,17C 17,17.5523 16.5523,18 16,18L 6.99999,18C 6.44771,18 5.99999,17.5523 5.99999,17L 5.99999,8.00002C 5.99999,7.44773 6.44771,7.00002 6.99999,7.00002L 9,7.00002L 9,8.00001L 7,8.00001L 7,17L 16,17L 16,8.00001L 12,8L 12,11.0854C 12.5826,11.2913 13,11.8469 13,12.5 Z M 11.5,12C 11.2239,12 11,12.2239 11,12.5C 11,12.7761 11.2239,13 11.5,13C 11.7761,13 12,12.7761 12,12.5C 12,12.2239 11.7761,12 11.5,12 Z "},
{PackIconMaterialLightKind.Note, "M 16,12C 14.3431,12 13,10.6569 13,9.00002L 13,5.00003L 4.99999,5.00002C 3.89542,5.00002 2.99999,5.89545 2.99999,7.00002L 2.99999,18C 2.99999,19.1046 3.89542,20 4.99999,20L 18,20C 19.1045,20 20,19.1046 20,18L 20,12L 16,12 Z M 14,9.00002C 14,10.1046 14.8954,11 16,11L 19.5858,11L 14,5.41422L 14,9.00002 Z M 4.99999,4.00002L 14,4.00002L 21,11L 21,18C 21,19.6569 19.6568,21 18,21L 4.99999,21C 3.34314,21 2,19.6569 2,18L 2,7.00002C 2,5.34316 3.34314,4.00002 4.99999,4.00002 Z "},
{PackIconMaterialLightKind.NoteMultiple, "M 17,12C 15.3431,12 14,10.6569 14,9.00002L 14,5.00003L 5.99999,5.00002C 4.89542,5.00002 3.99999,5.89545 3.99999,7.00002L 3.99999,18C 3.99999,19.1046 4.89542,20 5.99999,20L 19,20C 20.1045,20 21,19.1046 21,18L 21,12L 17,12 Z M 15,9.00002C 15,10.1046 15.8954,11 17,11L 20.5858,11L 15,5.41422L 15,9.00002 Z M 5.99999,4.00002L 15,4.00002L 22,11L 22,18C 22,19.6569 20.6568,21 19,21L 5.99999,21C 4.34314,21 3,19.6569 3,18L 3,7.00002C 3,5.34316 4.34314,4.00002 5.99999,4.00002 Z M 6.00001,23C 3.23859,23 1.00001,20.7614 1.00001,18L 1,8L 2.00001,8L 2.00002,18C 2.00002,20.2091 3.79088,22 6.00002,22L 18,22L 18,23L 6.00001,23 Z "},
{PackIconMaterialLightKind.NotePlus, "M 16,12C 14.3431,12 13,10.6569 13,9.00002L 13,5.00003L 4.99999,5.00002C 3.89542,5.00002 2.99999,5.89545 2.99999,7.00002L 2.99999,18C 2.99999,19.1046 3.89542,20 4.99999,20L 18,20C 19.1045,20 20,19.1046 20,18L 20,12L 16,12 Z M 14,9.00002C 14,10.1046 14.8954,11 16,11L 19.5858,11L 14,5.41422L 14,9.00002 Z M 4.99999,4.00002L 14,4.00002L 21,11L 21,18C 21,19.6569 19.6568,21 18,21L 4.99999,21C 3.34314,21 2,19.6569 2,18L 2,7.00002C 2,5.34316 3.34314,4.00002 4.99999,4.00002 Z M 7,18L 7,16L 5,16L 5,15L 7,15L 7,13L 8,13L 8,15L 10,15L 10,16L 8,16L 8,18L 7,18 Z "},
{PackIconMaterialLightKind.NoteText, "M 16,12C 14.3431,12 13,10.6569 13,9.00002L 13,5.00003L 4.99999,5.00002C 3.89542,5.00002 2.99999,5.89545 2.99999,7.00002L 2.99999,18C 2.99999,19.1046 3.89542,20 4.99999,20L 18,20C 19.1045,20 20,19.1046 20,18L 20,12L 16,12 Z M 14,9.00002C 14,10.1046 14.8954,11 16,11L 19.5858,11L 14,5.41422L 14,9.00002 Z M 4.99999,4.00002L 14,4.00003L 21,11L 21,18C 21,19.6569 19.6568,21 18,21L 4.99999,21C 3.34314,21 2,19.6569 2,18L 2,7.00002C 2,5.34317 3.34314,4.00002 4.99999,4.00002 Z M 5,8.00001L 11,8.00001L 11,9.00001L 5,9.00001L 5,8.00001 Z M 5,12L 11,12L 11,13L 5,13L 5,12 Z M 5,16L 18,16L 18,17L 5,17L 5,16 Z "},
{PackIconMaterialLightKind.Paperclip, "M 17,7.00001L 17,17.5C 17,20.54 14.54,23 11.5,23C 8.46,23 6,20.54 6,17.5L 6,6.00001C 6,3.79001 7.79,2.00001 10,2.00001C 12.21,2.00001 14,3.79001 14,6.00001L 14,16.5C 14,17.88 12.88,19 11.5,19C 10.12,19 9,17.88 9,16.5L 9,7.00001L 9.99999,7.00001L 9.99999,16.5C 9.99999,17.3284 10.6716,18 11.5,18C 12.3284,18 13,17.3284 13,16.5L 13,7.14847L 13,7.00001L 13,6.00001C 13,4.34315 11.6568,3.00001 9.99999,3.00001C 8.34314,3.00001 7,4.34315 7,6.00001L 7,16.4447L 7,17.5C 7,19.9853 9.01472,22 11.5,22C 13.9853,22 16,19.9853 16,17.5L 16,7.00001L 17,7.00001 Z "},
{PackIconMaterialLightKind.Pause, "M 13,19L 13,5.99999L 17,5.99999L 17,19L 13,19 Z M 6,19L 6,6L 10,6L 10,19L 6,19 Z M 6.99999,7.00001L 7,18L 9,18L 9,7.00001L 6.99999,7.00001 Z M 14,7.00001L 14,18L 16,18L 16,7.00001L 14,7.00001 Z "},
{PackIconMaterialLightKind.Pencil, "M 19.7059,8.04158L 17.3739,10.3735L 13.6239,6.62354L 15.9559,4.29159C 16.3469,3.90051 16.9799,3.90051 17.3699,4.29159L 19.7059,6.62756C 20.0969,7.0175 20.0969,7.65051 19.7059,8.04158 Z M 2.99917,17.248L 13.0637,7.18392L 16.8137,10.9339L 6.74916,20.998L 2.99917,20.998L 2.99917,17.248 Z M 16.6207,5.04355L 15.0817,6.58253L 17.4175,8.91828L 18.9565,7.37929L 16.6207,5.04355 Z M 15.3572,10.9786L 13.0215,8.64282L 4,17.6642L 4,20L 6.33578,20L 15.3572,10.9786 Z "},
{PackIconMaterialLightKind.Phone, "M 19.5,22C 20.3271,22 21,21.3271 21,20.5L 21,17C 21,16.1729 20.3271,15.5 19.5,15.5C 18.3301,15.5 17.1807,15.3164 16.0801,14.9531C 15.5488,14.7822 14.9668,14.9219 14.5566,15.3164L 13.1172,16.7559C 10.6357,15.4121 8.5654,13.3428 7.23191,10.8726L 8.66062,9.43649C 9.07282,9.0542 9.22071,8.47311 9.0449,7.9136C 8.6836,6.81878 8.5,5.67041 8.5,4.5C 8.5,3.67291 7.82709,3 7.00001,3L 3.50001,3C 2.67292,3 2.00001,3.67291 2.00001,4.5C 2.00001,14.1494 9.85059,22 19.5,22 Z M 3.50001,4L 7.00001,4C 7.27592,4 7.50001,4.22409 7.50001,4.5C 7.50001,5.77731 7.7002,7.03131 8.0933,8.22021C 8.1377,8.36178 8.13129,8.5635 7.96631,8.71728L 6.0098,10.6826C 7.64652,13.9111 10.0654,16.3291 13.3076,17.9795L 15.2568,16.0303C 15.3975,15.8945 15.5938,15.8477 15.7725,15.9043C 16.9688,16.2998 18.2227,16.5 19.5,16.5C 19.7754,16.5 20,16.7246 20,17L 20,20.5C 20,20.7754 19.7754,21 19.5,21C 10.4019,21 3.00001,13.5977 3.00001,4.5C 3.00001,4.22409 3.2241,4 3.50001,4 Z "},
{PackIconMaterialLightKind.Picture, "M 5,3L 18,3C 19.6569,3 21,4.34315 21,6L 21,19C 21,20.6569 19.6569,22 18,22L 5,22C 3.34315,22 2,20.6569 2,19L 2,6C 2,4.34315 3.34315,3 5,3 Z M 5,4.00001C 3.89543,4.00001 3,4.89544 3,6.00001L 3,17.5858L 7.29289,13.2929L 9.79289,15.7929L 14.7929,10.7929L 20,16L 20,6.00001C 20,4.89544 19.1046,4.00001 18,4.00001L 5,4.00001 Z M 9.79289,17.2071L 7.29289,14.7071L 3,19C 3,20.1046 3.89543,21 5,21L 18,21C 19.1046,21 20,20.1046 20,19L 20,17.4142L 14.7929,12.2071L 9.79289,17.2071 Z M 7.5,6.00001C 8.88071,6.00001 10,7.1193 10,8.50001C 10,9.88072 8.88071,11 7.5,11C 6.11928,11 5,9.88072 5,8.50001C 5,7.1193 6.11928,6.00001 7.5,6.00001 Z M 7.5,7.00001C 6.67157,7.00001 6,7.67159 6,8.50001C 6,9.32843 6.67157,10 7.5,10C 8.32842,10 9,9.32843 9,8.50001C 9,7.67159 8.32842,7.00001 7.5,7.00001 Z "},
{PackIconMaterialLightKind.Pin, "M 14.0006,12.4148L 14.0001,5L 15,5L 15,4L 8,4L 8,5L 9.00007,5L 9.00057,12.4136L 7,14.4142L 7,15L 16,15L 16,14.4142L 14.0006,12.4148 Z M 16.9991,13.9981L 16.9991,13.9991L 17,14L 16.9991,14.0009L 16.9991,15.9981L 12,16L 11.9999,20.5L 11.4999,22L 10.9999,20.5L 11,16L 5.99939,15.9981L 5.99939,13.9981L 6.00193,13.9981L 7.99991,12.0001L 7.99926,5.99811L 6.99926,5.99811L 6.99927,2.9981L 15.9989,2.99813L 15.9989,5.99814L 14.9991,5.99814L 14.9998,11.9998L 16.9981,13.9981L 16.9991,13.9981 Z "},
{PackIconMaterialLightKind.PinOff, "M 2.79289,4.45711L 3.5,3.75L 20.25,20.5L 19.5429,21.2071L 14.3349,15.9991L 12,16L 11.9999,20.5L 11.4999,22L 10.9999,20.5L 11,16L 5.99939,15.9981L 5.99939,13.9981L 6.00193,13.9981L 7.9999,12.0001L 7.99965,9.66387L 2.79289,4.45711 Z M 14.0006,12.4148L 14.0001,5L 15,5L 15,4L 8,4L 8,5L 9.00007,5L 9.00026,7.83604L 7.99935,6.83514L 7.99926,5.99811L 7.16232,5.99811L 6.99926,5.83505L 6.99926,2.9981L 15.9989,2.99813L 15.9989,5.99814L 14.9991,5.99814L 14.9998,11.9998L 16.9981,13.9981L 16.9991,13.9981L 16.9991,13.9991L 17,14L 16.9991,14.0009L 16.9991,15.8349L 16,14.8358L 16,14.4142L 14.0006,12.4148 Z M 9.00057,12.4136L 7,14.4142L 7,15L 13.3358,15L 9.00045,10.6647L 9.00057,12.4136 Z "},
{PackIconMaterialLightKind.Play, "M 18.4022,12.5L 9,18.3751L 8,19L 8,6L 18.4022,12.5 Z M 16.5151,12.5L 9,7.80405L 9,17.196L 16.5151,12.5 Z "},
{PackIconMaterialLightKind.Plus, "M 5,13L 5,12L 11,12L 11,6L 12,6L 12,12L 18,12L 18,13L 12,13L 12,19L 11,19L 11,13L 5,13 Z "},
{PackIconMaterialLightKind.PlusBox, "M 7,12L 11,12L 11,8L 12,8L 12,12L 16,12L 16,13L 12,13L 12,17L 11,17L 11,13L 7,13L 7,12 Z M 6,4L 17,4C 18.6569,4 20,5.34315 20,7L 20,18C 20,19.6569 18.6569,21 17,21L 6,21C 4.34315,21 3,19.6569 3,18L 3,7C 3,5.34315 4.34315,4 6,4 Z M 6,5C 4.89543,5 4,5.89543 4,7L 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,7C 19,5.89543 18.1046,5 17,5L 6,5 Z "},
{PackIconMaterialLightKind.PlusCircle, "M 7,12L 11,12L 11,8L 12,8L 12,12L 16,12L 16,13L 12,13L 12,17L 11,17L 11,13L 7,13L 7,12 Z M 11.5,3C 16.7467,3 21,7.2533 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5C 2,7.2533 6.25329,3 11.5,3 Z M 11.5,4.00001C 6.80558,4.00001 3,7.80559 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80559 16.1944,4.00001 11.5,4.00001 Z "},
{PackIconMaterialLightKind.Power, "M 11,13L 11,4L 12,4L 12,13L 11,13 Z M 19,12.5C 19,16.6421 15.6421,20 11.5,20C 7.35786,20 4,16.6421 4,12.5C 4,9.78828 5.43915,7.41269 7.59533,6.09533L 8.32619,6.82619C 6.3414,7.93883 5,10.0628 5,12.5C 5,16.0899 7.91015,19 11.5,19C 15.0898,19 18,16.0899 18,12.5C 18,10.0628 16.6586,7.93883 14.6738,6.82619L 15.4047,6.09534C 17.5609,7.41269 19,9.78828 19,12.5 Z "},
{PackIconMaterialLightKind.Presentation, "M 2,4L 10,4C 10,3.44772 10.4477,3 11,3L 12,3C 12.5523,3 13,3.44772 13,4L 21,4L 21,5L 20,5L 20,16L 14.2679,16L 15.8756,22L 14.8404,22L 13.2327,16L 9.76733,16L 8.15963,22L 7.12436,22L 8.73205,16L 3,16L 3,5L 2,5L 2,4 Z M 19,15L 19,5.00001L 4,5.00001L 4,15L 19,15 Z "},
{PackIconMaterialLightKind.PresentationPlay, "M 2,4L 10,4C 10,3.44772 10.4477,3 11,3L 12,3C 12.5523,3 13,3.44772 13,4L 21,4L 21,5L 20,5L 20,16L 14.2679,16L 15.8756,22L 14.8404,22L 13.2327,16L 9.76733,16L 8.15963,22L 7.12436,22L 8.73205,16L 3,16L 3,5L 2,5L 2,4 Z M 19,15L 19,5.00001L 4,5.00001L 4,15L 19,15 Z M 10,7L 11,7L 14,10L 11,13L 10,13L 10,7 Z M 11,8.41422L 11,11.5858L 12.5858,10L 11,8.41422 Z "},
{PackIconMaterialLightKind.Printer, "M 16.9994,3.99819L 16.9994,8.99818L 17.9994,8.99819C 19.6564,8.99819 20.9994,10.3412 20.9994,11.9982L 20.9994,16.9981L 16.9994,16.9981L 16.9994,20.9981L 5.99939,20.9981L 5.99939,16.9981L 1.99939,16.9981L 1.99939,11.9981C 1.99939,10.3421 3.34339,8.99813 4.99939,8.99813L 5.99939,8.99813L 5.99939,3.99813L 16.9994,3.99819 Z M 17.9994,12.9982C 17.4464,12.9982 16.9994,12.5512 16.9994,11.9982C 16.9994,11.4452 17.4464,10.9982 17.9994,10.9982C 18.5524,10.9982 18.9994,11.4452 18.9994,11.9982C 18.9994,12.5512 18.5524,12.9982 17.9994,12.9982 Z M 3,12L 3,16L 6,16L 6,14L 17,14L 17,16L 20,16L 20,12C 20,10.8954 19.1046,10 18,10L 5,10C 3.89543,10 3,10.8954 3,12 Z M 16,20L 16,15L 7,15L 7,20L 16,20 Z M 7,5L 7,9L 16,9L 16,5L 7,5 Z "},
{PackIconMaterialLightKind.RedoVariant, "M 17,20L 17,19L 16,19L 16,20L 17,20 Z M 10,8.00002C 6.6863,8.00002 4.00001,10.6863 4.00001,14C 4.00001,17.3137 6.6863,20 10,20L 14,20L 14,19L 10,19C 7.23858,19 5,16.7614 5,14C 5,11.2386 7.23858,9.00001 10,9.00001L 17.0858,9L 14.0503,12.0355L 14.7574,12.7426L 19,8.5L 14.7574,4.25735L 14.0503,4.96447L 17.0858,8L 10,8.00002 Z "},
{PackIconMaterialLightKind.Refresh, "M 4.99577,4.99984L 9.99577,4.99984L 9.99577,10.0002L 8.99577,10.0002L 8.99577,6.49284C 6.64941,7.47363 5.00033,9.79069 5.00033,12.4928C 5.00033,16.0827 7.91048,18.9928 11.5003,18.9928C 15.0902,18.9928 18.0003,16.0827 18.0003,12.4928C 18.0003,9.41764 15.8646,6.84131 12.9958,6.16569L 12.9958,5.14193C 16.4212,5.83512 19.0003,8.86279 19.0003,12.4928C 19.0003,16.6349 15.6426,19.9928 11.5003,19.9928C 7.35807,19.9928 4.00033,16.6349 4.00033,12.4928C 4.00033,9.7194 5.50586,7.29753 7.74414,5.99984L 4.99577,5.99984L 4.99577,4.99984 Z "},
{PackIconMaterialLightKind.Repeat, "M 20,7.50001L 16.4645,11.0355L 15.7574,10.3284L 18.0858,8.00001L 5.99999,8.00002L 5.99999,12L 5,12L 5,7.00002L 18.0858,7.00001L 15.7574,4.67158L 16.4645,3.96447L 20,7.50001 Z M 17,17L 17,13L 18,13L 18,18L 4.91421,18L 7.24263,20.3284L 6.53552,21.0355L 2.99999,17.5L 6.53553,13.9645L 7.24264,14.6716L 4.91421,17L 17,17 Z "},
{PackIconMaterialLightKind.RepeatOff, "M 2.79289,4.45711L 3.5,3.75L 20.25,20.5L 19.5429,21.2071L 16.3358,18L 4.91421,18L 7.24263,20.3284L 6.53552,21.0355L 2.99999,17.5L 6.53553,13.9645L 7.24264,14.6716L 4.91421,17L 15.3358,17L 6.33581,8.00002L 5.99999,8.00002L 5.99999,12L 4.99999,12L 5,7.00002L 5.33581,7.00002L 2.79289,4.45711 Z M 20,7.50001L 16.4645,11.0355L 15.7574,10.3284L 18.0858,8.00001L 9.16423,8.00002L 8.16423,7.00002L 18.0858,7.00002L 15.7574,4.67158L 16.4645,3.96447L 20,7.50001 Z M 17,13L 18,13L 18,16.8358L 17,15.8358L 17,13 Z "},
{PackIconMaterialLightKind.RepeatOnce, "M 20,7.50001L 16.4645,11.0355L 15.7574,10.3284L 18.0858,8.00001L 5.99999,8.00002L 5.99999,12L 5,12L 5,7.00002L 18.0858,7.00001L 15.7574,4.67158L 16.4645,3.96447L 20,7.50001 Z M 17,17L 17,13L 18,13L 18,18L 4.91421,18L 7.24263,20.3284L 6.53552,21.0355L 2.99999,17.5L 6.53553,13.9645L 7.24264,14.6716L 4.91421,17L 17,17 Z M 10,14L 11,14L 11,11L 10,11L 10,10L 12,10L 12,14L 13,14L 13,15L 10,15L 10,14 Z "},
{PackIconMaterialLightKind.Rewind, "M 0.999996,12.5L 10.4022,18.3751L 11.4022,19L 11.4022,13.3762L 19.4022,18.3751L 20.4022,19L 20.4022,6L 11.4022,11.6238L 11.4022,6L 0.999996,12.5 Z M 2.88708,12.5L 10.4022,7.80406L 10.4022,17.196L 2.88708,12.5 Z M 11.8871,12.5L 19.4022,7.80406L 19.4022,17.196L 11.8871,12.5 Z "},
{PackIconMaterialLightKind.Rss, "M 5,16C 6.65685,16 8,17.3431 8,19C 8,20.6569 6.65685,22 5,22C 3.34315,22 2,20.6569 2,19C 2,17.3431 3.34315,16 5,16 Z M 5,17C 3.89543,17 3,17.8954 3,19C 3,20.1046 3.89543,21 5,21C 6.10456,21 6.99999,20.1046 6.99999,19C 6.99999,17.8954 6.10456,17 5,17 Z M 2,11C 8.07513,11 13,15.9249 13,22L 12,22C 12,16.4772 7.52284,12 2,12L 2,11 Z M 2,7.00001C 10.2843,7.00001 17,13.7157 17,22L 16,22C 16,14.268 9.73198,8.00001 2,8.00001L 2,7.00001 Z M 2,3C 12.4934,3 21,11.5066 21,22L 20,22C 20,12.0589 11.9411,4.00001 2,4.00001L 2,3 Z "},
{PackIconMaterialLightKind.Script, "M 3,19C 3,20.1046 3.89543,21 5,21L 11.7639,21C 11.2889,20.4692 11,19.7684 11,19L 3,19 Z M 14,21C 15.1046,21 16,20.1046 16,19L 16,6C 16,5.23165 16.2889,4.53076 16.7639,4L 7.99999,4.00002C 6.89542,4.00002 5.99999,4.89545 5.99999,6.00002L 6,18L 12,18L 12,19C 12,20.1046 12.8954,21 14,21 Z M 5,6.00001C 5,4.34316 6.34318,3.00002 8.00004,3.00002L 19,3.00004C 20.6569,3.00006 22,4.34319 22,6.00002L 22,8L 17,8L 17,19C 17,20.6569 15.6568,22 14,22L 5,22C 3.34314,22 2,20.6569 2,19L 2,18L 5,18L 5,6.00001 Z M 21,7.00002L 21,6.00002C 21,4.89546 20.1045,4.00002 19,4.00002C 17.8954,4.00003 17,4.89545 17,6.00001L 17,7.00001L 21,7.00002 Z "},
{PackIconMaterialLightKind.SeekNext, "M 15.4022,12.5L 5,6L 5,19L 6,18.3751L 15.4022,12.5 Z M 13.5151,12.5L 6,17.196L 6,7.80406L 13.5151,12.5 Z M 18,6L 17,6L 17,19L 18,19L 18,6 Z "},
{PackIconMaterialLightKind.SeekPrevious, "M 7.59783,12.5L 18,6L 18,19L 17,18.3751L 7.59783,12.5 Z M 9.48491,12.5L 17,17.196L 17,7.80405L 9.48491,12.5 Z M 5,6L 6,6L 6,19L 5,19L 5,6 Z "},
{PackIconMaterialLightKind.ShapeCircle, "M 11.5,3C 16.7467,3 21,7.2533 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5C 2,7.2533 6.25329,3 11.5,3 Z M 11.5,4C 6.80558,4 3,7.80558 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80558 16.1944,4 11.5,4 Z "},
{PackIconMaterialLightKind.ShapeHexagon, "M 6.59253,21L 1.68844,12.5059L 6.59931,4L 16.4075,4L 21.315,12.5L 16.4075,21L 6.59253,21 Z M 15.8301,5L 7.17666,5L 2.84314,12.5059L 7.16987,20L 15.8301,20L 20.1603,12.5L 15.8301,5 Z "},
{PackIconMaterialLightKind.ShapeOctagon, "M 3,16.0112L 3,8.97919L 7.97919,4L 15.0208,4L 20,8.97918L 20,16.0255L 15.0255,21L 7.98881,21L 3,16.0112 Z M 8.39339,5.00002L 3.99999,9.39342L 3.99999,15.597L 8.40301,20L 14.6113,20L 19,15.6113L 19,9.3934L 14.6066,5.00002L 8.39339,5.00002 Z "},
{PackIconMaterialLightKind.ShapeRhombus, "M 2.58579,12.5L 11.5,3.58578L 20.4142,12.5L 11.5,21.4142L 2.58579,12.5 Z M 11.5,4.99999L 4,12.5L 11.5,20L 19,12.5L 11.5,4.99999 Z "},
{PackIconMaterialLightKind.ShapeSquare, "M 3,4L 20,4L 20,21L 3,21L 3,4 Z M 4,5L 4,20L 19,20L 19,5L 4,5 Z "},
{PackIconMaterialLightKind.ShapeTriangle, "M 1,21L 11.5,2.81347L 22,21L 1,21 Z M 20.2679,20L 11.5,4.81347L 2.73205,20L 20.2679,20 Z "},
{PackIconMaterialLightKind.Shield, "M 11.5,3.10793L 19.0001,6.63096L 18.9996,11.6444C 18.9996,16.4531 15.7837,20.8959 11.5,22.0358C 7.21625,20.8969 4.00044,16.4531 4.00044,11.6444L 3.99994,6.63096M 11.5,23.0688C 16.3977,21.8418 19.9995,16.9441 19.9995,11.6444L 20,6L 11.5,2L 3,6L 3.0005,11.6444C 3.0005,16.9441 6.60229,21.8418 11.5,23.0688 Z "},
{PackIconMaterialLightKind.Shuffle, "M 13,5L 19,5L 19,11L 18,11L 18,6.70711L 4.71141,19.9957L 4.0043,19.2886L 17.2929,6L 13,6L 13,5 Z M 13,19L 17.2929,19L 12.7071,14.4142L 13.4142,13.7071L 18,18.2929L 18,14L 19,14L 19,20L 13,20L 13,19 Z M 4.00432,5.71143L 4.71143,5.00432L 10.2929,10.5858L 9.58579,11.2929L 4.00432,5.71143 Z "},
{PackIconMaterialLightKind.Signal, "M 2,21L 2,16L 6,16L 6,21L 2,21 Z M 3,17L 3,20L 5,20L 5,17L 3,17 Z M 7,21L 7,12L 11,12L 11,21L 7,21 Z M 8,13L 8,20L 10,20L 10,13L 8,13 Z M 12,21L 12,8L 16,8L 16,21L 12,21 Z M 13,9L 13,20L 15,20L 15,9L 13,9 Z M 17,21L 17,4L 21,4L 21,21L 17,21 Z M 18,5L 18,20L 20,20L 20,5L 18,5 Z "},
{PackIconMaterialLightKind.Sitemap, "M 9,3L 14,3L 14,8L 12,8L 12,12L 17,12C 18.6569,12 20,13.3431 20,15L 20,17L 22,17L 22,22L 17,22L 17,17L 19,17L 19,15C 19,13.8954 18.1046,13 17,13L 12,13L 12,17L 14,17L 14,22L 9,22L 9,17L 11,17L 11,13L 6,13C 4.89543,13 4,13.8954 4,15L 4,17L 6,17L 6,22L 1,22L 1,17L 3,17L 3,15C 3,13.3431 4.34315,12 6,12L 11,12L 11,8L 9,8L 9,3 Z M 13,7.00001L 13,4.00001L 10,4.00001L 10,7.00001L 13,7.00001 Z M 5,21L 5,18L 2,18L 2,21L 5,21 Z M 13,21L 13,18L 10,18L 10,21L 13,21 Z M 21,21L 21,18L 18,18L 18,21L 21,21 Z "},
{PackIconMaterialLightKind.Sleep, "M 2,13L 7,13L 7,14L 3.25953,19L 7,19L 7,20L 2,20L 2,19L 5.75001,14L 2,14L 2,13 Z M 9,9L 14,9L 14,10L 10.2595,15L 14,15L 14,16L 9,16L 9,15L 12.75,10L 9,10L 9,9 Z M 16,5L 21,5L 21,6.00001L 17.2595,11L 21,11L 21,12L 16,12L 16,11L 19.75,6L 16,6L 16,5 Z "},
{PackIconMaterialLightKind.SleepOff, "M 2.79289,4.45711L 3.5,3.75L 20.25,20.5L 19.5429,21.2071L 14,15.6642L 14,16L 8.99999,16L 8.99999,15L 10.8582,12.5224L 2.79289,4.45711 Z M 2,13L 7,13L 7,14L 3.25953,19L 7,19L 7,20L 2,20L 2,19L 5.75001,14L 2,14L 2,13 Z M 14,9.00001L 14,10L 12.7864,11.6222L 12.0704,10.9062L 12.75,10L 11.1642,10L 10.1642,9.00001L 14,9.00001 Z M 10.2595,15L 13.3358,15L 11.576,13.2402L 10.2595,15 Z M 16,5.00001L 21,5.00001L 21,6.00001L 17.2595,11L 21,11L 21,12L 16,12L 16,11L 19.75,6.00001L 16,6.00001L 16,5.00001 Z "},
{PackIconMaterialLightKind.Spellcheck, "M 8.5,17.5L 9.20711,16.7929L 12.7071,20.2929L 20.5,12.5L 21.2071,13.2071L 12.7071,21.7071L 8.5,17.5 Z M 4.71208,13L 3.5,16L 2.5,16L 7.34831,4L 8.75,4L 13.5983,16L 12.5983,16L 11.3862,13L 4.71208,13 Z M 5.1161,12L 10.9822,12L 8.04916,4.74044L 5.1161,12 Z "},
{PackIconMaterialLightKind.Star, "M 12.8604,10.4421L 11,6.0593L 9.13781,10.4463L 4.39462,10.8613L 7.99148,13.988L 6.92042,18.6273L 11.0056,16.1727L 15.0868,18.625L 14.0147,13.9812L 17.6082,10.8575L 12.8604,10.4421 Z M 16.5911,20.6955L 11.0056,17.3393L 5.4161,20.6978L 6.88195,14.3485L 1.96057,10.0705L 8.45208,9.50252L 11,3.5L 13.5461,9.4983L 20.0422,10.0666L 15.1243,14.3417L 16.5911,20.6955 Z "},
{PackIconMaterialLightKind.StarHalf, "M 11,6.0593L 9.13781,10.4463L 4.39462,10.8613L 7.99148,13.988L 6.92042,18.6273L 11,16.1761L 11,17.3427L 5.4161,20.6978L 6.88195,14.3485L 1.96057,10.0705L 8.45208,9.50252L 11,3.50001L 11,6.0593 Z "},
{PackIconMaterialLightKind.Stop, "M 17,18L 6.00004,18L 5.99992,7.00005L 17,6.99997L 17,18 Z M 7,8.00001L 7,17L 16,17L 16,8.00001L 7,8.00001 Z "},
{PackIconMaterialLightKind.Tab, "M 6,4L 17,4C 18.6569,4 20,5.34315 20,7L 20,18C 20,19.6569 18.6569,21 17,21L 6,21C 4.34315,21 3,19.6569 3,18L 3,7C 3,5.34315 4.34315,4 6,4 Z M 6,5.00001C 4.89543,5.00001 4,5.89544 4,7.00001L 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,10L 11,10L 11,5.00001L 6,5.00001 Z M 19,7.00001C 19,5.89544 18.1046,5.00001 17,5.00001L 12,5.00001L 12,9L 19,9L 19,7.00001 Z "},
{PackIconMaterialLightKind.Table, "M 6,5L 17,5C 18.6569,5 20,6.34315 20,8L 20,17C 20,18.6569 18.6569,20 17,20L 6,20C 4.34314,20 3,18.6569 3,17L 3,8C 3,6.34315 4.34314,5 6,5 Z M 4,17C 4,18.1046 4.89543,19 6,19L 11,19L 11,16L 4,16L 4,17 Z M 11,12L 4,12L 4,15L 11,15L 11,12 Z M 17,19C 18.1046,19 19,18.1046 19,17L 19,16L 12,16L 12,19L 17,19 Z M 19,12L 12,12L 12,15L 19,15L 19,12 Z M 4,11L 11,11L 11,8L 4,8L 4,11 Z M 12,11L 19,11L 19,8L 12,8L 12,11 Z "},
{PackIconMaterialLightKind.TabPlus, "M 6,4L 17,4C 18.6569,4 20,5.34315 20,7L 20,18C 20,19.6569 18.6569,21 17,21L 6,21C 4.34315,21 3,19.6569 3,18L 3,7C 3,5.34315 4.34315,4 6,4 Z M 6,5.00001C 4.89543,5.00001 4,5.89544 4,7.00001L 4,18C 4,19.1046 4.89543,20 6,20L 17,20C 18.1046,20 19,19.1046 19,18L 19,10L 11,10L 11,5.00001L 6,5.00001 Z M 19,7.00001C 19,5.89544 18.1046,5.00001 17,5.00001L 12,5.00001L 12,9.00001L 19,9L 19,7.00001 Z M 8,18L 8,16L 6.00001,16L 6.00001,15L 8,15L 8,13L 9,13L 9,15L 11,15L 11,16L 9,16L 9,18L 8,18 Z "},
{PackIconMaterialLightKind.Taco, "M 3.5,18C 2.11929,18 1,16.8807 1,15.5C 1,11.3579 4.80558,8 9.5,8C 10.1889,8 10.8586,8.07231 11.5,8.20879C 12.1414,8.07231 12.8111,8 13.5,8C 18.1944,8 22,11.3579 22,15.5C 22,16.8807 20.8807,18 19.5,18L 3.5,18 Z M 2,15.5C 2,16.3284 2.67157,17 3.5,17C 4.32843,17 5,16.3284 5,15.5C 5,12.7241 6.70918,10.3004 9.24963,9.00356C 5.2234,9.11801 2,11.9828 2,15.5 Z M 19.5,17C 20.3284,17 21,16.3284 21,15.5C 21,11.9102 17.6421,9 13.5,9C 9.35786,9 6,11.9102 6,15.5C 6,16.0628 5.81402,16.5822 5.50018,17L 19.5,17 Z "},
{PackIconMaterialLightKind.Tag, "M 15.6194,21.119C 14.4478,22.2906 12.5483,22.2906 11.3767,21.119L 3.0539,12.9963C 2.4512,12.4476 2,11.6293 2,10.75L 2,6C 2,4.34314 3.34315,3 5,3L 9.75,3C 10.6293,3 11.4476,3.45122 11.9963,4.05391L 20.0691,12.4266C 21.2407,13.5982 21.2407,15.4977 20.0691,16.6692L 15.6194,21.119 Z M 14.9123,20.4119L 19.362,15.9622C 20.1431,15.1811 20.1431,13.9148 19.362,13.1337L 11.1124,4.58426C 10.7756,4.1972 10.3023,4 9.75,4L 4.97333,3.97334C 3.86876,3.97334 3,4.89543 3,6L 3,10.75C 3,11.3023 3.19718,11.7756 3.58423,12.1124L 12.0838,20.4119C 12.8649,21.193 14.1312,21.193 14.9123,20.4119 Z M 6.5,5C 7.88071,5 9,6.11929 9,7.5C 9,8.88071 7.88072,10 6.5,10C 5.11929,10 4,8.88071 4,7.5C 4,6.11929 5.11929,5 6.5,5 Z M 6.5,6.00001C 5.67158,6.00001 5,6.67158 5,7.50001C 5,8.32843 5.67158,9 6.5,9C 7.32843,9 8,8.32843 8,7.50001C 8,6.67158 7.32843,6.00001 6.5,6.00001 Z "},
{PackIconMaterialLightKind.Television, "M 8,21L 8,20L 9,20L 9,19L 4,19C 2.34315,19 1,17.6569 1,16L 1,7C 1,5.34315 2.34315,4 4,4L 19,4C 20.6569,4 22,5.34315 22,7L 22,16C 22,17.6569 20.6569,19 19,19L 14,19L 14,20L 15,20L 15,21L 8,21 Z M 10,19L 10,20L 13,20L 13,19L 10,19 Z M 4,5.00001C 2.89543,5.00001 2,5.89544 2,7.00001L 2,16C 2,17.1046 2.89543,18 4,18L 19,18C 20.1046,18 21,17.1046 21,16L 21,7.00001C 21,5.89544 20.1046,5.00001 19,5.00001L 4,5.00001 Z "},
{PackIconMaterialLightKind.ThumbDown, "M 21,15L 18,15C 17.4477,15 17,14.5523 17,14L 17,5C 17,4.44772 17.4477,4 18,4L 21,4C 21.5523,4 22,4.44772 22,5L 22,14C 22,14.5523 21.5523,15 21,15 Z M 21,14L 21,5L 18,5L 18,14L 21,14 Z M 5.28374,5.97493L 2.28267,10.9743C 2.10317,11.2742 1.99999,11.6251 1.99999,12L 1.99999,13C 1.99999,14.1046 2.89543,15 4,15L 9.60994,15L 8.15248,20.4393L 8.14758,20.4576C 8.05837,20.7912 8.1447,21.1618 8.4064,21.4235L 14.415,15.415L 14.4142,15.4142C 14.7761,15.0523 15,14.5523 15,14L 15,6.99999C 15,5.89543 14.1046,5 13,5L 6.99999,5C 6.27037,5 5.632,5.3907 5.28374,5.97493 Z M 0.999995,12C 0.999995,11.4065 1.17234,10.8533 1.46971,10.3876L 4.37571,5.5452C 4.88769,4.62363 5.87101,4 6.99999,4L 13,4C 14.6568,4 16,5.34315 16,7L 16,14C 16,14.8275 15.665,15.5767 15.1232,16.1195L 8.40641,22.8378L 7.6993,22.1306C 7.16623,21.5976 6.99698,20.8385 7.19155,20.1619L 8.30672,16L 3.99999,16C 2.34314,16 0.999995,14.6569 0.999995,13L 0.999995,12 Z "},
{PackIconMaterialLightKind.ThumbsUpDown, "M 10.9041,8.42781L 11,8C 11,7.44772 10.5523,7 10,7L 4.92592,7.00001L 5.84748,3.56073L 5.85238,3.54243C 5.94159,3.20888 5.85526,2.83821 5.59356,2.57652L 1.585,6.58508L 1.58577,6.58585C 1.22384,6.94778 0.999981,7.44778 0.999981,8.00007L 0.999996,12C 0.999996,13.1046 1.89543,14 3,14L 7,14C 7.79733,14 8.48568,13.5334 8.80693,12.8584L 8.80481,12.8574L 10.9041,8.42781 Z M 7,15L 3,15C 1.34315,15 0,13.6569 0,12L -1.01725e-005,8.00006C -1.01725e-005,7.17257 0.335012,6.42333 0.87682,5.88058L 5.59355,1.16233L 6.30065,1.86943C 6.83373,2.40249 7.00298,3.16158 6.80841,3.83818L 6.22915,6.00002L 10,6.00001C 11.1046,6.00001 12,6.89544 12,8C 12,8.34024 11.915,8.66063 11.7652,8.94112L 9.76384,13.1687C 9.30819,14.2449 8.24227,15 7,15 Z M 12.0959,16.5722L 12,17C 12,17.5523 12.4477,18 13,18L 18.0741,18L 17.1525,21.4393L 17.1476,21.4576C 17.0584,21.7911 17.1447,22.1618 17.4064,22.4235L 21.415,18.4149L 21.4142,18.4142C 21.7762,18.0522 22,17.5522 22,16.9999L 22,13C 22,11.8954 21.1046,11 20,11L 16,11C 15.2027,11 14.5143,11.4666 14.1931,12.1416L 14.1952,12.1426L 12.0959,16.5722 Z M 16,10L 20,10C 21.6568,10 23,11.3431 23,13L 23,16.9999C 23,17.8274 22.665,18.5767 22.1232,19.1194L 17.4064,23.8377L 16.6993,23.1306C 16.1663,22.5975 15.997,21.8384 16.1916,21.1618L 16.7708,19L 13,19C 11.8954,19 11,18.1046 11,17C 11,16.6598 11.085,16.3394 11.2348,16.0589L 13.2362,11.8313C 13.6918,10.7551 14.7577,10 16,10 Z "},
{PackIconMaterialLightKind.ThumbUp, "M 2,10L 5,10C 5.55228,10 6,10.4477 6,11L 6,20C 6,20.5523 5.55228,21 5,21L 2,21C 1.44772,21 1,20.5523 1,20L 1,11C 1,10.4477 1.44772,10 2,10 Z M 2,11L 2,20L 5,20L 5,11L 2,11 Z M 17.7162,19.0251L 20.7173,14.0257C 20.8968,13.7258 21,13.3749 21,13L 21,12C 21,10.8954 20.1046,10 19,10L 13.39,10L 14.8475,4.56069L 14.8524,4.54239C 14.9416,4.20884 14.8553,3.83817 14.5936,3.57646L 8.58502,9.58503L 8.58578,9.58579C 8.22386,9.94772 7.99999,10.4477 7.99999,11L 7.99999,18C 7.99999,19.1046 8.89542,20 9.99999,20L 16,20C 16.7296,20 17.368,19.6093 17.7162,19.0251 Z M 22,13C 22,13.5935 21.8277,14.1467 21.5303,14.6124L 18.6243,19.4548C 18.1123,20.3764 17.129,21 16,21L 10,21C 8.34315,21 7,19.6569 7,18L 7,11C 7,10.1725 7.33503,9.42327 7.87683,8.88052L 14.5936,2.16225L 15.3007,2.86936C 15.8338,3.40242 16.003,4.16153 15.8084,4.83813L 14.6933,9L 19,9C 20.6569,9 22,10.3432 22,12L 22,13 Z "},
{PackIconMaterialLightKind.Tooltip, "M 5,4.00001L 18,4.00001C 19.6569,4.00001 21,5.34315 21,7.00001L 21,16C 21,17.6569 19.6569,19 18,19L 14.5,19L 11.5,22L 8.49999,19L 5,19C 3.34315,19 2,17.6569 2,16L 2,7.00001C 2,5.34315 3.34315,4.00001 5,4.00001 Z M 5,5.00001C 3.89543,5.00001 3,5.89544 3,7.00001L 3,16C 3,17.1046 3.89543,18 5,18L 8.9142,18L 11.5,20.5858L 14.0858,18L 18,18C 19.1046,18 20,17.1046 20,16L 20,7.00001C 20,5.89544 19.1046,5.00001 18,5.00001L 5,5.00001 Z "},
{PackIconMaterialLightKind.TooltipText, "M 5,4.00001L 18,4.00001C 19.6569,4.00001 21,5.34315 21,7.00001L 21,16C 21,17.6569 19.6569,19 18,19L 14.5,19L 11.5,22L 8.49999,19L 5,19C 3.34315,19 2,17.6569 2,16L 2,7.00001C 2,5.34315 3.34315,4.00001 5,4.00001 Z M 5,5.00001C 3.89543,5.00001 3,5.89544 3,7.00001L 3,16C 3,17.1046 3.89543,18 5,18L 8.9142,18L 11.5,20.5858L 14.0858,18L 18,18C 19.1046,18 20,17.1046 20,16L 20,7.00001C 20,5.89544 19.1046,5.00001 18,5.00001L 5,5.00001 Z M 5,8L 18,8L 18,9L 5,9L 5,8 Z M 5,11L 17,11L 17,12L 5,12L 5,11 Z M 5,14L 13,14L 13,15L 5,15L 5,14 Z "},
{PackIconMaterialLightKind.Trophy, "M 7,22C 7,19.7909 8.79086,18 11,18L 11,17C 8.58105,17 6.56329,15.2822 6.10002,13L 5,13C 3.34315,13 2,11.6568 2,10L 2,4.99998L 4,4.99999C 4.76836,4.99999 5.46925,5.28884 6.00001,5.76389L 6,3L 17,3L 17,5.76389C 17.5308,5.28885 18.2316,4.99999 19,4.99999L 21,4.99999L 21,10C 21,11.6569 19.6569,13 18,13L 16.9,13C 16.4367,15.2822 14.419,17 12,17L 12,18C 14.2091,18 16,19.7909 16,22L 7,22 Z M 12,19L 11,19C 9.69378,19 8.58254,19.8348 8.1707,21L 14.8293,21C 14.4174,19.8348 13.3062,19 12,19 Z M 16,4.00001L 7,4.00001L 7,12C 7,14.2091 8.79086,16 11,16L 12,16C 14.2091,16 16,14.2091 16,12L 16,4.00001 Z M 20,10L 20,6.00001L 19,6.00001C 17.8954,6.00001 17,6.89543 17,8L 17,12L 18,12C 19.1046,12 20,11.1046 20,10 Z M 3.00001,10C 3.00001,11.1046 3.89544,12 5.00001,12L 6,12L 6.00002,8C 6.00001,6.89543 5.10459,6.00001 4.00002,6.00001L 3.00001,6.00001L 3.00001,10 Z "},
{PackIconMaterialLightKind.UndoVariant, "M 6,20L 6,19L 7,19L 7,20L 6,20 Z M 13,8.00002C 16.3137,8.00002 19,10.6863 19,14C 19,17.3137 16.3137,20 13,20L 9,20L 9,19L 13,19C 15.7614,19 18,16.7614 18,14C 18,11.2386 15.7614,9.00001 13,9.00001L 5.91421,9L 8.94975,12.0355L 8.24264,12.7426L 4,8.5L 8.24265,4.25735L 8.94975,4.96447L 5.91421,8L 13,8.00002 Z "},
{PackIconMaterialLightKind.UnfoldLessHorizontal, "M 15.7426,5.29288L 11.5,9.53553L 7.25735,5.29289L 7.96446,4.58578L 11.5,8.12132L 15.0355,4.58578L 15.7426,5.29288 Z M 15.7426,19.7071L 15.0355,20.4142L 11.5,16.8787L 7.96445,20.4142L 7.25735,19.7071L 11.5,15.4645L 15.7426,19.7071 Z "},
{PackIconMaterialLightKind.UnfoldLessVertical, "M 18.7071,16.7426L 14.4645,12.5L 18.7071,8.25735L 19.4142,8.96446L 15.8787,12.5L 19.4142,16.0355L 18.7071,16.7426 Z M 4.29288,16.7426L 3.58577,16.0355L 7.12131,12.5L 3.58578,8.96446L 4.29288,8.25735L 8.53553,12.5L 4.29288,16.7426 Z "},
{PackIconMaterialLightKind.UnfoldMoreHorizontal, "M 15.7426,8.82842L 15.0355,9.53553L 11.5,5.99999L 7.96446,9.53553L 7.25735,8.82842L 11.5,4.58578L 15.7426,8.82842 Z M 15.7426,16.1716L 11.5,20.4142L 7.25735,16.1716L 7.96446,15.4645L 11.5,19L 15.0355,15.4645L 15.7426,16.1716 Z "},
{PackIconMaterialLightKind.UnfoldMoreVertical, "M 15.1716,16.7426L 14.4645,16.0355L 18,12.5L 14.4645,8.96446L 15.1716,8.25735L 19.4142,12.5L 15.1716,16.7426 Z M 7.82842,16.7426L 3.58577,12.5L 7.82842,8.25735L 8.53552,8.96446L 4.99999,12.5L 8.53553,16.0355L 7.82842,16.7426 Z "},
{PackIconMaterialLightKind.Ungroup, "M 2,3.00001L 5,3.00001L 5,4.00001L 13,4.00001L 13,3.00002L 16,3.00003L 16,6.00001L 15,6.00001L 15,10L 18,10L 18,9L 21,9.00001L 21,12L 20,12L 20,19L 21,19L 21,22L 18,22L 18,21L 11,21L 11,22L 8,22L 7.99999,19L 8.99999,19L 8.99999,16L 5,16L 5,17L 2,17L 2,14L 3,14L 3,6L 2,6L 2,3.00001 Z M 18,12L 18,11L 15,11L 15,14L 16,14L 16,17L 13,17L 13,16L 9.99998,16L 9.99997,19L 11,19L 11,20L 18,20L 18,19L 19,19L 19,12L 18,12 Z M 13,6.00002L 13,5.00003L 4.99999,5.00002L 4.99999,6.00002L 3.99999,6.00003L 3.99999,14L 4.99999,14L 4.99999,15L 8.99999,15L 8.99999,12L 7.99998,12L 7.99998,9.00003L 11,9.00004L 11,10L 14,10L 14,6.00002L 13,6.00002 Z M 11,12L 9.99998,12L 9.99997,15L 13,15L 13,14L 14,14L 14,11L 11,11L 11,12 Z M 3,5.00001L 4,5.00001L 4,4.00001L 3,4.00001L 3,5.00001 Z M 14,5.00001L 15,5.00001L 15,4.00001L 14,4.00001L 14,5.00001 Z M 9,11L 10,11L 10,10L 9,10L 9,11 Z M 19,11L 20,11L 20,10L 19,10L 19,11 Z M 9,21L 10,21L 10,20L 9,20L 9,21 Z M 19,21L 20,21L 20,20L 19,20L 19,21 Z M 3,16L 4,16L 4,15L 3,15L 3,16 Z M 14,16L 15,16L 15,15L 14,15L 14,16 Z "},
{PackIconMaterialLightKind.Upload, "M 12,18.1642L 12,5.9142L 17.2501,11.1642L 18,10.5L 11.5,4.00001L 5,10.5L 5.75001,11.1642L 11,5.91422L 11,18.1642L 12,18.1642 Z M 3,19L 4,19L 4,21L 19,21L 19,19L 20,19L 20,22L 3,22L 3,19 Z "},
{PackIconMaterialLightKind.ViewDashboard, "M 12,4.00001L 20,4.00001L 20,10L 12,10L 12,4.00001 Z M 12,21L 12,11L 20,11L 20,21L 12,21 Z M 3,21L 3,15L 11,15L 11,21L 3,21 Z M 3,14L 3,4.00001L 11,4.00001L 11,14L 3,14 Z M 4,5.00001L 4,13L 10,13L 10,5.00001L 4,5.00001 Z M 13,5.00001L 13,9.00001L 19,9.00001L 19,5.00001L 13,5.00001 Z M 13,12L 13,20L 19,20L 19,12L 13,12 Z M 4,16L 4,20L 10,20L 10,16L 4,16 Z "},
{PackIconMaterialLightKind.ViewModule, "M 15,6L 20,6L 20,12L 15,12L 15,6 Z M 9,12L 9,6.00001L 14,6.00001L 14,12L 9,12 Z M 15,19L 15,13L 20,13L 20,19L 15,19 Z M 9,19L 9,13L 14,13L 14,19L 9,19 Z M 3,19L 3,13L 8,13L 8,19L 3,19 Z M 3,12L 3,6.00001L 8,6.00001L 8,12L 3,12 Z M 4,7.00001L 4,11L 7,11L 7,7.00001L 4,7.00001 Z M 9.99999,7.00001L 9.99999,11L 13,11L 13,7.00001L 9.99999,7.00001 Z M 16,7.00001L 16,11L 19,11L 19,7.00001L 16,7.00001 Z M 4,14L 4,18L 7,18L 7,14L 4,14 Z M 10,14L 10,18L 13,18L 13,14L 10,14 Z M 16,14L 16,18L 19,18L 19,14L 16,14 Z "},
{PackIconMaterialLightKind.Volume, "M 21,12.5C 21,16.4741 17.909,19.7263 14,19.9836L 14,18.9811C 17.3562,18.7257 20,15.9216 20,12.5C 20,9.07839 17.3562,6.27427 14,6.01895L 14,5.0164C 17.909,5.2737 21,8.52588 21,12.5 Z M 18,12.5C 18,14.8163 16.25,16.7238 14,16.9725L 14,15.9646C 15.6961,15.7219 17,14.2632 17,12.5C 17,10.7368 15.6961,9.27807 14,9.03545L 14,8.02747C 16.25,8.27619 18,10.1837 18,12.5 Z M 15,12.5C 15,13.1531 14.5826,13.7087 14,13.9146L 14,11.0854C 14.5826,11.2913 15,11.8469 15,12.5 Z M 2,9L 6,9L 10,5L 12,5L 12,20L 10,20L 6,16L 2,16L 2,9 Z M 3,15L 6.41421,15L 10.4142,19L 11,19L 11,6.00001L 10.4142,6.00001L 6.41421,10L 3,10L 3,15 Z "},
{PackIconMaterialLightKind.VolumeMinus, "M 2,9L 6,9L 10,5L 12,5L 12,20L 10,20L 6,16L 2,16L 2,9 Z M 3,15L 6.41421,15L 10.4142,19L 11,19L 11,6.00001L 10.4142,6.00001L 6.41421,10L 3,10L 3,15 Z M 14,13L 14,12L 21,12L 21,13L 14,13 Z "},
{PackIconMaterialLightKind.VolumeMute, "M 2,9L 6,9L 10,5L 12,5L 12,20L 10,20L 6,16L 2,16L 2,9 Z M 3,15L 6.41421,15L 10.4142,19L 11,19L 11,6.00001L 10.4142,6.00001L 6.41421,10L 3,10L 3,15 Z M 13.9645,15.3284L 16.7929,12.5L 13.9645,9.67158L 14.6716,8.96447L 17.5,11.7929L 20.3284,8.96447L 21.0355,9.67157L 18.2071,12.5L 21.0355,15.3284L 20.3284,16.0355L 17.5,13.2071L 14.6716,16.0355L 13.9645,15.3284 Z "},
{PackIconMaterialLightKind.VolumeOff, "M 2.79289,4.45711L 3.5,3.75L 20.25,20.5L 19.5429,21.2071L 17.302,18.9662C 16.3222,19.5436 15.1996,19.9046 14,19.9836L 14,18.9811C 14.9232,18.9108 15.7925,18.6477 16.5678,18.232L 15.0586,16.7228C 14.7227,16.8468 14.3681,16.9319 14,16.9725L 14,15.9646C 14.0858,15.9523 14.1706,15.9369 14.2543,15.9185L 12,13.6642L 12,20L 10,20L 6,16L 2,16L 2,9L 6,9L 6.6679,8.33211L 2.79289,4.45711 Z M 21,12.5C 21,14.5293 20.194,16.3704 18.8848,17.7206L 18.1776,17.0134C 19.3059,15.8442 20,14.2532 20,12.5C 20,9.07839 17.3562,6.27427 14,6.01895L 14,5.01641C 17.909,5.2737 21,8.52588 21,12.5 Z M 18,12.5C 18,13.7009 17.5296,14.7919 16.763,15.5988L 16.0556,14.8914C 16.6414,14.2657 17,13.4247 17,12.5C 17,10.7368 15.6961,9.27807 14,9.03546L 14,8.02747C 16.25,8.2762 18,10.1837 18,12.5 Z M 15,12.5C 15,12.8724 14.8643,13.2131 14.6396,13.4754L 14,12.8358L 14,11.0854C 14.5826,11.2913 15,11.8469 15,12.5 Z M 6.41421,10L 3,10L 3,15L 6.41421,15L 10.4142,19L 11,19L 11,12.6642L 7.375,9.03922L 6.41421,10 Z M 10,5.00001L 12,5.00001L 12,10.8358L 11,9.83578L 11,6.00001L 10.4142,6.00001L 8.78921,7.625L 8.08211,6.9179L 10,5.00001 Z "},
{PackIconMaterialLightKind.VolumePlus, "M 2,9L 6,9L 10,5L 12,5L 12,20L 10,20L 6,16L 2,16L 2,9 Z M 3,15L 6.41421,15L 10.4142,19L 11,19L 11,6.00001L 10.4142,6.00001L 6.41421,10L 3,10L 3,15 Z M 17,16L 17,13L 14,13L 14,12L 17,12L 17,9.00001L 18,9.00001L 18,12L 21,12L 21,13L 18,13L 18,16L 17,16 Z "},
{PackIconMaterialLightKind.Wifi, "M 11.5,20.5L 6.98612,14.5099C 8.24198,13.5621 9.80535,13 11.5,13C 13.1946,13 14.7579,13.562 16.0138,14.5098L 11.5,20.5 Z M 11.5,18.8384L 14.5674,14.7678C 13.6537,14.2779 12.6093,14 11.5,14C 10.3907,14 9.34631,14.2779 8.43263,14.7678L 11.5,18.8384 Z M 11.5,4.00001C 15.2282,4.00001 18.6675,5.23647 21.4304,7.3217L 20.8286,8.12038C 18.2331,6.16154 15.0022,5 11.5,5C 7.99773,5 4.76677,6.16156 2.17133,8.12045L 1.56948,7.32178C 4.33237,5.23651 7.77179,4.00001 11.5,4.00001 Z M 11.5,10C 13.8724,10 16.0611,10.7868 17.8193,12.1138L 17.2175,12.9125C 15.6267,11.7119 13.6465,11 11.5,11C 9.35345,11 7.37318,11.7119 5.78242,12.9125L 5.18057,12.1139C 6.93878,10.7869 9.12749,10 11.5,10 Z M 11.5,7.00001C 14.5503,7.00001 17.3643,8.01166 19.6249,9.71774L 19.023,10.5164C 16.9299,8.93672 14.3244,8.00001 11.5,8.00001C 8.67559,8.00001 6.06997,8.93675 3.97688,10.5165L 3.37503,9.71782C 5.63557,8.01169 8.44964,7.00001 11.5,7.00001 Z "},
{PackIconMaterialLightKind.Xml, "M 16.1716,17.7426L 15.4644,17.0355L 20,12.5L 15.4644,7.96445L 16.1716,7.25734L 21.4142,12.5L 16.1716,17.7426 Z M 6.82841,17.7426L 1.58577,12.5L 6.82841,7.25734L 7.53551,7.96445L 2.99998,12.5L 7.53552,17.0355L 6.82841,17.7426 Z M 12.7315,5L 13.7315,5L 10.2685,20L 9.26848,20L 12.7315,5 Z "},
};
}
}
} | 489.324042 | 2,079 | 0.688328 | [
"MIT"
] | GerHobbelt/MahApps.Metro.IconPacks | src/MahApps.Metro.IconPacks/PackIconMaterialLightDataFactory.cs | 140,438 | C# |
// MIT License
//
// Copyright(c) 2021 ICARUS Consulting GmbH
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace Yaapii.Atoms.Func
{
/// <summary>
/// Function that has two inputs and an output
/// </summary>
/// <typeparam name="In1">type of first input</typeparam>
/// <typeparam name="In2">type of second input</typeparam>
/// <typeparam name="Out">type of output</typeparam>
public sealed class BiFuncOf<In1, In2, Out> : IBiFunc<In1, In2, Out>
{
private readonly System.Func<In1, In2, Out> _func;
/// <summary>
/// Function that has two inputs and an output.
/// </summary>
/// <param name="func"></param>
public BiFuncOf(System.Func<In1, In2, Out> func)
{
_func = func;
}
/// <summary>
/// Invoke the function with arguments and retrieve th output.
/// </summary>
/// <param name="arg1">first argument</param>
/// <param name="arg2">second argument</param>
/// <returns>the output</returns>
public Out Invoke(In1 arg1, In2 arg2)
{
return _func.Invoke(arg1, arg2);
}
}
}
| 39.428571 | 81 | 0.664855 | [
"MIT"
] | icarus-consulting/Yaapii.Atoms | src/Yaapii.Atoms/Func/BiFuncOf.cs | 2,208 | C# |
using System.Resources;
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("SayHelloXF")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SayHelloXF")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// 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")]
| 34.677419 | 84 | 0.743256 | [
"Apache-2.0"
] | adrianstevens/NETConf2017 | SayHelloXF/SayHelloXF/SayHelloXF/Properties/AssemblyInfo.cs | 1,078 | C# |
/*
* Copyright Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/
/*
* Do not modify this file. This file is generated from the gamelift-2015-10-01.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Serialization;
using Amazon.GameLift.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
using ThirdParty.Json.LitJson;
namespace Amazon.GameLift.Model.Internal.MarshallTransformations
{
/// <summary>
/// Response Unmarshaller for GameSessionFullException Object
/// </summary>
public class GameSessionFullExceptionUnmarshaller : IErrorResponseUnmarshaller<GameSessionFullException, JsonUnmarshallerContext>
{
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public GameSessionFullException Unmarshall(JsonUnmarshallerContext context)
{
return this.Unmarshall(context, new ErrorResponse());
}
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <param name="errorResponse"></param>
/// <returns></returns>
public GameSessionFullException Unmarshall(JsonUnmarshallerContext context, ErrorResponse errorResponse)
{
context.Read();
GameSessionFullException unmarshalledObject = new GameSessionFullException(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
int targetDepth = context.CurrentDepth;
while (context.ReadAtDepth(targetDepth))
{
}
return unmarshalledObject;
}
private static GameSessionFullExceptionUnmarshaller _instance = new GameSessionFullExceptionUnmarshaller();
/// <summary>
/// Gets the singleton.
/// </summary>
public static GameSessionFullExceptionUnmarshaller Instance
{
get
{
return _instance;
}
}
}
} | 35.8 | 140 | 0.651988 | [
"Apache-2.0"
] | philasmar/aws-sdk-net | sdk/src/Services/GameLift/Generated/Model/Internal/MarshallTransformations/GameSessionFullExceptionUnmarshaller.cs | 3,043 | C# |
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.GTK
{
internal class ResourcesProvider : ISystemResourcesProvider
{
private const string TitleStyleKey = "HeaderLabelStyle";
private const string SubtitleStyleKey = "SubheaderLabelStyle";
private const string BodyStyleKey = "BodyLabelStyle";
private const string CaptionStyleKey = "CaptionLabelStyle";
private const string ListItemDetailTextStyleKey = "BodyLabelStyle";
private const string ListItemTextStyleKey = "BaseLabelStyle";
public IResourceDictionary GetSystemResources()
{
return new ResourceDictionary
{
[Device.Styles.TitleStyleKey] = GetStyle(TitleStyleKey),
[Device.Styles.SubtitleStyleKey] = GetStyle(SubtitleStyleKey),
[Device.Styles.BodyStyleKey] = GetStyle(BodyStyleKey),
[Device.Styles.CaptionStyleKey] = GetStyle(CaptionStyleKey),
[Device.Styles.ListItemDetailTextStyleKey] = GetStyle(ListItemDetailTextStyleKey),
[Device.Styles.ListItemTextStyleKey] = GetStyle(ListItemTextStyleKey)
};
}
private Style GetStyle(string nativeKey)
{
var result = new Style(typeof(Label));
switch(nativeKey)
{
case TitleStyleKey:
result.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = 24 });
break;
case SubtitleStyleKey:
result.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = 20 });
break;
case BodyStyleKey:
result.Setters.Add(new Setter { Property = Label.TextColorProperty, Value = Color.Blue });
break;
case CaptionStyleKey:
break;
case ListItemTextStyleKey:
break;
}
return result;
}
}
} | 40.058824 | 110 | 0.593245 | [
"MIT"
] | 1rfan786/xamarin.android | Xamarin.Forms.Platform.GTK/ResourcesProvider.cs | 2,045 | C# |
using Microsoft.Extensions.Configuration.Json;
namespace AspnetcoreEx.Extensions;
public class CustomJsonConfigurationProvider : JsonConfigurationProvider
{
public CustomJsonConfigurationProvider(CustomJsonConfigurationSource source) : base(source)
{
}
public override void Load(Stream stream)
{
// Let the base class do the heavy lifting.
base.Load(stream);
// Do decryption here, you can tap into the Data property like so:
Data["Client:Password"] = Data["Client:Password"] + "--thisistext";
// But you have to make your own MyEncryptionLibrary, not included here
}
}
public class CustomJsonConfigurationSource: JsonConfigurationSource
{
public override IConfigurationProvider Build(IConfigurationBuilder builder)
{
EnsureDefaults(builder);
return new CustomJsonConfigurationProvider(this);
}
} | 29.833333 | 95 | 0.727374 | [
"Apache-2.0"
] | futugyou/CodeFragments | AspnetcoreEx/Extensions/CustomJsonConfigurationProvider.cs | 897 | C# |
// <auto-generated />
using System;
using BakeryShop.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace BakeryShop.Migrations
{
[DbContext(typeof(BakeryDbContext))]
[Migration("20210122193436_Image")]
partial class Image
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseIdentityColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.2");
modelBuilder.Entity("BakeryShop.Models.Bread", b =>
{
b.Property<int>("BreadId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("CategoryId")
.HasColumnType("int");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageThumbnailUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsBreadOfTheWeek")
.HasColumnType("bit");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Price")
.HasColumnType("decimal(18,2)");
b.HasKey("BreadId");
b.HasIndex("CategoryId");
b.ToTable("Breads");
b.HasData(
new
{
BreadId = 1,
CategoryId = 2,
Description = "100% faina alba de grau, apa, sare, 5% maia naturala din faina de grau, 600 g.",
ImageThumbnailUrl = "https://gillcleerenpluralsight.blob.core.windows.net/files/applepiesmall.jpg",
ImageUrl = "https://gillcleerenpluralsight.blob.core.windows.net/files/applepie.jpg",
IsBreadOfTheWeek = true,
Name = "White Bread",
Price = 10m
},
new
{
BreadId = 2,
CategoryId = 1,
Description = "Faina alba de grau,Faina spelta, apa, sare, 5% maia naturala din faina de grau, 600 g.",
ImageThumbnailUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21325&parId=880317F0636F898D%21316&o=OneUp",
ImageUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21325&parId=880317F0636F898D%21316&o=OneUp",
IsBreadOfTheWeek = false,
Name = "Spelt Bread",
Price = 12m
},
new
{
BreadId = 3,
CategoryId = 2,
Description = "Prin faina 100% integrala din care este dospita, aceasta paine aduce numeroase beneficii sanatatii.",
ImageThumbnailUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21320&parId=880317F0636F898D%21316&o=OneUp",
ImageUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21320&parId=880317F0636F898D%21316&o=OneUp",
IsBreadOfTheWeek = true,
Name = "Whole Weat Bread",
Price = 11m
},
new
{
BreadId = 4,
CategoryId = 2,
Description = "Paine intermediara cu maia naturala, fara drojdie si fara aditivi. Incearca si tu savuroasa paine rustica ",
ImageThumbnailUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21318&parId=880317F0636F898D%21316&o=OneUp",
ImageUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21318&parId=880317F0636F898D%21316&o=OneUp",
IsBreadOfTheWeek = true,
Name = "Rustic Bread",
Price = 12m
},
new
{
BreadId = 5,
CategoryId = 1,
Description = "Se spune că simplitatea este cea mai înalta formă a sofisticării, iar această pâine susţine această afirmaţie în mod categoric. Gustul bogat si simplu o face extrem de versatilă pentru toate ideile de masă.",
ImageThumbnailUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21323&parId=880317F0636F898D%21316&o=OneUp",
ImageUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21323&parId=880317F0636F898D%21316&o=OneUp",
IsBreadOfTheWeek = true,
Name = "Leaven Bread",
Price = 13m
},
new
{
BreadId = 6,
CategoryId = 1,
Description = "Baghetă tradițională franţuzească, cu miez puţin, alveolat şi o crustă crocantă şi subţire. Alegerea perfectă pentru toate mesele.",
ImageThumbnailUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21330&parId=880317F0636F898D%21316&o=OneUp",
ImageUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21330&parId=880317F0636F898D%21316&o=OneUp",
IsBreadOfTheWeek = false,
Name = "Baquette Bread",
Price = 6.5m
},
new
{
BreadId = 7,
CategoryId = 1,
Description = "O pâine moale şi fină, de inspiraţie italienească, conţine ulei de măsline extravirgin din belşug, contribuind decisiv la gustul agreabil.",
ImageThumbnailUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21329&parId=880317F0636F898D%21316&o=OneUp",
ImageUrl = "https://onedrive.live.com/?cid=880317F0636F898D&id=880317F0636F898D%21329&parId=880317F0636F898D%21316&o=OneUp",
IsBreadOfTheWeek = false,
Name = "Ciabata Bread",
Price = 13m
});
});
modelBuilder.Entity("BakeryShop.Models.Category", b =>
{
b.Property<int>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("CategoryName")
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortDescription")
.HasColumnType("nvarchar(max)");
b.HasKey("CategoryId");
b.ToTable("Categories");
b.HasData(
new
{
CategoryId = 1,
CategoryName = "Special Bread"
},
new
{
CategoryId = 2,
CategoryName = "Regular Bread"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(max)");
b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(max)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("IdentityUser");
});
modelBuilder.Entity("BakeryShop.Models.Bread", b =>
{
b.HasOne("BakeryShop.Models.Category", "Category")
.WithMany("Breads")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
});
modelBuilder.Entity("BakeryShop.Models.Category", b =>
{
b.Navigation("Breads");
});
#pragma warning restore 612, 618
}
}
}
| 45.774059 | 251 | 0.46883 | [
"MIT"
] | danasarghe/BakeryShop | BakeryShop/Migrations/20210122193436_Image.Designer.cs | 10,974 | 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.Diagnostics.CodeAnalysis;
namespace System.Reflection
{
public static class TypeExtensions
{
public static ConstructorInfo? GetConstructor(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] this Type type!!,
Type[] types)
{
return type.GetConstructor(types);
}
public static ConstructorInfo[] GetConstructors(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] this Type type!!)
{
return type.GetConstructors();
}
public static ConstructorInfo[] GetConstructors(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetConstructors(bindingAttr);
}
public static MemberInfo[] GetDefaultMembers(
[DynamicallyAccessedMembers(
DynamicallyAccessedMemberTypes.PublicFields
| DynamicallyAccessedMemberTypes.PublicMethods
| DynamicallyAccessedMemberTypes.PublicEvents
| DynamicallyAccessedMemberTypes.PublicProperties
| DynamicallyAccessedMemberTypes.PublicConstructors
| DynamicallyAccessedMemberTypes.PublicNestedTypes)] this Type type!!)
{
return type.GetDefaultMembers();
}
public static EventInfo? GetEvent(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents)] this Type type!!,
string name)
{
return type.GetEvent(name);
}
public static EventInfo? GetEvent(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents | DynamicallyAccessedMemberTypes.NonPublicEvents)] this Type type!!,
string name,
BindingFlags bindingAttr)
{
return type.GetEvent(name, bindingAttr);
}
public static EventInfo[] GetEvents(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents)] this Type type!!)
{
return type.GetEvents();
}
public static EventInfo[] GetEvents(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents | DynamicallyAccessedMemberTypes.NonPublicEvents)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetEvents(bindingAttr);
}
public static FieldInfo? GetField(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] this Type type!!,
string name)
{
return type.GetField(name);
}
public static FieldInfo? GetField(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] this Type type!!,
string name,
BindingFlags bindingAttr)
{
return type.GetField(name, bindingAttr);
}
public static FieldInfo[] GetFields(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] this Type type!!)
{
return type.GetFields();
}
public static FieldInfo[] GetFields(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetFields(bindingAttr);
}
public static Type[] GetGenericArguments(this Type type!!)
{
return type.GetGenericArguments();
}
public static Type[] GetInterfaces(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type type!!)
{
return type.GetInterfaces();
}
public static MemberInfo[] GetMember(
[DynamicallyAccessedMembers(
DynamicallyAccessedMemberTypes.PublicFields
| DynamicallyAccessedMemberTypes.PublicMethods
| DynamicallyAccessedMemberTypes.PublicEvents
| DynamicallyAccessedMemberTypes.PublicProperties
| DynamicallyAccessedMemberTypes.PublicConstructors
| DynamicallyAccessedMemberTypes.PublicNestedTypes)] this Type type!!,
string name)
{
return type.GetMember(name);
}
public static MemberInfo[] GetMember(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] this Type type!!,
string name,
BindingFlags bindingAttr)
{
return type.GetMember(name, bindingAttr);
}
public static MemberInfo[] GetMembers(
[DynamicallyAccessedMembers(
DynamicallyAccessedMemberTypes.PublicFields
| DynamicallyAccessedMemberTypes.PublicMethods
| DynamicallyAccessedMemberTypes.PublicEvents
| DynamicallyAccessedMemberTypes.PublicProperties
| DynamicallyAccessedMemberTypes.PublicConstructors
| DynamicallyAccessedMemberTypes.PublicNestedTypes)] this Type type!!)
{
return type.GetMembers();
}
public static MemberInfo[] GetMembers(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetMembers(bindingAttr);
}
public static MethodInfo? GetMethod(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] this Type type!!,
string name)
{
return type.GetMethod(name);
}
public static MethodInfo? GetMethod(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] this Type type!!,
string name,
BindingFlags bindingAttr)
{
return type.GetMethod(name, bindingAttr);
}
public static MethodInfo? GetMethod(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] this Type type!!,
string name,
Type[] types)
{
return type.GetMethod(name, types);
}
public static MethodInfo[] GetMethods(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] this Type type!!)
{
return type.GetMethods();
}
public static MethodInfo[] GetMethods(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetMethods(bindingAttr);
}
public static Type? GetNestedType(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicNestedTypes | DynamicallyAccessedMemberTypes.NonPublicNestedTypes)] this Type type!!,
string name,
BindingFlags bindingAttr)
{
return type.GetNestedType(name, bindingAttr);
}
public static Type[] GetNestedTypes(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicNestedTypes | DynamicallyAccessedMemberTypes.NonPublicNestedTypes)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetNestedTypes(bindingAttr);
}
public static PropertyInfo[] GetProperties(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] this Type type!!)
{
return type.GetProperties();
}
public static PropertyInfo[] GetProperties(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)] this Type type!!,
BindingFlags bindingAttr)
{
return type.GetProperties(bindingAttr);
}
public static PropertyInfo? GetProperty(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] this Type type!!,
string name)
{
return type.GetProperty(name);
}
public static PropertyInfo? GetProperty(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)] this Type type!!,
string name,
BindingFlags bindingAttr)
{
return type.GetProperty(name, bindingAttr);
}
public static PropertyInfo? GetProperty(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] this Type type!!,
string name,
Type? returnType)
{
return type.GetProperty(name, returnType);
}
public static PropertyInfo? GetProperty(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] this Type type!!,
string name,
Type? returnType,
Type[] types)
{
return type.GetProperty(name, returnType, types);
}
public static bool IsAssignableFrom(this Type type!!, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] Type? c)
{
return type.IsAssignableFrom(c);
}
public static bool IsInstanceOfType(this Type type!!, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object? o)
{
return type.IsInstanceOfType(o);
}
}
public static class AssemblyExtensions
{
[RequiresUnreferencedCode("Types might be removed")]
public static Type[] GetExportedTypes(this Assembly assembly!!)
{
return assembly.GetExportedTypes();
}
public static Module[] GetModules(this Assembly assembly!!)
{
return assembly.GetModules();
}
[RequiresUnreferencedCode("Types might be removed")]
public static Type[] GetTypes(this Assembly assembly!!)
{
return assembly.GetTypes();
}
}
public static class EventInfoExtensions
{
public static MethodInfo? GetAddMethod(this EventInfo eventInfo!!)
{
return eventInfo.GetAddMethod();
}
public static MethodInfo? GetAddMethod(this EventInfo eventInfo!!, bool nonPublic)
{
return eventInfo.GetAddMethod(nonPublic);
}
public static MethodInfo? GetRaiseMethod(this EventInfo eventInfo!!)
{
return eventInfo.GetRaiseMethod();
}
public static MethodInfo? GetRaiseMethod(this EventInfo eventInfo!!, bool nonPublic)
{
return eventInfo.GetRaiseMethod(nonPublic);
}
public static MethodInfo? GetRemoveMethod(this EventInfo eventInfo!!)
{
return eventInfo.GetRemoveMethod();
}
public static MethodInfo? GetRemoveMethod(this EventInfo eventInfo!!, bool nonPublic)
{
return eventInfo.GetRemoveMethod(nonPublic);
}
}
public static class MemberInfoExtensions
{
/// <summary>
/// Determines if there is a metadata token available for the given member.
/// <see cref="GetMetadataToken(MemberInfo)"/> throws <see cref="InvalidOperationException"/> otherwise.
/// </summary>
/// <remarks>This maybe</remarks>
public static bool HasMetadataToken(this MemberInfo member!!)
{
try
{
return GetMetadataTokenOrZeroOrThrow(member) != 0;
}
catch (InvalidOperationException)
{
// Thrown for unbaked ref-emit members/types.
// Other cases such as typeof(byte[]).MetadataToken will be handled by comparison to zero above.
return false;
}
}
/// <summary>
/// Gets a metadata token for the given member if available. The returned token is never nil.
/// </summary>
/// <exception cref="InvalidOperationException">
/// There is no metadata token available. <see cref="HasMetadataToken(MemberInfo)"/> returns false in this case.
/// </exception>
public static int GetMetadataToken(this MemberInfo member!!)
{
int token = GetMetadataTokenOrZeroOrThrow(member);
if (token == 0)
{
throw new InvalidOperationException(SR.NoMetadataTokenAvailable);
}
return token;
}
private static int GetMetadataTokenOrZeroOrThrow(this MemberInfo member)
{
int token = member.MetadataToken;
// Tokens have MSB = table index, 3 LSBs = row index
// row index of 0 is a nil token
const int rowMask = 0x00FFFFFF;
if ((token & rowMask) == 0)
{
// Nil token is returned for edge cases like typeof(byte[]).MetadataToken.
return 0;
}
return token;
}
}
public static class MethodInfoExtensions
{
public static MethodInfo GetBaseDefinition(this MethodInfo method!!)
{
return method.GetBaseDefinition();
}
}
public static class ModuleExtensions
{
public static bool HasModuleVersionId(this Module module!!)
{
return true; // not expected to fail on platforms with Module.ModuleVersionId built-in.
}
public static Guid GetModuleVersionId(this Module module!!)
{
return module.ModuleVersionId;
}
}
public static class PropertyInfoExtensions
{
public static MethodInfo[] GetAccessors(this PropertyInfo property!!)
{
return property.GetAccessors();
}
public static MethodInfo[] GetAccessors(this PropertyInfo property!!, bool nonPublic)
{
return property.GetAccessors(nonPublic);
}
public static MethodInfo? GetGetMethod(this PropertyInfo property!!)
{
return property.GetGetMethod();
}
public static MethodInfo? GetGetMethod(this PropertyInfo property!!, bool nonPublic)
{
return property.GetGetMethod(nonPublic);
}
public static MethodInfo? GetSetMethod(this PropertyInfo property!!)
{
return property.GetSetMethod();
}
public static MethodInfo? GetSetMethod(this PropertyInfo property!!, bool nonPublic)
{
return property.GetSetMethod(nonPublic);
}
}
}
| 36 | 164 | 0.630159 | [
"MIT"
] | AUTOMATE-2001/runtime | src/libraries/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.cs | 15,120 | C# |
using System;
using System.Data;
using System.Data.Linq;
using System.Diagnostics;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Globalization;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using LinqToDB;
using LinqToDB.Common;
using LinqToDB.Data;
using LinqToDB.DataProvider;
using LinqToDB.DataProvider.Oracle;
using LinqToDB.Mapping;
using LinqToDB.Tools;
using NUnit.Framework;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
namespace Tests.DataProvider
{
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using LinqToDB.Data.RetryPolicy;
using LinqToDB.Linq;
using LinqToDB.Linq.Internal;
using LinqToDB.SchemaProvider;
using Model;
[TestFixture]
public class OracleTests : TestBase
{
string _pathThroughSql = "SELECT :p FROM sys.dual";
string PathThroughSql
{
get
{
_pathThroughSql += " ";
return _pathThroughSql;
}
}
[Test]
public void TestParameters([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.VarBinary("p", null)), Is.EqualTo(null));
Assert.That(conn.Execute<char> (PathThroughSql, DataParameter.Char ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<string>(PathThroughSql, new { p = 1 }), Is.EqualTo("1"));
Assert.That(conn.Execute<string>(PathThroughSql, new { p = "1" }), Is.EqualTo("1"));
Assert.That(conn.Execute<int> ("SELECT :p FROM sys.dual", new { p = new DataParameter { Value = 1 } }), Is.EqualTo(1));
Assert.That(conn.Execute<string>("SELECT :p1 FROM sys.dual", new { p1 = new DataParameter { Value = "1" } }), Is.EqualTo("1"));
Assert.That(conn.Execute<int> ("SELECT :p1 + :p2 FROM sys.dual", new { p1 = 2, p2 = 3 }), Is.EqualTo(5));
Assert.That(conn.Execute<int> ("SELECT :p2 + :p1 FROM sys.dual", new { p2 = 2, p1 = 3 }), Is.EqualTo(5));
}
}
static void TestType<T>(
DataConnection connection,
string dataTypeName,
[DisallowNull] T value,
string tableName = "\"AllTypes\"",
bool convertToString = false,
bool throwException = false)
{
Assert.That(connection.Execute<T>($"SELECT {dataTypeName} FROM {tableName} WHERE ID = 1"),
Is.EqualTo(connection.MappingSchema.GetDefaultValue(typeof(T))));
object actualValue = connection.Execute<T>($"SELECT {dataTypeName} FROM {tableName} WHERE ID = 2")!;
object expectedValue = value;
if (convertToString)
{
actualValue = actualValue. ToString()!;
expectedValue = expectedValue.ToString()!;
}
if (throwException)
{
if (!EqualityComparer<T>.Default.Equals((T)actualValue, (T)expectedValue))
throw new Exception($"Expected: {expectedValue} But was: {actualValue}");
}
else
{
Assert.That(actualValue, Is.EqualTo(expectedValue));
}
}
/* If this test fails for you with
"ORA-22288: file or LOB operation FILEOPEN failed
The system cannot find the path specified."
Copy file Data\Oracle\bfile.txt to C:\DataFiles on machine with oracle server
(of course only if it is Windows machine)
*/
[Test]
public void TestDataTypes([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
TestType(conn, "\"bigintDataType\"", 1000000L);
TestType(conn, "\"numericDataType\"", 9999999m);
TestType(conn, "\"bitDataType\"", true);
TestType(conn, "\"smallintDataType\"", (short)25555);
TestType(conn, "\"decimalDataType\"", 2222222m);
TestType(conn, "\"smallmoneyDataType\"", 100000m);
TestType(conn, "\"intDataType\"", 7777777);
TestType(conn, "\"tinyintDataType\"", (sbyte)100);
TestType(conn, "\"moneyDataType\"", 100000m);
TestType(conn, "\"floatDataType\"", 20.31d);
TestType(conn, "\"realDataType\"", 16.2f);
TestType(conn, "\"datetimeDataType\"", new DateTime(2012, 12, 12, 12, 12, 12));
TestType(conn, "\"datetime2DataType\"", new DateTime(2012, 12, 12, 12, 12, 12, 012));
TestType(conn, "\"datetimeoffsetDataType\"", new DateTimeOffset(2012, 12, 12, 12, 12, 12, 12, new TimeSpan(-5, 0, 0)));
// TODO: fix timezones handling
if (!context.Contains("Native"))
{
var dt = new DateTimeOffset(2012, 12, 12, 12, 12, 12, 12, TimeSpan.Zero);
TestType(conn, "\"localZoneDataType\"", new DateTimeOffset(2012, 12, 12, 12, 12, 12, 12, TimeZoneInfo.Local.GetUtcOffset(dt) /* new TimeSpan(-4, 0, 0)*/), throwException:true);
}
TestType(conn, "\"charDataType\"", '1');
TestType(conn, "\"varcharDataType\"", "234");
TestType(conn, "\"textDataType\"", "567");
TestType(conn, "\"ncharDataType\"", "23233");
TestType(conn, "\"nvarcharDataType\"", "3323");
TestType(conn, "\"ntextDataType\"", "111");
TestType(conn, "\"binaryDataType\"", new byte[] { 0, 170 });
#if !AZURE
// TODO: configure test file in docker image
TestType(conn, "\"bfileDataType\"", new byte[] { 49, 50, 51, 52, 53 });
#endif
var res = "<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>";
TestType(conn, "XMLSERIALIZE(DOCUMENT \"xmlDataType\" AS CLOB NO INDENT)", res);
}
}
void TestNumeric<T>(DataConnection conn, T expectedValue, DataType dataType, string skip = "")
{
var skipTypes = skip.Split(' ');
foreach (var sqlType in new[]
{
"number",
"number(10,0)",
"number(20,0)",
"binary_float",
"binary_double"
}.Except(skipTypes))
{
var sqlValue = expectedValue is bool ? (bool)(object)expectedValue? 1 : 0 : (object?)expectedValue;
var sql = string.Format(CultureInfo.InvariantCulture, "SELECT Cast({0} as {1}) FROM sys.dual", sqlValue ?? "NULL", sqlType);
Debug.WriteLine(sql + " -> " + typeof(T));
Assert.That(conn.Execute<T>(sql), Is.EqualTo(expectedValue));
}
Debug.WriteLine("{0} -> DataType.{1}", typeof(T), dataType);
Assert.That(conn.Execute<T>(PathThroughSql, new DataParameter { Name = "p", DataType = dataType, Value = expectedValue }), Is.EqualTo(expectedValue));
Debug.WriteLine("{0} -> auto", typeof(T));
Assert.That(conn.Execute<T>(PathThroughSql, new DataParameter { Name = "p", Value = expectedValue }), Is.EqualTo(expectedValue));
Debug.WriteLine("{0} -> new", typeof(T));
Assert.That(conn.Execute<T>(PathThroughSql, new { p = expectedValue }), Is.EqualTo(expectedValue));
}
void TestSimple<T>(DataConnection conn, T expectedValue, DataType dataType)
where T : struct
{
TestNumeric<T> (conn, expectedValue, dataType);
TestNumeric<T?>(conn, expectedValue, dataType);
TestNumeric<T?>(conn, (T?)null, dataType);
}
[Test]
public void TestNumerics([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
TestSimple<bool> (conn, true, DataType.Boolean);
TestSimple<sbyte> (conn, 1, DataType.SByte);
TestSimple<short> (conn, 1, DataType.Int16);
TestSimple<int> (conn, 1, DataType.Int32);
TestSimple<long> (conn, 1L, DataType.Int64);
TestSimple<byte> (conn, 1, DataType.Byte);
TestSimple<ushort> (conn, 1, DataType.UInt16);
TestSimple<uint> (conn, 1u, DataType.UInt32);
TestSimple<ulong> (conn, 1ul, DataType.UInt64);
TestSimple<float> (conn, 1, DataType.Single);
TestSimple<double> (conn, 1d, DataType.Double);
TestSimple<decimal>(conn, 1m, DataType.Decimal);
TestSimple<decimal>(conn, 1m, DataType.VarNumeric);
TestSimple<decimal>(conn, 1m, DataType.Money);
TestSimple<decimal>(conn, 1m, DataType.SmallMoney);
TestNumeric(conn, sbyte.MinValue, DataType.SByte);
TestNumeric(conn, sbyte.MaxValue, DataType.SByte);
TestNumeric(conn, short.MinValue, DataType.Int16);
TestNumeric(conn, short.MaxValue, DataType.Int16);
TestNumeric(conn, int.MinValue, DataType.Int32);
TestNumeric(conn, int.MaxValue, DataType.Int32, "binary_float");
TestNumeric(conn, long.MinValue, DataType.Int64, "number(10,0)");
TestNumeric(conn, long.MaxValue, DataType.Int64, "number(10,0) binary_float binary_double");
TestNumeric(conn, byte.MaxValue, DataType.Byte, "");
TestNumeric(conn, ushort.MaxValue, DataType.UInt16, "");
TestNumeric(conn, uint.MaxValue, DataType.UInt32, "binary_float");
TestNumeric(conn, ulong.MaxValue, DataType.UInt64, "number(10,0) binary_float binary_double");
TestNumeric(conn, -3.4E+28f, DataType.Single, "number number(10,0) number(20,0)");
TestNumeric(conn, +3.4E+28f, DataType.Single, "number number(10,0) number(20,0)");
TestNumeric(conn, decimal.MinValue, DataType.Decimal, "number(10,0) number(20,0) binary_float binary_double");
TestNumeric(conn, decimal.MaxValue, DataType.Decimal, "number(10,0) number(20,0) binary_float binary_double");
TestNumeric(conn, decimal.MinValue, DataType.VarNumeric, "number(10,0) number(20,0) binary_float binary_double");
TestNumeric(conn, decimal.MaxValue, DataType.VarNumeric, "number(10,0) number(20,0) binary_float binary_double");
TestNumeric(conn, -922337203685477m, DataType.Money, "number(10,0) binary_float");
TestNumeric(conn, +922337203685477m, DataType.Money, "number(10,0) binary_float");
TestNumeric(conn, -214748m, DataType.SmallMoney);
TestNumeric(conn, +214748m, DataType.SmallMoney);
}
}
[Test]
public void TestDate([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var dateTime = new DateTime(2012, 12, 12);
Assert.That(conn.Execute<DateTime> (PathThroughSql, DataParameter.Date("p", dateTime)), Is.EqualTo(dateTime));
Assert.That(conn.Execute<DateTime?>(PathThroughSql, new DataParameter("p", dateTime, DataType.Date)), Is.EqualTo(dateTime));
}
}
[Test]
public void TestSmallDateTime([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var dateTime = new DateTime(2012, 12, 12, 12, 12, 00);
Assert.That(conn.Execute<DateTime> (PathThroughSql, DataParameter.SmallDateTime("p", dateTime)), Is.EqualTo(dateTime));
Assert.That(conn.Execute<DateTime?>(PathThroughSql, new DataParameter("p", dateTime, DataType.SmallDateTime)), Is.EqualTo(dateTime));
}
}
[Test]
public void TestDateTime([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var dateTime = new DateTime(2012, 12, 12, 12, 12, 12);
Assert.That(conn.Execute<DateTime> ("SELECT to_date('2012-12-12 12:12:12', 'YYYY-MM-DD HH:MI:SS') FROM sys.dual"), Is.EqualTo(dateTime));
Assert.That(conn.Execute<DateTime?>("SELECT to_date('2012-12-12 12:12:12', 'YYYY-MM-DD HH:MI:SS') FROM sys.dual"), Is.EqualTo(dateTime));
Assert.That(conn.Execute<DateTime> (PathThroughSql, DataParameter.DateTime("p", dateTime)), Is.EqualTo(dateTime));
Assert.That(conn.Execute<DateTime?>(PathThroughSql, new DataParameter("p", dateTime)), Is.EqualTo(dateTime));
Assert.That(conn.Execute<DateTime?>(PathThroughSql, new DataParameter("p", dateTime, DataType.DateTime)), Is.EqualTo(dateTime));
}
}
[Test]
public void TestDateTime2([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var dateTime1 = new DateTime(2012, 12, 12, 12, 12, 12);
var dateTime2 = new DateTime(2012, 12, 12, 12, 12, 12, 12);
Assert.That(conn.Execute<DateTime?>("SELECT timestamp '2012-12-12 12:12:12.012' FROM sys.dual"), Is.EqualTo(dateTime2));
Assert.That(conn.Execute<DateTime> (PathThroughSql, DataParameter.DateTime2("p", dateTime2)), Is.EqualTo(dateTime2));
Assert.That(conn.Execute<DateTime> (PathThroughSql, DataParameter.Create ("p", dateTime2)), Is.EqualTo(dateTime2));
Assert.That(conn.Execute<DateTime?>(PathThroughSql, new DataParameter("p", dateTime2, DataType.DateTime2)), Is.EqualTo(dateTime2));
}
}
[Test]
public void TestDateTimeOffset([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var dto = new DateTimeOffset(2012, 12, 12, 12, 12, 12, 12, new TimeSpan(5, 0, 0));
Assert.That(conn.Execute<DateTimeOffset>(
"SELECT timestamp '2012-12-12 12:12:12.012' FROM sys.dual"),
Is.EqualTo(new DateTimeOffset(2012, 12, 12, 12, 12, 12, 12, TimeZoneInfo.Local.GetUtcOffset(new DateTime(2012, 12, 12, 12, 12, 12)))));
Assert.That(conn.Execute<DateTimeOffset?>(
"SELECT timestamp '2012-12-12 12:12:12.012' FROM sys.dual"),
Is.EqualTo(new DateTimeOffset(2012, 12, 12, 12, 12, 12, 12, TimeZoneInfo.Local.GetUtcOffset(new DateTime(2012, 12, 12, 12, 12, 12)))));
Assert.That(conn.Execute<DateTime>(
"SELECT timestamp '2012-12-12 12:12:12.012 -04:00' FROM sys.dual"),
Is.EqualTo(new DateTime(2012, 12, 12, 12, 12, 12, 12)));
Assert.That(conn.Execute<DateTime?>(
"SELECT timestamp '2012-12-12 12:12:12.012 -04:00' FROM sys.dual"),
Is.EqualTo(new DateTime(2012, 12, 12, 12, 12, 12, 12)));
Assert.That(conn.Execute<DateTimeOffset>(
"SELECT timestamp '2012-12-12 12:12:12.012 +05:00' FROM sys.dual"),
Is.EqualTo(dto));
Assert.That(conn.Execute<DateTimeOffset?>(
"SELECT timestamp '2012-12-12 12:12:12.012 +05:00' FROM sys.dual"),
Is.EqualTo(dto));
Assert.That(conn.Execute<DateTime> ("SELECT \"datetimeoffsetDataType\" FROM \"AllTypes\" WHERE ID = 1"), Is.EqualTo(default(DateTime)));
Assert.That(conn.Execute<DateTime?>("SELECT \"datetimeoffsetDataType\" FROM \"AllTypes\" WHERE ID = 1"), Is.EqualTo(default(DateTime?)));
Assert.That(conn.Execute<DateTimeOffset?>(PathThroughSql, new DataParameter("p", dto)). ToString(), Is.EqualTo(dto.ToString()));
Assert.That(conn.Execute<DateTimeOffset?>(PathThroughSql, new DataParameter("p", dto, DataType.DateTimeOffset)).ToString(), Is.EqualTo(dto.ToString()));
}
}
[Test]
public void TestChar([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<char> ("SELECT Cast('1' as char) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>("SELECT Cast('1' as char) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char> ("SELECT Cast('1' as char(1)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>("SELECT Cast('1' as char(1)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char> ("SELECT Cast('1' as varchar2(20)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>("SELECT Cast('1' as varchar2(20)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char> ("SELECT Cast('1' as nchar) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>("SELECT Cast('1' as nchar) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char> ("SELECT Cast('1' as nchar(20)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>("SELECT Cast('1' as nchar(20)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char> ("SELECT Cast('1' as nvarchar2(20)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>("SELECT Cast('1' as nvarchar2(20)) FROM sys.dual"), Is.EqualTo('1'));
Assert.That(conn.Execute<char> (PathThroughSql, DataParameter.Char ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>(PathThroughSql, DataParameter.Char ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char> (PathThroughSql, DataParameter.VarChar ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>(PathThroughSql, DataParameter.VarChar ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char> (PathThroughSql, DataParameter.NChar ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>(PathThroughSql, DataParameter.NChar ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char> (PathThroughSql, DataParameter.NVarChar("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>(PathThroughSql, DataParameter.NVarChar("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char> (PathThroughSql, DataParameter.Create ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>(PathThroughSql, DataParameter.Create ("p", '1')), Is.EqualTo('1'));
Assert.That(conn.Execute<char> (PathThroughSql, new DataParameter { Name = "p", Value = '1' }), Is.EqualTo('1'));
Assert.That(conn.Execute<char?>(PathThroughSql, new DataParameter { Name = "p", Value = '1' }), Is.EqualTo('1'));
}
}
[Test]
public void TestString([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<string>("SELECT Cast('12345' as char(20)) FROM sys.dual"), Is.EqualTo("12345"));
Assert.That(conn.Execute<string>("SELECT Cast(NULL as char(20)) FROM sys.dual"), Is.Null);
Assert.That(conn.Execute<string>("SELECT Cast('12345' as varchar2(20)) FROM sys.dual"), Is.EqualTo("12345"));
Assert.That(conn.Execute<string>("SELECT Cast(NULL as varchar2(20)) FROM sys.dual"), Is.Null);
Assert.That(conn.Execute<string>("SELECT \"textDataType\" FROM \"AllTypes\" WHERE ID = 2"), Is.EqualTo("567"));
Assert.That(conn.Execute<string>("SELECT \"textDataType\" FROM \"AllTypes\" WHERE ID = 1"), Is.Null);
Assert.That(conn.Execute<string>("SELECT Cast('12345' as nchar(20)) FROM sys.dual"), Is.EqualTo("12345"));
Assert.That(conn.Execute<string>("SELECT Cast(NULL as nchar(20)) FROM sys.dual"), Is.Null);
Assert.That(conn.Execute<string>("SELECT Cast('12345' as nvarchar2(20)) FROM sys.dual"), Is.EqualTo("12345"));
Assert.That(conn.Execute<string>("SELECT Cast(NULL as nvarchar2(20)) FROM sys.dual"), Is.Null);
Assert.That(conn.Execute<string>("SELECT \"ntextDataType\" FROM \"AllTypes\" WHERE ID = 2"), Is.EqualTo("111"));
Assert.That(conn.Execute<string>("SELECT \"ntextDataType\" FROM \"AllTypes\" WHERE ID = 1"), Is.Null);
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.Char ("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.VarChar ("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.Text ("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.NChar ("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.NVarChar("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.NText ("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.Create ("p", "123")), Is.EqualTo("123"));
Assert.That(conn.Execute<string>(PathThroughSql, DataParameter.Create("p", (string?)null)), Is.EqualTo(null));
Assert.That(conn.Execute<string>(PathThroughSql, new DataParameter { Name = "p", Value = "1" }), Is.EqualTo("1"));
}
}
[Test]
public void TestBinary([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var arr1 = new byte[] { 0x30, 0x39 };
var arr2 = new byte[] { 0, 0, 0x30, 0x39 };
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<byte[]>("SELECT to_blob('3039') FROM sys.dual"), Is.EqualTo( arr1));
Assert.That(conn.Execute<Binary>("SELECT to_blob('00003039') FROM sys.dual"), Is.EqualTo(new Binary(arr2)));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.VarBinary("p", null)), Is.EqualTo(null));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.Binary ("p", arr1)), Is.EqualTo(arr1));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.VarBinary("p", arr1)), Is.EqualTo(arr1));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.Create ("p", arr1)), Is.EqualTo(arr1));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.VarBinary("p", new byte[0])), Is.EqualTo(new byte[0]));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.Image ("p", new byte[0])), Is.EqualTo(new byte[0]));
Assert.That(conn.Execute<byte[]>(PathThroughSql, new DataParameter { Name = "p", Value = arr1 }), Is.EqualTo(arr1));
Assert.That(conn.Execute<byte[]>(PathThroughSql, DataParameter.Create ("p", new Binary(arr1))), Is.EqualTo(arr1));
Assert.That(conn.Execute<byte[]>(PathThroughSql, new DataParameter("p", new Binary(arr1))), Is.EqualTo(arr1));
}
}
[Test]
public void TestOracleManagedTypes([IncludeDataSources(TestProvName.AllOracleManaged)] string context)
{
using (var conn = new DataConnection(context))
{
var arr = new byte[] { 0x30, 0x39 };
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleBinary> ("SELECT to_blob('3039') FROM sys.dual"). Value, Is.EqualTo(arr));
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleBlob> ("SELECT to_blob('3039') FROM sys.dual"). Value, Is.EqualTo(arr));
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleDecimal> ("SELECT Cast(1 as decimal) FROM sys.dual"). Value, Is.EqualTo(1));
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleString> ("SELECT Cast('12345' as char(6)) FROM sys.dual"). Value, Is.EqualTo("12345 "));
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleClob> ("SELECT \"ntextDataType\" FROM \"AllTypes\" WHERE ID = 2").Value, Is.EqualTo("111"));
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleDate> ("SELECT \"datetimeDataType\" FROM \"AllTypes\" WHERE ID = 2").Value, Is.EqualTo(new DateTime(2012, 12, 12, 12, 12, 12)));
Assert.That(conn.Execute<Oracle.ManagedDataAccess.Types.OracleTimeStamp>("SELECT \"datetime2DataType\" FROM \"AllTypes\" WHERE ID = 2").Value, Is.EqualTo(new DateTime(2012, 12, 12, 12, 12, 12, 12)));
}
}
#if NET472
[Test]
public void TestOracleNativeTypes([IncludeDataSources(TestProvName.AllOracleNative)] string context)
{
using (var conn = new DataConnection(context))
{
var arr = new byte[] { 0x30, 0x39 };
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleBinary> ("SELECT to_blob('3039') FROM sys.dual"). Value, Is.EqualTo(arr));
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleBlob> ("SELECT to_blob('3039') FROM sys.dual"). Value, Is.EqualTo(arr));
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleDecimal> ("SELECT Cast(1 as decimal) FROM sys.dual"). Value, Is.EqualTo(1));
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleString> ("SELECT Cast('12345' as char(6)) FROM sys.dual"). Value, Is.EqualTo("12345 "));
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleClob> ("SELECT \"ntextDataType\" FROM \"AllTypes\" WHERE ID = 2").Value, Is.EqualTo("111"));
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleDate> ("SELECT \"datetimeDataType\" FROM \"AllTypes\" WHERE ID = 2").Value, Is.EqualTo(new DateTime(2012, 12, 12, 12, 12, 12)));
Assert.That(conn.Execute<Oracle.DataAccess.Types.OracleTimeStamp>("SELECT \"datetime2DataType\" FROM \"AllTypes\" WHERE ID = 2").Value, Is.EqualTo(new DateTime(2012, 12, 12, 12, 12, 12, 12)));
}
}
#endif
[Test]
public void TestGuid([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (new DisableBaseline("Server-side guid generation test"))
using (var conn = new DataConnection(context))
{
var guid = conn.Execute<Guid>("SELECT \"guidDataType\" FROM \"AllTypes\" WHERE ID = 2");
Assert.That(conn.Execute<Guid?>("SELECT \"guidDataType\" FROM \"AllTypes\" WHERE ID = 1"), Is.EqualTo(null));
Assert.That(conn.Execute<Guid?>("SELECT \"guidDataType\" FROM \"AllTypes\" WHERE ID = 2"), Is.EqualTo(guid));
Assert.That(conn.Execute<Guid>(PathThroughSql, DataParameter.Create("p", guid)), Is.EqualTo(guid));
Assert.That(conn.Execute<Guid>(PathThroughSql, new DataParameter { Name = "p", Value = guid }), Is.EqualTo(guid));
}
}
[Test]
public void TestXml([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<string> ("SELECT XMLTYPE('<xml/>') FROM sys.dual").TrimEnd(), Is.EqualTo("<xml/>"));
Assert.That(conn.Execute<XDocument> ("SELECT XMLTYPE('<xml/>') FROM sys.dual").ToString(), Is.EqualTo("<xml />"));
Assert.That(conn.Execute<XmlDocument>("SELECT XMLTYPE('<xml/>') FROM sys.dual").InnerXml, Is.EqualTo("<xml />"));
var xdoc = XDocument.Parse("<xml/>");
var xml = Convert<string,XmlDocument>.Lambda("<xml/>");
var xmlExpected = GetProviderName(context, out var _).Contains("Native") ? "<xml/>\n" : "<xml/>";
Assert.That(conn.Execute<string> (PathThroughSql, DataParameter.Xml("p", "<xml/>")), Is.EqualTo(xmlExpected));
Assert.That(conn.Execute<XDocument> (PathThroughSql, DataParameter.Xml("p", xdoc)).ToString(), Is.EqualTo("<xml />"));
Assert.That(conn.Execute<XmlDocument>(PathThroughSql, DataParameter.Xml("p", xml)). InnerXml, Is.EqualTo("<xml />"));
Assert.That(conn.Execute<XDocument> (PathThroughSql, new DataParameter("p", xdoc)).ToString(), Is.EqualTo("<xml />"));
Assert.That(conn.Execute<XDocument> (PathThroughSql, new DataParameter("p", xml)). ToString(), Is.EqualTo("<xml />"));
}
}
enum TestEnum
{
[MapValue("A")] AA,
[MapValue("B")] BB,
}
[Test]
public void TestEnum1([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<TestEnum> ("SELECT 'A' FROM sys.dual"), Is.EqualTo(TestEnum.AA));
Assert.That(conn.Execute<TestEnum?>("SELECT 'A' FROM sys.dual"), Is.EqualTo(TestEnum.AA));
Assert.That(conn.Execute<TestEnum> ("SELECT 'B' FROM sys.dual"), Is.EqualTo(TestEnum.BB));
Assert.That(conn.Execute<TestEnum?>("SELECT 'B' FROM sys.dual"), Is.EqualTo(TestEnum.BB));
}
}
[Test]
public void TestEnum2([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
Assert.That(conn.Execute<string>(PathThroughSql, new { p = TestEnum.AA }), Is.EqualTo("A"));
Assert.That(conn.Execute<string>(PathThroughSql, new { p = (TestEnum?)TestEnum.BB }), Is.EqualTo("B"));
Assert.That(conn.Execute<string>(PathThroughSql, new { p = ConvertTo<string>.From((TestEnum?)TestEnum.AA) }), Is.EqualTo("A"));
Assert.That(conn.Execute<string>(PathThroughSql, new { p = ConvertTo<string>.From(TestEnum.AA) }), Is.EqualTo("A"));
Assert.That(conn.Execute<string>(PathThroughSql, new { p = conn.MappingSchema.GetConverter<TestEnum?,string>()!(TestEnum.AA) }), Is.EqualTo("A"));
}
}
[Test]
public void TestTreatEmptyStringsAsNulls([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
var table = db.GetTable<OracleSpecific.StringTest>();
var expected = table.Where(_ => _.KeyValue == "NullValues").ToList();
AreEqual(expected, table.Where(_ => string.IsNullOrEmpty(_.StringValue1)));
AreEqual(expected, table.Where(_ => string.IsNullOrEmpty(_.StringValue2)));
AreEqual(expected, table.Where(_ => _.StringValue1 == ""));
AreEqual(expected, table.Where(_ => _.StringValue2 == ""));
AreEqual(expected, table.Where(_ => _.StringValue1 == null));
AreEqual(expected, table.Where(_ => _.StringValue2 == null));
string emptyString = string.Empty;
string? nullString = null;
AreEqual(expected, table.Where(_ => _.StringValue1 == emptyString));
AreEqual(expected, table.Where(_ => _.StringValue2 == emptyString));
AreEqual(expected, table.Where(_ => _.StringValue1 == nullString));
AreEqual(expected, table.Where(_ => _.StringValue2 == nullString));
AreEqual(expected, GetStringTest1(db, emptyString));
AreEqual(expected, GetStringTest1(db, emptyString));
AreEqual(expected, GetStringTest2(db, emptyString));
AreEqual(expected, GetStringTest2(db, emptyString));
AreEqual(expected, GetStringTest1(db, nullString));
AreEqual(expected, GetStringTest1(db, nullString));
AreEqual(expected, GetStringTest2(db, nullString));
AreEqual(expected, GetStringTest2(db, nullString));
}
}
private IEnumerable<OracleSpecific.StringTest> GetStringTest1(IDataContext db, string? value)
{
return db.GetTable<OracleSpecific.StringTest>()
.Where(_ => value == _.StringValue1);
}
private IEnumerable<OracleSpecific.StringTest> GetStringTest2(IDataContext db, string? value)
{
return db.GetTable<OracleSpecific.StringTest>()
.Where(_ => value == _.StringValue2);
}
#region DateTime Tests
[Table]
public partial class AllTypes
{
[Column(DataType=DataType.Decimal, Length=22, Scale=0), PrimaryKey, NotNull] public decimal ID { get; set; } // NUMBER
[Column(DataType=DataType.Decimal, Length=22, Precision=20, Scale=0), Nullable ] public decimal? bigintDataType { get; set; } // NUMBER (20,0)
[Column(DataType=DataType.Decimal, Length=22, Scale=0), Nullable ] public decimal? numericDataType { get; set; } // NUMBER
[Column(DataType=DataType.Decimal, Length=22, Precision=1, Scale=0), Nullable ] public sbyte? bitDataType { get; set; } // NUMBER (1,0)
[Column(DataType=DataType.Decimal, Length=22, Precision=5, Scale=0), Nullable ] public int? smallintDataType { get; set; } // NUMBER (5,0)
[Column(DataType=DataType.Decimal, Length=22, Scale=6), Nullable ] public decimal? decimalDataType { get; set; } // NUMBER
[Column(DataType=DataType.Decimal, Length=22, Precision=10, Scale=4), Nullable ] public decimal? smallmoneyDataType { get; set; } // NUMBER (10,4)
[Column(DataType=DataType.Decimal, Length=22, Precision=10, Scale=0), Nullable ] public long? intDataType { get; set; } // NUMBER (10,0)
[Column(DataType=DataType.Decimal, Length=22, Precision=3, Scale=0), Nullable ] public short? tinyintDataType { get; set; } // NUMBER (3,0)
[Column(DataType=DataType.Decimal, Length=22), Nullable ] public decimal? moneyDataType { get; set; } // NUMBER
[Column(DataType=DataType.Double, Length=8), Nullable ] public double? floatDataType { get; set; } // BINARY_DOUBLE
[Column(DataType=DataType.Single, Length=4), Nullable ] public float? realDataType { get; set; } // BINARY_FLOAT
[Column(DataType=DataType.Date), Nullable ] public DateTime? datetimeDataType { get; set; } // DATE
[Column(DataType=DataType.DateTime2, Length=11, Scale=6), Nullable ] public DateTime? datetime2DataType { get; set; } // TIMESTAMP(6)
[Column(DataType=DataType.DateTimeOffset, Length=13, Scale=6), Nullable ] public DateTimeOffset? datetimeoffsetDataType { get; set; } // TIMESTAMP(6) WITH TIME ZONE
[Column(DataType=DataType.DateTimeOffset, Length=11, Scale=6), Nullable ] public DateTimeOffset? localZoneDataType { get; set; } // TIMESTAMP(6) WITH LOCAL TIME ZONE
[Column(DataType=DataType.Char, Length=1), Nullable ] public char? charDataType { get; set; } // CHAR(1)
[Column(DataType=DataType.VarChar, Length=20), Nullable ] public string? varcharDataType { get; set; } // VARCHAR2(20)
[Column(DataType=DataType.Text, Length=4000), Nullable ] public string? textDataType { get; set; } // CLOB
[Column(DataType=DataType.NChar, Length=40), Nullable ] public string? ncharDataType { get; set; } // NCHAR(40)
[Column(DataType=DataType.NVarChar, Length=40), Nullable ] public string? nvarcharDataType { get; set; } // NVARCHAR2(40)
[Column(DataType=DataType.NText, Length=4000), Nullable ] public string? ntextDataType { get; set; } // NCLOB
[Column(DataType=DataType.Blob, Length=4000), Nullable ] public byte[]? binaryDataType { get; set; } // BLOB
[Column(DataType=DataType.VarBinary, Length=530), Nullable ] public byte[]? bfileDataType { get; set; } // BFILE
[Column(DataType=DataType.Binary, Length=16), Nullable ] public byte[]? guidDataType { get; set; } // RAW(16)
[Column(DataType=DataType.Long), Nullable ] public string? longDataType { get; set; } // LONG
[Column(DataType=DataType.Undefined, Length=256), Nullable ] public object? uriDataType { get; set; } // URITYPE
[Column(DataType=DataType.Xml, Length=2000), Nullable ] public string? xmlDataType { get; set; } // XMLTYPE
}
[Table("t_entity")]
public sealed class Entity
{
[PrimaryKey, Identity]
[NotNull, Column("entity_id")] public long Id { get; set; }
[NotNull, Column("time")] public DateTime Time { get; set; }
[NotNull, Column("duration")] public TimeSpan Duration { get; set; }
}
[Test]
public void TestTimeSpan([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
{
db.BeginTransaction();
long id = 1;
db.GetTable<Entity>().Insert(() => new Entity { Id = id + 1, Duration = TimeSpan.FromHours(1) });
}
}
[Test]
public void DateTimeTest1([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
{
db.GetTable<AllTypes>().Delete(t => t.ID >= 1000);
using (db.BeginTransaction())
{
db.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.MultipleRows },
new[]
{
new AllTypes
{
ID = 1000,
datetimeDataType = TestData.DateTime,
datetime2DataType = TestData.DateTime
}
});
}
}
}
[Test]
public async Task DateTimeTest1Async([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
{
db.GetTable<AllTypes>().Delete(t => t.ID >= 1000);
using (db.BeginTransaction())
{
await db.BulkCopyAsync(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.MultipleRows },
new[]
{
new AllTypes
{
ID = 1000,
datetimeDataType = TestData.DateTime,
datetime2DataType = TestData.DateTime
}
});
}
}
}
[Test]
public void NVarchar2InsertTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
using (db.BeginTransaction())
{
db.InlineParameters = false;
var value = "致我们最爱的母亲";
var id = db.GetTable<AllTypes>()
.InsertWithInt32Identity(() => new AllTypes
{
nvarcharDataType = value
});
var query = from p in db.GetTable<AllTypes>()
where p.ID == id
select new { p.nvarcharDataType };
var res = query.Single();
Assert.That(res.nvarcharDataType, Is.EqualTo(value));
}
}
[Test]
public void NVarchar2UpdateTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
using (db.BeginTransaction())
{
db.InlineParameters = false;
var value = "致我们最爱的母亲";
var id = db.GetTable<AllTypes>()
.InsertWithInt32Identity(() => new AllTypes
{
intDataType = 123
});
db.GetTable<AllTypes>()
.Set(e => e.nvarcharDataType, () => value)
.Update();
var query = from p in db.GetTable<AllTypes>()
where p.ID == id
select new { p.nvarcharDataType };
var res = query.Single();
Assert.That(res.nvarcharDataType, Is.EqualTo(value));
}
}
[Test]
public void SelectDateTime([IncludeDataSources(TestProvName.AllOracleNative)] string context)
{
using (var db = new DataConnection(context))
{
var ms = new MappingSchema();
// Set custom DateTime to SQL converter.
//
ms.SetValueToSqlConverter(
typeof(DateTime),
(stringBuilder, dataType, val) =>
{
var value = (DateTime)val;
Assert.That(dataType.Type.DataType, Is.Not.EqualTo(DataType.Undefined));
var format =
dataType.Type.DataType == DataType.DateTime2 ?
"TO_DATE('{0:yyyy-MM-dd HH:mm:ss}', 'YYYY-MM-DD HH24:MI:SS')" :
"TO_TIMESTAMP('{0:yyyy-MM-dd HH:mm:ss.fffffff}', 'YYYY-MM-DD HH24:MI:SS.FF7')";
stringBuilder.AppendFormat(format, value);
});
db.AddMappingSchema(ms);
var res = db.GetTable<AllTypes>().Where(e => e.datetime2DataType == TestData.DateTime).ToList();
Debug.WriteLine(res.Count);
}
}
[Test]
public void DateTimeTest2([IncludeDataSources(TestProvName.AllOracle)] string context)
{
// Set custom DateTime to SQL converter.
//
var ms = new MappingSchema();
ms.SetValueToSqlConverter(
typeof(DateTime),
(stringBuilder,dataType,val) =>
{
var value = (DateTime)val;
var format =
dataType.Type.DataType == DataType.DateTime ?
"TO_DATE('{0:yyyy-MM-dd HH:mm:ss}', 'YYYY-MM-DD HH24:MI:SS')" :
"TO_TIMESTAMP('{0:yyyy-MM-dd HH:mm:ss.fffffff}', 'YYYY-MM-DD HH24:MI:SS.FF7')";
stringBuilder.AppendFormat(format, value);
});
using (var db = new DataConnection(context, ms))
{
db.GetTable<AllTypes>().Delete(t => t.ID >= 1000);
using (db.BeginTransaction())
{
db.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.MultipleRows },
new[]
{
new AllTypes
{
ID = 1000,
datetimeDataType = TestData.DateTime,
datetime2DataType = TestData.DateTime
}
});
}
}
}
[Test]
public async Task DateTimeTest2Async([IncludeDataSources(TestProvName.AllOracle)] string context)
{
// Set custom DateTime to SQL converter.
//
var ms = new MappingSchema();
ms.SetValueToSqlConverter(
typeof(DateTime),
(stringBuilder, dataType, val) =>
{
var value = (DateTime)val;
var format =
dataType.Type.DataType == DataType.DateTime ?
"TO_DATE('{0:yyyy-MM-dd HH:mm:ss}', 'YYYY-MM-DD HH24:MI:SS')" :
"TO_TIMESTAMP('{0:yyyy-MM-dd HH:mm:ss.fffffff}', 'YYYY-MM-DD HH24:MI:SS.FF7')";
stringBuilder.AppendFormat(format, value);
});
using (var db = new DataConnection(context, ms))
{
db.GetTable<AllTypes>().Delete(t => t.ID >= 1000);
using (db.BeginTransaction())
{
await db.BulkCopyAsync(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.MultipleRows },
new[]
{
new AllTypes
{
ID = 1000,
datetimeDataType = TestData.DateTime,
datetime2DataType = TestData.DateTime
}
});
}
}
}
[Test]
public void ClauseDateTimeWithoutJointure([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var date = TestData.Date;
using (var db = new DataConnection(context))
{
var query = from a in db.GetTable<AllTypes>()
where a.datetimeDataType == date
select a;
query.FirstOrDefault();
Assert.That(db.Command.Parameters.Count, Is.EqualTo(2));
var parm = (IDbDataParameter)db.Command.Parameters[0]!;
Assert.That(parm.DbType, Is.EqualTo(DbType.Date));
}
}
[Test]
public void ClauseDateTimeWithJointure([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var date = TestData.Date;
using (var db = new DataConnection(context))
{
var query = from a in db.GetTable<AllTypes>()
join b in db.GetTable<AllTypes>() on a.ID equals b.ID
where a.datetimeDataType == date
select a;
query.FirstOrDefault();
Assert.That(db.Command.Parameters.Count, Is.EqualTo(2));
var parm = (IDbDataParameter)db.Command.Parameters[0]!;
Assert.That(parm.DbType, Is.EqualTo(DbType.Date));
}
}
#endregion
#region Sequence
[Test]
public void SequenceInsert([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
db.GetTable<OracleSpecific.SequenceTest>().Where(_ => _.Value == "SeqValue").Delete();
db.Insert(new OracleSpecific.SequenceTest { Value = "SeqValue" });
var id = db.GetTable<OracleSpecific.SequenceTest>().Single(_ => _.Value == "SeqValue").ID;
db.GetTable<OracleSpecific.SequenceTest>().Where(_ => _.ID == id).Delete();
Assert.AreEqual(0, db.GetTable<OracleSpecific.SequenceTest>().Count(_ => _.Value == "SeqValue"));
}
}
[Test]
public void SequenceInsertWithIdentity([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
db.GetTable<OracleSpecific.SequenceTest>().Where(_ => _.Value == "SeqValue").Delete();
var id1 = Convert.ToInt32(db.InsertWithIdentity(new OracleSpecific.SequenceTest { Value = "SeqValue" }));
var id2 = db.GetTable<OracleSpecific.SequenceTest>().Single(_ => _.Value == "SeqValue").ID;
Assert.AreEqual(id1, id2);
db.GetTable<OracleSpecific.SequenceTest>().Where(_ => _.ID == id1).Delete();
Assert.AreEqual(0, db.GetTable<OracleSpecific.SequenceTest>().Count(_ => _.Value == "SeqValue"));
}
}
#endregion
#region BulkCopy
void BulkCopyLinqTypes(string context, BulkCopyType bulkCopyType)
{
using (var db = new DataConnection(context))
{
if (bulkCopyType == BulkCopyType.ProviderSpecific)
{
var ms = new MappingSchema();
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypes>()
.Property(e => e.GuidValue)
.IsNotColumn()
;
if (GetProviderName(context, out var _).Contains("Native"))
{
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypes>()
.Property(e => e.BoolValue)
.HasDataType(DataType.Int16)
;
}
db.AddMappingSchema(ms);
}
try
{
db.BulkCopy(
new BulkCopyOptions { BulkCopyType = bulkCopyType },
Enumerable.Range(0, 10).Select(n =>
new LinqDataTypes
{
ID = 4000 + n,
MoneyValue = 1000m + n,
DateTimeValue = new DateTime(2001, 1, 11, 1, 11, 21, 100),
BoolValue = true,
GuidValue = TestData.SequentialGuid(n),
SmallIntValue = (short)n
}
));
}
finally
{
db.GetTable<LinqDataTypes>().Delete(p => p.ID >= 4000);
}
}
}
async Task BulkCopyLinqTypesAsync(string context, BulkCopyType bulkCopyType)
{
using (var db = new DataConnection(context))
{
if (bulkCopyType == BulkCopyType.ProviderSpecific)
{
var ms = new MappingSchema();
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypes>()
.Property(e => e.GuidValue)
.IsNotColumn()
;
if (GetProviderName(context, out var _).Contains("Native"))
{
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypes>()
.Property(e => e.BoolValue)
.HasDataType(DataType.Int16)
;
}
db.AddMappingSchema(ms);
}
try
{
await db.BulkCopyAsync(
new BulkCopyOptions { BulkCopyType = bulkCopyType },
Enumerable.Range(0, 10).Select(n =>
new LinqDataTypes
{
ID = 4000 + n,
MoneyValue = 1000m + n,
DateTimeValue = new DateTime(2001, 1, 11, 1, 11, 21, 100),
BoolValue = true,
GuidValue = TestData.SequentialGuid(n),
SmallIntValue = (short)n
}
));
}
finally
{
await db.GetTable<LinqDataTypes>().DeleteAsync(p => p.ID >= 4000);
}
}
}
[Test]
public void BulkCopyLinqTypesMultipleRows(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopyLinqTypes(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopyLinqTypesMultipleRowsAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopyLinqTypesAsync(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopyLinqTypesProviderSpecific(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopyLinqTypes(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopyLinqTypesProviderSpecificAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopyLinqTypesAsync(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopyRetrieveSequencesProviderSpecific(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopyRetrieveSequence(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopyRetrieveSequencesProviderSpecificAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopyRetrieveSequenceAsync(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopyRetrieveSequencesMultipleRows(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopyRetrieveSequence(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopyRetrieveSequencesMultipleRowsAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopyRetrieveSequenceAsync(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopyRetrieveSequencesRowByRow(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopyRetrieveSequence(context, BulkCopyType.RowByRow);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopyRetrieveSequencesRowByRowAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopyRetrieveSequenceAsync(context, BulkCopyType.RowByRow);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
static void BulkCopyRetrieveSequence(string context, BulkCopyType bulkCopyType)
{
var data = new[]
{
new OracleSpecific.SequenceTest { Value = "Value"},
new OracleSpecific.SequenceTest { Value = "Value"},
new OracleSpecific.SequenceTest { Value = "Value"},
new OracleSpecific.SequenceTest { Value = "Value"},
};
using (var db = new TestDataConnection(context))
{
db.GetTable<OracleSpecific.SequenceTest>().Where(_ => _.Value == "SeqValue").Delete();
var options = new BulkCopyOptions
{
MaxBatchSize = 5,
//RetrieveSequence = true,
KeepIdentity = bulkCopyType != BulkCopyType.RowByRow,
BulkCopyType = bulkCopyType,
NotifyAfter = 3,
RowsCopiedCallback = copied => Debug.WriteLine(copied.RowsCopied)
};
db.BulkCopy(options, data.RetrieveIdentity(db));
foreach (var d in data)
{
Assert.That(d.ID, Is.GreaterThan(0));
}
//Assert.That(options.BulkCopyType, Is.EqualTo(bulkCopyType));
}
}
static async Task BulkCopyRetrieveSequenceAsync(string context, BulkCopyType bulkCopyType)
{
var data = new[]
{
new OracleSpecific.SequenceTest { Value = "Value"},
new OracleSpecific.SequenceTest { Value = "Value"},
new OracleSpecific.SequenceTest { Value = "Value"},
new OracleSpecific.SequenceTest { Value = "Value"},
};
using (var db = new TestDataConnection(context))
{
db.GetTable<OracleSpecific.SequenceTest>().Where(_ => _.Value == "SeqValue").Delete();
var options = new BulkCopyOptions
{
MaxBatchSize = 5,
//RetrieveSequence = true,
KeepIdentity = bulkCopyType != BulkCopyType.RowByRow,
BulkCopyType = bulkCopyType,
NotifyAfter = 3,
RowsCopiedCallback = copied => Debug.WriteLine(copied.RowsCopied)
};
await db.BulkCopyAsync(options, data.RetrieveIdentity(db));
foreach (var d in data)
{
Assert.That(d.ID, Is.GreaterThan(0));
}
//Assert.That(options.BulkCopyType, Is.EqualTo(bulkCopyType));
}
}
[Table(Name = "STG_TRADE_INFORMATION")]
public class Trade
{
[Column("STG_TRADE_ID")] public int ID { get; set; }
[Column("STG_TRADE_VERSION")] public int Version { get; set; }
[Column("INFORMATION_TYPE_ID")] public int TypeID { get; set; }
[Column("INFORMATION_TYPE_NAME")] public string? TypeName { get; set; }
[Column("VALUE")] public string? Value { get; set; }
[Column("VALUE_AS_INTEGER")] public int? ValueAsInteger { get; set; }
[Column("VALUE_AS_DATE")] public DateTime? ValueAsDate { get; set; }
}
static void BulkCopy1(string context, BulkCopyType bulkCopyType)
{
var data = new[]
{
new Trade { ID = 375, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 328, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 348, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 357, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 371, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 333, Version = 1, TypeID = 20224, TypeName = "Gas Month", ValueAsInteger = 1, ValueAsDate = new DateTime(2011, 1, 5) },
new Trade { ID = 353, Version = 1, TypeID = 20224, TypeName = "Gas Month", ValueAsInteger = 1000000000, },
new Trade { ID = 973, Version = 1, TypeID = 20160, TypeName = "EU Allowances", },
};
using (var db = new TestDataConnection(context))
{
var options = new BulkCopyOptions
{
MaxBatchSize = 5,
BulkCopyType = bulkCopyType,
NotifyAfter = 3,
RowsCopiedCallback = copied => Debug.WriteLine(copied.RowsCopied)
};
db.BulkCopy(options, data);
//Assert.That(options.BulkCopyType, Is.EqualTo(bulkCopyType));
}
}
static async Task BulkCopy1Async(string context, BulkCopyType bulkCopyType)
{
var data = new[]
{
new Trade { ID = 375, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 328, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 348, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 357, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 371, Version = 1, TypeID = 20224, TypeName = "Gas Month", },
new Trade { ID = 333, Version = 1, TypeID = 20224, TypeName = "Gas Month", ValueAsInteger = 1, ValueAsDate = new DateTime(2011, 1, 5) },
new Trade { ID = 353, Version = 1, TypeID = 20224, TypeName = "Gas Month", ValueAsInteger = 1000000000, },
new Trade { ID = 973, Version = 1, TypeID = 20160, TypeName = "EU Allowances", },
};
using (var db = new TestDataConnection(context))
{
var options = new BulkCopyOptions
{
MaxBatchSize = 5,
BulkCopyType = bulkCopyType,
NotifyAfter = 3,
RowsCopiedCallback = copied => Debug.WriteLine(copied.RowsCopied)
};
await db.BulkCopyAsync(options, data);
//Assert.That(options.BulkCopyType, Is.EqualTo(bulkCopyType));
}
}
[Test]
public void BulkCopy1MultipleRows(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopy1(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopy1MultipleRowsAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopy1Async(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopy1ProviderSpecific(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopy1(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopy1ProviderSpecificAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopy1Async(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
// we use copy of table with all-uppercase names to be able to use it with native
// bulk copy with ODP.NET provider
[Table("LINQDATATYPESBC")]
public class LinqDataTypesBC
{
[PrimaryKey] public int ID;
[Column("MONEYVALUE")] public decimal MoneyValue;
[Column("DATETIMEVALUE", DataType = DataType.DateTime2)] public DateTime? DateTimeValue;
[Column("DATETIMEVALUE2")] public DateTime? DateTimeValue2;
[Column("BOOLVALUE", DataType = DataType.Int16)] public bool? BoolValue;
[Column("GUIDVALUE")] public Guid? GuidValue;
[Column("SMALLINTVALUE")] public short? SmallIntValue;
[Column("INTVALUE")] public int? IntValue;
[Column("BIGINTVALUE")] public long? BigIntValue;
[Column("STRINGVALUE")] public string? StringValue;
}
static void BulkCopy21(string context, BulkCopyType bulkCopyType)
{
using (var db = new TestDataConnection(context))
{
db.GetTable<LinqDataTypesBC>().Delete();
if (context.Contains("Native") && bulkCopyType == BulkCopyType.ProviderSpecific)
{
var ms = new MappingSchema();
db.AddMappingSchema(ms);
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypesBC>()
.Property(e => e.GuidValue)
.IsNotColumn()
;
}
try
{
db.BulkCopy(
new BulkCopyOptions { MaxBatchSize = 2, BulkCopyType = bulkCopyType },
new[]
{
new LinqDataTypesBC { ID = 1003, MoneyValue = 0m, DateTimeValue = null, BoolValue = true, GuidValue = new Guid("ef129165-6ffe-4df9-bb6b-bb16e413c883"), SmallIntValue = null, IntValue = null },
new LinqDataTypesBC { ID = 1004, MoneyValue = 0m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 2, IntValue = 1532334 },
new LinqDataTypesBC { ID = 1005, MoneyValue = 1m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 5, IntValue = null },
new LinqDataTypesBC { ID = 1006, MoneyValue = 2m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 6, IntValue = 153 }
});
}
finally
{
db.GetTable<LinqDataTypesBC>().Delete();
}
}
}
static async Task BulkCopy21Async(string context, BulkCopyType bulkCopyType)
{
using (var db = new TestDataConnection(context))
{
db.GetTable<LinqDataTypesBC>().Delete();
if (context.Contains("Native") && bulkCopyType == BulkCopyType.ProviderSpecific)
{
var ms = new MappingSchema();
db.AddMappingSchema(ms);
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypesBC>()
.Property(e => e.GuidValue)
.IsNotColumn()
;
}
try
{
await db.BulkCopyAsync(
new BulkCopyOptions { MaxBatchSize = 2, BulkCopyType = bulkCopyType },
new[]
{
new LinqDataTypesBC { ID = 1003, MoneyValue = 0m, DateTimeValue = null, BoolValue = true, GuidValue = new Guid("ef129165-6ffe-4df9-bb6b-bb16e413c883"), SmallIntValue = null, IntValue = null },
new LinqDataTypesBC { ID = 1004, MoneyValue = 0m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 2, IntValue = 1532334 },
new LinqDataTypesBC { ID = 1005, MoneyValue = 1m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 5, IntValue = null },
new LinqDataTypesBC { ID = 1006, MoneyValue = 2m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 6, IntValue = 153 }
});
}
finally
{
db.GetTable<LinqDataTypesBC>().Delete();
}
}
}
[Test]
public void BulkCopy21MultipleRows(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopy21(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopy21MultipleRowsAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopy21Async(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopy21ProviderSpecific(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopy21(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopy21ProviderSpecificAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopy21Async(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
static void BulkCopy22(string context, BulkCopyType bulkCopyType)
{
using (var db = new TestDataConnection(context))
{
db.Types2.Delete(_ => _.ID > 1000);
var ms = new MappingSchema();
db.AddMappingSchema(ms);
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypes2>()
.Property(e => e.GuidValue)
.IsNotColumn()
;
try
{
db.BulkCopy(
new BulkCopyOptions { MaxBatchSize = 2, BulkCopyType = bulkCopyType },
new[]
{
new LinqDataTypes2 { ID = 1003, MoneyValue = 0m, DateTimeValue = TestData.DateTime, BoolValue = true, GuidValue = new Guid("ef129165-6ffe-4df9-bb6b-bb16e413c883"), SmallIntValue = null, IntValue = null },
new LinqDataTypes2 { ID = 1004, MoneyValue = 0m, DateTimeValue = null, BoolValue = false, GuidValue = null, SmallIntValue = 2, IntValue = 1532334 },
new LinqDataTypes2 { ID = 1005, MoneyValue = 1m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 5, IntValue = null },
new LinqDataTypes2 { ID = 1006, MoneyValue = 2m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 6, IntValue = 153 }
});
}
finally
{
db.Types2.Delete(_ => _.ID > 1000);
}
}
}
static async Task BulkCopy22Async(string context, BulkCopyType bulkCopyType)
{
using (var db = new TestDataConnection(context))
{
db.Types2.Delete(_ => _.ID > 1000);
var ms = new MappingSchema();
db.AddMappingSchema(ms);
ms.GetFluentMappingBuilder()
.Entity<LinqDataTypes2>()
.Property(e => e.GuidValue)
.IsNotColumn()
;
try
{
await db.BulkCopyAsync(
new BulkCopyOptions { MaxBatchSize = 2, BulkCopyType = bulkCopyType },
new[]
{
new LinqDataTypes2 { ID = 1003, MoneyValue = 0m, DateTimeValue = TestData.DateTime, BoolValue = true, GuidValue = new Guid("ef129165-6ffe-4df9-bb6b-bb16e413c883"), SmallIntValue = null, IntValue = null },
new LinqDataTypes2 { ID = 1004, MoneyValue = 0m, DateTimeValue = null, BoolValue = false, GuidValue = null, SmallIntValue = 2, IntValue = 1532334 },
new LinqDataTypes2 { ID = 1005, MoneyValue = 1m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 5, IntValue = null },
new LinqDataTypes2 { ID = 1006, MoneyValue = 2m, DateTimeValue = TestData.DateTime, BoolValue = false, GuidValue = null, SmallIntValue = 6, IntValue = 153 }
});
}
finally
{
await db.Types2.DeleteAsync(_ => _.ID > 1000);
}
}
}
[Test]
public void BulkCopy22MultipleRows(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopy22(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopy22MultipleRowsAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopy22Async(context, BulkCopyType.MultipleRows);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public void BulkCopy22ProviderSpecific(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
BulkCopy22(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
[Test]
public async Task BulkCopy22ProviderSpecificAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
try
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
await BulkCopy22Async(context, BulkCopyType.ProviderSpecific);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
}
}
#endregion
#region CreateTest
[Table]
class TempTestTable
{
// column name length = 30 char (maximum for Oracle)
[Column(Name = "AAAAAAAAAAAAAAAAAAAAAAAAAAAABC")]
public long Id { get; set; }
}
[Test]
public void LongAliasTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
{
try { db.DropTable<TempTestTable>(); } catch {}
var table = db.CreateTable<TempTestTable>();
var query =
(
from t in table.Distinct()
select new { t.Id }
).ToList();
db.DropTable<TempTestTable>();
}
}
#endregion
#region XmlTable
[Test]
public void XmlTableTest1([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var list = conn.OracleXmlTable(new[]
{
new { field1 = 1, field2 = "11" },
new { field1 = 2, field2 = "22" },
})
.Select(t => new { t.field1, t.field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].field1, Is.EqualTo(1));
Assert.That(list[1].field1, Is.EqualTo(2));
Assert.That(list[0].field2, Is.EqualTo("11"));
Assert.That(list[1].field2, Is.EqualTo("22"));
}
}
[Test]
public void XmlTableTest2([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = GetDataContext(context))
{
var list =
(
from t1 in conn.Parent
join t2 in conn.OracleXmlTable(new[]
{
new { field1 = 1, field2 = "11" },
new { field1 = 2, field2 = "22" },
})
on t1.ParentID equals t2.field1
select new { t2.field1, t2.field2 }
).ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].field1, Is.EqualTo(1));
Assert.That(list[1].field1, Is.EqualTo(2));
Assert.That(list[0].field2, Is.EqualTo("11"));
Assert.That(list[1].field2, Is.EqualTo("22"));
}
}
[Test]
public void XmlTableTest3([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var data = new[]
{
new { field1 = 1, field2 = "11" },
new { field1 = 2, field2 = "22" },
};
var list = conn.OracleXmlTable(data)
.Select(t => new { t.field1, t.field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].field1, Is.EqualTo(1));
Assert.That(list[1].field1, Is.EqualTo(2));
Assert.That(list[0].field2, Is.EqualTo("11"));
Assert.That(list[1].field2, Is.EqualTo("22"));
}
}
class XmlData
{
public int Field1;
[Column(Length = 2)]
public string? Field2;
}
[Test]
public void XmlTableTest4([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var list = conn.OracleXmlTable<XmlData>("<t><r><c0>1</c0><c1>11</c1></r><r><c0>2</c0><c1>22</c1></r></t>")
.Select(t => new { t.Field1, t.Field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].Field1, Is.EqualTo(1));
Assert.That(list[1].Field1, Is.EqualTo(2));
Assert.That(list[0].Field2, Is.EqualTo("11"));
Assert.That(list[1].Field2, Is.EqualTo("22"));
}
}
static string? _data;
[Test]
public void XmlTableTest5([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = GetDataContext(context))
{
_data = "<t><r><c0>1</c0><c1>11</c1></r><r><c0>2</c0><c1>22</c1></r></t>";
var list = conn.OracleXmlTable<XmlData>(_data)
.Select(t => new { t.Field1, t.Field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].Field1, Is.EqualTo(1));
Assert.That(list[1].Field1, Is.EqualTo(2));
Assert.That(list[0].Field2, Is.EqualTo("11"));
Assert.That(list[1].Field2, Is.EqualTo("22"));
_data = "<t><r><c0>1</c0><c1>11</c1></r></t>";
list =
(
from t1 in conn.Parent
join t2 in conn.OracleXmlTable<XmlData>(_data)
on t1.ParentID equals t2.Field1
select new { t2.Field1, t2.Field2 }
).ToList();
Assert.That(list.Count, Is.EqualTo(1));
Assert.That(list[0].Field1, Is.EqualTo(1));
Assert.That(list[0].Field2, Is.EqualTo("11"));
}
}
[Test]
public void XmlTableTest6([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = new DataConnection(context))
{
var data = new[]
{
new { field1 = 1, field2 = "11" },
new { field1 = 2, field2 = "22" },
};
var xmlData = OracleTools.GetXmlData(conn.MappingSchema, data);
var list = conn.OracleXmlTable<XmlData>(xmlData)
.Select(t => new { t.Field1, t.Field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].Field1, Is.EqualTo(1));
Assert.That(list[1].Field1, Is.EqualTo(2));
Assert.That(list[0].Field2, Is.EqualTo("11"));
Assert.That(list[1].Field2, Is.EqualTo("22"));
}
}
[Test]
public void XmlTableTest7([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = GetDataContext(context))
{
var data = new[]
{
new { field1 = 1, field2 = "11" },
new { field1 = 2, field2 = "22" },
};
var xmlData = OracleTools.GetXmlData(conn.MappingSchema, data);
var list = conn.OracleXmlTable<XmlData>(() => xmlData)
.Select(t => new { t.Field1, t.Field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(2));
Assert.That(list[0].Field1, Is.EqualTo(1));
Assert.That(list[1].Field1, Is.EqualTo(2));
Assert.That(list[0].Field2, Is.EqualTo("11"));
Assert.That(list[1].Field2, Is.EqualTo("22"));
xmlData = "<t><r><c0>1</c0><c1>11</c1></r></t>";
list = conn.OracleXmlTable<XmlData>(() => xmlData)
.Select(t => new { t.Field1, t.Field2 })
.ToList();
Assert.That(list.Count, Is.EqualTo(1));
Assert.That(list[0].Field1, Is.EqualTo(1));
Assert.That(list[0].Field2, Is.EqualTo("11"));
}
}
[Test]
public void XmlTableTest8([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = GetDataContext(context))
{
var data = "<t><r><c0>1</c0><c1>11</c1></r></t>";
var list =
(
from p in conn.Parent
where conn.OracleXmlTable<XmlData>(data).Count(t => t.Field1 == p.ParentID) > 0
select p
).ToList();
Assert.That(list[0].ParentID, Is.EqualTo(1));
data = "<t><r><c0>2</c0><c1>22</c1></r></t>";
list =
(
from p in conn.Parent
where conn.OracleXmlTable<XmlData>(data).Count(t => t.Field1 == p.ParentID) > 0
select p
).ToList();
Assert.That(list[0].ParentID, Is.EqualTo(2));
}
}
[Test]
public void XmlTableTest9([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var conn = GetDataContext(context))
{
var data = "<t><r><c0>1</c0><c1>11</c1></r></t>";
var list =
(
from p in conn.Parent
where conn.OracleXmlTable<XmlData>(() => data).Count(t => t.Field1 == p.ParentID) > 0
select p
).ToList();
Assert.That(list[0].ParentID, Is.EqualTo(1));
data = "<t><r><c0>2</c0><c1>22</c1></r></t>";
list =
(
from p in conn.Parent
where conn.OracleXmlTable<XmlData>(() => data).Count(t => t.Field1 == p.ParentID) > 0
select p
).ToList();
Assert.That(list[0].ParentID, Is.EqualTo(2));
}
}
#endregion
[Test]
public void TestOrderByFirst1([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
var q =
from x in db.Parent
where x.Value1 == 1
orderby x.ParentID descending
select x;
var row = q.First();
var start = 0;
var n = 0;
while ((start = db.LastQuery!.IndexOf("FROM", start) + 1) > 0)
n++;
Assert.That(n, Is.EqualTo(context.Contains("11") ? 2 : 1));
}
}
[Test]
public void TestOrderByFirst2([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
var q =
from x in db.Parent
where x.Value1 == 1
select x;
var row = q.First();
var start = 0;
var n = 0;
while ((start = db.LastQuery!.IndexOf("FROM", start) + 1) > 0)
n++;
Assert.That(n, Is.EqualTo(1));
}
}
[Test]
public void TestOrderByFirst3([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
var q =
from x in db.Parent
where x.Value1 == 1
orderby x.ParentID descending
select x;
var row = q.Skip(1).First();
var start = 0;
var n = 0;
while ((start = db.LastQuery!.IndexOf("FROM", start) + 1) > 0)
n++;
Assert.That(n, Is.EqualTo(context.Contains("11") ? 3 : 1));
}
}
[Table("DecimalOverflow")]
class DecimalOverflow
{
[Column] public decimal Decimal1;
[Column] public decimal Decimal2;
[Column] public decimal Decimal3;
}
[Test]
public void OverflowTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
OracleDataProvider provider;
using (var db = new DataConnection(context))
{
provider = new OracleDataProvider(db.DataProvider.Name, ((OracleDataProvider)db.DataProvider).Version);
}
provider.ReaderExpressions[new ReaderInfo { FieldType = typeof(decimal) }] = (Expression<Func<IDataReader, int, decimal>>)((r,i) => GetDecimal(r, i));
using (var db = new DataConnection(provider, DataConnection.GetConnectionString(context)))
{
var list = db.GetTable<DecimalOverflow>().ToList();
}
}
const int ClrPrecision = 29;
[ColumnReader(1)]
static decimal GetDecimal(IDataReader rd, int idx)
{
if (rd is Oracle.ManagedDataAccess.Client.OracleDataReader reader)
{
var value = reader.GetOracleDecimal(idx);
var newval = Oracle.ManagedDataAccess.Types.OracleDecimal.SetPrecision(value, value > 0 ? ClrPrecision : (ClrPrecision - 1));
return newval.Value;
}
else
{
var value = ((OracleDataReader)rd).GetOracleDecimal(idx);
var newval = OracleDecimal.SetPrecision(value, value > 0 ? ClrPrecision : (ClrPrecision - 1));
return newval.Value;
}
}
[Table("DecimalOverflow")]
class DecimalOverflow2
{
[Column] public OracleDecimal Decimal1;
[Column] public OracleDecimal Decimal2;
[Column] public OracleDecimal Decimal3;
}
[Test]
public void OverflowTest2([IncludeDataSources(TestProvName.AllOracleManaged)] string context)
{
using (var db = new DataConnection(context))
{
var list = db.GetTable<DecimalOverflow2>().ToList();
}
}
public class UseAlternativeBulkCopy
{
public int Id;
public int Value;
public override int GetHashCode()
{
return Id;
}
public override bool Equals(object? obj)
{
return obj is UseAlternativeBulkCopy e
&& e.Id == Id && e.Value == Value;
}
}
[Test]
public void UseAlternativeBulkCopyInsertIntoTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var data = new List<UseAlternativeBulkCopy>(100);
for (var i = 0; i < 100; i++)
data.Add(new UseAlternativeBulkCopy() { Id = i, Value = i });
using (var db = new DataConnection(context))
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertInto;
db.CreateTable<UseAlternativeBulkCopy>();
try
{
db.BulkCopy(25, data);
var selected = db.GetTable<UseAlternativeBulkCopy>().ToList();
AreEqual(data, selected);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
db.DropTable<UseAlternativeBulkCopy>();
}
}
}
[Test]
public async Task UseAlternativeBulkCopyInsertIntoTestAsync([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var data = new List<UseAlternativeBulkCopy>(100);
for (var i = 0; i < 100; i++)
data.Add(new UseAlternativeBulkCopy() { Id = i, Value = i });
using (var db = new DataConnection(context))
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertInto;
await db.CreateTableAsync<UseAlternativeBulkCopy>();
try
{
await db.BulkCopyAsync(25, data);
var selected = await db.GetTable<UseAlternativeBulkCopy>().ToListAsync();
AreEqual(data, selected);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
await db.DropTableAsync<UseAlternativeBulkCopy>();
}
}
}
[Test]
public void UseAlternativeBulkCopyInsertDualTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var data = new List<UseAlternativeBulkCopy>(100);
for (var i = 0; i < 100; i++)
data.Add(new UseAlternativeBulkCopy() { Id = i, Value = i });
using (var db = new DataConnection(context))
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertDual;
db.CreateTable<UseAlternativeBulkCopy>();
try
{
db.BulkCopy(25, data);
var selected = db.GetTable<UseAlternativeBulkCopy>().ToList();
AreEqual(data, selected);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
db.DropTable<UseAlternativeBulkCopy>();
}
}
}
[Test]
public async Task UseAlternativeBulkCopyInsertDualTestAsync([IncludeDataSources(TestProvName.AllOracle)] string context)
{
var data = new List<UseAlternativeBulkCopy>(100);
for (var i = 0; i < 100; i++)
data.Add(new UseAlternativeBulkCopy() { Id = i, Value = i });
using (var db = new DataConnection(context))
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertDual;
await db.CreateTableAsync<UseAlternativeBulkCopy>();
try
{
await db.BulkCopyAsync(25, data);
var selected = await db.GetTable<UseAlternativeBulkCopy>().ToListAsync();
AreEqual(data, selected);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
await db.DropTableAsync<UseAlternativeBulkCopy>();
}
}
}
public class ClobEntity
{
public ClobEntity()
{ }
public ClobEntity(int id)
{
Id = id;
ClobValue = "Clob" .PadRight(4001, id.ToString()[0]);
NClobValue = "NClob".PadRight(4001, id.ToString()[0]);
}
public int Id;
[Column(DataType = DataType.Text)]
public string? ClobValue;
[Column(DataType = DataType.NText)]
public string? NClobValue;
public override int GetHashCode()
{
return Id;
}
public override bool Equals(object? obj)
{
return obj is ClobEntity clob
&& clob.Id == Id
&& clob.ClobValue == ClobValue
&& clob.NClobValue == NClobValue;
}
}
[Test]
public void ClobTest1([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new DataConnection(context))
{
try
{
db.CreateTable<ClobEntity>();
var obj = new ClobEntity(1);
db.Insert(obj);
var selected = db.GetTable<ClobEntity>().First(_ => _.Id == 1);
Assert.AreEqual(obj, selected);
}
finally
{
db.DropTable<ClobEntity>();
}
}
}
[Test]
public void ClobBulkCopyTest(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
var data = new List<ClobEntity>(new[] { new ClobEntity(1), new ClobEntity(2) });
using (var db = new DataConnection(context))
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
try
{
db.CreateTable<ClobEntity>();
db.BulkCopy(data);
var selected = db.GetTable<ClobEntity>().ToList();
AreEqual(data, selected);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
db.DropTable<ClobEntity>();
}
}
}
[Test]
public async Task ClobBulkCopyTestAsync(
[IncludeDataSources(TestProvName.AllOracle)] string context,
[Values(
AlternativeBulkCopy.InsertAll,
AlternativeBulkCopy.InsertDual,
AlternativeBulkCopy.InsertInto)]
AlternativeBulkCopy useAlternativeBulkCopy)
{
var data = new List<ClobEntity>(new[] { new ClobEntity(1), new ClobEntity(2) });
using (var db = new DataConnection(context))
{
OracleTools.UseAlternativeBulkCopy = useAlternativeBulkCopy;
try
{
await db.CreateTableAsync<ClobEntity>();
await db.BulkCopyAsync(data);
var selected = await db.GetTable<ClobEntity>().ToListAsync();
AreEqual(data, selected);
}
finally
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertAll;
await db.DropTableAsync<ClobEntity>();
}
}
}
[Table(IsColumnAttributeRequired = false)]
public class DateTimeOffsetTable
{
public DateTimeOffset DateTimeOffsetValue;
}
[Test]
public void Issue515Test([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
try
{
var now = new DateTimeOffset(2000, 1, 1, 10, 11, 12, TimeSpan.FromHours(5));
db.CreateTable<DateTimeOffsetTable>();
db.Insert(new DateTimeOffsetTable() {DateTimeOffsetValue = now});
Assert.AreEqual(now, db.GetTable<DateTimeOffsetTable>().Select(_ => _.DateTimeOffsetValue).Single());
}
finally
{
db.DropTable<DateTimeOffsetTable>();
}
}
}
[Test]
public void Issue612Test([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
try
{
// initialize with ticks with default oracle timestamp presicion (6 fractional seconds)
var expected = new DateTimeOffset(636264847785126550, TimeSpan.FromHours(3));
db.CreateTable<DateTimeOffsetTable>();
db.Insert(new DateTimeOffsetTable { DateTimeOffsetValue = expected });
var actual = db.GetTable<DateTimeOffsetTable>().Select(x => x.DateTimeOffsetValue).Single();
Assert.That(actual, Is.EqualTo(expected));
}
finally
{
db.DropTable<DateTimeOffsetTable>();
}
}
}
[Test]
public void Issue612TestDefaultTSTZPrecisonCanDiffersOfUpTo9Ticks([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
try
{
// initialize with ticks with default DateTimeOffset presicion (7 fractional seconds for Oracle TSTZ)
var expected = new DateTimeOffset(636264847785126559, TimeSpan.FromHours(3));
db.CreateTable<DateTimeOffsetTable>();
db.Insert(new DateTimeOffsetTable { DateTimeOffsetValue = expected });
var actual = db.GetTable<DateTimeOffsetTable>().Select(x => x.DateTimeOffsetValue).Single();
Assert.That(actual, Is.EqualTo(expected).Within(9).Ticks);
}
finally
{
db.DropTable<DateTimeOffsetTable>();
}
}
}
public static IEnumerable<Person> PersonSelectByKey(DataConnection dataConnection, int id)
{
return dataConnection.QueryProc<Person>("PERSON_SELECTBYKEY",
new DataParameter("pID", @id),
new DataParameter { Name = "retCursor", DataType = DataType.Cursor, Direction = ParameterDirection.ReturnValue });
}
[Test]
public void PersonSelectByKey([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
AreEqual(Person.Where(_ => _.ID == 1), PersonSelectByKey(db, 1));
}
}
[Table(Name = "AllTypes")]
public partial class ALLTYPE2
{
[Column, PrimaryKey, Identity] public decimal ID { get; set; } // NUMBER
[Column, Nullable] public byte[]? binaryDataType { get; set; } // BLOB
[Column, Nullable] public byte[]? bfileDataType { get; set; } // BFILE
[Column, Nullable] public byte[]? guidDataType { get; set; } // RAW(16)
}
[Test]
public void Issue539([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
var n = 0;
try
{
var val = new byte[] { 1, 2, 3 };
n = Convert.ToInt32(db.GetTable<ALLTYPE2>()
.InsertWithIdentity(() => new ALLTYPE2 { ID = 1000, binaryDataType = val, guidDataType = val }));
var qry = db.GetTable<ALLTYPE2>().Where(_ => _.ID == 1000 && _.guidDataType == val);
var data = db.GetTable<ALLTYPE2>()
.Where(_ => _.ID == n)
.Select(_ => new
{
_.binaryDataType,
Count = qry.Count()
}).First();
AreEqual(val, data.binaryDataType!);
}
finally
{
db.GetTable<ALLTYPE2>().Delete(_ => _.ID == n);
}
}
}
[Table("ISSUE723TABLE")]
public class Issue723Table
{
[PrimaryKey, Identity, NotNull]
public int Id;
public string? StringValue;
}
[Test]
public void Issue723Test1([IncludeDataSources(TestProvName.AllOracle)] string context)
{
// v12 fix: ORA-65096: invalid common user or role name
// http://www.dba-oracle.com/t_ora_65096_create_user_12c_without_c_prefix.htm
var ms = new MappingSchema();
using (var db = (DataConnection)GetDataContext(context, ms))
{
var currentUser = db.Execute<string>("SELECT user FROM dual");
db.Execute("GRANT CREATE ANY TRIGGER TO " + currentUser);
db.Execute("GRANT CREATE ANY SEQUENCE TO " + currentUser);
db.Execute("GRANT DROP ANY TRIGGER TO " + currentUser);
db.Execute("GRANT DROP ANY SEQUENCE TO " + currentUser);
try {db.Execute("DROP USER C##ISSUE723SCHEMA CASCADE");} catch { }
db.Execute("CREATE USER C##ISSUE723SCHEMA IDENTIFIED BY password");
try
{
var tableSpace = db.Execute<string>("SELECT default_tablespace FROM sys.dba_users WHERE username = 'C##ISSUE723SCHEMA'");
db.Execute($"ALTER USER C##ISSUE723SCHEMA quota unlimited on {tableSpace}");
db.CreateTable<Issue723Table>(schemaName: "C##ISSUE723SCHEMA");
Assert.That(db.LastQuery!.Contains("C##ISSUE723SCHEMA.ISSUE723TABLE"));
try
{
db.MappingSchema.GetFluentMappingBuilder()
.Entity<Issue723Table>()
.HasSchemaName("C##ISSUE723SCHEMA");
for (var i = 1; i < 3; i++)
{
var id = Convert.ToInt32(db.InsertWithIdentity(new Issue723Table() { StringValue = i.ToString() }));
Assert.AreEqual(i, id);
}
Assert.That(db.LastQuery.Contains("C##ISSUE723SCHEMA.ISSUE723TABLE"));
}
finally
{
db.DropTable<Issue723Table>(schemaName: "C##ISSUE723SCHEMA");
}
}
finally
{
db.Execute("DROP USER C##ISSUE723SCHEMA CASCADE");
}
}
}
[Test]
public void Issue723Test2([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
using (db.CreateLocalTable<Issue723Table>())
{
Assert.True(true);
}
}
public class Issue731Table
{
public int Id;
public Guid Guid;
[Column(DataType = DataType.Binary)]
public Guid BinaryGuid;
public byte[]? BlobValue;
[Column(Length = 5)]
public byte[]? RawValue;
}
[Test]
public void Issue731Test([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
using (db.CreateLocalTable<Issue731Table>())
{
var origin = new Issue731Table()
{
Id = 1,
Guid = TestData.Guid1,
BinaryGuid = TestData.Guid2,
BlobValue = new byte[] { 1, 2, 3 },
RawValue = new byte[] { 4, 5, 6 }
};
db.Insert(origin);
var result = db.GetTable<Issue731Table>().First(_ => _.Id == 1);
Assert.AreEqual(origin.Id, result.Id);
Assert.AreEqual(origin.Guid, result.Guid);
Assert.AreEqual(origin.BinaryGuid, result.BinaryGuid);
Assert.AreEqual(origin.BlobValue, result.BlobValue);
Assert.AreEqual(origin.RawValue, result.RawValue);
}
}
class MyDate
{
public int Year;
public int Month;
public int Day;
public int Hour;
public int Minute;
public int Second;
public int Nanosecond;
public string TimeZone = null!;
}
static MyDate OracleTimeStampTZToMyDate(OracleTimeStampTZ tz)
{
return new MyDate
{
Year = tz.Year,
Month = tz.Month,
Day = tz.Day,
Hour = tz.Hour,
Minute = tz.Minute,
Second = tz.Second,
Nanosecond = tz.Nanosecond,
TimeZone = tz.TimeZone,
};
}
static OracleTimeStampTZ MyDateToOracleTimeStampTZ(MyDate dt)
{
return dt == null ?
OracleTimeStampTZ.Null :
new OracleTimeStampTZ(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Nanosecond, dt.TimeZone);
}
[Table("AllTypes")]
class MappingTest
{
[Column] public int ID;
[Column("datetimeoffsetDataType")] public MyDate? MyDate;
}
[Test]
public void CustomMappingNonstandardTypeTest([IncludeDataSources(TestProvName.AllOracleManaged)] string context)
{
var ms = new MappingSchema();
var dataProvider = (DataProviderBase)DataConnection.GetDataProvider(context);
// Expression to read column value from data reader.
//
dataProvider.ReaderExpressions[new ReaderInfo
{
ToType = typeof(MyDate),
ProviderFieldType = typeof(OracleTimeStampTZ),
}] = (Expression<Func<OracleDataReader,int,MyDate>>)((rd, idx) => OracleTimeStampTZToMyDate(rd.GetOracleTimeStampTZ(idx)));
// Converts object property value to data reader parameter.
//
ms.SetConverter<MyDate,DataParameter>(
dt => new DataParameter { Value = MyDateToOracleTimeStampTZ(dt) });
// Converts object property value to SQL.
//
ms.SetValueToSqlConverter(typeof(MyDate), (sb,tp,v) =>
{
if (!(v is MyDate value)) sb.Append("NULL");
else sb.Append($"DATE '{value.Year}-{value.Month}-{value.Day}'");
});
// Converts object property value to SQL.
//
ms.SetValueToSqlConverter(typeof(OracleTimeStampTZ), (sb,tp,v) =>
{
var value = (OracleTimeStampTZ)v;
if (value.IsNull) sb.Append("NULL");
else sb.Append($"DATE '{value.Year}-{value.Month}-{value.Day}'");
});
// Maps OracleTimeStampTZ to MyDate and the other way around.
//
ms.SetConverter<OracleTimeStampTZ,MyDate>(OracleTimeStampTZToMyDate);
ms.SetConverter<MyDate,OracleTimeStampTZ>(MyDateToOracleTimeStampTZ);
using (var db = GetDataContext(context, ms))
{
var table = db.GetTable<MappingTest>();
var list = table.ToList();
table.Update(
mt => mt.ID == list[0].ID,
mt => new MappingTest
{
MyDate = list[0].MyDate
});
db.InlineParameters = true;
table.Update(
mt => mt.ID == list[0].ID,
mt => new MappingTest
{
MyDate = list[0].MyDate
});
}
}
class BooleanMapping
{
private sealed class EqualityComparer : IEqualityComparer<BooleanMapping>
{
public bool Equals(BooleanMapping? x, BooleanMapping? y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.Id == y.Id && x.BoolProp == y.BoolProp && x.NullableBoolProp == y.NullableBoolProp;
}
public int GetHashCode(BooleanMapping obj)
{
unchecked
{
var hashCode = obj.Id;
hashCode = (hashCode * 397) ^ obj.BoolProp.GetHashCode();
hashCode = (hashCode * 397) ^ obj.NullableBoolProp.GetHashCode();
return hashCode;
}
}
}
public static IEqualityComparer<BooleanMapping> Comparer { get; } = new EqualityComparer();
[PrimaryKey]
public int Id { get; set; }
[Column]
public bool BoolProp { get; set; }
[Column]
public bool? NullableBoolProp { get; set; }
}
[Test]
public void BooleanMappingTests([IncludeDataSources(TestProvName.AllOracleManaged)] string context)
{
var ms = new MappingSchema();
ms.SetConvertExpression<bool?, DataParameter>(_ =>
_ != null
? DataParameter.Char(null, _.HasValue && _.Value ? 'Y' : 'N')
: new DataParameter(null, DBNull.Value));
var testData = new[]
{
new BooleanMapping { Id = 1, BoolProp = true, NullableBoolProp = true },
new BooleanMapping { Id = 2, BoolProp = false, NullableBoolProp = false },
new BooleanMapping { Id = 3, BoolProp = true, NullableBoolProp = null }
};
using (var db = GetDataContext(context, ms))
using (var table = db.CreateLocalTable<BooleanMapping>())
{
table.BulkCopy(testData);
var values = table.ToArray();
AreEqual(testData, values, BooleanMapping.Comparer);
}
}
[Test]
public async Task BooleanMappingTestsAsync([IncludeDataSources(TestProvName.AllOracleManaged)] string context)
{
var ms = new MappingSchema();
ms.SetConvertExpression<bool?, DataParameter>(_ =>
_ != null
? DataParameter.Char(null, _.HasValue && _.Value ? 'Y' : 'N')
: new DataParameter(null, DBNull.Value));
var testData = new[]
{
new BooleanMapping { Id = 1, BoolProp = true, NullableBoolProp = true },
new BooleanMapping { Id = 2, BoolProp = false, NullableBoolProp = false },
new BooleanMapping { Id = 3, BoolProp = true, NullableBoolProp = null }
};
using (var db = GetDataContext(context, ms))
using (var table = db.CreateLocalTable<BooleanMapping>())
{
await table.BulkCopyAsync(testData);
var values = await table.ToArrayAsync();
AreEqual(testData, values, BooleanMapping.Comparer);
}
}
[Table("BinaryData")]
public class TestIdentifiersTable1
{
[Column]
public int BinaryDataID { get; set; }
}
[Table("BINARYDATA")]
public class TestIdentifiersTable2
{
[Column("BINARYDATAID")]
public int BinaryDataID { get; set; }
}
[Test]
public void TestLowercaseIdentifiersQuotation([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
var initial = OracleTools.DontEscapeLowercaseIdentifiers;
try
{
OracleTools.DontEscapeLowercaseIdentifiers = true;
db.GetTable<TestIdentifiersTable1>().ToList();
db.GetTable<TestIdentifiersTable2>().ToList();
Query.ClearCaches();
OracleTools.DontEscapeLowercaseIdentifiers = false;
// no specific exception type as it differ for managed and native providers
Assert.That(() => db.GetTable<TestIdentifiersTable1>().ToList(), Throws.Exception.With.Message.Contains("ORA-00942"));
db.GetTable<TestIdentifiersTable2>().ToList();
}
finally
{
OracleTools.DontEscapeLowercaseIdentifiers = initial;
}
}
}
[SkipCI("TODO: BFile field requires configuration on CI")]
[Test]
public void ProcedureOutParameters([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
var isNative = GetProviderName(context, out var _).Contains("Native");
using (var db = (DataConnection)GetDataContext(context))
{
var pms = new[]
{
new DataParameter {Name = "ID" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "bigintDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "numericDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "bitDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "smallintDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "decimalDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "smallmoneyDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "intDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "tinyintDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "moneyDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Decimal, Value = 1},
new DataParameter {Name = "floatDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Double, Value = 1},
new DataParameter {Name = "realDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Single, Value = 1},
new DataParameter {Name = "datetimeDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.DateTime, Value = TestData.DateTime},
new DataParameter {Name = "datetime2DataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.DateTime2, Value = TestData.DateTime},
new DataParameter {Name = "datetimeoffsetDataType", Direction = ParameterDirection.InputOutput, DataType = DataType.DateTimeOffset, Value = TestData.DateTimeOffset},
new DataParameter {Name = "localZoneDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.DateTimeOffset, Value = TestData.DateTimeOffset},
new DataParameter {Name = "charDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Char, Value = 'A'},
new DataParameter {Name = "char20DataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Char, Value = 'B'},
new DataParameter {Name = "varcharDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.VarChar, Value = "VarChar"},
new DataParameter {Name = "textDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Text, Value = "Text"},
new DataParameter {Name = "ncharDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.NChar, Value = "NChar"},
new DataParameter {Name = "nvarcharDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.NVarChar, Value = "NVarChar"},
new DataParameter {Name = "ntextDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.NText, Value = "NText"},
new DataParameter {Name = "binaryDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Blob, Value = new byte []{ 1,2,3 }},
new DataParameter {Name = "bfileDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.BFile, Value = new byte []{ 1,2,3 }},
new DataParameter {Name = "guidDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Guid, Value = TestData.Guid1},
// TODO: it is not clear which db type use for this parameter so oracle will accept it
//new DataParameter {Name = "uriDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Undefined, Value = "http://uri.com" },
new DataParameter {Name = "xmlDataType" , Direction = ParameterDirection.InputOutput, DataType = DataType.Xml, Value = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>hi</test>"},
};
db.ExecuteProc("ALLOUTPUTPARAMETERS", pms);
// assert types converted
Assert.AreEqual(typeof(decimal) , pms[0] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[1] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[2] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[3] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[4] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[5] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[6] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[7] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[8] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[9] .Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[10].Value!.GetType());
Assert.AreEqual(typeof(decimal) , pms[11].Value!.GetType());
Assert.AreEqual(typeof(DateTime) , pms[12].Value!.GetType());
Assert.AreEqual(typeof(DateTime) , pms[13].Value!.GetType());
Assert.AreEqual(typeof(DateTimeOffset), pms[14].Value!.GetType());
Assert.AreEqual(typeof(DateTimeOffset), pms[15].Value!.GetType());
Assert.AreEqual(typeof(string) , pms[16].Value!.GetType());
// [17] is char20 which is not set now for some reason
Assert.AreEqual(typeof(string) , pms[18].Value!.GetType());
Assert.AreEqual(typeof(string) , pms[19].Value!.GetType());
Assert.AreEqual(typeof(string) , pms[20].Value!.GetType());
Assert.AreEqual(typeof(string) , pms[21].Value!.GetType());
Assert.AreEqual(typeof(string) , pms[22].Value!.GetType());
Assert.AreEqual(typeof(byte[]) , pms[23].Value!.GetType());
Assert.AreEqual(((OracleDataProvider)db.DataProvider).Adapter.OracleBFileType, pms[24].Value!.GetType());
Assert.AreEqual(typeof(byte[]) , pms[25].Value!.GetType());
Assert.AreEqual(typeof(string) , pms[26].Value!.GetType());
// assert values
Assert.AreEqual(2 , pms[0].Value);
Assert.AreEqual(1000000 , pms[1].Value);
Assert.AreEqual(9999999 , pms[2].Value);
Assert.AreEqual(1 , pms[3].Value);
Assert.AreEqual(25555 , pms[4].Value);
Assert.AreEqual(2222222 , pms[5].Value);
Assert.AreEqual(100000 , pms[6].Value);
Assert.AreEqual(7777777 , pms[7].Value);
Assert.AreEqual(100 , pms[8].Value);
Assert.AreEqual(100000 , pms[9].Value);
Assert.AreEqual(20.31 , pms[10].Value);
Assert.AreEqual(16.2 , pms[11].Value);
Assert.AreEqual(new DateTime(2012, 12, 12, 12, 12, 12), pms[12].Value);
Assert.AreEqual(new DateTime(2012, 12, 12, 12, 12, 12, 12), pms[13].Value);
Assert.AreEqual(new DateTimeOffset(2012, 12, 12, 12, 12, 12, isNative ? 0 : 12, TimeSpan.FromHours(-5)), pms[14].Value);
// TODO: fix timezones handling
if (!context.Contains("Native"))
Assert.That(pms[15].Value,
Is.EqualTo(new DateTimeOffset(2012, 12, 12, 11, 12, 12, isNative ? 0 : 12, TimeSpan.Zero)).
Or.EqualTo(new DateTimeOffset(2012, 12, 12, 11, 12, 12, isNative ? 0 : 12, TestData.DateTimeOffset.Offset)).
Or.EqualTo(new DateTimeOffset(2012, 12, 12, 12, 12, 12, isNative ? 0 : 12, TestData.DateTimeOffset.Offset.Add(new TimeSpan(-1, 0, 0)))).
Or.EqualTo(new DateTimeOffset(2012, 12, 12, 12, 12, 12, isNative ? 0 : 12, new TimeSpan(-5, 0, 0))));
Assert.AreEqual("1" , pms[16].Value);
Assert.IsNull(pms[17].Value);
Assert.AreEqual("234" , pms[18].Value);
Assert.AreEqual("567" , pms[19].Value);
Assert.AreEqual("23233" , pms[20].Value);
Assert.AreEqual("3323" , pms[21].Value);
Assert.AreEqual("111" , pms[22].Value);
Assert.AreEqual(new byte[] { 0, 0xAA }, pms[23].Value);
// default converter for BFile missing intentionally
var bfile = pms[24].Output!.Value!;
if (isNative)
{
#if NET472
using (var file = (Oracle.DataAccess.Types.OracleBFile)bfile)
{
file.OpenFile();
Assert.AreEqual(new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35 }, file.Value);
}
#endif
}
else
{
using (var file = (Oracle.ManagedDataAccess.Types.OracleBFile)bfile)
{
file.OpenFile();
Assert.AreEqual(new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35 }, file.Value);
}
}
// guid is autogenerated
Assert.AreEqual(16 , ((byte[])pms[25].Value!).Length);
Assert.AreEqual(
"<root><elementstrattr=\"strvalue\"intattr=\"12345\"/></root>",
pms[26].Value!.ToString()!.Replace(" ", "").Replace("\n", ""));
}
}
class MyTestDataConnection : TestDataConnection
{
public MyTestDataConnection(string configurationString)
: base(configurationString)
{
}
protected override IDataReader ExecuteReader(IDbCommand command, CommandBehavior commandBehavior)
{
var reader = base.ExecuteReader(command, commandBehavior);
if (reader is OracleDataReader or1 && command is OracleCommand oc1)
{
or1.FetchSize = oc1.RowSize * 10000;
}
return reader;
}
}
[Test]
public void OverrideExecuteReaderTest([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = new MyTestDataConnection(context))
{
_ = db.Person.ToList();
}
}
[Test]
public void LongDataTypeTest([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
db.GetTable<AllTypes>()
.Where(t => t.ID > 2)
.Delete();
try
{
var items = db.GetTable<AllTypes>()
.Select(t => new { t.longDataType })
.ToArray();
Assert.That(items.Length, Is.GreaterThanOrEqualTo(2));
Assert.That(items[0].longDataType, Is.Null);
Assert.That(items[1].longDataType, Is.EqualTo("LONG"));
var str = new string('A', 10000);
var id = db.GetTable<AllTypes>().InsertWithDecimalIdentity(() => new AllTypes
{
longDataType = str,
});
var insertedItems = db.GetTable<AllTypes>()
.Where(t => t.ID == id)
.Select(t => new { t.longDataType })
.ToArray();
Assert.That(insertedItems[0].longDataType, Is.EqualTo(str));
var str2 = new string('B', 4000);
var id2 = db.GetTable<AllTypes>().InsertWithDecimalIdentity(() => new AllTypes
{
longDataType = Sql.ToSql(str2),
});
var insertedItems2 = db.GetTable<AllTypes>()
.Where(t => t.ID == id2)
.Select(t => new { t.longDataType })
.ToArray();
Assert.That(insertedItems2[0].longDataType, Is.EqualTo(str2));
}
finally
{
db.GetTable<AllTypes>()
.Where(t => t.ID > 2)
.Delete();
}
}
}
class LongRawTable
{
[Column(Name = "ID")] public int Id { get; set; }
[Column(Name = "longRawDataType", DataType=DataType.LongRaw), Nullable] public byte[]? LONGRAWDATATYPE { get; set; } // LONG RAW
}
[Test]
public void LongRawDataTypeTest([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
db.GetTable<LongRawTable>()
.Where(t => t.Id > 2)
.Delete();
var items = db.GetTable<LongRawTable>()
.Select(t => new { t.LONGRAWDATATYPE })
.ToArray();
Assert.That(items.Length, Is.EqualTo(2));
Assert.That(items[0].LONGRAWDATATYPE, Is.Null);
Assert.That(items[1].LONGRAWDATATYPE, Is.Not.Null);
var bytes1 = Encoding.UTF8.GetBytes(new string('A', 10000));
db.GetTable<LongRawTable>().Insert(() => new LongRawTable
{
Id = 3,
LONGRAWDATATYPE = bytes1,
});
var bytes2 = Encoding.UTF8.GetBytes(new string('B', 10000));
db.GetTable<LongRawTable>().Insert(() => new LongRawTable
{
Id = 4,
LONGRAWDATATYPE = bytes2,
});
var insertedItems = db.GetTable<LongRawTable>()
.Where(t => t.Id.In(3, 4))
.Select(t => new { t.LONGRAWDATATYPE })
.ToArray();
Assert.That(insertedItems.Length, Is.EqualTo(2));
Assert.That(insertedItems[0].LONGRAWDATATYPE, Is.EqualTo(bytes1));
Assert.That(insertedItems[1].LONGRAWDATATYPE, Is.EqualTo(bytes2));
}
}
[Test]
public void TestUpdateAliases([IncludeDataSources(TestProvName.AllOracle)] string context)
{
using (var db = GetDataContext(context))
{
var query = from child in db.Child
from parent in db.Parent.InnerJoin(parent => parent.ParentID == child.ParentID && parent.ParentID < 5)
select child;
var countRecords = query.Count();
var recordsAffected = query.Set(child => child.ParentID, child => child.ParentID)
.Update();
Assert.That(recordsAffected, Is.EqualTo(countRecords));
}
}
[Table("TEST_IDENTITY_SCHEMA")]
public class ItentityColumnTable
{
[Column("ID", IsIdentity = true, DbType = "NUMBER GENERATED BY DEFAULT AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE ORDER NOCYCLE")]
public int Id { get; set; }
[Column("NOT_ID")]
public int NotId { get; set; }
}
[Test]
public void TestIdentityColumnRead([IncludeDataSources(false, TestProvName.AllOracle12)] string context)
{
using (var db = new TestDataConnection(context))
using (db.CreateLocalTable<ItentityColumnTable>())
{
var schema = db.DataProvider.GetSchemaProvider().GetSchema(db, new GetSchemaOptions()
{
GetProcedures = false
});
var table = schema.Tables.Single(t => t.TableName == "TEST_IDENTITY_SCHEMA");
Assert.AreEqual(2, table.Columns.Count);
var id = table.Columns.Single(c => c.ColumnName == "ID");
var notid = table.Columns.Single(c => c.ColumnName == "NOT_ID");
Assert.True(id .IsIdentity);
Assert.False(notid.IsIdentity);
}
}
#region DateTime
[Table("Test0431")]
public partial class TestDateTimeTypes
{
[Column(DataType = DataType.Date)] public DateTime Date { get; set; }
[Column] public DateTime DateTime { get; set; }
[Column(DataType = DataType.DateTime)] public DateTime DateTime_ { get; set; }
[Column(DataType = DataType.DateTime2)] public DateTime DateTime2 { get; set; }
[Column(DataType = DataType.DateTime2, Precision = 0)] public DateTime DateTime2_0 { get; set; }
[Column(DataType = DataType.DateTime2, Precision = 1)] public DateTime DateTime2_1 { get; set; }
[Column(DataType = DataType.DateTime2, Precision = 9)] public DateTime DateTime2_9 { get; set; }
[Column] public DateTimeOffset DateTimeOffset_ { get; set; }
[Column(Precision = 0)] public DateTimeOffset DateTimeOffset_0 { get; set; }
[Column(Precision = 1)] public DateTimeOffset DateTimeOffset_1 { get; set; }
[Column(Precision = 9)] public DateTimeOffset DateTimeOffset_9 { get; set; }
public static readonly TestDateTimeTypes[] Data = new[]
{
new TestDateTimeTypes()
{
// for DataType.Date we currently don't trim parameter values of time part
Date = new DateTime(2020, 1, 3),
DateTime = new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234),
DateTime_ = new DateTime(2020, 1, 3, 4, 5, 6),
DateTime2 = new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234),
DateTime2_0 = new DateTime(2020, 1, 3, 4, 5, 6, 189).AddTicks(1234),
DateTime2_1 = new DateTime(2020, 1, 3, 4, 5, 6, 719).AddTicks(1234),
DateTime2_9 = new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234),
DateTimeOffset_ = new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1234),
DateTimeOffset_0 = new DateTimeOffset(2020, 1, 3, 4, 5, 6, 189, TimeSpan.FromMinutes(45)).AddTicks(1234),
DateTimeOffset_1 = new DateTimeOffset(2020, 1, 3, 4, 5, 6, 719, TimeSpan.FromMinutes(45)).AddTicks(1234),
DateTimeOffset_9 = new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1234)
}
};
}
[Test]
public void TestDateTimeRoundtrip([IncludeDataSources(true, TestProvName.AllOracle)] string context, [Values] bool inlineParameters)
{
using (var db = GetDataContext(context))
using (var table = db.CreateLocalTable<TestDateTimeTypes>())
{
db.Insert(TestDateTimeTypes.Data[0]);
db.InlineParameters = inlineParameters;
var pDate = new DateTime(2020, 1, 3);
var pDateTime = new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234);
var pDateTimeOffset = new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1234);
var real = table.ToArray();
var results = table.Where(r => r.Date == pDate ).ToArray(); assert();
results = table.Where(r => r.DateTime == pDateTime ).ToArray(); assert();
results = table.Where(r => r.DateTime_ == pDateTime ).ToArray(); assert();
results = table.Where(r => r.DateTime2 == pDateTime ).ToArray(); assert();
results = table.Where(r => r.DateTime2_0 == pDateTime ).ToArray(); assert();
results = table.Where(r => r.DateTime2_1 == pDateTime ).ToArray(); assert();
results = table.Where(r => r.DateTime2_9 == pDateTime ).ToArray(); assert();
results = table.Where(r => r.DateTimeOffset_ == pDateTimeOffset ).ToArray(); assert();
results = table.Where(r => r.DateTimeOffset_0 == pDateTimeOffset ).ToArray(); assert();
results = table.Where(r => r.DateTimeOffset_1 == pDateTimeOffset ).ToArray(); assert();
results = table.Where(r => r.DateTimeOffset_9 == pDateTimeOffset ).ToArray(); assert();
void assert()
{
Assert.AreEqual(1, results.Length);
Assert.AreEqual(new DateTime(2020, 1, 3), results[0].Date);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1230), results[0].DateTime);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6), results[0].DateTime_);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1230), results[0].DateTime2);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 0), results[0].DateTime2_0);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 700), results[0].DateTime2_1);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234), results[0].DateTime2_9);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1230), results[0].DateTimeOffset_);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 0, TimeSpan.FromMinutes(45)), results[0].DateTimeOffset_0);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 700, TimeSpan.FromMinutes(45)), results[0].DateTimeOffset_1);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1234), results[0].DateTimeOffset_9);
}
}
}
[Test]
public void TestDateTimeSQL([IncludeDataSources(false, TestProvName.AllOracle)] string context, [Values] bool inlineParameters)
{
using (var db = new TestDataConnection(context))
using (var table = db.CreateLocalTable<TestDateTimeTypes>())
{
Assert.True(db.LastQuery!.Contains("\"Date\" date NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTime\" timestamp NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTime_\" date NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTime2\" timestamp NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTime2_0\" timestamp(0) NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTime2_1\" timestamp(1) NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTime2_9\" timestamp(9) NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTimeOffset_\" timestamp with time zone NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTimeOffset_0\" timestamp(0) with time zone NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTimeOffset_1\" timestamp(1) with time zone NOT NULL"));
Assert.True(db.LastQuery.Contains("\"DateTimeOffset_9\" timestamp(9) with time zone NOT NULL"));
db.Insert(TestDateTimeTypes.Data[0]);
db.InlineParameters = inlineParameters;
var pDate = new DateTime(2020, 1, 3);
var pDateTime = new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234);
var pDateTimeOffset = new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1234);
var results = table.Where(r => r.Date == pDate).ToArray();
assert("TO_DATE('2020-01-03', 'YYYY-MM-DD')");
results = table.Where(r => r.DateTime == pDateTime).ToArray();
assert("TO_TIMESTAMP('2020-01-03 04:05:06.789123', 'YYYY-MM-DD HH24:MI:SS.FF6')");
results = table.Where(r => r.DateTime_ == pDateTime).ToArray();
assert("TO_DATE('2020-01-03 04:05:06', 'YYYY-MM-DD HH24:MI:SS')");
results = table.Where(r => r.DateTime2 == pDateTime).ToArray();
assert("TO_TIMESTAMP('2020-01-03 04:05:06.789123', 'YYYY-MM-DD HH24:MI:SS.FF6')");
results = table.Where(r => r.DateTime2_0 == pDateTime).ToArray();
assert("TO_TIMESTAMP('2020-01-03 04:05:06', 'YYYY-MM-DD HH24:MI:SS')");
results = table.Where(r => r.DateTime2_1 == pDateTime).ToArray();
assert("TO_TIMESTAMP('2020-01-03 04:05:06.7', 'YYYY-MM-DD HH24:MI:SS.FF1')");
results = table.Where(r => r.DateTime2_9 == pDateTime).ToArray();
assert("TO_TIMESTAMP('2020-01-03 04:05:06.7891234', 'YYYY-MM-DD HH24:MI:SS.FF7')");
results = table.Where(r => r.DateTimeOffset_ == pDateTimeOffset).ToArray();
assert("TO_TIMESTAMP_TZ('2020-01-03 03:20:06.789123 00:00', 'YYYY-MM-DD HH24:MI:SS.FF6 TZH:TZM')");
results = table.Where(r => r.DateTimeOffset_0 == pDateTimeOffset).ToArray();
assert("TO_TIMESTAMP_TZ('2020-01-03 03:20:06 00:00', 'YYYY-MM-DD HH24:MI:SS TZH:TZM')");
results = table.Where(r => r.DateTimeOffset_1 == pDateTimeOffset).ToArray();
assert("TO_TIMESTAMP_TZ('2020-01-03 03:20:06.7 00:00', 'YYYY-MM-DD HH24:MI:SS.FF1 TZH:TZM')");
results = table.Where(r => r.DateTimeOffset_9 == pDateTimeOffset).ToArray();
assert("TO_TIMESTAMP_TZ('2020-01-03 03:20:06.7891234 00:00', 'YYYY-MM-DD HH24:MI:SS.FF7 TZH:TZM')");
void assert(string function)
{
Assert.AreEqual(1, results.Length);
Assert.AreEqual(new DateTime(2020, 1, 3), results[0].Date);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1230), results[0].DateTime);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6), results[0].DateTime_);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1230), results[0].DateTime2);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 0), results[0].DateTime2_0);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 700), results[0].DateTime2_1);
Assert.AreEqual(new DateTime(2020, 1, 3, 4, 5, 6, 789).AddTicks(1234), results[0].DateTime2_9);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1230), results[0].DateTimeOffset_);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 0, TimeSpan.FromMinutes(45)), results[0].DateTimeOffset_0);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 700, TimeSpan.FromMinutes(45)), results[0].DateTimeOffset_1);
Assert.AreEqual(new DateTimeOffset(2020, 1, 3, 4, 5, 6, 789, TimeSpan.FromMinutes(45)).AddTicks(1234), results[0].DateTimeOffset_9);
if (inlineParameters)
Assert.True(db.LastQuery.Contains(function));
}
}
}
#endregion
[ActiveIssue(399)]
[Test]
public void Issue399Test([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
var schema = db.DataProvider.GetSchemaProvider().GetSchema(db, new GetSchemaOptions()
{
GetTables = false,
GetProcedures = true
});
Assert.AreEqual(11, schema.Procedures.Count);
// This filter used by T4 generator
Assert.AreEqual(11, schema.Procedures.Where(
proc => proc.IsLoaded
|| proc.IsFunction && !proc.IsTableFunction
|| proc.IsTableFunction && proc.ResultException != null).Count());
}
}
[Table("TYPESTEST")]
public class TypesTest
{
[Column(DbType = "CHAR(10)") ] public string Char10 { get; set; } = null!;
[Column(DbType = "NCHAR(10)") ] public string NChar10 { get; set; } = null!;
[Column(DbType = "VARCHAR(10)") ] public string VarChar10 { get; set; } = null!;
[Column(DbType = "VARCHAR2(10)") ] public string VarChar2_10 { get; set; } = null!;
[Column(DbType = "NVARCHAR2(10)")] public string NVarChar2_10 { get; set; } = null!;
}
// TODO: add more types and assertions
[Test]
public void TestSchemaTypes([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
using (db.CreateLocalTable<TypesTest>())
{
var schema = db.DataProvider.GetSchemaProvider().GetSchema(db, new GetSchemaOptions()
{
GetTables = true,
GetProcedures = false
});
var table = schema.Tables.Where(t => t.TableName == nameof(TypesTest).ToUpperInvariant()).SingleOrDefault()!;
Assert.IsNotNull(table);
Assert.AreEqual(5, table.Columns.Count);
AssertColumn(nameof(TypesTest.Char10) , "CHAR(10)" , 10);
AssertColumn(nameof(TypesTest.NChar10) , "NCHAR(10)" , 10);
AssertColumn(nameof(TypesTest.VarChar10) , "VARCHAR2(10)" , 10); // VARCHAR is alias to VARCHAR2
AssertColumn(nameof(TypesTest.VarChar2_10) , "VARCHAR2(10)" , 10);
AssertColumn(nameof(TypesTest.NVarChar2_10), "NVARCHAR2(10)", 10);
void AssertColumn(string name, string dbType, int? length)
{
var column = table.Columns.SingleOrDefault(c => c.ColumnName == name)!;
Assert.IsNotNull(column);
Assert.AreEqual(dbType, column.ColumnType);
Assert.AreEqual(length, column.Length);
}
}
}
[Table("BULKCOPYTABLE")]
class BulkCopyTable
{
[Column("ID")] public int Id { get; set; }
}
[Table("BULKCOPYTABLE2")]
class BulkCopyTable2
{
[Column("id")] public int Id { get; set; }
}
[Test]
public void BulkCopyWithSchemaName(
[IncludeDataSources(false, TestProvName.AllOracle)] string context, [Values] bool withSchema)
{
using var db = new TestDataConnection(context);
using var table = db.CreateLocalTable<BulkCopyTable>();
{
var schemaName = TestUtils.GetSchemaName(db);
var trace = string.Empty;
db.OnTraceConnection += ti =>
{
if (ti.TraceInfoStep == TraceInfoStep.BeforeExecute)
trace = ti.SqlText;
};
table.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.ProviderSpecific, SchemaName = withSchema ? schemaName : null },
Enumerable.Range(1, 10).Select(id => new BulkCopyTable { Id = id }));
if (withSchema)
Assert.True(trace.Contains($"INSERT BULK {schemaName}.BULKCOPYTABLE"));
else
Assert.True(trace.Contains("INSERT BULK BULKCOPYTABLE"));
}
}
[Test]
public void BulkCopyWithServerName(
[IncludeDataSources(false, TestProvName.AllOracle)] string context, [Values] bool withServer)
{
using var db = new TestDataConnection(context);
using var table = db.CreateLocalTable<BulkCopyTable>();
{
var serverName = TestUtils.GetServerName(db);
var trace = string.Empty;
db.OnTraceConnection += ti =>
{
if (ti.TraceInfoStep == TraceInfoStep.BeforeExecute)
trace = ti.SqlText;
};
table.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.ProviderSpecific, ServerName = withServer ? serverName : null },
Enumerable.Range(1, 10).Select(id => new BulkCopyTable { Id = id }));
if (withServer)
Assert.False(trace.Contains($"INSERT BULK"));
else
Assert.True(trace.Contains("INSERT BULK BULKCOPYTABLE"));
}
}
[Test]
public void BulkCopyWithEscapedColumn(
[IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
using var db = new TestDataConnection(context);
using var table = db.CreateLocalTable<BulkCopyTable2>();
{
var serverName = TestUtils.GetServerName(db);
var trace = string.Empty;
db.OnTraceConnection += ti =>
{
if (ti.TraceInfoStep == TraceInfoStep.BeforeExecute)
trace = ti.SqlText;
};
table.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.ProviderSpecific },
Enumerable.Range(1, 10).Select(id => new BulkCopyTable2 { Id = id }));
Assert.False(trace.Contains($"INSERT BULK"));
}
}
[Test]
public void BulkCopyTransactionTest(
[IncludeDataSources(false, TestProvName.AllOracle)] string context, [Values] bool withTransaction, [Values] bool withInternalTransaction)
{
using var db = new TestDataConnection(context);
using var table = db.CreateLocalTable<BulkCopyTable>();
{
IDisposable? tr = null;
if (withTransaction)
tr = db.BeginTransaction();
try
{
var trace = string.Empty;
db.OnTraceConnection += ti =>
{
if (ti.TraceInfoStep == TraceInfoStep.BeforeExecute)
trace = ti.SqlText;
};
if (withTransaction && withInternalTransaction)
Assert.Throws<InvalidOperationException>(() =>
{
table.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.ProviderSpecific, UseInternalTransaction = withInternalTransaction },
Enumerable.Range(1, 10).Select(id => new BulkCopyTable { Id = id }));
});
else
{
table.BulkCopy(
new BulkCopyOptions() { BulkCopyType = BulkCopyType.ProviderSpecific, UseInternalTransaction = withInternalTransaction },
Enumerable.Range(1, 10).Select(id => new BulkCopyTable { Id = id }));
Assert.True(trace.Contains($"INSERT BULK"));
}
}
finally
{
tr?.Dispose();
}
}
}
#region Issue 2342
[Test]
public void Issue2342Test([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
var oldMode = OracleTools.UseAlternativeBulkCopy;
try
{
OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertInto;
Configuration.RetryPolicy.Factory = connection => new DummyRetryPolicy();
using var db = new TestDataConnection(context);
using var table = db.CreateLocalTable<Issue2342Entity>();
using (db.BeginTransaction())
{
table.BulkCopy(Enumerable.Range(1, 10).Select(id => new Issue2342Entity { Id = id, Name = $"Name_{id}" }));
}
table.Truncate();
}
finally
{
OracleTools.UseAlternativeBulkCopy = oldMode;
Configuration.RetryPolicy.Factory = null;
}
}
sealed class DummyRetryPolicy : IRetryPolicy
{
public TResult Execute<TResult>(Func<TResult> operation) => operation();
public void Execute(Action operation) => operation();
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> operation, CancellationToken cancellationToken = new CancellationToken()) => operation(cancellationToken);
public Task ExecuteAsync(Func<CancellationToken, Task> operation, CancellationToken cancellationToken = new CancellationToken()) => operation(cancellationToken);
}
[Table]
sealed class Issue2342Entity
{
[Column] public long Id { get; set; }
[NotNull, Column(Length = 256)] public string Name { get; set; } = null!;
}
#endregion
[Test]
public void TestTablesAndViewsLoad([IncludeDataSources(false, TestProvName.AllOracle)] string context, [Values] bool withFilter)
{
using (var db = new TestDataConnection(context))
{
var options = withFilter
? new GetSchemaOptions() { ExcludedSchemas = new string[] { "fake" } }
: null;
var schema = db.DataProvider.GetSchemaProvider().GetSchema(db, options);
var table = schema.Tables.Where(t => t.TableName == "SchemaTestTable").FirstOrDefault()!;
var view = schema.Tables.Where(t => t.TableName == "SchemaTestView").FirstOrDefault()!;
var matView = schema.Tables.Where(t => t.TableName == "SchemaTestMatView" && t.IsView).FirstOrDefault()!;
var matViewTable = schema.Tables.Where(t => t.TableName == "SchemaTestMatView" && !t.IsView).FirstOrDefault();
Assert.IsNotNull(table);
Assert.AreEqual("This is table", table.Description);
Assert.IsFalse(table.IsView);
Assert.AreEqual(1, table.Columns.Count);
Assert.AreEqual("Id", table.Columns[0].ColumnName);
Assert.AreEqual("This is column", table.Columns[0].Description);
Assert.IsNotNull(view);
Assert.IsNull(view.Description);
Assert.IsTrue(view.IsView);
Assert.AreEqual(1, view.Columns.Count);
Assert.AreEqual("Id", view.Columns[0].ColumnName);
Assert.AreEqual("This is view column", view.Columns[0].Description);
Assert.IsNotNull(matView);
Assert.AreEqual("This is matview", matView.Description);
Assert.AreEqual(1, matView.Columns.Count);
Assert.AreEqual("Id", matView.Columns[0].ColumnName);
Assert.AreEqual("This is matview column", matView.Columns[0].Description);
Assert.IsNull(matViewTable);
}
}
#region Issue 2504
[Test]
public async Task Issue2504Test([IncludeDataSources(false, TestProvName.AllOracle)] string context)
{
using (var db = new TestDataConnection(context))
{
db.Execute("CREATE SEQUENCE SEQ_A START WITH 1 MINVALUE 0");
try
{
db.Execute(@"
CREATE TABLE ""TABLE_A""(
""COLUMN_A"" NUMBER(20, 0) NOT NULL,
""COLUMN_B"" NUMBER(6, 0) NOT NULL,
""COLUMN_C"" NUMBER(6, 0) NOT NULL,
CONSTRAINT ""PK_TABLE_A"" PRIMARY KEY(""COLUMN_A"", ""COLUMN_B"", ""COLUMN_C"")
)");
var id = await db.InsertWithInt64IdentityAsync(new Issue2504Table1
{
COLUMNA = 1,
COLUMNB = 2
});
Assert.AreEqual(1, id);
id = await db.InsertWithInt64IdentityAsync(new Issue2504Table2()
{
COLUMNA = 1,
COLUMNB = 2
});
Assert.AreEqual(2, id);
}
finally
{
db.Execute("DROP SEQUENCE SEQ_A");
db.Execute("DROP TABLE \"TABLE_A\"");
}
}
}
[Table(Name = "TABLE_A")]
public sealed class Issue2504Table1
{
[PrimaryKey]
[Column(Name = "COLUMN_A"), NotNull]
public long COLUMNA { get; set; }
[PrimaryKey]
[Column(Name = "COLUMN_B"), NotNull]
public int COLUMNB { get; set; }
[PrimaryKey]
[Column(Name = "COLUMN_C"), NotNull, SequenceName("SEQ_A")]
public int COLUMNC { get; set; }
}
[Table(Name = "TABLE_A")]
public sealed class Issue2504Table2
{
[PrimaryKey]
[Column(Name = "COLUMN_A"), NotNull]
public long COLUMNA { get; set; }
[PrimaryKey]
[Column(Name = "COLUMN_B"), NotNull]
public int COLUMNB { get; set; }
[PrimaryKey]
[Column(Name = "COLUMN_C"), NotNull, SequenceName(ProviderName.Oracle, "SEQ_A")]
public int COLUMNC { get; set; }
}
#endregion
[Test]
public void TestDateTimeNAddTimeSpan([IncludeDataSources(true, TestProvName.AllOracle)] string context)
{
var ts = TimeSpan.FromHours(1);
using (var db = GetDataContext(context))
{
db.GetTable<AllTypes>()
.Where(_ =>
Sql.CurrentTimestamp > _.datetime2DataType + TimeSpan.FromHours(1)
).Select(x => x.ID).ToArray();
}
}
}
}
| 37.026219 | 217 | 0.630005 | [
"MIT"
] | deus348/linq2db | Tests/Linq/DataProvider/OracleTests.cs | 137,439 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerStat : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
| 15.526316 | 52 | 0.623729 | [
"Unlicense"
] | palmmyvillage/CodeLab1-2019-FInalProject | CodeLab1_2019_FinalProject/Assets/Scripts/PlayerStat.cs | 297 | C# |
using System;
using System.Reflection;
namespace FullSerializer.Internal {
/// <summary>
/// A property or field on a MetaType.
/// </summary>
public class fsMetaProperty {
internal fsMetaProperty(FieldInfo field) {
_memberInfo = field;
StorageType = field.FieldType;
JsonName = GetJsonName(field);
MemberName = field.Name;
IsPublic = field.IsPublic;
CanRead = true;
CanWrite = true;
}
internal fsMetaProperty(PropertyInfo property) {
_memberInfo = property;
StorageType = property.PropertyType;
JsonName = GetJsonName(property);
MemberName = property.Name;
IsPublic = (property.GetGetMethod() != null && property.GetGetMethod().IsPublic) && (property.GetSetMethod() != null && property.GetSetMethod().IsPublic);
CanRead = property.CanRead;
CanWrite = property.CanWrite;
}
/// <summary>
/// Internal handle to the reflected member.
/// </summary>
private MemberInfo _memberInfo;
/// <summary>
/// The type of value that is stored inside of the property. For example, for an int field,
/// StorageType will be typeof(int).
/// </summary>
public Type StorageType {
get;
private set;
}
/// <summary>
/// Can this property be read?
/// </summary>
public bool CanRead {
get;
private set;
}
/// <summary>
/// Can this property be written to?
/// </summary>
public bool CanWrite {
get;
private set;
}
/// <summary>
/// The serialized name of the property, as it should appear in JSON.
/// </summary>
public string JsonName {
get;
private set;
}
/// <summary>
/// The name of the actual member.
/// </summary>
public string MemberName {
get;
private set;
}
/// <summary>
/// Is this member public?
/// </summary>
public bool IsPublic {
get;
private set;
}
/// <summary>
/// Writes a value to the property that this MetaProperty represents, using given object
/// instance as the context.
/// </summary>
public void Write(object context, object value) {
FieldInfo field = _memberInfo as FieldInfo;
PropertyInfo property = _memberInfo as PropertyInfo;
if (field != null) {
field.SetValue(context, value);
}
else if (property != null) {
MethodInfo setMethod = property.GetSetMethod(/*nonPublic:*/ true);
if (setMethod != null) {
setMethod.Invoke(context, new object[] { value });
}
}
}
/// <summary>
/// Reads a value from the property that this MetaProperty represents, using the given
/// object instance as the context.
/// </summary>
public object Read(object context) {
if (_memberInfo is PropertyInfo) {
return ((PropertyInfo)_memberInfo).GetValue(context, new object[] { });
}
else {
return ((FieldInfo)_memberInfo).GetValue(context);
}
}
/// <summary>
/// Returns the name the given member wants to use for JSON serialization.
/// </summary>
private static string GetJsonName(MemberInfo member) {
var attr = fsPortableReflection.GetAttribute<fsPropertyAttribute>(member);
if (attr != null && string.IsNullOrEmpty(attr.Name) == false) {
return attr.Name;
}
return member.Name;
}
}
} | 30.813953 | 166 | 0.52327 | [
"MIT"
] | Chaser324/soundcloud-unity | Assets/FullSerializer/Reflection/fsMetaProperty.cs | 3,977 | C# |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.