public static NestedTypeName Deserialize(global::Improbable.Worker.Core.SchemaObject obj) { var instance = new NestedTypeName(); { instance.OtherZero = global::Improbable.Gdk.Tests.TypeName.Other.NestedTypeName.Other0.Serialization.Deserialize(obj.GetObject(1)); } { instance.EnumField = (global::Improbable.Gdk.Tests.TypeName.Other.NestedTypeName.NestedEnum)obj.GetEnum(2); } return(instance); }
/// <summary> /// Gets the declaring type name. /// </summary> /// <exception cref="InvalidOperationException">This is a top-level type name.</exception> /// <example><c>new FullTypeName("NS.A+B+C").GetDeclaringType()</c> will return <c>new FullTypeName("NS.A+B")</c></example> public FullTypeName GetDeclaringType() { if (nestedTypes == null) { throw new InvalidOperationException(); } if (nestedTypes.Length == 1) { return(topLevelType); } NestedTypeName[] outerNestedTypeNames = new NestedTypeName[nestedTypes.Length - 1]; Array.Copy(nestedTypes, 0, outerNestedTypeNames, 0, outerNestedTypeNames.Length); return(new FullTypeName(topLevelType, nestedTypes)); }
/// <summary> /// Creates a nested type name. /// </summary> /// <example><c>new FullTypeName("NS.A+B").NestedType("C", 1)</c> will return <c>new FullTypeName("NS.A+B+C`1")</c></example> public FullTypeName NestedType(string name, int additionalTypeParameterCount) { if (name == null) { throw new ArgumentNullException("name"); } var newNestedType = new NestedTypeName(name, additionalTypeParameterCount); if (nestedTypes == null) { return(new FullTypeName(topLevelType, new[] { newNestedType })); } NestedTypeName[] newNestedTypeNames = new NestedTypeName[nestedTypes.Length + 1]; nestedTypes.CopyTo(newNestedTypeNames, 0); newNestedTypeNames[newNestedTypeNames.Length - 1] = newNestedType; return(new FullTypeName(topLevelType, newNestedTypeNames)); }
/// <summary> /// Constructs a FullTypeName by parsing the given reflection name. /// Note that FullTypeName can only represent type definition names. If the reflection name /// might refer to a parameterized type or array etc., use /// <see cref="ReflectionHelper.ParseReflectionName(string)"/> instead. /// </summary> /// <remarks> /// Expected syntax: <c>NamespaceName '.' TopLevelTypeName ['`'#] { '+' NestedTypeName ['`'#] }</c> /// where # are type parameter counts /// </remarks> public FullTypeName(string reflectionName) { int pos = reflectionName.IndexOf('+'); if (pos < 0) { // top-level type this.topLevelType = new TopLevelTypeName(reflectionName); this.nestedTypes = null; } else { // nested type string[] parts = reflectionName.Split('+'); this.topLevelType = new TopLevelTypeName(parts[0]); this.nestedTypes = new NestedTypeName[parts.Length - 1]; for (int i = 0; i < nestedTypes.Length; i++) { int tpc; string name = SRMExtensions.SplitTypeParameterCountFromReflectionName(parts[i + 1], out tpc); nestedTypes[i] = new NestedTypeName(name, tpc); } } }
public static void Serialize(NestedTypeName instance, global::Improbable.Worker.Core.SchemaObject obj) { global::Generated.Improbable.Gdk.Tests.TypeName.Other.NestedTypeName.Other0.Serialization.Serialize(instance.OtherZero, obj.AddObject(1)); obj.AddEnum(2, (uint)instance.EnumField); }