本文整理汇总了C#中Generator.Generate方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.Generate方法的具体用法?C# Generator.Generate怎么用?C# Generator.Generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator.Generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGenerateLppl
public void TestGenerateLppl()
{
var options = new GeneratorOptions();
var generator = new Generator(options);
var generated = generator.Generate();
Console.WriteLine(generated.ToListPlot());
}
示例2: ParseTracker
public void ParseTracker()
{
var generator = new Generator();
generator.Settings.ContextNaming = ContextNaming.Preserve;
generator.Settings.EntityNaming = EntityNaming.Singular;
generator.Settings.RelationshipNaming = RelationshipNaming.ListSuffix;
generator.Settings.TableNaming = TableNaming.Singular;
var selector = GetDatabaseSchema("Tracker");
Assert.IsNotNull(selector);
EntityContext entityContext = generator.Generate(selector);
Assert.IsNotNull(entityContext);
var settings = new XmlWriterSettings { Indent = true };
var serializer = new XmlSerializer(typeof(EntityContext));
using (var writer = XmlWriter.Create(@"..\..\Tracker.Generated.xml", settings))
serializer.Serialize(writer, entityContext);
string contextDirectory = @"..\..\..\Tracker.Core";
string mappingDirectory = @"..\..\..\Tracker.Core\Mapping";
Synchronizer.UpdateFromSource(entityContext, contextDirectory, mappingDirectory);
using (var writer = XmlWriter.Create(@"..\..\Tracker.Updated.xml", settings))
serializer.Serialize(writer, entityContext);
}
示例3: Parse
public void Parse(string input, string[] args = null)
{
var xxr = new XamlXmlReader(new StringReader(input), new XamlSchemaContext());
var graphReader = new XamlObjectWriter(xxr.SchemaContext);
while (xxr.Read())
graphReader.WriteNode(xxr);
var page = (Page)graphReader.Result;
// Map our generators
var g = new Generator();
g.Map<Page, PageGeneratorBlock>();
g.Map<Button, ButtonGeneratorBlock>();
g.Map<StackPanel, StackPanelGeneratorBlock>();
var doc = new HtmlDocument();
var html = doc.CreateElement("html");
g.Generate(html, page);
// HTML5 Doc type
doc.DocumentNode.AppendChild(doc.CreateComment("<!DOCTYPE html>"));
doc.DocumentNode.AppendChild(html);
doc.Save("test.htm");
var cssContents = g.GenerateStyles(page);
File.WriteAllText("XamlCore.css", cssContents);
}
示例4: Generate
public IEnumerable<SetSong> Generate(int numSets, int numSongsPerSet, IEnumerable<Song> songs)
{
_masterSongList = songs.ToArray();
_generator = new Generator(_masterSongList);
_setSongs = _generator.Generate(numSets, numSongsPerSet, GetNextSong);
return _setSongs;
}
示例5: Generate
public IEnumerable<SetSong> Generate(int numSets, int numSongsPerSet, IEnumerable<Song> songs)
{
_masterSongList = songs.ToArray();
_songMemberInstrumentList = _masterSongList.SelectMany(x => x.SongMemberInstruments).ToList();
_generator = new Generator(_masterSongList);
_setSongs = _generator.Generate(numSets, numSongsPerSet, GetNextSong);
return _setSongs;
}
示例6: TestGeneratePl
public void TestGeneratePl()
{
var options = new GeneratorOptions
{
Function = x => new Pl().Evaluate(x)
};
var generator = new Generator(options);
var generated = generator.Generate();
Console.WriteLine(generated.ToListPlot());
}
示例7: CanGenerateClasses
public void CanGenerateClasses()
{
Assert.DoesNotThrow(() =>
{
var outputPath = GetOutputPath("CanGenerateClasses");
var gen = new Generator
{
EnableDataBinding = true,
IntegerDataType = typeof(int),
UseXElementForAny = true,
CollectionType = typeof(IList<>),
CollectionImplementationType = typeof(List<>),
GenerateDesignerCategoryAttribute = false,
GenerateNullables = true,
GenerateSerializableAttribute = false,
OutputFolder = outputPath,
NamingScheme = NamingScheme.Direct,
DataAnnotationMode = DataAnnotationMode.None,
EmitOrder = true,
NamespaceProvider = new NamespaceProvider
{
GenerateNamespace = key =>
{
switch (Path.GetFileName(key.Source.LocalPath))
{
case "th000008_extern.xsd":
case "ndh000010_extern.xsd":
case "headerbasis000002.xsd":
return "Elster.Basis";
case "datenabholung_5.xsd":
case "elster0810_datenabholung_5.xsd":
switch (key.XmlSchemaNamespace)
{
case "http://www.elster.de/2002/XMLSchema":
return "Elster.Datenabholung5";
default:
throw new NotSupportedException(string.Format("Namespace {0} for schema {1}", key.XmlSchemaNamespace, key.Source));
}
default:
throw new NotSupportedException(string.Format("Namespace {0} for schema {1}", key.XmlSchemaNamespace, key.Source));
}
}
}
};
var xsdFiles = new[]
{
"headerbasis000002.xsd",
"ndh000010_extern.xsd",
"th000008_extern.xsd",
"datenabholung_5.xsd",
"elster0810_datenabholung_5.xsd",
}.Select(x => Path.Combine(InputPath, x)).ToList();
gen.Generate(xsdFiles);
});
}
示例8: GenerateTrackerDatabaseTest
public void GenerateTrackerDatabaseTest()
{
var selector = GetDatabaseSchema("Tracker");
Assert.IsNotNull(selector);
var generator = new Generator();
EntityContext entityContext = generator.Generate(selector);
Assert.IsNotNull(entityContext);
var settings = new XmlWriterSettings { Indent = true };
var serializer = new XmlSerializer(typeof(EntityContext));
using (var writer = XmlWriter.Create(@"..\..\Tracker.xml", settings))
serializer.Serialize(writer, entityContext);
}
示例9: TestLinearOptimizePl
public void TestLinearOptimizePl()
{
var pl = new Pl();
var options = new GeneratorOptions
{
Function = pl.Evaluate,
ErrorRange = 0.25
};
var generator = new Generator(options);
var generated = generator.Generate();
var optimizer = new LcFunctionLinearOptimizer(pl);
optimizer.Optimize(generated);
Console.WriteLine(pl.ToShow(generated));
}
示例10: RenameProperty
public void RenameProperty()
{
var selector = GetDatabaseSchema("Tracker");
Assert.IsNotNull(selector);
var generator = new Generator();
EntityContext entityContext = generator.Generate(selector);
Assert.IsNotNull(entityContext);
var settings = new XmlWriterSettings { Indent = true };
var serializer = new XmlSerializer(typeof(EntityContext));
using (var writer = XmlWriter.Create(@"..\..\Tracker.Before.xml", settings))
serializer.Serialize(writer, entityContext);
entityContext.RenameProperty("Task", "PriorityId", "NewPriorityId");
using (var writer = XmlWriter.Create(@"..\..\Tracker.After.xml", settings))
serializer.Serialize(writer, entityContext);
}
示例11: GenerateConnexInclusionModeTest
public void GenerateConnexInclusionModeTest()
{
var selector = GetDatabaseSchema("Connex");
Assert.IsNotNull(selector);
selector.SelectMode = SelectMode.Include;
selector.SelectedTables.Add("dbo.Agency");
selector.SelectedTables.Add("dbo.Client");
selector.SelectedTables.Add("dbo.Contact");
selector.SelectedTables.Add("dbo.Contract");
selector.SelectedTables.Add("dbo.MediaSupplier");
selector.SelectedTables.Add("dbo.Vendor");
selector.ColumnExpressions.Add(@"\.Id$");
selector.ColumnExpressions.Add(@"\.Name$");
selector.ColumnExpressions.Add(@"UniversalId$");
var generator = new Generator();
generator.Settings.TableNaming = TableNaming.Singular;
generator.Settings.EntityNaming = EntityNaming.Singular;
generator.Settings.RelationshipNaming = RelationshipNaming.Plural;
generator.Settings.ContextNaming = ContextNaming.Plural;
var cleanExpressions = new List<string>
{
"^(sp|tbl|udf|vw)_"
};
foreach (string s in cleanExpressions)
if (!string.IsNullOrEmpty(s))
generator.Settings.CleanExpressions.Add(s);
EntityContext entityContext = generator.Generate(selector);
Assert.IsNotNull(entityContext);
string json = JsonConvert.SerializeObject(entityContext, Formatting.Indented);
File.WriteAllText(@"..\..\Connex.json", json);
}
示例12: GenerateCategory
private void GenerateCategory()
{
string template = Helper.ReadTextFile(categoryFileName);
Generator gen = new Generator(template);
gen.ParseTemplate();
//用起始标志,标志的4个区间
Region rgnTitle = gen.GetRegion("Title");
Region rgnCategory = gen.GetRegion("Category");
Region rgnProducts = gen.GetRegion("Products");
Region rgnNavigator = gen.GetRegion("Navigator");
if(rgnTitle == null || rgnCategory == null || rgnProducts == null || rgnNavigator == null)
{
Response.Write("Missing region.");
return;
}
int categoryId;
string outputFileName;
DataView dvCategory = this.GetCategoryTable().DefaultView;
Pager pgrCategory = new Pager(1, dvCategory.Count);
for(int i = 0; i < pgrCategory.PageCount; i++)
{
rgnTitle.DataSource = (string)dvCategory[i]["CategoryName"]; //Use a string as data source
rgnCategory.DataSource = dvCategory[i]; //Use a DataRowView object as data source
categoryId = (int)dvCategory[i]["CategoryID"];
rgnProducts.DataSource = this.GetProductTable(categoryId); //Use a DataTable object as data souce
//set pager
pgrCategory.CurrentPage = i + 1;
rgnNavigator.DataSource = pgrCategory; //Use a Pager object as data source
outputFileName = string.Format(@"{0}\Html\Category{1}.html", outputPath, categoryId);
Helper.WriteTextFile(outputFileName, gen.Generate());
}
}
示例13: TransformHtml
public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
{
// TODO: Flesh this out. Rather bare bones at the moment.
var document = node.OwnerDocument;
var newElement = document.CreateElement("div");
var style = element.Style;
// TODO: Move this to GeneratorBlock, or not, at least not for this GeneratorBlock impl.
// Reason being is that I do some ContentProperty voodoo, which isnt appropriate for us here.
if (style != null)
newElement.Attributes.Add(document.CreateAttribute("class", style));
// Add our created element to the parent.
node.AppendChild(newElement);
// This is where special handling of Content comes in. I simply loop through the StackPanel and call generate.
// TODO: Try to generalize this and move it to GeneratorBlock. Will clean things up a bit.
foreach (var child in ((StackPanel)element).Children)
{
generator.Generate(newElement, child);
}
}
示例14: OnInspectorGUI
public override void OnInspectorGUI()
{
targetGenerator = (Generator)target;
base.OnInspectorGUI();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
partCount = EditorGUILayout.IntField("Steps", partCount);
if (GUILayout.Button("Generate"))
{
targetGenerator.Clear();
targetGenerator.Generate(partCount);
}
EditorGUILayout.EndHorizontal();
var shapeBoxStyle = new GUIStyle
{
padding = new RectOffset(5, 5, 5, 5),
normal =
{
background = MapUtility.GetColorTexture2D(Color.black)
},
alignment = TextAnchor.MiddleCenter
};
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Shape");
GUILayout.Box(targetGenerator.ShapeTexture, shapeBoxStyle);
EditorGUILayout.EndHorizontal();
EditorGUILayout.IntField("Seed", targetGenerator.Seed);
if (GUILayout.Button("Clear"))
{
Debug.Log("CLEAR!");
targetGenerator.Clear();
}
}
示例15: TestNonLinearOptimizePl
public void TestNonLinearOptimizePl()
{
var pl = new Pl();
Console.WriteLine(pl);
var options = new GeneratorOptions
{
Function = pl.Evaluate,
ErrorRange = 0,//.1,
TimeRangeMax = 0.8
};
var generator = new Generator(options);
var generated = generator.Generate();
pl.Tc += 0.5;// 5;
pl.M += 0.3;
var optimizer = new LcFunctionNonLinearOptimizer(pl);
optimizer.Optimize(generated);
Console.WriteLine(pl);
Console.WriteLine(pl.ToShow(generated));
}