mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 03:32:57 +00:00
UInt8Array fix
This commit is contained in:
parent
f9bbd603ce
commit
5f4660fde2
@ -25,7 +25,6 @@ namespace Esyur.Stores.MongoDB
|
||||
IMongoCollection<BsonDocument> resourcesCollection;
|
||||
|
||||
|
||||
|
||||
Dictionary<string, WeakReference> resources = new Dictionary<string, WeakReference>();
|
||||
|
||||
|
||||
@ -35,12 +34,16 @@ namespace Esyur.Stores.MongoDB
|
||||
[ResourceEvent]
|
||||
public event ResourceEventHanlder ResourceRemoved;
|
||||
|
||||
int count = 0;
|
||||
|
||||
[ResourceProperty]
|
||||
public virtual int Count
|
||||
{
|
||||
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);
|
||||
resourcesCollection.DeleteOne(filter);
|
||||
|
||||
count--;
|
||||
|
||||
ResourceRemoved?.Invoke(resource);
|
||||
|
||||
|
||||
Instance.Modified("Count");
|
||||
|
||||
return true;
|
||||
@ -317,6 +323,8 @@ namespace Esyur.Stores.MongoDB
|
||||
|
||||
ResourceAdded?.Invoke(resource);
|
||||
|
||||
count++;
|
||||
|
||||
Instance.Modified("Count");
|
||||
|
||||
return true;
|
||||
@ -543,6 +551,10 @@ namespace Esyur.Stores.MongoDB
|
||||
|
||||
resourcesCollection = this.database.GetCollection<BsonDocument>(collectionName);
|
||||
|
||||
|
||||
count = (int)resourcesCollection.CountDocuments(x => true);
|
||||
|
||||
|
||||
// return new AsyncReply<bool>(true);
|
||||
|
||||
|
||||
|
@ -640,7 +640,7 @@ namespace Esyur.Data
|
||||
public static sbyte[] GetInt8Array(this byte[] data, uint offset, uint 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;
|
||||
}
|
||||
|
||||
@ -652,7 +652,7 @@ namespace Esyur.Data
|
||||
public static byte[] GetUInt8Array(this byte[] data, uint offset, uint 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;
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,8 @@ namespace Esyur.Data
|
||||
//Array = 0x80,
|
||||
VarArray = 0x80,
|
||||
BoolArray,
|
||||
UInt8Array,
|
||||
Int8Array,
|
||||
UInt8Array,
|
||||
CharArray,
|
||||
Int16Array,
|
||||
UInt16Array,
|
||||
|
@ -36,7 +36,7 @@ using Esyur.Core;
|
||||
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 Dictionary<KT, T> dic;
|
||||
@ -144,11 +144,18 @@ namespace Esyur.Data
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
|
||||
public IEnumerator<KeyValuePair<KT, T>> GetEnumerator()
|
||||
{
|
||||
return dic.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return dic.GetEnumerator();
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (removableList)
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Net\DataLink\Sources\" />
|
||||
<Folder Include="obj\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1167,7 +1167,7 @@ namespace Esyur.Net.IIP
|
||||
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;
|
||||
|
||||
|
@ -34,6 +34,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Esyur.Net.IIP;
|
||||
using System.Text.RegularExpressions;
|
||||
using Esyur.Misc;
|
||||
|
||||
namespace Esyur.Resource
|
||||
{
|
||||
@ -82,6 +83,8 @@ namespace Esyur.Resource
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WeakReference<IResource>[] Resources => resources.Values.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Get a resource by instance Id.
|
||||
/// </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));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace Esyur.Stores
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
Dictionary<uint, IResource> resources = new Dictionary<uint, IResource>();
|
||||
KeyList<uint, IResource> resources = new KeyList<uint, IResource>();
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
@ -37,11 +37,13 @@ namespace Esyur.Stores
|
||||
if (r.Value.Instance.Name == path)
|
||||
return new AsyncReply<IResource>(r.Value);
|
||||
|
||||
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public bool Put(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["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
|
Loading…
x
Reference in New Issue
Block a user