コード例 #1
0
        public static BlendValueCapsule GetMemberValue(BlendValueCapsule value, string name)
        {
            Debug.Assert(value.Type.GetType() == typeof(BlendStructureType), "tyep unmatched");
            var rawValue = value.GetRawValue() as _RawValue;

            return(rawValue[name]);
        }
コード例 #2
0
ファイル: BlendArrayType.cs プロジェクト: yazici/BlendReader
        public static BlendValueCapsule GetAt(BlendValueCapsule value, int index1)
        {
            Debug.Assert(value.Type.GetType() == typeof(BlendArrayType), "tyep unmatched");
            var rawValue = value.GetRawValue() as BlendValueCapsule[];

            return(rawValue[index1]);
        }
コード例 #3
0
        public BlendValueCapsule DereferenceOne(IBlendType type)
        {
            if (!CanDereference(type))
            {
                return(null);
            }

            BlendValueCapsule result = null;

            try
            {
                int        offset = (int)m_address;
                IBlendType realType;
                using (var reader = new BinaryReader(m_mapper.GetStreamFromAddress(m_address, out realType)))
                {
                    var context = new ReadValueContext()
                    {
                        reader = reader, mapper = m_mapper
                    };
                    result = type.ReadValue(context);
                }
            }
            catch (Exception e)
            {
                throw new BlenderException("Failed to dereference {0} as {1}", AddressString, type.Name);
            }

            return(result);
        }
コード例 #4
0
ファイル: BlendArrayType.cs プロジェクト: yazici/BlendReader
        public static BlendValueCapsule GetAt(BlendValueCapsule value, int index1, int index2)
        {
            Debug.Assert(value.Type.GetType() == typeof(BlendArrayType), "tyep unmatched");
            var rawValue1 = value.GetRawValue() as object[];
            var rawValue2 = rawValue1[index1] as BlendValueCapsule[];

            return(rawValue2[index2]);
        }
コード例 #5
0
 public BlockHeaderEntity(BlendValueCapsule value)
     : base(value.GetMember("code").GetAllValueAsString(), value)
 {
     m_address   = Value.GetMember("old_memory_address").GetRawValue <BlendAddress>();
     m_size      = value.GetMember("size").GetRawValue <int>();
     m_sdnaIndex = value.GetMember("sdna_index").GetRawValue <int>();
     m_count     = value.GetMember("count").GetRawValue <int>();
 }
コード例 #6
0
        public static IEnumerable <object> GetAllRawValue(BlendValueCapsule value)
        {
            Debug.Assert(value.Type.GetType() == typeof(BlendStructureType), "tyep unmatched");
            var rawValue = value.GetRawValue() as _RawValue;

            foreach (var memberValue in rawValue.Values.SelectMany(v => v.GetAllValue()))
            {
                yield return(memberValue);
            }
        }
コード例 #7
0
            public _NodeModel(String name, BlendValueCapsule value)
            {
                m_name  = name;
                m_value = value;

                var sb     = new StringBuilder();
                var values = m_value.GetAllValue();

                m_cacheValue = string.Join(", ", values.Select(val => _GetString(val)));
            }
コード例 #8
0
ファイル: PropertyPanel.cs プロジェクト: yazici/BlendReader
 public void Attach(BlendValueCapsule value)
 {
     if (value == null)
     {
         this.treeViewAdv1.Model = null;
     }
     else
     {
         m_structureViewModel    = new StructureViewModel(value);
         this.treeViewAdv1.Model = m_structureViewModel;
         //m_structureViewModel.Attach(value);
     }
 }
コード例 #9
0
ファイル: BlendArrayType.cs プロジェクト: yazici/BlendReader
        public static IEnumerable <object> GetAllRawValue(BlendValueCapsule value)
        {
            Debug.Assert(value.Type.GetType() == typeof(BlendArrayType), "tyep unmatched");
            var type = (BlendArrayType)value.Type;

            if (type.ArrayDimension == 1)
            {
                if (type.BaseType.Equals(BlendPrimitiveType.Char()))
                {
                    // Parse as string
                    var objs = value.GetRawValue <BlendValueCapsule[]>();
                    yield return(ConvertUtil.CharArray2String(objs.Select(o => o.GetRawValue())));
                }
                else
                {
                    // Parse as 1 dimension array
                    var objs = value.GetRawValue <BlendValueCapsule[]>();
                    foreach (var obj in objs.SelectMany(v => v.GetAllValue()))
                    {
                        yield return(obj);
                    }
                }
            }
            else if (type.ArrayDimension == 2)
            {
                // Parse as 2 dimension array
                var objs1 = value.GetRawValue <object[]>();
                foreach (BlendValueCapsule[] objs2 in objs1)
                {
                    foreach (var obj in objs2.SelectMany(v => v.GetAllValue()))
                    {
                        yield return(obj);
                    }
                }
            }
            else
            {
                Debug.Assert(false, "logic error");
            }
        }
コード例 #10
0
ファイル: BlendArrayType.cs プロジェクト: yazici/BlendReader
        /// <summary>
        /// Read value corresponded this type from binary
        /// </summary>
        /// <param name="context">variable for making a value</param>
        /// <returns>value</returns>
        /// <seealso cref="IBlendType.ReadValue"/>
        public virtual BlendValueCapsule ReadValue(ReadValueContext context)
        {
            object obj = null;

            switch (ArrayDimension)
            {
            case 1:
            {
                var objs = new BlendValueCapsule[m_dimCountArray[0]];
                for (int i = 0; i < m_dimCountArray[0]; ++i)
                {
                    objs[i] = m_baseType.ReadValue(context);
                }
                obj = objs;
            }
            break;

            case 2:
            {
                var objs = new object[m_dimCountArray[0]];

                for (int i = 0; i < m_dimCountArray[0]; ++i)
                {
                    var tmp = new BlendValueCapsule[m_dimCountArray[1]];
                    for (int j = 0; j < m_dimCountArray[1]; ++j)
                    {
                        tmp[j] = m_baseType.ReadValue(context);
                    }

                    objs[i] = tmp;
                }
                obj = objs;
            }
            break;
            }

            return(new _BlendValueCapsule(this, obj));
        }
コード例 #11
0
 public void _Attach(BlendValueCapsule value)
 {
     m_rootNode = new _NodeModel("ROOT", value);
 }
コード例 #12
0
 public StructureViewModel(BlendValueCapsule value)
 {
     _Attach(value);
 }
コード例 #13
0
 public BlendEntityBase(String name, BlendValueCapsule value)
 {
     m_name     = name;
     m_value    = value;
     m_children = new List <BlendEntityBase>();
 }