コード例 #1
0
        public override object readObject(ImportContext ctx, TypeData[] typeArgs = null)
        {
            object value = (_type == null) ? null : Activator.CreateInstance(_type);
            int fieldCount = ctx.readLength();
            this.logInfo("Reading " + fieldCount + " fields...");
            for (int ii = 0; ii < fieldCount; ii++) {
            int fieldId = ctx.readId();
            FieldData field;
            if (fieldId < _fields.Count) {
                field = _fields[fieldId];

            } else {
                // ASSERT the fieldId
                // TODO
                if (fieldId != _fields.Count) {
                    this.logWarning("Unexpected field id!",
                            "expected", _fields.Count,
                            "got", fieldId);
                    throw new Exception("Unexpected field id!");
                }

                // new field
                string name = ctx.readString();
                TypeData type = ctx.readType();
                FieldInfo fieldInfo;
                if (_fieldInfo != null) {
                    _fieldInfo.TryGetValue(name, out fieldInfo);
                    if (_fieldInfo == null) {
                        ctx.warn("Importing class no longer has field: " + name);
                    }
                } else {
                    fieldInfo = null;
                }
                // fieldInfo can now be null
                field = new FieldData(type, fieldInfo);
                _fields.Add(field);
            }
            field.readField(ctx, value);
            }
            return value;
        }
コード例 #2
0
ファイル: TypeData.cs プロジェクト: raygreenwell/export
 public override object readObject(ImportContext ctx, TypeData[] typeArguments = null)
 {
     return ctx.readString();
 }
コード例 #3
0
ファイル: TypeData.cs プロジェクト: raygreenwell/export
        public override object readObject(ImportContext ctx, TypeData[] typeArgs = null)
        {
            string s = ctx.readString();
            if (_type != null) {
            try {
                return Enum.Parse(_type, s);

            } catch (ArgumentException) {
                ctx.warn("could not find enum constant '" + s + "' in type " + _type);
            }
            }
            return null;
        }