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


C# ScriptObject.GetProperty方法代码示例

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


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

示例1: SettingsClosingEventArgs

        /// <summary>
        /// Constructs a managed closing event from a corresponding JavaScript event.
        /// </summary>
        /// <param name="sevent">The JavaScript event argument for the SettingsClosing event.</param>
        public SettingsClosingEventArgs(ScriptObject sevent)
            : base()
        {
            this.sevent = sevent;

            byte act = Convert.ToByte(sevent.GetProperty("closeAction"));

            if (act == 0)
                Action = CloseAction.Commit;
            else Action = CloseAction.Cancel;

            Cancellable = Convert.ToBoolean(sevent.GetProperty("cancellable"));
        }
开发者ID:DaspawnW,项目名称:Denon-Receiver-Gadget,代码行数:17,代码来源:SilverlightGadgetEvents.cs

示例2: HtmlEventArgs

		internal HtmlEventArgs (HtmlObject source,
					ScriptObject eventObj)
		{
			this.source_element = source;
			this.eventObject = eventObj;

			eventType = (string) eventObject.GetProperty("type");

			if (eventType.StartsWith ("click") ||
			    eventType.StartsWith ("dblclick") ||
			    eventType.StartsWith ("mouse"))
				eventKind = EventKind.Mouse;
			else if (eventType.StartsWith ("key")) {
				eventKind = EventKind.Key;
			}
		}
开发者ID:dfr0,项目名称:moon,代码行数:16,代码来源:HtmlEventArgs.cs

示例3: exec

 public dynamic exec(string uid, string compName, string action, ScriptObject scriptObject = null)
 {
     // extract arguments
     List<object> args = new List<object>();
     if (scriptObject != null)
     {
         int i = 0;
         object prop;
         while (true) {
             prop = scriptObject.GetProperty(i++);
             if (prop != null) {
                 args.Add(prop);
             } else {
                 break;
             }
         }
     }
     return this._exec(uid, compName, action, args.Count != 0 ? args.ToArray() : null);
 }
开发者ID:russtee,项目名称:moxie,代码行数:19,代码来源:Moxie.xaml.cs

示例4: OnXmlHttpDownloadComplete

        public void OnXmlHttpDownloadComplete(ScriptObject handlerThis, string file) {
            try {
                object objReadyState = handlerThis.GetProperty("readyState");
                object objStatus = handlerThis.GetProperty("status");

                int readyState = 0;
                int status = 0;

                if (objStatus != null) status = (int)((double)objStatus / 1);
                if (objReadyState != null) readyState = (int)((double)objReadyState / 1);

                if (readyState == 4 && status == 200) {
                    string content = (string)handlerThis.GetProperty("responseText");
                    DownloadComplete(new Uri(file, UriKind.RelativeOrAbsolute), content, _onComplete);
                } else if (readyState == 4 && status != 200) {
                    throw new Exception(file + " download failed (status: " + status + ")");
                }
            } catch (Exception e) {
                // This catch-all is necessary since any unhandled exceptions
                if (Settings.ReportUnhandledErrors)
                    ErrorFormatter.DisplayError(Settings.ErrorTargetID, e);
            }
        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:23,代码来源:BrowserVirtualFilesystem.cs

示例5: GetBoundMember

 public static object GetBoundMember(ScriptObject obj, string name)
 {
     return obj.GetProperty(name);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:4,代码来源:ExtensionTypes.cs

示例6: ReadAsWindowsFirefoxXBox360

        internal void ReadAsWindowsFirefoxXBox360(ScriptObject gamepad)
        {
            this.IsActive = true;
            this.Identifier = (gamepad.GetProperty("id") as String);
            this.Name = "XBox 360 Controller";

            // Axes
            var axes = (gamepad.GetProperty("axes") as ScriptObject);
            this.LeftStickX = (Double)(axes.GetProperty(0));
            this.LeftStickY = (Double)(axes.GetProperty(1));
            this.LeftShoulder1 = ((Double)(axes.GetProperty(2)) > 0.00 ? (Double)(axes.GetProperty(2)) : 0.00);
            this.RightShoulder1 = ((Double)(axes.GetProperty(2)) < 0.00 ? -(Double)(axes.GetProperty(2)) : 0.00);
            this.RightStickX = (Double)(axes.GetProperty(3));
            this.RightStickY = (Double)(axes.GetProperty(4));
            this.DPadLeft = ((Double)(axes.GetProperty(5)) < -0.50 ? 1.00 : 0.00);
            this.DPadRight = ((Double)(axes.GetProperty(5)) > 0.50 ? 1.00 : 0.00);
            this.DPadUp = ((Double)(axes.GetProperty(6)) < -0.50 ? 1.00 : 0.00);
            this.DPadDown = ((Double)(axes.GetProperty(6)) > 0.50 ? 1.00 : 0.00);

            // Buttons
            var buttons = (gamepad.GetProperty("buttons") as ScriptObject);
            this.FaceButton0 = (Double)(buttons.GetProperty(0));
            this.FaceButton1 = (Double)(buttons.GetProperty(1));
            this.FaceButton2 = (Double)(buttons.GetProperty(2));
            this.FaceButton3 = (Double)(buttons.GetProperty(3));
            this.LeftShoulder0 = (Double)(buttons.GetProperty(4));
            this.RightShoulder0 = (Double)(buttons.GetProperty(5));
            this.Select = (Double)(buttons.GetProperty(6));
            this.Start = (Double)(buttons.GetProperty(7));
            this.LeftStickButton = (Double)(buttons.GetProperty(8));
            this.RightStickButton = (Double)(buttons.GetProperty(9));

            // Deadzones
            // From http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001(v=vs.85).aspx
            this.DeadZoneLeftStick = (7849.00 / 32767.00);
            this.DeadZoneRightStick = (8689.00 / 32767.00);
            this.DeadZoneShoulders = (30.00 / 255.00);
        }
开发者ID:TinkerWorX,项目名称:Silverlight-Gamepad-Input,代码行数:38,代码来源:GamePadState.cs

示例7: ReadAsMacintoshChromeF310

        internal void ReadAsMacintoshChromeF310(ScriptObject gamepad)
        {
            this.IsActive = true;
            this.Identifier = (gamepad.GetProperty("id") as String);
            this.Name = "Logitech F310 Controller";

            // Axes
            var axes = (gamepad.GetProperty("axes") as ScriptObject);
            this.LeftStickX = (Double)(axes.GetProperty(0));
            this.LeftStickY = (Double)(axes.GetProperty(1));
            this.RightStickX = (Double)(axes.GetProperty(2));
            this.RightStickY = (Double)(axes.GetProperty(5));
            // There is a switch to toggle the left joystick and dpad
            // only one is enabled at a time and the output always goes
            // through the left joystick
            this.DPadLeft = Double.NaN;
            this.DPadRight = Double.NaN;
            this.DPadUp = Double.NaN;
            this.DPadDown = Double.NaN;

            // Buttons
            var buttons = (gamepad.GetProperty("buttons") as ScriptObject);
            this.FaceButton0 = (Double)(buttons.GetProperty(1));
            this.FaceButton1 = (Double)(buttons.GetProperty(2));
            this.FaceButton2 = (Double)(buttons.GetProperty(0));
            this.FaceButton3 = (Double)(buttons.GetProperty(3));
            this.LeftShoulder0 = (Double)(buttons.GetProperty(4));
            this.RightShoulder0 = (Double)(buttons.GetProperty(5));
            this.LeftShoulder1 = (Double)(buttons.GetProperty(6));
            this.RightShoulder1 = (Double)(buttons.GetProperty(7));
            this.Select = (Double)(buttons.GetProperty(8));
            this.Start = (Double)(buttons.GetProperty(9));
            this.LeftStickButton = (Double)(buttons.GetProperty(10));
            this.RightStickButton = (Double)(buttons.GetProperty(11));

            // Deadzones
            // From http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001(v=vs.85).aspx
            this.DeadZoneLeftStick = (7849.00 / 32767.00);
            this.DeadZoneRightStick = (8689.00 / 32767.00);
            this.DeadZoneShoulders = (30.00 / 255.00);
        }
开发者ID:TinkerWorX,项目名称:Silverlight-Gamepad-Input,代码行数:41,代码来源:GamePadState.cs

示例8: recordStart

    public void recordStart(ScriptObject so) {
      try {
        trace("recordStart begin");
        player.Stop(); url = null;
        recordStartPar = new RecordStartPar {
          toDisc = (bool)so.GetProperty("toDisc"),
          //slOldBrowser = (bool)so.GetProperty("slOldBrowser"),
          toDiscFileUrl = (string)so.GetProperty("toDiscFileUrl"),
        };
        recordedBytes = 0;
        //if (recordStartPar.slOldBrowser && recordStartPar.toDisc) recordStartPar.toDiscLib = new uploadChunk.lib(null, () => Recorder.audioFormat, recordStartPar.toDiscFileUrl);
        if (recordedStream == null) recordedStream = new MemoryStream(); else recordedStream.SetLength(0);
        LMMedia.Recorder.RecordStart(recordStartPar, buf => {
          recordedBytes += buf.Length;
          if (OnRecordedMilisecs != null) Deployment.Current.Dispatcher.BeginInvoke(() => OnRecordedMilisecs(null, new NumberEventArgument { Value = (int)((long)8 * 1000 * recordedBytes / Recorder.audioFormat.SamplesPerSecond / Recorder.audioFormat.BitsPerSample) }));
          if (recordStartPar.toDisc) { //zapis na disk
            //if (recordStartPar.slOldBrowser) { //stary browser uploaduje na disk PCM data a po ukonceni provede MP3 kompresi
            //  recordStartPar.toDiscLib.uploadChunk(buf);
            //} else { //novy browser posle PCM do JS, kde se vse zpravuje podobne, jako pro Chrome nebo FF
            if (recordedStream.Position == 0) {
              var wr = new BinaryWriter(recordedStream);
              wr.Write((UInt16)Recorder.audioFormat.SamplesPerSecond); wr.Write((UInt16)Recorder.audioFormat.BitsPerSample); wr.Write((UInt16)Recorder.audioFormat.Channels);
            }
            recordedStream.Write(buf, 0, buf.Length);

            //var dump = buf.Take(10).Select(b => b.ToString()).Aggregate((r, i) => r + "," + i);

            Deployment.Current.Dispatcher.BeginInvoke(() => onPCMData(false));
            //XXX
            //trace("recordStart data " + buf.Take(10).Select(b => b.ToString()).Aggregate((r, i) => r + "," + i));
            //UInt16[] pcm = new UInt16[buf.Length / 2];
            //for (var i = 0; i < pcm.Length; i++) pcm[i] = BitConverter.ToUInt16(buf, i * 2);
            //swap double bytes
            //var bytes = buf.Select(b => Convert.ToChar(b)).ToArray();
            //for (var i = 0; i < bytes.Length / 2; i++) {
            //  var b = bytes[i * 2]; bytes[i * 2] = bytes[i * 2 + 1]; bytes[i * 2 + 1] = b;
            //}
            //var str = new string(bytes);
            //  OnPCMData(null, new PCMEventArgument {
            //    //Value = new List<byte>(buf),
            //    //Value = ByteArrayToHex(buf),
            //    BitsPerSample = Recorder.audioFormat.BitsPerSample,
            //    SamplesPerSecond = Recorder.audioFormat.SamplesPerSecond
            //  });
            //});
            //}
          } else { //zapis do pameti
            if (recordedStream.Position == 0) LMMedia.WaveFormatExtensible.WriteHeaderStart(recordedStream, Recorder.audioFormat);
            recordedStream.Write(buf, 0, buf.Length);
          }
        });
        trace("recordStart end");
      } catch (Exception exp) {
        error("recordStart", exp);
      }
    }
开发者ID:PavelPZ,项目名称:REW,代码行数:56,代码来源:Host.cs

示例9: iss_removeAll

        /**
         * Conducts an Isolated Storage removal or removal-precursory retrieval on all the
         * data items present in the IsolatedStorageSettings-related file in a given store,
         * dependant on the value of a boolean expression specifying the items to be processed.

         * @param exprStr           a String representation of a boolean expression
         * @param optionsSO         a ScriptObject containing auxilary data
         *                          pertinent to the to-be-conducted operation
         * @param operationID       a String identifying this storage operation in the
         *                          client-side scripting environment in which it was created
         */
        public void iss_removeAll(String exprStr, ScriptObject optionsSO, String operationID)
        {
            int processedItemCount = 0;

            /**
             * Concludes the over-arching remove operation, passing to a Javascript function
             * capable of handling such an event the number of data items processed,
             * as well as the error spawned by the operation, if any.

             * @param e		the Exception responsible for concluding the over-arching remove operation
             */
            Action<Exception> completeRemoveAll = delegate(Exception e)
            {
                Object[] argArray = (e == null ? new Object[]{processedItemCount} : new Object[] {processedItemCount, e});
                complete(operationID, argArray);
            };

            /**
             * Removes all the data items from the IsolatedStorageSettings-related
             * file in the store specified in {@code optionsObj}.
             */
            Action removeAll = delegate()
            {
                //Obtain an IsolatedStorageSettings object capable of conducting storage operations
                //in the store with the specified scope (such operations target a specific system-designated file)
                IsolatedStorageSettings iss = getIsolatedStorageSettings((String)optionsSO.GetProperty("storeScope"));

                //Record the number of data items currently in the file linked to iss
                int dataItemCount = iss.Count;

                //Clear and immediately serialize the (now absent) data in iss to the
                //file it is linked to. These actions clear the data in the linked file
                iss.Save();
                iss.Clear();
                /////

                //Set the number of items processed to the number of data items present before the file linked to ISS was cleared
                processedItemCount = dataItemCount;
            };

            if (exprStr.Equals("true"))
                executeStorageOperation(removeAll, completeRemoveAll);
            else
                iss_getAll(optionsSO, operationID);
        }
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:56,代码来源:BakedGoods.cs

示例10: iss_remove

        /**
         * Conducts an IsolatedStorageSettings-based removal operation in a
         * given store on data items keyed by Strings in a given collection.

         * @param keyArraySO         a ScriptObject containing elements each identifying a data item
         *                           in the IsolatedStorageSettings-related file located in a given store
         * @param optionsSO          a ScriptObject containing auxiliary data pertinent to the to-be-conducted operation
         * @param operationID        a String identifying this storage operation in the client-side scripting environment in which it was spawned
         */
        public void iss_remove(ScriptObject keyArraySO, ScriptObject optionsSO, String operationID)
        {
            int processedItemCount = 0;

            /**
             * Concludes the over-arching remove operation, passing to a Javascript function
             * capable of handling such an event the number of data items processed,
             * as well as the error spawned by the operation, if any.

             * @param e		the Exception responsible for concluding the over-arching remove operation
             */
            Action<Exception> completeRemove = delegate(Exception e)
            {
                Object[] argArray = (e == null ? new Object[] { processedItemCount } : new Object[] { processedItemCount, e });
                complete(operationID, argArray);
            };

            /**
             * Removes data items identified by the elements in {@code keyArray} from the
             * IsolatedStorageSettings-related file  specified in {@code optionsObj}.
             */
            Action remove = delegate()
            {
                //Obtain an IsolatedStorageSettings object capable of conducting storage operations
                //in the store withthe specified scope (such operations target a specific system-designated file)
                IsolatedStorageSettings iss = getIsolatedStorageSettings((String)optionsSO.GetProperty("storeScope"));

                //Loop through the elements in keyArraySO, removing from iss (which
                //contains the data of the file it is linked to) the item each keys
                int keyCount = (int)(double)keyArraySO.GetProperty("length");
                for (int i = 0; i < keyCount; i++)
                {
                    String key = keyArraySO.GetProperty(i).ToString();
                    iss.Remove(key);
                }
                /////

                //Immediately serialize the data in iss to its linked file
                iss.Save();

                //Set the number of items processed to the number of elements in keyArraySO (if execution has reached
                //here, each item keyed by an element in keyArray has been successfully removed from the store)
                processedItemCount = keyCount;
            };

            executeStorageOperation(remove, completeRemove);
        }
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:56,代码来源:BakedGoods.cs

示例11: iss_getAll

        /**
         * Performs an Isolated Storage retrieval operation on all the data items present
         * in the IsolatedStorageSettings-related file in a given store. The set of retrieved items
         * will be filtered for particular items by the client-side, which, depending on the type storage operation
         * responsible for invoking this function may send back the filtered items for further processing.

         * @param optionsDic        a ScriptObject containing auxilary data
         *                          pertinent to the to-be-conducted operation
         * @param operationID       a String identifying this storage operation in the
         *                          client-side scripting environment in which it was created
         */
        public void iss_getAll(ScriptObject optionsSO, String operationID)
        {
            //Will contain Dictonaries each consisting of the constituent key and value components
            //(keyed by "keyObj" and "valueObj" respectively) of a data item in the
            //IsolatedStorageSettings-related file contained in the target store
            List<Dictionary<String, Object>> dataItemList = new List<Dictionary<String, Object>>();

            int processedItemCount = 0;

            /**
             * Concludes the over-arching get operation, passing to a Javascript function capable of
             * handling such an event the number of data items processed, data procured as a
             * result of the retrieval as well as the error spawned by the operation, if any.

             * @param e		the Exception responsible for concluding the over-arching get operation
             */
            Action<Exception> completeGetAll = delegate(Exception e)
            {
                Object[] argArray = (e == null ? new Object[] {processedItemCount, dataItemList}
                                               : new Object[] {processedItemCount, dataItemList, e});
                complete(operationID, argArray);
            };

            /**
             * Retrieves all the data from the IsolatedStorageSettings-related file specified in {@code optionsObj}.
             */
            Action getAll = delegate()
            {
                //Obtain an IsolatedStorageSettings object capable of conducting storage operations
                //in the store with the specified scope (such operations target a specific system-designated file)
                IsolatedStorageSettings iss = getIsolatedStorageSettings((String)optionsSO.GetProperty("storeScope"));

                //Loop through the key-value pairs in the file linked to iss, appending
                //Dictionaries for, and containing the constituents of, each to dataItemList
                foreach (KeyValuePair<String, Object> dataItem in iss)
                    dataItemList.Add(new Dictionary<String, Object> { { "key", dataItem.Key }, { "value", dataItem.Value } });

                //Set the number of items processed to the number of items extracted from issStore
                processedItemCount = dataItemList.Count;

            };

            executeStorageOperation(getAll, completeGetAll);
        }
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:55,代码来源:BakedGoods.cs

示例12: iss_get

        /**
         * Conducts an IsolatedStorageSettings-based retrieval operation in a
         * given store on data items keyed by Strings in a given collection.

         * @param keyArraySO        a ScriptObject containing elements each identifying a data item
         *                          in the IsolatedStorageSettings-related file located in a given store
         * @param optionsDic        a ScriptObject containin auxiliary data-pertinent to the to-be-conducted operation
         * @param operationID       a String which uniquely identifies this storage operation in
         *                          the client-side scripting environment in which it was spawned
         */
        public void iss_get(ScriptObject keyArraySO, ScriptObject optionsSO, String operationID)
        {
            //Will contain pairs each consisting of a String in keyArray and the object it keys
            //in the IsolatedStorageSettings-related file contained in the target store
            Dictionary<String, Object> keyValuePairsDic = new Dictionary<String, Object>();

            int processedItemCount = 0;

            /**
             * Concludes the over-arching get operation, passing to a Javascript function capable of
             * handling such an event the number of data items processed, data procured as a
             * result of the retrieval as well as the error spawned by the operation, if any.

             * @param e		the Exception responsible for concluding the over-arching get operation
             */
            Action<Exception> completeGet = delegate(Exception e)
            {
                Object[] argArray = (e == null ? new Object[] { processedItemCount, keyValuePairsDic }
                                               : new Object[] { processedItemCount, keyValuePairsDic, e });
                complete(operationID, argArray);
            };

            /**
            * Performs a retrieval operation on the data items in the IsolatedStorageSettings-related
            * file specified in {@code optionsObj} that are identified by an element in {@code keyArray}.
            */
            Action get = delegate()
            {
                //Obtain an IsolatedStorageSettings object capable of conducting storage operations
                //in the store with the specified scope (such operations target a specific system-designated file)
                IsolatedStorageSettings iss = getIsolatedStorageSettings((String)optionsSO.GetProperty("storeScope"));

                //Loop through the elements in keyArray, establishing a pairing in
                //keyValuePairsDic between each and the object it keys (if any) in the
                //file linked to iss, incrementing processedItemCount after each such operation
                int keyCount = (int)(double)keyArraySO.GetProperty("length");
                for (int i = 0; i < keyCount; i++, processedItemCount++)
                {
                    String key = keyArraySO.GetProperty(i).ToString();

                    Object value;
                    iss.TryGetValue(key, out value);
                    keyValuePairsDic[key] = value;
                }
                /////
            };

            executeStorageOperation(get, completeGet);
        }
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:59,代码来源:BakedGoods.cs

示例13: isf_set

        /**
         * Conducts an Isolated Storage set operation using the data
         * contained in each element in a collection of ScriptObjects.

         * @code dataArray          a ScriptObject containing a collection of ScriptObjects each consisting of an object
         *                          to be persisted in Isolated Storage, a String which will name it in the store,
         *                          and (optionally) data to be used to dictate the write operation for that data item
         * @param optionsDic        a ScriptObject containing auxilary data pertinent to the to-be-conducted operation
         * @param operationID       a String identifying this storage operation in the
         *                          client-side scripting environment in which it was created
         */
        public void isf_set(ScriptObject dataArraySO, ScriptObject optionsSO, String operationID)
        {
            int processedItemCount = 0;

            /**
             * Concludes the over-arching set operation, passing to a Javascript function
             * capable of handling such an event the number of data items processed,
             * as well as the error spawned by the operation, if any.

             * @param e		the Exception responsible for concluding the over-arching set operation
             */
            Action<Exception> completeSet = delegate(Exception e)
            {
                var argArray = (e == null ? new Object[] { processedItemCount } : new Object[] { processedItemCount, e });
                complete(operationID, argArray);
            };

            /**
            * Performs a set operation using the data contained in the member objects of
            * {@code dataArraySO} in the Isolated Storage facility specified in {@code optionsObj}.
            */
            Action set = delegate()
            {
               /**
                * Retrives the write-operation dictating datum present in either a ScriptObject
                * representation of a data item or {@code optionsObj} keyed by a given String.

                * @param dataItemSO        a ScriptObject containing identifying, payload, and
                *                          (optionally) operation-dictating data of a data item
                * @param optionKey         a String which keys a value in {@code optionsObj} and possibly
                *                          {@code dataItemSO} that keys data to be used to help dictate
                *                          a write operation on the data item represented by {@code dataItemSO}
                * @return                  the Object in {@code dataItemSO} (or {@code optionsSO if no such
                *                          Object exists in the former) keyed by {@code optionKey}
                */
                Func<ScriptObject, String, Object> getWriteOptionValue = delegate(ScriptObject dataItemSO, String optionKey)
                {
                    Object variableValue = dataItemSO.GetProperty(optionKey);
                    return (variableValue != null ? variableValue : optionsSO.GetProperty(optionKey));
                };

               /**
                * Collects the set of data that specifies the subtleties of, and dictates a write operation.

                * @param dataItemSO       a ScriptObject containing identifying, payload, and
                *                         (optionally) operation-dictating data of a data item
                * @return                 a Dictionary<String, Object> containing the data in {@code dataItemSO} and {@code optionsSO}
                *                         (with data in the former superceding data which is identically keyed in the latter) that collectively
                *                         specify the subtleties of, and dictates the write operation for the data item represented by {@code dataItemSO}
                */
                Func<ScriptObject, Dictionary<String, Object>> getWriteOptions = delegate(ScriptObject dataItemSO)
                {
                    Dictionary<String, Object> writeOptionsDic = new Dictionary<String, Object>(5);
                    writeOptionsDic["writeOnlyIfAbsent"] = getWriteOptionValue(dataItemSO, "writeOnlyIfAbsent");
                    writeOptionsDic["dataFormat"] = getWriteOptionValue(dataItemSO, "dataFormat");
                    writeOptionsDic["dataEncoding"] = getWriteOptionValue(dataItemSO, "dataEncoding");
                    writeOptionsDic["truncateBeforeWrite"] = getWriteOptionValue(dataItemSO, "truncateBeforeWrite");
                    writeOptionsDic["truncatePosition"] = getWriteOptionValue(dataItemSO, "truncatePosition");
                    writeOptionsDic["startPosition"] = getWriteOptionValue(dataItemSO, "startPosition");

                    return writeOptionsDic;
                };

                //Obtain a handle to the Isolated Storage facility with the specified scope, using it as the setting to
                //conduct write operations in the directory specified by optionsSO using the file-identifying,
                //payload, and operation-related data contained in each of the ScriptObjects in dataArraySO
                using (var store = getIsolatedStorageStore((String)optionsSO.GetProperty("storeScope")))
                {
                    String directoryPath = (String)optionsSO.GetProperty("directoryPath");
                    if (!(directoryPath.EndsWith("/") || directoryPath.EndsWith("\\"))) directoryPath += "/";

                    //If there are any missing components in the path to the specified directory, create them
                    if (!store.DirectoryExists(directoryPath)) store.CreateDirectory(directoryPath);

                    //Loop through the ScriptObjects in dataArraySO, using the write-operation related data contained
                    //in each to conduct such an operation using the contained file-identifying and payload data
                    int dataItemCount = (int)(double)dataArraySO.GetProperty("length");
                    for (int i = 0; i < dataItemCount; i++)
                    {
                        ScriptObject currentDataItemSO = (ScriptObject)dataArraySO.GetProperty(i);

                        //Get the data which specifies the nuances of, and dictates execution of this write
                        //operation (this data has either been specifically supplied for this data item,
                        //or was specified for the entire set of data items to be processed
                        Dictionary<String, Object> writeOptionsDic = getWriteOptions(currentDataItemSO);

                        String currentFilePath = directoryPath + currentDataItemSO.GetProperty("key");
                        Object currentValueObject = currentDataItemSO.GetProperty("value");

//.........这里部分代码省略.........
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:101,代码来源:BakedGoods.cs

示例14: isf_removeAll

        /**
         * Conducts an Isolated Storage removal operation on the child (and if
         * specified deeper descendent) files contained in a given directory.

         * @param optionsDic        a ScriptObject containing auxiliary data pertinent to the to-be-conducted operation
         * @param operationID       a String uniquely identifying this storage operation in the
         *                          client-side environment in which it was created
         */
        public void isf_removeAll(ScriptObject optionsSO, String operationID)
        {
            int processedItemCount = 0;

            //Extract data from optionsSO that specify both the nature of the removal operations as well as its target entities
            Boolean isRecursive = (Boolean)optionsSO.GetProperty("recursive");
            Boolean removeDirectories = isRecursive && (Boolean)optionsSO.GetProperty("removeDirectories");
            Boolean removeTargetDirectory = isRecursive && (Boolean)optionsSO.GetProperty("removeTargetDirectory");
            /////

            //Ensure that the directory path specified for this operation has no duplicate seperators and trailing whitespace. This
            //modified path String will be used to test whether each to-be-processed directory is the directory specified in optionsDic
            String standardizedOriginDirectoryPath = Regex.Replace((String)optionsSO.GetProperty("directoryPath"), "(?:/|\\\\)+", "/").Trim();

            //Replace the parameter directoryPath with the standardized one (it will be extracted from optionsDic in functions it is passed to)
            optionsSO.SetProperty("directoryPath", standardizedOriginDirectoryPath);

            /**
             * Concludes the over-arching removeAll operation, passing to a Javascript function capable
             * of handling such an event the number of file system entities deleted.

             * @param e		the Exception responsible for concluding the over-arching removeAll operation
             */
            Action<Exception> completeRemoveAll = delegate(Exception e)
            {
                Object[] argArray = (e == null ? new Object[] { processedItemCount } : new Object[] { processedItemCount, e });
                complete(operationID, argArray);
            };

            /**
             * Determines (based on data in {@code optionsSO}) whether a given directory can be deleted.

             * @param directoryPath     a String of the path to a directory
             */
            Func<String, Boolean> canRemoveDirectory = delegate(String directoryPath){
                Boolean isTargetDirectory = directoryPath.Equals(standardizedOriginDirectoryPath);
                return (isTargetDirectory && removeTargetDirectory || !isTargetDirectory && removeDirectories);
            };

            /**
             * Deletes a file system entity from Isolated Storage.

             * @param store             an IsolatedStorageFile manifestation of the facility which contains the entity to be deleted
             * @param directoryPath     a String of the path to the directory containing the entity to be deleted
             * @param entityName        a String of the name of the file system entity to be deleted
             */
            Action<IsolatedStorageFile, String, String> remove = delegate(IsolatedStorageFile store, String directoryPath, String entityName)
            {
                String storeEntityPathName = directoryPath + entityName;

                if (store.DirectoryExists(storeEntityPathName))
                    store.DeleteDirectory(storeEntityPathName);
                else
                    store.DeleteFile(storeEntityPathName);

                processedItemCount++;
            };

            /**
             * Deletes an Isolated Storage facility.
             */
            Action clearStore = delegate()
            {
                //Obtain a handle to the Isolated Storage facility with the specified scope and remove it
                using (var store = getIsolatedStorageStore((String)optionsSO.GetProperty("storeScope")))
                    store.Remove();
                /////

                completeRemoveAll(null);
            };

            Boolean isClearStoreRequest = (removeDirectories && standardizedOriginDirectoryPath.Equals("/"));

            if (isClearStoreRequest)
               clearStore();
            else
                isf_getOrRemoveAll(optionsSO, canRemoveDirectory, remove, completeRemoveAll);
        }
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:86,代码来源:BakedGoods.cs

示例15: isf_getAll

        /**
         * Conducts an Isolated Storage retrieval operation on the child (and if
         * specified deeper descendent) files contained in a given directory.

         * @param optionsSO         a ScriptObject containing auxiliary data pertinent to the to-be-conducted operation
         * @param operationID       a String uniquely identifying this storage operation in the
         *                          client-side environment in which it was created
         */
        public void isf_getAll(ScriptObject optionsSO, String operationID)
        {
            //Will contain Dictionaries each consisting of a String of the
            //path to a file and an Object representing or containing its data.
            List<Dictionary<String, Object>> dataDicList = new List<Dictionary<String, Object>>();

            int processedItemCount = 0;

            String dataFormat = (String)optionsSO.GetProperty("dataFormat");
            String dataEncoding = (String)optionsSO.GetProperty("dataEncoding");

            /**
             * Concludes the over-arching getAll operation, passing to a Javascript function capable of handling
             * such an event the number of files read as well as the data resulting from the operation.

             *  @param e        the Exception responsible for concluding the over-arching getAll operation
             */
            Action<Exception> completeGetAll = delegate(Exception e)
            {
                Object[] argArray = (e == null ? new Object[] { processedItemCount, dataDicList }
                                               : new Object[] { processedItemCount, dataDicList, e });
                complete(operationID, argArray);
            };

            /**
             * Reads the contents of a file in Isolated Storage and creates
             * an element in dataDicList consisting of the file's name and data.

             * @param store             an IsolatedStorageFile manifestation of the facility which contains the file to be read
             * @param directoryPath     a String of the path to the directory containing the file identified to be read
             * @param fileName          a String of the name of the file to be read
             */
            Action<IsolatedStorageFile, String, String> get = delegate(IsolatedStorageFile store, String directoryPath, String fileName)
            {
                String filePath = directoryPath + fileName;

                Object fileDataObject = readFile(store, filePath, dataFormat, dataEncoding);
                dataDicList.Add(new Dictionary<String, Object> { { "key", filePath }, { "value", fileDataObject } });
                processedItemCount++;
            };

            isf_getOrRemoveAll(optionsSO, null, get, completeGetAll);
        }
开发者ID:klawson88,项目名称:Baked-Goods,代码行数:51,代码来源:BakedGoods.cs


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