Ejemplo n.º 1
0
        private string GetFormatedValue(Cabwiz.RegistryValueTypes type, string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            switch (type)
            {
                case Cabwiz.RegistryValueTypes.SZ:
                case Cabwiz.RegistryValueTypes.MULTI_SZ:
                    return value;

                case Cabwiz.RegistryValueTypes.DWORD:
                    {
                        int nValue;

                        var invariant = System.Globalization.CultureInfo.InvariantCulture;

                        var cultures = new System.IFormatProvider[] {
                            System.Globalization.CultureInfo.CurrentUICulture,
                            invariant
                        };

                        foreach (var culture in cultures)
                        {
                            if (int.TryParse(value, System.Globalization.NumberStyles.Integer, culture, out nValue))
                            {
                                return nValue.ToString(invariant);
                            }
                        }

                        // If we have reached this point, no parse was successful. Whine a bit.
                        throw new FormatException("The value could not a well-formatted 32-bit integer.");
                    }

                case Cabwiz.RegistryValueTypes.BINARY:
                    {
                        throw new NotSupportedException("BINARY data types are not yet supported by the visual editor.");
                    }

                default:
                    {
                        throw new ArgumentOutOfRangeException("type");
                    }
            }
        }
 public static string FloatToString(float p_Val, System.String format, System.IFormatProvider provider)
 {
     return(p_Val.ToString(format, provider));
 }
 public static string DecimalToString(decimal p_Val, System.String format, System.IFormatProvider provider)
 {
     return(p_Val.ToString(format, provider));
 }
 public static string DoubleToString(double p_Val, System.String format, System.IFormatProvider provider)
 {
     return(p_Val.ToString(format, provider));
 }
Ejemplo n.º 5
0
        static StackObject *TryParse_14(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int64 @result = __intp.RetriveInt64(ptr_of_this_method, __mStack);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.IFormatProvider @provider = (System.IFormatProvider) typeof(System.IFormatProvider).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Globalization.NumberStyles @style = (System.Globalization.NumberStyles) typeof(System.Globalization.NumberStyles).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            System.String @s = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));


            var result_of_this_method = System.Int64.TryParse(@s, @style, @provider, out @result);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method);
                ___dst->ObjectType      = ObjectTypes.Long;
                *(long *)&___dst->Value = @result;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @result;
                }
                else
                {
                    var ___type = __domain.GetType(___obj.GetType()) as CLRType;
                    ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @result);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var ___type = __domain.GetType(ptr_of_this_method->Value);
                if (___type is ILType)
                {
                    ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @result;
                }
                else
                {
                    ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @result);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Int64[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = @result;
            }
            break;
            }

            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            __intp.FreeStackValueType(ptr_of_this_method);
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            __intp.Free(ptr_of_this_method);
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
Ejemplo n.º 6
0
        static StackObject *TryParse_13(ILIntepreter __intp, StackObject *__esp, List <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Single result = *(float *)&ptr_of_this_method->Value;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.IFormatProvider provider = (System.IFormatProvider) typeof(System.IFormatProvider).CheckCLRTypes(__domain, StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Globalization.NumberStyles style = (System.Globalization.NumberStyles) typeof(System.Globalization.NumberStyles).CheckCLRTypes(__domain, StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            System.String s = (System.String) typeof(System.String).CheckCLRTypes(__domain, StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = System.Single.TryParse(s, style, provider, out result);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var dst = *(StackObject **)&ptr_of_this_method->Value;
                dst->ObjectType       = ObjectTypes.Float;
                *(float *)&dst->Value = result;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = result;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.GetField(ptr_of_this_method->ValueLow).SetValue(___obj, result);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = result;
                }
                else
                {
                    ((CLRType)t).GetField(ptr_of_this_method->ValueLow).SetValue(null, result);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Single[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = result;
            }
            break;
            }

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
Ejemplo n.º 7
0
 public void Write(System.IFormatProvider provider, string format, params object[] args)
 {
     Write(string.Format(provider, format, args));
 }
Ejemplo n.º 8
0
 public void WriteLine(System.IFormatProvider provider, string format, params object[] args)
 {
     Write(string.Format(provider, format, args) + System.Environment.NewLine);
 }