本文整理汇总了C#中IEngine.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.GetService方法的具体用法?C# IEngine.GetService怎么用?C# IEngine.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEngine
的用法示例。
在下文中一共展示了IEngine.GetService方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public static CreateObjectCommand Evaluate(IEngine engine, Command command)
{
if (command.Parameters.Count < 2)
return null;
if (command.Parameters[0].Name.ToLower() != "create")
return null;
if (command.Parameters[0].Value != null)
return null;
string name = command.Parameters[1].Name;
if (string.IsNullOrEmpty(name))
return null;
ISchemaService schemaService = engine.GetService<ISchemaService>();
if (!schemaService.HasClass(name))
return null;
CreateObjectCommand createObjectCommand = new CreateObjectCommand(name);
IList<Parameter> parameters = command.Parameters[1].Value as IList<Parameter>;
if (parameters != null)
{
foreach (Parameter parameter in parameters)
{
if (schemaService.HasProperty(name, parameter.Name))
{
createObjectCommand.Values[parameter.Name] = parameter.Value;
}
}
}
return createObjectCommand;
}
示例2: Initialize
protected override void Initialize(IEngine engine)
{
base.Initialize(engine);
var testFrameworkService = engine.GetService<IPexTestFrameworkManager>();
var host = testFrameworkService as IPexComponent;
testFrameworkService.AddTestFramework(new XunitTestFramework_2_0(host));
}
示例3: Evaluate
public static UpdateObjectsCommand Evaluate(IEngine engine, Command command)
{
if (command.Parameters.Count < 3)
return null;
if (command.Parameters[0].Name.ToLower() != "update")
return null;
if (command.Parameters[0].Value != null)
return null;
string name = command.Parameters[1].Name;
if (string.IsNullOrEmpty(name))
return null;
ISchemaService schemaService = engine.GetService<ISchemaService>();
if (!schemaService.HasClass(name))
return null;
if (command.Parameters[2].Name.ToLower() != "match")
return null;
IList<Parameter> match = command.Parameters[2].Value as IList<Parameter>;
UpdateObjectsCommand updateObjectsCommand = new UpdateObjectsCommand(name);
IList<Parameter> parameters = command.Parameters[1].Value as IList<Parameter>;
if (parameters != null)
{
foreach (Parameter parameter in parameters)
{
if (schemaService.HasProperty(name, parameter.Name))
{
updateObjectsCommand.Values[parameter.Name] = parameter.Value;
}
}
}
if (match != null)
{
foreach (Parameter parameter in match)
{
if (schemaService.HasProperty(name, parameter.Name))
{
updateObjectsCommand.Match[parameter.Name] = parameter.Value;
}
}
}
return updateObjectsCommand;
}
示例4: Evaluate
public static DeleteObjectsCommand Evaluate(IEngine engine, Command command)
{
if (command.Parameters.Count < 2)
return null;
if (command.Parameters[0].Name.ToLower() != "delete")
return null;
if (command.Parameters[0].Value != null)
return null;
string name = command.Parameters[1].Name;
if (string.IsNullOrEmpty(name))
return null;
ISchemaService schemaService = engine.GetService<ISchemaService>();
if (!schemaService.HasClass(name))
return null;
DeleteObjectsCommand deleteObjectsCommand = new DeleteObjectsCommand(name);
EvaluateMatch(command.Parameters[1].Value, name, schemaService, deleteObjectsCommand);
if (command.Parameters.Count > 2)
{
switch (command.Parameters[2].Name.ToLower())
{
case "match":
case "where":
EvaluateMatch(command.Parameters[2].Value, name, schemaService, deleteObjectsCommand);
break;
case "query":
if (command.Parameters[2].Value != null)
deleteObjectsCommand.Where = command.Parameters[2].Value.ToString();
break;
}
}
return deleteObjectsCommand;
}
示例5: Evaluate
public static CreatePropertyCommand Evaluate(IEngine engine, Command command)
{
if (command.Parameters.Count < 3)
return null;
if (command.Parameters[0].Name.ToLower() != "create")
return null;
if (command.Parameters[0].Value != null)
return null;
Multiplicity multiplicity = Multiplicity.None;
switch (command.Parameters[1].Name.ToLower())
{
case "property":
case "relationship":
break;
case "one-one":
case "oneone":
case "one-to-one":
case "onetoone":
multiplicity = Multiplicity.OneToOne;
break;
case "one-many":
case "onemany":
case "one-to-many":
case "onetomany":
case "reference":
multiplicity = Multiplicity.OneToMany;
break;
case "many-one":
case "manyone":
case "many-to-one":
case "manytoone":
case "list":
multiplicity = Multiplicity.ManyToOne;
break;
case "many-many":
case "manymany":
case "many-to-many":
case "manytomany":
multiplicity = Multiplicity.ManyToMany;
break;
default:
return null;
}
if (command.Parameters[1].Value != null)
return null;
string name = command.Parameters[2].Name;
if (string.IsNullOrEmpty(name))
return null; // register exception...
string[] parts = name.Split(".".ToCharArray());
if (parts.Length != 2)
return null; // register exception...
string className = parts[0];
string propertyName = parts[1];
if (string.IsNullOrEmpty(className))
return null; // register exception...
if (string.IsNullOrEmpty(propertyName))
return null; // register exception...
ISchemaService schemaService = engine.GetService<ISchemaService>();
IObjectService objectService = engine.GetService<IObjectService>();
CreatePropertyCommand createPropertyCommand = new CreatePropertyCommand(className, propertyName);
createPropertyCommand.Multiplicity = multiplicity;
createPropertyCommand.Type = typeof(string);
createPropertyCommand.StringLength = 255;
bool list = false;
IList<Parameter> parameters = command.Parameters[2].Value as IList<Parameter>;
if (parameters != null)
{
foreach (Parameter parameter in parameters)
{
if (parameter.Value != null)
{
switch (parameter.Name.ToLower())
{
case "type":
if (schemaService.HasClass(parameter.Value.ToString()))
createPropertyCommand.Type = objectService.GetTypeByName(parameter.Value.ToString());
else
createPropertyCommand.Type = Type.GetType(parameter.Value.ToString());
break;
case "list":
list = true;
break;
case "multiplicity":
case "ref":
case "reference":
case "referencetype":
if (createPropertyCommand.Multiplicity == Multiplicity.None)
{
//.........这里部分代码省略.........
示例6: Evaluate
public static DisplayObjectsCommand Evaluate(IEngine engine, Command command)
{
if (command.Parameters.Count < 2)
return null;
bool list = false;
switch (command.Parameters[0].Name.ToLower())
{
case "display":
case "show":
break;
case "list":
list = true;
break;
default:
return null;
}
if (command.Parameters[0].Value != null)
return null;
string name = command.Parameters[1].Name;
if (string.IsNullOrEmpty(name))
return null;
ISchemaService schemaService = engine.GetService<ISchemaService>();
if (!schemaService.HasClass(name))
return null;
DisplayObjectsCommand displayObjectsCommand = new DisplayObjectsCommand(name, list);
EvaluateMatch(command.Parameters[1].Value, name, schemaService, displayObjectsCommand);
if (command.Parameters.Count > 2)
{
switch (command.Parameters[2].Name.ToLower())
{
case "match":
case "where":
EvaluateMatch(command.Parameters[2].Value, name, schemaService, displayObjectsCommand);
break;
case "query":
if (command.Parameters[2].Value != null)
displayObjectsCommand.Where = command.Parameters[2].Value.ToString();
break;
}
}
return displayObjectsCommand;
}