本文整理汇总了C#中IGenerator类的典型用法代码示例。如果您正苦于以下问题:C# IGenerator类的具体用法?C# IGenerator怎么用?C# IGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IGenerator类属于命名空间,在下文中一共展示了IGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiscoTask
public DiscoTask(Settings settings, IGenerator<amBXScene> randomSceneGenerator, NotificationClientBase notificationService, Random random)
{
this.settings = settings;
this.randomSceneGenerator = randomSceneGenerator;
this.notificationService = notificationService;
this.random = random;
}
示例2: ProcessTree
private static void ProcessTree(Option<IAbstractSyntaxTree> ast, IGenerator generator)
{
if (!ast.Any())
return;
generator.Process(ast.Single());
}
示例3: VertexSourceAdapter
public VertexSourceAdapter(IVertexSource vertexSource, IGenerator generator)
{
markers = new null_markers();
this.VertexSource = vertexSource;
this.generator = generator;
m_status = status.initial;
}
示例4: Learn
/// <summary>
/// Trains a single model based on a generator
/// a predefined number of times with the provided
/// examples and data split and selects the best
/// (or most accurate) model
/// </summary>
/// <param name="examples">Source data</param>
/// <param name="trainingPercentage">Data split percentage</param>
/// <param name="repeat">Number of repetitions per generator</param>
/// <param name="generator">Model generator used</param>
/// <returns>Best model for provided generator</returns>
public static LearningModel Learn(IEnumerable<object> examples, double trainingPercentage, int repeat, IGenerator generator)
{
var total = examples.Count();
var descriptor = generator.Descriptor;
var data = descriptor.Convert(examples).ToExamples();
Matrix x = data.Item1;
Vector y = data.Item2;
var models = new IModel[repeat];
var accuracy = Vector.Zeros(repeat);
// run in parallel since they all have
// read-only references to the data model
// and update indices independently
Parallel.For(0, models.Length, i =>
{
var t = GenerateModel(generator, x, y, examples, trainingPercentage);
models[i] = t.Model;
accuracy[i] = t.Accuracy;
});
var idx = accuracy.MaxIndex();
return new LearningModel { Generator = generator, Model = models[idx], Accuracy = accuracy[idx] };
}
示例5: GenerateWithWatch
private static void GenerateWithWatch(IGenerator g)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write("\r\n{0}: ", g);
Console.ResetColor();
Console.Write("Working...\r\n");
List<string> result = null;
var sw = new Stopwatch();
var total = 0L;
for (int i = 0;i < _loop;i++)
{
sw.Reset();
sw.Start();
result = g.Generate(DIC, _len);
sw.Stop();
total += sw.ElapsedMilliseconds;
if (i <= 10)
{
Console.WriteLine("\tGot {0} items in {1,7}ms", result.Count, sw.ElapsedMilliseconds);
if (i == 10 && _loop > 10)
{
Console.WriteLine("\t......");
}
}
}
Console.WriteLine("\tGenerate finished for {2} times in {0,7}ms, {1,7}ms for each time.", total, total / _loop, _loop);
if (result != null)
{
PrintTheResult(result);
}
}
示例6: HelloWorldController
public HelloWorldController(IGenerator generator)
{
if (generator == null)
throw new ArgumentNullException("generator");
_Generator = generator;
}
示例7: Main
public static void Main(string[] args)
{
var targetDirectory = Path.GetFullPath(args.Length > 0 ? args[0] : ".");
var outputDirectory = Path.GetFullPath(args.Length > 1 ? args[1] : ".");
var options = args.Length > 2 ? args[2] : "";
if (!Directory.Exists(targetDirectory))
return;
if (!Directory.Exists(outputDirectory))
MiscUtil.CreateDirectory(outputDirectory);
var generators = new IGenerator[]
{
new MessageCodeGenerator(outputDirectory, options),
new DataCodeGenerator(outputDirectory),
new AttributeCodeGenerator(outputDirectory)
};
var targetFiles = Directory.GetFiles(targetDirectory, "*.xml", SearchOption.AllDirectories);
Parallel.ForEach(targetFiles, eachFile =>
{
var document = new XmlDocument();
document.Load(eachFile);
Parallel.ForEach(generators, e => e.Load(eachFile, document));
});
Parallel.ForEach(generators, e => e.Generate());
}
示例8: Field
public Field(IGenerator generator)
{
_generator = generator;
_generator.Generate(this);
if (_tiles == null || _types == null)
throw new Exception("Generator failed. Tiles or TileTypes missing!");
}
示例9: ConverterAdaptorVcgen
///<summary>
///</summary>
///<param name="source"></param>
///<param name="generator"></param>
public ConverterAdaptorVcgen(IVertexSource source, IGenerator generator)
{
_markers = new NullMarkers();
_source = source;
_generator = generator;
_status = EStatus.Initial;
}
示例10: PerformSampling
public void PerformSampling(string name, IGenerator layer)
{
PerformSamplingIndividual(name, layer, 5, 0);
PerformSamplingIndividual(name, layer, 5, 100);
PerformSamplingIndividual(name, layer, 5, 10000);
PerformSamplingIndividual(name, layer, 5, 10000000);
}
示例11: Setup
public void Setup()
{
ccu = new CodeCompileUnit();
mocks = new MockRepository();
engine = Engine.GlobalEngine;
engine.BinPath = @"C:\Program Files (x86)\MSBuild";
project = new Project();
buildEngine = mocks.DynamicMock<MockBuildEngine>(project);
logger = new NullLogger();
parserService = mocks.DynamicMock<ISiteTreeGeneratorService>();
naming = mocks.DynamicMock<INamingService>();
sourceStorage = mocks.DynamicMock<IParsedSourceStorageService>();
source = mocks.DynamicMock<ISourceGenerator>();
typeResolver = mocks.DynamicMock<ITypeResolver>();
treeService = mocks.DynamicMock<ITreeCreationService>();
viewSourceMapper = mocks.DynamicMock<IViewSourceMapper>();
generator = mocks.DynamicMock<IGenerator>();
task = new GenerateMonoRailSiteTreeTask(logger, parserService, naming, source, sourceStorage, typeResolver,
treeService, viewSourceMapper, generator);
item = mocks.DynamicMock<ITaskItem>();
parsedSource = mocks.DynamicMock<IParser>();
}
示例12: Emit
public void Emit(IGenerator codeEmittor)
{
foreach(var i in _instructions)
{
i.Emit(codeEmittor);
}
}
示例13: BuildBuffers
private void BuildBuffers(IGenerator generator)
{
List<MyOwnVertexFormat> vertices = new List<MyOwnVertexFormat>();
for (int x = 0; x < sideSize; x++)
{
for (int z = 0; z < sideSize; z++)
{
for (int y = 0; y < sideSize; y++)
{
double sample = generator.Sample(new Vector3(x, y, z) + location);
if ( sample > 0.6f)
{
CreateVertices(vertices, x, y, z, new Color((float)sample, (float)sample, (float)sample));
}
}
}
}
if(vertices.Count > 0)
{
vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration, vertices.Count, BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices.ToArray());
}
numVertices = vertices.Count;
}
示例14: Generator
/// <summary>
/// Initializes a new instance of a Generator.
/// </summary>
/// <param name="generator">The text generator to wrap.</param>
internal Generator(IGenerator generator)
{
_generator = generator;
_foundHandlers = new List<EventHandler<KeyFoundEventArgs>>();
_notFoundHandlers = new List<EventHandler<KeyNotFoundEventArgs>>();
_valueRequestedHandlers = new List<EventHandler<ValueRequestEventArgs>>();
}
示例15: Toolchain
public Toolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor)
{
Name = name;
Generator = generator;
Builder = builder;
Executor = executor;
}