System.Runtime.Serialization.CodeGenerator.StoreArrayElement C# (CSharp) Method

StoreArrayElement() private method

private StoreArrayElement ( object obj, object arrayIndex, object value ) : void
obj object
arrayIndex object
value object
return void
        internal void StoreArrayElement(object obj, object arrayIndex, object value)
        {
            Type arrayType = GetVariableType(obj);
            if (arrayType == Globals.TypeOfArray)
            {
                Call(obj, ArraySetValue, value, arrayIndex);
            }
            else
            {
                Type objType = arrayType.GetElementType();
                Load(obj);
                Load(arrayIndex);
                if (IsStruct(objType))
                    Ldelema(objType);
                Load(value);
                ConvertValue(GetVariableType(value), objType);
                if (IsStruct(objType))
                    Stobj(objType);
                else
                    Stelem(objType);
            }
        }

Usage Example

コード例 #1
0
        public void LoadArray()
        {
            LocalBuilder localArray = _ilg.DeclareLocal(Globals.TypeOfByteArray, "localArray");

            _ilg.NewArray(typeof(byte), _locals.Length);
            _ilg.Store(localArray);
            for (int i = 0; i < _locals.Length; i++)
            {
                _ilg.StoreArrayElement(localArray, i, _locals[i]);
            }
            _ilg.Load(localArray);
        }
All Usage Examples Of System.Runtime.Serialization.CodeGenerator::StoreArrayElement