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


C# JSObject类代码示例

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


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

示例1: GetPrototype

        public override dynamic GetPrototype()
        {
            dynamic p = new JSObject();
            p.toString = p.valueOf = new Func<dynamic, string>((self) => self._primitiveValue);

            return GetPrototype(this.GetType().Name, p);
        }
开发者ID:heupel,项目名称:hyperjs,代码行数:7,代码来源:JSString.cs

示例2: parseInt

 internal static JSObject parseInt(JSObject thisBind, Arguments args)
 {
     double result = double.NaN;
     var radixo = args[1];
     double dradix = radixo.IsExist ? Tools.JSObjectToDouble(radixo) : 0;
     int radix;
     if (double.IsNaN(dradix) || double.IsInfinity(dradix))
         radix = 0;
     else
         radix = (int)((long)dradix & 0xFFFFFFFF);
     if (radix != 0 && (radix < 2 || radix > 36))
         return Number.NaN;
     var source = args[0];
     if (source.valueType == JSObjectType.Int)
         return source;
     if (source.valueType == JSObjectType.Double)
         return double.IsInfinity(source.dValue) || double.IsNaN(source.dValue) ?
             Number.NaN : source.dValue == 0.0 ? (Number)0 : // +0 и -0 должны стать равными
             (Number)System.Math.Truncate(source.dValue);
     var arg = source.ToString().Trim(Tools.TrimChars);
     if (!string.IsNullOrEmpty(arg))
         Tools.ParseNumber(arg, out result, radix, Tools.ParseNumberOptions.AllowAutoRadix);
     if (double.IsInfinity(result))
         return Number.NaN;
     return System.Math.Truncate(result);
 }
开发者ID:modulexcite,项目名称:NiL.JS,代码行数:26,代码来源:GlobalFunctions.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)
        {
            // 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

示例4: Fib_1

 private JSValue Fib_1 (JSFunction function, JSObject @this, JSValue [] args)
 {
     return args[0].NumberValue <= 1 ? new JSValue (@this.Context, 1) : new JSValue (@this.Context,
         Fib_1 (function, @this, new [] { new JSValue (@this.Context, args[0].NumberValue - 1) }).NumberValue +
         Fib_1 (function, @this, new [] { new JSValue (@this.Context, args[0].NumberValue - 2) }).NumberValue
     );
 }
开发者ID:petejohanson,项目名称:banshee,代码行数:7,代码来源:JSFunctionTests.cs

示例5: refreshGlobalObjectProto

 internal static JSObject refreshGlobalObjectProto()
 {
     thisProto = CreateObject();
     thisProto.oValue = thisProto;
     thisProto.attributes |= JSObjectAttributesInternal.ReadOnly | JSObjectAttributesInternal.Immutable | JSObjectAttributesInternal.DoNotEnum | JSObjectAttributesInternal.DoNotDelete;
     return thisProto;
 }
开发者ID:modulexcite,项目名称:NiL.JS,代码行数:7,代码来源:GlobalObject.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 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

示例7: Ribbon

        public Ribbon()
        {
            InitializeComponent();
            BrowserUtility.InitBrowserUtility();

            // Register the test page component with command info
            _testComponent = new TestPageComponent();
            PageManager.Instance.AddPageComponent(_testComponent);

            _ribbon = new JSObject();
            _ribbon.SetField<bool>("initStarted", false);
            _ribbon.SetField<bool>("buildMinimized", true);
            _ribbon.SetField<bool>("launchedByKeyboard", false);
            _ribbon.SetField<bool>("initialTabSelectedByUser", false);
            _ribbon.SetField<string>("initialTabId", "Ribbon.Read");

            Anchor readTabA = (Anchor)Browser.Document.GetById(ReadTabId).FirstChild;
            Anchor libraryTabA = (Anchor)Browser.Document.GetById(LibraryTabId).FirstChild;
            Anchor documentTabA = (Anchor)Browser.Document.GetById(DocumentTabId).FirstChild;

            readTabA.Click += RibbonStartInit;
            libraryTabA.Click += RibbonStartInit;
            documentTabA.Click += RibbonStartInit;

            Browser.Window.Resize += HandleWindowResize;
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:26,代码来源:page.cs

示例8: Create

    // Use this for initialization
    public void Create()
    {
        ship = GetComponent<Ship> ();
        fleetAILoader = ship.fleet.GetComponent<FleetAILoader>();

        jsobj = new JSObject(fleetAILoader.GetEngine(),ship);
    }
开发者ID:oopartians,项目名称:SpaceBattle,代码行数:8,代码来源:ShipJSObject.cs

示例9: Invoke

 public override JSObject Invoke(JSObject thisBind, Arguments args)
 {
     var res = del(thisBind, args);
     if (res == null)
         return JSObject.Null;
     return res;
 }
开发者ID:modulexcite,项目名称:NiL.JS,代码行数:7,代码来源:ExternalFunction.cs

示例10: MappNested

        private JSGenericObject MappNested(object ifrom, JSObject resobject, JSGenericObject gres)
        {
            if (ifrom == null)
                return gres;

            IEnumerable<PropertyInfo> propertyInfos = ifrom.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (PropertyInfo propertyInfo in propertyInfos.Where(p => p.CanRead))
            {
                string pn = propertyInfo.Name;
                object childvalue = null;
                try
                {
                    childvalue = propertyInfo.GetValue(ifrom, null); 
                }
                catch(Exception e)
                {
                    Trace.WriteLine(string.Format("MVVM for awesomium: Unable to convert property {0} from {1} exception {2}", pn, ifrom, e));
                    continue;
                }

                IJSCSGlue childres = Map(childvalue);

                resobject[pn] = childres.JSValue;
                gres.Attributes[pn] = childres;
            }

            return gres;
        }      
开发者ID:skyaxl,项目名称:MVVM-for-awesomium,代码行数:29,代码来源:CSharpToJavascriptMapper.cs

示例11: Check

        private JSValue Check(JSObject ires)
        {
            if (ires == null)
                throw ExceptionHelper.NoKoExtension();

            return ires;
        }
开发者ID:skyaxl,项目名称:MVVM-for-awesomium,代码行数:7,代码来源:LocalBuilder.cs

示例12: 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 function to return the results too.
            if (!dArguments.HasProperty("callback")) throw new Exception("Missing 'callback' argument.");

            // Return a list of surface names.
            JSValue[] lSurfaces = (from pSurf in Authority.Surfaces select new JSValue(pSurf.Identifier)).ToArray();

            // If that function is a string.
            var jsValue = dArguments["callback"];
            if (jsValue.IsString)
            {
                pDisplay.AsyncCallGlobalFunction(jsValue.ToString(), lSurfaces);
                return true;
            }

            /*
            // If it is a function.
            else if (jsValue.IsObject)
            {
                ((JSObject)jsValue).Invoke("call", lSurfaces);
                return true;
            }
            */

            // Throw the error.
            throw new Exception("Unknown type specified in 'callback' argument.  Expected string.");
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:35,代码来源:SurfaceList.cs

示例13: TestAddObjectKey

		public void TestAddObjectKey ()
		{
			JSObject o = new JSObject (null);
			o.AddObjectKey (0, 1);

			Assert.AreEqual (1, o.Count, "A1");
			Assert.IsTrue (o.ContainsObjectKey (0), "A2");
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:8,代码来源:JSObjectTest.cs

示例14: DeleteDontDeletePropertyTest

 public void DeleteDontDeletePropertyTest()
 {
     var obj = new JSObject (context, null);
     obj.SetProperty ("foo", new JSValue (context, "i am permanent"), JSPropertyAttribute.DontDelete);
     Assert.IsTrue (obj.HasProperty ("foo"));
     Assert.IsFalse (obj.DeleteProperty ("foo"));
     Assert.IsTrue (obj.HasProperty ("foo"));
 }
开发者ID:knocte,项目名称:banshee,代码行数:8,代码来源:JSObjectTests.cs

示例15: charAt

 public static String charAt(JSObject self, Arguments pos)
 {
     var strValue = self.ToString();
     int p = Tools.JSObjectToInt32(pos[0], true);
     if ((p < 0) || (p >= strValue.Length))
         return "";
     return strValue[p].ToString();//Tools.charStrings[strValue[p]];
 }
开发者ID:modulexcite,项目名称:NiL.JS,代码行数:8,代码来源:String.cs


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