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
sequence | repository_name
stringlengths 7
92
| path
stringlengths 3
249
| size
int64 5
1.04M
| lang
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|
using System;
namespace Contensive.CLI {
static class RepairCmd {
//
// ====================================================================================================
/// <summary>
/// help text for this command
/// </summary>
internal static readonly string helpText = ""
+ Environment.NewLine
+ Environment.NewLine + "--repair (-r)"
+ Environment.NewLine + " reinstall the base collection and all it's dependancies. For all applications, or just one if specified with -a"
+ "";
//
// ====================================================================================================
/// <summary>
/// Repair a single or all apps, forcing full install to include up-to-date collections (to fix broken collection addons)
/// </summary>
/// <param name="appName"></param>
/// <param name="repair"></param>
public static void execute(Contensive.Processor.CPClass cp, string appName) {
UpgradeCmd.execute(cp, appName, true);
}
}
}
| 40.392857 | 153 | 0.45977 | [
"Apache-2.0"
] | contensive/Contensive5 | source/Cli/Views/RepairCmd.cs | 1,133 | 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("Exer_08_EmployeeData")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Exer_08_EmployeeData")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f95d0f5e-3d1a-4225-a0a8-6add9c1a76f1")]
// 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.054054 | 84 | 0.75071 | [
"MIT"
] | quakeN/ProgrammingFundamentals_Sept2017 | 06. Data types and variables/Exer_08_EmployeeData/Properties/AssemblyInfo.cs | 1,411 | C# |
using System;
using Newtonsoft.Json;
namespace TestConsole.Helpers
{
public static class StringHelpers
{
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
public static string SerializeBase64Encode(object @object)
{
return Base64Encode(JsonConvert.SerializeObject(@object));
}
}
}
| 29.307692 | 88 | 0.670604 | [
"MIT"
] | YatterOfficial/Yatter.Invigoration | TestConsole/Helpers/StringHelpers.cs | 764 | C# |
/**
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using Newtonsoft.Json;
namespace IBM.Watson.Discovery.V1.Model
{
/// <summary>
/// Enrichment step to perform on the document. Each enrichment is performed on the specified field in the order
/// that they are listed in the configuration.
/// </summary>
public class Enrichment
{
/// <summary>
/// Describes what the enrichment step does.
/// </summary>
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string Description { get; set; }
/// <summary>
/// Field where enrichments will be stored. This field must already exist or be at most 1 level deeper than an
/// existing field. For example, if `text` is a top-level field with no sub-fields, `text.foo` is a valid
/// destination but `text.foo.bar` is not.
/// </summary>
[JsonProperty("destination_field", NullValueHandling = NullValueHandling.Ignore)]
public string DestinationField { get; set; }
/// <summary>
/// Field to be enriched.
///
/// Arrays can be specified as the **source_field** if the **enrichment** service for this enrichment is set to
/// `natural_language_undstanding`.
/// </summary>
[JsonProperty("source_field", NullValueHandling = NullValueHandling.Ignore)]
public string SourceField { get; set; }
/// <summary>
/// Indicates that the enrichments will overwrite the destination_field field if it already exists.
/// </summary>
[JsonProperty("overwrite", NullValueHandling = NullValueHandling.Ignore)]
public bool? Overwrite { get; set; }
/// <summary>
/// Name of the enrichment service to call. Current options are `natural_language_understanding` and `elements`.
///
/// When using `natual_language_understanding`, the **options** object must contain Natural Language
/// Understanding options.
///
/// When using `elements` the **options** object must contain Element Classification options. Additionally,
/// when using the `elements` enrichment the configuration specified and files ingested must meet all the
/// criteria specified in [the
/// documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-element-classification#element-classification).
/// </summary>
[JsonProperty("enrichment", NullValueHandling = NullValueHandling.Ignore)]
public string _Enrichment { get; set; }
/// <summary>
/// If true, then most errors generated during the enrichment process will be treated as warnings and will not
/// cause the document to fail processing.
/// </summary>
[JsonProperty("ignore_downstream_errors", NullValueHandling = NullValueHandling.Ignore)]
public bool? IgnoreDownstreamErrors { get; set; }
/// <summary>
/// Options which are specific to a particular enrichment.
/// </summary>
[JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
public EnrichmentOptions Options { get; set; }
}
}
| 47.898734 | 136 | 0.66834 | [
"Apache-2.0"
] | AntiDesert5/unity-sdk | Scripts/Services/Discovery/V1/Model/Enrichment.cs | 3,784 | 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.Runtime.InteropServices;
internal partial class Interop
{
internal partial class User32
{
[DllImport(Libraries.User32, EntryPoint = "SendMessageTimeoutW")]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, int flags, int timeout, out IntPtr pdwResult);
}
}
| 33.333333 | 153 | 0.746 | [
"MIT"
] | 2m0nd/runtime | src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs | 500 | C# |
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Nibbler.Core.Macro.Definition;
using Nibbler.Core.Macro.Tapes;
using Nibbler.Core.Simple.Definition;
using Nibbler.Core.Simple.Run;
using Unlog;
namespace Nibbler.Core.Macro.Run
{
public class MmRun : TmRunBase<PackedExponentTape>
{
public Func<MmRun, bool?> PrestepHook = null;
public readonly MacroLibrary ML;
public MmRun (
TmDefinition def,
PackedExponentTape tape,
MacroLibrary ml,
State initialState = null,
History<PackedExponentTape> history = null)
: base (def, tape, initialState, history)
{
ML = ml;
}
/// <returns>
/// false iff (any of) NT or T
/// </returns>
protected override bool Step ()
{
if (PrestepHook != null) {
var hookresult = PrestepHook (this);
if (hookresult != null) {
return hookresult.Value;
}
}
MacroTransition mt;
while (true) {
try {
mt = Options.UseMacros ? GetMacro () : null;
break;
}
catch (TransitionNotDefinedException ex) {
CreateMissingTransitionBranches (ex.ReadSymbol.Value);
}
}
if (mt == null) {
throw new NotImplementedException ();
}
if (!MacroTransitionStep (mt)) {
return false;
}
return true;
}
private bool MacroTransitionStep (MacroTransition t)
{
if (t == null)
throw new ArgumentNullException ();
if (t.Next == null) {
Result.SetNonhalting ("Single cell runs indefinitely: " + t.ToString (Definition));
return false;
}
if (TmPrintOptions.PrintTransitionLevel >= PrintTransitionLevel.All) {
Log.ForegroundColor = ConsoleColor.Yellow;
Log.Write (t.ToString (Definition));
}
try {
if (t.EndFacingRight == null) {
// transition to halting state
Tape.WriteSingleInCell (t.Write, t.Direction, t.Shifts);
}
else {
bool dir;
bool whole;
if (true
&& Options.UseMacroForwarding
&& t.Source == t.Next
&& t.StartFacingRight == t.EndFacingRight
) {
if (TmPrintOptions.PrintTransitionLevel >= PrintTransitionLevel.All) {
var reps = Tape.GetEqualSymbolRepetitionCount ();
Log.Write ("x" + reps.ToString ());
}
dir = t.StartFacingRight;
whole = true;
}
else {
dir = t.Direction > 0;
whole = false;
}
if (!Tape.WritePacked (t.Write, dir, t.Shifts, whole)) {
Result.SetRefusedCandidate ("A cell with a virtual exponent without direct value was accessed. This operation is invalid, as it may depend on the virtual's value. (LONELY_EXPONENT_EXCEPTION)");
return false;
}
}
}
finally {
if (TmPrintOptions.PrintTransitionLevel >= PrintTransitionLevel.All) {
Log.WriteLine ();
Log.ResetColor ();
}
}
Q = t.Next;
return true;
}
private MacroTransition GetMacro ()
{
if (Tape.IsMisaligned) {
return null;
}
var read = Tape.ReadPacked ();
var mt = ML.GetMacro (Q, read, Tape.FacingRight);
if (mt == null) {
mt = MacroTransition.CreateSingleMacroTransition (Definition, Q, read, Tape.FacingRight, Tape.Macro);
if (mt != null) {
ML.LearnMacro (mt);
}
}
return mt;
}
protected override void BeforeRunCheck ()
{
if (!(Tape is PackedExponentTape)) {
throw new InvalidOperationException ("Cannot run on non packed exponent tape.");
}
if (Tape is PackedExponentTape != Options.UseMacros) {
throw new InvalidOperationException ("Packed tape and macro usage must be coherent.");
}
}
protected override void MacroSizeCheck ()
{
if (Tape.PackedTapeLength > 10) {
var suggest = Tape.SuggestMacroSizeEx ();
if (suggest != null && suggest.Value != Tape.Macro.MacroSize) {
throw new PoorChoiceOfBlockSizeException (suggest.Value);
}
}
}
}
}
| 24.944099 | 200 | 0.621514 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | nerai/Nibbler | src/Nibbler.Core.Macro/Run/MmRun.cs | 4,018 | C# |
//
// Copyright (c) Microsoft and contributors. 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.
//
// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Azure.Management.DataFactories.Models;
using Microsoft.WindowsAzure.Common.Internals;
namespace Microsoft.Azure.Management.DataFactories.Models
{
/// <summary>
/// The Azure blob storage.
/// </summary>
public partial class AzureBlobLocation : TableLocation
{
private string _fileName;
/// <summary>
/// Optional. The name of the Azure blob.
/// </summary>
public string FileName
{
get { return this._fileName; }
set { this._fileName = value; }
}
private string _folderPath;
/// <summary>
/// Optional. The path of the Azure blob storage.
/// </summary>
public string FolderPath
{
get { return this._folderPath; }
set { this._folderPath = value; }
}
private StorageFormat _format;
/// <summary>
/// Optional. The format of the Azure blob storage.
/// </summary>
public StorageFormat Format
{
get { return this._format; }
set { this._format = value; }
}
private IList<Partition> _partitionedBy;
/// <summary>
/// Optional. The partitions to be used by the path.
/// </summary>
public IList<Partition> PartitionedBy
{
get { return this._partitionedBy; }
set { this._partitionedBy = value; }
}
private string _tableRootLocation;
/// <summary>
/// Optional. The root of blob path.
/// </summary>
public string TableRootLocation
{
get { return this._tableRootLocation; }
set { this._tableRootLocation = value; }
}
/// <summary>
/// Initializes a new instance of the AzureBlobLocation class.
/// </summary>
public AzureBlobLocation()
{
this.PartitionedBy = new LazyList<Partition>();
}
/// <summary>
/// Initializes a new instance of the AzureBlobLocation class with
/// required arguments.
/// </summary>
public AzureBlobLocation(string linkedServiceName)
: this()
{
if (linkedServiceName == null)
{
throw new ArgumentNullException("linkedServiceName");
}
this.LinkedServiceName = linkedServiceName;
}
}
}
| 29.982301 | 76 | 0.580874 | [
"Apache-2.0"
] | achal3754/azure-sdk-for-net | src/DataFactoryManagement/Generated/Models/AzureBlobLocation.cs | 3,388 | C# |
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules
{
using System.Threading;
using System.Threading.Tasks;
using StyleCop.Analyzers.DocumentationRules;
using StyleCop.Analyzers.Test.DocumentationRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationAnalyzer,
StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationCodeFixProvider>;
public class SA1624CSharp7UnitTests : SA1624UnitTests
{
/// <summary>
/// Verifies that documentation that starts with the proper text for multiple expression-bodied accessors will
/// produce a diagnostic when one of the accessors has reduced visibility.
/// </summary>
/// <param name="accessibility">The accessibility of the property.</param>
/// <param name="type">The type to use for the property.</param>
/// <param name="accessors">The accessors for the property.</param>
/// <param name="summaryPrefix">The prefix to use in the summary text.</param>
/// <param name="expectedArgument1">The first expected argument for the diagnostic.</param>
/// <param name="expectedArgument2">The second expected argument for the diagnostic.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory(DisplayName = "Expression-bodied Property Accessor Findings")]
[InlineData("public", "int", "get => 0; internal set => this.field = value;", "Gets or sets", "get", "Gets")]
[InlineData("public", "int", "get => 0; private set => this.field = value;", "Gets or sets", "get", "Gets")]
[InlineData("public", "int", "internal get => 0; set => this.field = value;", "Gets or sets", "set", "Sets")]
[InlineData("public", "int", "private get => 0; set => this.field = value;", "Gets or sets", "set", "Sets")]
[InlineData("public", "bool", "get => false; private set => this.field = value;", "Gets or sets a value indicating whether", "get", "Gets a value indicating whether")]
[InlineData("public", "bool", "private get => false; set => this.field = value;", "Gets or sets a value indicating whether", "set", "Sets a value indicating whether")]
[InlineData("protected", "int", "get => 0; private set => this.field = value;", "Gets or sets", "get", "Gets")]
[InlineData("protected", "int", "private get => 0; set => this.field = value;", "Gets or sets", "set", "Sets")]
[InlineData("protected internal", "int", "get => 0; internal set => this.field = value;", "Gets or sets", "get", "Gets")]
[InlineData("protected internal", "int", "get => 0; private set => this.field = value;", "Gets or sets", "get", "Gets")]
[InlineData("protected internal", "int", "internal get => 0; set => this.field = value;", "Gets or sets", "set", "Sets")]
[InlineData("protected internal", "int", "private get => 0; set => this.field = value;", "Gets or sets", "set", "Sets")]
[InlineData("internal", "int", "get => 0; private set => this.field = value;", "Gets or sets", "get", "Gets")]
[InlineData("internal", "int", "private get => 0; set => this.field = value;", "Gets or sets", "set", "Sets")]
public async Task VerifyThatInvalidDocumentationWillReportDiagnosticWithExpressionBodiedAccessorsAsync(string accessibility, string type, string accessors, string summaryPrefix, string expectedArgument1, string expectedArgument2)
{
var testCode = $@"
public class TestClass
{{
private object field;
/// <summary>
/// {summaryPrefix} the test property.
/// </summary>
{accessibility} {type} TestProperty
{{
{accessors}
}}
}}
";
var fixedTestCode = $@"
public class TestClass
{{
private object field;
/// <summary>
/// {expectedArgument2} the test property.
/// </summary>
{accessibility} {type} TestProperty
{{
{accessors}
}}
}}
";
var expected = Diagnostic(PropertySummaryDocumentationAnalyzer.SA1624Descriptor).WithLocation(9, 7 + accessibility.Length + type.Length).WithArguments(expectedArgument1, expectedArgument2);
await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
}
}
}
| 57.35 | 237 | 0.656931 | [
"Apache-2.0"
] | Andreyul/StyleCopAnalyzers | StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1624CSharp7UnitTests.cs | 4,590 | C# |
using System;
using System.Reflection;
using System.Resources;
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("Microsoft.Windows.Data.DomainServices")]
[assembly: AssemblyDescription("Microsoft.Windows.Data.DomainServices.dll")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Outercurve Foundation")]
[assembly: AssemblyProduct("Open RIA Services")]
[assembly: AssemblyCopyright("© Outercurve Foundation. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6a97e2b8-0196-4e70-a6c9-7f85a7fe0d43")]
[assembly: CLSCompliant(true)]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.5.0")]
// AssemblyFileVersion attribute is generated automatically by a custom MSBuild task inside AutomaticAssemblyVersion.targets
//[assembly: AssemblyFileVersion("1.0.0.0")] | 42.225 | 124 | 0.76791 | [
"Apache-2.0"
] | Daniel-Svensson/OpenRiaServices | src/archive/OpenRiaServices.Data.DomainServices/Framework/Properties/AssemblyInfo.cs | 1,692 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Inbox2.Platform.Interfaces;
using System.Diagnostics;
namespace Inbox2.Platform.Framework.Locking
{
[Serializable]
public class ReaderLock : IDisposable
{
protected ISynchronizedObject synchronizedObject;
public ReaderLock(ISynchronizedObject synchronizedObject)
{
this.synchronizedObject = synchronizedObject;
if (!Debugger.IsAttached)
synchronizedObject.AcquireReaderLock();
}
public virtual void Dispose()
{
if (!Debugger.IsAttached)
synchronizedObject.ReleaseReaderLock();
}
}
} | 22.137931 | 60 | 0.742991 | [
"BSD-3-Clause"
] | Klaudit/inbox2_desktop | Code/Platform/Framework/Locking/ReaderLock.cs | 644 | C# |
using System;
using System.Windows;
namespace SharpVectors.Runtime
{
public static class SvgObject
{
#region Public Fields
public const string LinksLayer = "_SvgAnimationLayer";
public const string DrawLayer = "_SvgDrawingLayer";
public static readonly DependencyProperty IdProperty =
DependencyProperty.RegisterAttached("Id", typeof(string), typeof(SvgObject),
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.None));
public static readonly DependencyProperty UniqueIdProperty =
DependencyProperty.RegisterAttached("UniqueId", typeof(string), typeof(SvgObject),
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.None));
public static readonly DependencyProperty ClassProperty =
DependencyProperty.RegisterAttached("Class", typeof(string), typeof(SvgObject),
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.None));
public static readonly DependencyProperty TypeProperty =
DependencyProperty.RegisterAttached("Type", typeof(SvgObjectType), typeof(SvgObject),
new FrameworkPropertyMetadata(SvgObjectType.None, FrameworkPropertyMetadataOptions.None));
public static readonly DependencyProperty TitleProperty =
DependencyProperty.RegisterAttached("Title", typeof(String), typeof(SvgObject),
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.None));
public static readonly DependencyProperty OrderProperty =
DependencyProperty.RegisterAttached("Order", typeof(int), typeof(SvgObject),
new FrameworkPropertyMetadata(-1, FrameworkPropertyMetadataOptions.None));
#endregion
#region Public Methods
public static void SetName(DependencyObject element, string name)
{
if (!string.IsNullOrEmpty(name) && char.IsDigit(name[0]))
{
name = "_" + name;
}
element.SetValue(FrameworkElement.NameProperty, name);
}
public static string GetName(DependencyObject element)
{
string name = element.GetValue(FrameworkElement.NameProperty) as string;
if (!string.IsNullOrEmpty(name) && name.StartsWith("_", StringComparison.Ordinal))
{
name = name.Remove(0, 1);
}
return name;
}
public static void SetId(DependencyObject element, string value)
{
element.SetValue(IdProperty, value);
}
public static string GetId(DependencyObject element)
{
return (string)element.GetValue(IdProperty);
}
public static void SetUniqueId(DependencyObject element, string value)
{
element.SetValue(UniqueIdProperty, value);
}
public static string GetUniqueId(DependencyObject element)
{
return (string)element.GetValue(UniqueIdProperty);
}
public static void SetClass(DependencyObject element, string value)
{
element.SetValue(ClassProperty, value);
}
public static string GetClass(DependencyObject element)
{
return (string)element.GetValue(ClassProperty);
}
public static void SetType(DependencyObject element, SvgObjectType value)
{
element.SetValue(TypeProperty, value);
}
public static SvgObjectType GetType(DependencyObject element)
{
return (SvgObjectType)element.GetValue(TypeProperty);
}
public static void SetTitle(DependencyObject element, string value)
{
element.SetValue(TitleProperty, value);
}
public static string GetTitle(DependencyObject element)
{
return (string)element.GetValue(TitleProperty);
}
public static void SetOrder(DependencyObject element, int value)
{
element.SetValue(OrderProperty, value);
}
public static int GetOrder(DependencyObject element)
{
return (int)element.GetValue(OrderProperty);
}
public static bool IsValid(double value)
{
if (double.IsNaN(value) || double.IsInfinity(value))
{
return false;
}
return true;
}
public static bool IsValid(float value)
{
if (float.IsNaN(value) || float.IsInfinity(value))
{
return false;
}
return true;
}
public static bool IsEqual(double value1, double value2)
{
return value1.Equals(value2);
}
public static string RemoveWhitespace(string str)
{
if (str == null || str.Length == 0)
{
return string.Empty;
}
var len = str.Length;
var src = str.ToCharArray();
int dstIdx = 0;
for (int i = 0; i < len; i++)
{
var ch = src[i];
switch (ch)
{
case '\u0020':
case '\u00A0':
case '\u1680':
case '\u2000':
case '\u2001':
case '\u2002':
case '\u2003':
case '\u2004':
case '\u2005':
case '\u2006':
case '\u2007':
case '\u2008':
case '\u2009':
case '\u200A':
case '\u202F':
case '\u205F':
case '\u3000':
case '\u2028':
case '\u2029':
case '\u0009':
case '\u000A':
case '\u000B':
case '\u000C':
case '\u000D':
case '\u0085':
continue;
default:
src[dstIdx++] = ch;
break;
}
}
return new string(src, 0, dstIdx);
}
#endregion
}
}
| 33.632653 | 103 | 0.531705 | [
"MIT",
"BSD-3-Clause"
] | Altua/SharpVectors | Source/SharpVectorRuntimeWpf/SvgObject.cs | 6,594 | 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("QuadronacciRectangle")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("QuadronacciRectangle")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1d0069c8-0d99-4128-afbb-458d9f81b10a")]
// 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.748054 | [
"MIT"
] | Ico093/TelerikAcademy | C#1/Exams/C#Part1-29-December-2012/Exam29Dec2012/QuadronacciRectangle/Properties/AssemblyInfo.cs | 1,416 | 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("04. Sentence Split")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("04. Sentence Split")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5741caf2-217f-424b-ae25-69af9065e02b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 37.945946 | 84 | 0.745726 | [
"Apache-2.0"
] | Warglaive/Strings-and-Text-Processing---Exercises | 04. Sentence Split/Properties/AssemblyInfo.cs | 1,407 | C# |
using Store.Data.Infrastructure;
using Store.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Data.Repositoires
{
public class GadgetRepository : RepositoryBase<Gadget>, IGadgetRepository
{
public GadgetRepository(IDbFactory dbFactory): base(dbFactory)
{
}
}
public interface IGadgetRepository : IRepository<Gadget>
{
}
}
| 20.173913 | 77 | 0.721983 | [
"Apache-2.0"
] | HamadSalahuddin/store | Store/Store.Data/Repositoires/GadgetRepository.cs | 466 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SPDResults : MonoBehaviour
{
SpriteRenderer rend;
private void Start()
{
rend = GetComponent<SpriteRenderer>();
if (PlayerPrefs.GetFloat("Player_SPD") == 10.0f)
rend.color = new Color(0.85f, 0.85f, 0.85f, 1.0f);
else if (PlayerPrefs.GetFloat("Player_SPD") == 15.0f)
rend.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
}
}
| 27.444444 | 63 | 0.607287 | [
"MIT"
] | szheng1030/wgj102_doppelganger | ResultScripts/SPDResults.cs | 496 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreDisplay : MonoBehaviour {
// Use this for initialization
void Start () {
Text myText = GetComponent<Text>();
myText.text = ScoreKeeper.score.ToString();
ScoreKeeper.Reset();
}
// Update is called once per frame
void Update () {
}
}
| 18.6 | 45 | 0.715054 | [
"Apache-2.0"
] | szimano/koksyilasery | Assets/Scripts/ScoreDisplay.cs | 374 | C# |
using System;
using System.Collections.Generic;
namespace Iota.Api.Standard.Utils
{
internal class ArrayUtils
{
public static IEnumerable<T> SliceRow<T>(T[,] array, int row)
{
for (var i = array.GetLowerBound(1); i <= array.GetUpperBound(1); i++)
{
yield return array[row, i];
}
}
public static T[] SubArray<T>(T[] data, int startIndex, int endIndex)
{
int length = endIndex - startIndex;
T[] result = new T[endIndex - startIndex];
Array.Copy(data, startIndex, result, 0, length);
return result;
}
public static T[] SubArray2<T>(T[] data, int index, int length)
{
T[] result = new T[length];
Array.Copy(data, index, result, 0, length);
return result;
}
}
}
| 27.53125 | 82 | 0.526674 | [
"Apache-2.0"
] | iotaledger/iota.lib.csharp | IotaApi.Standard/Utils/ArrayUtils.cs | 883 | C# |
using RevisaoWebApi.Utils;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
namespace RevisaoWebApi.Models
{
public class ContextDB : DbContext
{
public DbSet<Usuario> usuarios { get; set; }
}
} | 19.857143 | 52 | 0.726619 | [
"MIT"
] | rudimarboeno/Hbsis-aula | RevisaoWebApi/RevisaoWebApi/Models/ContextDB.cs | 280 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
internal class CSharpDeclarationComputer : DeclarationComputer
{
public static void ComputeDeclarationsInSpan(
SemanticModel model,
TextSpan span,
bool getSymbol,
ArrayBuilder<DeclarationInfo> builder,
CancellationToken cancellationToken)
{
ComputeDeclarations(model, associatedSymbol: null, model.SyntaxTree.GetRoot(cancellationToken),
(node, level) => !node.Span.OverlapsWith(span) || InvalidLevel(level),
getSymbol, builder, null, cancellationToken);
}
public static void ComputeDeclarationsInNode(
SemanticModel model,
ISymbol associatedSymbol,
SyntaxNode node,
bool getSymbol,
ArrayBuilder<DeclarationInfo> builder,
CancellationToken cancellationToken,
int? levelsToCompute = null)
{
ComputeDeclarations(model, associatedSymbol, node, (n, level) => InvalidLevel(level), getSymbol, builder, levelsToCompute, cancellationToken);
}
private static bool InvalidLevel(int? level)
{
return level.HasValue && level.Value <= 0;
}
private static int? DecrementLevel(int? level)
{
return level.HasValue ? level - 1 : level;
}
private static void ComputeDeclarations(
SemanticModel model,
ISymbol associatedSymbol,
SyntaxNode node,
Func<SyntaxNode, int?, bool> shouldSkip,
bool getSymbol,
ArrayBuilder<DeclarationInfo> builder,
int? levelsToCompute,
CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (shouldSkip(node, levelsToCompute))
{
return;
}
var newLevel = DecrementLevel(levelsToCompute);
switch (node.Kind())
{
case SyntaxKind.NamespaceDeclaration:
{
var ns = (NamespaceDeclarationSyntax)node;
foreach (var decl in ns.Members)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
var declInfo = GetDeclarationInfo(model, node, getSymbol, cancellationToken);
builder.Add(declInfo);
NameSyntax name = ns.Name;
INamespaceSymbol nsSymbol = declInfo.DeclaredSymbol as INamespaceSymbol;
while (name.Kind() == SyntaxKind.QualifiedName)
{
name = ((QualifiedNameSyntax)name).Left;
var declaredSymbol = getSymbol ? nsSymbol?.ContainingNamespace : null;
builder.Add(new DeclarationInfo(name, ImmutableArray<SyntaxNode>.Empty, declaredSymbol));
nsSymbol = declaredSymbol;
}
return;
}
case SyntaxKind.ClassDeclaration:
case SyntaxKind.StructDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.RecordDeclaration:
{
var t = (TypeDeclarationSyntax)node;
foreach (var decl in t.Members)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
var attributes = GetAttributes(t.AttributeLists).Concat(GetTypeParameterListAttributes(t.TypeParameterList));
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
return;
}
case SyntaxKind.EnumDeclaration:
{
var t = (EnumDeclarationSyntax)node;
foreach (var decl in t.Members)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
var attributes = GetAttributes(t.AttributeLists);
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
return;
}
case SyntaxKind.EnumMemberDeclaration:
{
var t = (EnumMemberDeclarationSyntax)node;
var attributes = GetAttributes(t.AttributeLists);
var codeBlocks = SpecializedCollections.SingletonEnumerable(t.EqualsValue).Concat(attributes);
builder.Add(GetDeclarationInfo(model, node, getSymbol, codeBlocks, cancellationToken));
return;
}
case SyntaxKind.DelegateDeclaration:
{
var t = (DelegateDeclarationSyntax)node;
var attributes = GetAttributes(t.AttributeLists)
.Concat(GetParameterListInitializersAndAttributes(t.ParameterList))
.Concat(GetTypeParameterListAttributes(t.TypeParameterList));
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
return;
}
case SyntaxKind.EventDeclaration:
{
var t = (EventDeclarationSyntax)node;
if (t.AccessorList != null)
{
foreach (var decl in t.AccessorList.Accessors)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
}
var attributes = GetAttributes(t.AttributeLists);
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
return;
}
case SyntaxKind.EventFieldDeclaration:
case SyntaxKind.FieldDeclaration:
{
var t = (BaseFieldDeclarationSyntax)node;
var attributes = GetAttributes(t.AttributeLists);
foreach (var decl in t.Declaration.Variables)
{
var codeBlocks = SpecializedCollections.SingletonEnumerable(decl.Initializer).Concat(attributes);
builder.Add(GetDeclarationInfo(model, decl, getSymbol, codeBlocks, cancellationToken));
}
return;
}
case SyntaxKind.ArrowExpressionClause:
{
// Arrow expression clause declares getter symbol for properties and indexers.
if (node.Parent is BasePropertyDeclarationSyntax parentProperty)
{
builder.Add(GetExpressionBodyDeclarationInfo(parentProperty, (ArrowExpressionClauseSyntax)node, model, getSymbol, cancellationToken));
}
return;
}
case SyntaxKind.PropertyDeclaration:
{
var t = (PropertyDeclarationSyntax)node;
if (t.AccessorList != null)
{
foreach (var decl in t.AccessorList.Accessors)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
}
if (t.ExpressionBody != null)
{
ComputeDeclarations(model, associatedSymbol: null, t.ExpressionBody, shouldSkip, getSymbol, builder, levelsToCompute, cancellationToken);
}
var attributes = GetAttributes(t.AttributeLists);
var codeBlocks = SpecializedCollections.SingletonEnumerable(t.Initializer).Concat(attributes);
builder.Add(GetDeclarationInfo(model, node, getSymbol, codeBlocks, cancellationToken));
return;
}
case SyntaxKind.IndexerDeclaration:
{
var t = (IndexerDeclarationSyntax)node;
if (t.AccessorList != null)
{
foreach (var decl in t.AccessorList.Accessors)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
}
if (t.ExpressionBody != null)
{
ComputeDeclarations(model, associatedSymbol: null, t.ExpressionBody, shouldSkip, getSymbol, builder, levelsToCompute, cancellationToken);
}
var codeBlocks = GetParameterListInitializersAndAttributes(t.ParameterList);
var attributes = GetAttributes(t.AttributeLists);
codeBlocks = codeBlocks.Concat(attributes);
builder.Add(GetDeclarationInfo(model, node, getSymbol, codeBlocks, cancellationToken));
return;
}
case SyntaxKind.AddAccessorDeclaration:
case SyntaxKind.RemoveAccessorDeclaration:
case SyntaxKind.GetAccessorDeclaration:
case SyntaxKind.SetAccessorDeclaration:
case SyntaxKind.InitAccessorDeclaration:
{
var t = (AccessorDeclarationSyntax)node;
var blocks = ArrayBuilder<SyntaxNode>.GetInstance();
blocks.AddIfNotNull(t.Body);
blocks.AddIfNotNull(t.ExpressionBody);
blocks.AddRange(GetAttributes(t.AttributeLists));
builder.Add(GetDeclarationInfo(model, node, getSymbol, blocks, cancellationToken));
blocks.Free();
return;
}
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.ConversionOperatorDeclaration:
case SyntaxKind.DestructorDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.OperatorDeclaration:
{
var t = (BaseMethodDeclarationSyntax)node;
var codeBlocks = GetParameterListInitializersAndAttributes(t.ParameterList);
codeBlocks = codeBlocks.Concat(t.Body);
if (t is ConstructorDeclarationSyntax ctorDecl && ctorDecl.Initializer != null)
{
codeBlocks = codeBlocks.Concat(ctorDecl.Initializer);
}
var expressionBody = GetExpressionBodySyntax(t);
if (expressionBody != null)
{
codeBlocks = codeBlocks.Concat(expressionBody);
}
codeBlocks = codeBlocks.Concat(GetAttributes(t.AttributeLists));
if (node is MethodDeclarationSyntax methodDecl && methodDecl.TypeParameterList != null)
{
codeBlocks = codeBlocks.Concat(GetTypeParameterListAttributes(methodDecl.TypeParameterList));
}
builder.Add(GetDeclarationInfo(model, node, getSymbol, codeBlocks, cancellationToken));
return;
}
case SyntaxKind.CompilationUnit:
{
var t = (CompilationUnitSyntax)node;
if (associatedSymbol is IMethodSymbol)
{
builder.Add(GetDeclarationInfo(model, node, getSymbol, new[] { t }, cancellationToken));
}
else
{
foreach (var decl in t.Members)
{
ComputeDeclarations(model, associatedSymbol: null, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
if (t.AttributeLists.Any())
{
var attributes = GetAttributes(t.AttributeLists);
builder.Add(GetDeclarationInfo(model, node, getSymbol: false, attributes, cancellationToken));
}
}
return;
}
default:
return;
}
}
private static IEnumerable<SyntaxNode> GetAttributes(SyntaxList<AttributeListSyntax> attributeLists)
{
foreach (var attributeList in attributeLists)
{
foreach (var attribute in attributeList.Attributes)
{
yield return attribute;
}
}
}
private static IEnumerable<SyntaxNode> GetParameterListInitializersAndAttributes(BaseParameterListSyntax parameterList) =>
parameterList != null ?
parameterList.Parameters.SelectMany(p => GetParameterInitializersAndAttributes(p)) :
SpecializedCollections.EmptyEnumerable<SyntaxNode>();
private static IEnumerable<SyntaxNode> GetParameterInitializersAndAttributes(ParameterSyntax parameter) =>
SpecializedCollections.SingletonEnumerable(parameter.Default).Concat(GetAttributes(parameter.AttributeLists));
private static IEnumerable<SyntaxNode> GetTypeParameterListAttributes(TypeParameterListSyntax typeParameterList) =>
typeParameterList != null ?
typeParameterList.Parameters.SelectMany(p => GetAttributes(p.AttributeLists)) :
SpecializedCollections.EmptyEnumerable<SyntaxNode>();
private static DeclarationInfo GetExpressionBodyDeclarationInfo(
BasePropertyDeclarationSyntax declarationWithExpressionBody,
ArrowExpressionClauseSyntax expressionBody,
SemanticModel model,
bool getSymbol,
CancellationToken cancellationToken)
{
// TODO: use 'model.GetDeclaredSymbol(expressionBody)' when compiler is fixed to return the getter symbol for it.
var declaredAccessor = getSymbol ? (model.GetDeclaredSymbol(declarationWithExpressionBody, cancellationToken) as IPropertySymbol)?.GetMethod : null;
return new DeclarationInfo(
declaredNode: expressionBody,
executableCodeBlocks: ImmutableArray.Create<SyntaxNode>(expressionBody),
declaredSymbol: declaredAccessor);
}
/// <summary>
/// Gets the expression-body syntax from an expression-bodied member. The
/// given syntax must be for a member which could contain an expression-body.
/// </summary>
internal static ArrowExpressionClauseSyntax GetExpressionBodySyntax(CSharpSyntaxNode node)
{
ArrowExpressionClauseSyntax arrowExpr = null;
switch (node.Kind())
{
// The ArrowExpressionClause is the declaring syntax for the
// 'get' SourcePropertyAccessorSymbol of properties and indexers.
case SyntaxKind.ArrowExpressionClause:
arrowExpr = (ArrowExpressionClauseSyntax)node;
break;
case SyntaxKind.MethodDeclaration:
arrowExpr = ((MethodDeclarationSyntax)node).ExpressionBody;
break;
case SyntaxKind.OperatorDeclaration:
arrowExpr = ((OperatorDeclarationSyntax)node).ExpressionBody;
break;
case SyntaxKind.ConversionOperatorDeclaration:
arrowExpr = ((ConversionOperatorDeclarationSyntax)node).ExpressionBody;
break;
case SyntaxKind.PropertyDeclaration:
arrowExpr = ((PropertyDeclarationSyntax)node).ExpressionBody;
break;
case SyntaxKind.IndexerDeclaration:
arrowExpr = ((IndexerDeclarationSyntax)node).ExpressionBody;
break;
case SyntaxKind.ConstructorDeclaration:
arrowExpr = ((ConstructorDeclarationSyntax)node).ExpressionBody;
break;
case SyntaxKind.DestructorDeclaration:
arrowExpr = ((DestructorDeclarationSyntax)node).ExpressionBody;
break;
default:
// Don't throw, just use for the assert in case this is used in the semantic model
ExceptionUtilities.UnexpectedValue(node.Kind());
break;
}
return arrowExpr;
}
}
}
| 46.903797 | 165 | 0.540454 | [
"MIT"
] | JavierMatosD/roslyn | src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs | 18,529 | C# |
using System.Text;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Flatten.Contexts;
using dotnetCampus.OpenXmlUnitConverter;
using static DocumentFormat.OpenXml.Flatten.ElementConverters.ShapeGeometryConverters.ShapeGeometryFormulaHelper;
namespace DocumentFormat.OpenXml.Flatten.ElementConverters.ShapeGeometryConverters
{
/// <summary>
/// 箭头: 直角上
/// </summary>
public class BentUpArrowGeometry : ShapeGeometryBase
{
/// <inheritdoc />
public override string? ToGeometryPathString(EmuSize emuSize, AdjustValueList? adjusts = null)
{
return null;
}
/// <inheritdoc />
public override ShapePath[]? GetMultiShapePaths(EmuSize emuSize, AdjustValueList? adjusts = null)
{
var (h, w, l, r, t, b, hd2, hd4, hd5, hd6, hd8, ss, hc, vc, ls, ss2, ss4, ss6, ss8, wd2, wd4, wd5, wd6, wd8, wd10, cd2, cd4, cd6, cd8) = GetFormulaProperties(emuSize);
// <avLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">
// <gd name="adj1" fmla="val 25000" />
// <gd name="adj2" fmla="val 25000" />
// <gd name="adj3" fmla="val 25000" />
//</avLst>
var customAdj1 = adjusts?.GetAdjustValue("adj1");
var adj1 = customAdj1 ?? 25000d;
var customAdj2 = adjusts?.GetAdjustValue("adj2");
var adj2 = customAdj2 ?? 25000d;
var customAdj3 = adjusts?.GetAdjustValue("adj3");
var adj3 = customAdj3 ?? 25000d;
//<gdLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">
// <gd name="a1" fmla="pin 0 adj1 50000" />
// <gd name="a2" fmla="pin 0 adj2 50000" />
// <gd name="a3" fmla="pin 0 adj3 50000" />
// <gd name="y1" fmla="*/ ss a3 100000" />
// <gd name="dx1" fmla="*/ ss a2 50000" />
// <gd name="x1" fmla="+- r 0 dx1" />
// <gd name="dx3" fmla="*/ ss a2 100000" />
// <gd name="x3" fmla="+- r 0 dx3" />
// <gd name="dx2" fmla="*/ ss a1 200000" />
// <gd name="x2" fmla="+- x3 0 dx2" />
// <gd name="x4" fmla="+- x3 dx2 0" />
// <gd name="dy2" fmla="*/ ss a1 100000" />
// <gd name="y2" fmla="+- b 0 dy2" />
// <gd name="x0" fmla="*/ x4 1 2" />
// <gd name="y3" fmla="+/ y2 b 2" />
// <gd name="y15" fmla="+/ y1 b 2" />
//</gdLst>
// <gd name="a1" fmla="pin 0 adj1 50000" />
var a1 = Pin(0, adj1, 50000);
// <gd name="a2" fmla="pin 0 adj2 50000" />
var a2 = Pin(0, adj2, 50000);
// <gd name="a3" fmla="pin 0 adj3 50000" />
var a3 = Pin(0, adj3, 50000);
// <gd name="y1" fmla="*/ ss a3 100000" />
var y1 = ss * a3 / 100000;
// <gd name="dx1" fmla="*/ ss a2 50000" />
var dx1 = ss * a2 / 50000;
// <gd name="x1" fmla="+- r 0 dx1" />
var x1 = r - dx1;
// <gd name="dx3" fmla="*/ ss a2 100000" />
var dx3 = ss * a2 / 100000;
// <gd name="x3" fmla="+- r 0 dx3" />
var x3 = r - dx3;
// <gd name="dx2" fmla="*/ ss a1 200000" />
var dx2 = ss * a1 / 200000;
// <gd name="x2" fmla="+- x3 0 dx2" />
var x2 = x3 - dx2;
// <gd name="x4" fmla="+- x3 dx2 0" />
var x4 = x3 + dx2;
// <gd name="dy2" fmla="*/ ss a1 100000" />
var dy2 = ss * a1 / 100000d;
// <gd name="y2" fmla="+- b 0 dy2" />
var y2 = b - dy2;
// <gd name="x0" fmla="*/ x4 1 2" />
var x0 = x4 * 1 / 2;
// <gd name="y3" fmla="+/ y2 b 2" />
var y3 = (y2 + b) / 2;
// <gd name="y15" fmla="+/ y1 b 2" />
var y15 = (y1 + b) / 2;
//<pathLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">
// <path>
// <moveTo>
// <pt x="l" y="y2" />
// </moveTo>
// <lnTo>
// <pt x="x2" y="y2" />
// </lnTo>
// <lnTo>
// <pt x="x2" y="y1" />
// </lnTo>
// <lnTo>
// <pt x="x1" y="y1" />
// </lnTo>
// <lnTo>
// <pt x="x3" y="t" />
// </lnTo>
// <lnTo>
// <pt x="r" y="y1" />
// </lnTo>
// <lnTo>
// <pt x="x4" y="y1" />
// </lnTo>
// <lnTo>
// <pt x="x4" y="b" />
// </lnTo>
// <lnTo>
// <pt x="l" y="b" />
// </lnTo>
// <close />
// </path>
//</pathLst>
var shapePaths = new ShapePath[1];
// <path>
// <moveTo>
// <pt x="l" y="y2" />
// </moveTo>
var currentPoint = new EmuPoint(l, y2);
var stringPath = new StringBuilder();
stringPath.Append($"M {EmuToPixelString(currentPoint.X)},{EmuToPixelString(currentPoint.Y)} ");
// <lnTo>
// <pt x="x2" y="y2" />
// </lnTo>
currentPoint = LineToToString(stringPath, x2, y2);
// <lnTo>
// <pt x="x2" y="y1" />
// </lnTo>
currentPoint = LineToToString(stringPath, x2, y1);
// <lnTo>
// <pt x="x1" y="y1" />
// </lnTo>
currentPoint = LineToToString(stringPath, x1, y1);
// <lnTo>
// <pt x="x3" y="t" />
// </lnTo>
currentPoint = LineToToString(stringPath, x3, t);
// <lnTo>
// <pt x="r" y="y1" />
// </lnTo>
currentPoint = LineToToString(stringPath, r, y1);
// <lnTo>
// <pt x="x4" y="y1" />
// </lnTo>
currentPoint = LineToToString(stringPath, x4, y1);
// <lnTo>
// <pt x="x4" y="b" />
// </lnTo>
currentPoint = LineToToString(stringPath, x4, b);
// <lnTo>
// <pt x="l" y="b" />
// </lnTo>
currentPoint = LineToToString(stringPath, l, b);
// <close />
stringPath.Append(" z");
// </path>
shapePaths[0] = new ShapePath(stringPath.ToString());
//<rect l="l" t="y2" r="x4" b="b" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" />
InitializeShapeTextRectangle(l, y2, x4, b);
return shapePaths;
}
}
}
| 38.453039 | 179 | 0.418391 | [
"MIT"
] | dotnet-campus/DocumentFormat.OpenXml.Extensions | src/DocumentFormat.OpenXml.Flatten/DocumentFormat.OpenXml.Flatten/ElementConverters/Shape/ShapeGeometryConverters/BentUpArrowGeometry.cs | 6,972 | C# |
using Microsoft.Extensions.DependencyInjection;
namespace DataAccess
{
public static class DataAccessExtensions
{
public static IDataAccessBuilder AddDataAccess(this IServiceCollection services)
{
if (services == null)
{
ExceptionsHelper.ArgumentNullException(nameof(services));
}
return new DataAccessBuilder(services);
}
}
}
| 23.888889 | 88 | 0.630233 | [
"MIT"
] | rostrastegaev/Packages | DataAccess.Abstractions/DataAccessExtensions.cs | 432 | C# |
using SwfLib.Avm2.Data;
namespace SwfLib.Avm2 {
public class AbcNamespace {
public AsType Kind;
public string Name { get; set; }
public override string ToString() {
return string.Format("{0} {1}", Kind, !string.IsNullOrWhiteSpace(Name) ? Name : "*");
}
public static readonly AbcNamespace Any = new AbcNamespace { Kind = AsType.Void, Name = "" };
}
}
| 23.222222 | 101 | 0.600478 | [
"MIT"
] | SavchukSergey/SwfLib | SwfLib.Avm2/AbcNamespace.cs | 420 | C# |
using System;
using System.Linq;
using SULS.Data;
using SULS.Models;
namespace SULS.Services
{
public class SubmissionsService : ISubmissionsService
{
private readonly SULSContext dbContext;
private readonly Random random;
public SubmissionsService(SULSContext dbContext, Random random)
{
this.dbContext = dbContext;
this.random = random;
}
public void Create(string problemId, string userId, string code)
{
var problemMaxPoint = dbContext.Problems
.Where(x => x.Id == problemId)
.Select(x => x.Points)
.FirstOrDefault();
var submission = new Submission()
{
ProblemId = problemId,
UserId = userId,
Code = code,
CreatedOn = DateTime.UtcNow,
AchievedResult = this.random.Next(0, problemMaxPoint + 1)
};
this.dbContext.Submissions.Add(submission);
this.dbContext.SaveChanges();
}
public string GetNameById(string id)
{
var problemName = dbContext.Problems
.FirstOrDefault(x => x.Id == id);
return problemName?.Name;
}
public void Delete(string id)
{
var submission = this.dbContext.Submissions.Find(id);
this.dbContext.Submissions.Remove(submission);
this.dbContext.SaveChanges();
}
}
}
| 27.107143 | 73 | 0.55336 | [
"MIT"
] | iltodbul/SoftUni | C# Web Basics/Exam_Share_Trip_and_SULS/Apps/SULS/Services/SubmissionsService.cs | 1,520 | C# |
// Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
// See license.txt in the FileSharper distribution or repository for the
// full text of the license.
using System.Threading;
using System.IO;
using System;
using System.Collections.Generic;
namespace FileSharperCore
{
public interface ICondition : IPluggableItemWithColumnsAndCacheTypes
{
MatchResult Matches(FileInfo file, Dictionary<Type, IFileCache> fileCaches, CancellationToken token);
}
}
| 28.882353 | 109 | 0.773931 | [
"MIT"
] | adv12/FileSharper | src/FileSharper/FileSharperCore/ICondition.cs | 491 | C# |
// -----------------------------------------------------------------------
// <copyright file="Job.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Cinchcast.Roque.Core
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// <summary>
/// Representation of a task to execute by invoking a method in a service class
/// </summary>
public class Job
{
[Newtonsoft.Json.JsonProperty("t")]
public string Target { get; set; }
[Newtonsoft.Json.JsonProperty("m")]
public string Method { get; set; }
[Newtonsoft.Json.JsonProperty("e")]
public bool IsEvent { get; set; }
[Newtonsoft.Json.JsonProperty("a")]
public string[] Arguments { get; set; }
[Newtonsoft.Json.JsonProperty("c")]
public DateTime CreationUtc { get; set; }
private bool _IsResuming;
[JsonIgnore]
public bool IsResuming
{
get
{
return _IsResuming;
}
}
private Job()
{
}
public static Job Create(string targetTypeFullName, string methodName, params object[] arguments)
{
return new Job
{
Target = targetTypeFullName,
Method = methodName,
Arguments = arguments.Select(arg => JsonConvert.SerializeObject(arg)).ToArray(),
CreationUtc = DateTime.UtcNow
};
}
public static Job Create<T>(string methodName, params object[] arguments)
where T : new()
{
return Create(typeof(T).FullName, methodName, arguments);
}
public void MarkAsResuming()
{
_IsResuming = true;
}
public void Execute(Executor executor = null)
{
(executor ?? Executor.Default).Execute(this);
}
public static string AgeToString(TimeSpan age)
{
StringBuilder ageString = new StringBuilder();
if (age.TotalSeconds < 1)
{
ageString.Append("< 1sec ");
}
else
{
if (age.TotalDays >= 1)
{
ageString.Append((long)Math.Floor(age.TotalDays));
ageString.Append("days ");
}
if (age.Hours >= 1)
{
ageString.Append(age.Hours);
ageString.Append("hrs ");
}
if (age.Minutes >= 1)
{
ageString.Append(age.Minutes);
ageString.Append("min ");
}
if (age.Seconds >= 1)
{
ageString.Append(age.Seconds);
ageString.Append("sec ");
}
}
return ageString.ToString();
}
public string GetAgeString()
{
return AgeToString(DateTime.UtcNow.Subtract(CreationUtc));
}
}
}
| 28.2 | 106 | 0.45331 | [
"MIT"
] | BlogTalkRadio/Roque | Roque.Core/Job.cs | 3,386 | C# |
// 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.
namespace Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20210210
{
using static Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Extensions;
/// <summary>Provider specific input for InMage test failover.</summary>
public partial class InMageTestFailoverInput
{
/// <summary>
/// <c>AfterFromJson</c> will be called after the json deserialization has finished, allowing customization of the object
/// before it is returned. Implement this method in a partial class to enable this behavior
/// </summary>
/// <param name="json">The JsonNode that should be deserialized into this object.</param>
partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject json);
/// <summary>
/// <c>AfterToJson</c> will be called after the json erialization has finished, allowing customization of the <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject"
/// /> before it is returned. Implement this method in a partial class to enable this behavior
/// </summary>
/// <param name="container">The JSON container that the serialization result will be placed in.</param>
partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject container);
/// <summary>
/// <c>BeforeFromJson</c> will be called before the json deserialization has commenced, allowing complete customization of
/// the object before it is deserialized.
/// If you wish to disable the default deserialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter.
/// Implement this method in a partial class to enable this behavior.
/// </summary>
/// <param name="json">The JsonNode that should be deserialized into this object.</param>
/// <param name="returnNow">Determines if the rest of the deserialization should be processed, or if the method should return
/// instantly.</param>
partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject json, ref bool returnNow);
/// <summary>
/// <c>BeforeToJson</c> will be called before the json serialization has commenced, allowing complete customization of the
/// object before it is serialized.
/// If you wish to disable the default serialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter.
/// Implement this method in a partial class to enable this behavior.
/// </summary>
/// <param name="container">The JSON container that the serialization result will be placed in.</param>
/// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return
/// instantly.</param>
partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject container, ref bool returnNow);
/// <summary>
/// Deserializes a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode"/> into an instance of Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20210210.IInMageTestFailoverInput.
/// </summary>
/// <param name="node">a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode" /> to deserialize from.</param>
/// <returns>
/// an instance of Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20210210.IInMageTestFailoverInput.
/// </returns>
public static Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20210210.IInMageTestFailoverInput FromJson(Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode node)
{
return node is Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject json ? new InMageTestFailoverInput(json) : null;
}
/// <summary>
/// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject into a new instance of <see cref="InMageTestFailoverInput" />.
/// </summary>
/// <param name="json">A Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject instance to deserialize from.</param>
internal InMageTestFailoverInput(Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject json)
{
bool returnNow = false;
BeforeFromJson(json, ref returnNow);
if (returnNow)
{
return;
}
__testFailoverProviderSpecificInput = new Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20210210.TestFailoverProviderSpecificInput(json);
{_recoveryPointType = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonString>("recoveryPointType"), out var __jsonRecoveryPointType) ? (string)__jsonRecoveryPointType : (string)RecoveryPointType;}
{_recoveryPointId = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonString>("recoveryPointId"), out var __jsonRecoveryPointId) ? (string)__jsonRecoveryPointId : (string)RecoveryPointId;}
AfterFromJson(json);
}
/// <summary>
/// Serializes this instance of <see cref="InMageTestFailoverInput" /> into a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode" />.
/// </summary>
/// <param name="container">The <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject"/> container to serialize this object into. If the caller
/// passes in <c>null</c>, a new instance will be created and returned to the caller.</param>
/// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SerializationMode"/>.</param>
/// <returns>
/// a serialized instance of <see cref="InMageTestFailoverInput" /> as a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode" />.
/// </returns>
public Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SerializationMode serializationMode)
{
container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonObject();
bool returnNow = false;
BeforeToJson(ref container, ref returnNow);
if (returnNow)
{
return container;
}
__testFailoverProviderSpecificInput?.ToJson(container, serializationMode);
AddIf( null != (((object)this._recoveryPointType)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonString(this._recoveryPointType.ToString()) : null, "recoveryPointType" ,container.Add );
AddIf( null != (((object)this._recoveryPointId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.Json.JsonString(this._recoveryPointId.ToString()) : null, "recoveryPointId" ,container.Add );
AfterToJson(ref container);
return container;
}
}
} | 71.563636 | 297 | 0.69779 | [
"MIT"
] | Agazoth/azure-powershell | src/Migrate/generated/api/Models/Api20210210/InMageTestFailoverInput.json.cs | 7,763 | 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 medialive-2017-10-14.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using System.Net;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
namespace Amazon.MediaLive.Model
{
/// <summary>
/// Container for the parameters to the PurchaseOffering operation.
/// Purchase an offering and create a reservation.
/// </summary>
public partial class PurchaseOfferingRequest : AmazonMediaLiveRequest
{
private int? _count;
private string _name;
private string _offeringId;
private string _requestId;
private string _start;
private Dictionary<string, string> _tags = new Dictionary<string, string>();
/// <summary>
/// Gets and sets the property Count. Number of resources
/// </summary>
[AWSProperty(Required=true, Min=1)]
public int Count
{
get { return this._count.GetValueOrDefault(); }
set { this._count = value; }
}
// Check to see if Count property is set
internal bool IsSetCount()
{
return this._count.HasValue;
}
/// <summary>
/// Gets and sets the property Name. Name for the new reservation
/// </summary>
public string Name
{
get { return this._name; }
set { this._name = value; }
}
// Check to see if Name property is set
internal bool IsSetName()
{
return this._name != null;
}
/// <summary>
/// Gets and sets the property OfferingId. Offering to purchase, e.g. '87654321'
/// </summary>
[AWSProperty(Required=true)]
public string OfferingId
{
get { return this._offeringId; }
set { this._offeringId = value; }
}
// Check to see if OfferingId property is set
internal bool IsSetOfferingId()
{
return this._offeringId != null;
}
/// <summary>
/// Gets and sets the property RequestId. Unique request ID to be specified. This is needed
/// to prevent retries from creating multiple resources.
/// </summary>
public string RequestId
{
get { return this._requestId; }
set { this._requestId = value; }
}
// Check to see if RequestId property is set
internal bool IsSetRequestId()
{
return this._requestId != null;
}
/// <summary>
/// Gets and sets the property Start. Requested reservation start time (UTC) in ISO-8601
/// format. The specified time must be between the first day of the current month and
/// one year from now. If no value is given, the default is now.
/// </summary>
public string Start
{
get { return this._start; }
set { this._start = value; }
}
// Check to see if Start property is set
internal bool IsSetStart()
{
return this._start != null;
}
/// <summary>
/// Gets and sets the property Tags. A collection of key-value pairs
/// </summary>
public Dictionary<string, string> Tags
{
get { return this._tags; }
set { this._tags = value; }
}
// Check to see if Tags property is set
internal bool IsSetTags()
{
return this._tags != null && this._tags.Count > 0;
}
}
} | 31.407143 | 108 | 0.568342 | [
"Apache-2.0"
] | philasmar/aws-sdk-net | sdk/src/Services/MediaLive/Generated/Model/PurchaseOfferingRequest.cs | 4,397 | C# |
using System;
using static BulletSharp.UnsafeNativeMethods;
namespace BulletSharp
{
public class DefaultCollisionConstructionInfo : BulletDisposableObject
{
private PoolAllocator _collisionAlgorithmPool;
private PoolAllocator _persistentManifoldPool;
public DefaultCollisionConstructionInfo()
{
IntPtr native = btDefaultCollisionConstructionInfo_new();
InitializeUserOwned(native);
}
public PoolAllocator CollisionAlgorithmPool
{
get => _collisionAlgorithmPool;
set
{
btDefaultCollisionConstructionInfo_setCollisionAlgorithmPool(Native, value.Native);
_collisionAlgorithmPool = value;
}
}
public int CustomCollisionAlgorithmMaxElementSize
{
get => btDefaultCollisionConstructionInfo_getCustomCollisionAlgorithmMaxElementSize(Native);
set => btDefaultCollisionConstructionInfo_setCustomCollisionAlgorithmMaxElementSize(Native, value);
}
public int DefaultMaxCollisionAlgorithmPoolSize
{
get => btDefaultCollisionConstructionInfo_getDefaultMaxCollisionAlgorithmPoolSize(Native);
set => btDefaultCollisionConstructionInfo_setDefaultMaxCollisionAlgorithmPoolSize(Native, value);
}
public int DefaultMaxPersistentManifoldPoolSize
{
get => btDefaultCollisionConstructionInfo_getDefaultMaxPersistentManifoldPoolSize(Native);
set => btDefaultCollisionConstructionInfo_setDefaultMaxPersistentManifoldPoolSize(Native, value);
}
public PoolAllocator PersistentManifoldPool
{
get => _persistentManifoldPool;
set
{
btDefaultCollisionConstructionInfo_setPersistentManifoldPool(Native, value.Native);
_persistentManifoldPool = value;
}
}
public int UseEpaPenetrationAlgorithm
{
get => btDefaultCollisionConstructionInfo_getUseEpaPenetrationAlgorithm(Native);
set => btDefaultCollisionConstructionInfo_setUseEpaPenetrationAlgorithm(Native, value);
}
protected override void Dispose(bool disposing)
{
if (IsDisposed == false)
{
btDefaultCollisionConstructionInfo_delete(Native);
}
}
}
public class DefaultCollisionConfiguration : CollisionConfiguration
{
protected PoolAllocator _collisionAlgorithmPool;
protected PoolAllocator _persistentManifoldPool;
internal DefaultCollisionConfiguration(ConstructionInfo info)
{
}
public DefaultCollisionConfiguration()
{
IntPtr native = btDefaultCollisionConfiguration_new();
InitializeUserOwned(native);
}
public DefaultCollisionConfiguration(DefaultCollisionConstructionInfo constructionInfo)
{
if (constructionInfo == null)
{
throw new ArgumentNullException(nameof(constructionInfo));
}
_collisionAlgorithmPool = constructionInfo.CollisionAlgorithmPool;
_persistentManifoldPool = constructionInfo.PersistentManifoldPool;
IntPtr native = btDefaultCollisionConfiguration_new2(constructionInfo.Native);
InitializeUserOwned(native);
}
public override CollisionAlgorithmCreateFunc GetClosestPointsAlgorithmCreateFunc(BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1)
{
IntPtr createFunc = btCollisionConfiguration_getClosestPointsAlgorithmCreateFunc(Native, (int)proxyType0, (int)proxyType1);
if (proxyType0 == BroadphaseNativeType.BoxShape && proxyType1 == BroadphaseNativeType.BoxShape)
{
return new BoxBoxCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.SphereShape && proxyType1 == BroadphaseNativeType.SphereShape)
{
return new SphereSphereCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.SphereShape && proxyType1 == BroadphaseNativeType.TriangleShape)
{
return new SphereTriangleCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.TriangleShape && proxyType1 == BroadphaseNativeType.SphereShape)
{
return new SphereTriangleCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.StaticPlaneShape && BroadphaseProxy.IsConvex(proxyType1))
{
return new ConvexPlaneCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType1 == BroadphaseNativeType.StaticPlaneShape && BroadphaseProxy.IsConvex(proxyType0))
{
return new ConvexPlaneCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConvex(proxyType1))
{
return new ConvexConvexAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConcave(proxyType1))
{
return new ConvexConcaveCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsConvex(proxyType1) && BroadphaseProxy.IsConcave(proxyType0))
{
return new ConvexConcaveCollisionAlgorithm.SwappedCreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsCompound(proxyType0))
{
return new CompoundCompoundCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsCompound(proxyType1))
{
return new CompoundCompoundCollisionAlgorithm.SwappedCreateFunc(createFunc, this);
}
return new EmptyAlgorithm.CreateFunc(createFunc, this);
}
public override CollisionAlgorithmCreateFunc GetCollisionAlgorithmCreateFunc(BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1)
{
IntPtr createFunc = btCollisionConfiguration_getCollisionAlgorithmCreateFunc(Native, (int)proxyType0, (int)proxyType1);
if (proxyType0 == BroadphaseNativeType.BoxShape && proxyType1 == BroadphaseNativeType.BoxShape)
{
return new BoxBoxCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.SphereShape && proxyType1 == BroadphaseNativeType.SphereShape)
{
return new SphereSphereCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.SphereShape && proxyType1 == BroadphaseNativeType.TriangleShape)
{
return new SphereTriangleCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.TriangleShape && proxyType1 == BroadphaseNativeType.SphereShape)
{
return new SphereTriangleCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType0 == BroadphaseNativeType.StaticPlaneShape && BroadphaseProxy.IsConvex(proxyType1))
{
return new ConvexPlaneCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (proxyType1 == BroadphaseNativeType.StaticPlaneShape && BroadphaseProxy.IsConvex(proxyType0))
{
return new ConvexPlaneCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConvex(proxyType1))
{
return new ConvexConvexAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConcave(proxyType1))
{
return new ConvexConcaveCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsConvex(proxyType1) && BroadphaseProxy.IsConcave(proxyType0))
{
return new ConvexConcaveCollisionAlgorithm.SwappedCreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsCompound(proxyType0))
{
return new CompoundCompoundCollisionAlgorithm.CreateFunc(createFunc, this);
}
if (BroadphaseProxy.IsCompound(proxyType1))
{
return new CompoundCompoundCollisionAlgorithm.SwappedCreateFunc(createFunc, this);
}
return new EmptyAlgorithm.CreateFunc(createFunc, this);
}
public void SetConvexConvexMultipointIterations(int numPerturbationIterations = 3,
int minimumPointsPerturbationThreshold = 3)
{
btDefaultCollisionConfiguration_setConvexConvexMultipointIterations(
Native, numPerturbationIterations, minimumPointsPerturbationThreshold);
}
public void SetPlaneConvexMultipointIterations(int numPerturbationIterations = 3,
int minimumPointsPerturbationThreshold = 3)
{
btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations(Native,
numPerturbationIterations, minimumPointsPerturbationThreshold);
}
public override PoolAllocator CollisionAlgorithmPool
{
get
{
if (_collisionAlgorithmPool == null)
{
_collisionAlgorithmPool = new PoolAllocator(btCollisionConfiguration_getCollisionAlgorithmPool(Native), this);
}
return _collisionAlgorithmPool;
}
}
public override PoolAllocator PersistentManifoldPool
{
get
{
if (_persistentManifoldPool == null)
{
_persistentManifoldPool = new PoolAllocator(btCollisionConfiguration_getPersistentManifoldPool(Native), this);
}
return _persistentManifoldPool;
}
}
}
}
| 35.920168 | 148 | 0.790736 | [
"Apache-2.0"
] | xtom0369/BulletPhysicsForUnity | BulletSharpPInvoke/BulletSharp/Collision/DefaultCollisionConfiguration.cs | 8,549 | C# |
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MyApp.Namespace1
{
[Area("Blog")]
public class UsersController : Controller
{
public IActionResult AddUser()
{
return View();
}
}
}
namespace MyApp.Namespace2
{
// Matches { area = Zebra, controller = Users, action = AddUser }
[Area("Zebra")]
public class UsersController : Controller
{
public IActionResult AddUser()
{
return View();
}
}
}
namespace MyApp.Namespace3
{
// Matches { area = string.Empty, controller = Users, action = AddUser }
// Matches { area = null, controller = Users, action = AddUser }
// Matches { controller = Users, action = AddUser }
public class UsersController : Controller
{
public IActionResult AddUser()
{
return View();
}
}
}
namespace MyApp.Namespace4
{
[Area("Duck")]
public class UsersController : Controller
{
public IActionResult GenerateURLInArea()
{
// Uses the 'ambient' value of area
var url = Url.Action("Index", "Home");
// returns /Manage
return Content(url);
}
public IActionResult GenerateURLOutsideOfArea()
{
// Uses the empty value for area
var url = Url.Action("Index", "Home", new { area = "" });
// returns /Manage/Home/Index
return Content(url);
}
}
} | 22.253521 | 76 | 0.570886 | [
"Apache-2.0"
] | vincoss/NetCoreSamples | AspNetCore-2.0/src/WebApps_Mvc_Routing/Controllers/UsersController.cs | 1,582 | C# |
/*
* Copyright 2010-2014 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 rekognition-2016-06-27.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
namespace Amazon.Rekognition.Model
{
/// <summary>
/// Information about the Amazon Kinesis Data Streams stream to which a Rekognition Video
/// stream processor streams the results of a video analysis. For more information, see
/// .
/// </summary>
public partial class StreamProcessorOutput
{
private KinesisDataStream _kinesisDataStream;
/// <summary>
/// Gets and sets the property KinesisDataStream.
/// <para>
/// The Amazon Kinesis Data Streams stream to which the Amazon Rekognition stream processor
/// streams the analysis results.
/// </para>
/// </summary>
public KinesisDataStream KinesisDataStream
{
get { return this._kinesisDataStream; }
set { this._kinesisDataStream = value; }
}
// Check to see if KinesisDataStream property is set
internal bool IsSetKinesisDataStream()
{
return this._kinesisDataStream != null;
}
}
} | 32.288136 | 109 | 0.678215 | [
"Apache-2.0"
] | HaiNguyenMediaStep/aws-sdk-net | sdk/src/Services/Rekognition/Generated/Model/StreamProcessorOutput.cs | 1,905 | C# |
using AntDesign.Abp.Template.Blazor.Models;
namespace AntDesign.Abp.Template.Blazor.Pages.Form
{
public partial class BasicForm
{
private readonly BasicFormModel _model = new BasicFormModel();
private void HandleSubmit()
{
}
}
} | 21.076923 | 70 | 0.667883 | [
"Apache-2.0"
] | ElderJames/ant-design-blazor-abp | templates/src/AntDesign.Abp.Template.Blazor/Pages/Form/BasicForm/BasicForm.razor.cs | 274 | C# |
/******************************************************************************
* $Id: GDALRead.cs f070adf64950cae1c6cc86b104ba835c29df06b1 2016-08-28 06:06:11Z Kurt Schwehr $
*
* Name: GDALRead.cs
* Project: GDAL CSharp Interface
* Purpose: A sample app to read GDAL raster data.
* Author: Tamas Szekeres, [email protected]
*
******************************************************************************
* Copyright (c) 2007, Tamas Szekeres
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
using System;
using System.Drawing;
using System.Drawing.Imaging;
using OSGeo.GDAL;
/**
* <p>Title: GDAL C# GDALRead example.</p>
* <p>Description: A sample app to read GDAL raster data.</p>
* @author Tamas Szekeres ([email protected])
* @version 1.0
*/
/// <summary>
/// A C# based sample to read GDAL raster data.
/// </summary>
class GDALRead {
public static void usage()
{
Console.WriteLine("usage: gdalread {GDAL dataset name} {output file name} {overview}");
System.Environment.Exit(-1);
}
public static void Main(string[] args)
{
int iOverview = -1;
if (args.Length < 2) usage();
if (args.Length == 3) iOverview = int.Parse(args[2]);
// Using early initialization of System.Console
Console.WriteLine("");
try
{
/* -------------------------------------------------------------------- */
/* Register driver(s). */
/* -------------------------------------------------------------------- */
Gdal.AllRegister();
/* -------------------------------------------------------------------- */
/* Open dataset. */
/* -------------------------------------------------------------------- */
Dataset ds = Gdal.Open( args[0], Access.GA_ReadOnly );
if (ds == null)
{
Console.WriteLine("Can't open " + args[0]);
System.Environment.Exit(-1);
}
Console.WriteLine("Raster dataset parameters:");
Console.WriteLine(" Projection: " + ds.GetProjectionRef());
Console.WriteLine(" RasterCount: " + ds.RasterCount);
Console.WriteLine(" RasterSize (" + ds.RasterXSize + "," + ds.RasterYSize + ")");
/* -------------------------------------------------------------------- */
/* Get driver */
/* -------------------------------------------------------------------- */
Driver drv = ds.GetDriver();
if (drv == null)
{
Console.WriteLine("Can't get driver.");
System.Environment.Exit(-1);
}
Console.WriteLine("Using driver " + drv.LongName);
/* -------------------------------------------------------------------- */
/* Get raster band */
/* -------------------------------------------------------------------- */
for (int iBand = 1; iBand <= ds.RasterCount; iBand++)
{
Band band = ds.GetRasterBand(iBand);
Console.WriteLine("Band " + iBand + " :");
Console.WriteLine(" DataType: " + band.DataType);
Console.WriteLine(" Size (" + band.XSize + "," + band.YSize + ")");
Console.WriteLine(" PaletteInterp: " + band.GetRasterColorInterpretation().ToString());
for (int iOver = 0; iOver < band.GetOverviewCount(); iOver++)
{
Band over = band.GetOverview(iOver);
Console.WriteLine(" OverView " + iOver + " :");
Console.WriteLine(" DataType: " + over.DataType);
Console.WriteLine(" Size (" + over.XSize + "," + over.YSize + ")");
Console.WriteLine(" PaletteInterp: " + over.GetRasterColorInterpretation().ToString());
}
}
/* -------------------------------------------------------------------- */
/* Processing the raster */
/* -------------------------------------------------------------------- */
SaveBitmapBuffered(ds, args[1], iOverview);
}
catch (Exception e)
{
Console.WriteLine("Application error: " + e.Message);
}
}
private static void SaveBitmapBuffered(Dataset ds, string filename, int iOverview)
{
// Get the GDAL Band objects from the Dataset
Band redBand = ds.GetRasterBand(1);
if (redBand.GetRasterColorInterpretation() == ColorInterp.GCI_PaletteIndex)
{
SaveBitmapPaletteBuffered(ds, filename, iOverview);
return;
}
if (redBand.GetRasterColorInterpretation() == ColorInterp.GCI_GrayIndex)
{
SaveBitmapGrayBuffered(ds, filename, iOverview);
return;
}
if (redBand.GetRasterColorInterpretation() != ColorInterp.GCI_RedBand)
{
Console.WriteLine("Non RGB images are not supported by this sample! ColorInterp = " +
redBand.GetRasterColorInterpretation().ToString());
return;
}
if (ds.RasterCount < 3)
{
Console.WriteLine("The number of the raster bands is not enough to run this sample");
System.Environment.Exit(-1);
}
if (iOverview >= 0 && redBand.GetOverviewCount() > iOverview)
redBand = redBand.GetOverview(iOverview);
Band greenBand = ds.GetRasterBand(2);
if (greenBand.GetRasterColorInterpretation() != ColorInterp.GCI_GreenBand)
{
Console.WriteLine("Non RGB images are not supported by this sample! ColorInterp = " +
greenBand.GetRasterColorInterpretation().ToString());
return;
}
if (iOverview >= 0 && greenBand.GetOverviewCount() > iOverview)
greenBand = greenBand.GetOverview(iOverview);
Band blueBand = ds.GetRasterBand(3);
if (blueBand.GetRasterColorInterpretation() != ColorInterp.GCI_BlueBand)
{
Console.WriteLine("Non RGB images are not supported by this sample! ColorInterp = " +
blueBand.GetRasterColorInterpretation().ToString());
return;
}
if (iOverview >= 0 && blueBand.GetOverviewCount() > iOverview)
blueBand = blueBand.GetOverview(iOverview);
// Get the width and height of the raster
int width = redBand.XSize;
int height = redBand.YSize;
// Create a Bitmap to store the GDAL image in
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
DateTime start = DateTime.Now;
byte[] r = new byte[width * height];
byte[] g = new byte[width * height];
byte[] b = new byte[width * height];
redBand.ReadRaster(0, 0, width, height, r, width, height, 0, 0);
greenBand.ReadRaster(0, 0, width, height, g, width, height, 0, 0);
blueBand.ReadRaster(0, 0, width, height, b, width, height, 0, 0);
TimeSpan renderTime = DateTime.Now - start;
Console.WriteLine("SaveBitmapBuffered fetch time: " + renderTime.TotalMilliseconds + " ms");
int i, j;
for (i = 0; i< width; i++)
{
for (j=0; j<height; j++)
{
Color newColor = Color.FromArgb(Convert.ToInt32(r[i+j*width]),Convert.ToInt32(g[i+j*width]), Convert.ToInt32(b[i+j*width]));
bitmap.SetPixel(i, j, newColor);
}
}
bitmap.Save(filename);
}
private static void SaveBitmapPaletteBuffered(Dataset ds, string filename, int iOverview)
{
// Get the GDAL Band objects from the Dataset
Band band = ds.GetRasterBand(1);
if (iOverview >= 0 && band.GetOverviewCount() > iOverview)
band = band.GetOverview(iOverview);
ColorTable ct = band.GetRasterColorTable();
if (ct == null)
{
Console.WriteLine(" Band has no color table!");
return;
}
if (ct.GetPaletteInterpretation() != PaletteInterp.GPI_RGB)
{
Console.WriteLine(" Only RGB palette interp is supported by this sample!");
return;
}
// Get the width and height of the Dataset
int width = band.XSize;
int height = band.YSize;
// Create a Bitmap to store the GDAL image in
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
DateTime start = DateTime.Now;
byte[] r = new byte[width * height];
band.ReadRaster(0, 0, width, height, r, width, height, 0, 0);
TimeSpan renderTime = DateTime.Now - start;
Console.WriteLine("SaveBitmapBuffered fetch time: " + renderTime.TotalMilliseconds + " ms");
int i, j;
for (i = 0; i< width; i++)
{
for (j=0; j<height; j++)
{
ColorEntry entry = ct.GetColorEntry(r[i+j*width]);
Color newColor = Color.FromArgb(Convert.ToInt32(entry.c1),Convert.ToInt32(entry.c2), Convert.ToInt32(entry.c3));
bitmap.SetPixel(i, j, newColor);
}
}
bitmap.Save(filename);
}
private static void SaveBitmapGrayBuffered(Dataset ds, string filename, int iOverview)
{
// Get the GDAL Band objects from the Dataset
Band band = ds.GetRasterBand(1);
if (iOverview >= 0 && band.GetOverviewCount() > iOverview)
band = band.GetOverview(iOverview);
// Get the width and height of the Dataset
int width = band.XSize;
int height = band.YSize;
// Create a Bitmap to store the GDAL image in
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
DateTime start = DateTime.Now;
byte[] r = new byte[width * height];
band.ReadRaster(0, 0, width, height, r, width, height, 0, 0);
TimeSpan renderTime = DateTime.Now - start;
Console.WriteLine("SaveBitmapBuffered fetch time: " + renderTime.TotalMilliseconds + " ms");
int i, j;
for (i = 0; i< width; i++)
{
for (j=0; j<height; j++)
{
Color newColor = Color.FromArgb(Convert.ToInt32(r[i+j*width]),Convert.ToInt32(r[i+j*width]), Convert.ToInt32(r[i+j*width]));
bitmap.SetPixel(i, j, newColor);
}
}
bitmap.Save(filename);
}
} | 36.4791 | 140 | 0.547113 | [
"Apache-2.0"
] | VisualAwarenessTech/gdal-2.3.1 | swig/csharp/apps/GDALRead.cs | 11,345 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
namespace Runner.Problems
{
public class Problem0030 : Problem
{
public override object Solve()
{
var powers = new Dictionary<int, int>
{ {0,0},{1, 1}, {2, 32}, {3,243}, {4, 1024}, {5, 3125}, {6, 7776}, {7,16807}, {8,32768}, {9,59049} };
var foundNumbers = new List<int>();
for (var numberOfDigits = 2; numberOfDigits <= 6; numberOfDigits++)
{
// Init with as many ones as we have digits
var digits = InitCurrentDigits(numberOfDigits);
while (Increment(ref digits))
{
var sum = digits.Sum(p => powers[p]);
var number = DigitsToNumber(digits);
if (sum == number)
{
foundNumbers.Add(sum);
}
}
}
foreach (var foundNumber in foundNumbers)
{
Console.WriteLine(foundNumber);
}
return foundNumbers.Sum();
}
private bool Increment(ref int[] digits)
{
if (digits.All(p => p == 9)) return false;
var number = DigitsToNumber(digits);
number++;
digits = NumberToDigits(number).Reverse().ToArray();
return true;
}
private static IEnumerable<int> NumberToDigits(int number)
{
do
{
yield return number % 10;
number /= 10;
} while (number > 0);
}
private static int[] InitCurrentDigits(int numberOfDigits)
{
var currentDigits = new int[numberOfDigits];
for (var j = 0; j < numberOfDigits; j++)
{
currentDigits[j] = 1;
}
return currentDigits;
}
private int DigitsToNumber(int[] currentNumbers)
{
int number = 0;
for (var i = 0; i < currentNumbers.Length; i++)
{
var multiplier = (int)Math.Pow(10, currentNumbers.Length - i - 1);
number += currentNumbers[i] * multiplier;
}
return number;
}
}
} | 28.402439 | 117 | 0.466295 | [
"MIT"
] | MadCowDevelopment/ProjectEuler | Runner/Problems/0026-0050/Problem0030.cs | 2,331 | C# |
namespace SrkToolkit.Common.urlmon
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
/// <summary>
/// Contains P/Invoke code.
/// </summary>
public static class NativeMethods
{
/// <summary>
/// Finds the MIME from data.
/// </summary>
/// <param name="pBC">A pointer to the IBindCtx interface. Can be set to NULL.</param>
/// <param name="pwzUrl">A pointer to a string value that contains the URL of the data. Can be set to NULL if pBuffer contains the data to be sniffed.</param>
/// <param name="pBuffer">A pointer to the buffer that contains the data to be sniffed. Can be set to NULL if pwzUrl contains a valid URL.</param>
/// <param name="cbSize">An unsigned long integer value that contains the size of the buffer.</param>
/// <param name="pwzMimeProposed">A pointer to a string value that contains the proposed MIME type. This value is authoritative if type cannot be determined from the data. If the proposed type contains a semi-colon (;) it is removed. This parameter can be set to NULL.</param>
/// <param name="dwMimeFlags">
/// One of the following required values:
/// FMFD_DEFAULT
/// No flags specified. Use default behavior for the function.
/// FMFD_URLASFILENAME
/// Treat the specified pwzUrl as a file name.
/// FMFD_ENABLEMIMESNIFFING
/// Microsoft Internet Explorer 6 for Windows XP Service Pack 2 (SP2) and later. Use MIME-type detection even if FEATURE_MIME_SNIFFING is detected. Usually, this feature control key would disable MIME-type detection.
/// FMFD_IGNOREMIMETEXTPLAIN
/// Internet Explorer 6 for Windows XP SP2 and later. Perform MIME-type detection if "text/plain" is proposed, even if data sniffing is otherwise disabled. Plain text may be converted to text/html if HTML tags are detected.
/// FMFD_SERVERMIME
/// Windows Internet Explorer 8. Use the authoritative MIME type specified in pwzMimeProposed. Unless FMFD_IGNOREMIMETEXTPLAIN is specified, no data sniffing is performed.
/// FMFD_RESPECTTEXTPLAIN New for Internet Explorer 9
/// Internet Explorer 9. Do not perform detection if "text/plain" is specified in pwzMimeProposed.
/// FMFD_RETURNUPDATEDIMGMIMES New for Internet Explorer 9
/// Internet Explorer 9. Returns image/png and image/jpeg instead of image/x-png and image/pjpeg.
/// </param>
/// <param name="ppwzMimeOut">The address of a string value that receives the suggested MIME type.</param>
/// <param name="dwReserved">Reserved. Must be set to 0.</param>
/// <returns>
/// Returns one of the following values.
/// S_OK The operation completed successfully.
/// E_FAIL The operation failed.
/// E_INVALIDARG One or more arguments are invalid.
/// E_OUTOFMEMORY There is insufficient memory to complete the operation.
/// </returns>
[DllImport(@"urlmon.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false)]
private extern static int FindMimeFromData(
IntPtr pBC,
[MarshalAs(UnmanagedType.LPWStr)] string pwzUrl,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1, SizeParamIndex = 3)] byte[] pBuffer,
int cbSize,
[MarshalAs(UnmanagedType.LPWStr)] string pwzMimeProposed,
int dwMimeFlags,
out IntPtr ppwzMimeOut,
int dwReserved
);
/// <summary>
/// Wraps a call to urlmon.dll/GetMimeFromFile.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <param name="filename">The filename.</param>
/// <returns></returns>
public static string GetMimeFromFile(byte[] buffer, string filename)
{
try
{
IntPtr mimetype;
int result = FindMimeFromData(IntPtr.Zero, filename, buffer, 256, string.Empty, 0, out mimetype, 0);
if (result != 0)
{
throw Marshal.GetExceptionForHR(result);
}
string mime = Marshal.PtrToStringUni(mimetype);
Marshal.FreeCoTaskMem(mimetype);
// let's fix windows
if (mime == "image/x-png")
mime = "image/png";
return string.IsNullOrWhiteSpace(mime) ? null : mime;
}
catch (AccessViolationException)
{
throw;
}
catch (Exception)
{
throw;
}
}
}
}
| 50.838384 | 285 | 0.594278 | [
"Apache-2.0"
] | sandrock/SrkToolkit | Sources/NET4.SrkToolkit.Common.Unsafe/urlmon/NativeMethods.cs | 5,035 | 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("02. BonusScore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("02. BonusScore")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ca02379a-99e9-42ac-b431-69be4ea4c94b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 37.864865 | 84 | 0.743041 | [
"MIT"
] | Jorka7a13/SoftUni_CSharpBasics | 05. Conditional-Statements-Homework/Problem 02. BonusScore/Properties/AssemblyInfo.cs | 1,404 | C# |
using System;
using System.Collections.Generic;
using System.Text;
using BinaryAnalyzer.RecordTypeHandler;
using BinaryAnalyzer.Interface;
namespace BinaryAnalyzer.Struct
{
/// <summary>
/// The ObjectNullMultiple256 record provides the most compact form for multiple, consecutive Null records when the count of Null records is less than 256. The mechanism to serialize a Null Object is described in [MS-NRTP] section 3.1.5.1.12.
/// </summary>
class ObjectNullMultiple256 : IRecordObject
{
/// <summary>
/// A RecordTypeEnumeration value that identifies the record type. The value MUST be 13.
/// </summary>
public RecordTypeEnumeration RecordTypeEnum { set; get; } = RecordTypeEnumeration.ObjectNullMultiple256;
/// <summary>
/// A BYTE value (as specified in [MS-DTYP] section 2.2.6) that is the count of the number of consecutive Null objects. The value MUST be in the range of 0 to 255, inclusive.
/// </summary>
public byte NullCount { set; get; }
}
}
| 43.666667 | 246 | 0.701336 | [
"MIT"
] | tylearymf/.Net_BinaryAnalyzer | BinaryAnalyzer/BinaryAnalyzer/Struct/ObjectNullMultiple256.cs | 1,050 | C# |
using System;
using System.Text.RegularExpressions;
using Windows.Data.Json;
namespace HttpWebcamLiveStream.Web
{
public class HttpServerRequest
{
public string Request { get; private set; }
public JsonObject Body { get; private set; }
public string Url { get; private set; }
public bool Error { get; private set; }
public HttpServerRequest(string request, bool error)
{
request = request ?? string.Empty;
Request = request;
Error = error;
var urlRegex = new Regex(".*GET(.*)HTTP.*", RegexOptions.IgnoreCase);
var urlGroups = urlRegex.Match(request).Groups;
Url = urlGroups.Count >= 2 ? urlGroups[1].Value.Trim() : string.Empty;
var bodyRegex = new Regex("<RequestBody>(.*)</RequestBody>", RegexOptions.IgnoreCase);
var bodyGroups = bodyRegex.Match(Uri.UnescapeDataString(Url)).Groups;
var body = bodyGroups.Count >= 2 ? bodyGroups[1].Value.Trim() : null;
if (body != null)
{
JsonObject bodyJson = null;
if (JsonObject.TryParse(body, out bodyJson))
{
Body = bodyJson;
}
}
}
}
}
| 32.820513 | 98 | 0.5625 | [
"MIT"
] | SaschaIoT/HttpWebcamLiveStream | HttpWebcamLiveStream/Web/HttpServerRequest.cs | 1,282 | C# |
using System;
using System.Text;
using RabbitMQ.Client;
class Program
{
static void Main()
{
Console.Title = "Samples.RabbitMQ.NativeIntegration.Sender";
var connectionFactory = new ConnectionFactory();
using (var connection = connectionFactory.CreateConnection(Console.Title))
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
return;
}
using (var channel = connection.CreateModel())
{
var properties = channel.CreateBasicProperties();
#region GenerateUniqueMessageId
var messageId = Guid.NewGuid().ToString();
properties.MessageId = messageId;
#endregion
#region CreateNativePayload
var payload = "<MyMessage><SomeProperty>Hello from native sender</SomeProperty></MyMessage>";
#endregion
#region SendMessage
channel.BasicPublish(string.Empty, "Samples.RabbitMQ.NativeIntegration", false, properties, Encoding.UTF8.GetBytes(payload));
#endregion
Console.WriteLine($"Message with id {messageId} sent to queue Samples.RabbitMQ.NativeIntegration");
}
}
}
}
}
| 33.28 | 146 | 0.51863 | [
"Apache-2.0"
] | A-Franklin/docs.particular.net | samples/rabbitmq/native-integration/Rabbit_3/NativeSender/Program.cs | 1,617 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Routing;
namespace PepperDash.Essentials.Devices.Common
{
public class Roku2 : EssentialsDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs
{
[Api]
public IrOutputPortController IrPort { get; private set; }
public const string StandardDriverName = "Roku XD_S.ir";
[Api]
public uint DisplayUiType { get { return DisplayUiConstants.TypeRoku; } }
public Roku2(string key, string name, IrOutputPortController portCont)
: base(key, name)
{
IrPort = portCont;
DeviceManager.AddDevice(portCont);;
HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, null, this);
OutputPorts = new RoutingPortCollection<RoutingOutputPort> { HdmiOut };
}
#region IDPad Members
[Api]
public void Up(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_UP_ARROW, pressRelease);
}
[Api]
public void Down(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_DN_ARROW, pressRelease);
}
[Api]
public void Left(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_LEFT_ARROW, pressRelease);
}
[Api]
public void Right(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_RIGHT_ARROW, pressRelease);
}
[Api]
public void Select(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease);
}
[Api]
public void Menu(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_MENU, pressRelease);
}
[Api]
public void Exit(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_EXIT, pressRelease);
}
#endregion
#region ITransport Members
[Api]
public void Play(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease);
}
[Api]
public void Pause(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_PAUSE, pressRelease);
}
[Api]
public void Rewind(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease);
}
[Api]
public void FFwd(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease);
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void ChapMinus(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void ChapPlus(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Stop(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Record(bool pressRelease)
{
}
#endregion
#region IRoutingOutputs Members
public RoutingOutputPort HdmiOut { get; private set; }
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
#endregion
}
public class Roku2Factory : EssentialsDeviceFactory<Roku2>
{
public Roku2Factory()
{
TypeNames = new List<string>() { "roku" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new Roku Device");
var irCont = IRPortHelper.GetIrOutputPortController(dc);
return new Roku2(dc.Key, dc.Name, irCont);
}
}
} | 23.439759 | 114 | 0.716782 | [
"MIT"
] | JaytheSpazz/Essentials | essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs | 3,893 | C# |
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Reflection;
using Orleans.CodeGeneration;
using Orleans.Concurrency;
using Orleans.Runtime;
namespace Orleans.Serialization
{
internal static class BuiltInTypes
{
#region Constants
private static readonly Type objectType = typeof(object);
#endregion
#region Generic collections
internal static void SerializeGenericReadOnlyCollection(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeReadOnlyCollection), nameof(DeserializeReadOnlyCollection), nameof(DeepCopyReadOnlyCollection), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericReadOnlyCollection(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeReadOnlyCollection), nameof(DeserializeReadOnlyCollection), nameof(DeepCopyReadOnlyCollection), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericReadOnlyCollection(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeReadOnlyCollection), nameof(DeserializeReadOnlyCollection), nameof(DeepCopyReadOnlyCollection), generics);
return concretes.Item3(original);
}
internal static void SerializeReadOnlyCollection<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var collection = (ReadOnlyCollection<T>)obj;
stream.Write(collection.Count);
foreach (var element in collection)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeReadOnlyCollection<T>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var list = new List<T>(count);
DeserializationContext.Current.RecordObject(list);
for (var i = 0; i < count; i++)
{
list.Add((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
var ret = new ReadOnlyCollection<T>(list);
DeserializationContext.Current.RecordObject(ret);
return ret;
}
internal static object DeepCopyReadOnlyCollection<T>(object original)
{
var collection = (ReadOnlyCollection<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return original;
}
var innerList = new List<T>(collection.Count);
innerList.AddRange(collection.Select(element => (T)SerializationManager.DeepCopyInner(element)));
var retVal = new ReadOnlyCollection<T>(innerList);
SerializationContext.Current.RecordObject(original, retVal);
return retVal;
}
#region Lists
internal static void SerializeGenericList(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeList), nameof(DeserializeList), nameof(DeepCopyList), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericList(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeList), nameof(DeserializeList), nameof(DeepCopyList), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericList(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeList), nameof(DeserializeList), nameof(DeepCopyList), generics);
return concretes.Item3(original);
}
internal static void SerializeList<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var list = (List<T>)obj;
stream.Write(list.Count);
foreach (var element in list)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeList<T>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var list = new List<T>(count);
DeserializationContext.Current.RecordObject(list);
for (var i = 0; i < count; i++)
{
list.Add((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
return list;
}
internal static object DeepCopyList<T>(object original)
{
var list = (List<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return new List<T>(list);
}
// set the list capacity, to avoid list resizing.
var retVal = new List<T>(list.Count);
SerializationContext.Current.RecordObject(original, retVal);
retVal.AddRange(list.Select(element => (T)SerializationManager.DeepCopyInner(element)));
return retVal;
}
#endregion
#region LinkedLists
internal static void SerializeGenericLinkedList(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeLinkedList), nameof(DeserializeLinkedList), nameof(DeepCopyLinkedList), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericLinkedList(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeLinkedList), nameof(DeserializeLinkedList), nameof(DeepCopyLinkedList), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericLinkedList(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeLinkedList), nameof(DeserializeLinkedList), nameof(DeepCopyLinkedList), generics);
return concretes.Item3(original);
}
internal static void SerializeLinkedList<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var list = (LinkedList<T>)obj;
stream.Write(list.Count);
foreach (var element in list)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeLinkedList<T>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var list = new LinkedList<T>();
DeserializationContext.Current.RecordObject(list);
for (var i = 0; i < count; i++)
{
list.AddLast((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
return list;
}
internal static object DeepCopyLinkedList<T>(object original)
{
var list = (LinkedList<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return new LinkedList<T>(list);
}
var retVal = new LinkedList<T>();
SerializationContext.Current.RecordObject(original, retVal);
foreach (var item in list)
{
retVal.AddLast((T)SerializationManager.DeepCopyInner(item));
}
return retVal;
}
#endregion
#region HashSets
internal static void SerializeGenericHashSet(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeHashSet), nameof(DeserializeHashSet), nameof(DeepCopyHashSet), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericHashSet(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeHashSet), nameof(DeserializeHashSet), nameof(DeepCopyHashSet), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericHashSet(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeHashSet), nameof(DeserializeHashSet), nameof(DeepCopyHashSet), generics);
return concretes.Item3(original);
}
internal static void SerializeHashSet<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var set = (HashSet<T>)obj;
SerializationManager.SerializeInner(set.Comparer.Equals(EqualityComparer<T>.Default) ? null : set.Comparer,
stream, typeof(IEqualityComparer<T>));
stream.Write(set.Count);
foreach (var element in set)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeHashSet<T>(Type expected, BinaryTokenStreamReader stream)
{
var comparer =
(IEqualityComparer<T>)SerializationManager.DeserializeInner(typeof(IEqualityComparer<T>), stream);
var count = stream.ReadInt();
var set = new HashSet<T>(comparer);
DeserializationContext.Current.RecordObject(set);
for (var i = 0; i < count; i++)
{
set.Add((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
return set;
}
internal static object DeepCopyHashSet<T>(object original)
{
var set = (HashSet<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return new HashSet<T>(set, set.Comparer);
}
var retVal = new HashSet<T>(set.Comparer);
SerializationContext.Current.RecordObject(original, retVal);
foreach (var item in set)
{
retVal.Add((T)SerializationManager.DeepCopyInner(item));
}
return retVal;
}
internal static void SerializeGenericSortedSet(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeSortedSet), nameof(DeserializeSortedSet), nameof(DeepCopySortedSet), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericSortedSet(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeSortedSet), nameof(DeserializeSortedSet), nameof(DeepCopySortedSet), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericSortedSet(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeSortedSet), nameof(DeserializeSortedSet), nameof(DeepCopySortedSet), generics);
return concretes.Item3(original);
}
internal static void SerializeSortedSet<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var set = (SortedSet<T>)obj;
SerializationManager.SerializeInner(set.Comparer.Equals(Comparer<T>.Default) ? null : set.Comparer,
stream, typeof(IComparer<T>));
stream.Write(set.Count);
foreach (var element in set)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeSortedSet<T>(Type expected, BinaryTokenStreamReader stream)
{
var comparer =
(IComparer<T>)SerializationManager.DeserializeInner(typeof(IComparer<T>), stream);
var count = stream.ReadInt();
var set = new SortedSet<T>(comparer);
DeserializationContext.Current.RecordObject(set);
for (var i = 0; i < count; i++)
{
set.Add((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
return set;
}
internal static object DeepCopySortedSet<T>(object original)
{
var set = (SortedSet<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return new SortedSet<T>(set, set.Comparer);
}
var retVal = new SortedSet<T>(set.Comparer);
SerializationContext.Current.RecordObject(original, retVal);
foreach (var item in set)
{
retVal.Add((T)SerializationManager.DeepCopyInner(item));
}
return retVal;
}
#endregion
#region Queues
internal static void SerializeGenericQueue(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeQueue), nameof(DeserializeQueue), nameof(DeepCopyQueue), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericQueue(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeQueue), nameof(DeserializeQueue), nameof(DeepCopyQueue), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericQueue(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeQueue), nameof(DeserializeQueue), nameof(DeepCopyQueue), generics);
return concretes.Item3(original);
}
internal static void SerializeQueue<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var queue = (Queue<T>)obj;
stream.Write(queue.Count);
foreach (var element in queue)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeQueue<T>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var queue = new Queue<T>();
DeserializationContext.Current.RecordObject(queue);
for (var i = 0; i < count; i++)
{
queue.Enqueue((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
return queue;
}
internal static object DeepCopyQueue<T>(object original)
{
var queue = (Queue<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return new Queue<T>(queue);
}
var retVal = new Queue<T>(queue.Count);
SerializationContext.Current.RecordObject(original, retVal);
foreach (var item in queue)
{
retVal.Enqueue((T)SerializationManager.DeepCopyInner(item));
}
return retVal;
}
#endregion
#region Stacks
internal static void SerializeGenericStack(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeStack), nameof(DeserializeStack), nameof(DeepCopyStack), generics);
concretes.Item1(original, stream, expected);
}
internal static object DeserializeGenericStack(Type expected, BinaryTokenStreamReader stream)
{
var generics = expected.GetGenericArguments();
var concretes = RegisterConcreteMethods(expected, nameof(SerializeStack), nameof(DeserializeStack), nameof(DeepCopyStack), generics);
return concretes.Item2(expected, stream);
}
internal static object CopyGenericStack(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeStack), nameof(DeserializeStack), nameof(DeepCopyStack), generics);
return concretes.Item3(original);
}
internal static void SerializeStack<T>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var stack = (Stack<T>)obj;
stream.Write(stack.Count);
foreach (var element in stack)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeStack<T>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var list = new List<T>(count);
var stack = new Stack<T>(count);
DeserializationContext.Current.RecordObject(stack);
for (var i = 0; i < count; i++)
{
list.Add((T)SerializationManager.DeserializeInner(typeof(T), stream));
}
for (var i = count - 1; i >= 0; i--)
{
stack.Push(list[i]);
}
return stack;
}
internal static object DeepCopyStack<T>(object original)
{
var stack = (Stack<T>)original;
if (typeof(T).IsOrleansShallowCopyable())
{
return new Stack<T>(stack.Reverse()); // NOTE: Yes, the Reverse really is required
}
var retVal = new Stack<T>();
SerializationContext.Current.RecordObject(original, retVal);
foreach (var item in stack.Reverse())
{
retVal.Push((T)SerializationManager.DeepCopyInner(item));
}
return retVal;
}
#endregion
#region Dictionaries
internal static void SerializeGenericDictionary(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeDictionary), nameof(DeserializeDictionary), nameof(CopyDictionary));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericDictionary(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeDictionary), nameof(DeserializeDictionary), nameof(CopyDictionary));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericDictionary(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeDictionary), nameof(DeserializeDictionary), nameof(CopyDictionary));
return concreteMethods.Item3(original);
}
internal static void SerializeDictionary<K, V>(object original, BinaryTokenStreamWriter stream, Type expected)
{
var dict = (Dictionary<K, V>)original;
SerializationManager.SerializeInner(dict.Comparer.Equals(EqualityComparer<K>.Default) ? null : dict.Comparer,
stream, typeof(IEqualityComparer<K>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair.Key, stream, typeof(K));
SerializationManager.SerializeInner(pair.Value, stream, typeof(V));
}
}
internal static object DeserializeDictionary<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var comparer = (IEqualityComparer<K>)SerializationManager.DeserializeInner(typeof(IEqualityComparer<K>), stream);
var count = stream.ReadInt();
var dict = new Dictionary<K, V>(count, comparer);
DeserializationContext.Current.RecordObject(dict);
for (var i = 0; i < count; i++)
{
var key = (K)SerializationManager.DeserializeInner(typeof(K), stream);
var value = (V)SerializationManager.DeserializeInner(typeof(V), stream);
dict[key] = value;
}
return dict;
}
internal static object CopyDictionary<K, V>(object original)
{
var dict = (Dictionary<K, V>)original;
if (typeof(K).IsOrleansShallowCopyable() && typeof(V).IsOrleansShallowCopyable())
{
return new Dictionary<K, V>(dict, dict.Comparer);
}
var result = new Dictionary<K, V>(dict.Count, dict.Comparer);
SerializationContext.Current.RecordObject(original, result);
foreach (var pair in dict)
{
result[(K)SerializationManager.DeepCopyInner(pair.Key)] = (V)SerializationManager.DeepCopyInner(pair.Value);
}
return result;
}
internal static void SerializeGenericReadOnlyDictionary(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeReadOnlyDictionary), nameof(DeserializeReadOnlyDictionary), nameof(CopyReadOnlyDictionary));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericReadOnlyDictionary(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeReadOnlyDictionary), nameof(DeserializeReadOnlyDictionary), nameof(CopyReadOnlyDictionary));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericReadOnlyDictionary(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeReadOnlyDictionary), nameof(DeserializeReadOnlyDictionary), nameof(CopyReadOnlyDictionary));
return concreteMethods.Item3(original);
}
internal static void SerializeReadOnlyDictionary<K, V>(object original, BinaryTokenStreamWriter stream, Type expected)
{
var dict = (ReadOnlyDictionary<K, V>)original;
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair.Key, stream, typeof(K));
SerializationManager.SerializeInner(pair.Value, stream, typeof(V));
}
}
internal static object DeserializeReadOnlyDictionary<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var dict = new Dictionary<K, V>(count);
for (var i = 0; i < count; i++)
{
var key = (K)SerializationManager.DeserializeInner(typeof(K), stream);
var value = (V)SerializationManager.DeserializeInner(typeof(V), stream);
dict[key] = value;
}
var retVal = new ReadOnlyDictionary<K, V>(dict);
DeserializationContext.Current.RecordObject(retVal);
return retVal;
}
internal static object CopyReadOnlyDictionary<K, V>(object original)
{
if (typeof(K).IsOrleansShallowCopyable() && typeof(V).IsOrleansShallowCopyable())
{
return original;
}
var dict = (ReadOnlyDictionary<K, V>)original;
var innerDict = new Dictionary<K, V>(dict.Count);
foreach (var pair in dict)
{
innerDict[(K)SerializationManager.DeepCopyInner(pair.Key)] = (V)SerializationManager.DeepCopyInner(pair.Value);
}
var retVal = new ReadOnlyDictionary<K, V>(innerDict);
SerializationContext.Current.RecordObject(original, retVal);
return retVal;
}
internal static void SerializeStringObjectDictionary(object original, BinaryTokenStreamWriter stream, Type expected)
{
var dict = (Dictionary<string, object>)original;
SerializationManager.SerializeInner(dict.Comparer.Equals(EqualityComparer<string>.Default) ? null : dict.Comparer,
stream, typeof(IEqualityComparer<string>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
//stream.WriteTypeHeader(stringType, stringType);
stream.Write(pair.Key);
SerializationManager.SerializeInner(pair.Value, stream, objectType);
}
}
internal static object DeserializeStringObjectDictionary(Type expected, BinaryTokenStreamReader stream)
{
var comparer = (IEqualityComparer<string>)SerializationManager.DeserializeInner(typeof(IEqualityComparer<string>), stream);
var count = stream.ReadInt();
var dict = new Dictionary<string, object>(count, comparer);
DeserializationContext.Current.RecordObject(dict);
for (var i = 0; i < count; i++)
{
//stream.ReadFullTypeHeader(stringType); // Skip the type header, which will be string
var key = stream.ReadString();
var value = SerializationManager.DeserializeInner(null, stream);
dict[key] = value;
}
return dict;
}
internal static object CopyStringObjectDictionary(object original)
{
var dict = (Dictionary<string, object>)original;
var result = new Dictionary<string, object>(dict.Count, dict.Comparer);
SerializationContext.Current.RecordObject(original, result);
foreach (var pair in dict)
{
result[pair.Key] = SerializationManager.DeepCopyInner(pair.Value);
}
return result;
}
#endregion
#region SortedDictionaries
internal static void SerializeGenericSortedDictionary(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeSortedDictionary), nameof(DeserializeSortedDictionary), nameof(CopySortedDictionary));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericSortedDictionary(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeSortedDictionary), nameof(DeserializeSortedDictionary), nameof(CopySortedDictionary));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericSortedDictionary(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeSortedDictionary), nameof(DeserializeSortedDictionary), nameof(CopySortedDictionary));
return concreteMethods.Item3(original);
}
internal static void SerializeSortedDictionary<K, V>(object original, BinaryTokenStreamWriter stream, Type expected)
{
var dict = (SortedDictionary<K, V>)original;
SerializationManager.SerializeInner(dict.Comparer.Equals(Comparer<K>.Default) ? null : dict.Comparer, stream, typeof(IComparer<K>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair.Key, stream, typeof(K));
SerializationManager.SerializeInner(pair.Value, stream, typeof(V));
}
}
internal static object DeserializeSortedDictionary<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var comparer = (IComparer<K>)SerializationManager.DeserializeInner(typeof(IComparer<K>), stream);
var count = stream.ReadInt();
var dict = new SortedDictionary<K, V>(comparer);
DeserializationContext.Current.RecordObject(dict);
for (var i = 0; i < count; i++)
{
var key = (K)SerializationManager.DeserializeInner(typeof(K), stream);
var value = (V)SerializationManager.DeserializeInner(typeof(V), stream);
dict[key] = value;
}
return dict;
}
internal static object CopySortedDictionary<K, V>(object original)
{
var dict = (SortedDictionary<K, V>)original;
if (typeof(K).IsOrleansShallowCopyable() && typeof(V).IsOrleansShallowCopyable())
{
return new SortedDictionary<K, V>(dict, dict.Comparer);
}
var result = new SortedDictionary<K, V>(dict.Comparer);
SerializationContext.Current.RecordObject(original, result);
foreach (var pair in dict)
{
result[(K)SerializationManager.DeepCopyInner(pair.Key)] = (V)SerializationManager.DeepCopyInner(pair.Value);
}
return result;
}
#endregion
#region SortedLists
internal static void SerializeGenericSortedList(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeSortedList), nameof(DeserializeSortedList), nameof(CopySortedList));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericSortedList(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeSortedList), nameof(DeserializeSortedList), nameof(CopySortedList));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericSortedList(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeSortedList), nameof(DeserializeSortedList), nameof(CopySortedList));
return concreteMethods.Item3(original);
}
internal static void SerializeSortedList<K, V>(object original, BinaryTokenStreamWriter stream, Type expected)
{
var list = (SortedList<K, V>)original;
SerializationManager.SerializeInner(list.Comparer.Equals(Comparer<K>.Default) ? null : list.Comparer, stream, typeof(IComparer<K>));
stream.Write(list.Count);
foreach (var pair in list)
{
SerializationManager.SerializeInner(pair.Key, stream, typeof(K));
SerializationManager.SerializeInner(pair.Value, stream, typeof(V));
}
}
internal static object DeserializeSortedList<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var comparer = (IComparer<K>)SerializationManager.DeserializeInner(typeof(IComparer<K>), stream);
var count = stream.ReadInt();
var list = new SortedList<K, V>(count, comparer);
DeserializationContext.Current.RecordObject(list);
for (var i = 0; i < count; i++)
{
var key = (K)SerializationManager.DeserializeInner(typeof(K), stream);
var value = (V)SerializationManager.DeserializeInner(typeof(V), stream);
list[key] = value;
}
return list;
}
internal static object CopySortedList<K, V>(object original)
{
var list = (SortedList<K, V>)original;
if (typeof(K).IsOrleansShallowCopyable() && typeof(V).IsOrleansShallowCopyable())
{
return new SortedList<K, V>(list, list.Comparer);
}
var result = new SortedList<K, V>(list.Count, list.Comparer);
SerializationContext.Current.RecordObject(original, result);
foreach (var pair in list)
{
result[(K)SerializationManager.DeepCopyInner(pair.Key)] = (V)SerializationManager.DeepCopyInner(pair.Value);
}
return result;
}
#endregion
#endregion
#region Immutable Collections
internal static void SerializeGenericImmutableDictionary(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableDictionary), nameof(DeserializeImmutableDictionary), nameof(CopyImmutableDictionary));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericImmutableDictionary(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableDictionary), nameof(DeserializeImmutableDictionary), nameof(CopyImmutableDictionary));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericImmutableDictionary(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableDictionary), nameof(DeserializeImmutableDictionary), nameof(CopyImmutableDictionary));
return concreteMethods.Item3(original);
}
internal static object CopyImmutableDictionary<K, V>(object original)
{
return original;
}
internal static void SerializeImmutableDictionary<K, V>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var dict = (ImmutableDictionary<K, V>)untypedInput;
SerializationManager.SerializeInner(dict.KeyComparer.Equals(EqualityComparer<K>.Default) ? null : dict.KeyComparer, stream, typeof(IEqualityComparer<K>));
SerializationManager.SerializeInner(dict.ValueComparer.Equals(EqualityComparer<V>.Default) ? null : dict.ValueComparer, stream, typeof(IEqualityComparer<V>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair.Key, stream, typeof(K));
SerializationManager.SerializeInner(pair.Value, stream, typeof(V));
}
}
internal static object DeserializeImmutableDictionary<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var keyComparer = SerializationManager.DeserializeInner<IEqualityComparer<K>>(stream);
var valueComparer = SerializationManager.DeserializeInner<IEqualityComparer<V>>(stream);
var count = stream.ReadInt();
var dictBuilder = ImmutableDictionary.CreateBuilder(keyComparer, valueComparer);
for (var i = 0; i < count; i++)
{
var key = SerializationManager.DeserializeInner<K>(stream);
var value = SerializationManager.DeserializeInner<V>(stream);
dictBuilder.Add(key, value);
}
var dict = dictBuilder.ToImmutable();
DeserializationContext.Current.RecordObject(dict);
return dict;
}
internal static void SerializeGenericImmutableList(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableList), nameof(DeserializeImmutableList), nameof(CopyImmutableList));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericImmutableList(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableList), nameof(DeserializeImmutableList), nameof(CopyImmutableList));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericImmutableList(object original)
{
var t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableList), nameof(DeserializeImmutableList), nameof(CopyImmutableList));
return concreteMethods.Item3(original);
}
internal static void SerializeImmutableList<T>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var list = (ImmutableList<T>)untypedInput;
stream.Write(list.Count);
foreach (var element in list)
{
SerializationManager.SerializeInner(element, stream, typeof(T));
}
}
internal static object DeserializeImmutableList<T>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var listBuilder = ImmutableList.CreateBuilder<T>();
for (var i = 0; i < count; i++)
{
listBuilder.Add(SerializationManager.DeserializeInner<T>(stream));
}
var list = listBuilder.ToImmutable();
DeserializationContext.Current.RecordObject(list);
return list;
}
internal static object CopyImmutableList<K>(object original)
{
return original;
}
internal static object CopyGenericImmutableHashSet(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableHashSet), nameof(DeserializeImmutableHashSet), nameof(CopyImmutableHashSet));
return concreteMethods.Item3(original);
}
internal static void SerializeGenericImmutableHashSet(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableHashSet), nameof(DeserializeImmutableHashSet), nameof(CopyImmutableHashSet));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericImmutableHashSet(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableHashSet), nameof(DeserializeImmutableHashSet), nameof(CopyImmutableHashSet));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyImmutableHashSet<K>(object original)
{
return original;
}
internal static void SerializeImmutableHashSet<K>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var dict = (ImmutableHashSet<K>)untypedInput;
SerializationManager.SerializeInner(dict.KeyComparer.Equals(EqualityComparer<K>.Default) ? null : dict.KeyComparer, stream, typeof(IEqualityComparer<K>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair, stream, typeof(K));
}
}
internal static object DeserializeImmutableHashSet<K>(Type expected, BinaryTokenStreamReader stream)
{
var keyComparer = SerializationManager.DeserializeInner<IEqualityComparer<K>>(stream);
var count = stream.ReadInt();
var dictBuilder = ImmutableHashSet.CreateBuilder(keyComparer);
for (var i = 0; i < count; i++)
{
var key = SerializationManager.DeserializeInner<K>(stream);
dictBuilder.Add(key);
}
var dict = dictBuilder.ToImmutable();
DeserializationContext.Current.RecordObject(dict);
return dict;
}
internal static object CopyGenericImmutableSortedSet(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableSortedSet), nameof(DeserializeImmutableSortedSet), nameof(CopyImmutableSortedSet));
return concreteMethods.Item3(original);
}
internal static object DeserializeGenericImmutableSortedSet(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableSortedSet), nameof(DeserializeImmutableSortedSet), nameof(CopyImmutableSortedSet));
return concreteMethods.Item2(expected, stream);
}
internal static void SerializeGenericImmutableSortedSet(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableSortedSet), nameof(DeserializeImmutableSortedSet), nameof(CopyImmutableSortedSet));
concreteMethods.Item1(original, stream, expected);
}
internal static object CopyImmutableSortedSet<K>(object original)
{
return original;
}
internal static void SerializeImmutableSortedSet<K>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var dict = (ImmutableSortedSet<K>)untypedInput;
SerializationManager.SerializeInner(dict.KeyComparer.Equals(Comparer<K>.Default) ? null : dict.KeyComparer, stream, typeof(IComparer<K>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair, stream, typeof(K));
}
}
internal static object DeserializeImmutableSortedSet<K>(Type expected, BinaryTokenStreamReader stream)
{
var keyComparer = SerializationManager.DeserializeInner<IComparer<K>>(stream);
var count = stream.ReadInt();
var dictBuilder = ImmutableSortedSet.CreateBuilder(keyComparer);
for (var i = 0; i < count; i++)
{
var key = SerializationManager.DeserializeInner<K>(stream);
dictBuilder.Add(key);
}
var dict = dictBuilder.ToImmutable();
DeserializationContext.Current.RecordObject(dict);
return dict;
}
internal static object CopyGenericImmutableSortedDictionary(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableSortedDictionary), nameof(DeserializeImmutableSortedDictionary), nameof(CopyImmutableSortedDictionary));
return concreteMethods.Item3(original);
}
internal static object DeserializeGenericImmutableSortedDictionary(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableSortedDictionary), nameof(DeserializeImmutableSortedDictionary), nameof(CopyImmutableSortedDictionary));
return concreteMethods.Item2(expected, stream);
}
internal static void SerializeGenericImmutableSortedDictionary(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableSortedDictionary), nameof(DeserializeImmutableSortedDictionary), nameof(CopyImmutableSortedDictionary));
concreteMethods.Item1(original, stream, expected);
}
internal static object CopyImmutableSortedDictionary<K, V>(object original)
{
return original;
}
internal static void SerializeImmutableSortedDictionary<K, V>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var dict = (ImmutableSortedDictionary<K, V>)untypedInput;
SerializationManager.SerializeInner(dict.KeyComparer.Equals(Comparer<K>.Default) ? null : dict.KeyComparer, stream, typeof(IComparer<K>));
SerializationManager.SerializeInner(dict.ValueComparer.Equals(EqualityComparer<V>.Default) ? null : dict.ValueComparer, stream, typeof(IEqualityComparer<V>));
stream.Write(dict.Count);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair.Key, stream, typeof(K));
SerializationManager.SerializeInner(pair.Value, stream, typeof(V));
}
}
internal static object DeserializeImmutableSortedDictionary<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var keyComparer = SerializationManager.DeserializeInner<IComparer<K>>(stream);
var valueComparer = SerializationManager.DeserializeInner<IEqualityComparer<V>>(stream);
var count = stream.ReadInt();
var dictBuilder = ImmutableSortedDictionary.CreateBuilder(keyComparer, valueComparer);
for (var i = 0; i < count; i++)
{
var key = SerializationManager.DeserializeInner<K>(stream);
var value = SerializationManager.DeserializeInner<V>(stream);
dictBuilder.Add(key, value);
}
var dict = dictBuilder.ToImmutable();
DeserializationContext.Current.RecordObject(dict);
return dict;
}
internal static object CopyGenericImmutableArray(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableArray), nameof(DeserializeImmutableArray), nameof(CopyImmutableArray));
return concreteMethods.Item3(original);
}
internal static object DeserializeGenericImmutableArray(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableArray), nameof(DeserializeImmutableArray), nameof(CopyImmutableArray));
return concreteMethods.Item2(expected, stream);
}
internal static void SerializeGenericImmutableArray(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableArray), nameof(DeserializeImmutableArray), nameof(CopyImmutableArray));
concreteMethods.Item1(original, stream, expected);
}
internal static object CopyImmutableArray<K>(object original)
{
return original;
}
internal static void SerializeImmutableArray<K>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var dict = (ImmutableArray<K>)untypedInput;
stream.Write(dict.Length);
foreach (var pair in dict)
{
SerializationManager.SerializeInner(pair, stream, typeof(K));
}
}
internal static object DeserializeImmutableArray<K>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var dictBuilder = ImmutableArray.CreateBuilder<K>();
for (var i = 0; i < count; i++)
{
var key = SerializationManager.DeserializeInner<K>(stream);
dictBuilder.Add(key);
}
var dict = dictBuilder.ToImmutable();
DeserializationContext.Current.RecordObject(dict);
return dict;
}
internal static object CopyGenericImmutableQueue(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableQueue), nameof(DeserializeImmutableQueue), nameof(CopyImmutableQueue));
return concreteMethods.Item3(original);
}
internal static object DeserializeGenericImmutableQueue(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutableQueue), nameof(DeserializeImmutableQueue), nameof(CopyImmutableQueue));
return concreteMethods.Item2(expected, stream);
}
internal static void SerializeGenericImmutableQueue(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutableQueue), nameof(DeserializeImmutableQueue), nameof(CopyImmutableQueue));
concreteMethods.Item1(original, stream, expected);
}
internal static object CopyImmutableQueue<K>(object original)
{
return original;
}
internal static void SerializeImmutableQueue<K>(object untypedInput, BinaryTokenStreamWriter stream, Type typeExpected)
{
var queue = (ImmutableQueue<K>)untypedInput;
stream.Write(queue.Count());
foreach (var item in queue)
{
SerializationManager.SerializeInner(item, stream, typeof(K));
}
}
internal static object DeserializeImmutableQueue<K>(Type expected, BinaryTokenStreamReader stream)
{
var count = stream.ReadInt();
var items = new K[count];
for (var i = 0; i < count; i++)
{
var key = SerializationManager.DeserializeInner<K>(stream);
items[i] = key;
}
var queues = ImmutableQueue.CreateRange(items);
DeserializationContext.Current.RecordObject(queues);
return queues;
}
#endregion
#region Other generics
#region Tuples
internal static void SerializeTuple(object raw, BinaryTokenStreamWriter stream, Type expected)
{
Type t = raw.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeTuple) + generics.Length, nameof(DeserializeTuple) + generics.Length, nameof(DeepCopyTuple) + generics.Length, generics);
concretes.Item1(raw, stream, expected);
}
internal static object DeserializeTuple(Type t, BinaryTokenStreamReader stream)
{
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeTuple) + generics.Length, nameof(DeserializeTuple) + generics.Length, nameof(DeepCopyTuple) + generics.Length, generics);
return concretes.Item2(t, stream);
}
internal static object DeepCopyTuple(object original)
{
Type t = original.GetType();
var generics = t.GetGenericArguments();
var concretes = RegisterConcreteMethods(t, nameof(SerializeTuple) + generics.Length, nameof(DeserializeTuple) + generics.Length, nameof(DeepCopyTuple) + generics.Length, generics);
return concretes.Item3(original);
}
internal static object DeepCopyTuple1<T1>(object original)
{
var input = (Tuple<T1>)original;
var result = new Tuple<T1>((T1)SerializationManager.DeepCopyInner(input.Item1));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple1<T1>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
}
internal static object DeserializeTuple1<T1>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
return new Tuple<T1>(item1);
}
internal static object DeepCopyTuple2<T1, T2>(object original)
{
var input = (Tuple<T1, T2>)original;
var result = new Tuple<T1, T2>((T1)SerializationManager.DeepCopyInner(input.Item1), (T2)SerializationManager.DeepCopyInner(input.Item2));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple2<T1, T2>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1, T2>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
SerializationManager.SerializeInner(input.Item2, stream, typeof(T2));
}
internal static object DeserializeTuple2<T1, T2>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
var item2 = (T2)SerializationManager.DeserializeInner(typeof(T2), stream);
return new Tuple<T1, T2>(item1, item2);
}
internal static object DeepCopyTuple3<T1, T2, T3>(object original)
{
var input = (Tuple<T1, T2, T3>)original;
var result = new Tuple<T1, T2, T3>((T1)SerializationManager.DeepCopyInner(input.Item1), (T2)SerializationManager.DeepCopyInner(input.Item2),
(T3)SerializationManager.DeepCopyInner(input.Item3));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple3<T1, T2, T3>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1, T2, T3>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
SerializationManager.SerializeInner(input.Item2, stream, typeof(T2));
SerializationManager.SerializeInner(input.Item3, stream, typeof(T3));
}
internal static object DeserializeTuple3<T1, T2, T3>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
var item2 = (T2)SerializationManager.DeserializeInner(typeof(T2), stream);
var item3 = (T3)SerializationManager.DeserializeInner(typeof(T3), stream);
return new Tuple<T1, T2, T3>(item1, item2, item3);
}
internal static object DeepCopyTuple4<T1, T2, T3, T4>(object original)
{
var input = (Tuple<T1, T2, T3, T4>)original;
var result = new Tuple<T1, T2, T3, T4>((T1)SerializationManager.DeepCopyInner(input.Item1), (T2)SerializationManager.DeepCopyInner(input.Item2),
(T3)SerializationManager.DeepCopyInner(input.Item3),
(T4)SerializationManager.DeepCopyInner(input.Item4));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple4<T1, T2, T3, T4>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1, T2, T3, T4>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
SerializationManager.SerializeInner(input.Item2, stream, typeof(T2));
SerializationManager.SerializeInner(input.Item3, stream, typeof(T3));
SerializationManager.SerializeInner(input.Item4, stream, typeof(T4));
}
internal static object DeserializeTuple4<T1, T2, T3, T4>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
var item2 = (T2)SerializationManager.DeserializeInner(typeof(T2), stream);
var item3 = (T3)SerializationManager.DeserializeInner(typeof(T3), stream);
var item4 = (T4)SerializationManager.DeserializeInner(typeof(T4), stream);
return new Tuple<T1, T2, T3, T4>(item1, item2, item3, item4);
}
internal static object DeepCopyTuple5<T1, T2, T3, T4, T5>(object original)
{
var input = (Tuple<T1, T2, T3, T4, T5>)original;
var result = new Tuple<T1, T2, T3, T4, T5>((T1)SerializationManager.DeepCopyInner(input.Item1), (T2)SerializationManager.DeepCopyInner(input.Item2),
(T3)SerializationManager.DeepCopyInner(input.Item3),
(T4)SerializationManager.DeepCopyInner(input.Item4),
(T5)SerializationManager.DeepCopyInner(input.Item5));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple5<T1, T2, T3, T4, T5>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1, T2, T3, T4, T5>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
SerializationManager.SerializeInner(input.Item2, stream, typeof(T2));
SerializationManager.SerializeInner(input.Item3, stream, typeof(T3));
SerializationManager.SerializeInner(input.Item4, stream, typeof(T4));
SerializationManager.SerializeInner(input.Item5, stream, typeof(T5));
}
internal static object DeserializeTuple5<T1, T2, T3, T4, T5>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
var item2 = (T2)SerializationManager.DeserializeInner(typeof(T2), stream);
var item3 = (T3)SerializationManager.DeserializeInner(typeof(T3), stream);
var item4 = (T4)SerializationManager.DeserializeInner(typeof(T4), stream);
var item5 = (T5)SerializationManager.DeserializeInner(typeof(T5), stream);
return new Tuple<T1, T2, T3, T4, T5>(item1, item2, item3, item4, item5);
}
internal static object DeepCopyTuple6<T1, T2, T3, T4, T5, T6>(object original)
{
var input = (Tuple<T1, T2, T3, T4, T5, T6>)original;
var result = new Tuple<T1, T2, T3, T4, T5, T6>((T1)SerializationManager.DeepCopyInner(input.Item1), (T2)SerializationManager.DeepCopyInner(input.Item2),
(T3)SerializationManager.DeepCopyInner(input.Item3),
(T4)SerializationManager.DeepCopyInner(input.Item4),
(T5)SerializationManager.DeepCopyInner(input.Item5),
(T6)SerializationManager.DeepCopyInner(input.Item6));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple6<T1, T2, T3, T4, T5, T6>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1, T2, T3, T4, T5, T6>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
SerializationManager.SerializeInner(input.Item2, stream, typeof(T2));
SerializationManager.SerializeInner(input.Item3, stream, typeof(T3));
SerializationManager.SerializeInner(input.Item4, stream, typeof(T4));
SerializationManager.SerializeInner(input.Item5, stream, typeof(T5));
SerializationManager.SerializeInner(input.Item6, stream, typeof(T6));
}
internal static object DeserializeTuple6<T1, T2, T3, T4, T5, T6>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
var item2 = (T2)SerializationManager.DeserializeInner(typeof(T2), stream);
var item3 = (T3)SerializationManager.DeserializeInner(typeof(T3), stream);
var item4 = (T4)SerializationManager.DeserializeInner(typeof(T4), stream);
var item5 = (T5)SerializationManager.DeserializeInner(typeof(T5), stream);
var item6 = (T6)SerializationManager.DeserializeInner(typeof(T6), stream);
return new Tuple<T1, T2, T3, T4, T5, T6>(item1, item2, item3, item4, item5, item6);
}
internal static object DeepCopyTuple7<T1, T2, T3, T4, T5, T6, T7>(object original)
{
var input = (Tuple<T1, T2, T3, T4, T5, T6, T7>)original;
var result = new Tuple<T1, T2, T3, T4, T5, T6, T7>((T1)SerializationManager.DeepCopyInner(input.Item1), (T2)SerializationManager.DeepCopyInner(input.Item2),
(T3)SerializationManager.DeepCopyInner(input.Item3),
(T4)SerializationManager.DeepCopyInner(input.Item4),
(T5)SerializationManager.DeepCopyInner(input.Item5),
(T6)SerializationManager.DeepCopyInner(input.Item6),
(T7)SerializationManager.DeepCopyInner(input.Item7));
SerializationContext.Current.RecordObject(original, result);
return result;
}
internal static void SerializeTuple7<T1, T2, T3, T4, T5, T6, T7>(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var input = (Tuple<T1, T2, T3, T4, T5, T6, T7>)obj;
SerializationManager.SerializeInner(input.Item1, stream, typeof(T1));
SerializationManager.SerializeInner(input.Item2, stream, typeof(T2));
SerializationManager.SerializeInner(input.Item3, stream, typeof(T3));
SerializationManager.SerializeInner(input.Item4, stream, typeof(T4));
SerializationManager.SerializeInner(input.Item5, stream, typeof(T5));
SerializationManager.SerializeInner(input.Item6, stream, typeof(T6));
SerializationManager.SerializeInner(input.Item7, stream, typeof(T7));
}
internal static object DeserializeTuple7<T1, T2, T3, T4, T5, T6, T7>(Type expected, BinaryTokenStreamReader stream)
{
var item1 = (T1)SerializationManager.DeserializeInner(typeof(T1), stream);
var item2 = (T2)SerializationManager.DeserializeInner(typeof(T2), stream);
var item3 = (T3)SerializationManager.DeserializeInner(typeof(T3), stream);
var item4 = (T4)SerializationManager.DeserializeInner(typeof(T4), stream);
var item5 = (T5)SerializationManager.DeserializeInner(typeof(T5), stream);
var item6 = (T6)SerializationManager.DeserializeInner(typeof(T6), stream);
var item7 = (T7)SerializationManager.DeserializeInner(typeof(T7), stream);
return new Tuple<T1, T2, T3, T4, T5, T6, T7>(item1, item2, item3, item4, item5, item6, item7);
}
#endregion
#region KeyValuePairs
internal static void SerializeGenericKeyValuePair(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeKeyValuePair), nameof(DeserializeKeyValuePair), nameof(CopyKeyValuePair));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericKeyValuePair(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeKeyValuePair), nameof(DeserializeKeyValuePair), nameof(CopyKeyValuePair));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericKeyValuePair(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeKeyValuePair), nameof(DeserializeKeyValuePair), nameof(CopyKeyValuePair));
return concreteMethods.Item3(original);
}
internal static void SerializeKeyValuePair<TK, TV>(object original, BinaryTokenStreamWriter stream, Type expected)
{
var pair = (KeyValuePair<TK, TV>)original;
SerializationManager.SerializeInner(pair.Key, stream, typeof(TK));
SerializationManager.SerializeInner(pair.Value, stream, typeof(TV));
}
internal static object DeserializeKeyValuePair<K, V>(Type expected, BinaryTokenStreamReader stream)
{
var key = (K)SerializationManager.DeserializeInner(typeof(K), stream);
var value = (V)SerializationManager.DeserializeInner(typeof(V), stream);
return new KeyValuePair<K, V>(key, value);
}
internal static object CopyKeyValuePair<TK, TV>(object original)
{
var pair = (KeyValuePair<TK, TV>)original;
if (typeof(TK).IsOrleansShallowCopyable() && typeof(TV).IsOrleansShallowCopyable())
{
return pair; // KeyValuePair is a struct, so there's already been a copy at this point
}
var result = new KeyValuePair<TK, TV>((TK)SerializationManager.DeepCopyInner(pair.Key), (TV)SerializationManager.DeepCopyInner(pair.Value));
SerializationContext.Current.RecordObject(original, result);
return result;
}
#endregion
#region Nullables
internal static void SerializeGenericNullable(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeNullable), nameof(DeserializeNullable), nameof(CopyNullable));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericNullable(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeNullable), nameof(DeserializeNullable), nameof(CopyNullable));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericNullable(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeNullable), nameof(DeserializeNullable), nameof(CopyNullable));
return concreteMethods.Item3(original);
}
internal static void SerializeNullable<T>(object original, BinaryTokenStreamWriter stream, Type expected) where T : struct
{
var obj = (T?)original;
if (obj.HasValue)
{
SerializationManager.SerializeInner(obj.Value, stream, typeof(T));
}
else
{
stream.WriteNull();
}
}
internal static object DeserializeNullable<T>(Type expected, BinaryTokenStreamReader stream) where T : struct
{
if (stream.PeekToken() == SerializationTokenType.Null)
{
stream.ReadToken();
return new T?();
}
var val = (T)SerializationManager.DeserializeInner(typeof(T), stream);
return new Nullable<T>(val);
}
internal static object CopyNullable<T>(object original) where T : struct
{
return original; // Everything is a struct, so a direct copy is fine
}
#endregion
#region Immutables
internal static void SerializeGenericImmutable(object original, BinaryTokenStreamWriter stream, Type expected)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutable), nameof(DeserializeImmutable), nameof(CopyImmutable));
concreteMethods.Item1(original, stream, expected);
}
internal static object DeserializeGenericImmutable(Type expected, BinaryTokenStreamReader stream)
{
var concreteMethods = RegisterConcreteMethods(expected, nameof(SerializeImmutable), nameof(DeserializeImmutable), nameof(CopyImmutable));
return concreteMethods.Item2(expected, stream);
}
internal static object CopyGenericImmutable(object original)
{
Type t = original.GetType();
var concreteMethods = RegisterConcreteMethods(t, nameof(SerializeImmutable), nameof(DeserializeImmutable), nameof(CopyImmutable));
return concreteMethods.Item3(original);
}
internal static void SerializeImmutable<T>(object original, BinaryTokenStreamWriter stream, Type expected)
{
var obj = (Immutable<T>)original;
SerializationManager.SerializeInner(obj.Value, stream, typeof(T));
}
internal static object DeserializeImmutable<T>(Type expected, BinaryTokenStreamReader stream)
{
var val = (T)SerializationManager.DeserializeInner(typeof(T), stream);
return new Immutable<T>(val);
}
internal static object CopyImmutable<T>(object original)
{
return original; // Immutable means never having to make a copy...
}
#endregion
#endregion
#region Other System types
#region TimeSpan
internal static void SerializeTimeSpan(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var ts = (TimeSpan)obj;
stream.Write(ts.Ticks);
}
internal static object DeserializeTimeSpan(Type expected, BinaryTokenStreamReader stream)
{
return new TimeSpan(stream.ReadLong());
}
internal static object CopyTimeSpan(object obj)
{
return obj; // TimeSpan is a value type
}
#endregion
#region DateTimeOffset
internal static void SerializeDateTimeOffset(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var dts = (DateTimeOffset)obj;
stream.Write(dts.DateTime.Ticks);
stream.Write(dts.Offset.Ticks);
}
internal static object DeserializeDateTimeOffset(Type expected, BinaryTokenStreamReader stream)
{
return new DateTimeOffset(stream.ReadLong(), new TimeSpan(stream.ReadLong()));
}
internal static object CopyDateTimeOffset(object obj)
{
return obj; // DateTimeOffset is a value type
}
#endregion
#region Type
internal static void SerializeType(object obj, BinaryTokenStreamWriter stream, Type expected)
{
stream.Write(((Type)obj).OrleansTypeName());
}
internal static object DeserializeType(Type expected, BinaryTokenStreamReader stream)
{
return SerializationManager.ResolveTypeName(stream.ReadString());
}
internal static object CopyType(object obj)
{
return obj; // Type objects are effectively immutable
}
#endregion Type
#region GUID
internal static void SerializeGuid(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var guid = (Guid)obj;
stream.Write(guid.ToByteArray());
}
internal static object DeserializeGuid(Type expected, BinaryTokenStreamReader stream)
{
var bytes = stream.ReadBytes(16);
return new Guid(bytes);
}
internal static object CopyGuid(object obj)
{
return obj; // Guids are value types
}
#endregion
#region URIs
[ThreadStatic]
static private TypeConverter uriConverter;
internal static void SerializeUri(object obj, BinaryTokenStreamWriter stream, Type expected)
{
if (uriConverter == null) uriConverter = TypeDescriptor.GetConverter(typeof(Uri));
stream.Write(uriConverter.ConvertToInvariantString(obj));
}
internal static object DeserializeUri(Type expected, BinaryTokenStreamReader stream)
{
if (uriConverter == null) uriConverter = TypeDescriptor.GetConverter(typeof(Uri));
return uriConverter.ConvertFromInvariantString(stream.ReadString());
}
internal static object CopyUri(object obj)
{
return obj; // URIs are immutable
}
#endregion
#endregion
#region Internal Orleans types
#region Basic types
internal static void SerializeGrainId(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var id = (GrainId)obj;
stream.Write(id);
}
internal static object DeserializeGrainId(Type expected, BinaryTokenStreamReader stream)
{
return stream.ReadGrainId();
}
internal static object CopyGrainId(object original)
{
return original;
}
internal static void SerializeActivationId(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var id = (ActivationId)obj;
stream.Write(id);
}
internal static object DeserializeActivationId(Type expected, BinaryTokenStreamReader stream)
{
return stream.ReadActivationId();
}
internal static object CopyActivationId(object original)
{
return original;
}
internal static void SerializeActivationAddress(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var addr = (ActivationAddress)obj;
stream.Write(addr);
}
internal static object DeserializeActivationAddress(Type expected, BinaryTokenStreamReader stream)
{
return stream.ReadActivationAddress();
}
internal static object CopyActivationAddress(object original)
{
return original;
}
internal static void SerializeIPAddress(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var ip = (IPAddress)obj;
stream.Write(ip);
}
internal static object DeserializeIPAddress(Type expected, BinaryTokenStreamReader stream)
{
return stream.ReadIPAddress();
}
internal static object CopyIPAddress(object original)
{
return original;
}
internal static void SerializeIPEndPoint(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var ep = (IPEndPoint)obj;
stream.Write(ep);
}
internal static object DeserializeIPEndPoint(Type expected, BinaryTokenStreamReader stream)
{
return stream.ReadIPEndPoint();
}
internal static object CopyIPEndPoint(object original)
{
return original;
}
internal static void SerializeCorrelationId(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var id = (CorrelationId)obj;
stream.Write(id);
}
internal static object DeserializeCorrelationId(Type expected, BinaryTokenStreamReader stream)
{
var bytes = stream.ReadBytes(CorrelationId.SIZE_BYTES);
return new CorrelationId(bytes);
}
internal static object CopyCorrelationId(object original)
{
return original;
}
internal static void SerializeSiloAddress(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var addr = (SiloAddress)obj;
stream.Write(addr);
}
internal static object DeserializeSiloAddress(Type expected, BinaryTokenStreamReader stream)
{
return stream.ReadSiloAddress();
}
internal static object CopySiloAddress(object original)
{
return original;
}
internal static object CopyTaskId(object original)
{
return original;
}
#endregion
#region InvokeMethodRequest
internal static void SerializeInvokeMethodRequest(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var request = (InvokeMethodRequest)obj;
stream.Write(request.InterfaceId);
stream.Write(request.MethodId);
stream.Write(request.Arguments != null ? request.Arguments.Length : 0);
if (request.Arguments != null)
{
foreach (var arg in request.Arguments)
{
SerializationManager.SerializeInner(arg, stream, null);
}
}
}
internal static object DeserializeInvokeMethodRequest(Type expected, BinaryTokenStreamReader stream)
{
int iid = stream.ReadInt();
int mid = stream.ReadInt();
int argCount = stream.ReadInt();
object[] args = null;
if (argCount > 0)
{
args = new object[argCount];
for (var i = 0; i < argCount; i++)
{
args[i] = SerializationManager.DeserializeInner(null, stream);
}
}
return new InvokeMethodRequest(iid, mid, args);
}
internal static object CopyInvokeMethodRequest(object original)
{
var request = (InvokeMethodRequest)original;
object[] args = null;
if (request.Arguments != null)
{
args = new object[request.Arguments.Length];
for (var i = 0; i < request.Arguments.Length; i++)
{
args[i] = SerializationManager.DeepCopyInner(request.Arguments[i]);
}
}
var result = new InvokeMethodRequest(request.InterfaceId, request.MethodId, args);
SerializationContext.Current.RecordObject(original, result);
return result;
}
#endregion
#region Response
internal static void SerializeOrleansResponse(object obj, BinaryTokenStreamWriter stream, Type expected)
{
var resp = (Response)obj;
SerializationManager.SerializeInner(resp.ExceptionFlag ? resp.Exception : resp.Data, stream, null);
}
internal static object DeserializeOrleansResponse(Type expected, BinaryTokenStreamReader stream)
{
var obj = SerializationManager.DeserializeInner(null, stream);
return new Response(obj);
}
internal static object CopyOrleansResponse(object original)
{
var resp = (Response)original;
if (resp.ExceptionFlag)
{
return original;
}
var result = new Response(SerializationManager.DeepCopyInner(resp.Data));
SerializationContext.Current.RecordObject(original, result);
return result;
}
#endregion
#endregion
#region Utilities
private static Tuple<SerializationManager.Serializer, SerializationManager.Deserializer, SerializationManager.DeepCopier>
RegisterConcreteMethods(Type t, string serializerName, string deserializerName, string copierName, Type[] genericArgs = null)
{
if (genericArgs == null)
{
genericArgs = t.GetGenericArguments();
}
var genericCopier = typeof(BuiltInTypes).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == copierName).FirstOrDefault();
var concreteCopier = genericCopier.MakeGenericMethod(genericArgs);
var copier = (SerializationManager.DeepCopier)concreteCopier.CreateDelegate(typeof(SerializationManager.DeepCopier));
var genericSerializer = typeof(BuiltInTypes).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == serializerName).FirstOrDefault();
var concreteSerializer = genericSerializer.MakeGenericMethod(genericArgs);
var serializer = (SerializationManager.Serializer)concreteSerializer.CreateDelegate(typeof(SerializationManager.Serializer));
var genericDeserializer = typeof(BuiltInTypes).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == deserializerName).FirstOrDefault();
var concreteDeserializer = genericDeserializer.MakeGenericMethod(genericArgs);
var deserializer =
(SerializationManager.Deserializer)concreteDeserializer.CreateDelegate(typeof(SerializationManager.Deserializer));
SerializationManager.Register(t, copier, serializer, deserializer);
return new Tuple<SerializationManager.Serializer, SerializationManager.Deserializer, SerializationManager.DeepCopier>(serializer, deserializer, copier);
}
public static Tuple<SerializationManager.Serializer, SerializationManager.Deserializer, SerializationManager.DeepCopier>
RegisterConcreteMethods(Type concreteType, Type definingType, string copierName, string serializerName, string deserializerName, Type[] genericArgs = null)
{
if (genericArgs == null)
{
genericArgs = concreteType.GetGenericArguments();
}
var genericCopier = definingType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == copierName).FirstOrDefault();
var concreteCopier = genericCopier.MakeGenericMethod(genericArgs);
var copier = (SerializationManager.DeepCopier)concreteCopier.CreateDelegate(typeof(SerializationManager.DeepCopier));
var genericSerializer = definingType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == serializerName).FirstOrDefault();
var concreteSerializer = genericSerializer.MakeGenericMethod(genericArgs);
var serializer = (SerializationManager.Serializer)concreteSerializer.CreateDelegate(typeof(SerializationManager.Serializer));
var genericDeserializer = definingType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == deserializerName).FirstOrDefault();
var concreteDeserializer = genericDeserializer.MakeGenericMethod(genericArgs);
var deserializer =
(SerializationManager.Deserializer)concreteDeserializer.CreateDelegate(typeof(SerializationManager.Deserializer));
SerializationManager.Register(concreteType, copier, serializer, deserializer);
return new Tuple<SerializationManager.Serializer, SerializationManager.Deserializer, SerializationManager.DeepCopier>(serializer, deserializer, copier);
}
#endregion
}
}
| 43.129114 | 208 | 0.639998 | [
"MIT"
] | Drawaes/orleans | src/Orleans/Serialization/BuiltInTypes.cs | 85,180 | C# |
using AlphaTab.Model;
using AlphaTab.Rendering.Glyphs;
namespace AlphaTab.Rendering.Effects
{
internal class AlternateEndingsEffectInfo : IEffectBarRendererInfo
{
public string EffectId => "alternate-feel";
public bool HideOnMultiTrack => true;
public bool CanShareBand => false;
public EffectBarGlyphSizing SizingMode => EffectBarGlyphSizing.FullBar;
public bool ShouldCreateGlyph(Settings settings, Beat beat)
{
return beat.Index == 0 && beat.Voice.Bar.MasterBar.AlternateEndings != 0;
}
public EffectGlyph CreateNewGlyph(BarRendererBase renderer, Beat beat)
{
return new AlternateEndingsGlyph(0, 0, beat.Voice.Bar.MasterBar.AlternateEndings);
}
public bool CanExpand(Beat from, Beat to)
{
return true;
}
}
}
| 29.931034 | 94 | 0.658986 | [
"MPL-2.0"
] | Orzelius/alphaTab | Source/AlphaTab/Rendering/Effects/AlternateEndingsEffectInfo.cs | 870 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using CombatHelper.Controls;
using CombatHelper.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Open5eWebView), typeof(Open5eWebViewRenderer))]
namespace CombatHelper.Droid.Renderers
{
class Open5eWebViewRenderer : WebViewRenderer
{
public Open5eWebViewRenderer(Context context)
: base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
Control.SetWebViewClient(new Open5eWebViewClient());
}
}
} | 24.257143 | 84 | 0.714959 | [
"MIT"
] | Briinah/combat-helper | CombatHelper/CombatHelper.Android/Renderers/Open5eWebViewRenderer.cs | 851 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PCCatalog
{
class PCCatalog
{
static void Main()
{
Components Motherboard = new Components();
Motherboard.Name = "IntelALTServer";
Motherboard.Price = 10.32m;
Motherboard.Details = "No details";
Components Processor = new Components("Pentium Dual-Core",14.32m, "All details");
Components Ram = new Components("DDR2-400",10.43m,"All details");
Components GraphicsCard = new Components("DB-15 VGA",10.32m, "No details");
Components Hdd = new Components("256 SSD", 16.00m,"100 Terrabytes");
List<Computer> computers = new List<Computer>
{
new Computer("ACCER", Motherboard, Processor, Ram, GraphicsCard, Hdd, 3200.43m),
new Computer("APPLE", Motherboard, Processor, Ram, GraphicsCard, Hdd, 4433.65m),
new Computer("LENOVO", Motherboard, Processor, Ram, GraphicsCard, Hdd,5800.65m),
new Computer("ASUS", Motherboard, Processor, Ram, GraphicsCard, Hdd,11000.96m)
};
computers.Sort((x, y) => x.Price.CompareTo(y.Price));
foreach (Computer pc in computers)
{
Console.WriteLine(pc);
}
}
}
}
| 33.55814 | 96 | 0.575884 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Penkov/OOP | PCCatalog/PCCatalog.cs | 1,445 | 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.AzureNextGen.RecoveryServices.V20190513.Inputs
{
/// <summary>
/// IaaS VM workload-specific backup item representing the Azure Resource Manager VM.
/// </summary>
public sealed class AzureIaaSComputeVMProtectedItemArgs : Pulumi.ResourceArgs
{
/// <summary>
/// Type of backup management for the backed up item.
/// </summary>
[Input("backupManagementType")]
public InputUnion<string, Pulumi.AzureNextGen.RecoveryServices.V20190513.BackupManagementType>? BackupManagementType { get; set; }
/// <summary>
/// Name of the backup set the backup item belongs to
/// </summary>
[Input("backupSetName")]
public Input<string>? BackupSetName { get; set; }
/// <summary>
/// Unique name of container
/// </summary>
[Input("containerName")]
public Input<string>? ContainerName { get; set; }
/// <summary>
/// Create mode to indicate recovery of existing soft deleted data source or creation of new data source.
/// </summary>
[Input("createMode")]
public InputUnion<string, Pulumi.AzureNextGen.RecoveryServices.V20190513.CreateMode>? CreateMode { get; set; }
/// <summary>
/// Time for deferred deletion in UTC
/// </summary>
[Input("deferredDeleteTimeInUTC")]
public Input<string>? DeferredDeleteTimeInUTC { get; set; }
/// <summary>
/// Time remaining before the DS marked for deferred delete is permanently deleted
/// </summary>
[Input("deferredDeleteTimeRemaining")]
public Input<string>? DeferredDeleteTimeRemaining { get; set; }
/// <summary>
/// Additional information for this backup item.
/// </summary>
[Input("extendedInfo")]
public Input<Inputs.AzureIaaSVMProtectedItemExtendedInfoArgs>? ExtendedInfo { get; set; }
/// <summary>
/// Extended Properties for Azure IaasVM Backup.
/// </summary>
[Input("extendedProperties")]
public Input<Inputs.ExtendedPropertiesArgs>? ExtendedProperties { get; set; }
/// <summary>
/// Friendly name of the VM represented by this backup item.
/// </summary>
[Input("friendlyName")]
public Input<string>? FriendlyName { get; set; }
/// <summary>
/// Health status of protected item
/// </summary>
[Input("healthStatus")]
public InputUnion<string, Pulumi.AzureNextGen.RecoveryServices.V20190513.HealthStatus>? HealthStatus { get; set; }
/// <summary>
/// Flag to identify whether the deferred deleted DS is to be purged soon
/// </summary>
[Input("isDeferredDeleteScheduleUpcoming")]
public Input<bool>? IsDeferredDeleteScheduleUpcoming { get; set; }
/// <summary>
/// Flag to identify that deferred deleted DS is to be moved into Pause state
/// </summary>
[Input("isRehydrate")]
public Input<bool>? IsRehydrate { get; set; }
/// <summary>
/// Flag to identify whether the DS is scheduled for deferred delete
/// </summary>
[Input("isScheduledForDeferredDelete")]
public Input<bool>? IsScheduledForDeferredDelete { get; set; }
/// <summary>
/// Last backup operation status.
/// </summary>
[Input("lastBackupStatus")]
public Input<string>? LastBackupStatus { get; set; }
/// <summary>
/// Timestamp of the last backup operation on this backup item.
/// </summary>
[Input("lastBackupTime")]
public Input<string>? LastBackupTime { get; set; }
/// <summary>
/// Timestamp when the last (latest) backup copy was created for this backup item.
/// </summary>
[Input("lastRecoveryPoint")]
public Input<string>? LastRecoveryPoint { get; set; }
/// <summary>
/// ID of the backup policy with which this item is backed up.
/// </summary>
[Input("policyId")]
public Input<string>? PolicyId { get; set; }
/// <summary>
/// Data ID of the protected item.
/// </summary>
[Input("protectedItemDataId")]
public Input<string>? ProtectedItemDataId { get; set; }
/// <summary>
/// backup item type.
/// Expected value is 'AzureIaaSVMProtectedItem'.
/// </summary>
[Input("protectedItemType")]
public Input<string>? ProtectedItemType { get; set; }
/// <summary>
/// Backup state of this backup item.
/// </summary>
[Input("protectionState")]
public InputUnion<string, Pulumi.AzureNextGen.RecoveryServices.V20190513.ProtectionState>? ProtectionState { get; set; }
/// <summary>
/// Backup status of this backup item.
/// </summary>
[Input("protectionStatus")]
public Input<string>? ProtectionStatus { get; set; }
/// <summary>
/// ARM ID of the resource to be backed up.
/// </summary>
[Input("sourceResourceId")]
public Input<string>? SourceResourceId { get; set; }
/// <summary>
/// Fully qualified ARM ID of the virtual machine represented by this item.
/// </summary>
[Input("virtualMachineId")]
public Input<string>? VirtualMachineId { get; set; }
/// <summary>
/// Type of workload this item represents.
/// </summary>
[Input("workloadType")]
public InputUnion<string, Pulumi.AzureNextGen.RecoveryServices.V20190513.DataSourceType>? WorkloadType { get; set; }
public AzureIaaSComputeVMProtectedItemArgs()
{
}
}
}
| 36.25 | 138 | 0.604598 | [
"Apache-2.0"
] | pulumi/pulumi-azure-nextgen | sdk/dotnet/RecoveryServices/V20190513/Inputs/AzureIaaSComputeVMProtectedItemArgs.cs | 6,090 | C# |
#pragma checksum "D:\ASP.NET PROJECTS\WebMarket\WebMarket\Views\_ViewStart.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "7091c65830b0329e613be026ede8a57552863778"
// <auto-generated/>
#pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views__ViewStart), @"mvc.1.0.view", @"/Views/_ViewStart.cshtml")]
namespace AspNetCore
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
#nullable restore
#line 1 "D:\ASP.NET PROJECTS\WebMarket\WebMarket\Views\_ViewImports.cshtml"
using WebMarket;
#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "D:\ASP.NET PROJECTS\WebMarket\WebMarket\Views\_ViewImports.cshtml"
using WebMarket.Models;
#line default
#line hidden
#nullable disable
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"7091c65830b0329e613be026ede8a57552863778", @"/Views/_ViewStart.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d17675fdd68bf2a436863f12911cbe963bcb37ae", @"/Views/_ViewImports.cshtml")]
public class Views__ViewStart : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
{
#pragma warning disable 1998
public async override global::System.Threading.Tasks.Task ExecuteAsync()
{
#nullable restore
#line 1 "D:\ASP.NET PROJECTS\WebMarket\WebMarket\Views\_ViewStart.cshtml"
Layout = "_Layout";
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
}
}
#pragma warning restore 1591
| 45.830508 | 166 | 0.765163 | [
"MIT"
] | DewhiteE/WebMarket | WebMarket/obj/Debug/netcoreapp3.1/Razor/Views/_ViewStart.cshtml.g.cs | 2,704 | C# |
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Agri.Models.Configuration
{
public class MiniApp
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public List<MiniAppLabel> MiniAppLabels { get; set; }
}
} | 21.5 | 61 | 0.662791 | [
"Apache-2.0"
] | bcgov/agri-nmp | app/Agri.Models/Configuration/MiniApp.cs | 346 | C# |
using Adaptive.Aeron.LogBuffer;
using Adaptive.Agrona;
using Adaptive.Agrona.Concurrent;
using Adaptive.Agrona.Concurrent.Status;
namespace Adaptive.Aeron
{
/// <summary>
/// Aeron publisher API for sending messages to subscribers of a given channel and streamId pair. <seealso cref="Publication"/>s
/// are created via the <seealso cref="Aeron.AddPublication(string, int)"/> method, and messages are sent via one of the
/// <seealso cref="Publication.Offer(UnsafeBuffer)"/> methods, or a <seealso cref="TryClaim(int, BufferClaim)"/> and <seealso cref="BufferClaim.Commit()"/>
/// method combination.
/// <para>
/// The APIs used for try claim and offer are non-blocking and thread safe.
/// </para>
/// <para>
/// <b>Note:</b> Instances are threadsafe and can be shared between publishing threads.
///
/// </para>
/// </summary>
/// <seealso cref="Aeron.AddPublication(string, int)"></seealso>
/// <seealso cref="BufferClaim"></seealso>
public class ConcurrentPublication : Publication
{
private readonly TermAppender[] _termAppenders = new TermAppender[LogBufferDescriptor.PARTITION_COUNT];
internal ConcurrentPublication(
ClientConductor clientConductor,
string channel,
int streamId,
int sessionId,
IReadablePosition positionLimit,
int channelStatusId,
LogBuffers logBuffers,
long originalRegistrationId,
long registrationId)
: base(
clientConductor,
channel,
streamId,
sessionId,
positionLimit,
channelStatusId,
logBuffers,
originalRegistrationId,
registrationId
)
{
var buffers = logBuffers.DuplicateTermBuffers();
for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
{
_termAppenders[i] = new TermAppender(buffers[i], _logMetaDataBuffer, i);
}
}
/// <inheritdoc />
public override long Offer(IDirectBuffer buffer, int offset, int length, ReservedValueSupplier reservedValueSupplier = null)
{
long newPosition = CLOSED;
if (!_isClosed)
{
long limit = _positionLimit.GetVolatile();
int termCount = LogBufferDescriptor.ActiveTermCount(_logMetaDataBuffer);
TermAppender termAppender = _termAppenders[LogBufferDescriptor.IndexByTermCount(termCount)];
long rawTail = termAppender.RawTailVolatile();
long termOffset = rawTail & 0xFFFF_FFFFL;
int termId = LogBufferDescriptor.TermId(rawTail);
long position = LogBufferDescriptor.ComputeTermBeginPosition(termId, _positionBitsToShift, InitialTermId) + termOffset;
if (termCount != (termId - InitialTermId))
{
return ADMIN_ACTION;
}
if (position < limit)
{
int resultingOffset;
if (length <= MaxPayloadLength)
{
resultingOffset = termAppender.AppendUnfragmentedMessage(_headerWriter, buffer, offset, length, reservedValueSupplier, termId);
}
else
{
CheckForMaxMessageLength(length);
resultingOffset = termAppender.AppendFragmentedMessage(_headerWriter, buffer, offset, length, MaxPayloadLength, reservedValueSupplier, termId);
}
newPosition = NewPosition(termCount, (int)termOffset, termId, position, resultingOffset);
}
else
{
newPosition = BackPressureStatus(position, length);
}
}
return newPosition;
}
/// <inheritdoc />
public override long Offer(DirectBufferVector[] vectors, ReservedValueSupplier reservedValueSupplier = null)
{
int length = DirectBufferVector.ValidateAndComputeLength(vectors);
long newPosition = CLOSED;
if (!_isClosed)
{
long limit = _positionLimit.GetVolatile();
int termCount = LogBufferDescriptor.ActiveTermCount(_logMetaDataBuffer);
TermAppender termAppender = _termAppenders[LogBufferDescriptor.IndexByTermCount(termCount)];
long rawTail = termAppender.RawTailVolatile();
long termOffset = rawTail & 0xFFFF_FFFFL;
int termId = LogBufferDescriptor.TermId(rawTail);
long position = LogBufferDescriptor.ComputeTermBeginPosition(termId, _positionBitsToShift, InitialTermId) + termOffset;
if (termCount != (termId - InitialTermId))
{
return ADMIN_ACTION;
}
if (position < limit)
{
int resultingOffset;
if (length <= MaxPayloadLength)
{
resultingOffset = termAppender.AppendUnfragmentedMessage(_headerWriter, vectors, length, reservedValueSupplier, termId);
}
else
{
CheckForMaxMessageLength(length);
resultingOffset = termAppender.AppendFragmentedMessage(_headerWriter, vectors, length, MaxPayloadLength, reservedValueSupplier, termId);
}
newPosition = NewPosition(termCount, (int)termOffset, termId, position, resultingOffset);
}
else
{
newPosition = BackPressureStatus(position, length);
}
}
return newPosition;
}
/// <inheritdoc />
public override long TryClaim(int length, BufferClaim bufferClaim)
{
CheckForMaxPayloadLength(length);
long newPosition = CLOSED;
if (!_isClosed)
{
long limit = _positionLimit.GetVolatile();
int termCount = LogBufferDescriptor.ActiveTermCount(_logMetaDataBuffer);
TermAppender termAppender = _termAppenders[LogBufferDescriptor.IndexByTermCount(termCount)];
long rawTail = termAppender.RawTailVolatile();
long termOffset = rawTail & 0xFFFF_FFFFL;
int termId = LogBufferDescriptor.TermId(rawTail);
long position = LogBufferDescriptor.ComputeTermBeginPosition(termId, _positionBitsToShift, InitialTermId) + termOffset;
if (termCount != (termId - InitialTermId))
{
return ADMIN_ACTION;
}
if (position < limit)
{
int resultingOffset = termAppender.Claim(_headerWriter, length, bufferClaim, termId);
newPosition = NewPosition(termCount, (int)termOffset, termId, position, resultingOffset);
}
else
{
newPosition = BackPressureStatus(position, length);
}
}
return newPosition;
}
private long NewPosition(int termCount, int termOffset, int termId, long position, int resultingOffset)
{
if (resultingOffset > 0)
{
return (position - termOffset) + resultingOffset;
}
if ((position + termOffset) > _maxPossiblePosition)
{
return MAX_POSITION_EXCEEDED;
}
LogBufferDescriptor.RotateLog(_logMetaDataBuffer, termCount, termId);
return ADMIN_ACTION;
}
}
} | 31.462312 | 156 | 0.720013 | [
"Apache-2.0"
] | Horusiath/aeron.net | src/Adaptive.Aeron/ConcurrentPublication.cs | 6,263 | C# |
// Copyright © 2020-present Derek Thurn
// 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
// 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.Linq;
using Nighthollow.Interface;
using Nighthollow.Services;
using UnityEngine;
using UnityEngine.UIElements;
#nullable enable
namespace Nighthollow.Editing
{
public interface IEditor
{
/// <summary>
/// When you click on things, Unity takes focus away and drops your next KeyDown event, even if what you clicked
/// on has `focusable` set to false. So all child click and key handlers need to call this method to re-focus the
/// sheet properly to get click events.
/// </summary>
void FocusRoot();
void OnChildEditingComplete();
void OnDataChanged();
}
public sealed class EditorSheet : VisualElement, IEditor
{
public const int DefaultCellWidth = 250;
const int ContentPadding = 32;
readonly ServiceRegistry _registry;
readonly EditorSheetDelegate _sheetDelegate;
readonly Action? _onEscape;
readonly ScrollView _scrollView;
readonly VisualElement _content;
readonly Vector2Int? _initiallySelected;
Dictionary<Vector2Int, EditorCell> _cells;
Label? _leftPositionHelper;
Label? _topPositionHelper;
public Vector2Int? CurrentlySelected;
Vector2Int? CurrentlyActive { get; set; }
public EditorSheet(
ServiceRegistry registry,
EditorSheetDelegate sheetDelegate,
Vector2Int? selected,
Action? onEscape = null)
{
_registry = registry;
_sheetDelegate = sheetDelegate;
_onEscape = onEscape;
_initiallySelected = selected;
_content = new VisualElement();
_content.AddToClassList("editor-content");
_scrollView = new ScrollView();
_scrollView.AddToClassList("editor-scroll-view");
_scrollView.Add(_content);
Add(_scrollView);
_cells = RenderCells();
_sheetDelegate.Initialize(OnDataChanged);
focusable = true;
RegisterCallback<KeyDownEvent>(OnKeyDown);
RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
}
void OnGeometryChanged(GeometryChangedEvent evt)
{
Focus();
SelectPosition(_initiallySelected ?? Vector2Int.zero);
UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);
}
public int Width { get; private set; }
Dictionary<Vector2Int, EditorCell> RenderCells()
{
_content.Clear();
var content = _sheetDelegate.GetCells();
var cells = content.Cells;
var result = new Dictionary<Vector2Int, EditorCell>();
var columnCount = cells.Max(row => row.Count);
var columnWidths = content.ColumnWidths;
Width = ContentPadding + columnWidths.Sum();
for (var rowIndex = 0; rowIndex < cells.Count; rowIndex++)
{
var list = cells[rowIndex];
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
var position = new Vector2Int(columnIndex, rowIndex);
if (columnIndex != 0 && list.Count == 1)
{
// Full width column support
result[position] = result[new Vector2Int(0, rowIndex)];
continue;
}
var cell = columnIndex >= list.Count
? EditorCellFactory.CreateBlank()
: EditorCellFactory.Create(_registry, this, list[columnIndex]);
cell.RegisterCallback<ClickEvent>(e =>
{
if (position == CurrentlySelected)
{
ActivateCell(position);
}
else
{
SelectPosition(position);
}
});
cell.style.width = columnWidths[columnIndex];
if (list.Count == 1)
{
cell.style.width = Width - ContentPadding;
cell.AddToClassList("full-width-cell");
}
result[position] = cell;
_content.Add(cell);
}
}
_content.style.width = Width;
var footer = new VisualElement();
footer.AddToClassList("editor-footer");
_content.Add(footer);
return result;
}
public void OnDataChanged()
{
var previouslySelected = CurrentlySelected;
var key = CurrentlySelected.HasValue ? _cells[CurrentlySelected.Value].Key : null;
CurrentlySelected = null;
CurrentlyActive = null;
_cells = RenderCells();
InterfaceUtils.After(0.1f,
() =>
{
// Cell bounds aren't available immediately after re-rendering, but we don't seem to get OnGeometryChanged
// again?
SelectPosition(key != null ? _cells.FirstOrDefault(p => p.Value.Key == key).Key : previouslySelected);
});
}
public void OnKeyDown(KeyDownEvent evt)
{
if (!CurrentlySelected.HasValue)
{
return;
}
if (CurrentlyActive.HasValue)
{
_cells[CurrentlyActive.Value].OnParentKeyDown(evt);
return;
}
switch (evt.keyCode)
{
case KeyCode.Tab when !evt.shiftKey:
case KeyCode.RightArrow:
SelectPosition(CurrentlySelected.Value + new Vector2Int(1, 0));
break;
case KeyCode.Tab when evt.shiftKey:
case KeyCode.LeftArrow:
SelectPosition(CurrentlySelected.Value + new Vector2Int(-1, 0));
break;
case KeyCode.UpArrow:
SelectPosition(CurrentlySelected.Value + new Vector2Int(0, -1));
break;
case KeyCode.DownArrow:
SelectPosition(CurrentlySelected.Value + new Vector2Int(0, 1));
break;
case KeyCode.KeypadEnter:
case KeyCode.Return:
if (CurrentlyActive == null)
{
ActivateCell(CurrentlySelected.Value);
}
break;
case KeyCode.Escape:
case KeyCode.Backspace:
_onEscape?.Invoke();
break;
}
}
void ActivateCell(Vector2Int position)
{
if (position != CurrentlyActive)
{
if (CurrentlyActive.HasValue)
{
_cells[CurrentlyActive.Value].Deactivate();
}
CurrentlyActive = position;
_cells[position].Activate();
}
}
void SelectPosition(Vector2Int? position)
{
if (position.HasValue && _cells.ContainsKey(position.Value) && position != CurrentlySelected)
{
if (CurrentlyActive.HasValue)
{
_cells[CurrentlyActive.Value].Deactivate();
}
CurrentlyActive = null;
Focus();
if (CurrentlySelected.HasValue)
{
_cells[CurrentlySelected.Value].Unselect();
}
_cells[position.Value].Select();
CurrentlySelected = position;
Scroll(position.Value);
RenderPositionHelpers(position.Value);
}
}
public void FocusRoot()
{
Focus();
}
public void OnChildEditingComplete()
{
CurrentlyActive = null;
FocusRoot();
}
public void DeactivateAllCells()
{
foreach (var cell in _cells.Values)
{
cell.Deactivate();
}
}
bool IsFullScreen(Vector2Int position) => _cells[position].GetClasses().Contains("full-width-cell");
void Scroll(Vector2Int position)
{
var leaf = InterfaceUtils.FirstLeaf(_cells[position]);
_scrollView.ScrollTo(leaf);
// This is just sort of a crazy hack on top of unity's scrolling behavior, feel free to change randomly.
if (position.y == 0 || leaf.worldBound.y < 500)
{
_scrollView.scrollOffset =
IsFullScreen(position) ? new Vector2(0, 0) : new Vector2(_scrollView.scrollOffset.x, 0);
}
if (position.x == 0 || leaf.worldBound.x < 500)
{
_scrollView.scrollOffset = new Vector2(0, _scrollView.scrollOffset.y);
}
}
void RenderPositionHelpers(Vector2Int position)
{
var leftIndex = new Vector2Int(0, position.y);
string? left = null;
while (_cells.ContainsKey(leftIndex))
{
if (_cells[leftIndex].Preview() is { } preview)
{
left = preview;
break;
}
leftIndex = new Vector2Int(leftIndex.x + 1, leftIndex.y);
}
var topIndex = new Vector2Int(position.x, 0);
string? top = null;
while (_cells.ContainsKey(topIndex))
{
if (!IsFullScreen(topIndex) && _cells[topIndex].Preview() is { } preview)
{
top = preview;
break;
}
topIndex = new Vector2Int(topIndex.x, topIndex.y + 1);
}
var currentPosition = _cells[position].worldBound;
_leftPositionHelper?.RemoveFromHierarchy();
if (!IsFullScreen(position) && _scrollView.scrollOffset.x > 0 && left != null)
{
_leftPositionHelper = new Label(left);
_leftPositionHelper.style.left = 32;
_leftPositionHelper.style.top = currentPosition.y - 16;
_leftPositionHelper.AddToClassList("position-helper");
Add(_leftPositionHelper);
}
_topPositionHelper?.RemoveFromHierarchy();
if (!IsFullScreen(position) && _scrollView.scrollOffset.y > 0 && top != null)
{
_topPositionHelper = new Label(top);
_topPositionHelper.style.left = currentPosition.x - 16;
_topPositionHelper.style.top = 0;
_topPositionHelper.style.width = currentPosition.width;
_topPositionHelper.AddToClassList("position-helper");
Add(_topPositionHelper);
}
}
}
} | 28.778098 | 117 | 0.623573 | [
"Apache-2.0"
] | thurn/nighthollow | Assets/Nighthollow/Editing/EditorSheet.cs | 9,987 | C# |
using System;
using System.Drawing;
using System.Reflection;
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Hops;
[assembly: AssemblyTitle("Hops")]
[assembly: AssemblyDescription("Out of process solving using Rhino Compute")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Robert McNeel & Associates")]
[assembly: AssemblyProduct("Hops")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("82cb7266-a8bc-4d3e-99f6-b91504c7117f")]
[assembly: AssemblyVersion(GhaAssemblyInfo.AppVersion)]
[assembly: AssemblyFileVersion(GhaAssemblyInfo.AppVersion)]
namespace Hops
{
public class GhaAssemblyInfo : GH_AssemblyInfo
{
public static GhaAssemblyInfo TheAssemblyInfo { get; private set; }
public GhaAssemblyInfo()
{
TheAssemblyInfo = this;
}
public const string AppVersion = "0.10.1.0";
public override Bitmap Icon
{
get
{
var stream = GetType().Assembly.GetManifestResourceStream("Hops.resources.Hops_24x24.png");
return new System.Drawing.Bitmap(stream);
}
}
public override string Name
{
get
{
var attr = GetType().Assembly.GetCustomAttribute<AssemblyTitleAttribute>();
return attr.Title;
}
}
public override string Description
{
get
{
var attr = GetType().Assembly.GetCustomAttribute<AssemblyDescriptionAttribute>();
return attr.Description;
}
}
public override Guid Id
{
get
{
var attr = GetType().Assembly.GetCustomAttribute<GuidAttribute>();
return new Guid(attr.Value);
}
}
public override string AuthorName
{
get
{
var attr = GetType().Assembly.GetCustomAttribute<AssemblyCompanyAttribute>();
return attr.Company;
}
}
public override string AuthorContact => "https://github.com/mcneel/compute.rhino3d";
public override string AssemblyVersion
{
get
{
var t = typeof(GhaAssemblyInfo).Assembly.GetName().Version;
return $"{t.Major}.{t.Minor}.{t.Build}";
}
}
}
}
| 28.322222 | 107 | 0.583758 | [
"MIT"
] | Noahyt/compute.rhino3d | src/hops/Properties/AssemblyInfo.cs | 2,552 | C# |
using System.Collections.Generic;
namespace HealthyLifestyleTrackingApp.Services.Exercises.Models
{
public class ExerciseQueryServiceModel
{
public int CurrentPage { get; init; }
public int ExercisesPerPage { get; init; }
public int TotalExercises { get; set; }
public IEnumerable<ExerciseServiceModel> Exercises { get; init; }
}
}
| 23.8125 | 73 | 0.695538 | [
"MIT"
] | VeselinaSidova/Healthy-Lifestyle-Tracking-App | HealthyLifestyleTrackingApp/Services/Exercises/Models/ExerciseQueryServiceModel.cs | 383 | 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using log4net;
using SaaSBoostHelloWorld.Models;
using SaaSBoostHelloWorld.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using System.Web.Mvc;
namespace SaaSBoostHelloWorld.Controllers
{
public class ProductController : Controller
{
private static readonly ILog LOGGER = LogManager.GetLogger(typeof(ProductController));
private IProductDao productDao = new ProductDao();
private ICategoryDao categoryDao = new CategoryDao();
// GET: Product
public ActionResult Index()
{
LOGGER.Info("ProductController::Index");
IList<Product> products = productDao.GetProducts();
LOGGER.Info(String.Format("Returning {0} products", products.Count));
ViewData["msg"] = TempData["msg"];
ViewData["css"] = TempData["css"];
return View(products);
}
// GET: Product/{id}
public ActionResult Detail(int id)
{
LOGGER.Info("ProductController::Detail GET");
Product product = productDao.GetProduct(id);
return View(product);
}
// GET: Product/Cancel
public ActionResult Cancel()
{
LOGGER.Info("ProductController::Cancel");
ModelState.Clear();
return RedirectToAction("Index");
}
// GET: Product/Create
public ActionResult Create()
{
LOGGER.Info("ProductController::Create GET");
IList<Category> categories = categoryDao.GetCategories();
ViewData["categories"] = categories;
return View(new Product());
}
// POST: Product/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
LOGGER.Info("ProductController::Create POST");
if (ModelState.IsValid)
{
try
{
Product product = new Product
{
Sku = collection["Sku"],
Name = collection["Name"],
Price = Convert.ToDecimal(collection["Price"]),
ImageName = default
};
string categories = collection["Categories"];
if (!String.IsNullOrEmpty(categories))
{
string[] categoryIds = categories.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
LOGGER.Info($"Looping through {categoryIds.Length} checked category ids");
for (int i = 0; i < categoryIds.Length; i++)
{
string categoryId = categoryIds[i];
LOGGER.Info($"Converting {categoryId} to Int");
product.Categories.Add(new Category(Convert.ToInt32(categoryId)));
}
}
product = productDao.SaveProduct(product);
TempData["msg"] = "New product added";
TempData["css"] = "success";
return RedirectToAction("Index");
}
catch (Exception e)
{
LOGGER.Error($"Error saving product: {e}");
return View();
}
}
else
{
LOGGER.Warn("ModelState is invalid");
return View();
}
}
// GET: Product/Edit/{id}
public ActionResult Edit(int id)
{
LOGGER.Info("ProductController::Edit GET");
IList<Category> categories = categoryDao.GetCategories();
ViewData["categories"] = categories;
Product product = productDao.GetProduct(id);
IList<int> existingCategories = new List<int>();
foreach (Category category in product.Categories)
{
existingCategories.Add(category.Id);
}
ViewData["existingCategories"] = existingCategories;
return View(product);
}
// POST: Product/Edit/{id}
[HttpPost]
public ActionResult Edit(FormCollection collection, HttpPostedFileBase file)
{
LOGGER.Info("ProductController::Edit POST");
if (ModelState.IsValid)
{
try
{
Product product = new Product
{
Id = Convert.ToInt32(collection["Id"]),
Sku = collection["Sku"],
Name = collection["Name"],
Price = Convert.ToDecimal(collection["Price"]),
ImageName = default
};
string categories = collection["Categories"];
if (!String.IsNullOrEmpty(categories))
{
string[] categoryIds = categories.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
LOGGER.Info($"Looping through {categoryIds.Length} checked category ids");
for (int i = 0; i < categoryIds.Length; i++)
{
string categoryId = categoryIds[i];
LOGGER.Info($"Converting {categoryId} to Int");
product.Categories.Add(new Category(Convert.ToInt32(categoryId)));
}
}
if (file != null && file.ContentLength > 0)
{
LOGGER.Info($"Processing uploaded file {file.FileName}");
string fileName = Path.GetFileName(file.FileName);
product.ImageName = fileName;
string filePath = product.GetImagePath();
//string path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
//string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? "Unknown";
//string path = Path.Combine("C:\\Images", filePath);
string path = Path.Combine(Server.MapPath("~/Images"), filePath);
LOGGER.Info($"Saving uploaded file to {path}");
try
{
new FileInfo(path).Directory.Create();
file.SaveAs(path);
} catch (Exception e)
{
LOGGER.Error($"Error saving file: {e}");
}
} else
{
LOGGER.Info("Uploaded file is null");
}
product = productDao.SaveProduct(product);
TempData["msg"] = "Product updated";
TempData["css"] = "success";
return RedirectToAction("Index");
}
catch (Exception e)
{
LOGGER.Error($"Error saving product: {e}");
return View();
}
}
else
{
LOGGER.Warn("ModelState is invalid");
return View();
}
}
// GET: Product/Delete/{id}
public ActionResult Delete(int id)
{
LOGGER.Info("ProductController::Delete GET");
Product product = productDao.GetProduct(id);
if (product == null)
{
TempData["msg"] = $"No product for id {id}";
TempData["css"] = "danger";
}
return View(product);
}
// POST: Product/Delete/{id}
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
LOGGER.Info("ProductController::Delete POST");
try
{
Product product = new Product
{
Id = Convert.ToInt32(collection["Id"]),
Name = collection["Name"]
};
productDao.DeleteProduct(product);
TempData["msg"] = "Product deleted";
TempData["css"] = "success";
return RedirectToAction("Index");
}
catch (Exception e)
{
LOGGER.Error($"Error deleting product: {e}");
return View();
}
}
}
} | 39.871369 | 135 | 0.475908 | [
"Apache-2.0"
] | Mimozar/aws-saas-boost | samples/dotnet-framework/SaaSBoostHelloWorld/Controllers/ProductController.cs | 9,611 | C# |
// Copyright (c) 2007-2018 ppy Pty Ltd <[email protected]>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using osu.Framework.Timing;
namespace osu.Framework.Audio.Track
{
public class TrackVirtual : Track
{
private readonly StopwatchClock clock = new StopwatchClock();
private double seekOffset;
public TrackVirtual()
{
Length = double.PositiveInfinity;
}
public override bool Seek(double seek)
{
double current = CurrentTime;
seekOffset = seek;
lock (clock)
{
if (IsRunning)
clock.Restart();
else
clock.Reset();
}
if (Length > 0 && seekOffset > Length)
seekOffset = Length;
return current != seekOffset;
}
public override void Start()
{
lock (clock) clock.Start();
}
public override void Reset()
{
lock (clock) clock.Reset();
seekOffset = 0;
base.Reset();
}
public override void Stop()
{
lock (clock) clock.Stop();
}
public override bool IsRunning
{
get
{
lock (clock) return clock.IsRunning;
}
}
public override double CurrentTime
{
get
{
lock (clock) return seekOffset + clock.CurrentTime;
}
}
protected override void UpdateState()
{
base.UpdateState();
lock (clock)
{
if (CurrentTime >= Length)
Stop();
}
}
internal override void OnStateChanged()
{
base.OnStateChanged();
lock (clock)
clock.Rate = Tempo;
}
}
}
| 22.548387 | 103 | 0.445875 | [
"MIT"
] | miterosan/osu-framework | osu.Framework/Audio/Track/TrackVirtual.cs | 2,097 | 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("GeometricShapes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Toshiba")]
[assembly: AssemblyProduct("GeometricShapes")]
[assembly: AssemblyCopyright("Copyright © Toshiba 2015")]
[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("5d115a65-0735-4730-88e8-12812b6aaecd")]
// 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.297297 | 84 | 0.748765 | [
"MIT"
] | AndrewSmarty/OOP | GeometricShapes/GeometricShapes/Properties/AssemblyInfo.cs | 1,420 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using Microsoft.MixedReality.Toolkit.Input;
using System.Collections.Generic;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Utilities.Solvers
{
/// <summary>
/// This class handles the solver components that are attached to this <see href="https://docs.unity3d.com/ScriptReference/GameObject.html">GameObject</see>
/// </summary>
public class SolverHandler : ControllerFinder
{
[SerializeField]
[Tooltip("Tracked object to calculate position and orientation from. If you want to manually override and use a scene object, use the TransformTarget field.")]
private TrackedObjectType trackedObjectToReference = TrackedObjectType.Head;
/// <summary>
/// Tracked object to calculate position and orientation from. If you want to manually override and use a scene object, use the TransformTarget field.
/// </summary>
public TrackedObjectType TrackedObjectToReference
{
get { return trackedObjectToReference; }
set
{
if (trackedObjectToReference != value)
{
trackedObjectToReference = value;
RefreshTrackedObject();
}
}
}
[SerializeField]
[Tooltip("When using the hand to calculate position and orientation, use this specific joint.")]
private TrackedHandJoint trackedHandJoint = TrackedHandJoint.Palm;
/// <summary>
/// When using the hand to calculate position and orientation, use this specific joint.
/// </summary>
public TrackedHandJoint TrackedHandJoint
{
get { return trackedHandJoint; }
set
{
trackedHandJoint = value;
RefreshTrackedObject();
}
}
[SerializeField]
[Tooltip("Add an additional offset of the tracked object to base the solver on. Useful for tracking something like a halo position above your head or off the side of a controller.")]
private Vector3 additionalOffset;
/// <summary>
/// Add an additional offset of the tracked object to base the solver on. Useful for tracking something like a halo position above your head or off the side of a controller.
/// </summary>
public Vector3 AdditionalOffset
{
get { return additionalOffset; }
set
{
additionalOffset = value;
transformTarget = MakeOffsetTransform(transformTarget);
}
}
[SerializeField]
[Tooltip("Add an additional rotation on top of the tracked object. Useful for tracking what is essentially the up or right/left vectors.")]
private Vector3 additionalRotation;
/// <summary>
/// Add an additional rotation on top of the tracked object. Useful for tracking what is essentially the up or right/left vectors.
/// </summary>
public Vector3 AdditionalRotation
{
get { return additionalRotation; }
set
{
additionalRotation = value;
transformTarget = MakeOffsetTransform(transformTarget);
}
}
[SerializeField]
[Tooltip("Manual override for TrackedObjectToReference if you want to use a scene object. Leave empty if you want to use head, motion-tracked controllers, or motion-tracked hands.")]
private Transform transformTarget;
/// <summary>
/// The target transform that the solvers will act upon.
/// </summary>
public Transform TransformTarget
{
get { return transformTarget; }
set { transformTarget = value; }
}
[SerializeField]
[Tooltip("Whether or not this SolverHandler calls SolverUpdate() every frame. Only one SolverHandler should manage SolverUpdate(). This setting does not affect whether the Target Transform of this SolverHandler gets updated or not.")]
private bool updateSolvers = true;
/// <summary>
/// Whether or not this SolverHandler calls SolverUpdate() every frame. Only one SolverHandler should manage SolverUpdate(). This setting does not affect whether the Target Transform of this SolverHandler gets updated or not.
/// </summary>
public bool UpdateSolvers
{
get { return updateSolvers; }
set { updateSolvers = value; }
}
/// <summary>
/// The position the solver is trying to move to.
/// </summary>
public Vector3 GoalPosition { get; set; }
/// <summary>
/// The rotation the solver is trying to rotate to.
/// </summary>
public Quaternion GoalRotation { get; set; }
/// <summary>
/// The scale the solver is trying to scale to.
/// </summary>
public Vector3 GoalScale { get; set; }
/// <summary>
/// Alternate scale.
/// </summary>
public Vector3Smoothed AltScale { get; set; }
/// <summary>
/// The timestamp the solvers will use to calculate with.
/// </summary>
public float DeltaTime { get; set; }
private bool RequiresOffset => AdditionalOffset.sqrMagnitude != 0 || AdditionalRotation.sqrMagnitude != 0;
protected readonly List<Solver> solvers = new List<Solver>();
private float lastUpdateTime;
private GameObject transformWithOffset;
private IMixedRealityHandJointService HandJointService => handJointService ?? (handJointService = MixedRealityToolkit.Instance.GetService<IMixedRealityHandJointService>());
private IMixedRealityHandJointService handJointService = null;
#region MonoBehaviour Implementation
private void Awake()
{
GoalScale = Vector3.one;
AltScale = new Vector3Smoothed(Vector3.one, 0.1f);
DeltaTime = Time.deltaTime;
lastUpdateTime = Time.realtimeSinceStartup;
solvers.AddRange(GetComponents<Solver>());
}
private void Start()
{
// TransformTarget overrides TrackedObjectToReference
if (!transformTarget)
{
AttachToNewTrackedObject();
}
}
private void Update()
{
DeltaTime = Time.realtimeSinceStartup - lastUpdateTime;
lastUpdateTime = Time.realtimeSinceStartup;
}
private void LateUpdate()
{
if (UpdateSolvers)
{
//Before calling solvers, update goal to be the transform so that working and transform will match
GoalPosition = transform.position;
GoalRotation = transform.rotation;
GoalScale = transform.localScale;
for (int i = 0; i < solvers.Count; ++i)
{
Solver solver = solvers[i];
if (solver != null && solver.enabled)
{
solver.SolverUpdateEntry();
}
}
}
}
protected void OnDestroy()
{
DetachFromCurrentTrackedObject();
}
#endregion MonoBehaviour Implementation
protected override void OnControllerFound()
{
if (!transformTarget)
{
TrackTransform(ControllerTransform);
}
}
protected override void OnControllerLost()
{
DetachFromCurrentTrackedObject();
}
/// <summary>
/// Clears the transform target and attaches to the current <see cref="TrackedObjectToReference"/>.
/// </summary>
public void RefreshTrackedObject()
{
DetachFromCurrentTrackedObject();
AttachToNewTrackedObject();
}
protected virtual void DetachFromCurrentTrackedObject()
{
transformTarget = null;
if (transformWithOffset != null)
{
Destroy(transformWithOffset);
transformWithOffset = null;
}
}
protected virtual void AttachToNewTrackedObject()
{
switch (TrackedObjectToReference)
{
case TrackedObjectType.Head:
// No need to search for a controller if we've already attached to the head.
Handedness = Handedness.None;
TrackTransform(CameraCache.Main.transform);
break;
case TrackedObjectType.MotionControllerLeft:
Handedness = Handedness.Left;
break;
case TrackedObjectType.MotionControllerRight:
Handedness = Handedness.Right;
break;
case TrackedObjectType.HandJointLeft:
// Set to None, so the underlying ControllerFinder doesn't attach to a controller.
// TODO: Make this more generic / configurable for hands vs controllers. Also resolve the duplicate Handedness variables.
Handedness = Handedness.None;
TrackTransform(RequestEnableHandJoint(Handedness.Left));
break;
case TrackedObjectType.HandJointRight:
Handedness = Handedness.None;
TrackTransform(RequestEnableHandJoint(Handedness.Right));
break;
}
}
private void TrackTransform(Transform newTrackedTransform)
{
transformTarget = RequiresOffset ? MakeOffsetTransform(newTrackedTransform) : newTrackedTransform;
}
public Transform RequestEnableHandJoint(Handedness handedness)
{
return HandJointService?.RequestJointTransform(trackedHandJoint, handedness);
}
private Transform MakeOffsetTransform(Transform parentTransform)
{
if (transformWithOffset == null)
{
transformWithOffset = new GameObject();
transformWithOffset.transform.parent = parentTransform;
}
transformWithOffset.transform.localPosition = Vector3.Scale(AdditionalOffset, transformWithOffset.transform.localScale);
transformWithOffset.transform.localRotation = Quaternion.Euler(AdditionalRotation);
transformWithOffset.name = string.Format("{0} on {1} with offset {2}, {3}", gameObject.name, TrackedObjectToReference.ToString(), AdditionalOffset, AdditionalRotation);
return transformWithOffset.transform;
}
}
} | 37.986111 | 242 | 0.599726 | [
"MIT"
] | gejohnst/MixedRealityToolkit-Unity | Assets/MixedRealityToolkit.SDK/Features/Utilities/Solvers/SolverHandler.cs | 10,940 | C# |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Five
{
public partial class TestBox : Form
{
Label[,] tb = new Label[17, 17];
public TestBox()
{
InitializeComponent();
this.BackColor = Color.Gray;
//画棋盘
Bitmap bmp = new Bitmap(480, 480);
Graphics g = Graphics.FromImage(bmp);
Pen b = new Pen(Color.White);
for (int i = 1; i <= 15; i++)
{
g.DrawLine(b, i * 30, 30, i * 30, 450);
}
for (int i = 1; i <= 15; i++)
{
g.DrawLine(b, 30, i * 30, 450, i * 30);
}
g.FillEllipse(Brushes.White, 115, 115, 10, 10);//画点,下面四个也是画点
g.FillEllipse(Brushes.White, 115, 355, 10, 10);
g.FillEllipse(Brushes.White, 355, 115, 10, 10);
g.FillEllipse(Brushes.White, 355, 355, 10, 10);
g.FillEllipse(Brushes.White, 235, 235, 10, 10);
Pen br = new Pen(Color.White, 3);
g.DrawRectangle(br, 25, 25, 430, 430);//画边框
platform.Image = bmp;
for (int i=1;i<=15;i++) for(int j = 1; j <= 15; j++)
{
tb[i, j] = new Label
{
BackColor = Color.Transparent,
Location = new Point(i * 30 - 14, j * 30 - 15),
Size = new Size(30, 30),
TextAlign = ContentAlignment.MiddleCenter,
Font = new Font("宋体", 8, FontStyle.Bold)
};
platform.Controls.Add(tb[i, j]);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 1; i <= 15; i++) for (int j = 1; j <= 15; j++)
{
switch(MainForm.point[i, j])
{
case 0: { tb[i, j].ForeColor = Color.Black;break; }
case 1: { tb[i, j].ForeColor = Color.Purple; break; }
case 2: { tb[i, j].ForeColor = Color.Blue; break; }
case 3: { tb[i, j].ForeColor = Color.SkyBlue; break; }
case 4: { tb[i, j].ForeColor = Color.DarkGreen; break; }
case 5: { tb[i, j].ForeColor = Color.Green; break; }
case 6: { tb[i, j].ForeColor = Color.SpringGreen; break; }
case 7: { tb[i, j].ForeColor = Color.YellowGreen; break; }
case 8: { tb[i, j].ForeColor = Color.GreenYellow; break; }
case 9: { tb[i, j].ForeColor = Color.Yellow; break; }
default:
{
if (MainForm.point[i, j] >= 1000) tb[i, j].ForeColor = Color.Red;
else if (MainForm.point[i, j] >= 100) tb[i, j].ForeColor = Color.Orange;
else if (MainForm.point[i, j] >= 10) tb[i, j].ForeColor = Color.LightGoldenrodYellow;
break;
}
}
tb[i, j].Text = MainForm.point[i, j].ToString();
}
}
}
}
| 41.186047 | 118 | 0.425466 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | IAFEnvoy/Five | Five/TestBox.cs | 3,582 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace _03.Big_Factorial
{
class Program
{
static void Main(string[] args)
{
BigInteger countFactorial = 1;
var nFactorial = int.Parse(Console.ReadLine());
for (int i = 1; i <= nFactorial; i++)
{
countFactorial *= i;
}
Console.WriteLine(countFactorial);
}
}
}
| 21.16 | 59 | 0.568998 | [
"MIT"
] | DimovDimo/softuni-00-programming-fundamentals-january-2018 | 17.OBJECTS AND CLASSES/17.OBJECTS AND CLASS/03. Big Factorial/03. Big Factorial.cs | 531 | C# |
// MIT License
//
// Copyright (c) 2019 Stormancer
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using MsgPack.Serialization;
using Stormancer.Server.Plugins.API;
using Stormancer.Server.Plugins.Configuration;
using Stormancer.Core;
using Stormancer.Diagnostics;
using Stormancer.Server.Plugins.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
using System.Threading;
using Stormancer.Plugins;
namespace Stormancer.Server.Plugins.ServiceLocator
{
class LocatorController : ControllerBase
{
private readonly IServiceLocator _locator;
private readonly IUserSessions _sessions;
private readonly ILogger logger;
public LocatorController(IServiceLocator locator, IUserSessions sessions, ILogger logger)
{
_locator = locator;
_sessions = sessions;
this.logger = logger;
}
[Api(ApiAccess.Public, ApiType.Rpc)]
public async Task<string> GetSceneConnectionToken(string serviceType, string serviceName, RequestContext<IScenePeerClient> ctx)
{
var session = await _sessions.GetSession(ctx.RemotePeer,ctx.CancellationToken);
if (session == null || session.User == null)
{
logger.Log(LogLevel.Error, "locator", "An user tried to locate a service without being authenticated.", new { session });
throw new ClientException("locator.notAuthenticated");
}
try
{
var token = await _locator.GetSceneConnectionToken(serviceType, serviceName, session);
return token;
}
catch (InvalidOperationException ex) when (ex.InnerException is HttpRequestException hre)
{
if (hre.StatusCode == HttpStatusCode.NotFound)
{
throw new ClientException("sceneNotFound");
}
else
{
throw;
}
}
}
}
}
| 35.52809 | 137 | 0.674573 | [
"MIT"
] | Stormancer/plugins | src/Stormancer.Plugins/Users/Stormancer.Server.Plugins.Users/ServiceLocator/LocatorController.cs | 3,162 | C# |
// Copyright (c) Microsoft. All rights reserved.
using System;
namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub
{
/// <summary>
/// The special type of exception that provides managed exit from a retry loop. The user code can use this
/// exception to notify the retry policy that no further retry attempts are required.
/// </summary>
[Obsolete("You should use cancellation tokens or other means of stoping the retry loop.")]
sealed class RetryLimitExceededException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.RetryLimitExceededException" /> class with a default error message.
/// </summary>
public RetryLimitExceededException() : this("Retry limit exceeded")
{
}
/// <summary>
/// Initializes a new instance of the <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.RetryLimitExceededException" /> class with a specified error message.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public RetryLimitExceededException(string message) : base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.RetryLimitExceededException" /> class with a reference to the inner exception
/// that is the cause of this exception.
/// </summary>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public RetryLimitExceededException(Exception innerException) : base((innerException != null) ? innerException.Message : "Retry limit exceeded", innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.RetryLimitExceededException" /> class with a specified error message and inner exception.
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public RetryLimitExceededException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
| 49.166667 | 191 | 0.679237 | [
"MIT"
] | alextnewman/iotedge | edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/transientFaultHandling/RetryLimitExceededException.cs | 2,360 | C# |
using System.Diagnostics.CodeAnalysis;
using System.Net.Sockets;
using NModbusAsync.IO;
using Xunit;
namespace NModbusAsync.Test.Unit
{
[ExcludeFromCodeCoverage]
public class TcpClientAdapterTest
{
[Fact]
[Trait("Category", "Unit")]
public void DisposesTcpClient()
{
// Arrange
var tcpClient = new TcpClient();
var target = new TcpClientAdapter<TcpClient>(tcpClient);
// Act
target.Dispose();
// Assert
Assert.Null(tcpClient.Client);
}
}
} | 22.423077 | 68 | 0.581475 | [
"MIT"
] | wolf8196/NModbusAsync | NModbusAsync.Test/Unit/TcpClientAdapterTest.cs | 585 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace Vechicle_mngmt
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
| 26.045455 | 70 | 0.708551 | [
"MIT"
] | sharma452/Vechicle_mngmt | Vechicle_mngmt/Global.asax.cs | 575 | C# |
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SMECommerce.Databases.DbContexts;
namespace EFcoreExamples.Migrations
{
[DbContext(typeof(SMECommerceDbContext))]
[Migration("20211126052620_Category_Code_Added")]
partial class Category_Code_Added
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.11")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("SMECommerce.Models.EntityModels.Brand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Brand");
});
modelBuilder.Entity("SMECommerce.Models.EntityModels.Category", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Code")
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.HasKey("Id");
b.ToTable("Categories");
});
modelBuilder.Entity("SMECommerce.Models.EntityModels.Item", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int?>("BrandId")
.HasColumnType("int");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("ManufacturerDate")
.HasColumnType("datetime2");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("BrandId");
b.HasIndex("CategoryId");
b.ToTable("Products");
});
modelBuilder.Entity("SMECommerce.Models.EntityModels.Item", b =>
{
b.HasOne("SMECommerce.Models.EntityModels.Brand", "Brand")
.WithMany("Products")
.HasForeignKey("BrandId");
b.HasOne("SMECommerce.Models.EntityModels.Category", "Category")
.WithMany("Items")
.HasForeignKey("CategoryId");
b.Navigation("Brand");
b.Navigation("Category");
});
modelBuilder.Entity("SMECommerce.Models.EntityModels.Brand", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("SMECommerce.Models.EntityModels.Category", b =>
{
b.Navigation("Items");
});
#pragma warning restore 612, 618
}
}
}
| 35.825397 | 125 | 0.510855 | [
"MIT"
] | MoksedurRahman/Dot_Net_Core_Token_Base_Summary_ | SMECommerc.Databases/Migrations/20211126052620_Category_Code_Added.Designer.cs | 4,516 | 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Shared.Utilities;
namespace Microsoft.CodeAnalysis.Remote
{
internal sealed class RemoteFindUsagesService : BrokeredServiceBase, IRemoteFindUsagesService
{
internal sealed class Factory : FactoryBase<IRemoteFindUsagesService, IRemoteFindUsagesService.ICallback>
{
protected override IRemoteFindUsagesService CreateService(in ServiceConstructionArguments arguments, RemoteCallback<IRemoteFindUsagesService.ICallback> callback)
=> new RemoteFindUsagesService(arguments, callback);
}
private readonly RemoteCallback<IRemoteFindUsagesService.ICallback> _callback;
public RemoteFindUsagesService(in ServiceConstructionArguments arguments, RemoteCallback<IRemoteFindUsagesService.ICallback> callback)
: base(arguments)
{
_callback = callback;
}
public ValueTask FindReferencesAsync(
PinnedSolutionInfo solutionInfo,
SerializableSymbolAndProjectId symbolAndProjectId,
FindReferencesSearchOptions options,
CancellationToken cancellationToken)
{
return RunServiceAsync(async cancellationToken =>
{
using (UserOperationBooster.Boost())
{
var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
var project = solution.GetProject(symbolAndProjectId.ProjectId);
var symbol = await symbolAndProjectId.TryRehydrateAsync(
solution, cancellationToken).ConfigureAwait(false);
if (symbol == null)
return;
var context = new RemoteFindUsageContext(_callback, cancellationToken);
await AbstractFindUsagesService.FindReferencesAsync(
context, symbol, project, options).ConfigureAwait(false);
}
}, cancellationToken);
}
public ValueTask FindImplementationsAsync(
PinnedSolutionInfo solutionInfo,
SerializableSymbolAndProjectId symbolAndProjectId,
CancellationToken cancellationToken)
{
return RunServiceAsync(async cancellationToken =>
{
using (UserOperationBooster.Boost())
{
var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
var project = solution.GetProject(symbolAndProjectId.ProjectId);
var symbol = await symbolAndProjectId.TryRehydrateAsync(
solution, cancellationToken).ConfigureAwait(false);
if (symbol == null)
return;
var context = new RemoteFindUsageContext(_callback, cancellationToken);
await AbstractFindUsagesService.FindImplementationsAsync(
symbol, project, context).ConfigureAwait(false);
}
}, cancellationToken);
}
private sealed class RemoteFindUsageContext : IFindUsagesContext, IStreamingProgressTracker
{
private readonly RemoteCallback<IRemoteFindUsagesService.ICallback> _callback;
private readonly Dictionary<DefinitionItem, int> _definitionItemToId = new Dictionary<DefinitionItem, int>();
public CancellationToken CancellationToken { get; }
public RemoteFindUsageContext(RemoteCallback<IRemoteFindUsagesService.ICallback> callback, CancellationToken cancellationToken)
{
_callback = callback;
CancellationToken = cancellationToken;
}
#region IStreamingProgressTracker
public ValueTask AddItemsAsync(int count)
=> _callback.InvokeAsync((callback, cancellationToken) => callback.AddItemsAsync(count), CancellationToken);
public ValueTask ItemCompletedAsync()
=> _callback.InvokeAsync((callback, cancellationToken) => callback.ItemCompletedAsync(), CancellationToken);
#endregion
#region IFindUsagesContext
public IStreamingProgressTracker ProgressTracker => this;
public ValueTask ReportMessageAsync(string message)
=> _callback.InvokeAsync((callback, cancellationToken) => callback.ReportMessageAsync(message), CancellationToken);
[Obsolete]
public ValueTask ReportProgressAsync(int current, int maximum)
=> _callback.InvokeAsync((callback, cancellationToken) => callback.ReportProgressAsync(current, maximum), CancellationToken);
public ValueTask SetSearchTitleAsync(string title)
=> _callback.InvokeAsync((callback, cancellationToken) => callback.SetSearchTitleAsync(title), CancellationToken);
public ValueTask OnDefinitionFoundAsync(DefinitionItem definition)
{
var id = GetOrAddDefinitionItemId(definition);
var dehydratedDefinition = SerializableDefinitionItem.Dehydrate(id, definition);
return _callback.InvokeAsync((callback, cancellationToken) => callback.OnDefinitionFoundAsync(dehydratedDefinition), CancellationToken);
}
private int GetOrAddDefinitionItemId(DefinitionItem item)
{
lock (_definitionItemToId)
{
if (!_definitionItemToId.TryGetValue(item, out var id))
{
id = _definitionItemToId.Count;
_definitionItemToId.Add(item, id);
}
return id;
}
}
public ValueTask OnReferenceFoundAsync(SourceReferenceItem reference)
{
var definitionItem = GetOrAddDefinitionItemId(reference.Definition);
var dehydratedReference = SerializableSourceReferenceItem.Dehydrate(definitionItem, reference);
return _callback.InvokeAsync((callback, cancellationToken) => callback.OnReferenceFoundAsync(dehydratedReference), CancellationToken);
}
#endregion
}
}
}
| 44.300654 | 173 | 0.651815 | [
"MIT"
] | BrianFreemanAtlanta/roslyn | src/Workspaces/Remote/ServiceHub/Services/FindUsages/RemoteFindUsagesService.cs | 6,780 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.AspNetCore.Authentication.Certificate
{
/// <summary>
/// Default values related to certificate authentication middleware
/// </summary>
public static class CertificateAuthenticationDefaults
{
/// <summary>
/// The default value used for CertificateAuthenticationOptions.AuthenticationScheme
/// </summary>
public const string AuthenticationScheme = "Certificate";
}
}
| 34.294118 | 92 | 0.711835 | [
"MIT"
] | 48355746/AspNetCore | src/Security/Authentication/Certificate/src/CertificateAuthenticationDefaults.cs | 583 | C# |
namespace Root.Code.Models.E01D.ObjectTracking
{
public class TrackedObject
{
//public ObjectState
public object Value { get; set; }
}
}
| 16.8 | 47 | 0.625 | [
"Apache-2.0"
] | E01D/Base | src/E01D.Base.Clr.General.Reflection.Models/Coding/Code/Models/E01D/Base/Clr/General/Reflection/ObjectTracking/TrackedObject.cs | 170 | C# |
/*
Copyright (c) 2013, Darren Horrocks
Copyright (c) 2021, Russell Webster
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Darren Horrocks, Russell Webster nor the names of their
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace System.Net.Torrent.Data
{
using System.Collections.Generic;
using System.IO;
public interface IMetadata : IHashProvider
{
public string Announce { get; }
public ICollection<string> AnnounceList { get; }
public string Comment { get; }
public string CreatedBy { get; }
public DateTime CreationDate { get; }
public ICollection<byte[]> PieceHashes { get; }
public long PieceSize { get; }
public bool Private { get; }
public IReadOnlyCollection<string> GetFiles();
public bool Load(MagnetLink magnetLink);
public bool Load(Stream stream);
}
} | 36.360656 | 80 | 0.753832 | [
"BSD-3-Clause"
] | AreebaAroosh/System.Net.Torrent | System.Net.Torrent/Data/IMetadata.cs | 2,220 | C# |
using NativeQuadTree.Jobs.Internal;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
namespace NativeQuadTree
{
/// <summary>
/// Example on how to do a range query, it's better to write your own and do many queries in a batch
/// </summary>
[BurstCompile]
public struct RectQueryJob<T> : IJob where T : unmanaged
{
[ReadOnly]
public AABB2D Bounds;
[ReadOnly]
public NativeReference<NativeQuadTree<T>> QuadTree;
public NativeList<QuadElement<T>> Results;
private QuadTreeRectRangeQuery<T> query;
public RectQueryJob(AABB2D bounds, NativeReference<NativeQuadTree<T>> quadTree, NativeList<QuadElement<T>> results)
{
Bounds = bounds;
QuadTree = quadTree;
Results = results;
query = new QuadTreeRectRangeQuery<T>();
}
public void Execute()
{
query.Query(QuadTree.Value, Bounds, Results);
}
}
} | 27.75 | 123 | 0.61962 | [
"MIT"
] | crener/NativeQuadtree | Assets/Jobs/RectQueryJob.cs | 999 | C# |
using System;
namespace TpsParser
{
public sealed class TpsParserException : Exception
{
public TpsParserException(string message)
: base(message)
{ }
public TpsParserException(string message, Exception innerException)
: base(message, innerException)
{ }
}
}
| 20.625 | 75 | 0.624242 | [
"MIT"
] | Trinitek/TpsParser | src/TpsParser/TpsParserException.cs | 332 | 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
#region Usings
using System;
using System.Collections;
using System.Globalization;
using DotNetNuke.Entities.Users;
#endregion
namespace DotNetNuke.Services.Tokens
{
public class ArrayListPropertyAccess : IPropertyAccess
{
private readonly ArrayList custom;
public ArrayListPropertyAccess(ArrayList list)
{
custom = list;
}
#region IPropertyAccess Members
public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
{
if (custom == null)
{
return string.Empty;
}
object valueObject = null;
string OutputFormat = format;
if (string.IsNullOrEmpty(format))
{
OutputFormat = "g";
}
int intIndex = int.Parse(propertyName);
if ((custom != null) && custom.Count > intIndex)
{
valueObject = custom[intIndex].ToString();
}
if ((valueObject != null))
{
switch (valueObject.GetType().Name)
{
case "String":
return PropertyAccess.FormatString((string) valueObject, format);
case "Boolean":
return (PropertyAccess.Boolean2LocalizedYesNo((bool) valueObject, formatProvider));
case "DateTime":
case "Double":
case "Single":
case "Int32":
case "Int64":
return (((IFormattable) valueObject).ToString(OutputFormat, formatProvider));
default:
return PropertyAccess.FormatString(valueObject.ToString(), format);
}
}
else
{
PropertyNotFound = true;
return string.Empty;
}
}
public CacheLevel Cacheability
{
get
{
return CacheLevel.notCacheable;
}
}
#endregion
}
}
| 30.024691 | 167 | 0.525905 | [
"MIT"
] | Tychodewaard/Dnn.Platform | DNN Platform/Library/Services/Tokens/PropertyAccess/ArrayListPropertyAccesss.cs | 2,434 | C# |
// Copyright 2016 Serilog Contributors
//
// 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.
// Below code has been modified as per application need.
// Used "sqlite-net-pcl" (instead of "System.Data.SQLite") which is cross platform support.
// Removed some parameters which are not used in application.
using System;
using System.Collections.Generic;
using System.IO;
using SQLite;
using System.Threading;
using System.Threading.Tasks;
using Serilog.Core;
using Serilog.Debugging;
using Serilog.Events;
using Serilog.Sinks.Batch;
using Serilog.Sinks.Extensions;
namespace Serilog.SQLite.Logging
{
internal class SQLiteSink : BatchProvider, ILogEventSink
{
private readonly string _databasePath;
private readonly bool _storeTimestampInUtc;
private readonly bool _rollOver;
private readonly SQLiteConnectionString _sqlLiteConnectionString;
private readonly string _tableName;
private static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
public SQLiteSink(
string sqlLiteDbPath,
string tableName,
bool storeTimestampInUtc,
uint batchSize = 100,
bool rollOver = true) : base(batchSize: (int)batchSize, maxBufferSize: 100_000)
{
_databasePath = sqlLiteDbPath;
_tableName = tableName;
_storeTimestampInUtc = storeTimestampInUtc;
_rollOver = rollOver;
InitializeDatabase();
}
public SQLiteSink(
SQLiteConnectionString sqlLiteConnectionString,
string tableName,
bool storeTimestampInUtc,
uint batchSize = 100,
bool rollOver = true) : base(batchSize: (int)batchSize, maxBufferSize: 100_000)
{
_sqlLiteConnectionString = sqlLiteConnectionString;
_tableName = tableName;
_storeTimestampInUtc = storeTimestampInUtc;
_rollOver = rollOver;
InitializeDatabase();
}
#region ILogEvent implementation
public void Emit(LogEvent logEvent)
{
PushEvent(logEvent);
}
#endregion
private void InitializeDatabase()
{
var conn = GetSqLiteAsyncConnection();
CreateSqlTable(conn);
}
private SQLiteAsyncConnection GetSqLiteAsyncConnection()
{
if (_databasePath != null)
{
var sqlConString = new SQLiteConnectionString(_databasePath, true);
return new SQLiteAsyncConnection(sqlConString);
}
else
{
return new SQLiteAsyncConnection(_sqlLiteConnectionString);
}
}
private void CreateSqlTable(SQLiteAsyncConnection sqlConnection)
{
var colDefs = "id INTEGER PRIMARY KEY AUTOINCREMENT,";
colDefs += "Timestamp TEXT,";
colDefs += "Level VARCHAR(10),";
colDefs += "Exception TEXT,";
colDefs += "RenderedMessage TEXT,";
colDefs += "Properties TEXT";
var sqlCreateText = $"CREATE TABLE IF NOT EXISTS {_tableName} ({colDefs})";
int result = sqlConnection.ExecuteAsync(sqlCreateText).GetAwaiter().GetResult();
}
private void TruncateLog(SQLiteAsyncConnection sqlConnection)
{
sqlConnection.ExecuteAsync($"DELETE FROM {_tableName}")
.ConfigureAwait(false);
}
protected override async Task<bool> WriteLogEventAsync(ICollection<LogEvent> logEventsBatch)
{
if ((logEventsBatch == null) || (logEventsBatch.Count == 0))
return true;
await semaphoreSlim.WaitAsync().ConfigureAwait(false);
try
{
var sqlConnection = GetSqLiteAsyncConnection();
try
{
await WriteToDatabaseAsync(logEventsBatch, sqlConnection).ConfigureAwait(false);
return true;
}
catch (SQLiteException e)
{
SelfLog.WriteLine(e.Message);
if (e.Result != SQLite3.Result.Full)
{
return false;
}
if (!_rollOver)
{
SelfLog.WriteLine("Discarding log excessive of max database");
return true;
}
var dbExtension = Path.GetExtension(_databasePath);
var newFilePath = Path.Combine(Path.GetDirectoryName(_databasePath) ?? "Logs",
$"{Path.GetFileNameWithoutExtension(_databasePath)}-{DateTime.Now:yyyyMMdd_hhmmss.ff}{dbExtension}");
File.Copy(_databasePath, newFilePath, true);
TruncateLog(sqlConnection);
await WriteToDatabaseAsync(logEventsBatch, sqlConnection).ConfigureAwait(false);
SelfLog.WriteLine($"Rolling database to {newFilePath}");
return true;
}
catch (Exception e)
{
SelfLog.WriteLine(e.Message);
return false;
}
}
finally
{
semaphoreSlim.Release();
}
}
private async Task WriteToDatabaseAsync(ICollection<LogEvent> logEventsBatch,
SQLiteAsyncConnection sqlConnection)
{
var sqlInsertText = "INSERT INTO {0} (Timestamp, Level, Exception, RenderedMessage, Properties)";
sqlInsertText += " VALUES (@timeStamp, @level, @exception, @renderedMessage, @properties)";
sqlInsertText = string.Format(sqlInsertText, _tableName);
foreach (var logEvent in logEventsBatch)
{
var logTimeStamp = _storeTimestampInUtc
? logEvent.Timestamp.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff")
: logEvent.Timestamp.ToString("yyyy-MM-ddTHH:mm:ss.fff");
var logLevel = logEvent.Level.ToString();
var exception = logEvent.Exception?.ToString() ?? string.Empty;
var message = logEvent.MessageTemplate.Text;
var properties = logEvent.Properties.Count > 0 ? logEvent.Properties.Json() : string.Empty;
await sqlConnection.ExecuteAsync(sqlInsertText, new object[]
{
logTimeStamp,
logLevel,
exception,
message,
properties
}).ConfigureAwait(false);
}
}
}
} | 36.019802 | 125 | 0.58425 | [
"Apache-2.0"
] | jaandk/serilog-sinks-sqlite-Net-PCL | src/Serilog.Sinks.SQLite/Sinks/SQLite/SQLiteSink.cs | 7,278 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace Lpp.Dns.DTO
{
/// <summary>
/// Theme
/// </summary>
[DataContract]
public class ThemeDTO
{
/// <summary>
/// Title
/// </summary>
[DataMember]
public string Title { get; set; }
/// <summary>
/// Terms
/// </summary>
[DataMember]
public string Terms { get; set; }
/// <summary>
/// Info
/// </summary>
[DataMember]
public string Info { get; set; }
/// <summary>
/// Resources
/// </summary>
[DataMember]
public string Resources { get; set; }
/// <summary>
/// Footer
/// </summary>
[DataMember]
public string Footer { get; set; }
/// <summary>
/// Logo image
/// </summary>
[DataMember]
public string LogoImage { get; set; }
/// <summary>
/// SystemUserConfirmationTitle
/// </summary>
[DataMember]
public string SystemUserConfirmationTitle { get; set; }
/// <summary>
/// SystemUserConfirmationContent
/// </summary>
[DataMember]
public string SystemUserConfirmationContent { get; set; }
/// <summary>
/// Contact Us Link
/// </summary>
[DataMember]
public string ContactUsHref { get; set; }
}
}
| 23.415385 | 65 | 0.5 | [
"Apache-2.0"
] | Missouri-BMI/popmednet | Lpp.Dns.DTO/Themes/ThemeDTO.cs | 1,524 | C# |
namespace GPS_Distance.ViewModels
{
using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using CommonServiceLocator;
using DistanceCalculator.Models;
using GPS_Distance.Events;
using GPS_Distance.Models;
using Prism.Events;
using static DistanceCalculator.Helpers.Helper;
using static GPS_Distance.Helpers.Helper;
//todo constrain the maximum size of the list box
//todo add scrollable to the list box control
public class EntryFormViewModel : ValidationBaseViewModel
{
/*
need to keep the Entry page from bring in the helper classes to reduce dependency
all processing for the results needs to be in the back end
*/
#region Fields
private ObservableCollection<Location> _endPointLocations = new ObservableCollection<Location>();
private string _startLatitude = string.Empty;
private string _startLongitude = string.Empty;
private string _endLatitude = string.Empty;
private string _endLongitude = string.Empty;
private readonly IEventAggregator _eventAggregator;
private Location _selectedItem = new Location();
private string _notification = string.Empty;
#endregion
#region Properties
public ObservableCollection<Location> EndPointsLocations
{
get => _endPointLocations;
set => SetProperty(ref _endPointLocations, value);
}
public Location SelectedItem
{
get => _selectedItem;
set => SetProperty(ref _selectedItem, value);
}
public string Notification
{
get => _notification;
set => SetProperty(ref _notification, value);
}
public string StartLatitude
{
get => _startLatitude;
set
{
if (SetProperty(ref _startLatitude, value))
ValidateProperty(value, (v) => TryParseLatitude(v, out _), "Not a valid latitude");
}
}
public string StartLongitude
{
get => _startLongitude;
set
{
if (SetProperty(ref _startLongitude, value))
ValidateProperty(value, (v) => TryParseLongitude(v, out _), "Not a valid longitude");
}
}
public string EndLatitude
{
get => _endLatitude;
set
{
if (SetProperty(ref _endLatitude, value))
ValidateProperty(value, (v) => TryParseLatitude(v, out _), "Not a valid latitude");
}
}
public string EndLongitude
{
get => _endLongitude;
set
{
if (SetProperty(ref _endLongitude, value))
ValidateProperty(value, (v) => TryParseLongitude(v, out _), "Not a valid longitude");
}
}
#endregion
#region Commands
public ICommand ClearStartValuesCommand { get; }
public ICommand ClearEndValuesCommand { get; }
public ICommand AddEndPointCommand { get; }
public ICommand ClearEndPositionsListCommand { get; }
public ICommand ResetFormCommand { get; }
public ICommand MeasureDistanceCommand { get; }
public ICommand ImportDataCommand { get; }
public ICommand ExportDataCommand { get; }
public ICommand RemoveEndPositionCommand { get; }
#endregion
#region Constructor
public EntryFormViewModel()
{
_eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
// Setup Command
ClearStartValuesCommand = new RelayCommand(ClearStartValues);
ClearEndValuesCommand = new RelayCommand(ClearEndValues);
AddEndPointCommand = new RelayCommand(AddEndPoint);
ClearEndPositionsListCommand = new RelayCommand(ClearEndPositionsList);
ResetFormCommand = new RelayCommand(ResetForm);
MeasureDistanceCommand = new RelayCommand(MeasureDistance);
ImportDataCommand = new RelayCommand(ImportData);
ExportDataCommand = new RelayCommand(ExportData);
RemoveEndPositionCommand = new RelayCommand(RemoveEndPosition);
}
#endregion
#region Methods
/*
Values are set to empty as the textbox has no Placeholder attribute
if a value is put in it must be cleared before entering data this
is counter intuitive
*/
//TODO add ability to remove endPoint from list
private void AddEndPoint()
{
if (!TryParseLatitude(EndLatitude, out var latitude)) return;
if (!TryParseLongitude(EndLongitude, out var longitude)) return;
EndPointsLocations.Add(new Location(latitude, longitude));
ClearEndValues();
}
private void RemoveEndPosition()
{
if (SelectedItem != null)
{
EndPointsLocations.Remove(SelectedItem);
}
}
private void MeasureDistance()
{
if (!TryParseLatitude(StartLatitude, out var latitude)) return;
if (!TryParseLongitude(StartLongitude, out var longitude)) return;
_eventAggregator.GetEvent<DistanceResultEvent>().Publish(
new DistanceResultEventArgs
{
InputDTO = new InputDTO
{
StartLocation = new Location(latitude, longitude),
EndLocations = EndPointsLocations
}
});
_eventAggregator.GetEvent<ResultTabEnablerEvent>().Publish(
new ResultTabEnablerEventArgs { Enable = true });
}
private void ImportData() // Errors handled during import.
{
var fileName = ImportFromJson(out var startPoint, out var endPoints);
if (fileName == string.Empty) Notification = "Import canceled by the user.";
else if (fileName == "?") Notification = "Import failed to complete!";
else if (startPoint is null) Notification = $"No End GPS Positions found in file '{fileName}', try another file.";
else
{
Notification = $"Imported {endPoints.Count} End GPS Positions from file '{fileName}'.";
StartLatitude = startPoint.Latitude.ToString(); // Updates screen.
StartLongitude = startPoint.Longitude.ToString();
foreach (var endPoint in endPoints)
{
EndLatitude = endPoint.Latitude.ToString(); // Updates screen.
EndLongitude = endPoint.Longitude.ToString();
AddEndPoint();
}
}
}
private void ExportData() // Errors handled during export.
{
if (EndPointsLocations.Count == 0) Notification = "No End GPS Positions to Export.";
else
{
var fileName = ExportToJson(StartLatitude, StartLongitude, EndPointsLocations);
Notification = fileName == string.Empty ? "Export canceled by the user."
: fileName == "?" ? "Export failed to complete!"
: $"Exported {EndPointsLocations.Count} End GPS Positions to file '{fileName}'.";
}
}
#endregion
#region FormResetters
private void ClearStartValues()
{
StartLatitude = string.Empty;
StartLongitude = string.Empty;
}
private void ClearEndValues()
{
EndLatitude = string.Empty;
EndLongitude = string.Empty;
}
private void ClearEndPositionsList()
{
EndPointsLocations.Clear();
}
private void ResetForm()
{
ClearStartValues();
ClearEndValues();
ClearEndPositionsList();
}
#endregion
}
}
| 35.329004 | 126 | 0.580076 | [
"MIT"
] | CopperBeardyTwitch/GPS | GPS_Distance/ViewModels/EntryFormViewModel.cs | 8,163 | C# |
using System;
using System.Globalization;
using Prism.Behaviors;
using Prism.Commands;
using Prism.Forms.Tests.Mocks.Behaviors;
using Xamarin.Forms;
using Xunit;
namespace Prism.Forms.Tests.Behaviors
{
public class EventToCommandBehaviorFixture
{
public EventToCommandBehaviorFixture()
{
Xamarin.Forms.Mocks.MockForms.Init();
}
private class ItemTappedEventArgsConverter : IValueConverter
{
private readonly bool _returnParameter;
public bool HasConverted { get; private set; }
public ItemTappedEventArgsConverter(bool returnParameter)
{
_returnParameter = returnParameter;
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
HasConverted = true;
return _returnParameter ? parameter : (value as ItemTappedEventArgs)?.Item;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
[Fact]
public void Command_OrderOfExecution()
{
const string commandParameter = "ItemProperty";
var executedCommand = false;
var converter = new ItemTappedEventArgsConverter(false);
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
EventArgsConverter = converter,
CommandParameter = commandParameter,
Command = new DelegateCommand<string>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal(commandParameter, o);
Assert.False(converter.HasConverted);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, commandParameter, 0));
Assert.True(executedCommand);
}
[Fact]
public void Command_Converter()
{
const string item = "ItemProperty";
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
EventArgsConverter = new ItemTappedEventArgsConverter(false),
Command = new DelegateCommand<string>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal(item, o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item, 0));
Assert.True(executedCommand);
}
[Fact]
public void Command_ConverterWithConverterParameter()
{
const string item = "ItemProperty";
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
EventArgsConverter = new ItemTappedEventArgsConverter(true),
EventArgsConverterParameter = item,
Command = new DelegateCommand<string>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal(item, o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0));
Assert.True(executedCommand);
}
[Fact]
public void Command_ExecuteWithParameter()
{
const string item = "ItemProperty";
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
CommandParameter = item,
Command = new DelegateCommand<string>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal(item, o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0));
Assert.True(executedCommand);
}
[Fact]
public void Command_EventArgsParameterPath()
{
const string item = "ItemProperty";
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
EventArgsParameterPath = "Item",
Command = new DelegateCommand<string>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal(item, o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item, 0));
Assert.True(executedCommand);
}
[Fact]
public void Command_EventArgsParameterPath_Nested()
{
dynamic item = new
{
AProperty = "Value"
};
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
EventArgsParameterPath = "Item.AProperty",
Command = new DelegateCommand<object>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal("Value", o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item));
Assert.True(executedCommand);
}
[Fact]
public void Command_EventArgsParameterPath_Nested_When_ChildIsNull()
{
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
EventArgsParameterPath = "Item.AProperty",
Command = new DelegateCommand<object>(o =>
{
executedCommand = true;
Assert.Null(o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0));
Assert.True(executedCommand);
}
[Fact]
public void Command_CanExecute()
{
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
Command = new DelegateCommand(() => Assert.True(false), () => false)
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
}
[Fact]
public void Command_CanExecuteWithParameterShouldExecute()
{
var shouldExeute = bool.TrueString;
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
CommandParameter = shouldExeute,
Command = new DelegateCommand<string>(o =>
{
executedCommand = true;
Assert.True(true);
}, o => o.Equals(bool.TrueString))
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
Assert.True(executedCommand);
}
[Fact]
public void Command_CanExecuteWithParameterShouldNotExeute()
{
var shouldExeute = bool.FalseString;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
CommandParameter = shouldExeute,
Command = new DelegateCommand<string>(o => Assert.True(false), o => o.Equals(bool.TrueString))
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
}
[Fact]
public void Command_Execute()
{
var executedCommand = false;
var behavior = new EventToCommandBehaviorMock
{
EventName = "ItemTapped",
Command = new DelegateCommand(() =>
{
executedCommand = true;
Assert.True(true);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
Assert.True(executedCommand);
}
[Fact]
public void EventName_InvalidEventShouldThrow()
{
var behavior = new EventToCommandBehavior
{
EventName = "OnItemTapped"
};
var listView = new ListView();
Assert.Throws<ArgumentException>(() => listView.Behaviors.Add(behavior));
}
[Fact]
public void EventName_Valid()
{
var behavior = new EventToCommandBehavior
{
EventName = "ItemTapped"
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
}
}
}
| 34.486301 | 110 | 0.522443 | [
"MIT"
] | Adam--/Prism | tests/Forms/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs | 10,072 | C# |
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.Aws.WafV2.Inputs
{
public sealed class WebAclRuleStatementAndStatementStatementOrStatementStatementAndStatementStatementSqliMatchStatementTextTransformationGetArgs : Pulumi.ResourceArgs
{
/// <summary>
/// Relative processing order for multiple transformations that are defined for a rule statement. AWS WAF processes all transformations, from lowest priority to highest, before inspecting the transformed content.
/// </summary>
[Input("priority", required: true)]
public Input<int> Priority { get; set; } = null!;
/// <summary>
/// Transformation to apply, please refer to the Text Transformation [documentation](https://docs.aws.amazon.com/waf/latest/APIReference/API_TextTransformation.html) for more details.
/// </summary>
[Input("type", required: true)]
public Input<string> Type { get; set; } = null!;
public WebAclRuleStatementAndStatementStatementOrStatementStatementAndStatementStatementSqliMatchStatementTextTransformationGetArgs()
{
}
}
}
| 43.84375 | 220 | 0.726301 | [
"ECL-2.0",
"Apache-2.0"
] | chivandikwa/pulumi-aws | sdk/dotnet/WafV2/Inputs/WebAclRuleStatementAndStatementStatementOrStatementStatementAndStatementStatementSqliMatchStatementTextTransformationGetArgs.cs | 1,403 | C# |
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BolaoNet.Domain.Entities.DadosBasicos
{
public class PagamentoTipo : Base.AuditModel
{
#region Properties
[Key, Column(Order = 0)]
public int TipoPagamento { get; set; }
public string Descricao { get; set; }
#endregion
}
}
| 21.913043 | 51 | 0.708333 | [
"MIT"
] | Thoris/BolaoNet | BolaoNet.Domain.Entities/DadosBasicos/PagamentoTipo.cs | 506 | 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>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("6. Strong number")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("6. Strong number")]
[assembly: System.Reflection.AssemblyTitleAttribute("6. Strong number")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
| 41.583333 | 80 | 0.644289 | [
"Apache-2.0"
] | Vladimir-Dodnikov/C-Fundamentals-May-2019 | 02. CSharp-Fundamentals-Intro-and-Basic-Syntax-Exercises/6. Strong number/obj/Debug/netcoreapp2.2/6. Strong number.AssemblyInfo.cs | 998 | C# |
using System.Collections.Generic;
using Viren.Core.Enums;
namespace Viren.Execution.Dtos.CalculationDtos.Batch
{
public class BatchCalculationInputItemDto
{
public BatchCalculationInputItemDto()
{
Project = string.Empty;
Model = string.Empty;
EntryPoint = string.Empty;
CalculationInputs = new List<CalculationInputDto>();
}
public string Project { get; set; }
public string Model { get; set; }
public int Version { get; set; }
public int? Revision { get; set; }
public string EntryPoint { get; set; }
public bool? Debug { get; set; }
public ResultType? ResultType { get; set; }
public IList<CalculationInputDto> CalculationInputs { get; set; }
}
} | 25.21875 | 73 | 0.610905 | [
"MIT"
] | tealpartners/viren.net | src/Viren.Execution/Dtos/CalculationDtos/Batch/BatchCalculationInputItemDto.cs | 809 | C# |
using System;
using UnitTest.TestBuilder.Core.Abstracts;
namespace UnitTest.TestBuilder.Core.Tests.Implementation
{
class ObjectBuilder : IObjectBuilder
{
public bool CanCreate(Type type)
{
return type.IsInterface && type != typeof(ITestServiceC);
}
public object Create(Type type)
{
if (!CanCreate(type)) return null;
if(type == typeof(ITestServiceA))
{
return new TestServiceA();
}
if (type == typeof(ITestServiceB))
{
return new TestServiceB();
}
return null;
}
}
}
| 21.774194 | 69 | 0.525926 | [
"MIT"
] | Jacky-Mo/UnitTest.TestBuilder.Core | UnitTest.TestBuilder.Core.Tests/Implementation/ObjectBuilder.cs | 677 | C# |
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace KdSoft.Lmdb.Interop
{
/// <summary>
/// Helpers for native interop.
/// </summary>
[CLSCompliant(false)]
public static unsafe class DbLibUtil
{
/// <summary>
/// calculates length of null-terminated byte string
/// </summary>
public static int ByteStrLen(byte* str) {
byte* tmp = str;
int len = 0;
if (tmp != null) {
while (*tmp != 0)
tmp++;
len = (int)(tmp - str);
}
return len;
}
/// <summary>
/// Copies null-terminated byte string into byte buffer.
/// Will resize buffer, if necessary, does nothing if ptr == null.
/// </summary>
/// <param name="bytePtr">Null terminated bye string to copy.</param>
/// <param name="buffer">Byte buffer to copy to.</param>
/// <returns>New size of buffer.</returns>
public static int PtrToBuffer(byte* bytePtr, ref byte[] buffer) {
int size = ByteStrLen(bytePtr);
if (size > (buffer == null ? 0 : buffer.Length))
Array.Resize<byte>(ref buffer, size);
if (bytePtr != null)
Marshal.Copy((IntPtr)bytePtr, buffer, 0, size);
return size;
}
/// <summary>
/// Creates null-terminated UTF8 string in buffer. Will re-allocate buffer, if necessary.
/// If str == null then the buffer will be ignored.
/// </summary>
/// <param name="str">String to convert to UTF-8 encoding.</param>
/// <param name="utf8">Configured UTF-8 encoder.</param>
/// <param name="buffer"></param>
/// <returns>Byte length of UTF-8 encoded string, including null-terminator</returns>
public static int StrToUtf8(string str, UTF8Encoding utf8, ref byte[] buffer) {
if (str == null)
return 0;
int count = utf8.GetMaxByteCount(str.Length);
// increment to next 32 bit boundary, that is, by at least one and at most 4 bytes
count = ((count >> 2) + 1) << 2;
if (count > (buffer == null ? 0 : buffer.Length))
Array.Resize<byte>(ref buffer, count);
count = utf8.GetBytes(str, 0, str.Length, buffer, 0);
// add null terminator - we have space for at least one more byte
#pragma warning disable S2259 // Null pointers should not be dereferenced
buffer[count] = 0;
#pragma warning restore S2259 // Null pointers should not be dereferenced
return count + 1;
}
/// <summary>
/// Creates null-terminated UTF8 string in buffer. Will re-allocate buffer, if necessary.
/// If str == null then the buffer will be ignored.
/// </summary>
/// <param name="str">String to convert to UTF-8 encoding.</param>
/// <param name="buffer"></param>
/// <returns>Byte length of UTF-8 encoded string, including null-terminator</returns>
public static int StrToUtf8(string str, ref byte[] buffer) {
return StrToUtf8(str, (UTF8Encoding)Encoding.UTF8, ref buffer);
}
/// <summary>
/// Converts null-terminated UTF-8 byte string to .NET string .
/// Will re-allocate buffer if necessary, buffer can be null.
/// </summary>
/// <param name="utf8">Pointer to a null-terminated UTF-8 string.</param>
/// <param name="buffer">Byte buffer to use for the decoding process.</param>
/// <returns>.NET string.</returns>
public static string Utf8PtrToString(byte* utf8, ref byte[] buffer) {
int count = PtrToBuffer(utf8, ref buffer);
if (count > 0)
return Encoding.UTF8.GetString(buffer, 0, count);
else
return string.Empty;
}
/// <summary>
/// Converts null-terminated UTF-8 byte string to .NET string .
/// </summary>
/// <param name="utf8">Pointer to a null-terminated UTF-8 string.</param>
/// <returns>.NET string.</returns>
public static string Utf8PtrToString(byte* utf8) {
byte[] buffer = null;
return Utf8PtrToString(utf8, ref buffer);
}
public static DateTime UnixToDateTime(IntPtr unixTime) {
return new System.DateTime(1970, 1, 1).AddSeconds((long)unixTime);
}
public static IntPtr DateTimeToUnix(DateTime dt) {
TimeSpan delta = dt - new System.DateTime(1970, 1, 1);
return new IntPtr((long)delta.TotalSeconds);
}
/// <summary>
/// Writes UInt32 value to byte array at given index, in big-endian byte order.
/// </summary>
/// <param name="num">UInt32 value to write.</param>
/// <param name="bytes">Byte buffer to write the value into.</param>
/// <param name="index">Index in byte buffer to start writing at.</param>
public static void UInt32ToBEBytes(UInt32 num, byte[] bytes, int index) {
unchecked {
bytes[index++] = (byte)(num >> 24);
bytes[index++] = (byte)((num & 0x00FF0000) >> 16);
bytes[index++] = (byte)((num & 0x0000FF00) >> 8);
bytes[index] = (byte)(num & 0x000000FF);
}
}
/// <summary>
/// Reads UInt32 value from byte array at given index, in big-endian byte order.
/// </summary>
/// <param name="bytes">Byte buffer to read from.</param>
/// <param name="index">Index in byte buffer to start reading from.</param>
/// <returns>UInt32 value read from byte buffer.</returns>
public static UInt32 BEBytesToUInt32(byte[] bytes, int index) {
UInt32 result;
unchecked {
result = (UInt32)bytes[index++] << 24;
result |= (UInt32)bytes[index++] << 16;
result |= (UInt32)bytes[index++] << 8;
}
result |= bytes[index];
return result;
}
}
}
| 42.475862 | 97 | 0.55772 | [
"MIT"
] | kwaclaw/KdSoft.Lmdb | Lmdb/interop/DbLibUtil.cs | 6,161 | C# |
namespace SharpArch.Web.Http.Castle
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.Dependencies;
using global::Castle.Windsor;
using SharpArch.Domain;
/// <summary>
/// Resolves HTTP dependencies using Castle Windsor.
/// </summary>
public class WindsorDependencyResolver : IDependencyResolver
{
private readonly IWindsorContainer container;
/// <summary>
/// Initializes a new instance of the <see cref="WindsorDependencyResolver" /> class.
/// </summary>
/// <param name="container">The container.</param>
public WindsorDependencyResolver(IWindsorContainer container)
{
Check.Require(container != null);
this.container = container;
}
/// <summary>
/// Begins the scope.
/// </summary>
/// <returns>A scope.</returns>
public IDependencyScope BeginScope()
{
return this;
}
/// <summary>
/// Gets the service for the specified type.
/// </summary>
/// <param name="serviceType">Type of the service.</param>
/// <returns>A service.</returns>
public object GetService(Type serviceType)
{
if (!this.container.Kernel.HasComponent(serviceType))
{
return null;
}
return this.container.Resolve(serviceType);
}
/// <summary>
/// Gets all services for the specified type.
/// </summary>
/// <param name="serviceType">Type of the service.</param>
/// <returns>A collection of services.</returns>
public IEnumerable<object> GetServices(Type serviceType)
{
if (!this.container.Kernel.HasComponent(serviceType))
{
return new object[0];
}
return this.container.ResolveAll(serviceType).Cast<object>();
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting
/// unmanaged resources.
/// </summary>
public void Dispose()
{
}
}
} | 29.706667 | 95 | 0.566427 | [
"BSD-3-Clause"
] | milesibastos/Sharp-Architecture | Solutions/SharpArch.Web.Http/Castle/WindsorDependencyResolver.cs | 2,228 | C# |
using _11.Polynomials;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Test_10.Factorial
{
/// <summary>
///This is a test class for SubtractPolynomials and is intended
///to contain all SubtractPolynomials Unit Tests
///</summary>
[TestClass()]
public class SubtractPolynomials
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
/// <summary>
///A test for SubtractPolynomials
///</summary>
[TestMethod()]
public void TestOrdinarySubtract()
{
int[] p1 = {3,5,0,9}; // TODO: Initialize to an appropriate value
int[] p2 = {5,6}; // TODO: Initialize to an appropriate value
int[] expected = {3,5,-5,3}; // TODO: Initialize to an appropriate value
int[] actual;
actual = Polynomial.SubtractPolynomials(p1, p2);
bool isEqual = true;
for (int i = 0; i < expected.Length; i++)
{
if (actual[i]!=expected[i])
{
isEqual = false; break;
}
}
Assert.IsTrue(isEqual);
}
}
}
| 27.744444 | 84 | 0.52503 | [
"MIT"
] | GeorgiMateev/telerik-academy | 09.Methods/Test-10.Factorial/SubtractPolynomials.cs | 2,499 | C# |
using System;
namespace QuickstreamAPI.Exceptions
{
public class QuickstreamAPIException : Exception
{
public QuickstreamAPIException(string message) : base(message) {}
public QuickstreamAPIException() {}
}
} | 23.7 | 73 | 0.71308 | [
"MIT"
] | seanobjames/quickstreamapi-dotnet | src/QuickstreamAPI/Exceptions/QuickstreamAPIException.cs | 237 | C# |
// Copyright (c) 2020-2021 Vladimir Popov [email protected] https://github.com/ZorPastaman/Random-Generators
using System;
using UnityEditor;
using UnityEngine;
using Zor.RandomGenerators.DiscreteDistributions;
using Object = UnityEngine.Object;
namespace Zor.RandomGenerators.PropertyDrawerAttributes
{
[CustomPropertyDrawer(typeof(RequireDiscreteGenerator))]
public sealed class RequireDiscreteRandomGeneratorEditor : PropertyDrawer
{
private const string GeneratorPropertyName = "m_DiscreteGeneratorProvider";
private const string SharedPropertyName = "m_Shared";
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
if (property.type != nameof(DiscreteGeneratorProviderReference))
{
Debug.LogError($"Attribute {nameof(RequireDiscreteGenerator)} is set on a wrong type: {property.type}. Expected {nameof(DiscreteGeneratorProviderReference)}.");
return base.GetPropertyHeight(property, label);
}
float height = EditorGUI.GetPropertyHeight(property, label, false);
if (property.isExpanded)
{
SerializedProperty generatorProperty = property.FindPropertyRelative(GeneratorPropertyName);
SerializedProperty sharedProperty = property.FindPropertyRelative(SharedPropertyName);
height += EditorGUI.GetPropertyHeight(generatorProperty) + EditorGUI.GetPropertyHeight(sharedProperty)
+ 2f * EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (property.type != nameof(DiscreteGeneratorProviderReference))
{
Debug.LogError($"Attribute {nameof(RequireDiscreteGenerator)} is set on a wrong type: {property.type}. Expected {nameof(DiscreteGeneratorProviderReference)}.");
return;
}
position.height = EditorGUI.GetPropertyHeight(property, false);
EditorGUI.PropertyField(position, property, label, false);
if (!property.isExpanded)
{
return;
}
++EditorGUI.indentLevel;
SerializedProperty generatorProperty = property.FindPropertyRelative(GeneratorPropertyName);
position.y += position.height + EditorGUIUtility.standardVerticalSpacing;
position.height = EditorGUI.GetPropertyHeight(generatorProperty);
if (!CheckType(generatorProperty))
{
generatorProperty.objectReferenceValue = null;
}
EditorGUI.PropertyField(position, generatorProperty);
SerializedProperty sharedProperty = property.FindPropertyRelative(SharedPropertyName);
position.y += position.height + EditorGUIUtility.standardVerticalSpacing;
position.height = EditorGUI.GetPropertyHeight(sharedProperty);
EditorGUI.PropertyField(position, sharedProperty);
--EditorGUI.indentLevel;
}
private bool CheckType(SerializedProperty property)
{
Object objectReference = property.objectReferenceValue;
if (objectReference == null)
{
return false;
}
Type argumentType = GetGenericArgumentType(objectReference.GetType());
if (argumentType == null)
{
return false;
}
return ((RequireDiscreteGenerator)attribute).valueType == argumentType;
}
private static Type GetGenericArgumentType(Type type)
{
while (type.BaseType != null)
{
type = type.BaseType;
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(DiscreteGeneratorProvider<>))
{
return type.GetGenericArguments()[0];
}
}
return null;
}
}
}
| 32.40566 | 164 | 0.765066 | [
"MIT"
] | ZorPastaman/Random-Generators | Editor/CustomEditors/RequireDiscreteRandomGeneratorEditor.cs | 3,437 | C# |
using System;
using System.CodeDom;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk.Metadata;
namespace Unchase.Dynamics365.Customization
{
/// <summary>
/// Used by the ICodeGenerationService to retrieve types for the CodeDOM objects being created.
/// </summary>
public interface ITypeMappingService
{
/// <summary>
/// Retrieves a CodeTypeReference for the entity set being generated.
/// </summary>
Task<CodeTypeReference> GetTypeForEntityAsync(EntityMetadata entityMetadata, IServiceProvider services);
/// <summary>
/// Retrieves a CodeTypeReference for the attribute being generated.
/// </summary>
Task<CodeTypeReference> GetTypeForAttributeTypeAsync(EntityMetadata entityMetadata, AttributeMetadata attributeMetadata, IServiceProvider services);
/// <summary>
/// Retrieves a CodeTypeReference for the 1:N, N:N, or N:1 relationship being generated.
/// </summary>
Task<CodeTypeReference> GetTypeForRelationshipAsync(RelationshipMetadataBase relationshipMetadata, EntityMetadata otherEntityMetadata, IServiceProvider services);
/// <summary>
/// Retrieves a CodeTypeReference for the Request Field being generated.
/// </summary>
Task<CodeTypeReference> GetTypeForRequestFieldAsync(SdkMessageRequestField requestField, IServiceProvider services);
/// <summary>
/// Retrieves a CodeTypeReference for the Response Field being generated.
/// </summary>
Task<CodeTypeReference> GetTypeForResponseFieldAsync(SdkMessageResponseField responseField, IServiceProvider services);
}
}
| 40.333333 | 170 | 0.768595 | [
"Apache-2.0"
] | unchase/Unchase.Dynamics365.Connectedservice | src/Unchase.Dynamics365.Customization/ITypeMappingService.cs | 1,575 | C# |
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sledge.Shell.Input
{
/// <summary>
/// Performs polling on the current keyboard state.
/// </summary>
/// Most of this is adapted from:
/// http://www.switchonthecode.com/tutorials/winforms-accessing-mouse-and-keyboard-state
public static class KeyboardState
{
private static readonly Dictionary<string, string> KeyStringReplacements;
static KeyboardState()
{
KeyStringReplacements = new Dictionary<string, string>
{
{"Add", "+"},
{"Oemplus", "+"},
{"Subtract", "-"},
{"OemMinus", "-"},
{"Separator", "-"},
{"Decimal", "."},
{"OemPeriod", "."},
{"Divide", "/"},
{"OemQuestion", "/"},
{"Multiply", "*"},
{"OemBackslash", "\\"},
{"Oem5", "\\"},
{"OemCloseBrackets", "]"},
{"Oem6", "]"},
{"OemOpenBrackets", "["},
{"OemPipe", "|"},
{"OemQuotes", "'"},
{"Oem7", "'"},
{"OemSemicolon", ";"},
{"Oem1", ";"},
{"Oemcomma", ","},
{"Oemtilde", "`"},
{"Back", "Backspace"},
{"Return", "Enter"},
{"Next", "PageDown"},
{"Prior", "PageUp"},
{"D1", "1"},
{"D2", "2"},
{"D3", "3"},
{"D4", "4"},
{"D5", "5"},
{"D6", "6"},
{"D7", "7"},
{"D8", "8"},
{"D9", "9"},
{"D0", "0"},
{"Delete", "Del"}
};
}
public static bool Ctrl => IsModifierKeyDown(Keys.Control);
public static bool Shift => IsModifierKeyDown(Keys.Shift);
public static bool Alt => IsModifierKeyDown(Keys.Alt);
public static bool CapsLocked => IsKeyToggled(Keys.CapsLock);
public static bool ScrollLocked => IsKeyToggled(Keys.Scroll);
public static bool NumLocked => IsKeyToggled(Keys.NumLock);
private static bool IsModifierKeyDown(Keys k)
{
return (Control.ModifierKeys & k) == k;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern short GetKeyState(int keyCode);
public static bool IsKeyDown(Keys key)
{
// Key is down if the high bit is 1
return (GetKeyState((int)key) & 0x8000) == 0x8000;
}
public static bool IsAnyKeyDown(params Keys[] keys)
{
return keys.Any(IsKeyDown);
}
private static bool IsKeyToggled(Keys key)
{
// Key is toggled if the low bit is 1
return (GetKeyState((int) key) & 0x0001) == 0x0001;
}
public static string KeysToString(Keys key)
{
// KeysConverter seems to ignore the invariant culture, manually replicate the results
var mods = key & Keys.Modifiers;
var keycode = key & Keys.KeyCode;
if (keycode == Keys.None) return "";
var str = keycode.ToString();
if (KeyStringReplacements.ContainsKey(str)) str = KeyStringReplacements[str];
// Modifier order: Ctrl+Alt+Shift+Key
return (mods.HasFlag(Keys.Control) ? "Ctrl+" : "")
+ (mods.HasFlag(Keys.Alt) ? "Alt+" : "")
+ (mods.HasFlag(Keys.Shift) ? "Shift+" : "")
+ str;
}
}
}
| 43.891892 | 98 | 0.363916 | [
"BSD-3-Clause"
] | LogicAndTrick/sledge | Sledge.Shell/Input/KeyboardState.cs | 4,874 | C# |
// <copyright file="ParserExtensions.cs" company="Shkyrockett" >
// Copyright © 2008 - 2020 Shkyrockett. All rights reserved.
// </copyright>
// <author id="shkyrockett">Shkyrockett</author>
// <license>
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </license>
// <summary></summary>
// <remarks></remarks>
using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace Engine
{
/// <summary>
/// Extension Methods for Parsing.
/// </summary>
public static class ParserExtensions
{
/// <summary>
/// Parse the <see cref="bool"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="bool"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool? ParseBool(this string text) => bool.TryParse(text, out var value) ? value : (bool?)null;
/// <summary>
/// Parse the <see cref="char"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="char"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static char? ParseChar(this string text) => char.TryParse(text, out var value) ? value : (char?)null;
/// <summary>
/// Parse the <see cref="sbyte"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="sbyte"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static sbyte? ParseSByte(this string text) => ParseSByte(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="sbyte"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="sbyte"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static sbyte? ParseSByte(this string text, IFormatProvider formatProvider) => ParseSByte(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="sbyte"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="sbyte"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static sbyte? ParseSByte(this string text, NumberStyles styles, IFormatProvider formatProvider) => sbyte.TryParse(text, styles, formatProvider, out var value) ? value : (sbyte?)null;
/// <summary>
/// Parse the <see cref="byte"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="byte"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte? ParseByte(this string text) => ParseByte(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="byte"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="byte"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte? ParseByte(this string text, IFormatProvider formatProvider) => ParseByte(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="byte"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="byte"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte? ParseByte(this string text, NumberStyles styles, IFormatProvider formatProvider) => byte.TryParse(text, styles, formatProvider, out var value) ? value : (byte?)null;
/// <summary>
/// Parse the <see cref="ushort"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="ushort"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ushort? ParseUShort(this string text) => ParseUShort(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="ushort"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="ushort"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ushort? ParseUShort(this string text, IFormatProvider formatProvider) => ParseUShort(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="ushort"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="ushort"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ushort? ParseUShort(this string text, NumberStyles styles, IFormatProvider formatProvider) => ushort.TryParse(text, styles, formatProvider, out var value) ? value : (ushort?)null;
/// <summary>
/// Parse the <see cref="short"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="short"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static short? ParseShort(this string text) => ParseShort(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="short"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="short"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static short? ParseShort(this string text, IFormatProvider formatProvider) => ParseShort(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="short"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="short"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static short? ParseShort(this string text, NumberStyles styles, IFormatProvider formatProvider) => short.TryParse(text, styles, formatProvider, out var value) ? value : (short?)null;
/// <summary>
/// Parse the <see cref="uint"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="uint"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint? ParseUInt(this string text) => ParseUInt(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="uint"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="uint"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint? ParseUInt(this string text, IFormatProvider formatProvider) => ParseUInt(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="uint"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="uint"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint? ParseUInt(this string text, NumberStyles styles, IFormatProvider formatProvider) => uint.TryParse(text, styles, formatProvider, out var value) ? value : (uint?)null;
/// <summary>
/// Parse the <see cref="int"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="int"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int? ParseInt(this string text) => ParseInt(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="int"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="int"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int? ParseInt(this string text, IFormatProvider formatProvider) => ParseInt(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="int"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="int"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int? ParseInt(this string text, NumberStyles styles, IFormatProvider formatProvider) => int.TryParse(text, styles, formatProvider, out var value) ? value : (int?)null;
/// <summary>
/// Parse the <see cref="ulong"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="ulong"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong? ParseULong(this string text) => ParseULong(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="ulong"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="ulong"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong? ParseULong(this string text, IFormatProvider formatProvider) => ParseULong(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="ulong"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="ulong"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong? ParseULong(this string text, NumberStyles styles, IFormatProvider formatProvider) => ulong.TryParse(text, styles, formatProvider, out var value) ? value : (ulong?)null;
/// <summary>
/// Parse the <see cref="long"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="long"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long? ParseLong(this string text) => ParseLong(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="long"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="long"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long? ParseLong(this string text, IFormatProvider formatProvider) => ParseLong(text, NumberStyles.Integer, formatProvider);
/// <summary>
/// Parse the <see cref="long"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="long"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long? ParseLong(this string text, NumberStyles styles, IFormatProvider formatProvider) => long.TryParse(text, styles, formatProvider, out var value) ? value : (long?)null;
/// <summary>
/// Parse the <see cref="float"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="float"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float? ParseFloat(this string text) => ParseFloat(text, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="float"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="float"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float? ParseFloat(this string text, IFormatProvider formatProvider) => ParseFloat(text, NumberStyles.Float | NumberStyles.AllowThousands, formatProvider);
/// <summary>
/// Parse the <see cref="float"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="float"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float? ParseFloat(this string text, NumberStyles styles, IFormatProvider formatProvider) => float.TryParse(text, styles, formatProvider, out var value) ? value : (float?)null;
/// <summary>
/// Parse the <see cref="double"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="double"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double? ParseDouble(this string text) => ParseDouble(text, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="double"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="double"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double? ParseDouble(this string text, IFormatProvider formatProvider) => ParseDouble(text, NumberStyles.Float | NumberStyles.AllowThousands, formatProvider);
/// <summary>
/// Parse the <see cref="double"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider">The provider.</param>
/// <returns>The <see cref="double"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double? ParseDouble(this string text, NumberStyles styles, IFormatProvider formatProvider) => double.TryParse(text, styles, formatProvider, out var value) ? value : (double?)null;
/// <summary>
/// Parse the <see cref="decimal"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The <see cref="decimal"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static decimal? ParseDecimal(this string text) => ParseDecimal(text, NumberStyles.Number, CultureInfo.InvariantCulture);
/// <summary>
/// Parse the <see cref="decimal"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="formatProvider"></param>
/// <returns>The <see cref="decimal"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static decimal? ParseDecimal(this string text, IFormatProvider formatProvider) => ParseDecimal(text, NumberStyles.Number, formatProvider);
/// <summary>
/// Parse the <see cref="decimal"/>.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="styles"></param>
/// <param name="formatProvider">The provider.</param>
/// <returns>The <see cref="decimal"/>.</returns>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static decimal? ParseDecimal(this string text, NumberStyles styles, IFormatProvider formatProvider) => decimal.TryParse(text, styles, formatProvider, out var value) ? value : (decimal?)null;
}
}
| 47.596774 | 205 | 0.615554 | [
"MIT"
] | Shkyrockett/engine | Engine.Base/Framework/ParserExtensions.cs | 17,709 | C# |
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using EnsureThat;
using MediatR;
namespace Microsoft.Health.Fhir.Core.Messages.Search
{
public class SearchParametersHashUpdated : INotification
{
public SearchParametersHashUpdated(Dictionary<string, string> updatedHashMap)
{
EnsureArg.IsNotNull(updatedHashMap, nameof(updatedHashMap));
UpdatedHashMap = updatedHashMap;
}
public Dictionary<string, string> UpdatedHashMap { get; }
}
}
| 35.416667 | 101 | 0.549412 | [
"MIT"
] | 10thmagnitude/fhir-server | src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersHashUpdated.cs | 852 | C# |
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2015 Riley Labrecque
// Please see the included LICENSE.txt for additional information.
// This file is automatically generated.
// Changes to this file will be reverted when you update Steamworks.NET
using System;
using System.Runtime.InteropServices;
namespace Steamworks {
internal static class NativeMethods {
internal const string NativeLibraryName = "CSteamworks";
#region steam_api.h
[DllImport("CSteamworks", EntryPoint = "Shutdown", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_Shutdown();
[DllImport("CSteamworks", EntryPoint = "IsSteamRunning", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamAPI_IsSteamRunning();
[DllImport("CSteamworks", EntryPoint = "RestartAppIfNecessary", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamAPI_RestartAppIfNecessary(AppId_t unOwnAppID);
[DllImport("CSteamworks", EntryPoint = "WriteMiniDump", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_WriteMiniDump(uint uStructuredExceptionCode, IntPtr pvExceptionInfo, uint uBuildID);
[DllImport("CSteamworks", EntryPoint = "SetMiniDumpComment", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_SetMiniDumpComment(InteropHelp.UTF8StringHandle pchMsg);
[DllImport("CSteamworks", EntryPoint = "SteamClient_", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamClient();
[DllImport("CSteamworks", EntryPoint = "InitSafe", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamAPI_InitSafe();
#if DISABLED
// This depends on how CSteamworks was compiled. By default it's compiled with VERSION_SAFE_STEAM_API_INTERFACES.
[DllImport("CSteamworks", EntryPoint = "Init", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamAPI_Init();
#endif
// Steamworks.NET handles registering and running callbacks itself, these are the passthroughs to Steams implementation. These shouldn't ever be needed.
[DllImport("CSteamworks", EntryPoint = "RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_RunCallbacks();
[DllImport("CSteamworks", EntryPoint = "RegisterCallback", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_RegisterCallback(IntPtr pCallback, int iCallback);
[DllImport("CSteamworks", EntryPoint = "UnregisterCallback", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_UnregisterCallback(IntPtr pCallback);
[DllImport("CSteamworks", EntryPoint = "RegisterCallResult", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_RegisterCallResult(IntPtr pCallback, ulong hAPICall);
[DllImport("CSteamworks", EntryPoint = "UnregisterCallResult", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_UnregisterCallResult(IntPtr pCallback, ulong hAPICall);
[DllImport("CSteamworks", EntryPoint = "Steam_RunCallbacks_", CallingConvention = CallingConvention.Cdecl)]
public static extern void Steam_RunCallbacks(HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.I1)] bool bGameServerCallbacks);
[DllImport("CSteamworks", EntryPoint = "Steam_RegisterInterfaceFuncs_", CallingConvention = CallingConvention.Cdecl)]
public static extern void Steam_RegisterInterfaceFuncs(IntPtr hModule);
[DllImport("CSteamworks", EntryPoint = "Steam_GetHSteamUserCurrent_", CallingConvention = CallingConvention.Cdecl)]
public static extern int Steam_GetHSteamUserCurrent();
[DllImport("CSteamworks", EntryPoint = "GetSteamInstallPath", CallingConvention = CallingConvention.Cdecl)]
public static extern int SteamAPI_GetSteamInstallPath();
[DllImport("CSteamworks", EntryPoint = "GetHSteamPipe_", CallingConvention = CallingConvention.Cdecl)]
public static extern int SteamAPI_GetHSteamPipe();
[DllImport("CSteamworks", EntryPoint = "SetTryCatchCallbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_SetTryCatchCallbacks([MarshalAs(UnmanagedType.I1)] bool bTryCatchCallbacks);
[DllImport("CSteamworks", EntryPoint = "GetHSteamUser_", CallingConvention = CallingConvention.Cdecl)]
public static extern int SteamAPI_GetHSteamUser();
[DllImport("CSteamworks", EntryPoint = "UseBreakpadCrashHandler", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_UseBreakpadCrashHandler(InteropHelp.UTF8StringHandle pchVersion, InteropHelp.UTF8StringHandle pchDate, InteropHelp.UTF8StringHandle pchTime, [MarshalAs(UnmanagedType.I1)] bool bFullMemoryDumps, IntPtr pvContext, IntPtr m_pfnPreMinidumpCallback);
// SteamContext Accessors:
[DllImport("CSteamworks", EntryPoint = "SteamUser", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamUser();
[DllImport("CSteamworks", EntryPoint = "SteamFriends", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamFriends();
[DllImport("CSteamworks", EntryPoint = "SteamUtils", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamUtils();
[DllImport("CSteamworks", EntryPoint = "SteamMatchmaking", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamMatchmaking();
[DllImport("CSteamworks", EntryPoint = "SteamUserStats", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamUserStats();
[DllImport("CSteamworks", EntryPoint = "SteamApps", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamApps();
[DllImport("CSteamworks", EntryPoint = "SteamNetworking", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamNetworking();
[DllImport("CSteamworks", EntryPoint = "SteamMatchmakingServers", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamMatchmakingServers();
[DllImport("CSteamworks", EntryPoint = "SteamRemoteStorage", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamRemoteStorage();
[DllImport("CSteamworks", EntryPoint = "SteamScreenshots", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamScreenshots();
[DllImport("CSteamworks", EntryPoint = "SteamHTTP", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamHTTP();
[DllImport("CSteamworks", EntryPoint = "SteamUnifiedMessages", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamUnifiedMessages();
[DllImport("CSteamworks", EntryPoint = "SteamController", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamController();
[DllImport("CSteamworks", EntryPoint = "SteamUGC", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamUGC();
[DllImport("CSteamworks", EntryPoint = "SteamAppList", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamAppList();
[DllImport("CSteamworks", EntryPoint = "SteamMusic", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamMusic();
[DllImport("CSteamworks", EntryPoint = "SteamMusicRemote", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamMusicRemote();
#endregion
#region steam_gameserver.h
[DllImport("CSteamworks", EntryPoint = "GameServer_InitSafe", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamGameServer_InitSafe(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, InteropHelp.UTF8StringHandle pchVersionString);
#if DISABLED
// This depends on how CSteamworks was compiled. By default it's compiled with VERSION_SAFE_STEAM_API_INTERFACES.
[DllImport("CSteamworks", EntryPoint = "GameServer_Init", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamGameServer_Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, InteropHelp.UTF8StringHandle pchVersionString);
#endif
[DllImport("CSteamworks", EntryPoint = "GameServer_Shutdown", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamGameServer_Shutdown();
[DllImport("CSteamworks", EntryPoint = "GameServer_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamGameServer_RunCallbacks();
[DllImport("CSteamworks", EntryPoint = "GameServer_BSecure", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SteamGameServer_BSecure();
[DllImport("CSteamworks", EntryPoint = "GameServer_GetSteamID", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong SteamGameServer_GetSteamID();
[DllImport("CSteamworks", EntryPoint = "GameServer_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl)]
public static extern int SteamGameServer_GetHSteamPipe();
[DllImport("CSteamworks", EntryPoint = "GameServer_GetHSteamUser", CallingConvention = CallingConvention.Cdecl)]
public static extern int SteamGameServer_GetHSteamUser();
[DllImport("CSteamworks", EntryPoint = "SteamClientGameServer", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamClientGameServer();
// SteamGameServerContext Accessors
[DllImport("CSteamworks", EntryPoint = "SteamGameServer", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamGameServer();
[DllImport("CSteamworks", EntryPoint = "SteamGameServerUtils", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamGameServerUtils();
[DllImport("CSteamworks", EntryPoint = "SteamGameServerNetworking", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamGameServerNetworking();
[DllImport("CSteamworks", EntryPoint = "SteamGameServerStats", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamGameServerStats();
[DllImport("CSteamworks", EntryPoint = "SteamGameServerHTTP", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SteamGameServerHTTP();
#endregion
#region steamencryptedappticket.h
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_BDecryptTicket")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool BDecryptTicket([In, Out] byte[] rgubTicketEncrypted, uint cubTicketEncrypted, [In, Out] byte[] rgubTicketDecrypted, ref uint pcubTicketDecrypted, [MarshalAs(UnmanagedType.LPArray, SizeConst=Constants.k_nSteamEncryptedAppTicketSymmetricKeyLen)] byte[] rgubKey, int cubKey);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_BIsTicketForApp")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool BIsTicketForApp([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_GetTicketIssueTime")]
public static extern uint GetTicketIssueTime([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_GetTicketSteamID")]
public static extern void GetTicketSteamID([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted, out CSteamID psteamID);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_GetTicketAppID")]
public static extern uint GetTicketAppID([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_BUserOwnsAppInTicket")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool BUserOwnsAppInTicket([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_BUserIsVacBanned")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool BUserIsVacBanned([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted);
[DllImport("sdkencryptedappticket", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamEncryptedAppTicket_GetUserVariableData")]
public static extern IntPtr GetUserVariableData([In, Out] byte[] rgubTicketDecrypted, uint cubTicketDecrypted, out uint pcubUserData);
#endregion
#region SteamAppList
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamAppList_GetNumInstalledApps();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamAppList_GetInstalledApps([In, Out] AppId_t[] pvecAppID, uint unMaxAppIDs);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamAppList_GetAppName(AppId_t nAppID, IntPtr pchName, int cchNameMax);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamAppList_GetAppInstallDir(AppId_t nAppID, IntPtr pchDirectory, int cchNameMax);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamAppList_GetAppBuildId(AppId_t nAppID);
#endregion
#region SteamApps
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsSubscribed();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsLowViolence();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsCybercafe();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsVACBanned();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamApps_GetCurrentGameLanguage();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamApps_GetAvailableGameLanguages();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsSubscribedApp(AppId_t appID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsDlcInstalled(AppId_t appID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamApps_GetEarliestPurchaseUnixTime(AppId_t nAppID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsSubscribedFromFreeWeekend();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamApps_GetDLCCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BGetDLCDataByIndex(int iDLC, out AppId_t pAppID, out bool pbAvailable, IntPtr pchName, int cchNameBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamApps_InstallDLC(AppId_t nAppID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamApps_UninstallDLC(AppId_t nAppID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamApps_RequestAppProofOfPurchaseKey(AppId_t nAppID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_GetCurrentBetaName(IntPtr pchName, int cchNameBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_MarkContentCorrupt([MarshalAs(UnmanagedType.I1)] bool bMissingFilesOnly);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamApps_GetInstalledDepots(AppId_t appID, [In, Out] DepotId_t[] pvecDepots, uint cMaxDepots);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamApps_GetAppInstallDir(AppId_t appID, IntPtr pchFolder, uint cchFolderBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_BIsAppInstalled(AppId_t appID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamApps_GetAppOwner();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamApps_GetLaunchQueryParam(InteropHelp.UTF8StringHandle pchKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamApps_GetDlcDownloadProgress(AppId_t nAppID, out ulong punBytesDownloaded, out ulong punBytesTotal);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamApps_GetAppBuildId();
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamApps_RegisterActivationCode(InteropHelp.UTF8StringHandle pchActivationCode);
#endif
#endregion
#region SteamClient
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamClient_CreateSteamPipe();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamClient_BReleaseSteamPipe(HSteamPipe hSteamPipe);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamClient_ConnectToGlobalUser(HSteamPipe hSteamPipe);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamClient_CreateLocalUser(out HSteamPipe phSteamPipe, EAccountType eAccountType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_ReleaseUser(HSteamPipe hSteamPipe, HSteamUser hUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamUser(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamGameServer(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_SetLocalIPBinding(uint unIP, ushort usPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamFriends(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamUtils(HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamMatchmaking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamMatchmakingServers(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamGenericInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamUserStats(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamGameServerStats(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamApps(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamNetworking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamRemoteStorage(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamScreenshots(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_RunFrame();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamClient_GetIPCCallCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamClient_BShutdownIfAllPipesClosed();
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamPS3OverlayRender();
#endif
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamHTTP(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamUnifiedMessages(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamController(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamUGC(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamAppList(HSteamUser hSteamUser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamMusic(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_Set_SteamAPI_CPostAPIResultInProcess(SteamAPI_PostAPIResultInProcess_t func);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_Remove_SteamAPI_CPostAPIResultInProcess(SteamAPI_PostAPIResultInProcess_t func);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamClient_Set_SteamAPI_CCheckCallbackRegisteredInProcess(SteamAPI_CheckCallbackRegistered_t func);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamInventory(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamClient_GetISteamVideo(HSteamUser hSteamuser, HSteamPipe hSteamPipe, InteropHelp.UTF8StringHandle pchVersion);
#endregion
#region SteamController
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamController_Init(InteropHelp.UTF8StringHandle pchAbsolutePathToControllerConfigVDF);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamController_Shutdown();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamController_RunFrame();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamController_GetControllerState(uint unControllerIndex, out SteamControllerState_t pState);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamController_TriggerHapticPulse(uint unControllerIndex, ESteamControllerPad eTargetPad, ushort usDurationMicroSec);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamController_SetOverrideMode(InteropHelp.UTF8StringHandle pchMode);
#endregion
#region SteamFriends
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetPersonaName();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_SetPersonaName(InteropHelp.UTF8StringHandle pchPersonaName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EPersonaState ISteamFriends_GetPersonaState();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendCount(EFriendFlags iFriendFlags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetFriendByIndex(int iFriend, EFriendFlags iFriendFlags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EFriendRelationship ISteamFriends_GetFriendRelationship(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EPersonaState ISteamFriends_GetFriendPersonaState(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetFriendPersonaName(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_GetFriendGamePlayed(CSteamID steamIDFriend, out FriendGameInfo_t pFriendGameInfo);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetFriendPersonaNameHistory(CSteamID steamIDFriend, int iPersonaName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendSteamLevel(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetPlayerNickname(CSteamID steamIDPlayer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendsGroupCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern FriendsGroupID_t ISteamFriends_GetFriendsGroupIDByIndex(int iFG);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetFriendsGroupName(FriendsGroupID_t friendsGroupID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendsGroupMembersCount(FriendsGroupID_t friendsGroupID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_GetFriendsGroupMembersList(FriendsGroupID_t friendsGroupID, [In, Out] CSteamID[] pOutSteamIDMembers, int nMembersCount);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_HasFriend(CSteamID steamIDFriend, EFriendFlags iFriendFlags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetClanCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetClanByIndex(int iClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetClanName(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetClanTag(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_GetClanActivityCounts(CSteamID steamIDClan, out int pnOnline, out int pnInGame, out int pnChatting);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_DownloadClanActivityCounts([In, Out] CSteamID[] psteamIDClans, int cClansToRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendCountFromSource(CSteamID steamIDSource);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetFriendFromSourceByIndex(CSteamID steamIDSource, int iFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_IsUserInSource(CSteamID steamIDUser, CSteamID steamIDSource);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_SetInGameVoiceSpeaking(CSteamID steamIDUser, [MarshalAs(UnmanagedType.I1)] bool bSpeaking);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_ActivateGameOverlay(InteropHelp.UTF8StringHandle pchDialog);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_ActivateGameOverlayToUser(InteropHelp.UTF8StringHandle pchDialog, CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_ActivateGameOverlayToWebPage(InteropHelp.UTF8StringHandle pchURL);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_ActivateGameOverlayToStore(AppId_t nAppID, EOverlayToStoreFlag eFlag);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_SetPlayedWith(CSteamID steamIDUserPlayedWith);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_ActivateGameOverlayInviteDialog(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetSmallFriendAvatar(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetMediumFriendAvatar(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetLargeFriendAvatar(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_RequestUserInformation(CSteamID steamIDUser, [MarshalAs(UnmanagedType.I1)] bool bRequireNameOnly);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_RequestClanOfficerList(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetClanOwner(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetClanOfficerCount(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamFriends_GetUserRestrictions();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_SetRichPresence(InteropHelp.UTF8StringHandle pchKey, InteropHelp.UTF8StringHandle pchValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_ClearRichPresence();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetFriendRichPresence(CSteamID steamIDFriend, InteropHelp.UTF8StringHandle pchKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendRichPresenceKeyCount(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamFriends_GetFriendRichPresenceKeyByIndex(CSteamID steamIDFriend, int iKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamFriends_RequestFriendRichPresence(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_InviteUserToGame(CSteamID steamIDFriend, InteropHelp.UTF8StringHandle pchConnectString);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetCoplayFriendCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetCoplayFriend(int iCoplayFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendCoplayTime(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamFriends_GetFriendCoplayGame(CSteamID steamIDFriend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_JoinClanChatRoom(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_LeaveClanChatRoom(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetClanChatMemberCount(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetChatMemberByIndex(CSteamID steamIDClan, int iUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_SendClanChatMessage(CSteamID steamIDClanChat, InteropHelp.UTF8StringHandle pchText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetClanChatMessage(CSteamID steamIDClanChat, int iMessage, IntPtr prgchText, int cchTextMax, out EChatEntryType peChatEntryType, out CSteamID psteamidChatter);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_IsClanChatAdmin(CSteamID steamIDClanChat, CSteamID steamIDUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_IsClanChatWindowOpenInSteam(CSteamID steamIDClanChat);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_OpenClanChatWindowInSteam(CSteamID steamIDClanChat);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_CloseClanChatWindowInSteam(CSteamID steamIDClanChat);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_SetListenForFriendsMessages([MarshalAs(UnmanagedType.I1)] bool bInterceptEnabled);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamFriends_ReplyToFriendMessage(CSteamID steamIDFriend, InteropHelp.UTF8StringHandle pchMsgToSend);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamFriends_GetFriendMessage(CSteamID steamIDFriend, int iMessageID, IntPtr pvData, int cubData, out EChatEntryType peChatEntryType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_GetFollowerCount(CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_IsFollowing(CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamFriends_EnumerateFollowingList(uint unStartIndex);
#endregion
#region SteamGameServer
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_InitGameServer(uint unIP, ushort usGamePort, ushort usQueryPort, uint unFlags, AppId_t nGameAppId, InteropHelp.UTF8StringHandle pchVersionString);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetProduct(InteropHelp.UTF8StringHandle pszProduct);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetGameDescription(InteropHelp.UTF8StringHandle pszGameDescription);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetModDir(InteropHelp.UTF8StringHandle pszModDir);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetDedicatedServer([MarshalAs(UnmanagedType.I1)] bool bDedicated);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_LogOn(InteropHelp.UTF8StringHandle pszToken);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_LogOnAnonymous();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_LogOff();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_BLoggedOn();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_BSecure();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServer_GetSteamID();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_WasRestartRequested();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetMaxPlayerCount(int cPlayersMax);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetBotPlayerCount(int cBotplayers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetServerName(InteropHelp.UTF8StringHandle pszServerName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetMapName(InteropHelp.UTF8StringHandle pszMapName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetPasswordProtected([MarshalAs(UnmanagedType.I1)] bool bPasswordProtected);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetSpectatorPort(ushort unSpectatorPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetSpectatorServerName(InteropHelp.UTF8StringHandle pszSpectatorServerName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_ClearAllKeyValues();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetKeyValue(InteropHelp.UTF8StringHandle pKey, InteropHelp.UTF8StringHandle pValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetGameTags(InteropHelp.UTF8StringHandle pchGameTags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetGameData(InteropHelp.UTF8StringHandle pchGameData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetRegion(InteropHelp.UTF8StringHandle pszRegion);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_SendUserConnectAndAuthenticate(uint unIPClient, [In, Out] byte[] pvAuthBlob, uint cubAuthBlobSize, out CSteamID pSteamIDUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServer_CreateUnauthenticatedUserConnection();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SendUserDisconnect(CSteamID steamIDUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_BUpdateUserData(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchPlayerName, uint uScore);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServer_GetAuthSessionTicket([In, Out] byte[] pTicket, int cbMaxTicket, out uint pcbTicket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EBeginAuthSessionResult ISteamGameServer_BeginAuthSession([In, Out] byte[] pAuthTicket, int cbAuthTicket, CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_EndAuthSession(CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_CancelAuthTicket(HAuthTicket hAuthTicket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EUserHasLicenseForAppResult ISteamGameServer_UserHasLicenseForApp(CSteamID steamID, AppId_t appID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_RequestUserGroupStatus(CSteamID steamIDUser, CSteamID steamIDGroup);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_GetGameplayStats();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServer_GetServerReputation();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServer_GetPublicIP();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServer_HandleIncomingPacket([In, Out] byte[] pData, int cbData, uint srcIP, ushort srcPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamGameServer_GetNextOutgoingPacket([In, Out] byte[] pOut, int cbMaxOut, out uint pNetAdr, out ushort pPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_EnableHeartbeats([MarshalAs(UnmanagedType.I1)] bool bActive);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_SetHeartbeatInterval(int iHeartbeatInterval);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServer_ForceHeartbeat();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServer_AssociateWithClan(CSteamID steamIDClan);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServer_ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer);
#endregion
#region SteamGameServerHTTP
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern HTTPRequestHandle ISteamGameServerHTTP_CreateHTTPRequest(EHTTPMethod eHTTPRequestMethod, InteropHelp.UTF8StringHandle pchAbsoluteURL);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestContextValue(HTTPRequestHandle hRequest, ulong ulContextValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestNetworkActivityTimeout(HTTPRequestHandle hRequest, uint unTimeoutSeconds);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestHeaderValue(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchHeaderName, InteropHelp.UTF8StringHandle pchHeaderValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestGetOrPostParameter(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchParamName, InteropHelp.UTF8StringHandle pchParamValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SendHTTPRequest(HTTPRequestHandle hRequest, out SteamAPICall_t pCallHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SendHTTPRequestAndStreamResponse(HTTPRequestHandle hRequest, out SteamAPICall_t pCallHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_DeferHTTPRequest(HTTPRequestHandle hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_PrioritizeHTTPRequest(HTTPRequestHandle hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPResponseHeaderSize(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchHeaderName, out uint unResponseHeaderSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPResponseHeaderValue(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchHeaderName, [In, Out] byte[] pHeaderValueBuffer, uint unBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPResponseBodySize(HTTPRequestHandle hRequest, out uint unBodySize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPResponseBodyData(HTTPRequestHandle hRequest, [In, Out] byte[] pBodyDataBuffer, uint unBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPStreamingResponseBodyData(HTTPRequestHandle hRequest, uint cOffset, [In, Out] byte[] pBodyDataBuffer, uint unBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_ReleaseHTTPRequest(HTTPRequestHandle hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPDownloadProgressPct(HTTPRequestHandle hRequest, out float pflPercentOut);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestRawPostBody(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchContentType, [In, Out] byte[] pubBody, uint unBodyLen);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern HTTPCookieContainerHandle ISteamGameServerHTTP_CreateCookieContainer([MarshalAs(UnmanagedType.I1)] bool bAllowResponsesToModify);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_ReleaseCookieContainer(HTTPCookieContainerHandle hCookieContainer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetCookie(HTTPCookieContainerHandle hCookieContainer, InteropHelp.UTF8StringHandle pchHost, InteropHelp.UTF8StringHandle pchUrl, InteropHelp.UTF8StringHandle pchCookie);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestCookieContainer(HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestUserAgentInfo(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchUserAgentInfo);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestRequiresVerifiedCertificate(HTTPRequestHandle hRequest, [MarshalAs(UnmanagedType.I1)] bool bRequireVerifiedCertificate);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_SetHTTPRequestAbsoluteTimeoutMS(HTTPRequestHandle hRequest, uint unMilliseconds);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerHTTP_GetHTTPRequestWasTimedOut(HTTPRequestHandle hRequest, out bool pbWasTimedOut);
#endregion
#region SteamGameServerInventory
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EResult ISteamGameServerInventory_GetResultStatus(SteamInventoryResult_t resultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GetResultItems(SteamInventoryResult_t resultHandle, [In, Out] SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerInventory_GetResultTimestamp(SteamInventoryResult_t resultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_CheckResultSteamID(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerInventory_DestroyResult(SteamInventoryResult_t resultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GetAllItems(out SteamInventoryResult_t pResultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GetItemsByID(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemInstanceID_t[] pInstanceIDs, uint unCountInstanceIDs);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_SerializeResult(SteamInventoryResult_t resultHandle, [In, Out] byte[] pOutBuffer, out uint punOutBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_DeserializeResult(out SteamInventoryResult_t pOutResultHandle, [In, Out] byte[] pBuffer, uint unBufferSize, [MarshalAs(UnmanagedType.I1)] bool bRESERVED_MUST_BE_FALSE);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GenerateItems(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemDef_t[] pArrayItemDefs, [In, Out] uint[] punArrayQuantity, uint unArrayLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GrantPromoItems(out SteamInventoryResult_t pResultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_AddPromoItem(out SteamInventoryResult_t pResultHandle, SteamItemDef_t itemDef);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_AddPromoItems(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemDef_t[] pArrayItemDefs, uint unArrayLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_ConsumeItem(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemConsume, uint unQuantity);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_ExchangeItems(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemDef_t[] pArrayGenerate, [In, Out] uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, [In, Out] SteamItemInstanceID_t[] pArrayDestroy, [In, Out] uint[] punArrayDestroyQuantity, uint unArrayDestroyLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_TransferItemQuantity(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemIdSource, uint unQuantity, SteamItemInstanceID_t itemIdDest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerInventory_SendItemDropHeartbeat();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_TriggerItemDrop(out SteamInventoryResult_t pResultHandle, SteamItemDef_t dropListDefinition);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_TradeItems(out SteamInventoryResult_t pResultHandle, CSteamID steamIDTradePartner, [In, Out] SteamItemInstanceID_t[] pArrayGive, [In, Out] uint[] pArrayGiveQuantity, uint nArrayGiveLength, [In, Out] SteamItemInstanceID_t[] pArrayGet, [In, Out] uint[] pArrayGetQuantity, uint nArrayGetLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_LoadItemDefinitions();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GetItemDefinitionIDs([In, Out] SteamItemDef_t[] pItemDefIDs, out uint punItemDefIDsArraySize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerInventory_GetItemDefinitionProperty(SteamItemDef_t iDefinition, InteropHelp.UTF8StringHandle pchPropertyName, IntPtr pchValueBuffer, ref uint punValueBufferSize);
#endregion
#region SteamGameServerNetworking
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_SendP2PPacket(CSteamID steamIDRemote, [In, Out] byte[] pubData, uint cubData, EP2PSend eP2PSendType, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_IsP2PPacketAvailable(out uint pcubMsgSize, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_ReadP2PPacket([In, Out] byte[] pubDest, uint cubDest, out uint pcubMsgSize, out CSteamID psteamIDRemote, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_AcceptP2PSessionWithUser(CSteamID steamIDRemote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_CloseP2PSessionWithUser(CSteamID steamIDRemote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_CloseP2PChannelWithUser(CSteamID steamIDRemote, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_GetP2PSessionState(CSteamID steamIDRemote, out P2PSessionState_t pConnectionState);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_AllowP2PPacketRelay([MarshalAs(UnmanagedType.I1)] bool bAllow);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerNetworking_CreateListenSocket(int nVirtualP2PPort, uint nIP, ushort nPort, [MarshalAs(UnmanagedType.I1)] bool bAllowUseOfPacketRelay);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerNetworking_CreateP2PConnectionSocket(CSteamID steamIDTarget, int nVirtualPort, int nTimeoutSec, [MarshalAs(UnmanagedType.I1)] bool bAllowUseOfPacketRelay);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerNetworking_CreateConnectionSocket(uint nIP, ushort nPort, int nTimeoutSec);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_DestroySocket(SNetSocket_t hSocket, [MarshalAs(UnmanagedType.I1)] bool bNotifyRemoteEnd);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_DestroyListenSocket(SNetListenSocket_t hSocket, [MarshalAs(UnmanagedType.I1)] bool bNotifyRemoteEnd);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_SendDataOnSocket(SNetSocket_t hSocket, IntPtr pubData, uint cubData, [MarshalAs(UnmanagedType.I1)] bool bReliable);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_IsDataAvailableOnSocket(SNetSocket_t hSocket, out uint pcubMsgSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_RetrieveDataFromSocket(SNetSocket_t hSocket, IntPtr pubDest, uint cubDest, out uint pcubMsgSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_IsDataAvailable(SNetListenSocket_t hListenSocket, out uint pcubMsgSize, out SNetSocket_t phSocket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_RetrieveData(SNetListenSocket_t hListenSocket, IntPtr pubDest, uint cubDest, out uint pcubMsgSize, out SNetSocket_t phSocket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_GetSocketInfo(SNetSocket_t hSocket, out CSteamID pSteamIDRemote, out int peSocketStatus, out uint punIPRemote, out ushort punPortRemote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerNetworking_GetListenSocketInfo(SNetListenSocket_t hListenSocket, out uint pnIP, out ushort pnPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ESNetSocketConnectionType ISteamGameServerNetworking_GetSocketConnectionType(SNetSocket_t hSocket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamGameServerNetworking_GetMaxPacketSize(SNetSocket_t hSocket);
#endregion
#region SteamGameServerStats
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServerStats_RequestUserStats(CSteamID steamIDUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_GetUserStat(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out int pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_GetUserStat_(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out float pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_GetUserAchievement(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out bool pbAchieved);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_SetUserStat(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, int nData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_SetUserStat_(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, float fData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_UpdateUserAvgRateStat(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, float flCountThisSession, double dSessionLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_SetUserAchievement(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerStats_ClearUserAchievement(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServerStats_StoreUserStats(CSteamID steamIDUser);
#endregion
#region SteamGameServerUtils
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerUtils_GetSecondsSinceAppActive();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerUtils_GetSecondsSinceComputerActive();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EUniverse ISteamGameServerUtils_GetConnectedUniverse();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerUtils_GetServerRealTime();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamGameServerUtils_GetIPCountry();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_GetImageSize(int iImage, out uint pnWidth, out uint pnHeight);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_GetImageRGBA(int iImage, [In, Out] byte[] pubDest, int nDestBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_GetCSERIPPort(out uint unIP, out ushort usPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern byte ISteamGameServerUtils_GetCurrentBatteryPower();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerUtils_GetAppID();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerUtils_SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_IsAPICallCompleted(SteamAPICall_t hSteamAPICall, out bool pbFailed);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ESteamAPICallFailure ISteamGameServerUtils_GetAPICallFailureReason(SteamAPICall_t hSteamAPICall);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_GetAPICallResult(SteamAPICall_t hSteamAPICall, IntPtr pCallback, int cubCallback, int iCallbackExpected, out bool pbFailed);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerUtils_RunFrame();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerUtils_GetIPCCallCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerUtils_SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_IsOverlayEnabled();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_BOverlayNeedsPresent();
#if ! _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamGameServerUtils_CheckFileSignature(InteropHelp.UTF8StringHandle szFileName);
#endif
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerUtils_PostPS3SysutilCallback(ulong status, ulong param, IntPtr userdata);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_BIsReadyToShutdown();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_BIsPSNOnline();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamGameServerUtils_SetPSNGameBootInviteStrings(InteropHelp.UTF8StringHandle pchSubject, InteropHelp.UTF8StringHandle pchBody);
#endif
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_ShowGamepadTextInput(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, InteropHelp.UTF8StringHandle pchDescription, uint unCharMax, InteropHelp.UTF8StringHandle pchExistingText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamGameServerUtils_GetEnteredGamepadTextLength();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_GetEnteredGamepadTextInput(IntPtr pchText, uint cchText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamGameServerUtils_GetSteamUILanguage();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamGameServerUtils_IsSteamRunningInVR();
#endregion
#region SteamHTMLSurface
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTMLSurface_Init();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTMLSurface_Shutdown();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamHTMLSurface_CreateBrowser(InteropHelp.UTF8StringHandle pchUserAgent, InteropHelp.UTF8StringHandle pchUserCSS);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_RemoveBrowser(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_LoadURL(HHTMLBrowser unBrowserHandle, InteropHelp.UTF8StringHandle pchURL, InteropHelp.UTF8StringHandle pchPostData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_SetSize(HHTMLBrowser unBrowserHandle, uint unWidth, uint unHeight);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_StopLoad(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_Reload(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_GoBack(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_GoForward(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_AddHeader(HHTMLBrowser unBrowserHandle, InteropHelp.UTF8StringHandle pchKey, InteropHelp.UTF8StringHandle pchValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_ExecuteJavascript(HHTMLBrowser unBrowserHandle, InteropHelp.UTF8StringHandle pchScript);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_MouseUp(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_MouseDown(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_MouseDoubleClick(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_MouseMove(HHTMLBrowser unBrowserHandle, int x, int y);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_MouseWheel(HHTMLBrowser unBrowserHandle, int nDelta);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_KeyDown(HHTMLBrowser unBrowserHandle, uint nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_KeyUp(HHTMLBrowser unBrowserHandle, uint nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_KeyChar(HHTMLBrowser unBrowserHandle, uint cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_SetHorizontalScroll(HHTMLBrowser unBrowserHandle, uint nAbsolutePixelScroll);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_SetVerticalScroll(HHTMLBrowser unBrowserHandle, uint nAbsolutePixelScroll);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_SetKeyFocus(HHTMLBrowser unBrowserHandle, [MarshalAs(UnmanagedType.I1)] bool bHasKeyFocus);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_ViewSource(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_CopyToClipboard(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_PasteFromClipboard(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_Find(HHTMLBrowser unBrowserHandle, InteropHelp.UTF8StringHandle pchSearchStr, [MarshalAs(UnmanagedType.I1)] bool bCurrentlyInFind, [MarshalAs(UnmanagedType.I1)] bool bReverse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_StopFind(HHTMLBrowser unBrowserHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_GetLinkAtPosition(HHTMLBrowser unBrowserHandle, int x, int y);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_SetCookie(InteropHelp.UTF8StringHandle pchHostname, InteropHelp.UTF8StringHandle pchKey, InteropHelp.UTF8StringHandle pchValue, InteropHelp.UTF8StringHandle pchPath, uint nExpires, bool bSecure, bool bHTTPOnly);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_SetPageScaleFactor(HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_AllowStartRequest(HHTMLBrowser unBrowserHandle, [MarshalAs(UnmanagedType.I1)] bool bAllowed);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_JSDialogResponse(HHTMLBrowser unBrowserHandle, [MarshalAs(UnmanagedType.I1)] bool bResult);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamHTMLSurface_FileLoadDialogResponse(HHTMLBrowser unBrowserHandle, IntPtr pchSelectedFiles);
#endregion
#region SteamHTTP
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern HTTPRequestHandle ISteamHTTP_CreateHTTPRequest(EHTTPMethod eHTTPRequestMethod, InteropHelp.UTF8StringHandle pchAbsoluteURL);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestContextValue(HTTPRequestHandle hRequest, ulong ulContextValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestNetworkActivityTimeout(HTTPRequestHandle hRequest, uint unTimeoutSeconds);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestHeaderValue(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchHeaderName, InteropHelp.UTF8StringHandle pchHeaderValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestGetOrPostParameter(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchParamName, InteropHelp.UTF8StringHandle pchParamValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SendHTTPRequest(HTTPRequestHandle hRequest, out SteamAPICall_t pCallHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SendHTTPRequestAndStreamResponse(HTTPRequestHandle hRequest, out SteamAPICall_t pCallHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_DeferHTTPRequest(HTTPRequestHandle hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_PrioritizeHTTPRequest(HTTPRequestHandle hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPResponseHeaderSize(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchHeaderName, out uint unResponseHeaderSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPResponseHeaderValue(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchHeaderName, [In, Out] byte[] pHeaderValueBuffer, uint unBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPResponseBodySize(HTTPRequestHandle hRequest, out uint unBodySize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPResponseBodyData(HTTPRequestHandle hRequest, [In, Out] byte[] pBodyDataBuffer, uint unBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPStreamingResponseBodyData(HTTPRequestHandle hRequest, uint cOffset, [In, Out] byte[] pBodyDataBuffer, uint unBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_ReleaseHTTPRequest(HTTPRequestHandle hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPDownloadProgressPct(HTTPRequestHandle hRequest, out float pflPercentOut);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestRawPostBody(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchContentType, [In, Out] byte[] pubBody, uint unBodyLen);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern HTTPCookieContainerHandle ISteamHTTP_CreateCookieContainer([MarshalAs(UnmanagedType.I1)] bool bAllowResponsesToModify);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_ReleaseCookieContainer(HTTPCookieContainerHandle hCookieContainer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetCookie(HTTPCookieContainerHandle hCookieContainer, InteropHelp.UTF8StringHandle pchHost, InteropHelp.UTF8StringHandle pchUrl, InteropHelp.UTF8StringHandle pchCookie);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestCookieContainer(HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestUserAgentInfo(HTTPRequestHandle hRequest, InteropHelp.UTF8StringHandle pchUserAgentInfo);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestRequiresVerifiedCertificate(HTTPRequestHandle hRequest, [MarshalAs(UnmanagedType.I1)] bool bRequireVerifiedCertificate);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_SetHTTPRequestAbsoluteTimeoutMS(HTTPRequestHandle hRequest, uint unMilliseconds);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamHTTP_GetHTTPRequestWasTimedOut(HTTPRequestHandle hRequest, out bool pbWasTimedOut);
#endregion
#region SteamInventory
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EResult ISteamInventory_GetResultStatus(SteamInventoryResult_t resultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GetResultItems(SteamInventoryResult_t resultHandle, [In, Out] SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamInventory_GetResultTimestamp(SteamInventoryResult_t resultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_CheckResultSteamID(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamInventory_DestroyResult(SteamInventoryResult_t resultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GetAllItems(out SteamInventoryResult_t pResultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GetItemsByID(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemInstanceID_t[] pInstanceIDs, uint unCountInstanceIDs);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_SerializeResult(SteamInventoryResult_t resultHandle, [In, Out] byte[] pOutBuffer, out uint punOutBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_DeserializeResult(out SteamInventoryResult_t pOutResultHandle, [In, Out] byte[] pBuffer, uint unBufferSize, [MarshalAs(UnmanagedType.I1)] bool bRESERVED_MUST_BE_FALSE);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GenerateItems(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemDef_t[] pArrayItemDefs, [In, Out] uint[] punArrayQuantity, uint unArrayLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GrantPromoItems(out SteamInventoryResult_t pResultHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_AddPromoItem(out SteamInventoryResult_t pResultHandle, SteamItemDef_t itemDef);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_AddPromoItems(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemDef_t[] pArrayItemDefs, uint unArrayLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_ConsumeItem(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemConsume, uint unQuantity);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_ExchangeItems(out SteamInventoryResult_t pResultHandle, [In, Out] SteamItemDef_t[] pArrayGenerate, [In, Out] uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, [In, Out] SteamItemInstanceID_t[] pArrayDestroy, [In, Out] uint[] punArrayDestroyQuantity, uint unArrayDestroyLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_TransferItemQuantity(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemIdSource, uint unQuantity, SteamItemInstanceID_t itemIdDest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamInventory_SendItemDropHeartbeat();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_TriggerItemDrop(out SteamInventoryResult_t pResultHandle, SteamItemDef_t dropListDefinition);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_TradeItems(out SteamInventoryResult_t pResultHandle, CSteamID steamIDTradePartner, [In, Out] SteamItemInstanceID_t[] pArrayGive, [In, Out] uint[] pArrayGiveQuantity, uint nArrayGiveLength, [In, Out] SteamItemInstanceID_t[] pArrayGet, [In, Out] uint[] pArrayGetQuantity, uint nArrayGetLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_LoadItemDefinitions();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GetItemDefinitionIDs([In, Out] SteamItemDef_t[] pItemDefIDs, out uint punItemDefIDsArraySize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamInventory_GetItemDefinitionProperty(SteamItemDef_t iDefinition, InteropHelp.UTF8StringHandle pchPropertyName, IntPtr pchValueBuffer, ref uint punValueBufferSize);
#endregion
#region SteamMatchmaking
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmaking_GetFavoriteGameCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_GetFavoriteGame(int iGame, out AppId_t pnAppID, out uint pnIP, out ushort pnConnPort, out ushort pnQueryPort, out uint punFlags, out uint pRTime32LastPlayedOnServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmaking_AddFavoriteGame(AppId_t nAppID, uint nIP, ushort nConnPort, ushort nQueryPort, uint unFlags, uint rTime32LastPlayedOnServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_RemoveFavoriteGame(AppId_t nAppID, uint nIP, ushort nConnPort, ushort nQueryPort, uint unFlags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamMatchmaking_RequestLobbyList();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListStringFilter(InteropHelp.UTF8StringHandle pchKeyToMatch, InteropHelp.UTF8StringHandle pchValueToMatch, ELobbyComparison eComparisonType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListNumericalFilter(InteropHelp.UTF8StringHandle pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListNearValueFilter(InteropHelp.UTF8StringHandle pchKeyToMatch, int nValueToBeCloseTo);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListFilterSlotsAvailable(int nSlotsAvailable);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter eLobbyDistanceFilter);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListResultCountFilter(int cMaxResults);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_AddRequestLobbyListCompatibleMembersFilter(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamMatchmaking_GetLobbyByIndex(int iLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamMatchmaking_CreateLobby(ELobbyType eLobbyType, int cMaxMembers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamMatchmaking_JoinLobby(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_LeaveLobby(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_InviteUserToLobby(CSteamID steamIDLobby, CSteamID steamIDInvitee);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmaking_GetNumLobbyMembers(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamMatchmaking_GetLobbyMemberByIndex(CSteamID steamIDLobby, int iMember);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmaking_GetLobbyData(CSteamID steamIDLobby, InteropHelp.UTF8StringHandle pchKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SetLobbyData(CSteamID steamIDLobby, InteropHelp.UTF8StringHandle pchKey, InteropHelp.UTF8StringHandle pchValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmaking_GetLobbyDataCount(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_GetLobbyDataByIndex(CSteamID steamIDLobby, int iLobbyData, IntPtr pchKey, int cchKeyBufferSize, IntPtr pchValue, int cchValueBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_DeleteLobbyData(CSteamID steamIDLobby, InteropHelp.UTF8StringHandle pchKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmaking_GetLobbyMemberData(CSteamID steamIDLobby, CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_SetLobbyMemberData(CSteamID steamIDLobby, InteropHelp.UTF8StringHandle pchKey, InteropHelp.UTF8StringHandle pchValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SendLobbyChatMsg(CSteamID steamIDLobby, [In, Out] byte[] pvMsgBody, int cubMsgBody);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmaking_GetLobbyChatEntry(CSteamID steamIDLobby, int iChatID, out CSteamID pSteamIDUser, [In, Out] byte[] pvData, int cubData, out EChatEntryType peChatEntryType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_RequestLobbyData(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_SetLobbyGameServer(CSteamID steamIDLobby, uint unGameServerIP, ushort unGameServerPort, CSteamID steamIDGameServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_GetLobbyGameServer(CSteamID steamIDLobby, out uint punGameServerIP, out ushort punGameServerPort, out CSteamID psteamIDGameServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SetLobbyMemberLimit(CSteamID steamIDLobby, int cMaxMembers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmaking_GetLobbyMemberLimit(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SetLobbyType(CSteamID steamIDLobby, ELobbyType eLobbyType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SetLobbyJoinable(CSteamID steamIDLobby, [MarshalAs(UnmanagedType.I1)] bool bLobbyJoinable);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamMatchmaking_GetLobbyOwner(CSteamID steamIDLobby);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SetLobbyOwner(CSteamID steamIDLobby, CSteamID steamIDNewOwner);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmaking_SetLinkedLobby(CSteamID steamIDLobby, CSteamID steamIDLobbyDependent);
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmaking_CheckForPSNGameBootInvite(uint iGameBootAttributes);
#endif
#endregion
#region SteamMatchmakingServers
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_RequestInternetServerList(AppId_t iApp, IntPtr ppchFilters, uint nFilters, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_RequestLANServerList(AppId_t iApp, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_RequestFriendsServerList(AppId_t iApp, IntPtr ppchFilters, uint nFilters, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_RequestFavoritesServerList(AppId_t iApp, IntPtr ppchFilters, uint nFilters, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_RequestHistoryServerList(AppId_t iApp, IntPtr ppchFilters, uint nFilters, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_RequestSpectatorServerList(AppId_t iApp, IntPtr ppchFilters, uint nFilters, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmakingServers_ReleaseRequest(HServerListRequest hServerListRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamMatchmakingServers_GetServerDetails(HServerListRequest hRequest, int iServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmakingServers_CancelQuery(HServerListRequest hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmakingServers_RefreshQuery(HServerListRequest hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMatchmakingServers_IsRefreshing(HServerListRequest hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmakingServers_GetServerCount(HServerListRequest hRequest);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmakingServers_RefreshServer(HServerListRequest hRequest, int iServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmakingServers_PingServer(uint unIP, ushort usPort, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmakingServers_PlayerDetails(uint unIP, ushort usPort, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamMatchmakingServers_ServerRules(uint unIP, ushort usPort, IntPtr pRequestServersResponse);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMatchmakingServers_CancelServerQuery(HServerQuery hServerQuery);
#endregion
#region SteamMusic
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusic_BIsEnabled();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusic_BIsPlaying();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern AudioPlayback_Status ISteamMusic_GetPlaybackStatus();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMusic_Play();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMusic_Pause();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMusic_PlayPrevious();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMusic_PlayNext();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamMusic_SetVolume(float flVolume);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern float ISteamMusic_GetVolume();
#endregion
#region SteamMusicRemote
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_RegisterSteamMusicRemote(InteropHelp.UTF8StringHandle pchName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_DeregisterSteamMusicRemote();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_BIsCurrentMusicRemote();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_BActivationSuccess([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_SetDisplayName(InteropHelp.UTF8StringHandle pchDisplayName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_SetPNGIcon_64x64([In, Out] byte[] pvBuffer, uint cbBufferLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_EnablePlayPrevious([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_EnablePlayNext([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_EnableShuffled([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_EnableLooped([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_EnableQueue([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_EnablePlaylists([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdatePlaybackStatus(AudioPlayback_Status nStatus);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdateShuffled([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdateLooped([MarshalAs(UnmanagedType.I1)] bool bValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdateVolume(float flValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_CurrentEntryWillChange();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_CurrentEntryIsAvailable([MarshalAs(UnmanagedType.I1)] bool bAvailable);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdateCurrentEntryText(InteropHelp.UTF8StringHandle pchText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdateCurrentEntryElapsedSeconds(int nValue);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_UpdateCurrentEntryCoverArt([In, Out] byte[] pvBuffer, uint cbBufferLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_CurrentEntryDidChange();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_QueueWillChange();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_ResetQueueEntries();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_SetQueueEntry(int nID, int nPosition, InteropHelp.UTF8StringHandle pchEntryText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_SetCurrentQueueEntry(int nID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_QueueDidChange();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_PlaylistWillChange();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_ResetPlaylistEntries();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_SetPlaylistEntry(int nID, int nPosition, InteropHelp.UTF8StringHandle pchEntryText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_SetCurrentPlaylistEntry(int nID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamMusicRemote_PlaylistDidChange();
#endregion
#region SteamNetworking
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_SendP2PPacket(CSteamID steamIDRemote, [In, Out] byte[] pubData, uint cubData, EP2PSend eP2PSendType, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_IsP2PPacketAvailable(out uint pcubMsgSize, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_ReadP2PPacket([In, Out] byte[] pubDest, uint cubDest, out uint pcubMsgSize, out CSteamID psteamIDRemote, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_AcceptP2PSessionWithUser(CSteamID steamIDRemote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_CloseP2PSessionWithUser(CSteamID steamIDRemote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_CloseP2PChannelWithUser(CSteamID steamIDRemote, int nChannel);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_GetP2PSessionState(CSteamID steamIDRemote, out P2PSessionState_t pConnectionState);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_AllowP2PPacketRelay([MarshalAs(UnmanagedType.I1)] bool bAllow);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamNetworking_CreateListenSocket(int nVirtualP2PPort, uint nIP, ushort nPort, [MarshalAs(UnmanagedType.I1)] bool bAllowUseOfPacketRelay);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamNetworking_CreateP2PConnectionSocket(CSteamID steamIDTarget, int nVirtualPort, int nTimeoutSec, [MarshalAs(UnmanagedType.I1)] bool bAllowUseOfPacketRelay);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamNetworking_CreateConnectionSocket(uint nIP, ushort nPort, int nTimeoutSec);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_DestroySocket(SNetSocket_t hSocket, [MarshalAs(UnmanagedType.I1)] bool bNotifyRemoteEnd);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_DestroyListenSocket(SNetListenSocket_t hSocket, [MarshalAs(UnmanagedType.I1)] bool bNotifyRemoteEnd);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_SendDataOnSocket(SNetSocket_t hSocket, IntPtr pubData, uint cubData, [MarshalAs(UnmanagedType.I1)] bool bReliable);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_IsDataAvailableOnSocket(SNetSocket_t hSocket, out uint pcubMsgSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_RetrieveDataFromSocket(SNetSocket_t hSocket, IntPtr pubDest, uint cubDest, out uint pcubMsgSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_IsDataAvailable(SNetListenSocket_t hListenSocket, out uint pcubMsgSize, out SNetSocket_t phSocket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_RetrieveData(SNetListenSocket_t hListenSocket, IntPtr pubDest, uint cubDest, out uint pcubMsgSize, out SNetSocket_t phSocket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_GetSocketInfo(SNetSocket_t hSocket, out CSteamID pSteamIDRemote, out int peSocketStatus, out uint punIPRemote, out ushort punPortRemote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamNetworking_GetListenSocketInfo(SNetListenSocket_t hListenSocket, out uint pnIP, out ushort pnPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ESNetSocketConnectionType ISteamNetworking_GetSocketConnectionType(SNetSocket_t hSocket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamNetworking_GetMaxPacketSize(SNetSocket_t hSocket);
#endregion
#region SteamRemoteStorage
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileWrite(InteropHelp.UTF8StringHandle pchFile, [In, Out] byte[] pvData, int cubData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamRemoteStorage_FileRead(InteropHelp.UTF8StringHandle pchFile, [In, Out] byte[] pvData, int cubDataToRead);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileForget(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileDelete(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_FileShare(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_SetSyncPlatforms(InteropHelp.UTF8StringHandle pchFile, ERemoteStoragePlatform eRemoteStoragePlatform);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_FileWriteStreamOpen(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileWriteStreamWriteChunk(UGCFileWriteStreamHandle_t writeHandle, [In, Out] byte[] pvData, int cubData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileWriteStreamClose(UGCFileWriteStreamHandle_t writeHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileWriteStreamCancel(UGCFileWriteStreamHandle_t writeHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileExists(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FilePersisted(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamRemoteStorage_GetFileSize(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern long ISteamRemoteStorage_GetFileTimestamp(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ERemoteStoragePlatform ISteamRemoteStorage_GetSyncPlatforms(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamRemoteStorage_GetFileCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamRemoteStorage_GetFileNameAndSize(int iFile, out int pnFileSizeInBytes);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_GetQuota(out int pnTotalBytes, out int puAvailableBytes);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_IsCloudEnabledForAccount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_IsCloudEnabledForApp();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamRemoteStorage_SetCloudEnabledForApp([MarshalAs(UnmanagedType.I1)] bool bEnabled);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_UGCDownload(UGCHandle_t hContent, uint unPriority);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_GetUGCDownloadProgress(UGCHandle_t hContent, out int pnBytesDownloaded, out int pnBytesExpected);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_GetUGCDetails(UGCHandle_t hContent, out AppId_t pnAppID, out IntPtr ppchName, out int pnFileSizeInBytes, out CSteamID pSteamIDOwner);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamRemoteStorage_UGCRead(UGCHandle_t hContent, [In, Out] byte[] pvData, int cubDataToRead, uint cOffset, EUGCReadAction eAction);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamRemoteStorage_GetCachedUGCCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_GetCachedUGCHandle(int iCachedContent);
#if _PS3 || _SERVER
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamRemoteStorage_GetFileListFromServer();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FileFetch(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_FilePersist(InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_SynchronizeToClient();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_SynchronizeToServer();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_ResetFileRequestState();
#endif
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_PublishWorkshopFile(InteropHelp.UTF8StringHandle pchFile, InteropHelp.UTF8StringHandle pchPreviewFile, AppId_t nConsumerAppId, InteropHelp.UTF8StringHandle pchTitle, InteropHelp.UTF8StringHandle pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, IntPtr pTags, EWorkshopFileType eWorkshopFileType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_CreatePublishedFileUpdateRequest(PublishedFileId_t unPublishedFileId);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFileFile(PublishedFileUpdateHandle_t updateHandle, InteropHelp.UTF8StringHandle pchFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFilePreviewFile(PublishedFileUpdateHandle_t updateHandle, InteropHelp.UTF8StringHandle pchPreviewFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFileTitle(PublishedFileUpdateHandle_t updateHandle, InteropHelp.UTF8StringHandle pchTitle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFileDescription(PublishedFileUpdateHandle_t updateHandle, InteropHelp.UTF8StringHandle pchDescription);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFileVisibility(PublishedFileUpdateHandle_t updateHandle, ERemoteStoragePublishedFileVisibility eVisibility);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFileTags(PublishedFileUpdateHandle_t updateHandle, IntPtr pTags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_CommitPublishedFileUpdate(PublishedFileUpdateHandle_t updateHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_GetPublishedFileDetails(PublishedFileId_t unPublishedFileId, uint unMaxSecondsOld);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_DeletePublishedFile(PublishedFileId_t unPublishedFileId);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_EnumerateUserPublishedFiles(uint unStartIndex);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_SubscribePublishedFile(PublishedFileId_t unPublishedFileId);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_EnumerateUserSubscribedFiles(uint unStartIndex);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_UnsubscribePublishedFile(PublishedFileId_t unPublishedFileId);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamRemoteStorage_UpdatePublishedFileSetChangeDescription(PublishedFileUpdateHandle_t updateHandle, InteropHelp.UTF8StringHandle pchChangeDescription);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_GetPublishedItemVoteDetails(PublishedFileId_t unPublishedFileId);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_UpdateUserPublishedItemVote(PublishedFileId_t unPublishedFileId, [MarshalAs(UnmanagedType.I1)] bool bVoteUp);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_GetUserPublishedItemVoteDetails(PublishedFileId_t unPublishedFileId);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_EnumerateUserSharedWorkshopFiles(CSteamID steamId, uint unStartIndex, IntPtr pRequiredTags, IntPtr pExcludedTags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_PublishVideo(EWorkshopVideoProvider eVideoProvider, InteropHelp.UTF8StringHandle pchVideoAccount, InteropHelp.UTF8StringHandle pchVideoIdentifier, InteropHelp.UTF8StringHandle pchPreviewFile, AppId_t nConsumerAppId, InteropHelp.UTF8StringHandle pchTitle, InteropHelp.UTF8StringHandle pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, IntPtr pTags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_SetUserPublishedFileAction(PublishedFileId_t unPublishedFileId, EWorkshopFileAction eAction);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_EnumeratePublishedFilesByUserAction(EWorkshopFileAction eAction, uint unStartIndex);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_EnumeratePublishedWorkshopFiles(EWorkshopEnumerationType eEnumerationType, uint unStartIndex, uint unCount, uint unDays, IntPtr pTags, IntPtr pUserTags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamRemoteStorage_UGCDownloadToLocation(UGCHandle_t hContent, InteropHelp.UTF8StringHandle pchLocation, uint unPriority);
#endregion
#region SteamScreenshots
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamScreenshots_WriteScreenshot([In, Out] byte[] pubRGB, uint cubRGB, int nWidth, int nHeight);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamScreenshots_AddScreenshotToLibrary(InteropHelp.UTF8StringHandle pchFilename, InteropHelp.UTF8StringHandle pchThumbnailFilename, int nWidth, int nHeight);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamScreenshots_TriggerScreenshot();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamScreenshots_HookScreenshots([MarshalAs(UnmanagedType.I1)] bool bHook);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamScreenshots_SetLocation(ScreenshotHandle hScreenshot, InteropHelp.UTF8StringHandle pchLocation);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamScreenshots_TagUser(ScreenshotHandle hScreenshot, CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamScreenshots_TagPublishedFile(ScreenshotHandle hScreenshot, PublishedFileId_t unPublishedFileID);
#endregion
#region SteamUGC
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_CreateQueryUserUGCRequest(AccountID_t unAccountID, EUserUGCList eListType, EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint unPage);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_CreateQueryAllUGCRequest(EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint unPage);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_SendQueryUGCRequest(UGCQueryHandle_t handle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_GetQueryUGCResult(UGCQueryHandle_t handle, uint index, out SteamUGCDetails_t pDetails);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_ReleaseQueryUGCRequest(UGCQueryHandle_t handle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_AddRequiredTag(UGCQueryHandle_t handle, InteropHelp.UTF8StringHandle pTagName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_AddExcludedTag(UGCQueryHandle_t handle, InteropHelp.UTF8StringHandle pTagName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetReturnLongDescription(UGCQueryHandle_t handle, [MarshalAs(UnmanagedType.I1)] bool bReturnLongDescription);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetReturnTotalOnly(UGCQueryHandle_t handle, [MarshalAs(UnmanagedType.I1)] bool bReturnTotalOnly);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetAllowCachedResponse(UGCQueryHandle_t handle, uint unMaxAgeSeconds);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetCloudFileNameFilter(UGCQueryHandle_t handle, InteropHelp.UTF8StringHandle pMatchCloudFileName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetMatchAnyTag(UGCQueryHandle_t handle, [MarshalAs(UnmanagedType.I1)] bool bMatchAnyTag);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetSearchText(UGCQueryHandle_t handle, InteropHelp.UTF8StringHandle pSearchText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetRankedByTrendDays(UGCQueryHandle_t handle, uint unDays);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_RequestUGCDetails(PublishedFileId_t nPublishedFileID, uint unMaxAgeSeconds);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_CreateItem(AppId_t nConsumerAppId, EWorkshopFileType eFileType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_StartItemUpdate(AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetItemTitle(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchTitle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetItemDescription(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchDescription);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetItemVisibility(UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetItemTags(UGCUpdateHandle_t updateHandle, IntPtr pTags);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetItemContent(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pszContentFolder);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_SetItemPreview(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pszPreviewFile);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_SubmitItemUpdate(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchChangeNote);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EItemUpdateStatus ISteamUGC_GetItemUpdateProgress(UGCUpdateHandle_t handle, out ulong punBytesProcessed, out ulong punBytesTotal);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_SubscribeItem(PublishedFileId_t nPublishedFileID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUGC_UnsubscribeItem(PublishedFileId_t nPublishedFileID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUGC_GetNumSubscribedItems();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUGC_GetSubscribedItems([In, Out] PublishedFileId_t[] pvecPublishedFileID, uint cMaxEntries);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_GetItemInstallInfo(PublishedFileId_t nPublishedFileID, out ulong punSizeOnDisk, IntPtr pchFolder, uint cchFolderSize, out bool pbLegacyItem);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUGC_GetItemUpdateInfo(PublishedFileId_t nPublishedFileID, out bool pbNeedsUpdate, out bool pbIsDownloading, out ulong punBytesDownloaded, out ulong punBytesTotal);
#endregion
#region SteamUnifiedMessages
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUnifiedMessages_SendMethod(InteropHelp.UTF8StringHandle pchServiceMethod, [In, Out] byte[] pRequestBuffer, uint unRequestBufferSize, ulong unContext);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUnifiedMessages_GetMethodResponseInfo(ClientUnifiedMessageHandle hHandle, out uint punResponseSize, out EResult peResult);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUnifiedMessages_GetMethodResponseData(ClientUnifiedMessageHandle hHandle, [In, Out] byte[] pResponseBuffer, uint unResponseBufferSize, [MarshalAs(UnmanagedType.I1)] bool bAutoRelease);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUnifiedMessages_ReleaseMethod(ClientUnifiedMessageHandle hHandle);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUnifiedMessages_SendNotification(InteropHelp.UTF8StringHandle pchServiceNotification, [In, Out] byte[] pNotificationBuffer, uint unNotificationBufferSize);
#endregion
#region SteamUser
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUser_GetHSteamUser();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUser_BLoggedOn();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUser_GetSteamID();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUser_InitiateGameConnection([In, Out] byte[] pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint unIPServer, ushort usPortServer, [MarshalAs(UnmanagedType.I1)] bool bSecure);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_TerminateGameConnection(uint unIPServer, ushort usPortServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_TrackAppUsageEvent(CGameID gameID, int eAppUsageEvent, InteropHelp.UTF8StringHandle pchExtraInfo);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUser_GetUserDataFolder(IntPtr pchBuffer, int cubBuffer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_StartVoiceRecording();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_StopVoiceRecording();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EVoiceResult ISteamUser_GetAvailableVoice(out uint pcbCompressed, out uint pcbUncompressed, uint nUncompressedVoiceDesiredSampleRate);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EVoiceResult ISteamUser_GetVoice([MarshalAs(UnmanagedType.I1)] bool bWantCompressed, [In, Out] byte[] pDestBuffer, uint cbDestBufferSize, out uint nBytesWritten, [MarshalAs(UnmanagedType.I1)] bool bWantUncompressed, [In, Out] byte[] pUncompressedDestBuffer, uint cbUncompressedDestBufferSize, out uint nUncompressBytesWritten, uint nUncompressedVoiceDesiredSampleRate);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EVoiceResult ISteamUser_DecompressVoice([In, Out] byte[] pCompressed, uint cbCompressed, [In, Out] byte[] pDestBuffer, uint cbDestBufferSize, out uint nBytesWritten, uint nDesiredSampleRate);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUser_GetVoiceOptimalSampleRate();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUser_GetAuthSessionTicket([In, Out] byte[] pTicket, int cbMaxTicket, out uint pcbTicket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EBeginAuthSessionResult ISteamUser_BeginAuthSession([In, Out] byte[] pAuthTicket, int cbAuthTicket, CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_EndAuthSession(CSteamID steamID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_CancelAuthTicket(HAuthTicket hAuthTicket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EUserHasLicenseForAppResult ISteamUser_UserHasLicenseForApp(CSteamID steamID, AppId_t appID);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUser_BIsBehindNAT();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_AdvertiseGame(CSteamID steamIDGameServer, uint unIPServer, ushort usPortServer);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUser_RequestEncryptedAppTicket([In, Out] byte[] pDataToInclude, int cbDataToInclude);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUser_GetEncryptedAppTicket([In, Out] byte[] pTicket, int cbMaxTicket, out uint pcbTicket);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUser_GetGameBadgeLevel(int nSeries, [MarshalAs(UnmanagedType.I1)] bool bFoil);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUser_GetPlayerSteamLevel();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUser_RequestStoreAuthURL(InteropHelp.UTF8StringHandle pchRedirectURL);
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_LogOn([MarshalAs(UnmanagedType.I1)] bool bInteractive);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_LogOnAndLinkSteamAccountToPSN([MarshalAs(UnmanagedType.I1)] bool bInteractive, InteropHelp.UTF8StringHandle pchUserName, InteropHelp.UTF8StringHandle pchPassword);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUser_LogOnAndCreateNewSteamAccountIfNeeded([MarshalAs(UnmanagedType.I1)] bool bInteractive);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUser_GetConsoleSteamID();
#endif
#endregion
#region SteamUserStats
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_RequestCurrentStats();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetStat(InteropHelp.UTF8StringHandle pchName, out int pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetStat_(InteropHelp.UTF8StringHandle pchName, out float pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_SetStat(InteropHelp.UTF8StringHandle pchName, int nData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_SetStat_(InteropHelp.UTF8StringHandle pchName, float fData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_UpdateAvgRateStat(InteropHelp.UTF8StringHandle pchName, float flCountThisSession, double dSessionLength);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetAchievement(InteropHelp.UTF8StringHandle pchName, out bool pbAchieved);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_SetAchievement(InteropHelp.UTF8StringHandle pchName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_ClearAchievement(InteropHelp.UTF8StringHandle pchName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetAchievementAndUnlockTime(InteropHelp.UTF8StringHandle pchName, out bool pbAchieved, out uint punUnlockTime);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_StoreStats();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUserStats_GetAchievementIcon(InteropHelp.UTF8StringHandle pchName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamUserStats_GetAchievementDisplayAttribute(InteropHelp.UTF8StringHandle pchName, InteropHelp.UTF8StringHandle pchKey);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_IndicateAchievementProgress(InteropHelp.UTF8StringHandle pchName, uint nCurProgress, uint nMaxProgress);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUserStats_GetNumAchievements();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamUserStats_GetAchievementName(uint iAchievement);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_RequestUserStats(CSteamID steamIDUser);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetUserStat(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out int pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetUserStat_(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out float pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetUserAchievement(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out bool pbAchieved);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetUserAchievementAndUnlockTime(CSteamID steamIDUser, InteropHelp.UTF8StringHandle pchName, out bool pbAchieved, out uint punUnlockTime);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_ResetAllStats([MarshalAs(UnmanagedType.I1)] bool bAchievementsToo);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_FindOrCreateLeaderboard(InteropHelp.UTF8StringHandle pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_FindLeaderboard(InteropHelp.UTF8StringHandle pchLeaderboardName);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamUserStats_GetLeaderboardName(SteamLeaderboard_t hSteamLeaderboard);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUserStats_GetLeaderboardEntryCount(SteamLeaderboard_t hSteamLeaderboard);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ELeaderboardSortMethod ISteamUserStats_GetLeaderboardSortMethod(SteamLeaderboard_t hSteamLeaderboard);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ELeaderboardDisplayType ISteamUserStats_GetLeaderboardDisplayType(SteamLeaderboard_t hSteamLeaderboard);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_DownloadLeaderboardEntries(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_DownloadLeaderboardEntriesForUsers(SteamLeaderboard_t hSteamLeaderboard, [In, Out] CSteamID[] prgUsers, int cUsers);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetDownloadedLeaderboardEntry(SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, out LeaderboardEntry_t pLeaderboardEntry, [In, Out] int[] pDetails, int cDetailsMax);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int nScore, [In, Out] int[] pScoreDetails, int cScoreDetailsCount);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_AttachLeaderboardUGC(SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_GetNumberOfCurrentPlayers();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_RequestGlobalAchievementPercentages();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUserStats_GetMostAchievedAchievementInfo(IntPtr pchName, uint unNameBufLen, out float pflPercent, out bool pbAchieved);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUserStats_GetNextMostAchievedAchievementInfo(int iIteratorPrevious, IntPtr pchName, uint unNameBufLen, out float pflPercent, out bool pbAchieved);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetAchievementAchievedPercent(InteropHelp.UTF8StringHandle pchName, out float pflPercent);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_RequestGlobalStats(int nHistoryDays);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetGlobalStat(InteropHelp.UTF8StringHandle pchStatName, out long pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetGlobalStat_(InteropHelp.UTF8StringHandle pchStatName, out double pData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUserStats_GetGlobalStatHistory(InteropHelp.UTF8StringHandle pchStatName, [In, Out] long[] pData, uint cubData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamUserStats_GetGlobalStatHistory_(InteropHelp.UTF8StringHandle pchStatName, [In, Out] double[] pData, uint cubData);
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_InstallPS3Trophies();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUserStats_GetTrophySpaceRequiredBeforeInstall();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_SetUserStatsData(IntPtr pvData, uint cubData);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUserStats_GetUserStatsData(IntPtr pvData, uint cubData, out uint pcubWritten);
#endif
#endregion
#region SteamUtils
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUtils_GetSecondsSinceAppActive();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUtils_GetSecondsSinceComputerActive();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern EUniverse ISteamUtils_GetConnectedUniverse();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUtils_GetServerRealTime();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamUtils_GetIPCountry();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_GetImageSize(int iImage, out uint pnWidth, out uint pnHeight);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_GetImageRGBA(int iImage, [In, Out] byte[] pubDest, int nDestBufferSize);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_GetCSERIPPort(out uint unIP, out ushort usPort);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern byte ISteamUtils_GetCurrentBatteryPower();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUtils_GetAppID();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUtils_SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_IsAPICallCompleted(SteamAPICall_t hSteamAPICall, out bool pbFailed);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ESteamAPICallFailure ISteamUtils_GetAPICallFailureReason(SteamAPICall_t hSteamAPICall);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_GetAPICallResult(SteamAPICall_t hSteamAPICall, IntPtr pCallback, int cubCallback, int iCallbackExpected, out bool pbFailed);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUtils_RunFrame();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUtils_GetIPCCallCount();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUtils_SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_IsOverlayEnabled();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_BOverlayNeedsPresent();
#if ! _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ISteamUtils_CheckFileSignature(InteropHelp.UTF8StringHandle szFileName);
#endif
#if _PS3
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUtils_PostPS3SysutilCallback(ulong status, ulong param, IntPtr userdata);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_BIsReadyToShutdown();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_BIsPSNOnline();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamUtils_SetPSNGameBootInviteStrings(InteropHelp.UTF8StringHandle pchSubject, InteropHelp.UTF8StringHandle pchBody);
#endif
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_ShowGamepadTextInput(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, InteropHelp.UTF8StringHandle pchDescription, uint unCharMax, InteropHelp.UTF8StringHandle pchExistingText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ISteamUtils_GetEnteredGamepadTextLength();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_GetEnteredGamepadTextInput(IntPtr pchText, uint cchText);
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ISteamUtils_GetSteamUILanguage();
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool ISteamUtils_IsSteamRunningInVR();
#endregion
#region SteamVideo
[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ISteamVideo_GetVideoURL(AppId_t unVideoAppID);
#endregion
}
}
| 62.479112 | 414 | 0.838886 | [
"MIT"
] | mikaelgarde/Steamworks.NET | Plugins/Steamworks.NET/autogen/NativeMethods.cs | 166,007 | C# |
using CodeWars;
using NUnit.Framework;
namespace CodeWarsTests
{
[TestFixture]
public class SimpleFun2CircleOfNumbersTests
{
[Test]
public void TestCase()
{
var kata = new SimpleFun2CircleOfNumbers();
Assert.AreEqual(7, kata.CircleOfNumbers(10, 2), "");
Assert.AreEqual(2, kata.CircleOfNumbers(10, 7), "");
Assert.AreEqual(3, kata.CircleOfNumbers(4, 1), "");
Assert.AreEqual(0, kata.CircleOfNumbers(6, 3), "");
}
}
} | 27.684211 | 64 | 0.587452 | [
"MIT"
] | a-kozhanov/codewars-csharp | CodeWarsTests/7kyu/SimpleFun2CircleOfNumbersTests.cs | 528 | C# |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class QuestList : MonoBehaviour, ISavable
{
List<Quest> quests = new List<Quest>();
public event Action OnUpdated;
public void AddQuest(Quest quest)
{
if (!quests.Contains(quest))
quests.Add(quest);
OnUpdated?.Invoke();
}
public bool IsStarted(string questName)
{
var questStatus = quests.FirstOrDefault(q => q.Base.Name == questName)?.Status;
return questStatus == QuestStatus.Started || questStatus == QuestStatus.Completed;
}
public bool IsCompleted(string questName)
{
var questStatus = quests.FirstOrDefault(q => q.Base.Name == questName)?.Status;
return questStatus == QuestStatus.Completed;
}
public static QuestList GetQuestList()
{
return FindObjectOfType<PlayerController>().GetComponent<QuestList>();
}
public object CaptureState()
{
return quests.Select(q => q.GetSaveData()).ToList();
}
public void RestoreState(object state)
{
var saveData = state as List<QuestSaveData>;
if (saveData != null)
{
quests = saveData.Select(q => new Quest(q)).ToList();
OnUpdated?.Invoke();
}
}
}
| 25.132075 | 90 | 0.632132 | [
"Unlicense"
] | ManuDem/RPGUnity | Assets/Scripts/Quests/QuestList.cs | 1,334 | 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 customer-profiles-2020-08-15.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using System.Net;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
namespace Amazon.CustomerProfiles.Model
{
/// <summary>
/// This is the response object from the GetProfileObjectTypeTemplate operation.
/// </summary>
public partial class GetProfileObjectTypeTemplateResponse : AmazonWebServiceResponse
{
private bool? _allowProfileCreation;
private Dictionary<string, ObjectTypeField> _fields = new Dictionary<string, ObjectTypeField>();
private Dictionary<string, List<ObjectTypeKey>> _keys = new Dictionary<string, List<ObjectTypeKey>>();
private string _sourceName;
private string _sourceObject;
private string _templateId;
/// <summary>
/// Gets and sets the property AllowProfileCreation.
/// <para>
/// Indicates whether a profile should be created when data is received if one doesn’t
/// exist for an object of this type. The default is <code>FALSE</code>. If the AllowProfileCreation
/// flag is set to <code>FALSE</code>, then the service tries to fetch a standard profile
/// and associate this object with the profile. If it is set to <code>TRUE</code>, and
/// if no match is found, then the service creates a new standard profile.
/// </para>
/// </summary>
public bool AllowProfileCreation
{
get { return this._allowProfileCreation.GetValueOrDefault(); }
set { this._allowProfileCreation = value; }
}
// Check to see if AllowProfileCreation property is set
internal bool IsSetAllowProfileCreation()
{
return this._allowProfileCreation.HasValue;
}
/// <summary>
/// Gets and sets the property Fields.
/// <para>
/// A map of the name and ObjectType field.
/// </para>
/// </summary>
public Dictionary<string, ObjectTypeField> Fields
{
get { return this._fields; }
set { this._fields = value; }
}
// Check to see if Fields property is set
internal bool IsSetFields()
{
return this._fields != null && this._fields.Count > 0;
}
/// <summary>
/// Gets and sets the property Keys.
/// <para>
/// A list of unique keys that can be used to map data to the profile.
/// </para>
/// </summary>
public Dictionary<string, List<ObjectTypeKey>> Keys
{
get { return this._keys; }
set { this._keys = value; }
}
// Check to see if Keys property is set
internal bool IsSetKeys()
{
return this._keys != null && this._keys.Count > 0;
}
/// <summary>
/// Gets and sets the property SourceName.
/// <para>
/// The name of the source of the object template.
/// </para>
/// </summary>
[AWSProperty(Min=1, Max=64)]
public string SourceName
{
get { return this._sourceName; }
set { this._sourceName = value; }
}
// Check to see if SourceName property is set
internal bool IsSetSourceName()
{
return this._sourceName != null;
}
/// <summary>
/// Gets and sets the property SourceObject.
/// <para>
/// The source of the object template.
/// </para>
/// </summary>
[AWSProperty(Min=1, Max=64)]
public string SourceObject
{
get { return this._sourceObject; }
set { this._sourceObject = value; }
}
// Check to see if SourceObject property is set
internal bool IsSetSourceObject()
{
return this._sourceObject != null;
}
/// <summary>
/// Gets and sets the property TemplateId.
/// <para>
/// A unique identifier for the object template.
/// </para>
/// </summary>
[AWSProperty(Min=1, Max=64)]
public string TemplateId
{
get { return this._templateId; }
set { this._templateId = value; }
}
// Check to see if TemplateId property is set
internal bool IsSetTemplateId()
{
return this._templateId != null;
}
}
} | 33.748428 | 116 | 0.573053 | [
"Apache-2.0"
] | philasmar/aws-sdk-net | sdk/src/Services/CustomerProfiles/Generated/Model/GetProfileObjectTypeTemplateResponse.cs | 5,368 | C# |
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
using FastProxy.Definitions;
using FastProxy.Helpers;
namespace FastProxy
{
/// <summary>
/// Allow to generate new dynamic proxy and an concrete or abstract definition
/// </summary>
public class ProxyFactory
{
private const string DynamicAssemblyName = "FastProxyDynamicAssembly";
private const string DynamicModuleName = "FastProxyDynamicModule";
private static readonly ReaderWriterLockSlim BuildersSlimLock = new ReaderWriterLockSlim();
private static ProxyFactory _default;
public static ProxyFactory Default
{
get
{
LockExecuteRelease(CreateDefault);
return _default;
}
}
/// <summary>
/// we have only one method builder that can contain complex subsequences
/// </summary>
private readonly IProxyMethodBuilder _methodBuilder;
/// <summary>
/// Proxy type constructor
/// </summary>
private readonly IProxyTypeBuilder _typeBuilder;
private readonly List<IBeforeCollectInterceptorInformation> _preInit = new List<IBeforeCollectInterceptorInformation>();
private readonly List<IBeforeInvokeInterceptor> _preInvoke = new List<IBeforeInvokeInterceptor>();
private readonly List<IAfterInvokeInterceptor> _postInvoke = new List<IAfterInvokeInterceptor>();
private readonly Dictionary<int, IProxyInfo> _cache = new Dictionary<int, IProxyInfo>();
private static AssemblyBuilder _builder;
private static ModuleBuilder _moduleBuilder;
public ProxyFactory(IProxyTypeBuilder typeBuilder, IProxyMethodBuilder methodBuilder)
{
_methodBuilder = methodBuilder;
_typeBuilder = typeBuilder;
}
private int GetUniquePostfix<TAbstract, TConcrete, TInterceptor>()
{
var result = typeof(TAbstract).FullName.GetHashCode() | typeof(TConcrete).FullName.GetHashCode() | typeof(TInterceptor).FullName.GetHashCode();
void GenerateHashcode<T>(T item)
{
result |= item.GetHashCode();
}
_preInit.ForEach(GenerateHashcode);
_preInvoke.ForEach(GenerateHashcode);
_postInvoke.ForEach(GenerateHashcode);
return result;
}
/// <summary>
/// Create new Proxy Type (not instance)
/// </summary>
/// <typeparam name="TAbstract">Abstract or concrete definition of the proxy type</typeparam>
/// <typeparam name="TInterceptor">Interceptor type</typeparam>
/// <typeparam name="TConcrete">Concrete Type of the implementation</typeparam>
/// <returns>Type of the new Proxy object</returns>
public ProxyInfo<TAbstract> CreateProxyInfo<TAbstract, TConcrete, TInterceptor>(params object[] args)
where TInterceptor : IInterceptor, new()
where TConcrete : TAbstract
{
IProxyInfo result = null;
void Create()
{
CreateBuilders();
var abstractType = typeof(TAbstract);
var concreteType = typeof(TConcrete);
var interceptorType = typeof(TInterceptor);
var uniquePostfix = GetUniquePostfix<TAbstract, TConcrete, TInterceptor>();
if (uniquePostfix < 0)
{
uniquePostfix += int.MaxValue;
}
if (_cache.TryGetValue(uniquePostfix, out result) == false)
{
var type = _typeBuilder.Create(abstractType, concreteType, interceptorType, _moduleBuilder, $"_{uniquePostfix}");
var input = new ProxyMethodBuilderTransientParameters
{
TypeInfo = type,
MethodCreationCounter = 0,
PreInit = new List<IBeforeCollectInterceptorInformation>(_preInit),
PreInvoke = new List<IBeforeInvokeInterceptor>(_preInvoke),
PostInvoke = new List<IAfterInvokeInterceptor>(_postInvoke),
};
foreach (var item in type.Methods)
{
_methodBuilder.Create(item, input);
}
var proxyType = type.ProxyType.CreateTypeInfo();
result = new ProxyInfo<TAbstract>(
concreteType,
abstractType,
proxyType,
uniquePostfix,
proxyType.GetConstructors()
);
_cache.Add(uniquePostfix, result);
#if (!NETSTANDARD2_0)
_builder.Save(DynamicAssemblyName + ".dll");
#endif
}
}
LockExecuteRelease(Create);
return (ProxyInfo<TAbstract>)result;
}
private static void LockExecuteRelease(Action exec)
{
try
{
BuildersSlimLock.EnterWriteLock();
exec();
}
catch (Exception e)
{
}
finally
{
BuildersSlimLock.ExitWriteLock();
}
}
private static void CreateBuilders()
{
if (_builder == null)
{
#if (!NETSTANDARD2_0)
_builder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(DynamicAssemblyName), AssemblyBuilderAccess.RunAndSave);
_moduleBuilder = _builder.DefineDynamicModule(DynamicModuleName, DynamicAssemblyName + ".mod", true);
#else
var access = AssemblyBuilderAccess.Run;
_builder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(DynamicAssemblyName), AssemblyBuilderAccess.Run);
_moduleBuilder = _builder.DefineDynamicModule(DynamicModuleName);
#endif
}
}
private static void CreateDefault()
{
if (_default == null)
{
_default = new ProxyFactory(new ProxyTypeBuilder(), new ProxyMethodBuilder());
}
}
}
}
| 36.72 | 155 | 0.580299 | [
"MIT"
] | RomanKernSW/Study.DynamicProxy | FastProxy/ProxyFactory.cs | 6,428 | C# |
// Copyright 2022 Google LLC
//
// 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
//
// 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.
// Generated code. DO NOT EDIT!
namespace Google.Cloud.Dialogflow.Cx.V3.Snippets
{
// [START dialogflow_v3_generated_TestCases_BatchDeleteTestCases_sync_flattened_resourceNames]
using Google.Cloud.Dialogflow.Cx.V3;
public sealed partial class GeneratedTestCasesClientSnippets
{
/// <summary>Snippet for BatchDeleteTestCases</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void BatchDeleteTestCasesResourceNames()
{
// Create client
TestCasesClient testCasesClient = TestCasesClient.Create();
// Initialize request argument(s)
AgentName parent = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]");
// Make the request
testCasesClient.BatchDeleteTestCases(parent);
}
}
// [END dialogflow_v3_generated_TestCases_BatchDeleteTestCases_sync_flattened_resourceNames]
}
| 40.902439 | 104 | 0.710197 | [
"Apache-2.0"
] | AlexandrTrf/google-cloud-dotnet | apis/Google.Cloud.Dialogflow.Cx.V3/Google.Cloud.Dialogflow.Cx.V3.GeneratedSnippets/TestCasesClient.BatchDeleteTestCasesResourceNamesSnippet.g.cs | 1,677 | C# |
using NServiceBus;
namespace Messages
{
public class OrderBilled :
IEvent
{
public string OrderId { get; set; }
}
} | 15.4 | 44 | 0.558442 | [
"Apache-2.0"
] | A-Franklin/docs.particular.net | tutorials/nservicebus-101/lesson-4/Solution/Messages/OrderBilled.cs | 147 | C# |
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace WebSocketSharp
{
public abstract class WebSocketHandler
{
protected readonly WebSocketDictionary Sockets;
private readonly int bufferLength = 4 * 1024;
// TODO: should we add a cancellation token?
//private readonly CancellationToken cancellationToken = new CancellationToken();
protected WebSocketHandler(WebSocketDictionary sockets)
{
Sockets = sockets;
}
/// <summary>
/// Connect to the WebSocket.
/// </summary>
/// <param name="socketId"></param>
/// <param name="socket"></param>
/// <returns></returns>
/// <remarks>
/// The socket must be opened before.
/// </remarks>
public Task ConnectAsync(string socketId, WebSocket socket)
{
if (socket.State != WebSocketState.Open)
throw new Exception("The socket must be opened before calling this method.");
Sockets.Add(socketId, socket);
return OnOpenAsync(new WebSocketEventArgs(socketId, socket));
}
public async Task CloseAsync(string socketId, string message = "Closing")
{
await Sockets[socketId].CloseAsync(WebSocketCloseStatus.NormalClosure, message, CancellationToken.None);
Sockets.Remove(socketId);
}
public virtual async Task OnOpenAsync(WebSocketEventArgs e) => await Task.CompletedTask;
public virtual async Task OnTextAsync(WebSocketEventArgs e, string text) => await Task.CompletedTask;
public virtual async Task OnBinaryAsync(WebSocketEventArgs e, byte[] buffer) => await Task.CompletedTask;
public virtual async Task OnCloseAsync(WebSocketEventArgs e) => await Task.CompletedTask;
// TODO: call it when necessary.
public virtual async Task OnErrorAsync(WebSocketErrorEventArgs e) => await Task.CompletedTask;
public Task SendAsync(string socketId, string message)
{
return SendAsync(Sockets[socketId], Encoding.UTF8.GetBytes(message), WebSocketMessageType.Text);
}
public Task SendAsync(string socketId, byte[] buffer)
{
return SendAsync(Sockets[socketId], buffer, WebSocketMessageType.Binary);
}
public Task SendAsync(IEnumerable<string> sockets, string message)
{
return Task.WhenAll(sockets.Select(socketId => SendAsync(socketId, message)).ToList());
}
public Task SendAsync(IEnumerable<string> sockets, byte[] buffer)
{
return Task.WhenAll(sockets.Select(socketId => SendAsync(socketId, buffer)).ToList());
}
public Task SendToAllAsync(string message)
{
return Task.WhenAll(Sockets.Select(kvp => SendAsync(kvp.Key, message)).ToList());
}
public Task SendToAllAsync(byte[] buffer)
{
return Task.WhenAll(Sockets.Select(kvp => SendAsync(kvp.Key, buffer)).ToList());
}
private async Task SendAsync(WebSocket socket, byte[] message, WebSocketMessageType type)
{
if (socket.State != WebSocketState.Open)
return;
for (var offset = 0; offset < message.Length; offset += bufferLength)
{
var remainingBuffer = message.Length - offset;
var buffer = new ArraySegment<byte>(message, offset, Math.Min(bufferLength, remainingBuffer));
var isLastLoop = offset + bufferLength >= message.Length;
await socket.SendAsync(buffer, type, isLastLoop, CancellationToken.None);
}
}
public async Task ReceiveLoopAsync(string socketId, WebSocket socket)
{
var memoryStream = new MemoryStream();
var buffer = new byte[bufferLength];
var segment = new ArraySegment<byte>(buffer);
do
{
WebSocketReceiveResult result;
memoryStream.Position = 0;
do
{
result = await socket.ReceiveAsync(segment, CancellationToken.None);
await memoryStream.WriteAsync(buffer, 0, result.Count);
} while (!result.EndOfMessage);
switch (result.MessageType)
{
case WebSocketMessageType.Text:
var str = Encoding.UTF8.GetString(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
await OnTextAsync(new WebSocketEventArgs(socketId, socket), str);
break;
case WebSocketMessageType.Binary:
await OnBinaryAsync(new WebSocketEventArgs(socketId, socket), memoryStream.ToArray());
break;
case WebSocketMessageType.Close:
if (socket.State == WebSocketState.CloseReceived)
{
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None);
}
await OnCloseAsync(new WebSocketEventArgs(socketId, socket));
break;
}
} while (socket.State == WebSocketState.Open);
}
}
}
| 39.357143 | 123 | 0.6 | [
"MIT"
] | angedelamort/web-socket-sharp | WebSocketSharp/WebSocketHandler.cs | 5,512 | C# |
using StackExchange.Exceptional.Internal;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
namespace StackExchange.Exceptional
{
/// <summary>
/// Extensions methods for <see cref="Exception"/>s.
/// </summary>
public static partial class Extensions
{
/// <summary>
/// For logging an exception with no HttpContext, most commonly used in non-web applications
/// so that they don't have to carry a reference to System.Web.
/// </summary>
/// <param name="ex">The exception to log.</param>
/// <param name="category">The category to associate with this exception.</param>
/// <param name="rollupPerServer">Whether to log up per-server, e.g. errors are only duplicates if they have same stack on the same machine.</param>
/// <param name="customData">Any custom data to store with the exception like UserId, etc...this will be rendered as JSON in the error view for script use.</param>
/// <param name="applicationName">If specified, the application name to log with, if not specified the name in <see cref="ErrorStoreSettings.ApplicationName"/> is used.</param>
public static Error LogNoContext(
this Exception ex,
string category = null,
bool rollupPerServer = false,
Dictionary<string, string> customData = null,
string applicationName = null)
{
try
{
// If we should be ignoring this exception, skip it entirely.
// Otherwise create the error itself, populating CustomData with what was passed-in.
var error = ex.GetErrorIfNotIgnored(Statics.Settings, category, applicationName, rollupPerServer, customData);
if (error?.LogToStore() == true)
{
return error;
}
}
catch (Exception e)
{
Statics.Settings?.OnLogFailure?.Invoke(e);
Trace.WriteLine(e);
}
return null;
}
/// <summary>
/// For logging an exception with no HttpContext asynchronously, most commonly used in non-web applications
/// so that they don't have to carry a reference to System.Web.
/// </summary>
/// <param name="ex">The exception to log.</param>
/// <param name="category">The category to associate with this exception.</param>
/// <param name="rollupPerServer">Whether to log up per-server, e.g. errors are only duplicates if they have same stack on the same machine.</param>
/// <param name="customData">Any custom data to store with the exception like UserId, etc...this will be rendered as JSON in the error view for script use.</param>
/// <param name="applicationName">If specified, the application name to log with, if not specified the name in <see cref="ErrorStoreSettings.ApplicationName"/> is used.</param>
public static Task<Error> LogNoContextAsync(
this Exception ex,
string category = null,
bool rollupPerServer = false,
Dictionary<string, string> customData = null,
string applicationName = null)
{
try
{
// If we should be ignoring this exception, skip it entirely.
// Otherwise create the error itself, populating CustomData with what was passed-in.
var error = ex.GetErrorIfNotIgnored(Statics.Settings, category, applicationName, rollupPerServer, customData);
if (error != null)
{
return LogToStoreAsync(error);
}
}
catch (Exception e)
{
Statics.Settings?.OnLogFailure?.Invoke(e);
Trace.WriteLine(e);
}
return Task.FromResult<Error>(null);
}
/// <summary>
/// Adds a key/value pair for logging to an exception, one that'll appear in exceptional
/// </summary>
/// <typeparam name="T">The specific type of exception (for return type chaining).</typeparam>
/// <param name="ex">The exception itself.</param>
/// <param name="key">The key to add to the exception data.</param>
/// <param name="value">The value to add to the exception data.</param>
public static T AddLogData<T>(this T ex, string key, string value) where T : Exception
{
ex.Data[Constants.CustomDataKeyPrefix + key] = value ?? string.Empty;
return ex;
}
/// <summary>
/// Adds a key/value pair for logging to an exception, one that'll appear in exceptional
/// </summary>
/// <typeparam name="T">The specific type of exception (for return type chaining).</typeparam>
/// <param name="ex">The exception itself.</param>
/// <param name="key">The key to add to the exception data.</param>
/// <param name="value">The value to add to the exception data.</param>
public static T AddLogData<T>(this T ex, string key, object value) where T : Exception => AddLogData(ex, key, value?.ToString());
private static async Task<Error> LogToStoreAsync(Error error)
{
if (await error.LogToStoreAsync().ConfigureAwait(false))
{
return error;
}
return null;
}
}
}
| 47.603448 | 184 | 0.60105 | [
"Apache-2.0",
"MIT"
] | NickCraver/StackExchange.Exceptional | src/StackExchange.Exceptional.Shared/Extensions.cs | 5,524 | C# |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Poseidon.Winform.Core
{
using Poseidon.Core.DL;
using Poseidon.Winform.Base;
/// <summary>
/// 设施表格控件
/// </summary>
public partial class FacilityGrid : WinEntityGrid<Facility>
{
#region Field
/// <summary>
/// 是否显示复选框
/// </summary>
private bool enableMultiCheckSelect = false;
#endregion //Field
#region Constructor
public FacilityGrid()
{
InitializeComponent();
}
#endregion //Constructor
#region Method
/// <summary>
/// 获取选中行
/// </summary>
/// <returns></returns>
public List<Facility> GetSelectedRows()
{
List<Facility> data = new List<Facility>();
int[] rowIndex = this.dgvEntity.GetSelectedRows();
for (int i = 0; i < rowIndex.Length; i++)
{
var row = this.dgvEntity.GetRow(rowIndex[i]) as Facility;
data.Add(row);
}
return data;
}
#endregion //Method
#region Event
/// <summary>
/// 控件载入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FacilityGrid_Load(object sender, EventArgs e)
{
this.dgvEntity.OptionsSelection.MultiSelect = this.enableMultiCheckSelect;
if (this.enableMultiCheckSelect)
this.dgvEntity.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
}
#endregion //Event
#region Property
/// <summary>
/// 是否能多选
/// </summary>
[Category("功能"), Description("是否能多选"), Browsable(true)]
public bool EnableMultiCheckSelect
{
get
{
return this.enableMultiCheckSelect;
}
set
{
this.enableMultiCheckSelect = value;
}
}
#endregion //Property
}
}
| 25.730337 | 135 | 0.544105 | [
"MIT"
] | robertzml/Poseidon.Winform | Poseidon.Winform.Core/Control/FacilityGrid.cs | 2,360 | C# |
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Org.Apache.REEF.Utilities.Diagnostics;
using Org.Apache.REEF.Utilities.Logging;
using Org.Apache.REEF.Wake.Time.Runtime.Event;
namespace Org.Apache.REEF.Wake.Util
{
public class FixedThreadPoolTaskService : ITaskService
{
private static readonly Logger LOGGER = Logger.GetLogger(typeof(FixedThreadPoolTaskService));
TaskFactory factory;
List<Task> tasks = new List<Task>();
bool shuttingDown;
internal FixedThreadPoolTaskService(int maxDegreeOfParallelism)
{
LimitedConcurrencyLevelTaskScheduler lcts = new LimitedConcurrencyLevelTaskScheduler(maxDegreeOfParallelism);
factory = new TaskFactory(lcts);
}
public bool AwaitTermination(long n, TimeSpan unit)
{
Task[] allTasks;
lock (tasks)
{
if (tasks.Count == 0)
{
return true;
}
allTasks = tasks.ToArray();
}
return Task.WaitAll(allTasks, unit);
}
public void ShutdownNow()
{
Shutdown();
}
public void Shutdown()
{
lock (tasks)
{
shuttingDown = true;
}
}
public Task<T> Submit<T>(Func<T> c)
{
Task<T> task = null;
lock (tasks)
{
if (shuttingDown)
{
Exceptions.Throw(new InvalidOperationException("Shutting down"), LOGGER);
}
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
CancellationToken cancellationToken = cancellationTokenSource.Token;
task = factory.StartNew(c, cancellationToken);
tasks.Add(task);
}
return task;
}
public void Execute(ThreadStart threadStart)
{
new Actionable(threadStart).Call();
}
internal void RemoveTask(Task task)
{
lock (tasks)
{
tasks.Remove(task);
}
}
}
}
| 30.150943 | 121 | 0.587297 | [
"Apache-2.0"
] | tmajest/incubator-reef | lang/cs/Org.Apache.REEF.Wake/Util/FixedThreadPoolTaskService.cs | 3,198 | C# |
namespace $safeprojectname$
{
/// <summary>
/// Partial class extending the User type that adds shared properties and methods.
/// These properties and methods will be available both to the server app and the client app.
/// </summary>
public partial class User
{
/// <summary>
/// Returns the user display name, which by default is its FriendlyName.
/// If FriendlyName is not set, the User Name is returned.
/// </summary>
public string DisplayName
{
get
{
if (!string.IsNullOrEmpty(this.FriendlyName))
{
return this.FriendlyName;
}
else
{
return this.Name;
}
}
}
}
}
| 28.517241 | 97 | 0.501814 | [
"Apache-2.0"
] | Daniel-Svensson/OpenRiaServices | src/VisualStudio/Templates/CSharp/BusinessApplication/BA.Web/Models/Shared/User.shared.cs | 829 | C# |
namespace Kokugen.Core.Events
{
public interface IHandler
{
}
} | 12 | 29 | 0.583333 | [
"Apache-2.0"
] | ryankelley/kokugen | src/kokugen.core/Events/IHandler.cs | 84 | 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.Inputs
{
/// <summary>
/// The private link service ip configuration.
/// </summary>
public sealed class PrivateLinkServiceIpConfigurationArgs : Pulumi.ResourceArgs
{
/// <summary>
/// Resource ID.
/// </summary>
[Input("id")]
public Input<string>? Id { get; set; }
/// <summary>
/// The name of private link service ip configuration.
/// </summary>
[Input("name")]
public Input<string>? Name { get; set; }
/// <summary>
/// Whether the ip configuration is primary or not.
/// </summary>
[Input("primary")]
public Input<bool>? Primary { get; set; }
/// <summary>
/// The private IP address of the IP configuration.
/// </summary>
[Input("privateIPAddress")]
public Input<string>? PrivateIPAddress { get; set; }
/// <summary>
/// Whether the specific IP configuration is IPv4 or IPv6. Default is IPv4.
/// </summary>
[Input("privateIPAddressVersion")]
public InputUnion<string, Pulumi.AzureNative.Network.IPVersion>? PrivateIPAddressVersion { get; set; }
/// <summary>
/// The private IP address allocation method.
/// </summary>
[Input("privateIPAllocationMethod")]
public InputUnion<string, Pulumi.AzureNative.Network.IPAllocationMethod>? PrivateIPAllocationMethod { get; set; }
/// <summary>
/// The reference to the subnet resource.
/// </summary>
[Input("subnet")]
public Input<Inputs.SubnetArgs>? Subnet { get; set; }
public PrivateLinkServiceIpConfigurationArgs()
{
}
}
}
| 31.538462 | 121 | 0.602927 | [
"Apache-2.0"
] | polivbr/pulumi-azure-native | sdk/dotnet/Network/Inputs/PrivateLinkServiceIpConfigurationArgs.cs | 2,050 | C# |
Subsets and Splits