本文整理汇总了TypeScript中@microsoft/applicationinsights-core-js.CoreUtils.isNullOrUndefined方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreUtils.isNullOrUndefined方法的具体用法?TypeScript CoreUtils.isNullOrUndefined怎么用?TypeScript CoreUtils.isNullOrUndefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@microsoft/applicationinsights-core-js.CoreUtils
的用法示例。
在下文中一共展示了CoreUtils.isNullOrUndefined方法的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);
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}