Example #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]);
        }
Example #2
0
        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]);
        }
Example #3
0
        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]);
        }
Example #4
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);
            }
        }
Example #5
0
        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");
            }
        }