当前位置: 首页>>代码示例>>C#>>正文


C# JSObject.GetValueOrDefault方法代码示例

本文整理汇总了C#中JSObject.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# JSObject.GetValueOrDefault方法的具体用法?C# JSObject.GetValueOrDefault怎么用?C# JSObject.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSObject的用法示例。


在下文中一共展示了JSObject.GetValueOrDefault方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot swap display to target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pDisplay.ActiveSurface)
            {
                Log.Write("Cannot swap display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // If the target surface has a display, get a reference and remove it.
            Display pOtherView = pTargetSurface.ActiveDisplay;
            if (pOtherView != null)
                Authority.RemoveDisplay(pOtherView);

            // Remove this display from this surface and put it on the target surface.
            Authority.RemoveDisplay(pDisplay);
            Authority.ShowDisplay(pDisplay, pTargetSurface);

            // Now put the other display on the original surface.
            if (pOtherView != null)
                Authority.ShowDisplay(pOtherView, pSurface);

            // Boom.
            return true;
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:40,代码来源:SwapDisplay.cs

示例2: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a sound file.
            var sSound = dArguments.GetValueOrDefault("file", "");
            if (sSound == null || sSound == "")
            {
                Log.Write("Cannot play sound.  Are you missing a 'file' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Attempt to play it.
            try
            {
                SoundPlayer pSound = new SoundPlayer(sSound);
                pSound.Play();
                return true;
            }
            
            // Log warnings.
            catch (Exception e)
            {
                Log.Write("Cannot play sound. " + e.Message, pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:32,代码来源:PlaySound.cs

示例3: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot move display to target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pDisplay.ActiveSurface)
            {
                Log.Write("Cannot move display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // If the new surface is occupied, bail.
            if (pTargetSurface.ActiveDisplay != null)
            {
                Log.Write("Cannot move display to target surface because it already has a display on it.", this.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Do we want to force a reload of everything with the move.
            var bForceReload = dArguments.GetValueOrDefault("force_reload", false);

            // If we want to force a reload.
            if (bForceReload)
            {
                Authority.DeleteDisplay(pDisplay);
                Authority.ShowDisplay(new Display(pDisplay.LoadInstruction, pDisplay.RenderResolution), pTargetSurface);
                return true;
            }

            // If not.
            else
            {
                // Just detach it from one and move to the other.
                Authority.MoveDisplay(pDisplay, pTargetSurface);
                return true;
            }
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:50,代码来源:MoveDisplay.cs

示例4: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var sLoad = dArguments.GetValueOrDefault("load", "");
            if (sLoad == null || sLoad == "")
            {
                Log.Write("Cannot open display.  Missing valid 'load' parameter. e.g. 'http://mysite.com'", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot open display on target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Do we want to override if occupied?
            var bOverride = dArguments.GetValueOrDefault("override", false);

            // If a display is already on the target surface.
            if (pTargetSurface.ActiveDisplay != null)
            {
                // Do we close it?
                if (bOverride)
                {
                    Authority.DeleteDisplay(pTargetSurface.ActiveDisplay);
                }

                // Or do we respect it's right to life!
                else
                {
                    Log.Write("Cannot open display on target surface.  Surface is already occupied.", pDisplay.ToString(), Log.Type.DisplayWarning);
                    return false;
                }
            }

            // Create the new display.
            Authority.ShowDisplay(new Display(sLoad), pTargetSurface);
            return true;
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:49,代码来源:OpenDisplay.cs

示例5: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Get the first target.
            var pTarget1 = Authority.FindSurface(dArguments.GetValueOrDefault("target1", ""));
            if (pTarget1 == null)
            {
                Log.Write("SwapTargetDisplay: Missing valid 'target1' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Get the first target.
            var pTarget2 = Authority.FindSurface(dArguments.GetValueOrDefault("target2", ""));
            if (pTarget2 == null)
            {
                Log.Write("SwapTargetDisplay: Missing valid 'target2' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Check the surface this view is on is not our target.
            if (pTarget1 == pTarget2)
            {
                Log.Write("SwapTargetDisplay: Surface targets are the same.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Store references to the displays.
            Display pDisplay1 = pTarget1.ActiveDisplay;
            Display pDisplay2 = pTarget2.ActiveDisplay;

            // Remove them both from surfaces.
            if (pDisplay1 != null) Authority.RemoveDisplay(pDisplay1);
            if (pDisplay2 != null) Authority.RemoveDisplay(pDisplay2);

            // Re-open them on the other surfaces.
            if (pDisplay1 != null) Authority.ShowDisplay(pDisplay1, pTarget2);
            if (pDisplay2 != null) Authority.ShowDisplay(pDisplay2, pTarget1);

            // Boom.
            return true;
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:47,代码来源:SwapTargetDisplay.cs

示例6: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot close display on target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }
            
            // Close it, if open.
            if (pTargetSurface.ActiveDisplay != null)
            {
                Authority.DeleteDisplay(pTargetSurface.ActiveDisplay);
                return true;
            }

            // Return false, nothing to do.
            return false;
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:27,代码来源:CloseTargetDisplay.cs

示例7: Cuboid

        /// <summary>
        /// Construct a new Kinect Trigger Space Cuboid based on some arguments.
        /// </summary>
        /// <param name="pSurface"></param>
        /// <param name="dArguments"></param>
        public Cuboid(Display pView, JSObject dArguments)
        {
            // Get the min-depth touch depth and cuboid height.
            fSurfaceZOffset = dArguments.GetValueOrDefault("surface_zoffset", fSurfaceZOffset);
            fHeight = dArguments.GetValueOrDefault("height", fHeight);

            // Get the surface we are capturing input from.
            this.SetRelativeSurface(dArguments.GetValueOrDefault("relativeto", ""));

            // Get the callback.
            this.SetCallbackFunctionName(dArguments.GetValueOrDefault("callback", ""));

            // Store the view.
            ParentDisplay = pView;

            // Push us onto a list of spatial queries in the Kinect processing thread.
            Surface.SpatialQueries.Add(this);
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:23,代码来源:Cuboid.cs

示例8: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pCurrentSurface = Authority.FindSurface(dArguments.GetValueOrDefault("source", ""));
            if (pCurrentSurface == null)
            {
                Log.Write("Cannot move target display to target surface.  Missing valid 'source' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Get the target display.
            var pCurrentDisplay = pCurrentSurface.ActiveDisplay;
            if (pCurrentDisplay == null)
            {
                Log.Write("Cannot move target display to target surface.  Source surface has no display.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("dest", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot move target display to target surface.  Missing valid 'dest' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pCurrentSurface)
            {
                Log.Write("Cannot move target display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // If the new surface is occupied, bail.
            if (pTargetSurface.ActiveDisplay != null)
            {
                Log.Write("Cannot move target display to target surface because it already has a display on it.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Do we want to close the display on the destination?
            var bOverride = dArguments.GetValueOrDefault("override", false);

            // If a display is already on the target surface.
            if (pTargetSurface.ActiveDisplay != null)
            {
                // Do we close it?
                if (bOverride)
                {
                    Authority.DeleteDisplay(pTargetSurface.ActiveDisplay);
                }

                // Or do we respect it's right to life!
                else
                {
                    Log.Write("Cannot move target display to target surface.  Surface is already occupied.", pDisplay.ToString(), Log.Type.DisplayWarning);
                    return false;
                }
            }

            // Do we want to force a reload of everything with the move.
            var bForceReload = dArguments.GetValueOrDefault("force_reload", false);

            // If we want to force a reload.
            if (bForceReload)
            {
                Authority.DeleteDisplay(pCurrentDisplay);
                Authority.ShowDisplay(new Display(pCurrentDisplay.LoadInstruction, pCurrentDisplay.RenderResolution), pTargetSurface);
                return true;
            }

            // If not.
            else
            {
                // Just detach it from one and move to the other.
                Authority.MoveDisplay(pCurrentDisplay, pTargetSurface);
                return true;
            }
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:86,代码来源:MoveTargetDisplay.cs

示例9: LowestPointCube

 /// <summary>
 /// Construct a new Kinect Trigger Space Cuboid based on some arguments.
 /// </summary>
 /// <param name="pSurface"></param>
 /// <param name="dArguments"></param>
 public LowestPointCube(Display pView, JSObject dArguments)
     : base(pView, dArguments)
 {
     // Store the point limit.
     iPointLimit = Math.Max(0, dArguments.GetValueOrDefault("point_limit", iPointLimit));
     bSendEmptyFrames = dArguments.GetValueOrDefault("sendemptyframes", bSendEmptyFrames);
     bSendEmptySuccessiveFrames = dArguments.GetValueOrDefault("sendemptysucessiveframes", bSendEmptyFrames);
 }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:13,代码来源:LowestPointCube.cs


注:本文中的JSObject.GetValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。