コード例 #1
0
ファイル: SHPStruct.cs プロジェクト: Xkein/PatcherYRpp
 public unsafe Pointer <SHPFile> AsFile()
 {
     return(!IsReference() ? Pointer <SHPStruct> .AsPointer(ref this).Convert <SHPFile>() : Pointer <SHPFile> .Zero);
 }
コード例 #2
0
ファイル: INIParser.cs プロジェクト: Xkein/PatcherExtension
        static bool TryParse(string str, ref T outValue)
        {
            Pointer <T> pOutValue = Pointer <T> .AsPointer(ref outValue);

            Type type = typeof(T);

            if (type == typeof(string))
            {
                return(TryParseString(str, ref pOutValue.Convert <string>().Ref));
            }
            else if (type == typeof(bool))
            {
                return(TryParseBool(str, ref pOutValue.Convert <bool>().Ref));
            }
            else if (type == typeof(int))
            {
                return(TryParseInt(str, ref pOutValue.Convert <int>().Ref));
            }
            else if (type == typeof(uint))
            {
                return(TryParseUInt(str, ref pOutValue.Convert <uint>().Ref));
            }
            else if (type == typeof(sbyte))
            {
                return(TryParseSByte(str, ref pOutValue.Convert <sbyte>().Ref));
            }
            else if (type == typeof(byte))
            {
                return(TryParseByte(str, ref pOutValue.Convert <byte>().Ref));
            }
            else if (type == typeof(long))
            {
                return(TryParseLong(str, ref pOutValue.Convert <long>().Ref));
            }
            else if (type == typeof(ulong))
            {
                return(TryParseULong(str, ref pOutValue.Convert <ulong>().Ref));
            }
            else if (type == typeof(short))
            {
                return(TryParseShort(str, ref pOutValue.Convert <short>().Ref));
            }
            else if (type == typeof(ushort))
            {
                return(TryParseUShort(str, ref pOutValue.Convert <ushort>().Ref));
            }
            else if (type == typeof(float))
            {
                return(TryParseFloat(str, ref pOutValue.Convert <float>().Ref));
            }
            else if (type == typeof(double))
            {
                return(TryParseDouble(str, ref pOutValue.Convert <double>().Ref));
            }

            //switch (outValue)
            //{
            //    case string:
            //        return TryParseString(str, ref pOutValue.Convert<string>().Ref);
            //    case bool:
            //        return TryParseBool(str, ref pOutValue.Convert<bool>().Ref);
            //    case int:
            //        return TryParseInt(str, ref pOutValue.Convert<int>().Ref);
            //    case byte:
            //        return TryParseByte(str, ref pOutValue.Convert<byte>().Ref);
            //    case float:
            //        return TryParseFloat(str, ref pOutValue.Convert<float>().Ref);
            //    case double:
            //        return TryParseDouble(str, ref pOutValue.Convert<double>().Ref);
            //    default:
            //        break;
            //}
            return(false);
        }