当前位置: 首页>>代码示例>>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;未经允许,请勿转载。