mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 11:32:59 +00:00
UInt8Array fix
This commit is contained in:
parent
f9bbd603ce
commit
5f4660fde2
@ -25,7 +25,6 @@ namespace Esyur.Stores.MongoDB
|
|||||||
IMongoCollection<BsonDocument> resourcesCollection;
|
IMongoCollection<BsonDocument> resourcesCollection;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dictionary<string, WeakReference> resources = new Dictionary<string, WeakReference>();
|
Dictionary<string, WeakReference> resources = new Dictionary<string, WeakReference>();
|
||||||
|
|
||||||
|
|
||||||
@ -35,12 +34,16 @@ namespace Esyur.Stores.MongoDB
|
|||||||
[ResourceEvent]
|
[ResourceEvent]
|
||||||
public event ResourceEventHanlder ResourceRemoved;
|
public event ResourceEventHanlder ResourceRemoved;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
[ResourceProperty]
|
[ResourceProperty]
|
||||||
public virtual int Count
|
public virtual int Count
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (int)resourcesCollection.CountDocuments(x => true);
|
return count;
|
||||||
|
|
||||||
|
//return (int)resourcesCollection.Count(x => true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +88,11 @@ namespace Esyur.Stores.MongoDB
|
|||||||
this.database.DropCollection("record_" + objectId);
|
this.database.DropCollection("record_" + objectId);
|
||||||
resourcesCollection.DeleteOne(filter);
|
resourcesCollection.DeleteOne(filter);
|
||||||
|
|
||||||
|
count--;
|
||||||
|
|
||||||
ResourceRemoved?.Invoke(resource);
|
ResourceRemoved?.Invoke(resource);
|
||||||
|
|
||||||
|
|
||||||
Instance.Modified("Count");
|
Instance.Modified("Count");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -317,6 +323,8 @@ namespace Esyur.Stores.MongoDB
|
|||||||
|
|
||||||
ResourceAdded?.Invoke(resource);
|
ResourceAdded?.Invoke(resource);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
Instance.Modified("Count");
|
Instance.Modified("Count");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -543,6 +551,10 @@ namespace Esyur.Stores.MongoDB
|
|||||||
|
|
||||||
resourcesCollection = this.database.GetCollection<BsonDocument>(collectionName);
|
resourcesCollection = this.database.GetCollection<BsonDocument>(collectionName);
|
||||||
|
|
||||||
|
|
||||||
|
count = (int)resourcesCollection.CountDocuments(x => true);
|
||||||
|
|
||||||
|
|
||||||
// return new AsyncReply<bool>(true);
|
// return new AsyncReply<bool>(true);
|
||||||
|
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ namespace Esyur.Data
|
|||||||
public static sbyte[] GetInt8Array(this byte[] data, uint offset, uint length)
|
public static sbyte[] GetInt8Array(this byte[] data, uint offset, uint length)
|
||||||
{
|
{
|
||||||
var rt = new sbyte[length];
|
var rt = new sbyte[length];
|
||||||
Buffer.BlockCopy(rt, (int)offset, rt, 0, (int)length);
|
Buffer.BlockCopy(data, (int)offset, rt, 0, (int)length);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ namespace Esyur.Data
|
|||||||
public static byte[] GetUInt8Array(this byte[] data, uint offset, uint length)
|
public static byte[] GetUInt8Array(this byte[] data, uint offset, uint length)
|
||||||
{
|
{
|
||||||
var rt = new byte[length];
|
var rt = new byte[length];
|
||||||
Buffer.BlockCopy(rt, (int)offset, rt, 0, (int)length);
|
Buffer.BlockCopy(data, (int)offset, rt, 0, (int)length);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ namespace Esyur.Data
|
|||||||
//Array = 0x80,
|
//Array = 0x80,
|
||||||
VarArray = 0x80,
|
VarArray = 0x80,
|
||||||
BoolArray,
|
BoolArray,
|
||||||
UInt8Array,
|
|
||||||
Int8Array,
|
Int8Array,
|
||||||
|
UInt8Array,
|
||||||
CharArray,
|
CharArray,
|
||||||
Int16Array,
|
Int16Array,
|
||||||
UInt16Array,
|
UInt16Array,
|
||||||
|
@ -36,7 +36,7 @@ using Esyur.Core;
|
|||||||
namespace Esyur.Data
|
namespace Esyur.Data
|
||||||
{
|
{
|
||||||
|
|
||||||
public class KeyList<KT, T> : IEnumerable
|
public class KeyList<KT, T> : IEnumerable<KeyValuePair<KT, T>>
|
||||||
{
|
{
|
||||||
private readonly object syncRoot = new object();
|
private readonly object syncRoot = new object();
|
||||||
private Dictionary<KT, T> dic;
|
private Dictionary<KT, T> dic;
|
||||||
@ -144,11 +144,18 @@ namespace Esyur.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
|
||||||
|
public IEnumerator<KeyValuePair<KT, T>> GetEnumerator()
|
||||||
{
|
{
|
||||||
return dic.GetEnumerator();
|
return dic.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return dic.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
if (removableList)
|
if (removableList)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Net\DataLink\Sources\" />
|
<Folder Include="Net\DataLink\Sources\" />
|
||||||
|
<Folder Include="obj\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1167,7 +1167,7 @@ namespace Esyur.Net.IIP
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rt is System.Collections.IEnumerable && !(rt is Array))
|
if (rt is System.Collections.IEnumerable && !(rt is Array || rt is Structure))
|
||||||
{
|
{
|
||||||
var enu = rt as System.Collections.IEnumerable;
|
var enu = rt as System.Collections.IEnumerable;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Esyur.Net.IIP;
|
using Esyur.Net.IIP;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Esyur.Misc;
|
||||||
|
|
||||||
namespace Esyur.Resource
|
namespace Esyur.Resource
|
||||||
{
|
{
|
||||||
@ -82,6 +83,8 @@ namespace Esyur.Resource
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WeakReference<IResource>[] Resources => resources.Values.ToArray();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a resource by instance Id.
|
/// Get a resource by instance Id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -475,6 +478,9 @@ namespace Esyur.Resource
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var t = resource.GetType();
|
||||||
|
Global.Counters["T-" + t.Namespace + "." + t.Name]++;
|
||||||
|
|
||||||
resources.Add(resource.Instance.Id, new WeakReference<IResource>(resource));
|
resources.Add(resource.Instance.Id, new WeakReference<IResource>(resource));
|
||||||
|
|
||||||
if (warehouseIsOpen)
|
if (warehouseIsOpen)
|
||||||
@ -531,7 +537,9 @@ namespace Esyur.Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Put(res, name, store, parent, null, 0, manager, attributes);
|
if (store != null || parent != null || res is IStore)
|
||||||
|
Put(res, name, store, parent, null, 0, manager, attributes);
|
||||||
|
|
||||||
return (T)res;
|
return (T)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace Esyur.Stores
|
|||||||
|
|
||||||
public event DestroyedEvent OnDestroy;
|
public event DestroyedEvent OnDestroy;
|
||||||
|
|
||||||
Dictionary<uint, IResource> resources = new Dictionary<uint, IResource>();
|
KeyList<uint, IResource> resources = new KeyList<uint, IResource>();
|
||||||
|
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
@ -37,11 +37,13 @@ namespace Esyur.Stores
|
|||||||
if (r.Value.Instance.Name == path)
|
if (r.Value.Instance.Name == path)
|
||||||
return new AsyncReply<IResource>(r.Value);
|
return new AsyncReply<IResource>(r.Value);
|
||||||
|
|
||||||
|
|
||||||
return new AsyncReply<IResource>(null);
|
return new AsyncReply<IResource>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Put(IResource resource)
|
public bool Put(IResource resource)
|
||||||
{
|
{
|
||||||
|
|
||||||
resources.Add(resource.Instance.Id, resource);// new WeakReference<IResource>(resource));
|
resources.Add(resource.Instance.Id, resource);// new WeakReference<IResource>(resource));
|
||||||
resource.Instance.Attributes["children"] = new AutoList<IResource, Instance>(resource.Instance);
|
resource.Instance.Attributes["children"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||||
resource.Instance.Attributes["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
resource.Instance.Attributes["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user