-
Notifications
You must be signed in to change notification settings - Fork 0
Simple examples
Andrey Ekimov edited this page Nov 25, 2018
·
4 revisions
6. MultiArrays with simple elements
7. MultiArrays with complex elements
Name: NameOfObjects
Description: "This's an example of a description."
LifeTime: 99.99
Mover:
ExactlyForwardAngle: 5
MoveAngle: 60
AIPathType: WalkWay
Reflection to C# code:
[CascadeObject(MemberSerialization.All)]
class CUnit
{
public string Name;
public string Description { get; private set; }
float _life_time; //auto name changing to LifeTime
CMoverDescr _mover;
}
[CascadeObject(CascadeSerializer.MemberSerialization.Fields)]
public class CMoverDescr
{
[CascadeProperty(Name = "ExactlyForwardAngle", Default = 3f)]
private float _exactly_forward;
public float ExactlyForwardAngle { get { return _exactly_forward; } }
[CascadeProperty(Default = 70f)]
private float _move_angle;
public float MoveAngle { get { return _move_angle; } }
[CascadeProperty("AIPathType")]
private EAIPathType _ai_path_type;
public EAIPathType AIPathType { get { return _ai_path_type; } }
[CascadeProperty(Default = 50f)]
private float _ignor_pathfinder_distance;
public float IgnorPathfinderDistance { get { return _ignor_pathfinder_distance; } }
}
Names: Name1, Name2, Name3
Masks: "###.##", "**.*.*"
Ids: 324, 567, 454
Reflection to C# code:
[CascadeObject(MemberSerialization.All)]
class CSomeClass
{
public string[] Names;
public List<string> Masks { get; private set; }
HashSet<uint> _ids; //auto name changing to Ids
}
Dict:
dickey1: 1
dickey2: 2
Reflection to C# code:
class CSomeClass
{
public Dictionary<string, int> _dict;
public CSomeClass()
{
_dict = new Dictionary<string, int>();
}
public void Init()
{
_dict.Add("dickey1", 1);
_dict.Add("dickey2", 2);
}
}
BaseNullable: 9
BaseEnum: TestEnumValue3
Reflection to C# code:
[CascadeObject(MemberSerialization.All)]
class CSomeClass
{
public enum ETestEnum { TestEnumValue1, TestEnumValue2, TestEnumValue3 }
private ETestEnum _base_enum;
public double? BaseNullable { get; set; }
public void Init()
{
_base_enum = ETestEnum.TestEnumValue3;
BaseNullable = 9;
}
}
C# code:
[CascadeObject(MemberSerialization.All)]
public class CTestBase
{
private float _base_float;
private string _base_string;
private ETestEnum _base_enum;
public float BaseInt { get; set; }
public double? BaseNullable { get; set; }
public virtual void Init1()
{
_base_float = 101.909f;
_base_string = "str2";
_base_enum = ETestEnum.TestEnumValue3;
BaseInt = 7;
BaseNullable = 9;
}
}
[CascadeObject(MemberSerialization.All)]
public class CTestClass1 : CTestBase
{
[CascadeProperty(Default = 10)]
[DefaultValue(10)]
private int _int;
[CascadeIgnore]
public int PubProp { get; set; }
public CTestClass1()
{
_int = 10;
}
public override void Init()
{
base.Init1();
_int = 8;
}
}
Cascade:
Int: 8
BaseInt: 7
BaseNullable: 9
BaseFloat: 101.909
BaseString: str2
BaseEnum: TestEnumValue3
C# code:
public class CTestClassMultiArrayAtom
{
public int[,,] _multi_array_r3;
public int[,] _multi_array;
public void Init1()
{
_multi_array_r3 = new int[3, 2, 2]
{
{ { 1, 11 }, { 2, 22 } },
{ { 3, 33 }, { 4, 44 } },
{ { 5, 55 }, { 6, 66 } }
};
_multi_array = new int[3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
}
public void Init2()
{
//_multi_array = new int[,] { { } };
//_array = new int[] { };
_multi_array_r3 = new int[1, 2, 1] { { { 1 }, { 2 } } };
_multi_array = new int[2, 1] { { 1 }, { 2 } };
}
public void Init3()
{
//_multi_array = new int[,] { { } };
//_array = new int[] { };
_multi_array_r3 = new int[1, 1, 1] { { { 1 } } };
_multi_array = new int[1, 1] { { 1 } };
}
}
Cascade:
- Init1:
MultiArrayR3:
1, 11
2, 22
--
3, 33
4, 44
--
5, 55
6, 66
MultiArray:
1, 2
3, 4
5, 6
- Init2:
MultiArrayR3:
--
1
2
MultiArray:
1
2
- Init3:
MultiArrayR3:
--
1
MultiArray:
1
C# code:
public class CTestClassArrayArraysAtom
{
public int[][] _multi_array;
public void Init()
{
_multi_array = new int[3][];
_multi_array[0] = new int[] { 1 };
_multi_array[1] = new int[] { 2, 3 };
_multi_array[2] = new int[] { 4, 5, 6 };
}
}
Cascade:
MultiArray:
1
2, 3
4, 5, 6
C# code:
public class CSimpleClass
{
public int _int_data = 9;
}
public class CTestClassMAObject
{
public CSimpleClass[,,] _multi_array_r3;
public CSimpleClass[,] _multi_array;
public void Init1()
{
var to = new CSimpleClass();
to._int_data = 10;
_multi_array_r3 = new CSimpleClass[3, 2, 2] { { { to, to }, { to, to } }, { { to, to }, { to, to } }, { { to, to }, { to, to } } };
_multi_array = new CSimpleClass[3, 2] { { to, to }, { to, to }, { to, to } };
}
public void Init2()
{
//_multi_array = new int[,] { { } };
//_array = new int[] { };
var to = new CSimpleClass();
to._int_data = 10;
_multi_array_r3 = new CSimpleClass[1, 1, 1] { { { to } } };
_multi_array = new CSimpleClass[1, 1] { { to } };
}
}
Cascade:
- Init1
MultiArrayR3:
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
MultiArray:
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
- Init2
MultiArrayR3:
--
--
--
IntData: 10
MultiArray:
--
--
IntData: 10
C# code:
public class CTestClassAAObject
{
public CSimpleClass[][] _multi_array;
public void Init1()
{
var to = new CSimpleClass();
to._int_data = 10;
_multi_array = new CSimpleClass[3][];
_multi_array[0] = new CSimpleClass[] { to };
_multi_array[1] = new CSimpleClass[] { to, to };
_multi_array[2] = new CSimpleClass[] { to, to, to };
}
}
Cascade:
- Init1
MultiArray:
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10
--
IntData: 10