コード例 #1
0
        public UInt64 GetUInt64()
        {
            UInt64 value = 0;

            PInvokeUtils.ThrowIfResult(NativeMethods.PropertyValue_GetUInt64(this.Interface, ref value));
            return(value);
        }
コード例 #2
0
        private void CreateHelper <T>(T value, CreateValueFunc <T> pInvokeCreate)
        {
            IntPtr pValue = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(pInvokeCreate(value, ref pValue));
            this.SetInterface(pValue);
        }
コード例 #3
0
        public bool GetBoolean()
        {
            bool value = false;

            PInvokeUtils.ThrowIfResult(NativeMethods.PropertyValue_GetBoolean(this.Interface, ref value));
            return(value);
        }
コード例 #4
0
        public Int32 GetInt32()
        {
            Int32 value = 0;

            PInvokeUtils.ThrowIfResult(NativeMethods.PropertyValue_GetInt32(this.Interface, ref value));
            return(value);
        }
コード例 #5
0
        public DateTime GetDateTime()
        {
            long value = 0;

            PInvokeUtils.ThrowIfResult(NativeMethods.PropertyValue_GetDateTime(this.Interface, ref value));
            return(DateTime.FromFileTime(value));
        }
コード例 #6
0
        public byte GetByte()
        {
            byte value = 0;

            PInvokeUtils.ThrowIfResult(NativeMethods.PropertyValue_GetByte(this.Interface, ref value));
            return(value);
        }
コード例 #7
0
 public IntPtr[] GetInspectableArray()
 {
     return(PInvokeUtils.GetPtrArray(delegate(ref UInt32 size, ref IntPtr pValues)
     {
         return NativeMethods.PropertyValue_GetInspectableArray(this.Interface, ref size, ref pValues);
     }));
 }
コード例 #8
0
 public String GetString()
 {
     return(PInvokeUtils.GetString(delegate(ref IntPtr pStr)
     {
         return NativeMethods.PropertyValue_GetString(this.Interface, ref pStr);
     }));
 }
コード例 #9
0
        internal void AddCallbackEventHandler(
            IntPtr pInterface,
            AttachCallbackEventHandlerDelegate pInvokeAttach,
            OnEventHandlerAdapter <T> callback)
        {
            NativeMethods.OnCallbackEventHandler callbackAdapter = (IntPtr pEventArgs) =>
            {
                try
                {
                    var ctorInfo = typeof(T).GetTypeInfo().DeclaredConstructors.Single(
                        ci => ci.GetParameters().Length > 0 &&
                        ci.GetParameters()[0].ParameterType == typeof(IntPtr));
                    var eventArgsAdapter = (T)ctorInfo.Invoke(new object[] { pEventArgs });
                    callback(eventArgsAdapter);
                }
                catch (Exception)
                {
                    return(-1);
                }
                return(0);
            };

            IntPtr pEventHandler = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(pInvokeAttach(pInterface, callbackAdapter, ref pEventHandler));
            this.Callbacks.Value.Add(callback, new Tuple <IntPtr, NativeMethods.OnCallbackEventHandler>(pEventHandler, callbackAdapter));
        }
コード例 #10
0
        private void CreateArrayHelper <T>(T[] value, CreateArrayValueFunc <T> pInvokeCreate)
        {
            IntPtr pValue = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(pInvokeCreate((uint)value.Length, value, ref pValue));
            this.SetInterface(pValue);
        }
コード例 #11
0
        public InspectableAdapter GetResults()
        {
            IntPtr pValue = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.AsyncOperation_GetResults(this.Interface, ref pValue));
            return(ObjectStaticsUtil.CreateInspectable(pValue));
        }
コード例 #12
0
        internal static IntPtr CastToInternal(IntPtr pInterface, Guid iid)
        {
            IntPtr pCastInterface = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.Inspectable_CastTo(pInterface, ref iid, ref pCastInterface));
            return(pCastInterface);
        }
コード例 #13
0
        public int IndexOf(InspectableAdapter value)
        {
            Int32 index = 0;

            PInvokeUtils.ThrowIfResult(NativeMethods.ObservableCollection_IndexOf(this.Interface, value != null ? value.Interface:IntPtr.Zero, ref index));
            return(index);
        }
コード例 #14
0
        public InspectableAdapter GetItem(uint index)
        {
            IntPtr pValue = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.ObservableCollection_GetItem(this.Interface, index, ref pValue));
            return(ObjectStaticsUtil.CreateInspectable(pValue));
        }
コード例 #15
0
        public InspectableAdapter GetProperty(uint propertyId)
        {
            IntPtr pValue = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.ObjectDispatch_GetProperty(this.Interface, propertyId, ref pValue));
            return(ObjectStaticsUtil.CreateInspectable(pValue));
        }
コード例 #16
0
 public void SetProperty(uint propertyId, InspectableAdapter pValue)
 {
     PInvokeUtils.ThrowIfResult(NativeMethods.ObjectDispatch_SetProperty(
                                    this.Interface,
                                    propertyId,
                                    pValue != null ? pValue.Interface:IntPtr.Zero));
 }
コード例 #17
0
        public static bool IsAvailable()
        {
            bool isAvailable = false;

            PInvokeUtils.ThrowIfResult(NativeMethods.Logger_IsAvailable(ref isAvailable));
            return(isAvailable);
        }
コード例 #18
0
        public PropertyTypeInfoAdapter GetResultTypeInfo()
        {
            IntPtr pInterface = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.Command_GetResultTypeInfo(this.Interface, ref pInterface));
            return(new PropertyTypeInfoAdapter(pInterface));
        }
コード例 #19
0
        public bool HasKey(string key)
        {
            bool result = false;

            PInvokeUtils.ThrowIfResult(NativeMethods.Dictionary_HasKey(this.Interface, key, ref result));
            return(result);
        }
コード例 #20
0
        public InspectableAdapter Lookup(string key)
        {
            IntPtr pValue = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.Dictionary_Lookup(this.Interface, key, ref pValue));
            return(ObjectStaticsUtil.CreateInspectable(pValue));
        }
コード例 #21
0
        internal DictionaryAdapter()
        {
            IntPtr pInterface = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.Dictionary_CreateInstance(ref pInterface));
            this.SetInterface(pInterface);
        }
コード例 #22
0
        internal static Guid GetObjectType(IntPtr pInterface)
        {
            Guid type = Guid.Empty;

            PInvokeUtils.ThrowIfResult(NativeMethods.ObjectStaticsUtil_GetObjectType(pInterface, ref type));
            return(type);
        }
コード例 #23
0
        public LoggerLevel GetCategoryLevel(string categoryPath)
        {
            UInt32 level = 0;

            PInvokeUtils.ThrowIfResult(NativeMethods.Logger_GetCategoryLevel(this.Interface, categoryPath, ref level));
            return((LoggerLevel)level);
        }
コード例 #24
0
        public bool IsTypeOf(Guid iid)
        {
            bool result = false;

            PInvokeUtils.ThrowIfResult(NativeMethods.Inspectable_IsTypeOf(this.Interface, ref iid, ref result));
            return(result);
        }
コード例 #25
0
        public InspectableAdapter[] GetItems()
        {
            var items = PInvokeUtils.GetPtrArray(delegate(ref UInt32 size, ref IntPtr pValues)
            {
                return(NativeMethods.ObservableCollection_GetItems(this.Interface, ref size, ref pValues));
            });

            return(ObjectStaticsUtil.CreateInspectableArray(items));
        }
コード例 #26
0
        public T GetActivationFactory <T>(string activationId)
        {
            IntPtr pFactory = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.ActivationFactory_GetFactory(
                                           activationId,
                                           ref pFactory));
            return(GetOrCreateObject(new ObservableObjectAdapter(pFactory)).AssertCast <T>());
        }
コード例 #27
0
        public InspectableAdapter Execute(InspectableAdapter pParameter)
        {
            IntPtr result = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.Command_Execute(
                                           this.Interface,
                                           pParameter != null ? pParameter.Interface:IntPtr.Zero,
                                           ref result));
            return(ObjectStaticsUtil.CreateInspectable(result));
        }
コード例 #28
0
        public bool CanExecute(InspectableAdapter pParameter)
        {
            bool canExecute = false;

            PInvokeUtils.ThrowIfResult(NativeMethods.Command_CanExecute(
                                           this.Interface,
                                           pParameter != null ? pParameter.Interface : IntPtr.Zero,
                                           ref canExecute));
            return(canExecute);
        }
コード例 #29
0
        public static ObjectAdapter ActivateObject(Guid iidType, InspectableAdapter pContext)
        {
            IntPtr pObject = IntPtr.Zero;

            PInvokeUtils.ThrowIfResult(NativeMethods.ObjectStaticsUtil_ActivateObject(
                                           ref iidType,
                                           pContext != null ? pContext.Interface : IntPtr.Zero,
                                           ref pObject));
            return(CreateObject(pObject, GetObjectType(pObject)));
        }
コード例 #30
0
        static LoggerAdapter()
        {
            LazyFoundationInstance = new Lazy <LoggerAdapter>(() =>
            {
                IntPtr pInterface = IntPtr.Zero;

                PInvokeUtils.ThrowIfResult(NativeMethods.Logger_GetFoundationInstance(ref pInterface));
                return(new LoggerAdapter(pInterface));
            });
        }