-
Notifications
You must be signed in to change notification settings - Fork 397
/
StringResult.cs
41 lines (35 loc) · 1.58 KB
/
StringResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------
namespace System.Fabric.Interop
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Fabric.Common;
using SecureString = System.Security.SecureString;
// TODO: evaluate whether we should have an explicit callback to Dispose, or if we should copy to HGLOBAL?
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.TypesThatOwnDisposableFieldsShouldBeDisposable,
Justification = "Interop class to be obsoleted after Windows Fabric transition.")]
internal class StringResult : NativeCommon.IFabricStringResult
{
private IPinNode pin;
public StringResult(string s)
{
this.pin = new PinBlittable(s);
}
public static string FromNative(NativeCommon.IFabricStringResult nativeResult)
{
return NativeTypes.FromNativeString(nativeResult);
}
public static SecureString FromNativeToSecureString(NativeCommon.IFabricStringResult nativeResult)
{
return NativeTypes.FromNativeToSecureString(nativeResult);
}
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Matches native API.")]
public IntPtr get_String()
{
return this.pin.AddrOfPinnedObject();
}
}
}