本文整理汇总了C#中IVertexType.GetAttributeDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# IVertexType.GetAttributeDefinition方法的具体用法?C# IVertexType.GetAttributeDefinition怎么用?C# IVertexType.GetAttributeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVertexType
的用法示例。
在下文中一共展示了IVertexType.GetAttributeDefinition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestInsertVertexToVertexAddDefinition
private Tuple<long?, VertexAddDefinition> RequestInsertVertexToVertexAddDefinition(RequestInsertVertex myInsertDefinition,
IVertexType myVertexType,
Int64 myTransaction,
SecurityToken mySecurity)
{
long vertexID = (myInsertDefinition.VertexUUID.HasValue)
? myInsertDefinition.VertexUUID.Value
: _idManager.GetVertexTypeUniqeID(myVertexType.ID).GetNextID();
var source = new VertexInformation(myVertexType.ID, vertexID);
long creationdate = DateTime.UtcNow.ToBinary();
long modificationDate = creationdate;
String comment = myInsertDefinition.Comment;
String edition = myInsertDefinition.Edition;
long? revision = null;
IEnumerable<SingleEdgeAddDefinition> singleEdges;
IEnumerable<HyperEdgeAddDefinition> hyperEdges;
CreateEdgeAddDefinitions(myInsertDefinition.OutgoingEdges,
myVertexType,
myTransaction,
mySecurity,
source,
creationdate,
out singleEdges,
out hyperEdges);
var binaries = (myInsertDefinition.BinaryProperties == null)
? null
: myInsertDefinition.BinaryProperties.Select(x => new StreamAddDefinition(myVertexType.GetAttributeDefinition(x.Key).ID, x.Value));
var structured = ConvertStructuredProperties(myInsertDefinition, myVertexType);
ExtractVertexProperties(ref edition,
ref revision,
ref comment,
ref vertexID,
ref creationdate,
ref modificationDate,
structured);
//set id to maximum to allow user set UUIDs
_idManager.GetVertexTypeUniqeID(myVertexType.ID).SetToMaxID(vertexID);
return Tuple.Create(revision, new VertexAddDefinition(vertexID,
myVertexType.ID,
edition,
hyperEdges,
singleEdges,
null,
binaries,
comment,
creationdate,
modificationDate,
structured,
myInsertDefinition.UnstructuredProperties));
}
示例2: ProcessAttributeRemoveList
private void ProcessAttributeRemoveList(IVertexType vertexType, GQLPluginManager myPluginManager, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, AttributeRemoveList attributeRemoveList, ref RequestUpdate result)
{
if (attributeRemoveList.TupleDefinition is VertexTypeVertexIDCollectionNode)
{
#region setofUUIDs
var edgedef = new EdgePredefinition(attributeRemoveList.AttributeName);
List<EdgePredefinition> toBeRemovedEdges = new List<EdgePredefinition>();
foreach (var aTupleElement in ((VertexTypeVertexIDCollectionNode)attributeRemoveList.TupleDefinition).Elements)
{
foreach (var aVertexIDTuple in aTupleElement.VertexIDs)
{
var innerEdge = new EdgePredefinition();
innerEdge.AddVertexID(aTupleElement.ReferencedVertexTypeName, aVertexIDTuple.Item1);
edgedef.AddEdge(innerEdge);
}
}
result.RemoveElementsFromCollection(attributeRemoveList.AttributeName, edgedef);
#endregion
}
else if (attributeRemoveList.TupleDefinition is TupleDefinition)
{
if (((TupleDefinition)attributeRemoveList.TupleDefinition).All(_ => _.Value is ValueDefinition))
{
#region base-set
//has to be list of comparables
ListCollectionWrapper listWrapper = new ListCollectionWrapper();
Type myRequestedType;
if (vertexType.HasProperty(attributeRemoveList.AttributeIDChain.ContentString))
{
myRequestedType = ((IPropertyDefinition)vertexType.GetAttributeDefinition(attributeRemoveList.AttributeIDChain.ContentString)).BaseType;
}
else
{
myRequestedType = typeof(String);
}
foreach (var aTupleElement in (TupleDefinition)attributeRemoveList.TupleDefinition)
{
listWrapper.Add(((ValueDefinition)aTupleElement.Value).Value.ConvertToIComparable(myRequestedType));
}
result.RemoveElementsFromCollection(attributeRemoveList.AttributeIDChain.ContentString, listWrapper);
#endregion
}
else
{
#region binaryExpression
Dictionary<String, EdgePredefinition> toBeRemovedEdges = new Dictionary<String, EdgePredefinition>();
foreach (var aTupleElement in ((TupleDefinition)attributeRemoveList.TupleDefinition))
{
if (aTupleElement.Value is BinaryExpressionDefinition)
{
#region BinaryExpressionDefinition
if (!vertexType.HasAttribute(attributeRemoveList.AttributeName))
{
throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.", vertexType.Name, attributeRemoveList.AttributeName));
}
IAttributeDefinition attribute = vertexType.GetAttributeDefinition(attributeRemoveList.AttributeName);
var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;
var vertexIDs = ProcessBinaryExpression(
(BinaryExpressionDefinition)aTupleElement.Value,
myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType).ToList();
if (vertexIDs.Count > 1)
{
throw new ReferenceAssignmentExpectedException(String.Format("It is not possible to create a single edge pointing to {0} vertices", vertexIDs.Count));
}
EdgePredefinition outValue = null;
if (toBeRemovedEdges.TryGetValue(attributeRemoveList.AttributeName, out outValue))
{
foreach (var aVertex in vertexIDs)
{
outValue.AddEdge(new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID));
}
}
else
{
EdgePredefinition edge = new EdgePredefinition(attributeRemoveList.AttributeName);
foreach (var aVertex in vertexIDs)
{
edge.AddEdge(new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID));
}
//.........这里部分代码省略.........
示例3: CreateVertexUpdateDefinition
private Tuple<long?, String, VertexUpdateDefinition> CreateVertexUpdateDefinition(
IVertex myVertex,
IVertexType myVertexType,
RequestUpdate myUpdate,
IPropertyProvider myPropertyCopy,
Int64 myTransaction,
SecurityToken mySecurity)
{
#region get removes
List<long> toBeDeletedSingle = null;
List<long> toBeDeletedHyper = null;
List<long> toBeDeletedStructured = null;
List<String> toBeDeletedUnstructured = null;
List<long> toBeDeletedBinaries = null;
if (myUpdate.RemovedAttributes != null)
{
#region remove each defined attribute
foreach (var name in myUpdate.RemovedAttributes)
{
if (myVertexType.HasAttribute(name))
{
var attr = myVertexType.GetAttributeDefinition(name);
switch (attr.Kind)
{
case AttributeType.Property:
if ((attr as IPropertyDefinition).IsMandatory)
throw new MandatoryConstraintViolationException(attr.Name);
toBeDeletedStructured = toBeDeletedStructured ?? new List<long>();
toBeDeletedStructured.Add(attr.ID);
break;
case AttributeType.BinaryProperty:
toBeDeletedBinaries = toBeDeletedBinaries ?? new List<long>();
toBeDeletedBinaries.Add(attr.ID);
break;
case AttributeType.IncomingEdge:
//TODO: a better exception here.
throw new Exception("The edges on an incoming edge attribute can not be removed.");
case AttributeType.OutgoingEdge:
switch ((attr as IOutgoingEdgeDefinition).Multiplicity)
{
case EdgeMultiplicity.HyperEdge:
case EdgeMultiplicity.MultiEdge:
toBeDeletedHyper = toBeDeletedHyper ?? new List<long>();
toBeDeletedHyper.Add(attr.ID);
break;
case EdgeMultiplicity.SingleEdge:
toBeDeletedSingle = toBeDeletedSingle ?? new List<long>();
toBeDeletedSingle.Add(attr.ID);
break;
default:
//TODO a better exception here
throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement.");
}
break;
default:
//TODO: a better exception here.
throw new Exception("The enumeration AttributeType was updated, but not this switch statement.");
}
}
else
{
toBeDeletedUnstructured = toBeDeletedUnstructured ?? new List<String>();
toBeDeletedUnstructured.Add(name);
}
}
#endregion
}
if (myUpdate.RemovedUnstructuredProperties != null)
{
#region remove each unstructured property
foreach (var name in myUpdate.RemovedUnstructuredProperties)
{
if ((myVertexType.HasAttribute(name)) && (myVertexType.GetAttributeDefinition(name).Kind == AttributeType.Property))
{
toBeDeletedUnstructured = toBeDeletedUnstructured ?? new List<String>();
toBeDeletedUnstructured.Add(name);
}
}
#endregion
}
#endregion
#region get update definitions
//.........这里部分代码省略.........
示例4: ProcessAttributeAssignOrUpdateSetRef
private void ProcessAttributeAssignOrUpdateSetRef(IVertexType vertexType, GQLPluginManager myPluginManager, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, AttributeAssignOrUpdateSetRef attributeAssignOrUpdateSetRef, ref RequestUpdate result)
{
#region SetRefNode
var edgeDefinition = new EdgePredefinition(attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString);
if (attributeAssignOrUpdateSetRef.SetRefDefinition.IsREFUUID)
{
#region direct vertex ids
foreach (var aTupleElement in attributeAssignOrUpdateSetRef.SetRefDefinition.TupleDefinition)
{
if (aTupleElement.Value is ValueDefinition)
{
#region ValueDefinition
foreach (var aProperty in aTupleElement.Parameters)
{
edgeDefinition.AddUnknownProperty(aProperty.Key, aProperty.Value);
}
edgeDefinition.AddVertexID(
attributeAssignOrUpdateSetRef.SetRefDefinition.ReferencedVertexType,
Convert.ToInt64(((ValueDefinition)aTupleElement.Value).Value));
#endregion
}
else
{
throw new NotImplementedQLException("TODO");
}
}
result.UpdateEdge(edgeDefinition);
#endregion
}
else
{
#region expression
if (!vertexType.HasAttribute(attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString))
{
throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.", vertexType.Name, attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString));
}
IAttributeDefinition attribute = vertexType.GetAttributeDefinition(attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString);
foreach (var aTupleElement in attributeAssignOrUpdateSetRef.SetRefDefinition.TupleDefinition)
{
if (aTupleElement.Value is BinaryExpressionDefinition)
{
#region BinaryExpressionDefinition
var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;
var vertexIDs = ProcessBinaryExpression(
(BinaryExpressionDefinition)aTupleElement.Value,
myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType).ToList();
if (vertexIDs.Count > 1)
{
throw new ReferenceAssignmentExpectedException(String.Format("It is not possible to create a single edge pointing to {0} vertices", vertexIDs.Count));
}
var inneredge = new EdgePredefinition();
foreach (var aStructuredProperty in aTupleElement.Parameters)
{
edgeDefinition.AddUnknownProperty(aStructuredProperty.Key, aStructuredProperty.Value);
}
edgeDefinition.AddVertexID(vertexIDs.FirstOrDefault().VertexTypeID, vertexIDs.FirstOrDefault().VertexID);
#endregion
}
else
{
throw new NotImplementedQLException("");
}
}
#endregion
result.UpdateEdge(edgeDefinition);
return;
}
#endregion
}
示例5: ProcessAttributeAssignOrUpdateList
private void ProcessAttributeAssignOrUpdateList(IVertexType vertexType, GQLPluginManager myPluginManager, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, AttributeAssignOrUpdateList attributeAssignOrUpdateList, ref RequestUpdate result)
{
Type myRequestedType;
switch (attributeAssignOrUpdateList.CollectionDefinition.CollectionType)
{
case CollectionType.Set:
#region set
if (((TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition).All(_ => _.Value is ValueDefinition))
{
#region base-set
//has to be list of comparables
SetCollectionWrapper setWrapper = new SetCollectionWrapper();
if (vertexType.HasProperty(attributeAssignOrUpdateList.AttributeIDChain.ContentString))
{
myRequestedType = ((IPropertyDefinition)vertexType.GetAttributeDefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString)).BaseType;
}
else
{
myRequestedType = typeof(String);
}
foreach (var aTupleElement in (TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition)
{
setWrapper.Add(((ValueDefinition)aTupleElement.Value).Value.ConvertToIComparable(myRequestedType));
}
result.AddElementsToCollection(attributeAssignOrUpdateList.AttributeIDChain.ContentString, setWrapper);
#endregion
}
else
{
#region edge-set
EdgePredefinition edgeDefinition = new EdgePredefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString);
if (!vertexType.HasAttribute(attributeAssignOrUpdateList.AttributeIDChain.ContentString))
{
throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.", vertexType.Name, attributeAssignOrUpdateList.AttributeIDChain.ContentString));
}
IAttributeDefinition attribute = vertexType.GetAttributeDefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString);
foreach (var aTupleElement in (TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition)
{
if (aTupleElement.Value is BinaryExpressionDefinition)
{
#region BinaryExpressionDefinition
var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;
foreach (var aVertex in ProcessBinaryExpression(
(BinaryExpressionDefinition)aTupleElement.Value,
myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType))
{
var inneredge = new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID);
foreach (var aStructuredProperty in aTupleElement.Parameters)
{
inneredge.AddUnknownProperty(aStructuredProperty.Key, aStructuredProperty.Value);
}
edgeDefinition.AddEdge(inneredge);
}
#endregion
}
else
{
throw new NotImplementedQLException("TODO");
}
}
if (attributeAssignOrUpdateList.Assign)
{
result.UpdateEdge(edgeDefinition);
}
else
{
result.AddElementsToCollection(attributeAssignOrUpdateList.AttributeIDChain.ContentString, edgeDefinition);
}
#endregion
}
#endregion
return;
case CollectionType.List:
#region list
//has to be list of comparables
ListCollectionWrapper listWrapper = new ListCollectionWrapper();
if (vertexType.HasProperty(attributeAssignOrUpdateList.AttributeIDChain.ContentString))
//.........这里部分代码省略.........
示例6: ProcessStructuredProperty
private static void ProcessStructuredProperty(GQLPluginManager myPluginManager,
IGraphDB myGraphDB,
SecurityToken mySecurityToken,
Int64 myTransactionToken,
IVertexType vertexType,
AAttributeAssignOrUpdate aAttributeDefinition,
ref RequestInsertVertex result)
{
#region AttributeAssignOrUpdateValue
if (aAttributeDefinition is AttributeAssignOrUpdateValue)
{
var value = aAttributeDefinition as AttributeAssignOrUpdateValue;
result.AddUnknownProperty(value.AttributeIDChain.ContentString, value.Value);
return;
}
#endregion
#region AttributeAssignOrUpdateList
if (aAttributeDefinition is AttributeAssignOrUpdateList)
{
var value = aAttributeDefinition as AttributeAssignOrUpdateList;
switch (value.CollectionDefinition.CollectionType)
{
case CollectionType.Set:
#region set
if (!vertexType.HasAttribute(aAttributeDefinition.AttributeIDChain.ContentString))
{
throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.",
vertexType.Name,
aAttributeDefinition.AttributeIDChain.ContentString));
}
IAttributeDefinition attribute = vertexType.GetAttributeDefinition(aAttributeDefinition
.AttributeIDChain
.ContentString);
EdgePredefinition edgeDefinition = new EdgePredefinition(value.AttributeIDChain.ContentString);
foreach (var aTupleElement in (TupleDefinition)value.CollectionDefinition.TupleDefinition)
{
if (aTupleElement.Value is BinaryExpressionDefinition)
{
#region BinaryExpressionDefinition
var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;
foreach (var aVertex in ProcessBinaryExpression(
(BinaryExpressionDefinition)aTupleElement.Value,
myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType))
{
var inneredge = new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID);
foreach (var aStructuredProperty in aTupleElement.Parameters)
{
inneredge.AddUnknownProperty(aStructuredProperty.Key, aStructuredProperty.Value);
}
edgeDefinition.AddEdge(inneredge);
}
#endregion
}
else
{
throw new NotImplementedQLException("TODO");
}
}
result.AddEdge(edgeDefinition);
#endregion)
return;
case CollectionType.List:
#region list
//has to be list of comparables
ListCollectionWrapper listWrapper = new ListCollectionWrapper();
Type myRequestedType;
if (vertexType.HasProperty(aAttributeDefinition.AttributeIDChain.ContentString))
{
myRequestedType = ((IPropertyDefinition)vertexType
.GetAttributeDefinition(aAttributeDefinition.AttributeIDChain.ContentString)).BaseType;
}
else
{
myRequestedType = typeof(String);
}
//.........这里部分代码省略.........
示例7: RenameAttributes
/// <summary>
/// Renames attributes
/// </summary>
/// <param name="myToBeRenamedAttributes"></param>
/// <param name="vertexType"></param>
/// <param name="myTransactionToken"></param>
/// <param name="mySecurityToken"></param>
private void RenameAttributes(Dictionary<string, string> myToBeRenamedAttributes, IVertexType vertexType, TransactionToken myTransactionToken, SecurityToken mySecurityToken)
{
if (!myToBeRenamedAttributes.IsNotNullOrEmpty())
return;
foreach (var aToBeRenamedAttribute in myToBeRenamedAttributes)
{
VertexUpdateDefinition update = new VertexUpdateDefinition(null, new StructuredPropertiesUpdate(new Dictionary<long, IComparable> { { (long)AttributeDefinitions.AttributeDotName, aToBeRenamedAttribute.Value } }));
var attribute = vertexType.GetAttributeDefinition(aToBeRenamedAttribute.Key);
switch (attribute.Kind)
{
case AttributeType.Property:
_vertexManager.ExecuteManager.VertexStore.UpdateVertex(mySecurityToken, myTransactionToken, attribute.ID, (long)BaseTypes.Property, update);
break;
case AttributeType.IncomingEdge:
_vertexManager.ExecuteManager.VertexStore.UpdateVertex(mySecurityToken, myTransactionToken, attribute.ID, (long)BaseTypes.IncomingEdge, update);
break;
case AttributeType.OutgoingEdge:
_vertexManager.ExecuteManager.VertexStore.UpdateVertex(mySecurityToken, myTransactionToken, attribute.ID, (long)BaseTypes.OutgoingEdge, update);
break;
case AttributeType.BinaryProperty:
_vertexManager.ExecuteManager.VertexStore.UpdateVertex(mySecurityToken, myTransactionToken, attribute.ID, (long)BaseTypes.BinaryProperty, update);
break;
default:
break;
}
}
}
示例8: PrintAllVerticesInBase
private void PrintAllVerticesInBase(IVertexType vertex_type)
{
var vertices1 = GraphDSServer.GetVertices<IEnumerable<IVertex>>(SecToken,
TransactionID,
new RequestGetVertices("User"),
(statistics, Vertices) => Vertices);
var attrName = vertex_type.GetAttributeDefinition("Name");
var attrFriendsDate = vertex_type.GetOutgoingEdgeDefinition("friends").InnerEdgeType.GetAttributeDefinition("Time");
foreach (var user in vertices1)
foreach (var hyper in user.GetAllOutgoingHyperEdges())
foreach (var edge in hyper.Item2.GetAllEdges())
Console.WriteLine("{0} - {1} Time: {2}",
user.GetPropertyAsString(attrName.ID),
edge.GetTargetVertex().GetPropertyAsString(attrName.ID),
edge.GetPropertyAsString(attrFriendsDate.ID));
}