本文整理汇总了C#中Pipeline类的典型用法代码示例。如果您正苦于以下问题:C# Pipeline类的具体用法?C# Pipeline怎么用?C# Pipeline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pipeline类属于命名空间,在下文中一共展示了Pipeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_load_all_filters_in_assembly
public void Should_load_all_filters_in_assembly()
{
var pipeline = new Pipeline<int, string>(serviceProvider)
.AddAssembly(typeof(AddFiltersInAssemblyTests).Assembly);
Assert.That(pipeline.Count, Is.EqualTo(5));
}
示例2: TestAsyncStateChangeFake
public void TestAsyncStateChangeFake()
{
bool done = false;
Pipeline pipeline = new Pipeline();
Assert.IsNotNull (pipeline, "Could not create pipeline");
Element src = ElementFactory.Make ("fakesrc");
Element sink = ElementFactory.Make ("fakesink");
Bin bin = (Bin) pipeline;
bin.Add (src, sink);
src.Link (sink);
Bus bus = pipeline.Bus;
Assert.AreEqual ( ( (Element) pipeline).SetState (State.Playing), StateChangeReturn.Async);
while (!done) {
State old, newState, pending;
Message message = bus.Poll (MessageType.StateChanged, -1);
if (message != null) {
message.ParseStateChanged (out old, out newState, out pending);
if (message.Src == (Gst.Object) pipeline && newState == State.Playing)
done = true;
}
}
Assert.AreEqual ( ( (Element) pipeline).SetState (State.Null), StateChangeReturn.Success);
}
示例3: Main
static void Main(string[] args)
{
var pump = new FileDataSource(new StreamReader(@"data\TestData.txt"));
var shifter = new CircularShifter();
var alphabetizer = new Alphabetizer();
#region Modifying the requirement - add a 'noise' list to remove words from the index
//var noiseWords = new FileDataSource(new StreamReader(@"data\noise.txt")).Begin();
//var noiseRemover = new NoiseRemoval(noiseWords);
//pump.Successor = noiseRemover;
//noiseRemover.Successor = shifter;
#endregion
pump.Successor = shifter;
shifter.Successor = alphabetizer;
var pipeline = new Pipeline<string>(pump: pump, sink: new ConsoleWriter());
Console.WriteLine("Begin Execution At:{0}", DateTime.UtcNow);
pipeline.Execute();
Console.WriteLine("Stop Execution At:{0}", DateTime.UtcNow);
Console.WriteLine("Press any key to continue");
Console.ReadKey();
}
示例4: DefaultCtorSplitsAtDashes
public void DefaultCtorSplitsAtDashes()
{
// Given
Engine engine = new Engine();
Metadata metadata = new Metadata(engine);
Pipeline pipeline = new Pipeline("Pipeline", engine, null);
IExecutionContext context = new ExecutionContext(engine, pipeline);
IDocument[] inputs = { new Document(metadata).Clone(@"FM1
FM2
---
Content1
Content2") };
string frontMatterContent = null;
FrontMatter frontMatter = new FrontMatter(new Execute(x =>
{
frontMatterContent = x.Content;
return new [] {x};
}));
// When
IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);
// Then
Assert.AreEqual(1, documents.Count());
Assert.AreEqual(@"FM1
FM2
", frontMatterContent);
Assert.AreEqual(@"Content1
Content2", documents.First().Content);
}
示例5: TestAsyncStateChangeEmpty
public void TestAsyncStateChangeEmpty()
{
Pipeline pipeline = new Pipeline();
Assert.IsNotNull (pipeline, "Could not create pipeline");
Assert.AreEqual ( ( (Element) pipeline).SetState (State.Playing), StateChangeReturn.Success);
}
示例6: ClearPipeline
/// <summary>
/// Deletes the pipeline and sets its corresponding property to null.
/// </summary>
/// <param name="p">The pipeline that will be deleted.</param>
public override void ClearPipeline(Pipeline p)
{
if (this.IncomePipeline == p)
{
this.IncomePipeline = null;
}
}
示例7: testMultiProperty
public void testMultiProperty()
{
var _Graph = TinkerGraphFactory.CreateTinkerGraph();
var _Marko = _Graph.VertexById(1);
var _EVP = new InVertexPipe<UInt64, Int64, String, String, Object,
UInt64, Int64, String, String, Object,
UInt64, Int64, String, String, Object,
UInt64, Int64, String, String, Object>();
var _PPipe = new PropertyPipe<String, Object>(Keys: "name");
var _Pipeline = new Pipeline<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
UInt64, Int64, String, String, Object,
UInt64, Int64, String, String, Object,
UInt64, Int64, String, String, Object>, String>(_EVP, _PPipe);
_Pipeline.SetSourceCollection(_Marko.OutEdges());
var _Counter = 0;
while (_Pipeline.MoveNext())
{
var _Name = _Pipeline.Current;
Assert.IsTrue(_Name.Equals("vadas") || _Name.Equals("josh") || _Name.Equals("lop"));
_Counter++;
}
Assert.AreEqual(3, _Counter);
}
示例8: Stencil
internal override void Stencil(Pipeline pipeline)
{
if (Glyphs == null || _vertices == null)
return;
pipeline.StencilInstancedGlyphs(Font.FillRule, this);
}
示例9: Main
public static void Main (string [] args) {
Application.Init();
if (args.Length != 1) {
Console.Error.WriteLine ("usage: mono queueexample.exe <filename>\n");
return;
}
Element pipeline = new Pipeline ("pipeline");
Element filesrc = ElementFactory.Make ("filesrc", "disk_source");
filesrc.SetProperty ("location", args[0]);
Element decode = ElementFactory.Make ("mad", "decode");
Element queue = ElementFactory.Make ("queue", "queue");
Element audiosink = ElementFactory.Make ("alsasink", "play_audio");
Bin bin = (Bin) pipeline;
bin.AddMany (filesrc, decode, queue, audiosink);
Element.LinkMany (filesrc, decode, queue, audiosink);
pipeline.SetState (State.Playing);
EventLoop (pipeline);
pipeline.SetState (State.Null);
}
示例10: MessageRegistration
public MessageRegistration(Type messageType, Type handlerType, Pipeline pipeline, IReadOnlyCollection<Type> dependancies, IReadOnlyCollection<Type> scopedDependancies)
{
if (messageType == null) throw new ArgumentNullException(nameof(messageType));
if (handlerType == null) throw new ArgumentNullException(nameof(handlerType));
if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
if (dependancies == null) throw new ArgumentNullException(nameof(dependancies));
if (scopedDependancies == null) throw new ArgumentNullException(nameof(scopedDependancies));
var messageTypeInfo = messageType.GetTypeInfo();
if (!typeof(IMessage).GetTypeInfo().IsAssignableFrom(messageTypeInfo)) throw new ArgumentException($"Parameter {nameof(messageType)} must implement IMessage", nameof(messageType));
if (typeof(ICommand).GetTypeInfo().IsAssignableFrom(messageTypeInfo)) {
GetValue(new[] { messageType }, messageType, handlerType, type => typeof(ICommandHandler<>).MakeGenericType(type));
} else if (typeof(IEvent).GetTypeInfo().IsAssignableFrom(messageTypeInfo)) {
GetValue(MessagesHelper.ExpandType(messageType).Where(x => x != typeof(IMessage)), messageType, handlerType, type => typeof(IEventHandler<>).MakeGenericType(type));
} else if (typeof(IQuery).GetTypeInfo().IsAssignableFrom(messageTypeInfo)) {
var genericArguments = messageTypeInfo.ImplementedInterfaces.Single(x => x.GetTypeInfo().IsGenericType && x.GetGenericTypeDefinition() == typeof(IQuery<,>)).GenericTypeArguments;
GetValue(new[] { messageType }, messageType, handlerType, type => typeof(IQueryHandler<,>).MakeGenericType(genericArguments));
}
this.MessageType = messageType;
this.Pipeline = pipeline;
this.Handler = handlerType;
Dependancies = dependancies;
ScopedDependancies = scopedDependancies;
}
示例11: GetDefaultContext
static LinkContext GetDefaultContext(Pipeline pipeline)
{
LinkContext context = new LinkContext (pipeline);
context.CoreAction = AssemblyAction.Skip;
context.OutputDirectory = "output";
return context;
}
示例12: testSelfFilter
public void testSelfFilter()
{
var _List = new List<String>() { "marko", "antonio", "rodriguez", "was", "here", "." };
var _Pipe1 = new AggregatorPipe<String>(new List<String>());
var _Pipe2 = new CollectionFilterPipe<String>(_Pipe1.SideEffect, ComparisonFilter.NOT_EQUAL);
var _Pipeline = new Pipeline<String, String>(_Pipe1, _Pipe2);
_Pipeline.SetSourceCollection(_List);
var _Counter = 0;
while (_Pipeline.MoveNext())
_Counter++;
Assert.AreEqual(6, _Counter);
_Pipe1 = new AggregatorPipe<String>(new List<String>());
_Pipe2 = new CollectionFilterPipe<String>(_Pipe1.SideEffect, ComparisonFilter.EQUAL);
_Pipeline = new Pipeline<String, String>(_Pipe1, _Pipe2);
_Pipeline.SetSourceCollection(_List);
_Counter = 0;
while (_Pipeline.MoveNext())
_Counter++;
Assert.AreEqual(0, _Counter);
}
示例13: Main
public static void Main(string [] args)
{
Application.Init ();
Pipeline pipeline = new Pipeline ("pipeline");
Element source = ElementFactory.Make ("filesrc", "source");
typefind = TypeFindElement.Make ("typefind");
Element sink = ElementFactory.Make ("fakesink", "sink");
source.SetProperty ("location", args[0]);
typefind.HaveType += OnHaveType;
pipeline.AddMany (source, typefind, sink);
source.Link (typefind);
typefind.Link (sink);
pipeline.SetState (State.Paused);
pipeline.SetState (State.Null);
source.Dispose ();
typefind.Dispose ();
sink.Dispose ();
pipeline.Dispose ();
}
示例14: ExecuteCommand
void ExecuteCommand()
{
var pipeline = currentPipeline;
try
{
pipeline.Invoke();
foreach (PSObject errorRecord in pipeline.Error.ReadToEnd())
{
var errorMessage = "Error executing powershell: " + errorRecord;
LogTo.Error(errorMessage);
LogError(errorMessage);
}
}
finally
{
try
{
if (pipeline != null)
{
pipeline.Dispose();
}
}
finally
{
currentPipeline = null;
}
}
}
示例15: Main
public static int Main(string[] args) {
if (args.Length < 3) {
Console.Error.WriteLine("Usage: RunUDPipe input_format(tokenize|conllu|horizontal|vertical) output_format(conllu) model");
return 1;
}
Console.Error.Write("Loading model: ");
Model model = Model.load(args[2]);
if (model == null) {
Console.Error.WriteLine("Cannot load model from file '{0}'", args[2]);
return 1;
}
Console.Error.WriteLine("done");
Pipeline pipeline = new Pipeline(model, args[0], Pipeline.DEFAULT, Pipeline.DEFAULT, args[1]);
ProcessingError error = new ProcessingError();
// Read whole input
StringBuilder textBuilder = new StringBuilder();
string line;
while ((line = Console.In.ReadLine()) != null)
textBuilder.Append(line).Append('\n');
// Process data
string text = textBuilder.ToString();
string processed = pipeline.process(text, error);
if (error.occurred()) {
Console.Error.WriteLine("An error occurred in RunUDPipe: {0}", error.message);
return 1;
}
Console.Write(processed);
return 0;
}