Comments (6)
using AqlaSerializer.Meta;
namespace ConsoleApp5
{
public class Test
{
public void RegisterCollectionClassWithMemberFields()
{
var model = RuntimeTypeModel.Default;
var metaType = model.Add(typeof(WithCollectionClassWithMemberFields), true);
metaType.AsReferenceDefault = true;
metaType.UseConstructor = false;
var metaType2 = model.Add(typeof(CollectionClassWithArrayField), true);
metaType2.AsReferenceDefault = true;
metaType2.UseConstructor = false;
metaType2.IgnoreListHandling = true;
var metaField = metaType.AddField(1, "_collectionClassWithArrayFields");
metaField.SetSettings(x => x.V.Format = AqlaSerializer.ValueFormat.Reference, 0);
var metaField2 = metaType2.AddField(1, "_params");
metaField2.SetSettings(x => x.V.Format = AqlaSerializer.ValueFormat.Reference, 0);
model.CompileInPlace();
}
[Serializable]
private class WithCollectionClassWithMemberFields
{
private readonly CollectionClassWithArrayField _collectionClassWithArrayFields;
public WithCollectionClassWithMemberFields(CollectionClassWithArrayField collectionClassWithMemberFields)
{
_collectionClassWithArrayFields = collectionClassWithMemberFields;
}
}
[Serializable]
private class CollectionClassWithArrayField : IList<double>
{
private readonly double[] _params;
public CollectionClassWithArrayField(int size)
{
_params = new double[size];
}
public double this[int index]
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public int Count
{
get
{
throw new NotImplementedException();
}
}
public bool IsReadOnly
{
get
{
throw new NotImplementedException();
}
}
public void Add(double item)
{
throw new NotImplementedException();
}
public void Clear()
{
throw new NotImplementedException();
}
public bool Contains(double item)
{
throw new NotImplementedException();
}
public void CopyTo(double[] array, int arrayIndex)
{
throw new NotImplementedException();
}
public IEnumerator<double> GetEnumerator()
{
throw new NotImplementedException();
}
public int IndexOf(double item)
{
throw new NotImplementedException();
}
public void Insert(int index, double item)
{
throw new NotImplementedException();
}
public bool Remove(double item)
{
throw new NotImplementedException();
}
public void RemoveAt(int index)
{
throw new NotImplementedException();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
}
}
}
from aqlaserializer.
AsReference
changes settings for all levels where double[]
is level 0 and double
is level 1. You need to change settings only for level 0. This is why it's marked obsolete.
from aqlaserializer.
Thanks for the solution. I'm using reflections to setup the default model. We have more than 10k classes. Is it possible to make the Aqla APIs more easily to use? For example, AsReference only change level 0 by default. Also, can Aqla be enhanced to automatically detect the double array and setup the levels accordingly. I'm not sure how to determine the levels in our reflection-based code.
from aqlaserializer.
AsReference is an obsolete member inherited from protobuf-net and must retain its semantics. I have no plans to change behavior of obsolete members.
from aqlaserializer.
Can Aqla be enhanced to automatically detect the double array and setup the levels accordingly?
from aqlaserializer.
Please see https://github.com/AqlaSolutions/AqlaSerializer/wiki/Member-Formats#defaults
You don't need to manually set members AsReference
, it works automatically.
from aqlaserializer.
Related Issues (20)
- RuntimeTypeModel.Default.CompileInPlace is too slow HOT 5
- Non-public member cannot be used with full dll compilation HOT 12
- AqlaSerializer.ProtoException: Trap count > 1, will be mismatched with next NoteObject HOT 15
- Dynamic type is not a contract-type
- Un-defined enum values HOT 1
- Unexpected sub-type HOT 4
- How to setup Aqla for complicated object relationships HOT 4
- Wrong group was ended
- Recursion depth exceeded safe limit HOT 2
- "Unable to determine member" when running obfuscated code HOT 1
- A deferred key does not have a value yet (NoteObject call missed?) HOT 10
- How to unregister or re-register a type? HOT 6
- Can you please publish the latest code?
- Failed to clone a dictionary with enum value
- Unable to Serialize a string object dictionary containing a string array as object
- Is Aqla's metadata inspection thread-safe? HOT 2
- Is there a way to re-compile the runtime type model as a dll? HOT 2
- Can we reformat the source code? HOT 1
- Reference tracking error message only for release build but not for debug build
- When a SortedDictionary is serialized, does Aqla keep the "Comparer" of it? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aqlaserializer.