Exemplo n.º 1
0
 private static object ConvertStringMap(FoxProperty property)
 {
     // Get the generic type to convert to.
     // Create an instance of a list of that type.
     // Add each entry to that list.
     return(null);
 }
Exemplo n.º 2
0
 private static object ConvertStaticArray(FoxProperty property)
 {
     // As far as I can tell, StaticArrays are not actually collections and only hold a single entry.
     foreach (var entry in property.Container)
     {
         return(entry);
     }
     throw new NotSupportedException($"Property '{property.Name}' had no entries. Report the file that caused this.");
 }
        private static void ImportEntityProperty(Entity entityInstance, FoxProperty foxProperty, IEntityReferenceResolver entityReferenceResolver)
        {
            var entityPropertyAndFieldInfo =
                FindMatchingEntityPropertyAndFieldInfo(entityInstance.GetType(), foxProperty.Name);

            var converter = foxProperty.Container.MakePropertyConverter(entityPropertyAndFieldInfo.Item2.FieldType, entityReferenceResolver);

            converter.ConvertFromFox(entityInstance, entityPropertyAndFieldInfo.Item2);
        }
Exemplo n.º 4
0
        private static object ConvertList(FoxProperty property, Type targetFieldType)
        {
            // TODO Add checks if you were dumb and your property isn't a list
            var list = Activator.CreateInstance(targetFieldType) as IList;

            foreach (var entry in property.Container)
            {
                //list.Add(ConvertValue(entry));
            }
            return(null);
        }
Exemplo n.º 5
0
        public object ConvertProperty(FoxProperty property)
        {
            switch (property.ContainerType)
            {
            case FoxContainerType.StaticArray:
                return(ConvertStaticArray(property));

            case FoxContainerType.DynamicArray:
                break;

            case FoxContainerType.StringMap:
                break;

            case FoxContainerType.List:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(null);
        }
Exemplo n.º 6
0
        public void ReadXml(XmlReader reader)
        {
            ClassName = reader.GetAttribute("class");
            Version = short.Parse(reader.GetAttribute("classVersion"));
            string addr = reader.GetAttribute("addr");
            Address = addr.StartsWith("0x")
                ? uint.Parse(addr.Substring(2, addr.Length - 2), NumberStyles.AllowHexSpecifier)
                : uint.Parse(addr);
            Unknown1 = short.Parse(reader.GetAttribute("unknown1"));
            Unknown2 = int.Parse(reader.GetAttribute("unknown2"));

            var isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement("entity");
            if (isEmptyElement) return;

            bool staticPropertiesElementEmpty = reader.IsEmptyElement;
            reader.ReadStartElement("staticProperties");
            if (staticPropertiesElementEmpty == false)
            {
                while (reader.LocalName == "property")
                {
                    FoxProperty staticProperty = new FoxProperty();
                    staticProperty.ReadXml(reader);
                    _staticProperties.Add(staticProperty);
                }
                reader.ReadEndElement();
            }

            bool dynamicPropertiesElementEmpty = reader.IsEmptyElement;
            reader.ReadStartElement("dynamicProperties");

            if (dynamicPropertiesElementEmpty == false)
            {
                while (reader.LocalName == "property")
                {
                    FoxProperty dynamicProperty = new FoxProperty();
                    dynamicProperty.ReadXml(reader);
                    _dynamicProperties.Add(dynamicProperty);
                }
                reader.ReadEndElement();
            }

            reader.ReadEndElement();
        }