public override bool Equals(object obj) { if (!(obj is VerbInfo)) { return(false); } VerbInfo other = obj as VerbInfo; if (!other.Verb.Equals(Verb)) { return(false); } if (!other.Stem.Equals(Stem)) { return(false); } if (!other.Time.Equals(Time)) { return(false); } if (!other.Positivity.Equals(Positivity)) { return(false); } if (!other.Type.Equals(Type)) { return(false); } if (!other.Person.Equals(Person)) { return(false); } return(true); }
/// <summary> /// Broadcasts the specified verb information. /// </summary> /// <param name="verbInfo">The verb information.</param> public void Broadcast(VerbInfo verbInfo) { if (BroadcastReceived != null) { BroadcastReceived(this, new ProcessVerbEventArgs { VerbInfo = verbInfo }); } }
/// <summary> /// Processes the verb. /// </summary> /// <param name="verbInfo">The verb information.</param> public void ProcessVerb(VerbInfo verbInfo) { if (OnProcessVerb != null) { OnProcessVerb(this, new ProcessVerbEventArgs { VerbInfo = verbInfo }); } }
public void Add(string verb, IHandlerBase handlerObject, string description = null, string usage = null, string group = null) { verb = verb.ToLowerInvariant(); if (_verbs.ContainsKey(verb)) { throw new EngineBuildException("Cannot add verbs with duplicate names"); } var info = new VerbInfo(verb, handlerObject, description, usage, group); _verbs.Add(verb, info); }
/// <summary> /// Broads the cast. /// </summary> /// <param name="verbInfo">The verb information.</param> /// <param name="runningApps">The running apps.</param> public void BroadCast(VerbInfo verbInfo, Dictionary <string, string> runningApps = null) { if (runningApps == null) { runningApps = RunningApps; } if (!HasRunningApplications) { return; } foreach (var pair in runningApps) { SendVerb(verbInfo, pair.Value); } }
/// <summary> /// Sends the verb. /// </summary> /// <param name="verbInfo">The verb information.</param> /// <param name="endpointAddress">The endpoint address.</param> private void SendVerb(VerbInfo verbInfo, string endpointAddress) { try { Logger.Info("Sending verb {0} @ {1}...", verbInfo.Verb, endpointAddress); var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); var pipeFactory = new ChannelFactory <IPlugin>(binding, new EndpointAddress(endpointAddress)); IPlugin plugin = pipeFactory.CreateChannel(); plugin.ProcessVerb(verbInfo); Logger.Info("Verb {0} @ {1} was sent!", verbInfo.Verb, endpointAddress); } catch (Exception exception) { Logger.Error(exception.GetCombinedMessages); } }
public void PrintUsageWithVerb() { string usage; using (StringWriter strWtr = new(new StringBuilder(1000))) { VerbInfo verbNfo = (VerbInfo)ReflectionKit.InvokeStaticMethod(typeof(Parser), "GetVerb", new[] { typeof(string), typeof(Type[]) }, new object[] { "unpack", new[] { typeof(UnpackOptions), typeof(CopyOptions) } }); ReflectionKit.InvokeStaticMethod(typeof(Parser), "PrintUsageWithError", new[] { typeof(TextWriter), typeof(string), typeof(Type[]), typeof(VerbInfo) }, new object[] { strWtr, "Missing required argument.", new[] { typeof(UnpackOptions), typeof(CopyOptions) }, verbNfo, }); usage = strWtr.ToString(); } Assert.IsNotNull(usage); Assert.IsNotEmpty(usage); // Assert.IsTrue(usage.Contains("xcite.clip.tests 1.0.0.0")); Assert.IsTrue(usage.Contains("ReSharperTestRunner 2.6.2.69")); // Assert.IsTrue(usage.Contains("Copyright © 2019")); Assert.IsTrue(usage.Contains("ERROR(S)")); Assert.IsTrue(usage.Contains("Missing required argument.")); Assert.IsTrue(usage.Contains("ARGUMENT(S)")); Assert.IsTrue(usage.Contains(" -f, --file (Required) Source path")); Assert.IsTrue(usage.Contains(" -d, --dest (Required) Destination path")); Assert.IsTrue(usage.Contains(" -o, --override Override flag")); Assert.IsTrue(usage.Contains(" -m, --Mode (Default Normal) Unpack mode")); Assert.IsTrue(usage.Contains(" -n, --name (Required) Name of the machine to address")); Assert.IsTrue(usage.Contains(" -p, --port (Default 9898) Port of the machine to address")); Assert.IsTrue(usage.Contains("Missing arguments. Check help!")); }
/// <summary> /// Returns a list of verbs. /// </summary> protected override void ProcessRecord() { Type[] verbTypes = new Type[] { typeof(VerbsCommon), typeof(VerbsCommunications), typeof(VerbsData), typeof(VerbsDiagnostic), typeof(VerbsLifecycle), typeof(VerbsOther), typeof(VerbsSecurity) }; Collection <WildcardPattern> matchingVerbs = SessionStateUtilities.CreateWildcardsFromStrings( this.Verb, WildcardOptions.IgnoreCase ); foreach (Type type in verbTypes) { string groupName = type.Name.Substring(5); if (this.Group != null) { if (!SessionStateUtilities.CollectionContainsValue(this.Group, groupName, StringComparer.OrdinalIgnoreCase)) { continue; } } foreach (FieldInfo field in type.GetFields()) { if (field.IsLiteral) { if (this.Verb != null) { if (!SessionStateUtilities.MatchesAnyWildcardPattern(field.Name, matchingVerbs, false)) { continue; } } VerbInfo verb = new VerbInfo(); verb.Verb = field.Name; verb.AliasPrefix = VerbAliasPrefixes.GetVerbAliasPrefix(field.Name); verb.Group = groupName; verb.Description = VerbDescriptions.GetVerbDescription(field.Name); WriteObject(verb); } } } }
public void PrintUsageWithVerbAndLongDescription() { string usage; using (StringWriter strWtr = new(new StringBuilder(1000))) { VerbInfo verbNfo = (VerbInfo)ReflectionKit.InvokeStaticMethod(typeof(Parser), "GetVerb", new[] { typeof(string), typeof(Type[]) }, new object[] { "detail", new[] { typeof(DetailOptions), typeof(UnpackOptions) } }); ReflectionKit.InvokeStaticMethod(typeof(Parser), "PrintUsageWithError", new[] { typeof(TextWriter), typeof(string), typeof(Type[]), typeof(VerbInfo) }, new object[] { strWtr, "Missing required argument.", new[] { typeof(UnpackOptions), typeof(CopyOptions) }, verbNfo, }); usage = strWtr.ToString(); } Assert.IsNotNull(usage); Assert.IsNotEmpty(usage); // Assert.IsTrue(usage.Contains("xcite.clip.tests 1.0.0.0")); Assert.IsTrue(usage.Contains("ReSharperTestRunner 2.6.2.69")); // Assert.IsTrue(usage.Contains("Copyright © 2019")); Assert.IsTrue(usage.Contains("ERROR(S)")); Assert.IsTrue(usage.Contains("Missing required argument.")); Assert.IsTrue(usage.Contains("ARGUMENT(S)")); Assert.IsTrue(usage.Contains(" -x, --ex Might do something. Don't known.")); Assert.IsTrue(usage.Contains(" -y, --ypsilon (Required) This really does something. So it's heavily recommended to activate this option,")); Assert.IsTrue(usage.Contains(" so that you can see some awesome features that you would have never expected. If you have")); Assert.IsTrue(usage.Contains(" some further questions, please ask the programmer.")); Assert.IsTrue(usage.Contains("Missing arguments. Check help!")); }
/// <summary> /// Processes the verb. /// </summary> /// <param name="info">The info.</param> /// <returns></returns> /// <remarks></remarks> public ResponseInfo ProcessVerb(VerbInfo info) { IVerbProcessor proc = CreateVerbProcessor(info); return(proc != null?proc.ProcessVerb(this, info) : null); }
/// <summary> /// Creates the verb processor. /// </summary> /// <param name="info">The info.</param> /// <returns></returns> /// <remarks></remarks> protected virtual IVerbProcessor CreateVerbProcessor(VerbInfo info) { return(null); }
/// <summary> /// Broadcasts the specified verb info to the active plugins. /// Any Plugins that respond to the message will return their info in the result array. /// </summary> /// <param name="verbInfo">The verb info.</param> public void Broadcast(VerbInfo verbInfo) { BroadCast(verbInfo, RunningApps); }
protected override ResponseInfo ProcessInternal(VerbInfo info) { return(null); }
/// <summary> /// Executes the applet. /// </summary> /// <param name="tag">The tag.</param> /// <param name="mode">The mode.</param> public void Broadcast(VerbInfo verbInfo) { //DeamonHelper.BroadCast(verbInfo); }
public void ProcessVerb(VerbInfo verbInfo) { //return PluginForm != null ? PluginForm.ProcessVerb(verbInfo) : null; }
public void Broadcast(VerbInfo nfo) { //return Host != null ? Host.Broadcast(nfo) : null; }