StringToIntPtr() публичный статический Метод

public static StringToIntPtr ( string str ) : IntPtr
str string
Результат System.IntPtr
Пример #1
0
        private static IntPtr GetFragment(IntPtr instance)
        {
            try {
                Uri    uri;
                string fragment;

                if (instance == IntPtr.Zero)
                {
                    return(IntPtr.Zero);
                }

                uri = FromGCHandle(instance);

                fragment = uri.Fragment;

                if (!string.IsNullOrEmpty(fragment))
                {
                    /* The managed 'Fragment' property returns the initial # character, while the native Uri class didn't */
                    fragment = fragment.Substring(1);
                }

                return(Value.StringToIntPtr(fragment));
            } catch (Exception ex) {
#if DEBUG
                try {
                    Console.WriteLine("UriHelper.GetFragment ({1}): {0}", ex.Message, FromGCHandle(instance).ToString());
                } catch {
                }
#endif
                return(IntPtr.Zero);
            }
        }
Пример #2
0
        public static MoonError FromIntPtr(IntPtr moon_error)
        {
            MoonError err = (MoonError)Marshal.PtrToStructure(moon_error, typeof(MoonError));

            if (err.message != IntPtr.Zero)
            {
                string msg = Marshal.PtrToStringAuto(err.message);
                err.message = Value.StringToIntPtr(msg);
            }

            return(err);
        }
Пример #3
0
        public static void ToValue(ref Value v, object o)
        {
            if (o == null)
            {
                v.Kind = Kind.NPOBJ;
                v.u.p  = IntPtr.Zero;
                return;
            }

            if (o is sbyte || o is short || o is int || o is byte || o is ushort ||
                o is uint || o is long || o is ulong || o is float || o is double ||
                o is decimal || o.GetType().IsEnum)
            {
                v.Kind = Kind.DOUBLE;
                v.u.d  = Convert.ToDouble(o);
            }
            else if (o is bool)
            {
                v.Kind  = Kind.BOOL;
                v.u.i32 = ((bool)o) ? 1 : 0;
            }
            else if (o is char || o is string || o is Guid)
            {
                v.Kind = Kind.STRING;
                v.u.p  = Value.StringToIntPtr(o.ToString());
            }
            else if (o is DateTime)
            {
                v.Kind  = Kind.DATETIME;
                v.u.i64 = (((DateTime)o).Ticks - new DateTime(1970, 1, 1).Ticks) / 10000;
            }
            else if (o is ScriptObject)
            {
                // FIXME: We should ref the SO here
                v.Kind = Kind.NPOBJ;
                v.u.p  = ((ScriptObject)o).Handle;
            }
            else
            {
                // FIXME: We should ref the SO here
                v.Kind = Kind.NPOBJ;
                v.u.p  = ManagedObject.GetManagedObject(o).Handle;
            }
        }
Пример #4
0
        public MoonError(Exception ex)
        {
            number   = 9;
            code     = 0;
            message  = Value.StringToIntPtr(ex.Message);
            gchandle = GCHandle.Alloc(ex);

            XamlParseException p = ex as XamlParseException;

            if (p != null)
            {
                char_position = p.LinePosition;
                line_number   = p.LineNumber;
                code          = p.Code;
            }
            else
            {
                //System.Console.WriteLine (ex);
                char_position = -1;
                line_number   = -1;
            }
        }
Пример #5
0
        private static IntPtr GetScheme(IntPtr instance)
        {
            try {
                Uri uri;

                if (instance == IntPtr.Zero)
                {
                    return(IntPtr.Zero);
                }

                uri = FromGCHandle(instance);

                return(Value.StringToIntPtr(uri.Scheme));
            } catch (Exception ex) {
#if DEBUG
                try {
                    Console.WriteLine("UriHelper.GetScheme ({1}): {0}", ex.Message, FromGCHandle(instance).ToString());
                } catch {
                }
#endif
                return(IntPtr.Zero);
            }
        }
Пример #6
0
        private static IntPtr GetHttpRequestString(IntPtr instance)
        {
            try {
                Uri uri;

                if (instance == IntPtr.Zero)
                {
                    return(IntPtr.Zero);
                }

                uri = FromGCHandle(instance);

                return(Value.StringToIntPtr(uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)));
            } catch (Exception ex) {
#if DEBUG
                try {
                    Uri u = FromGCHandle(instance);
                    Console.WriteLine("UriHelper.GetHttpRequestString (ToString: '{1}' OriginalString: '{2}'): {0}", ex.Message, u.ToString(), u.OriginalString);
                } catch {
                }
#endif
                return(IntPtr.Zero);
            }
        }