本文整理汇总了C#中ObjectReference类的典型用法代码示例。如果您正苦于以下问题:C# ObjectReference类的具体用法?C# ObjectReference怎么用?C# ObjectReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectReference类属于命名空间,在下文中一共展示了ObjectReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JoinClause
public JoinClause(ObjectReference table, JoinType joinType, SimpleExpression joinExpression)
{
if (table == null) throw new ArgumentNullException("table");
_table = table;
_joinType = joinType;
_joinExpression = joinExpression;
}
示例2: UnmarshallingContext
public UnmarshallingContext(Transaction transaction, ByteArrayBuffer buffer, ObjectReference
@ref, int addToIDTree, bool checkIDTree) : base(transaction, buffer, null, @ref
)
{
_addToIDTree = addToIDTree;
_checkIDTree = checkIDTree;
}
示例3: InferJoinExpression
private SimpleExpression InferJoinExpression(ObjectReference table)
{
if (table.GetOwner().IsNull()) return null;
var table1 = _schema.FindTable(table.GetOwner().GetName());
var table2 = _schema.FindTable(table.GetName());
var foreignKey = GetForeignKey(table1, table2);
return MakeJoinExpression(table, foreignKey);
}
示例4: ObjectReferenceTest
public void ObjectReferenceTest()
{
var reference = new ObjectReference<Person>(() => new Person());
Assert.IsFalse(reference.HasTarget);
var target = reference.Target;
Assert.IsTrue(reference.HasTarget);
}
示例5: IdResolutionGet
public void IdResolutionGet()
{
var itemInfo = TestItems.Item(ItemCode.MissileLauncher);
var idResolution = new IdResolutionContext(new[] { itemInfo, });
var objRef = new ObjectReference(itemInfo.ObjectId);
idResolution.Get<ItemInfo>(objRef);
}
示例6: GetColumn
private Column GetColumn(ObjectReference reference)
{
if (ReferenceEquals(reference, null))
{
return null;
}
var table = _schema.FindTable(reference.GetOwner().ToString());
return table.FindColumn(reference.GetName());
}
示例7: BuildElementResolver
private static Func<XElement, XElement> BuildElementResolver(ObjectReference reference)
{
var elementNames = reference.GetAllObjectNames();
if (elementNames.Length == 2)
{
return xml => xml;
}
return BuildNestedElementResolver(elementNames);
}
示例8: IdResolutionFail
public void IdResolutionFail()
{
const long id = 1L;
var itemInfo = TestItems.Item(ItemCode.MissileLauncher);
var idResolution = new IdResolutionContext(new[] { itemInfo, });
var objRef = new ObjectReference(id);
Should.Throw<ItemNotFoundException>(() => idResolution.Get<ItemInfo>(objRef)).Message.ShouldBe("Could not find ItemInfo \"[x00000001]\"");
Should.Throw<ItemNotFoundException>(() => idResolution.GetById<ItemInfo>(id)).Message.ShouldBe("Could not find ItemInfo \"1\"");
}
示例9: CriteriaDictionaryToExpression
public static SimpleExpression CriteriaDictionaryToExpression(ObjectReference table, IEnumerable<KeyValuePair<string, object>> dictionary)
{
if (dictionary.Count() == 1)
{
return CriteriaPairToExpression(table, dictionary.Single());
}
return new SimpleExpression(CriteriaPairToExpression(table, dictionary.First()),
CriteriaDictionaryToExpression(table, dictionary.Skip(1)),
SimpleExpressionType.And);
}
示例10: CriteriaDictionaryToExpression
public static SimpleExpression CriteriaDictionaryToExpression(ObjectReference table, IEnumerable<KeyValuePair<string, object>> dictionary)
{
var list = dictionary.ToList();
if (list.Count == 1)
{
return CriteriaPairToExpression(table, list[0]);
}
return new SimpleExpression(CriteriaPairToExpression(table, list[0]),
CriteriaDictionaryToExpression(table, list.Skip(1)),
SimpleExpressionType.And);
}
示例11: Get
public override IDictionary<string, object> Get(string tableName, params object[] keyValues)
{
if (!_keyColumns.ContainsKey(tableName)) throw new InvalidOperationException("No key specified for In-Memory table.");
var keys = _keyColumns[tableName];
if (keys.Length != keyValues.Length) throw new ArgumentException("Incorrect number of values for key.");
var expression = new ObjectReference(keys[0]) == keyValues[0];
for (int i = 1; i < keyValues.Length; i++)
{
expression = expression && new ObjectReference(keys[i]) == keyValues[i];
}
return Find(tableName, expression).FirstOrDefault();
}
示例12: GetId
public int GetId(object obj)
{
var reference = new ObjectReference(obj);
int id;
if (objToId.TryGetValue(reference, out id)) {
return id;
}
else {
var new_id = AllocateId();
objToId.Add(reference, new_id);
return new_id;
}
}
示例13: DisposeTest
public void DisposeTest()
{
var reference = new ObjectReference<Person>(() => new Person());
reference.Disposed += Reference_Disposed;
Assert.IsFalse(reference.HasTarget);
Assert.IsFalse(reference.IsDisposed);
reference.Dispose();
Assert.IsTrue(reference.IsDisposed);
var target = reference.Target;
}
示例14: GetResult
public virtual async Task<Paged<Entities.Url>> GetResult(Filter.Simple.Data.Filter filter, int? accountId = null)
{
filter.Resource = "Urls";
DataStrategy strategy = Database.Open();
var query = new SimpleQuery(strategy, filter.Resource);
var limit = _limit.Apply(filter);
var skip = _skip.Apply(filter);
dynamic accounts;
query = query.Join(ObjectReference.FromString("Accounts"), JoinType.Inner, out accounts)
.On(accounts.Id == new ObjectReference("AccountId", ObjectReference.FromString("Urls")))
.Select(
new ObjectReference("Id", ObjectReference.FromString("Urls")),
new ObjectReference("Address", ObjectReference.FromString("Urls")),
new ObjectReference("Id", ObjectReference.FromString("Accounts")).As("Account_Id"))
.Skip(_skip.Apply(filter))
.Take(_limit.Apply(filter));
if (accountId.HasValue)
{
var leftOperand = new ObjectReference("AccountId", ObjectReference.FromString("Urls"));
query.Where(new SimpleExpression(leftOperand, accountId, SimpleExpressionType.Equal));
}
if (filter.HasOrdering)
{
query = query.OrderBy(_order.Apply(filter), OrderByDirection.Ascending);
}
var data = await query.ToList<dynamic>();
var entities = AutoMapper.MapDynamic<Entities.Url>(data).ToList();
if (!entities.Any())
{
return null;
}
return new Paged<Entities.Url>
{
Limit = limit,
Skip = skip,
Data = entities
};
}
示例15: MarshallingContext
public MarshallingContext(Transaction trans, ObjectReference
@ref, IUpdateDepth updateDepth, bool isNew)
{
// YapClass ID
// Marshaller Version
// number of fields
_transaction = trans;
_reference = @ref;
_nullBitMap = new BitMap4(AspectCount());
_updateDepth = ClassMetadata().AdjustUpdateDepth(trans, updateDepth);
_isNew = isNew;
_writeBuffer = new MarshallingBuffer();
_currentBuffer = _writeBuffer;
}