コード例 #1
0
ファイル: JsDynamicWrapper.cs プロジェクト: JimmyJune/DotWeb
        private object SetProperty(DispatchIdentifier id, JsValue[] jsArgs, out Type returnType)
        {
            //Type targetType;
            //object value;
            //if (this.properties.TryGetValue(id.AsString, out value)) {
            //    targetType = value.GetType();
            //}
            //else {
                // this is needed so that we can make a dummy object instance
            var targetType = typeof(JsNativeHolder);
            //}

            var value = this.bridge.UnwrapValue(jsArgs.First(), targetType);
            this.SetPropertyValue(id.AsString, value);
            //this.bridge.SetDynamicProperty(this.target, id.AsString, value);
            returnType = typeof(void);
            return null;
        }
コード例 #2
0
ファイル: JsArrayWrapper.cs プロジェクト: JimmyJune/DotWeb
        public object Invoke(DispatchIdentifier id, DispatchType dispType, JsValue[] args, out Type returnType)
        {
            if (id.Tag == DispatchIdentifierType.String) {
                if (id.AsString == "length") {
                    return GetLength(dispType, out returnType);
                }
                else {
                    returnType = typeof(void);
                    return null;
                }
            }
            else {
                int intId = id.AsInt;
                if (intId == this.target.Length) {
                    return GetLength(dispType, out returnType);
                }

                if (intId >= 0 && intId < this.target.Length) {
                    Debug.WriteLine(string.Format("{0}, {1}[{2}]", dispType, this.target, id));
                    if (dispType == DispatchType.PropertyGet) {
                        returnType = this.elementType;
                        return this.target.GetValue(intId);
                    }

                    if (dispType == DispatchType.PropertySet) {
                        object value = this.bridge.UnwrapValue(args.First(), this.elementType);
                        this.target.SetValue(value, intId);
                        returnType = typeof(void);
                        return null;
                    }
                }
            }

            throw new NotSupportedException();
        }