本文整理汇总了C#中Zetbox.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Zetbox.GetType方法的具体用法?C# Zetbox.GetType怎么用?C# Zetbox.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zetbox
的用法示例。
在下文中一共展示了Zetbox.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceObject
public static void ReplaceObject(ObjectClass obj, Zetbox.API.IDataObject target, Zetbox.API.IDataObject source)
{
if (obj == null) throw new ArgumentNullException("obj");
if (target == null) throw new ArgumentNullException("target");
if (source == null) throw new ArgumentNullException("source");
var cls = _frozenCtx.FindPersistenceObject<ObjectClass>(obj.ExportGuid);
var clsType = cls.GetDescribedInterfaceType();
if (clsType != _frozenCtx.GetInterfaceType(target)
|| clsType != _frozenCtx.GetInterfaceType(source))
{
throw new ArgumentException("source and target must match the object class");
}
Logging.Server.InfoFormat("ReplaceObject: target = {0} ({1}) - \"{2}\"; source = target = {3} ({4}) - \"{5}\"",
target.GetType().Name,
target.ID,
target,
source.GetType().Name,
source.ID,
source);
var relEnds = _frozenCtx.GetQuery<RelationEnd>()
.Where(i => i.Type == cls)
.ToList();
using (var scope = _scopeFactory.BeginLifetimeScope())
using (var ctx = scope.Resolve<IZetboxServerContext>())
{
var targetObj = ctx.FindPersistenceObject(clsType, target.ID);
var sourceObj = ctx.FindPersistenceObject(clsType, source.ID);
var sourceID = source.ID;
foreach (var relEnd in relEnds)
{
var otherEnd = relEnd.Parent.GetOtherEnd(relEnd);
var rel = relEnd.Parent;
if (otherEnd.Navigator != null)
{
var prop = otherEnd.Navigator;
var propName = prop.Name;
var refClass = (ObjectClass)prop.ObjectClass;
var ifType = refClass.GetDescribedInterfaceType();
if (prop.GetIsList())
{
Logging.Server.DebugFormat("Replacing on list {0}", propName);
foreach (var refObj in ctx.Internals().GetPersistenceObjectQuery(ifType).Where(string.Format("{0}.Any(ID == @0)", propName), sourceID))
{
refObj.RemoveFromCollection(propName, sourceObj);
refObj.AddToCollection(propName, targetObj, true);
}
}
else
{
Logging.Server.DebugFormat("Replacing on property {0}", propName);
foreach (var refObj in ctx.Internals().GetPersistenceObjectQuery(ifType).Where(string.Format("{0}.ID == @0", propName), sourceID))
{
refObj.SetPropertyValue(propName, targetObj);
}
}
}
else
{
// Not my business
// The only side that that mathers is the side, that POINTS to the object in question.
}
}
ctx.Delete(sourceObj);
ctx.SubmitChanges();
}
}