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


C# ScriptObject.SetProperty方法代码示例

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


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

示例1: 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

示例2: SetMember

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


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