コード例 #1
0
        private static unsafe int Do_Abi_GetCustomProperty_0(IntPtr thisPtr, IntPtr name, IntPtr *result)
        {
            global::Microsoft.UI.Xaml.Data.ICustomProperty __result = default;
            try
            {
                string       _name        = MarshalString.FromAbi(name);
                object       target       = global::WinRT.ComWrappersSupport.FindObject <object>(thisPtr);
                PropertyInfo propertyInfo = target.GetType().GetProperty(
                    _name,
                    BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);

                if (propertyInfo is object)
                {
                    __result = new ManagedCustomProperty(propertyInfo);
                }

                *result = MarshalInterface <global::Microsoft.UI.Xaml.Data.ICustomProperty> .FromManaged(__result);
            }
            catch (Exception __exception__)
            {
                global::WinRT.ExceptionHelpers.SetErrorInfo(__exception__);
                return(global::WinRT.ExceptionHelpers.GetHRForException(__exception__));
            }
            return(0);
        }
コード例 #2
0
        private static unsafe int Do_Abi_GetIndexedProperty_1(IntPtr thisPtr, IntPtr name, global::ABI.System.Type type, IntPtr *result)
        {
            global::Microsoft.UI.Xaml.Data.ICustomProperty __result = default;
            try
            {
                string       _name        = MarshalString.FromAbi(name);
                object       target       = global::WinRT.ComWrappersSupport.FindObject <object>(thisPtr);
                PropertyInfo propertyInfo = target.GetType().GetProperty(
                    _name,
                    BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public,
                    null,                                                                   // default binder
                    null,                                                                   // ignore return type
                    new Type[] { global::ABI.System.Type.FromAbi(type) },                   // indexed parameter type
                    null                                                                    // ignore type modifier
                    );

                if (propertyInfo is object)
                {
                    __result = new ManagedCustomProperty(propertyInfo);
                }

                *result = MarshalInterface <global::Microsoft.UI.Xaml.Data.ICustomProperty> .FromManaged(__result);
            }
            catch (Exception __exception__)
            {
                global::WinRT.ExceptionHelpers.SetErrorInfo(__exception__);
                return(global::WinRT.ExceptionHelpers.GetHRForException(__exception__));
            }
            return(0);
        }
コード例 #3
0
        public static unsafe int GetActivationFactory(IntPtr hstrTargetAssembly, IntPtr hstrRuntimeClassId, IntPtr *activationFactory)
        {
            *activationFactory = IntPtr.Zero;

            var targetAssembly = MarshalString.FromAbi(hstrTargetAssembly);
            var runtimeClassId = MarshalString.FromAbi(hstrRuntimeClassId);

            try
            {
                var assembly = ActivationLoader.LoadAssembly(targetAssembly);
                var type     = assembly.GetType("WinRT.Module");
                if (type == null)
                {
                    return(REGDB_E_CLASSNOTREG);
                }
                var GetActivationFactory = type.GetMethod("GetActivationFactory");
                if (GetActivationFactory == null)
                {
                    return(REGDB_E_READREGDB);
                }
                IntPtr factory = (IntPtr)GetActivationFactory.Invoke(null, new object[] { runtimeClassId });
                if (factory == IntPtr.Zero)
                {
                    return(E_NOINTERFACE);
                }
                *activationFactory = factory;
                return(S_OK);
            }
            catch (Exception e)
            {
                global::WinRT.ExceptionHelpers.SetErrorInfo(e);
                return(global::WinRT.ExceptionHelpers.GetHRForException(e));
            }
        }
コード例 #4
0
ファイル: Type.cs プロジェクト: wjk/CsWinRT
        public static global::System.Type FromAbi(Type value)
        {
            string name = MarshalString.FromAbi(value.Name);

            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }
            return(TypeNameSupport.FindTypeByName(name.AsSpan()).type);
        }
コード例 #5
0
ファイル: Uri.cs プロジェクト: wjk/CsWinRT
        public static global::System.Uri FromAbi(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            using var uri = ObjectReference <ABI.Windows.Foundation.IUriRuntimeClassVftbl> .FromAbi(ptr);

            IntPtr rawUri = IntPtr.Zero;

            try
            {
                ExceptionHelpers.ThrowExceptionForHR(uri.Vftbl.get_RawUri_10(uri.ThisPtr, out rawUri));
                return(new global::System.Uri(MarshalString.FromAbi(rawUri)));
            }
            finally
            {
                MarshalString.DisposeAbi(rawUri);
            }
        }
コード例 #6
0
        public static global::System.ComponentModel.PropertyChangedEventArgs FromAbi(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            using var args = ObjectReference <ABI.Microsoft.UI.Xaml.Data.IPropertyChangedEventArgsVftbl> .FromAbi(ptr);

            IntPtr propertyName = IntPtr.Zero;

            try
            {
                ExceptionHelpers.ThrowExceptionForHR(args.Vftbl.get_PropertyName_0(args.ThisPtr, &propertyName));
                return(new global::System.ComponentModel.PropertyChangedEventArgs(MarshalString.FromAbi(propertyName)));
            }
            finally
            {
                MarshalString.DisposeAbi(propertyName);
            }
        }
コード例 #7
0
ファイル: HString.cs プロジェクト: weblate/SoundSwitch
 public override string ToString()
 {
     return(MarshalString.FromAbi(handle));
 }
コード例 #8
0
            private static int Do_Abi_Get_Property_Mapping(IntPtr thisPtr, IntPtr name, IntPtr index, IntPtr mapping)
            {
                try
                {
                    ComWrappersSupport.FindObject <global::Windows.Graphics.Effects.Interop.IGraphicsEffectD2D1Interop>(thisPtr).GetNamedPropertyMapping(MarshalString.FromAbi(name), out var mappingResult);
                }
                catch (Exception ex)
                {
                    return(Marshal.GetHRForException(ex));
                }

                return(0);
            }