本文整理汇总了C#中Options.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# Options.HasFlag方法的具体用法?C# Options.HasFlag怎么用?C# Options.HasFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options.HasFlag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public static IContainer Build(Options options, params object[] singletons)
{
var builder = new ContainerBuilder();
if (options.HasFlag(Options.ResolveDialogFromContainer))
{
builder.RegisterModule(new DialogModule());
}
else
{
builder.RegisterModule(new DialogModule_MakeRoot());
}
builder
.Register(c => new BotIdResolver("testBot"))
.As<IBotIdResolver>()
.SingleInstance();
builder
.Register((c, p) => mockConnectorFactory)
.As<IConnectorClientFactory>()
.InstancePerLifetimeScope();
if (options.HasFlag(Options.Reflection))
{
builder.RegisterModule(new ReflectionSurrogateModule());
}
var r =
builder
.Register<Queue<IMessageActivity>>(c => new Queue<IMessageActivity>())
.AsSelf();
if (options.HasFlag(Options.ScopedQueue))
{
r.InstancePerLifetimeScope();
}
else
{
r.SingleInstance();
}
builder
.RegisterType<BotToUserQueue>()
.AsSelf()
.As<IBotToUser>()
.InstancePerLifetimeScope();
foreach (var singleton in singletons)
{
builder
.Register(c => singleton)
.Keyed(FiberModule.Key_DoNotSerialize, singleton.GetType());
}
return builder.Build();
}
示例2: FixOptions
private static Options FixOptions(Options options)
{
//make sure we're closing streams with fileinfo
if (options.HasFlag(Options.KeepStreamsOpen))
{
options = (Options) FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
}
return options;
}
示例3: VerifySearchCodeResponse
private static void VerifySearchCodeResponse(
ITypedRequestProcessProxy server,
string searchPattern,
Options options,
DirectoryInfo chromiumDirectory,
int occurrenceCount,
params int[] positionsAndLengths) {
var response = SendRequest<SearchCodeResponse>(server, new SearchCodeRequest {
SearchParams = new SearchParams {
SearchString = searchPattern,
MaxResults = 2000,
MatchCase = options.HasFlag(Options.MatchCase),
Regex = options.HasFlag(Options.Regex),
}
}, ServerResponseTimeout)();
Assert.IsNotNull(response, "Server did not respond within timeout.");
Assert.IsNotNull(response.SearchResults);
Assert.IsNotNull(response.SearchResults.Entries);
Assert.AreEqual(1, response.SearchResults.Entries.Count);
var chromiumEntry = response.SearchResults.Entries[0] as DirectoryEntry;
Assert.IsNotNull(chromiumEntry);
Assert.AreEqual(chromiumDirectory.FullName, chromiumEntry.Name);
chromiumEntry.Entries.ForAll((index, x) => {
Debug.WriteLine(string.Format("File name: \"{0}\"", x.Name));
Assert.IsNotNull(x.Data);
Assert.IsTrue(x.Data is FilePositionsData);
((FilePositionsData)x.Data).Positions.ForEach(y => {
Debug.WriteLine(string.Format(" Text position: offset={0}, length={1}, text={2}", y.Position, y.Length, ExtractFileText(chromiumEntry, x, y)));
if (positionsAndLengths != null && positionsAndLengths.Length > 0) {
Assert.AreEqual(positionsAndLengths[index * 2], y.Position);
Assert.AreEqual(positionsAndLengths[(index * 2) + 1], y.Length);
}
});
});
Assert.AreEqual(occurrenceCount, chromiumEntry.Entries.Count);
}
示例4: RarReaderVolume
internal RarReaderVolume(Stream stream, Options options)
: base(StreamingMode.Streaming, options)
{
this.stream = stream;
this.streamOwner = !options.HasFlag(Options.KeepStreamsOpen);
}
示例5: StreamRarArchiveVolume
internal StreamRarArchiveVolume(Stream stream, Options options)
: base(StreamingMode.Seekable, options)
{
this.stream = stream;
this.streamOwner = !options.HasFlag(Options.KeepStreamsOpen);
}
示例6: Build
public static IContainer Build(Options options, MockConnectorFactory mockConnectorFactory, params object[] singletons)
{
var builder = new ContainerBuilder();
builder.RegisterModule(new DialogModule_MakeRoot());
builder
.Register((c, p) => mockConnectorFactory)
.As<IConnectorClientFactory>()
.InstancePerLifetimeScope();
builder
.Register(c => new BotIdResolver("testBot"))
.As<IBotIdResolver>()
.SingleInstance();
var r =
builder
.Register<Queue<IMessageActivity>>(c => new Queue<IMessageActivity>())
.AsSelf()
.InstancePerLifetimeScope();
builder
.RegisterType<BotToUserQueue>()
.AsSelf()
.As<IBotToUser>()
.InstancePerLifetimeScope();
if (options.HasFlag(Options.InMemoryBotDataStore))
{
//Note: memory store will be single instance for the bot
builder.RegisterType<InMemoryDataStore>()
.As<IBotDataStore<BotData>>()
.AsSelf()
.SingleInstance();
}
foreach (var singleton in singletons)
{
builder
.Register(c => singleton)
.Keyed(FiberModule.Key_DoNotSerialize, singleton.GetType());
}
return builder.Build();
}