Exemplo n.º 1
0
        public ContainedType(TypeReference innerType)
        {
            switch (innerType.ValueTypeSelector)
            {
            case ValueType.Enum:
                category      = ValueType.Enum;
                FqnType       = CommonDetailsUtils.GetCapitalisedFqnTypename(innerType.Enum);
                primitiveType = null;
                break;

            case ValueType.Primitive:
                category      = ValueType.Primitive;
                FqnType       = UnityTypeMappings.SchemaTypeToUnityType[innerType.Primitive];
                primitiveType = innerType.Primitive;
                break;

            case ValueType.Type:
                category      = ValueType.Type;
                FqnType       = CommonDetailsUtils.GetCapitalisedFqnTypename(innerType.Type);
                primitiveType = null;
                break;

            default:
                throw new ArgumentOutOfRangeException("Malformed inner type.");
            }
        }
Exemplo n.º 2
0
        private bool?CheckBlittable(Field field)
        {
            if (field.Map != null || field.List != null || field.Option != null)
            {
                blittableMap[field.Identifier] = false;
                return(false);
            }

            var innerSingularType = field.Singular.Type;

            if (innerSingularType.UserType != null)
            {
                if (!blittableMap.TryGetValue(CommonDetailsUtils.CreateIdentifier(innerSingularType.UserType.QualifiedName), out var isFieldBlittable))
                {
                    return(null);
                }

                blittableMap[field.Identifier] = isFieldBlittable;
                return(isFieldBlittable);
            }

            if (innerSingularType.Primitive != null && NonBlittableSchemaTypes.Contains(innerSingularType.Primitive))
            {
                blittableMap[field.Identifier] = false;
                return(false);
            }

            // No need to check enums - they are always blittable.
            blittableMap[field.Identifier] = true;
            return(true);
        }
Exemplo n.º 3
0
 public UnityEventDetails(ComponentDefinitionRaw.EventDefinitionRaw eventDefinitionRaw)
 {
     EventName          = Formatting.SnakeCaseToPascalCase(eventDefinitionRaw.Identifier.Name);
     CamelCaseEventName = Formatting.PascalCaseToCamelCase(EventName);
     FqnPayloadType     = CommonDetailsUtils.GetCapitalisedFqnTypename(eventDefinitionRaw.Type.Type.QualifiedName);
     EventIndex         = eventDefinitionRaw.EventIndex;
 }
Exemplo n.º 4
0
 // TODO: This can probably be reworked with the inner type concept.
 public ContainedType(Field.InnerType innerType, DetailsStore store)
 {
     if (innerType.Primitive != null)
     {
         category = ContainedTypeCategory.Primitive;
         Type     = CommonDetailsUtils.GetCapitalisedFqnTypename(innerType.Primitive);
         rawType  = innerType.Primitive;
     }
     else if (innerType.UserType != null)
     {
         category = ContainedTypeCategory.UserDefined;
         Type     = CommonDetailsUtils.GetCapitalisedFqnTypename(innerType.UserType.QualifiedName);
         rawType  = innerType.UserType.QualifiedName;
     }
     else if (innerType.EnumType != null)
     {
         category = ContainedTypeCategory.Enum;
         Type     = CommonDetailsUtils.GetCapitalisedFqnTypename(innerType.EnumType.QualifiedName);
         rawType  = innerType.EnumType.QualifiedName;
     }
     else
     {
         throw new ArgumentException("Malformed inner type.");
     }
 }
Exemplo n.º 5
0
 public ContainedType(TypeReferenceRaw typeReferenceRaw, HashSet <string> enumSet)
 {
     category = enumSet.Contains(typeReferenceRaw.TypeName)
         ? ContainedTypeCategory.Enum
         : SchemaFunctionMappings.BuiltInTypeWithSchemaFunctions.Contains(typeReferenceRaw.TypeName)
             ? ContainedTypeCategory.Primitive
             : ContainedTypeCategory.UserDefined;
     Type    = CommonDetailsUtils.GetFqnTypeFromTypeReference(typeReferenceRaw);
     rawType = typeReferenceRaw.TypeName;
 }
Exemplo n.º 6
0
        public UnityCommandDetails(ComponentDefinitionRaw.CommandDefinitionRaw commandDefinitionRaw)
        {
            CommandName          = Formatting.SnakeCaseToPascalCase(commandDefinitionRaw.Identifier.Name);
            CamelCaseCommandName = Formatting.PascalCaseToCamelCase(CommandName);
            FqnRequestType       =
                CommonDetailsUtils.GetCapitalisedFqnTypename(commandDefinitionRaw.RequestType.Type.QualifiedName);
            FqnResponseType =
                CommonDetailsUtils.GetCapitalisedFqnTypename(commandDefinitionRaw.ResponseType.Type.QualifiedName);

            CommandIndex = commandDefinitionRaw.CommandIndex;
        }
Exemplo n.º 7
0
 public void PopulateFields(DetailsStore store)
 {
     if (raw.Data != null)
     {
         FieldDetails = store.Types[CommonDetailsUtils.CreateIdentifier(raw.Data.QualifiedName)].FieldDetails;
     }
     else
     {
         FieldDetails = raw.Fields
                        .Select(field => new UnityFieldDetails(field, store))
                        .ToList()
                        .AsReadOnly();
     }
 }