本文整理汇总了C#中StringBuilder.RemoveSuffix方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.RemoveSuffix方法的具体用法?C# StringBuilder.RemoveSuffix怎么用?C# StringBuilder.RemoveSuffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.RemoveSuffix方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGraphDMLforVertexUnstructuredProperties
private string CreateGraphDMLforVertexUnstructuredProperties(
IEnumerable<UnstructuredPropertyContainer> myUnstructuredProperties,
Dictionary<long, IPropertyDefinition> myPropertyDefinitions)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
#region build string for unstructured properties
foreach (var attribute in myUnstructuredProperties)
{
if (attribute.Property == null)
{
continue;
}
#region Single
stringBuilder.Append(String.Concat(attribute.PropertyName, " = ", CreateGraphDMLforSingleAttribute(attribute.Property)));
#endregion
stringBuilder.Append(delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
#endregion
return stringBuilder.ToString();
}
示例2: CreateGraphDMLforVertexOutgoingHyperEdges
private string CreateGraphDMLforVertexOutgoingHyperEdges(IVertexType myVertexType,
IEnumerable<HyperEdgeContainer> myEdges,
Dictionary<long, IOutgoingEdgeDefinition> myOutgoingEdgeDefinitions)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
foreach (var hyperEdge in myEdges)
{
if (hyperEdge.Edge == null)
{
continue;
}
var outgoingEdgeDef = myOutgoingEdgeDefinitions[hyperEdge.PropertyID];
foreach (var aEdge in hyperEdge.Edge.GetAllEdges().GroupBy(x => x.GetTargetVertex().VertexTypeID, y => y))
{
stringBuilder.Append(String.Concat(outgoingEdgeDef.Name,
" = ",
S_SETOFUUIDS.ToUpperString(),
TERMINAL_LT,
_vertexTypes[aEdge.Key],
TERMINAL_GT,
S_BRACKET_LEFT));
foreach (var edge in aEdge)
{
stringBuilder.Append(String.Concat(edge.GetTargetVertex().VertexID));
if (edge.GetAllProperties().Count() > 0)
{
stringBuilder.Append(String.Concat(":", S_BRACKET_LEFT));
stringBuilder.Append(CreateGraphDMLforDefinedProperties(
edge.GetAllProperties(),
outgoingEdgeDef
.InnerEdgeType
.GetAttributeDefinitions(true)
.ToDictionary(key => key.ID, value => value as IPropertyDefinition)));
if (stringBuilder.ToString().EndsWith(":" + S_BRACKET_LEFT.ToString()))
stringBuilder.RemoveEnding(2);
else if (stringBuilder.ToString().EndsWith(delimiter))
{
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
}
else
stringBuilder.Append(S_BRACKET_RIGHT);
}
stringBuilder.Append(delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
stringBuilder.Append(delimiter);
}
}
return stringBuilder.ToString();
}
示例3: CreateGraphDMLforVertexOutgoingSingleEdges
private string CreateGraphDMLforVertexOutgoingSingleEdges(IVertexType myVertexType,
IEnumerable<SingleEdgeContainer> myEdges,
Dictionary<long, IOutgoingEdgeDefinition> myOutgoingEdgeDefinitions)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
foreach (var edge in myEdges)
{
if (edge.Edge == null)
{
continue;
}
var def = myOutgoingEdgeDefinitions[edge.PropertyID];
stringBuilder.Append(String.Concat(def.Name, " = ", S_REFUUID.ToUpperString(), TERMINAL_LT, _vertexTypes[edge.Edge.GetTargetVertex().VertexTypeID], TERMINAL_GT, S_BRACKET_LEFT));
stringBuilder.Append(String.Concat(edge.Edge.GetTargetVertex().VertexID, delimiter));
if (edge.Edge.GetAllProperties().Count() > 0)
{
stringBuilder.Append(CreateGraphDMLforVertexDefinedProperties(edge.Edge.GetAllProperties(), myOutgoingEdgeDefinitions));
}
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
stringBuilder.Append(delimiter);
}
return stringBuilder.ToString();
}
示例4: CreateGraphDMLforIVertex
private string CreateGraphDMLforIVertex(
IVertexType myVertexType,
IVertex myVertex,
Dictionary<long, IPropertyDefinition> myPropertyDefinitions)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
//INSERT INTO ... VALUES (VertexID = ...,
stringBuilder.Append(String.Concat(S_INSERT.ToUpperString(),
" ",
S_INTO.ToUpperString(),
" ",
myVertexType.Name,
" ",
S_VALUES.ToUpperString(),
" ",
S_BRACKET_LEFT));
stringBuilder.Append(String.Concat(S_UUID, " = ", myVertex.VertexID.ToString(), delimiter));
#region standard attributes (creationDate, ...)
string standardProperties = CreateGraphDMLforVertexStandardProperties(myVertex);
stringBuilder.Append(standardProperties);
#endregion
#region properties (age, list<String>, ...)
string defAttrsDML = CreateGraphDMLforDefinedProperties(myVertex.GetAllProperties(),
myPropertyDefinitions);
stringBuilder.Append(defAttrsDML);
#endregion
#region unstructured data
string unstrProperties = CreateGraphDMLforVertexUnstructuredProperties(
myVertex.GetAllUnstructuredProperties(),
myPropertyDefinitions);
stringBuilder.Append(unstrProperties);
#endregion
#region outgoing edges
#region singleEdge
string outgoingSingleEdges = CreateGraphDMLforVertexOutgoingSingleEdges(
myVertexType,
myVertex.GetAllOutgoingSingleEdges(),
myVertexType.GetOutgoingEdgeDefinitions(true)
.ToDictionary(key => key.ID, value => value));
stringBuilder.Append(outgoingSingleEdges);
#endregion
#region hyperEdge
string outgoingHyperEdges = CreateGraphDMLforVertexOutgoingHyperEdges
(myVertexType,
myVertex.GetAllOutgoingHyperEdges(),
myVertexType.GetOutgoingEdgeDefinitions(true)
.ToDictionary(key => key.ID, value => value));
stringBuilder.Append(outgoingHyperEdges);
#endregion
#endregion
if (stringBuilder.ToString().EndsWith(delimiter))
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
return stringBuilder.ToString();
}
示例5: CreateGraphDMLforVertexDefinedProperties
private string CreateGraphDMLforVertexDefinedProperties(
IEnumerable<PropertyContainer> myStructuredProperties,
Dictionary<long, IOutgoingEdgeDefinition> myOutgoingEdgeDefinitions)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
foreach (var attribute in myStructuredProperties)
{
if (attribute.Property == null)
{
continue;
}
if (!myOutgoingEdgeDefinitions.ContainsKey(attribute.PropertyID))
continue;
var typeAttribute = myOutgoingEdgeDefinitions[attribute.PropertyID];
switch (typeAttribute.Multiplicity)
{
case EdgeMultiplicity.SingleEdge:
#region Single
stringBuilder.Append(String.Concat(S_BRACKET_LEFT, typeAttribute.Name, " = ", CreateGraphDMLforSingleAttribute(attribute.Property), S_BRACKET_RIGHT));
#endregion
break;
case EdgeMultiplicity.HyperEdge:
#region Set
stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOF.ToUpperString(), " ", S_BRACKET_LEFT));
foreach (var val in (attribute.Property as ICollection))
{
stringBuilder.Append(CreateGraphDMLforSingleAttribute(val) + delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
#endregion
break;
default:
throw new UnknownException(new NotImplementedException("This should never happen"));
}
}
return stringBuilder.ToString();
}
示例6: CreateGraphDMLforDefinedProperties
private string CreateGraphDMLforDefinedProperties(
IEnumerable<PropertyContainer> myStructuredProperties,
Dictionary<long, IPropertyDefinition> myPropertyDefinitions)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
#region build string for properties
foreach (var attribute in myStructuredProperties)
{
if (attribute.Property == null)
{
continue;
}
var typeAttribute = myPropertyDefinitions[attribute.PropertyID];
switch (typeAttribute.Multiplicity)
{
case PropertyMultiplicity.Single:
#region Single
stringBuilder.Append(String.Concat(typeAttribute.Name,
" = ",
CreateGraphDMLforSingleAttribute(attribute.Property),
delimiter));
#endregion
break;
case PropertyMultiplicity.List:
#region List
stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_LISTOF.ToUpperString(), " ", S_BRACKET_LEFT));
foreach (var val in (attribute.Property as ICollectionWrapper))
{
if (typeAttribute.BaseType == typeof(String))
stringBuilder.Append("'" + CreateGraphDMLforSingleAttribute(val) + "'" + delimiter);
else
stringBuilder.Append(CreateGraphDMLforSingleAttribute(val) + delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
stringBuilder.Append(delimiter);
#endregion
break;
case PropertyMultiplicity.Set:
#region Set
stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOF.ToUpperString(), " ", S_BRACKET_LEFT));
foreach (var val in (attribute.Property as ICollectionWrapper))
{
if (typeAttribute.BaseType == typeof(String))
stringBuilder.Append("'" + CreateGraphDMLforSingleAttribute(val) + "'" + delimiter);
else
stringBuilder.Append(CreateGraphDMLforSingleAttribute(val) + delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
stringBuilder.Append(delimiter);
#endregion
break;
default:
throw new UnknownException(new NotImplementedException("This should never happen"));
}
}
#endregion
return stringBuilder.ToString();
}
示例7: CreateGraphDDL_VertexType
/// <summary>
/// Creates the ddl of a type.
/// </summary>
/// <param name="myVertexType">The vertex type.</param>
private String CreateGraphDDL_VertexType(IVertexType myVertexType)
{
var stringBuilder = new StringBuilder();
String delimiter = ", ";
stringBuilder.AppendFormat("{0} ", myVertexType.Name);
#region parent type
//EXTENDS ...
if (myVertexType.HasParentType)
{
stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myVertexType.ParentVertexType.Name);
}
#endregion
#region attributes
//are there attributes
if (myVertexType.HasAttributes(false))
{
#region !incomingEdges
if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind != AttributeType.IncomingEdge))
{
//so, there are attributes that are no incoming edges
stringBuilder.Append(String.Concat(S_ATTRIBUTES.ToUpperString(), " ", S_BRACKET_LEFT));
#region properties
if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.Property))
{
stringBuilder.Append(String.Concat(CreateGraphDDLOfProperties(myVertexType.GetPropertyDefinitions(false))));
}
#endregion
#region outgoing edges
if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.OutgoingEdge))
{
stringBuilder.Append(String.Concat(CreateGraphDDLOfOutgoingEdges(myVertexType.GetOutgoingEdgeDefinitions(false), myVertexType)));
}
#endregion
if (stringBuilder.ToString().EndsWith(delimiter))
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(String.Concat(S_BRACKET_RIGHT, " "));
}
#endregion
#region incomingEdges
if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.IncomingEdge))
{
stringBuilder.Append(
String.Concat(S_INCOMINGEDGES.ToUpperString(),
" ",
S_BRACKET_LEFT.ToUpperString(),
CreateGraphDDLOfIncomingEdges(
myVertexType.GetIncomingEdgeDefinitions(false)),
S_BRACKET_RIGHT.ToUpperString(), " "));
}
#endregion
}
#endregion
#region Uniques
if (myVertexType.HasUniqueDefinitions(false))
{
if (myVertexType.GetUniqueDefinitions(false).Count() > 0)
{
stringBuilder.Append(S_UNIQUE.ToUpperString() +
" " +
S_BRACKET_LEFT.Symbol +
CreateGraphDDLOfUniqueAttributes(
myVertexType
.GetUniqueDefinitions(false)) +
S_BRACKET_RIGHT.Symbol + " ");
}
}
#endregion
#region Mandatory attributes
if (myVertexType.HasProperties(false))
{
if (myVertexType.GetPropertyDefinitions(false).Any(aProperty => aProperty.IsMandatory))
{
//.........这里部分代码省略.........
示例8: CreateGraphDMLforDBObjectUndefinedAttributes
private Exceptional<String> CreateGraphDMLforDBObjectUndefinedAttributes(DumpFormats myDumpFormat, IDictionary<String, IObject> myAttributes, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
foreach (var attribute in myAttributes)
{
#region A single value...
if (attribute.Value is ADBBaseObject)
{
stringBuilder.Append(String.Concat(attribute.Key, " = ", CreateGraphDMLforADBBaseObject(myDumpFormat, attribute.Value as ADBBaseObject)));
}
#endregion
#region ..or, it is a List or Set, since the Set constraint was already verified we can use a list
else if (attribute.Value is IBaseEdge)
{
stringBuilder.Append(String.Concat(attribute.Key, " = ", S_LISTOF.ToUpperString(), " ", S_BRACKET_LEFT));
foreach (var val in (attribute.Value as IBaseEdge))
{
stringBuilder.Append(CreateGraphDMLforADBBaseObject(myDumpFormat, val as ADBBaseObject) + delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
}
#endregion
else
{
return new Exceptional<String>(new Error_NotImplemented(new StackTrace(true)));
}
stringBuilder.Append(delimiter);
}
return new Exceptional<String>(stringBuilder.ToString());
}
示例9: CreateGraphDMLforDBObjectDefinedAttributes
private Exceptional<String> CreateGraphDMLforDBObjectDefinedAttributes(DumpFormats myDumpFormat, IDictionary<AttributeUUID, IObject> myAttributes, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream, DBContext myDBContext)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
foreach (var attribute in myAttributes)
{
if (attribute.Value == null)
{
continue;
}
var typeAttribute = myGraphDBType.GetTypeAttributeByUUID(attribute.Key);
#region Reference attributes
if (typeAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined)
{
#region IReferenceEdge
if (attribute.Value is ASetOfReferencesEdgeType)
{
#region Create edge GDML
stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOFUUIDS.ToUpperString(), " ", S_BRACKET_LEFT));
//myEdgeBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOF.ToUpperString(), " ", S_BRACKET_LEFT));
#region Create an assignment content - if edge does not contain any elements create an empty one
if ((attribute.Value as ASetOfReferencesEdgeType).GetAllReferenceIDs().CountIsGreater(0))
{
if (attribute.Value is ASetOfReferencesWithInfoEdgeType)
{
#region Create attribute assignments
foreach (var val in (attribute.Value as ASetOfReferencesWithInfoEdgeType).GetAllReferenceIDsWeighted())
{
stringBuilder.Append(String.Concat("'", val.Item1.ToString(), "'"));
if (val.Item2 != null)
{
stringBuilder.Append(String.Concat(S_colon, S_BRACKET_LEFT, CreateGraphDMLforADBBaseObject(myDumpFormat, val.Item2), S_BRACKET_RIGHT));
}
stringBuilder.Append(delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
#endregion
}
else
{
#region Create an assignment content - if edge does not contain any elements create an empty one
if ((attribute.Value as ASetOfReferencesEdgeType).GetAllReferenceIDs().CountIsGreater(0))
{
#region Create attribute assignments
foreach (var val in (attribute.Value as ASetOfReferencesEdgeType).GetAllReferenceIDs())
{
stringBuilder.Append(String.Concat("'", val.ToString(), "'"));
stringBuilder.Append(delimiter);
}
stringBuilder.RemoveSuffix(delimiter);
#endregion
}
#endregion
}
}
#endregion
stringBuilder.Append(S_BRACKET_RIGHT);
#endregion
}
#endregion
#region SingleReference
else if (typeAttribute.KindOfType == KindsOfType.SingleReference)
{
stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_REFUUID.ToUpperString(), " ", S_BRACKET_LEFT));
stringBuilder.Append(String.Concat("'", (attribute.Value as ASingleReferenceEdgeType).GetUUID().ToString(), "'"));
stringBuilder.Append(S_BRACKET_RIGHT);
}
//.........这里部分代码省略.........
示例10: CreateGraphDMLforDBObject
private Exceptional<String> CreateGraphDMLforDBObject(DumpFormats myDumpFormat, DBContext myDBContext, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream)
{
var stringBuilder = new StringBuilder();
var delimiter = ", ";
stringBuilder.Append(String.Concat(S_INSERT.ToUpperString(), " ", S_INTO.ToUpperString(), " ", myGraphDBType.Name, " ", S_VALUES.ToUpperString(), " ", S_BRACKET_LEFT));
stringBuilder.Append(String.Concat(S_UUID.ToUpperString(), " = '", myDBObjectStream.ObjectUUID.ToString(), "'", delimiter));
#region CreateGraphDMLforDBODefinedAttributes
var defAttrsDML = CreateGraphDMLforDBObjectDefinedAttributes(myDumpFormat, myDBObjectStream.GetAttributes(), myGraphDBType, myDBObjectStream, myDBContext);
if (!defAttrsDML.Success())
{
return defAttrsDML;
}
stringBuilder.Append(defAttrsDML.Value);
#endregion
#region CreateGDMLforDBOUnDefinedAttributes
var undefAttrs = myDBObjectStream.GetUndefinedAttributes(myDBContext.DBObjectManager);
if (!undefAttrs.Success())
{
return new Exceptional<String>(undefAttrs);
}
if (undefAttrs.Value.Count > 0)
{
Exceptional<String> undefAttrsDML = CreateGraphDMLforDBObjectUndefinedAttributes(myDumpFormat, undefAttrs.Value, myGraphDBType, myDBObjectStream);
if (!undefAttrsDML.Success())
{
return undefAttrsDML;
}
stringBuilder.Append(undefAttrsDML.Value);
}
#endregion
stringBuilder.RemoveSuffix(delimiter);
stringBuilder.Append(S_BRACKET_RIGHT);
return new Exceptional<String>(stringBuilder.ToString());
}