Skip to content

Commit 6edf338

Browse files
WIP
1 parent f38491c commit 6edf338

File tree

69 files changed

+14920
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+14920
-6
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="AnnotatingElementMessagePackFormatter.cs" company="Starion Group S.A.">
3+
//
4+
// Copyright 2022-2026 Starion Group S.A.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// </copyright>
19+
// ------------------------------------------------------------------------------------------------
20+
21+
// ------------------------------------------------------------------------------------------------
22+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
23+
// ------------------------------------------------------------------------------------------------
24+
25+
namespace SysML2.NET.Serializer.MessagePack.Core
26+
{
27+
using System;
28+
29+
using SysML2.NET.Extensions.Core;
30+
31+
using global::MessagePack;
32+
using global::MessagePack.Formatters;
33+
34+
/// <summary>
35+
/// The purpose of the <see cref="AnnotatingElementMessagePackFormatter"/> is to provide
36+
/// the contract for MessagePack (de)serialization of the <see cref="SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement"/> type
37+
/// </summary>
38+
public class AnnotatingElementMessagePackFormatter : MessagePackFormatterBase, IMessagePackFormatter<SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement>
39+
{
40+
/// <summary>
41+
/// Serializes an <see cref="SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement"/> DTO.
42+
/// </summary>
43+
/// <param name="writer">
44+
/// The <see cref="MessagePackWriter"/> to use when serializing the value.
45+
/// </param>
46+
/// <param name="annotatingElement">
47+
/// The <see cref="SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement"/> that is to be serialized.
48+
/// </param>
49+
/// <param name="options">
50+
/// The serialization settings to use.
51+
/// </param>
52+
public void Serialize(ref MessagePackWriter writer, SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement annotatingElement, MessagePackSerializerOptions options)
53+
{
54+
if (annotatingElement == null)
55+
{
56+
throw new ArgumentNullException(nameof(annotatingElement), "The AnnotatingElement may not be null");
57+
}
58+
59+
writer.WriteArrayHeader(8);
60+
61+
WriteGuidBin16(ref writer, annotatingElement.Id);
62+
63+
writer.WriteArrayHeader(annotatingElement.AliasIds.Count);
64+
for (var i = 0; i < annotatingElement.AliasIds.Count; i++)
65+
{
66+
writer.Write(annotatingElement.AliasIds[i]);
67+
}
68+
69+
writer.Write(annotatingElement.DeclaredName);
70+
71+
writer.Write(annotatingElement.DeclaredShortName);
72+
73+
writer.Write(annotatingElement.ElementId);
74+
75+
writer.Write(annotatingElement.IsImpliedIncluded);
76+
77+
var ownedRelationship = annotatingElement.OwnedRelationship;
78+
writer.WriteArrayHeader(ownedRelationship.Count);
79+
for (var i = 0; i < ownedRelationship.Count; i++)
80+
{
81+
WriteGuidBin16(ref writer, ownedRelationship[i]);
82+
}
83+
84+
if (annotatingElement.OwningRelationship.HasValue)
85+
{
86+
WriteGuidBin16(ref writer, annotatingElement.OwningRelationship.Value);
87+
}
88+
else
89+
{
90+
writer.WriteNil();
91+
}
92+
93+
writer.Flush();
94+
}
95+
96+
/// <summary>
97+
/// Deserializes an <see cref="SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement"/> DTO
98+
/// </summary>
99+
/// <param name="reader">
100+
/// The <see cref="MessagePackWriter"/> to deserialize the <see cref="SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement"/> from.
101+
/// </param>
102+
/// <param name="options">
103+
/// The serialization settings to use.
104+
/// </param>
105+
/// <returns>
106+
/// The deserialized <see cref="SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement"/>.
107+
/// </returns>
108+
public SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
109+
{
110+
if (reader.TryReadNil())
111+
{
112+
return null;
113+
}
114+
115+
options.Security.DepthStep(ref reader);
116+
117+
var annotatingElement = new SysML2.NET.Core.DTO.Root.Annotations.AnnotatingElement();
118+
119+
var propertyCounter = reader.ReadArrayHeader();
120+
121+
for (var i = 0; i < propertyCounter; i++)
122+
{
123+
int valueLength;
124+
int valueCounter;
125+
126+
switch (i)
127+
{
128+
case 0:
129+
annotatingElement.Id = ReadGuidBin16(ref reader);
130+
break;
131+
case 1:
132+
valueLength = reader.ReadArrayHeader();
133+
annotatingElement.AliasIds.Capacity = valueLength;
134+
for (valueCounter = 0; valueCounter < valueLength; valueCounter++)
135+
{
136+
annotatingElement.AliasIds.Add(reader.ReadString());
137+
}
138+
break;
139+
case 2:
140+
annotatingElement.DeclaredName = reader.ReadString();
141+
break;
142+
case 3:
143+
annotatingElement.DeclaredShortName = reader.ReadString();
144+
break;
145+
case 4:
146+
annotatingElement.ElementId = reader.ReadString();
147+
break;
148+
case 5:
149+
annotatingElement.IsImpliedIncluded = reader.ReadBoolean();
150+
break;
151+
case 6:
152+
valueLength = reader.ReadArrayHeader();
153+
annotatingElement.OwnedRelationship.Capacity = valueLength;
154+
for (valueCounter = 0; valueCounter < valueLength; valueCounter++)
155+
{
156+
annotatingElement.OwnedRelationship.Add(ReadGuidBin16(ref reader));
157+
}
158+
break;
159+
case 7:
160+
if (reader.TryReadNil())
161+
{
162+
annotatingElement.OwningRelationship = null;
163+
}
164+
else
165+
{
166+
annotatingElement.OwningRelationship = ReadGuidBin16(ref reader);
167+
}
168+
break;
169+
default:
170+
reader.Skip();
171+
break;
172+
}
173+
}
174+
175+
reader.Depth--;
176+
177+
return annotatingElement;
178+
}
179+
}
180+
}
181+
182+
// ------------------------------------------------------------------------------------------------
183+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
184+
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)