本文整理汇总了C#中IPluginContext类的典型用法代码示例。如果您正苦于以下问题:C# IPluginContext类的具体用法?C# IPluginContext怎么用?C# IPluginContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPluginContext类属于命名空间,在下文中一共展示了IPluginContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessMessage
public void ProcessMessage(Message message, IPluginContext context, IJabbRClient client)
{
Guard.NullParameter(message, () => message);
Guard.NullParameter(context, () => context);
Guard.NullParameter(client, () => client);
foreach (var messageHandler in _messageHandlers)
{
Log.Trace("Applying handler: {0}", messageHandler.Name);
try
{
var result = messageHandler.Execute(message, context);
result.Execute(client, context.Room);
var continueProcessing = !result.IsHandled || messageHandler.ContinueProcessing;
if (!continueProcessing)
{
Log.Trace("Terminating message processing after: {0}.", messageHandler.Name);
break;
}
}
catch (Exception ex)
{
Log.ErrorException("Error applying handler: " + messageHandler.Name, ex);
}
}
}
开发者ID:CompileThis,项目名称:CompileThis.BawBag,代码行数:28,代码来源:PluginManager.cs
示例2: OptimizeDocumentIndexesIfRunning
public static void OptimizeDocumentIndexesIfRunning(this IDocumentIndexProvider documentIndexProvider, IPluginContext context, IActivityLogger logger)
{
foreach (IDocumentIndex documentIndex in GetDocumentIndexes(documentIndexProvider, context, runningOnly:true).Where(d => !d.IsOptimized))
{
documentIndex.Optimize(DocumentIndexOptimizeSetup.ImmediateOptimize);
}
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:7,代码来源:DocumentIndexProviderServices.cs
示例3: ExecuteCore
protected override MessageHandlerResult ExecuteCore(Message message, IPluginContext context)
{
if (context.IsBotAddressed
|| message.Type != MessageType.Default
|| context.RandomProvider.Next(2) == 0
|| !Matcher.IsMatch(message.Text))
{
return NotHandled();
}
var text = Matcher.Replace(
message.Text,
m =>
{
var capture = m.Captures[0].Value;
if (capture[0] == 'e')
{
return "s" + capture;
}
if (capture[1] == 'X')
{
return "SE" + capture.Substring(1);
}
return "Se" + capture.Substring(1);
});
return Handled(Message(text));
}
开发者ID:CompileThis,项目名称:CompileThis.BawBag,代码行数:30,代码来源:SexactlyHandler.cs
示例4: MashupInfoRepository
public MashupInfoRepository(ILogManager logManager, IPluginContext context, ITpBus bus, IMashupScriptStorage scriptStorage)
{
_bus = bus;
_scriptStorage = scriptStorage;
_log = logManager.GetLogger(GetType());
_context = context;
}
开发者ID:FarReachJason,项目名称:Target-Process-Plugins,代码行数:7,代码来源:MashupInfoRepository.cs
示例5: GetImage
private MessageHandlerResult GetImage(string query, IPluginContext context)
{
try
{
var bingContainer = new Bing.BingSearchContainer(new Uri(BingApiUri))
{
Credentials =
new NetworkCredential(BingApi, BingApi)
};
var imageQuery = bingContainer.Image(query, null, null, null, null, null, null);
var imageResults = imageQuery.Execute();
if (imageResults != null)
{
var imageList = imageResults.ToList();
if (imageList.Count > 0)
{
var index = context.RandomProvider.Next(imageList.Count);
var url = imageList[index].MediaUrl;
return this.Handled(this.Message(url));
}
}
var response = context.TextProcessor.FormatPluginResponse("Really? Do you kiss ${SOMEONE}'s mum with that mouth?", context);
return this.Handled(this.Message(response));
}
catch (Exception ex)
{
Log.ErrorException("Unable to search for images on bing.", ex);
return this.Handled(this.Message("Uh Oh..."));
}
}
开发者ID:CompileThis,项目名称:CompileThis.BawBag,代码行数:34,代码来源:ImageMeHandler.cs
示例6: ExecuteCore
protected override MessageHandlerResult ExecuteCore(Message message, IPluginContext context)
{
var match = Matcher.Match(message.Text);
if (!match.Success)
{
return NotHandled();
}
var values = new List<string>();
values.Add(match.Groups[1].Value.Trim());
values.AddRange(match.Groups[2].Captures.OfType<Capture>().Select(x => x.Value.Trim()));
var options = (from v in values
where v.Length > 0 && !v.Equals("or", StringComparison.InvariantCultureIgnoreCase)
select v).ToList();
if (options.Count == 0)
{
return Handled(Message("{0}: confuse BawBag, receive kicking...", context.User.Name), Kick());
}
var index = context.RandomProvider.Next(0, options.Count);
return Handled(Message("@{0}: {1}", context.User.Name, options[index]));
}
开发者ID:CompileThis,项目名称:CompileThis.BawBag,代码行数:25,代码来源:ChooseHandler.cs
示例7: MashupScriptStorage
public MashupScriptStorage(IPluginContext context, IMashupLocalFolder folder, ILogManager logManager, IMashupLoader mashupLoader)
{
_folder = folder;
_mashupLoader = mashupLoader;
_log = logManager.GetLogger(GetType());
_accountName = context.AccountName;
}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:7,代码来源:MashupScriptStorage.cs
示例8: Parse
public static PluginRunContext Parse(PluginConfigItem configItem, IPluginContext context)
{
string runContext = configItem.RunContext;
if (string.IsNullOrEmpty(runContext))
runContext = MainThread;
// on the same current thread
if (runContext == MainThread)
{
if (!Contexts.ContainsKey(runContext))
Contexts[runContext] = new PluginRunContext(configItem, context);
}
else if (runContext == NewThread)
{
if (!Contexts.ContainsKey(runContext))
// get a new thread
Contexts[runContext] = new MultiThreadPluginRunContext(configItem, context);
}
else if (runContext == NewProcess)
{
if (!Contexts.ContainsKey(runContext))
// get a new process
Contexts[runContext] = new MultiProcessPluginRunContext(configItem, context);
}
else if (runContext == NewAppDomain)
{
if (!Contexts.ContainsKey(runContext))
// get a new AppDomain
Contexts[runContext] = new MultiAppDomainPuginRunContext(configItem, context);
}
Contexts[runContext].ConfigItem = configItem;
Contexts[runContext].Context = context;
configItem.PluginRunContext = Contexts[runContext];
return Contexts[runContext];
}
开发者ID:nateliu,项目名称:StarSharp,代码行数:35,代码来源:PluginRunContext.cs
示例9: DoGetDocumentIndex
private Maybe<IDocumentIndex> DoGetDocumentIndex(IPluginContext context, DocumentIndexTypeToken documentIndexTypeToken)
{
Lazy<IDocumentIndex> fetched;
return _documentIndexes[documentIndexTypeToken].TryGetValue(context.AccountName.Value, out fetched)
? Maybe.Return(fetched.Value)
: Maybe.Nothing;
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:7,代码来源:DocumentIndexProvider.cs
示例10: BuildSearchIndexesCommand
public BuildSearchIndexesCommand(ITpBus bus, IProfileCollection profileCollection, IPluginContext pluginContext, IPluginMetadata pluginMetadata)
{
_bus = bus;
_profileCollection = profileCollection;
_pluginContext = pluginContext;
_pluginMetadata = pluginMetadata;
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:7,代码来源:BuildSearchIndexesCommand.cs
示例11: SetEnableForTp2
public SetEnableForTp2(IPluginContext pluginContext, IActivityLogger log, IProfileCollection profileCollection, ITpBus bus)
{
_pluginContext = pluginContext;
_log = log;
_profileCollection = profileCollection;
_bus = bus;
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:7,代码来源:SetEnableForTp2.cs
示例12: ExecuteCore
protected override MessageHandlerResult ExecuteCore(Message message, IPluginContext context)
{
var match = Matcher.Match(message.Text);
if (!match.Success)
{
return NotHandled();
}
var index = context.RandomProvider.Next(0, 2);
string answerText;
if (index == 0)
{
// Negative
var answerIndex = context.RandomProvider.Next(0, NegativeResponses.Length);
answerText = NegativeResponses[answerIndex];
}
else
{
// Positive
var answerIndex = context.RandomProvider.Next(0, PositiveResponses.Length);
answerText = PositiveResponses[answerIndex];
}
return Handled(Message("@{0}: {1}!", context.User.Name, answerText));
}
开发者ID:CompileThis,项目名称:CompileThis.BawBag,代码行数:26,代码来源:QuestionHandler.cs
示例13: Initialize
public void Initialize(IPluginContext context)
{
try // Try to load the config
{
string configPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\config.json"; // Define the config file 's path
string content = File.ReadAllText(configPath, System.Text.Encoding.UTF8); // Get the content of the config file
JsonTextReader reader = new JsonTextReader(new StringReader(content)); // Create the JSonTextReader
/*
* Parse the Json here
* */
string lastName = String.Empty;
while (reader.Read())
{
if (reader.TokenType == JsonToken.PropertyName)
{
lastName = (string) reader.Value;
}
else if (reader.TokenType == JsonToken.String)
{
planning.Add(lastName, (string)reader.Value);
lastName = "";
}
}
}
catch (Exception) { } // Catch any error and don't notify it
}
开发者ID:r00tKiller,项目名称:Dagobar,代码行数:28,代码来源:MandytohPlanningPlugin.cs
示例14: ShutdownDocumentIndexes
public static void ShutdownDocumentIndexes(this IDocumentIndexProvider documentIndexProvider, IPluginContext context, DocumentIndexShutdownSetup setup, IActivityLogger logger)
{
foreach (IDocumentIndex documentIndex in GetDocumentIndexes(documentIndexProvider, context, runningOnly:false))
{
var success = documentIndex.Shutdown(setup);
logger.DebugFormat("{0} was {1} shutted down", documentIndex.Type.TypeToken, success ? string.Empty : "not");
}
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:8,代码来源:DocumentIndexProviderServices.cs
示例15: GetKarma
private MessageHandlerResult GetKarma(string nick, IPluginContext context)
{
var result = context.RavenSession.Query<KarmaTotal, KarmaTotals>().SingleOrDefault(x => x.Name == nick);
var quantity = (result == null) ? 0 : result.Quantity;
return Handled(Message("@{0}: {1} = {2}", context.User.Name, nick, quantity));
}
开发者ID:CompileThis,项目名称:CompileThis.BawBag,代码行数:8,代码来源:KarmaHandler.cs
示例16: PreLoadMainPlugins
public static void PreLoadMainPlugins(IPluginContext mainPluginContext)
{
if (null != mainPluginContext)
{
PluginConfig pluginConfig = new PluginConfig(mainPluginContext);
pluginConfig.PreLoadPlugins();
}
}
开发者ID:nateliu,项目名称:StarSharp,代码行数:8,代码来源:PluginManager.cs
示例17: GetDocumentIndexes
private static IEnumerable<IDocumentIndex> GetDocumentIndexes(IDocumentIndexProvider documentIndexProvider, IPluginContext context, bool runningOnly)
{
IEnumerable<IDocumentIndex> documentIndexes = documentIndexProvider.DocumentIndexTypes.Select(t => t.TypeToken)
.Distinct()
.Select(t => runningOnly ? documentIndexProvider.GetDocumentIndex(context, t) : Maybe.Return(documentIndexProvider.GetOrCreateDocumentIndex(context,t)))
.Choose();
return documentIndexes;
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:8,代码来源:DocumentIndexProviderServices.cs
示例18: RunAtStartStopInitializer
public RunAtStartStopInitializer()
{
_documentIndexProvider = ObjectFactory.GetInstance<IDocumentIndexProvider>();
_log = ObjectFactory.GetInstance <IActivityLogger>();
_isOnSite = ObjectFactory.GetInstance<IMsmqTransport>().RoutableTransportMode == RoutableTransportMode.OnSite;
_documentIndexRebuilder = ObjectFactory.GetInstance<DocumentIndexRebuilder>();
_pluginContext = ObjectFactory.GetInstance<IPluginContext>();
}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:8,代码来源:RunAtStartStopInitializer.cs
示例19: QueryPlanBuilder
public QueryPlanBuilder(IPluginContext pluginContext, IProfileReadonly profile, IDocumentIndexProvider documentIndexProvider, IEntityTypeProvider entityTypeProvider, IIndexDataFactory indexDataFactory, ContextQueryPlanBuilder contextQueryPlanBuilder)
{
_pluginContext = pluginContext;
_profile = profile;
_documentIndexProvider = documentIndexProvider;
_entityTypeProvider = entityTypeProvider;
_indexDataFactory = indexDataFactory;
_contextQueryPlanBuilder = contextQueryPlanBuilder;
}
开发者ID:chenhualei,项目名称:Target-Process-Plugins,代码行数:9,代码来源:QueryPlanBuilder.cs
示例20: QueryPlanBuilder
public QueryPlanBuilder(IPluginContext pluginContext, IProfileReadonly profile, IDocumentIndexProvider documentIndexProvider, IEntityTypeProvider entityTypeProvider, IDocumentIdFactory documentIdFactory)
{
_accountName = pluginContext.AccountName;
_profile = profile;
_documentIndexProvider = documentIndexProvider;
_entityTypeProvider = entityTypeProvider;
_documentIdFactory = documentIdFactory;
_contextQueryPlanBuilder = new ContextQueryPlanBuilder(_documentIndexProvider, _documentIdFactory, pluginContext.AccountName, _profile, _entityTypeProvider);
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:9,代码来源:QueryPlanBuilder.cs
注:本文中的IPluginContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论