本文整理汇总了C#中Relation类的典型用法代码示例。如果您正苦于以下问题:C# Relation类的具体用法?C# Relation怎么用?C# Relation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Relation类属于命名空间,在下文中一共展示了Relation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyRememberToDeleteTemplate
private void ApplyRememberToDeleteTemplate(Relation rel, RelationEnd relEnd)
{
if (rel.GetOtherEnd(relEnd).Multiplicity == Multiplicity.ZeroOrMore)
{
if (relEnd.Navigator != null)
{
var prop = relEnd.Navigator;
this.WriteObjects(" // ", rel.GetAssociationName(), " ZeroOrMore\r\n");
this.WriteObjects(" foreach(NHibernatePersistenceObject x in ", prop.Name, ") {\r\n");
this.WriteObjects(" x.ParentsToDelete.Add(this);\r\n");
this.WriteObjects(" ChildrenToDelete.Add(x);\r\n");
this.WriteObjects(" }\r\n");
}
else
{
this.WriteObjects(" // should fetch && remember parent for ", relEnd.Parent.GetRelationClassName(), "\r\n");
}
}
else
{
if (relEnd.Navigator != null)
{
var prop = relEnd.Navigator;
this.WriteObjects(" // ", rel.GetAssociationName(), "\r\n");
this.WriteObjects(" if (", prop.Name, " != null) {\r\n");
this.WriteObjects(" ((NHibernatePersistenceObject)", prop.Name, ").ChildrenToDelete.Add(this);\r\n");
this.WriteObjects(" ParentsToDelete.Add((NHibernatePersistenceObject)", prop.Name, ");\r\n");
this.WriteObjects(" }\r\n");
}
else
{
this.WriteObjects(" // should fetch && remember children for ", relEnd.Parent.GetRelationClassName(), "\r\n");
}
}
}
示例2: GetRelationType
public static void GetRelationType(Relation rel, MethodReturnEventArgs<RelationType> e)
{
if (rel == null)
{
throw new ArgumentNullException("rel");
}
if (rel.A == null)
{
throw new ArgumentNullException("rel", "rel.A is null");
}
if (rel.B == null)
{
throw new ArgumentNullException("rel", "rel.B is null");
}
if ((rel.A.Multiplicity.UpperBound() == 1 && rel.B.Multiplicity.UpperBound() > 1)
|| (rel.A.Multiplicity.UpperBound() > 1 && rel.B.Multiplicity.UpperBound() == 1))
{
e.Result = RelationType.one_n;
}
else if (rel.A.Multiplicity.UpperBound() > 1 && rel.B.Multiplicity.UpperBound() > 1)
{
e.Result = RelationType.n_m;
}
else if (rel.A.Multiplicity.UpperBound() == 1 && rel.B.Multiplicity.UpperBound() == 1)
{
e.Result = RelationType.one_one;
}
else
{
throw new InvalidOperationException(String.Format("Unable to find out RelationType: {0}:{1}", rel.A.Multiplicity, rel.B.Multiplicity));
}
}
示例3: defineRelation
public Relation defineRelation(string name, Types element_types)
{
if (null == name) name = ".R"+m_code.relations.Count;
Relation r = new Relation(name, element_types);
m_code.relations.Add(r);
return r;
}
示例4: ApplyIndexPropertyTemplate
protected virtual void ApplyIndexPropertyTemplate(Relation rel, RelationEndRole endRole)
{
if (rel.NeedsPositionStorage(endRole))
{
// provided by ObjectReferencePropertyTemplate
string posBackingStore = "_" + endRole + Zetbox.API.Helper.PositionSuffix;
// is serialized by the ObjectReferenceProperty
//this.MembersToSerialize.Add(
// Serialization.SerializerType.All,
// relEnd.Type.Module.Namespace,
// endRole + Zetbox.API.Helper.PositionSuffix,
// posBackingStore);
this.WriteObjects(" public int? ", endRole, "Index { get { return ",
posBackingStore, "; } set { ",
posBackingStore, " = value; } }");
this.WriteLine();
}
else if (IsOrdered())
{
this.WriteLine("/// <summary>ignored implementation for INewListEntry</summary>");
this.WriteObjects("public int? ", endRole, "Index { get { return null; } set { } }");
}
}
示例5: FxnTypeToRelation
public Relation FxnTypeToRelation(CatFxnType ft)
{
Vector cons = TypeVectorToConstraintVector(ft.GetCons());
Vector prod = TypeVectorToConstraintVector(ft.GetProd());
Relation r = new Relation(cons, prod);
return r;
}
示例6: ParseElements
protected override object ParseElements(XmlDocument xml)
{
List<Relation> relations = new List<Relation>();
Relation rel;
foreach (XmlNode node in xml.DocumentElement.ChildNodes)
{
rel = new Relation(node.Name);
foreach (XmlNode auxNode in node.ChildNodes)
{
if (auxNode.Name.Equals("Subject"))
{
rel.Subject = auxNode.InnerText;
}
else if (auxNode.Name.Equals("Target"))
{
rel.Target = auxNode.InnerText;
}
else if (auxNode.Name.Equals("Value"))
{
rel.Value = Convert.ToSingle(auxNode.InnerText, CultureInfo.InvariantCulture);
}
}
relations.Add(rel);
}
return relations;
}
示例7: AddRelation
///// <summary>
/////
///// </summary>
///// <returns></returns>
//public override IEnumerable<Way> GetWays()
//{
// return _ways.Values;
//}
/// <summary>
///
/// </summary>
/// <param name="relation"></param>
public override void AddRelation(Relation relation)
{
if (relation == null) throw new ArgumentNullException("relation");
if (relation.Id == null) throw new Exception("relation.Id is null");
_relations[relation.Id.Value] = relation;
}
示例8: AddRelation
///// <summary>
/////
///// </summary>
///// <returns></returns>
//public override IEnumerable<Way> GetWays()
//{
// return _ways.Values;
//}
/// <summary>
///
/// </summary>
/// <param name="relation"></param>
public override void AddRelation(Relation relation)
{
if (relation == null) throw new ArgumentNullException("relation");
if (relation.Id == null) throw new Exception("relation.Id is null");
this.Store(relation);
}
示例9: Digraph
public Digraph(SymbolsGen s,Relation r,Func f1,Func f2,AddToFunc d)
{
sg=s; R=r; F1=f1; F2=f2; DF2=d;
N = new int[sg.m_trans];
for (int j=0;j<sg.m_trans;j++)
N[j]=0;
}
示例10: AddRelation
/// <summary>
/// Processes the given relation.
/// </summary>
/// <param name="relation"></param>
public override void AddRelation(Relation relation)
{
if (relation.Tags != null)
{
_tagsIndex.Add(relation.Tags);
}
}
示例11: Call
public static void Call(Arebis.CodeGeneration.IGenerationHost host,
IZetboxContext ctx,
Templates.Serialization.SerializationMembersList serializationList,
Relation rel, RelationEndRole endRole, string backingCollectionType)
{
if (host == null) { throw new ArgumentNullException("host"); }
if (rel == null) { throw new ArgumentNullException("rel"); }
RelationEnd relEnd = rel.GetEndFromRole(endRole);
RelationEnd otherEnd = rel.GetOtherEnd(relEnd);
string name = relEnd.Navigator.Name;
string exposedCollectionInterface = rel.NeedsPositionStorage(otherEnd.GetRole()) ? "IList" : "ICollection";
string referencedInterface = otherEnd.Type.GetDataTypeString();
string backingName = "_" + name;
string aSideType = rel.A.Type.GetDataTypeString();
string bSideType = rel.B.Type.GetDataTypeString();
string entryType = rel.GetRelationFullName() + host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
string providerCollectionType = (rel.NeedsPositionStorage(otherEnd.GetRole()) ? "IList<" : "ICollection<")
+ entryType + ">";
bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
bool serializeRelationEntries = rel.GetRelationType() == RelationType.n_m;
string entryProxyType = entryType + "." + rel.GetRelationClassName() + "Proxy";
string inverseNavigatorName = otherEnd.Navigator != null ? otherEnd.Navigator.Name : null;
Call(host, ctx, serializationList, name, exposedCollectionInterface, referencedInterface, backingName, backingCollectionType, aSideType, bSideType, entryType, providerCollectionType, rel.ExportGuid, endRole, eagerLoading, serializeRelationEntries, entryProxyType, inverseNavigatorName);
}
示例12: IsMyGame
public static bool IsMyGame(Relation relation)
{
return relation ==
Relation.IamPlayingAndMyMove
|| relation ==
Relation.IamPlayingAndMyOppsMove;
}
示例13: RelationDebugTemplate
public RelationDebugTemplate(Arebis.CodeGeneration.IGenerationHost _host, IZetboxContext ctx, Relation rel)
: base(_host)
{
this.ctx = ctx;
this.rel = rel;
}
示例14: MoveNode
internal static void MoveNode(int nodeId, int? oldParentId, int? newParentId)
{
using (CompAgriConnection ctx = new CompAgriConnection())
{
var relation = ctx.Relations.Where(o => o.Relation_Parent_Term_Id == oldParentId && o.Relation_Child_Term_Id == nodeId)
.FirstOrDefault();
if (relation != null)
{
relation.Relation_Parent_Term_Id = newParentId;
}
else
{
relation = new Relation
{
Relation_Child_Term_Id = nodeId,
Relation_Parent_Term_Id = newParentId
};
ctx.Relations.Add(relation);
}
ctx.SaveChanges();
}
}
示例15: TryWriteContentRelation
private bool TryWriteContentRelation(Relation<ContentItem> relation)
{
if (relation == null)
return false;
writer.Write(relation.ID);
return true;
}