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]); }
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]); }
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); }
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]); }
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>(); }
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); } }
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))); }
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); } }
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"); } }
/// <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)); }
public void _Attach(BlendValueCapsule value) { m_rootNode = new _NodeModel("ROOT", value); }
public StructureViewModel(BlendValueCapsule value) { _Attach(value); }
public BlendEntityBase(String name, BlendValueCapsule value) { m_name = name; m_value = value; m_children = new List <BlendEntityBase>(); }