本文整理匯總了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);
}
}
}
}
示例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;
}