當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript applicationinsights-core-js.CoreUtils類代碼示例

本文整理匯總了TypeScript中@microsoft/applicationinsights-core-js.CoreUtils的典型用法代碼示例。如果您正苦於以下問題:TypeScript CoreUtils類的具體用法?TypeScript CoreUtils怎麽用?TypeScript CoreUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CoreUtils類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: DetachEvent

 public static DetachEvent(obj, eventNameWithoutOn, handlerRef) {
     if (!CoreUtils.isNullOrUndefined(obj)) {
         if (!CoreUtils.isNullOrUndefined(obj.detachEvent)) {
             obj.detachEvent("on" + eventNameWithoutOn, handlerRef);
         }
         else {
             if (!CoreUtils.isNullOrUndefined(obj.removeEventListener)) {
                 obj.removeEventListener(eventNameWithoutOn, handlerRef, false);
             }
         }
     }
 }
開發者ID:Microsoft,項目名稱:ApplicationInsights-JS,代碼行數:12,代碼來源:ajaxUtils.ts

示例2: getConfig

    public static getConfig(config: IConfiguration & IConfig, field: string, identifier?: string, defaultValue: number | string | boolean = false): number | string | boolean {
        let configValue;
        if (identifier && config.extensionConfig && config.extensionConfig[identifier] && !CoreUtils.isNullOrUndefined(config.extensionConfig[identifier][field])) {
            configValue = config.extensionConfig[identifier][field];
        } else {
            configValue = config[field];
        }

        return !CoreUtils.isNullOrUndefined(configValue) ? configValue : defaultValue;
    }
開發者ID:Microsoft,項目名稱:ApplicationInsights-JS,代碼行數:10,代碼來源:IConfig.ts

示例3: AttachEvent

    ///<summary>Binds the specified function to an event, so that the function gets called whenever the event fires on the object</summary>
    ///<param name="obj">Object to which </param>
    ///<param name="eventNameWithoutOn">String that specifies any of the standard DHTML Events without "on" prefix</param>
    ///<param name="handlerRef">Pointer that specifies the function to call when event fires</param>
    ///<returns>True if the function was bound successfully to the event, otherwise false</returns>
    public static AttachEvent(obj, eventNameWithoutOn, handlerRef) {
        var result = false;
        if (!CoreUtils.isNullOrUndefined(obj)) {
            if (!CoreUtils.isNullOrUndefined(obj.attachEvent)) {
                // IE before version 9                    
                obj.attachEvent("on" + eventNameWithoutOn, handlerRef);
                result = true;
            }
            else {
                if (!CoreUtils.isNullOrUndefined(obj.addEventListener)) {
                    // all browsers except IE before version 9
                    obj.addEventListener(eventNameWithoutOn, handlerRef, false);
                    result = true;
                }
            }
        }

        return result;
    }
開發者ID:Microsoft,項目名稱:ApplicationInsights-JS,代碼行數:24,代碼來源:ajaxUtils.ts

示例4: Error

    public static create<T>(item: T,
        baseType: string,
        envelopeName: string,
        logger: IDiagnosticLogger,
        customProperties?: { [key: string]: any },
        systemProperties?: { [key: string]: any }): ITelemetryItem {

        envelopeName = DataSanitizer.sanitizeString(logger, envelopeName) || Util.NotSpecified;

        if (CoreUtils.isNullOrUndefined(item) ||
            CoreUtils.isNullOrUndefined(baseType) ||
            CoreUtils.isNullOrUndefined(envelopeName)) {
                throw Error("Input doesn't contain all required fields");
        }

        let telemetryItem: ITelemetryItem = {
            name: envelopeName,
            time: new Date().toISOString(),
            iKey: "", // this will be set in TelemetryContext
            ext: systemProperties ? systemProperties : {}, // part A
            tags: [],
            data: {
            },
            baseType: baseType,
            baseData: item // Part B
        };

        // Part C
        if (!CoreUtils.isNullOrUndefined(customProperties)) {
            for (var prop in customProperties) {
                if (customProperties.hasOwnProperty(prop)) {
                    telemetryItem.data[prop] = customProperties[prop];
                }
            }
        }

        return telemetryItem;
    }
開發者ID:Microsoft,項目名稱:ApplicationInsights-JS,代碼行數:38,代碼來源:TelemetryItemCreator.ts

示例5: GetLength

    public static GetLength(strObject) {
        var res = 0;
        if (!CoreUtils.isNullOrUndefined(strObject)) {
            var stringified = "";
            try {
                stringified = strObject.toString();
            } catch (ex) {
                // some troubles with complex object
            }

            res = stringified.length;
            res = isNaN(res) ? 0 : res;
        }

        return res;
    }
開發者ID:Microsoft,項目名稱:ApplicationInsights-JS,代碼行數:16,代碼來源:ajaxUtils.ts


注:本文中的@microsoft/applicationinsights-core-js.CoreUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。