Пример #1
0
        public void Initialize_Int16Property()
        {
            IBusinessObjectNumericProperty property = new Int16Property(
                GetPropertyParameters(GetPropertyInfo(typeof(ClassWithAllDataTypes), "Int16"), _businessObjectProvider));

            Assert.That(property.Type, Is.SameAs(typeof(Int16)));
            Assert.That(property.AllowNegative, Is.True);
        }
Пример #2
0
        public static Property Clone(Property target)
        {
            Property prop = null;
            int id = target.PropertyId;
            PropertyBag bag = target.Owner;

            switch (target.PropertyType)
            {
                case (int)PropertyKind.WispObject:
                    prop = new WispProperty(target.Name, id, ((WispProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.WispArray:
                    prop = new WispArrayProperty(target.Name, id, ((WispArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Int32:
                    prop = new Int32Property(target.Name, id, ((Int32Property)target).Value, bag);
                    break;
                case (int)PropertyKind.String:
                    prop = new StringProperty(target.Name, id, ((StringProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Bool:
                    prop = new BoolProperty(target.Name, id, ((BoolProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Guid:
                    prop = new GuidProperty(target.Name, id, ((GuidProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Single:
                    prop = new SingleProperty(target.Name, id, ((SingleProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Int32Array:
                    prop = new Int32ArrayProperty(target.Name, id, ((Int32ArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.StringArray:
                    prop = new StringArrayProperty(target.Name, id, ((StringArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.DateTime:
                    prop = new DateTimeProperty(target.Name, id, ((DateTimeProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.GuidArray:
                    prop = new GuidArrayProperty(target.Name, id, ((GuidArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Double:
                    prop = new DoubleProperty(target.Name, id, ((DoubleProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Byte:
                    prop = new ByteProperty(target.Name, id, ((ByteProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Component:
                    prop = new ComponentProperty(target.Name, id, ((ComponentProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.SingleArray:
                    prop = new SingleArrayProperty(target.Name, id, ((SingleArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Int64:
                    prop = new Int64Property(target.Name, id, ((Int64Property)target).Value, bag);
                    break;
                case (int)PropertyKind.ComponentArray:
                    prop = new ComponentArrayProperty(target.Name, id, ((ComponentArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.DateTimeArray:
                    prop = new DateTimeArrayProperty(target.Name, id, ((DateTimeArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.ByteArray:
                    prop = new ByteArrayProperty(target.Name, id, ((ByteArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.DoubleArray:
                    prop = new DoubleArrayProperty(target.Name, id, ((DoubleArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Int16Array:
                    prop = new Int16ArrayProperty(target.Name, id, ((Int16ArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.Int16:
                    prop = new Int16Property(target.Name, id, ((Int16Property)target).Value, bag);
                    break;
                case (int)PropertyKind.Int64Array:
                    prop = new Int64ArrayProperty(target.Name, id, ((Int64ArrayProperty)target).Value, bag);
                    break;
                case (int)PropertyKind.BoolArray:
                    prop = new BoolArrayProperty(target.Name, id, ((BoolArrayProperty)target).Value, bag);
                    break;
            }
            prop.Name = target.Name;
            return prop;
        }
Пример #3
0
        public static DotArkProperty ReadPropertyFromDisk(DotArkDeserializer d)
        {
            var ms = d.ms;

            //First, read a name and open it.
            ArkClassName name = ms.ReadArkClassname(d);

            //If this name is null, we've done something wrong.
            if (name == null)
            {
                throw new Exception("A property reading error occurred and got an unexpected NULL value; do not save");
            }

            //If the name is None, we've read to the final property and we can stop.
            if (name.IsNone())
            {
                return(null);
            }

            //Now, read the type
            ArkClassName type = ms.ReadArkClassname(d);

            //If the type is None or unreadable, something has gone wrong.
            if (type == null)
            {
                throw new Exception($"A property name was identified as {name.classname}, but the type failed to read.");
            }

            //Read in the index and size
            int size  = ms.ReadInt();
            int index = ms.ReadInt();

            //Based on the type, deserialize this.
            DotArkProperty prop;

            switch (type.classname)
            {
            case "IntProperty":
                prop = new IntProperty(d, index, size);
                break;

            case "UInt32Property":
                prop = new UInt32Property(d, index, size);
                break;

            case "Int8Property":
                prop = new Int8Property(d, index, size);
                break;

            case "Int16Property":
                prop = new Int16Property(d, index, size);
                break;

            case "UInt16Property":
                prop = new UInt16Property(d, index, size);
                break;

            case "UInt64Property":
                prop = new UInt64Property(d, index, size);
                break;

            case "BoolProperty":
                prop = new BoolProperty(d, index, size);
                break;

            case "ByteProperty":
                prop = new ByteProperty(d, index, size);
                break;

            case "FloatProperty":
                prop = new FloatProperty(d, index, size);
                break;

            case "DoubleProperty":
                prop = new DoubleProperty(d, index, size);
                break;

            case "NameProperty":
                prop = new NameProperty(d, index, size);
                break;

            case "ObjectProperty":
                prop = new ObjectProperty(d, index, size);
                break;

            case "StrProperty":
                prop = new StrProperty(d, index, size);
                break;

            case "StructProperty":
                prop = new StructProperty(d, index, size);
                break;

            case "ArrayProperty":
                prop = DotArkArray.ReadArray(d, index, size);     //UNFINISHED
                break;

            case "TextProperty":
                prop = new TextProperty(d, index, size);
                break;

            default:
                //Unknown
                throw new Exception($"Type {type.classname} was not a valid property type. Something failed to read.");
            }
            //Set additional values in the property and return it.
            prop.type  = type;
            prop.name  = name;
            prop.index = index;
            prop.size  = size;

            return(prop);
        }
Пример #4
0
        public static UProperty ReadProp(IOMemoryStream ms, UAssetFile f, string arrayType, bool isStruct)
        {
            //Read the name
            long start = ms.position;

            //Read the remainder of the properties
            string name;
            int    u1;
            string type;
            int    u2;
            int    length;
            int    index;

            if (arrayType == null)
            {
                //Not an array
                name = ms.ReadNameTableEntry(f);

                //Return null if this is "None". That means we're done reading
                if (name == "None")
                {
                    return(null);
                }

                u1     = ms.ReadInt();
                type   = ms.ReadNameTableEntry(f);
                u2     = ms.ReadInt();
                length = ms.ReadInt();
                index  = ms.ReadInt();
            }
            else
            {
                name   = null;
                u1     = 0;
                type   = arrayType;
                u2     = 0;
                length = 0;
                index  = 0;
            }
            long payloadStart = ms.position;

            //Create the object
            UProperty u;

            switch (type)
            {
            case "ArrayProperty": u = new ArrayProperty(ms, f); break;

            case "BoolProperty": u = new BoolProperty(ms, f); break;

            case "ByteProperty": u = new ByteProperty(ms, f); break;

            case "DoubleProperty": u = new DoubleProperty(ms, f); break;

            case "FloatProperty": u = new FloatProperty(ms, f); break;

            case "Int16Property": u = new Int16Property(ms, f); break;

            case "Int8Property": u = new Int8Property(ms, f); break;

            case "IntProperty": u = new IntProperty(ms, f); break;

            case "NameProperty": u = new NameProperty(ms, f); break;

            case "ObjectProperty": u = new ObjectProperty(ms, f); break;

            case "StrProperty": u = new StrProperty(ms, f); break;

            case "StructProperty": u = new StructProperty(ms, f); break;

            case "TextProperty": u = new TextProperty(ms, f); break;

            case "UInt16Property": u = new UInt16Property(ms, f); break;

            case "UInt32Property": u = new UInt32Property(ms, f); break;

            case "UInt64Property": u = new UInt64Property(ms, f); break;

            default:
                throw new Exception($"FAILED TO READ UPROPERTY: Type {type} was not a valid type. Name={name}, u1={u1}, u2={u2}, length={length}, index={index}, position={start}");
            }

            //Set attributes
            u.name         = name;
            u.unknown1     = u1;
            u.type         = type;
            u.unknown2     = u2;
            u.length       = length;
            u.index        = index;
            u.start        = start;
            u.payloadStart = payloadStart;
            u.isArray      = arrayType != null;

            //Dump
            f.DebugDump("UProperty Reading", ConsoleColor.Green, "name", name, "u1", u1.ToString(), "type", type, "u2", u2.ToString(), "length", length.ToString(), "index", index.ToString(), "start", start.ToString(), "payloadStart", payloadStart.ToString());

            //Read
            u.Read(ms, f);

            //Log
            string msg = u.WriteString();

            f.Debug("UProperty Read " + type, msg, ConsoleColor.DarkGreen);

            return(u);
        }