本文整理汇总了C#中OpenFlags类的典型用法代码示例。如果您正苦于以下问题:C# OpenFlags类的具体用法?C# OpenFlags怎么用?C# OpenFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OpenFlags类属于命名空间,在下文中一共展示了OpenFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Open
/// <summary>
/// Open
/// </summary>
/// <param name="flags">
/// A <see cref="OpenFlags"/>
/// </param>
/// <param name="readTimeoutMilliseconds">
/// A <see cref="System.Int32"/>
/// </param>
/// <param name="remoteAuthentication">
/// A <see cref="RemoteAuthentication"/>
/// </param>
public void Open(OpenFlags flags,
int readTimeoutMilliseconds,
RemoteAuthentication remoteAuthentication) {
if (!Opened) {
var errbuf = new StringBuilder(Pcap.PCAP_ERRBUF_SIZE); //will hold errors
IntPtr rmAuthPointer;
if (remoteAuthentication == null)
rmAuthPointer = IntPtr.Zero;
else
rmAuthPointer = remoteAuthentication.GetUnmanaged();
PcapHandle = SafeNativeMethods.pcap_open(Name,
Pcap.MAX_PACKET_SIZE, // portion of the packet to capture.
(int)flags,
readTimeoutMilliseconds,
rmAuthPointer,
errbuf);
if (rmAuthPointer != IntPtr.Zero)
Marshal.FreeHGlobal(rmAuthPointer);
if (PcapHandle == IntPtr.Zero) {
string err = "Unable to open the adapter (" + Name + "). " + errbuf.ToString();
throw new PcapException(err);
}
}
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:40,代码来源:WinPcapDevice.cs
示例2: Open
public UnixStream Open (OpenFlags flags)
{
int fd = Syscall.open (FullPath, flags);
if (fd < 0)
UnixMarshal.ThrowExceptionForLastError ();
return new UnixStream (fd);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:UnixFileInfo.cs
示例3: open
// fd, error
public static void open(string path, OpenFlags flags, Mono.Unix.Native.FilePermissions mode, Action<FileStream, Exception> callback)
{
ThreadPool.QueueUserWorkItem(a =>
{
try
{
FileMode fm;
FileAccess fa;
FileShare fs = FileShare.ReadWrite;
if (0 != (flags & OpenFlags.O_CREAT))
fm = FileMode.Create;
else
fm = FileMode.Open;
if (0 != (flags & OpenFlags.O_RDWR))
fa = FileAccess.ReadWrite;
else if (0 != (flags & OpenFlags.O_WRONLY))
fa = FileAccess.Write;
else
fa = FileAccess.Read;
var stream = new FileStream(path, fm, fa, fs);
Boundary.Instance.ExecuteOnTargetLoop (() => callback (stream, null));
}
catch(Exception e)
{
Boundary.Instance.ExecuteOnTargetLoop (() => callback (null, e));
}
});
}
开发者ID:aaronfeng,项目名称:manos,代码行数:32,代码来源:Libeio.cs
示例4: DoStoreOp
private static void DoStoreOp(StoreLocation location, OpenFlags flags, Action<X509Store> op)
{
var store = new X509Store(StoreName.My, location);
using (new StoreOpener(store, flags))
{
op(store);
}
}
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:8,代码来源:WindowsAzureCertificate.cs
示例5: OpenStore
private void OpenStore(OpenFlags openFlags) {
try {
_storeWrapper.Open(_storeName, _storeLocation, openFlags);
}
catch (SecurityException securityException) {
throw new CertificateException(_storeName, _storeLocation, securityException);
}
catch (CryptographicException cryptographicException) {
throw new CertificateException("open", _storeName, _storeLocation, cryptographicException);
}
}
开发者ID:amido,项目名称:CertificateRepository,代码行数:11,代码来源:CertificateRepository.cs
示例6: Open
public static FileStream Open(Context context, string fileName, int blockSize,
OpenFlags openFlags)
{
var fd = Syscall.open (fileName, openFlags,
FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IROTH);
var mask = OpenFlags.O_RDONLY | OpenFlags.O_RDWR | OpenFlags.O_WRONLY;
var canRead = (openFlags & mask) == OpenFlags.O_RDONLY
|| (openFlags & mask) == OpenFlags.O_RDWR;
var canWrite = (openFlags & mask) == OpenFlags.O_WRONLY
|| (openFlags & mask) == OpenFlags.O_RDWR;
return new FileStream (context, new IntPtr (fd), blockSize, canRead, canWrite);
}
开发者ID:rfantozzi,项目名称:manos,代码行数:12,代码来源:FileStream.cs
示例7: FromSystemStore
public static IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags)
{
CertStoreFlags certStoreFlags = MapX509StoreFlags(storeLocation, openFlags);
SafeCertStoreHandle certStore = Interop.crypt32.CertOpenStore(CertStoreProvider.CERT_STORE_PROV_SYSTEM_W, CertEncodingType.All, IntPtr.Zero, certStoreFlags, storeName);
if (certStore.IsInvalid)
throw Marshal.GetLastWin32Error().ToCryptographicException();
//
// We want the store to auto-resync when requesting a snapshot so that
// updates to the store will be taken into account.
//
// For compat with desktop, ignoring any failures from this call. (It is pretty unlikely to fail, in any case.)
//
bool ignore = Interop.crypt32.CertControlStore(certStore, CertControlStoreFlags.None, CertControlStoreType.CERT_STORE_CTRL_AUTO_RESYNC, IntPtr.Zero);
return new StorePal(certStore);
}
开发者ID:dotnet,项目名称:corefx,代码行数:18,代码来源:StorePal.Import.cs
示例8: Open
public void Open(OpenFlags openFlags)
{
DiagnosticUtility.DebugAssert(this.certStoreHandle.IsInvalid, "");
uint dwOpenFlags = MapX509StoreFlags(this.storeLocation, openFlags);
SafeCertStoreHandle certStoreHandle = CAPI.CertOpenStore(new IntPtr(CAPI.CERT_STORE_PROV_SYSTEM),
CAPI.X509_ASN_ENCODING | CAPI.PKCS_7_ASN_ENCODING,
IntPtr.Zero,
dwOpenFlags,
this.storeName);
if (certStoreHandle == null || certStoreHandle.IsInvalid)
{
int error = Marshal.GetLastWin32Error();
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(error));
}
this.certStoreHandle = certStoreHandle;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:18,代码来源:X509CertificateStore.cs
示例9: FromSystemStore
public static IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags)
{
if (storeLocation != StoreLocation.LocalMachine)
{
// TODO (#2206): Support CurrentUser persisted stores.
throw new NotImplementedException();
}
if (openFlags.HasFlag(OpenFlags.ReadWrite))
{
// TODO (#2206): Support CurrentUser persisted stores
// (they'd not be very useful without the ability to add/remove content)
throw new NotImplementedException();
}
// The static store approach here is making an optimization based on not
// having write support. Once writing is permitted the stores would need
// to fresh-read whenever being requested (or use FileWatcher/etc).
if (s_machineRootStore == null)
{
lock (s_machineIntermediateStore)
{
if (s_machineRootStore == null)
{
LoadMachineStores();
}
}
}
if (StringComparer.Ordinal.Equals("Root", storeName))
{
return CloneStore(s_machineRootStore);
}
if (StringComparer.Ordinal.Equals("CA", storeName))
{
return CloneStore(s_machineIntermediateStore);
}
// TODO (#2207): Support the rest of the stores, or throw PlatformNotSupportedException.
throw new NotImplementedException();
}
开发者ID:GreenDamTan,项目名称:corefx,代码行数:42,代码来源:StorePal.cs
示例10: DirectoryBasedStoreProvider
internal DirectoryBasedStoreProvider(string storeName, OpenFlags openFlags)
{
if (string.IsNullOrEmpty(storeName))
{
throw new CryptographicException(SR.Arg_EmptyOrNullString);
}
string directoryName = GetDirectoryName(storeName);
if (s_userStoreRoot == null)
{
// Do this here instead of a static field initializer so that
// the static initializer isn't capable of throwing the "home directory not found"
// exception.
s_userStoreRoot = PersistedFiles.GetUserFeatureDirectory(
X509Persistence.CryptographyFeatureName,
X509Persistence.X509StoresSubFeatureName);
}
_storePath = Path.Combine(s_userStoreRoot, directoryName);
if (0 != (openFlags & OpenFlags.OpenExistingOnly))
{
if (!Directory.Exists(_storePath))
{
throw new CryptographicException(SR.Cryptography_X509_StoreNotFound);
}
}
// ReadOnly is 0x00, so it is implicit unless either ReadWrite or MaxAllowed
// was requested.
OpenFlags writeFlags = openFlags & (OpenFlags.ReadWrite | OpenFlags.MaxAllowed);
if (writeFlags == OpenFlags.ReadOnly)
{
_readOnly = true;
}
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:38,代码来源:DirectoryBasedStoreProvider.cs
示例11: MapX509StoreFlags
// this method maps X509Store OpenFlags to a combination of crypto API flags
internal static uint MapX509StoreFlags (StoreLocation storeLocation, OpenFlags flags) {
uint dwFlags = 0;
uint openMode = ((uint)flags) & 0x3;
switch (openMode) {
case (uint) OpenFlags.ReadOnly:
dwFlags |= CAPI.CERT_STORE_READONLY_FLAG;
break;
case (uint) OpenFlags.MaxAllowed:
dwFlags |= CAPI.CERT_STORE_MAXIMUM_ALLOWED_FLAG;
break;
}
if ((flags & OpenFlags.OpenExistingOnly) == OpenFlags.OpenExistingOnly)
dwFlags |= CAPI.CERT_STORE_OPEN_EXISTING_FLAG;
if ((flags & OpenFlags.IncludeArchived) == OpenFlags.IncludeArchived)
dwFlags |= CAPI.CERT_STORE_ENUM_ARCHIVED_FLAG;
if (storeLocation == StoreLocation.LocalMachine)
dwFlags |= CAPI.CERT_SYSTEM_STORE_LOCAL_MACHINE;
else if (storeLocation == StoreLocation.CurrentUser)
dwFlags |= CAPI.CERT_SYSTEM_STORE_CURRENT_USER;
return dwFlags;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:x509utils.cs
示例12: Open
public void Open (OpenFlags flags)
{
if (String.IsNullOrEmpty (_name))
throw new CryptographicException (Locale.GetText ("Invalid store name (null or empty)."));
/* keep existing Mono installations (pre 2.0) compatible with new stuff */
string name;
switch (_name) {
case "Root":
name = "Trust";
break;
default:
name = _name;
break;
}
bool create = ((flags & OpenFlags.OpenExistingOnly) != OpenFlags.OpenExistingOnly);
store = Factory.Open (name, create);
if (store == null)
throw new CryptographicException (Locale.GetText ("Store {0} doesn't exists.", _name));
_flags = flags;
foreach (MX.X509Certificate x in store.Certificates) {
Certificates.Add (new X509Certificate2 (x.RawData));
}
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:X509Store.cs
示例13: CertificateStore
public CertificateStore (OpenFlags flags, StoreName name, StoreLocation location)
{
_store = new X509Store(name, location);
_store.Open(flags);
}
开发者ID:jmaxxz,项目名称:Jmaxxz.X509,代码行数:5,代码来源:CertificateStore.cs
示例14: CreateOpenRequest
/// <summary>
/// Create a open request packet for client to open a share on server.
/// </summary>
/// <param name = "messageId">the id of message, used to identity the request and the server response. </param>
/// <param name = "sessionUid">the valid session id, must be response by server of the session setup request. </param>
/// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param>
/// <param name = "flags">
/// The Flags field contains individual flags, as specified in [CIFS] sections 2.4.2 and 3.1.1.
/// </param>
/// <param name = "flags2">
/// The Flags2 field contains individual bit flags that, depending on the negotiated SMB dialect, indicate
/// various client and server capabilities.
/// </param>
/// <param name = "shareName">the file name to open </param>
/// <param name = "fileOpenMode">file open mode </param>
/// <param name = "fileOpenFunction">
/// A 16-bit field that controls the way a file SHOULD be treated when it is opened for use by certain
/// extended SMB requests.
/// </param>
/// <param name = "extFileAttributes">the extend file attributes </param>
/// <param name = "extSearchAttributes">the search attributes of file </param>
/// <param name = "allocationSize">Bytes to reserve on create or truncate </param>
/// <param name = "openFlags">A 16-bit field of flags for requesting attribute data and locking </param>
/// <returns>a open request packet </returns>
private SmbOpenAndxRequestPacket CreateOpenRequest(
ushort messageId,
ushort sessionUid,
ushort treeId,
SmbHeader_Flags_Values flags,
SmbHeader_Flags2_Values flags2,
string shareName,
AccessMode fileOpenMode,
OpenMode fileOpenFunction,
SmbFileAttributes extFileAttributes,
SmbFileAttributes extSearchAttributes,
uint allocationSize,
OpenFlags openFlags)
{
return new SmbOpenAndxRequestPacket(
this.cifsClient.CreateOpenAndxRequest(messageId, sessionUid, treeId,
(SmbFlags)flags, (SmbFlags2)flags2, (Flags)openFlags, fileOpenMode,
extSearchAttributes, extFileAttributes, new UTime(), fileOpenFunction,
allocationSize, this.capability.Timeout, shareName, null));
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:44,代码来源:SmbClient.cs
示例15: map_Mono_Posix_OpenFlags
internal static int map_Mono_Posix_OpenFlags (OpenFlags flags)
{
throw new System.NotImplementedException();
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:Syscall.Mosa.cs
示例16: eio_open
static extern IntPtr eio_open(string path, OpenFlags flags, mode_t mode, int pri, eio_cb cb, IntPtr data);
开发者ID:aaronfeng,项目名称:manos,代码行数:1,代码来源:Libeio.cs
示例17: open
public static int open(string pathname, OpenFlags flags, FileMode mode)
{
int posix_flags = map_Mono_Posix_OpenFlags (flags);
int posix_mode = map_Mono_Posix_FileMode (mode);
return syscall_open (pathname, posix_flags, posix_mode);
}
开发者ID:xxtbg,项目名称:coredroidservice,代码行数:7,代码来源:Syscall.cs
示例18: Parse
/// <summary>
/// Parse the RopLogonRequest structure.
/// </summary>
/// <param name="s">An stream containing RopLogonRequest structure.</param>
public override void Parse(Stream s)
{
base.Parse(s);
this.RopId = (RopIdType)ReadByte();
this.LogonId = ReadByte();
this.OutputHandleIndex = ReadByte();
this.LogonFlags = (LogonFlags)ReadByte();
this.OpenFlags = (OpenFlags)ReadUint();
this.StoreState = ReadUint();
this.EssdnSize = ReadUshort();
if (this.EssdnSize > 0)
{
this.Essdn = new MAPIString(Encoding.ASCII);
this.Essdn.Parse(s);
}
}
开发者ID:OfficeDev,项目名称:Office-Inspectors-for-Fiddler,代码行数:21,代码来源:MSOXCSTOR.cs
示例19: StoreOpener
public StoreOpener(X509Store store, OpenFlags openFlags)
{
store.Open(openFlags);
this.store = store;
}
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:5,代码来源:WindowsAzureCertificate.cs
示例20: Open
public void Open(OpenFlags flags);
开发者ID:ajit2936,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.Cryptography.X509Certificates.cs
注:本文中的OpenFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论