mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
using System;
|
|
using System.Linq;
|
|
|
|
namespace Volo.Abp.Caching
|
|
{
|
|
[Serializable]
|
|
public class PersonCacheItem
|
|
{
|
|
public string Name { get; private set; }
|
|
|
|
private PersonCacheItem()
|
|
{
|
|
|
|
}
|
|
|
|
public PersonCacheItem(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
}
|
|
|
|
public class ComplexObjectAsCacheKey
|
|
{
|
|
public string Name { get; set; }
|
|
public int Age { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
// Return selective fields
|
|
//return $"{Name}_{Age}";
|
|
// Return all the fields concatenated
|
|
var sb = new System.Text.StringBuilder();
|
|
var properties = this.GetType().GetProperties()
|
|
.Where(prop => prop.CanRead && prop.CanWrite);
|
|
foreach (var prop in properties)
|
|
{
|
|
var value = prop.GetValue(this, null);
|
|
if (value != null)
|
|
{
|
|
sb.Append(value.ToString());
|
|
}
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace Sail.Testing.Caching
|
|
{
|
|
[Serializable]
|
|
public class PersonCacheItem
|
|
{
|
|
public string Name { get; private set; }
|
|
|
|
private PersonCacheItem()
|
|
{
|
|
|
|
}
|
|
|
|
public PersonCacheItem(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
}
|
|
} |