本文整理汇总了C#中IVertexType.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IVertexType.HasAttribute方法的具体用法?C# IVertexType.HasAttribute怎么用?C# IVertexType.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVertexType
的用法示例。
在下文中一共展示了IVertexType.HasAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
//.........这里部分代码省略.........
示例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: 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
}
示例4: 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))
//.........这里部分代码省略.........
示例5: 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);
}
//.........这里部分代码省略.........
示例6: ProcessAAttributeDefinition
private static void ProcessAAttributeDefinition(GQLPluginManager myPluginManager,
IGraphDB myGraphDB,
SecurityToken mySecurityToken,
Int64 myTransactionToken,
IVertexType vertexType,
AAttributeAssignOrUpdate aAttributeDefinition,
ref RequestInsertVertex result)
{
if (vertexType.HasAttribute(aAttributeDefinition.AttributeIDChain.ContentString))
{
ProcessStructuredProperty(myPluginManager,
myGraphDB,
mySecurityToken,
myTransactionToken,
vertexType,
aAttributeDefinition,
ref result);
}
else
{
ProcessUnstructuredAttribute(vertexType,
aAttributeDefinition,
ref result);
}
}