本文整理汇总了C#中Properties.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.SetProperty方法的具体用法?C# Properties.SetProperty怎么用?C# Properties.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties.SetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNodeWithProperties
public void CreateNodeWithProperties()
{
var batch = new BatchStore();
var prop1 = new Properties();
prop1.SetProperty("name", "michael");
prop1.SetProperty("location", "new york");
var prop2 = new Properties();
prop2.SetProperty("color", "blue");
prop2.SetProperty("tree", "elm");
var batchNode1 = Node.CreateNode(prop1, batch);
var batchNode2 = Node.CreateNode(prop2, batch);
Assert.IsTrue(batch.Execute());
var restNode1 = batch.GetGraphObject(batchNode1);
var restNode2 = batch.GetGraphObject(batchNode2);
Assert.IsTrue(restNode1.Id > 0);
Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
Assert.IsTrue(restNode1.Properties.GetProperty<string>("name") == "michael");
Assert.IsTrue(restNode1.Properties.GetProperty<string>("location") == "new york");
Assert.IsTrue(restNode2.Properties.GetProperty<string>("color") == "blue");
Assert.IsTrue(restNode2.Properties.GetProperty<string>("tree") == "elm");
}
示例2: CreateRelationshipWithProperties
public void CreateRelationshipWithProperties()
{
var node1 = Node.CreateNode();
var node2 = Node.CreateNode();
var p = new Properties();
p.SetProperty("name", "jack");
p.SetProperty("age", 12);
var cypher = new Cypher();
cypher.Start(s => s.Node("n1", node1.Id).Node("n2", node2.Id));
cypher.Create(c => c.Node("n1").To("r", "like", p).Node("n2"));
cypher.Return(r => r.Relationship("r"));
var result = cypher.Execute();
Assert.IsTrue(result.Count() == 1);
Assert.IsTrue(result.First().Field<Relationship>("r") != null);
var rel = result.First().Field<Relationship>("r");
Assert.IsTrue(rel.StartNode == node1);
Assert.IsTrue(rel.EndNode == node2);
Assert.IsTrue(rel.GetProperty<string>("name") == "jack");
Assert.IsTrue(rel.GetProperty<int>("age") == 12);
}
示例3: SetNodeProperty2
public void SetNodeProperty2()
{
var now = DateTime.Now;
var p = new Properties();
p.SetProperty("name", "jack");
p.SetProperty("age", 12);
p.SetProperty("date", now);
var node1 = Node.CreateNode();
var cypher = new Cypher();
cypher.Start(s => s.Node("node1", node1.Id));
cypher.Set(s => s.Node("node1", p));
cypher.Return(r => r.Node("node1"));
var results = cypher.Execute();
var n1 = results.Rows[0].Field<Node>("node1");
Assert.IsTrue(n1.GetProperty<string>("name") == "jack");
Assert.IsTrue(n1.GetProperty<int>("age") == 12);
Assert.IsTrue(n1.GetProperty<DateTime>("date") == now);
}
示例4: OperatorHasTest2
public void OperatorHasTest2()
{
var p1 = new Properties();
p1.SetProperty("name", "jack");
var p2 = new Properties();
p2.SetProperty("name", "jill");
p2.SetProperty("count", 3);
var node1 = Node.CreateNode();
var node2 = Node.CreateNode();
var node3 = Node.CreateNode();
var rel1 = node1.CreateRelationshipTo(node2, "like", p1);
var rel2 = node1.CreateRelationshipTo(node3, "like", p2);
var cypher = new Cypher();
cypher.Start(s => s.Relationship("rel", rel1.Id , rel2.Id));
cypher.Where(w => w.RelationshipHas("rel", "count"));
cypher.Return(r => r.Relationship("rel"));
var result = cypher.Execute();
Assert.IsTrue(result.Count() == 1);
Assert.IsTrue(result.First().Field<Relationship>("rel") == rel2);
}
示例5: OperatorInTest
public void OperatorInTest()
{
var p1 = new Properties();
p1.SetProperty("name", "jack");
p1.SetProperty("count", 3);
var p2 = new Properties();
p2.SetProperty("name", "jill");
p2.SetProperty("count", 3);
var node1 = Node.CreateNode(p1);
var node2 = Node.CreateNode(p1);
var node3 = Node.CreateNode(p2);
var cypher = new Cypher();
cypher.Start(s => s.Node("node", node1.Id, node2.Id, node3.Id));
cypher.Where(w => w.Node("node").Property("name").In("jack"));
cypher.Return(r => r.Node("node"));
var result = cypher.Execute();
Assert.IsTrue(result.Count() == 2);
Assert.IsTrue(result.First().Field<Node>("node") == node1);
Assert.IsTrue(result.ElementAt(1).Field<Node>("node") == node2);
}
示例6: DeleteMultipleNodeProperties2
public void DeleteMultipleNodeProperties2()
{
var now = DateTime.Now;
var p = new Properties();
p.SetProperty("name", "jack");
p.SetProperty("age", 12);
p.SetProperty("date", now);
var node1 = Node.CreateNode(p);
var cypher = new Cypher();
cypher.Start(s => s.Node("node1", node1.Id));
cypher.Delete(d => d.Node("node1", new List<string>{"age", "name"}));
cypher.Return(r => r.Node("node1"));
var results = cypher.Execute();
var n1 = Node.GetNode(node1.Id);
Assert.IsTrue(n1 == results.Rows[0].Field<Node>("node1"));
Assert.IsTrue(n1.GetPropertyOrOther("age", -1) == -1);
Assert.IsTrue(n1.GetPropertyOrOther("name", "deleted") == "deleted");
Assert.IsTrue(n1.GetProperty<DateTime>("date") == now);
}
示例7: SaveFrom
public void SaveFrom(IConfiguration config, ConfigurationLevel level, Stream outputStream)
{
try {
var keys = config.GetKeys(level);
var properties = new Properties();
foreach (var configKey in keys) {
var configValue = config.GetValue(configKey);
object value;
if (configValue == null || configValue.Value == null) {
value = configKey.DefaultValue;
} else {
value = configValue.Value;
}
var stringValue = Convert.ToString(value, CultureInfo.InvariantCulture);
properties.SetProperty(configKey.Name, stringValue);
}
properties.Store(outputStream, String.Empty);
} catch (DatabaseConfigurationException) {
throw;
} catch (Exception ex) {
throw new DatabaseConfigurationException("Could not save the configurations to the given stream.", ex);
}
}
示例8: CreateNodeWithNodeType
public void CreateNodeWithNodeType()
{
var prop = new Properties();
prop.SetProperty("NodeType", "myNodeType");
var node = Node.CreateNode(prop);
Assert.IsNotNull(node);
Assert.IsTrue(node.Properties.GetProperty<string>("NodeType") == "myNodeType");
}
示例9: CreateNodeWithProperties
public void CreateNodeWithProperties()
{
var p = new Properties();
p.SetProperty("name", "jack");
p.SetProperty("age", 12);
var cypher = new Cypher();
cypher.Create(c => c.Node("node", p));
cypher.Return(r => r.Node("node"));
var result = cypher.Execute();
Assert.IsTrue(result.Count() == 1);
Assert.IsTrue(result.First().Field<Node>("node") != null);
var n = result.First().Field<Node>("node");
Assert.IsTrue(n.GetProperty<string>("name") == "jack");
Assert.IsTrue(n.GetProperty<int>("age") == 12);
}
示例10: OnManagersClear
protected override void OnManagersClear()
{
// Write the manager server address to the properties file,
Properties p = new Properties();
p.SetProperty("manager_server_address", "");
// Contains the root properties,
string propFile = Path.Combine(path, "00.properties");
FileStream fout = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
p.Store(fout, null);
fout.Close();
}
示例11: CreateNodesWithProperties
public void CreateNodesWithProperties()
{
var p = new Properties();
p.SetProperty("name", "jack");
p.SetProperty("age", 12);
var node1 = Node.CreateNode();
var cypher = new Cypher();
cypher.Start(s => s.Node("node1", node1.Id));
cypher.Relate(l => l.Node("node1").To("likes").Node("node2", p));
cypher.Return(r => r.Node("node2"));
var result = cypher.Execute();
Assert.IsTrue(result.Rows.Count == 1);
Assert.IsTrue(result.Rows[0].Field<Node>("node2") != null);
var n2 = result.Rows[0].Field<Node>("node2");
Assert.IsTrue(n2.GetProperty<string>("name") == "jack");
Assert.IsTrue(n2.GetProperty<int>("age") == 12);
}
示例12: OperatorHasTest1
public void OperatorHasTest1()
{
var p1 = new Properties();
p1.SetProperty("name", "jack");
var p2 = new Properties();
p2.SetProperty("name", "jill");
p2.SetProperty("count", 3);
var node1 = Node.CreateNode(p1);
var node2 = Node.CreateNode(p1);
var node3 = Node.CreateNode(p2);
var cypher = new Cypher();
cypher.Start(s => s.Node("node", node1.Id, node2.Id, node3.Id));
cypher.Where(w => w.NodeHas("node", "count"));
cypher.Return(r => r.Node("node"));
var result = cypher.Execute();
Assert.IsTrue(result.Rows.Count == 1);
Assert.IsTrue(result.Rows[0].Field<Node>("node") == node3);
}
示例13: Main
static void Main(string[] args)
{
ArrayList nos = new ArrayList();
// Criando os nós
for (int i = 0; i < 5; i++)
{
var propriedades = new Properties();
propriedades.SetProperty(NodeProperty.Nome.ToString(), "Nome_" + i.ToString());
propriedades.SetProperty(NodeProperty.Sobrenome.ToString(), "Sobrenome_" + i.ToString());
var no = Node.CreateNode(NodeType.Usuario.ToString(), propriedades);
}
// Criando o relacionamento
var no1 = nos[0];
var no2 = nos[1];
var no3 = nos[2];
var no4 = nos[3];
}
示例14: SetNodeProperty1
public void SetNodeProperty1()
{
var p = new Properties();
p.SetProperty("name", "jack");
var node1 = Node.CreateNode();
var cypher = new Cypher();
cypher.Start(s => s.Node("node1", node1.Id));
cypher.Set(s => s.Node("node1", p));
cypher.Return(r => r.Node("node1"));
var results = cypher.Execute();
var n1 = results.First().Field<Node>("node1");
Assert.IsTrue(n1.GetProperty<string>("name") == "jack");
}
示例15: SetRelationshipProperty1
public void SetRelationshipProperty1()
{
var p = new Properties();
p.SetProperty("name", "jack");
var node1 = Node.CreateNode();
var node2 = Node.CreateNode();
var rel = Relationship.CreateRelationship(node1, node2, "like");
var cypher = new Cypher();
cypher.Start(s => s.Relationship("rel1", rel.Id));
cypher.Set(s => s.Relationship("rel1", p));
cypher.Return(r => r.Relationship("rel1"));
var results = cypher.Execute();
var r1 = results.Rows[0].Field<Relationship>("rel1");
Assert.IsTrue(r1.GetProperty<string>("name") == "jack");
}