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


TypeScript sp-core-library.Text類代碼示例

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


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

示例1: ensureSearchQueryParameter

	/**************************************************************************************************
	 * Recursively executes the specified search query using batches of 500 results until all results are fetched
	 * @param queryParameters : The search query parameters following the "/_api/search/query?" part
	 * @param parameterName : The name of the parameter that needs to be ensured
	 * @param parameterValue : The value of the parameter that needs to be ensured
	 **************************************************************************************************/
	private ensureSearchQueryParameter(queryParameters: string, parameterName: string, parameterValue: any): string {
		if(parameterValue) {
			let strParameter = Text.format("{0}={1}", parameterName, parameterValue);
			queryParameters = queryParameters.replace(new RegExp('StartRow=\\d*', 'gi'), strParameter);

			if(queryParameters.toLowerCase().indexOf(parameterName) < 0) {
				queryParameters += ('&' + strParameter);
			}
		}
		return queryParameters;
	}
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例2: getTenantPropertyValue

    /**
     * Get the value of a tenant property bag property
     * @param key the property bag key
     */
    public async getTenantPropertyValue(key: string): Promise<any> {
        // Get settings from tenant properties
        const url = Text.format("{0}/_api/web/GetStorageEntity('{1}')", this._context.pageContext.site.absoluteUrl, key);

        try {
            const response = await this._context.spHttpClient.get(url, SPHttpClient.configurations.v1);            
            const data = await response.json();
                
            if (response.ok) {
                return data.Value;
            } else {

                // Expected response for errors
                const errorDetails = data["ExceptionMessage"];
                throw(errorDetails);
            }

        } catch (error) {
            Logger.write(Text.format("[TenantDataProvider_getTenantProperty]: Error: {0}", error));
        }    
    }
開發者ID:AdrianDiaz81,項目名稱:sp-dev-fx-extensions,代碼行數:25,代碼來源:TenantDataProvider.ts

示例3: AND

		return new Promise<string[]>((resolve,reject) => {
			let queryProperties = Text.format("querytext='SPSiteUrl:{0} AND (contentclass:STS_Site OR contentclass:STS_Web)'&selectproperties='Path'&trimduplicates=false&rowLimit=500&Properties='EnableDynamicGroups:true'", siteUrl);

			this.getSearchResultsRecursive(siteUrl, queryProperties)
				.then((results: any) => {
					resolve(this.getPathsFromResults(results));
				})
				.catch((error) => {
					reject(error);
				}
			);
		});	
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例4: generateUserFilter

    /*************************************************************************************************
	 * Generates a valid CAML filter string based on the specified user filter
	 * @param filter : The user filter that needs to be formatted into a CAML filter string
	 *************************************************************************************************/
    private static generateUserFilter(filter:IQueryFilter): string
    {
        let filterOutput = '';
        let filterUsers = filter.value as IPersonaProps[];

        if(filter.me) {
            filterOutput = Text.format("<Eq><FieldRef Name='{0}' /><Value Type='Integer'><UserID /></Value></Eq>", filter.field.internalName);
        }
        else if(isEmpty(filter.value)) {
            return '';
        }
        else if (filter.operator == QueryFilterOperator.ContainsAny || filterUsers == null)
        {
            let values = filterUsers != null ? filterUsers.map(x => Text.format("<Value Type='Integer'>{0}</Value>", x.optionalText)).join('') : '';
            filterOutput = Text.format("<In><FieldRef Name='{0}' LookupId='TRUE' /><Values>{1}</Values></In>", filter.field.internalName, values);
        }
        else if (filter.operator == QueryFilterOperator.ContainsAll)
        {
            let userFilters: IQueryFilter[] = [];

            for(let user of filterUsers) {
                let userValue:IPersonaProps[] = [ user ];

                let userFilter:IQueryFilter = {
                    index: null,
                    field: filter.field,
                    value: userValue,
                    join: QueryFilterJoin.And,
                    operator: QueryFilterOperator.ContainsAny
                };
                userFilters.push(userFilter);
            }

            filterOutput = this.generateFilters(userFilters);
        }

        return filterOutput;
    }
開發者ID:,項目名稱:,代碼行數:42,代碼來源:

示例5: reject

		return new Promise<any>((resolve,reject) => {
			let selectProps = selectProperties ? selectProperties.join(',') : '';
			let order = orderBy ? orderBy : 'InternalName';
			let endpoint = Text.format("{0}/_api/web/lists(guid'{1}')/Fields?$select={2}&$orderby={3}", webUrl, listId, selectProps, order);
			this.spHttpClient.get(endpoint, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => {
				if(response.ok) {
					resolve(response.json());
				}
				else {
					reject(response);
				}
			})
			.catch((error) => { reject(error); }); 
        });
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例6: resolve

		return new Promise<any>((resolve,reject) => {
			
			queryParameters = this.ensureSearchQueryParameter(queryParameters, 'StartRow', startRow);
			let endpoint = Text.format("{0}/_api/search/query?{1}", webUrl, queryParameters);

			this.spHttpClient.get(endpoint, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => {
				if(response.ok) {
					resolve(response.json());
				}
				else {
					reject(response.statusText);
				}
			})
			.catch((error) => { reject(error); }); 
		});	
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例7: and

		return new Promise<IListTitle[]>((resolve,reject) => {
			let endpoint = Text.format("{0}/_api/web/lists?$select=Id,Title&$filter=(IsPrivate eq false) and (IsCatalog eq false) and (Hidden eq false)", webUrl);
			this.spHttpClient.get(endpoint, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => {
				if(response.ok) {
					response.json().then((data: any) => {
						let listTitles:IListTitle[] = data.value.map((list) => { return { id: list.Id, title: list.Title }; });
						resolve(listTitles.sort((a,b) => { return Number(a.title > b.title); }));
					})
					.catch((error) => { reject(error); });
				}
				else {
					reject(response);
				}
			})
			.catch((error) => { reject(error); }); 
        });
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例8:

		return new Promise<any>((resolve,reject) => {
			let endpoint = Text.format("{0}/_api/web/lists(guid'{1}')/GetItems?$expand=FieldValuesAsText,FieldValuesAsHtml", webUrl, listId);
			let data:any = { 
				query : { 
					__metadata: { type: "SP.CamlQuery" }, 
					ViewXml: camlQuery
				}
			};
			let options: ISPHttpClientOptions = { headers: { 'odata-version': '3.0' }, body: JSON.stringify(data) };

			this.spHttpClient.post(endpoint, SPHttpClient.configurations.v1, options)
				.then((postResponse: SPHttpClientResponse) => {
					if(postResponse.ok) {
						resolve(postResponse.json());
					}
					else {
						reject(postResponse);
					}
				})
				.catch((error) => { 
					reject(error); 
				}); 
        });
開發者ID:,項目名稱:,代碼行數:23,代碼來源:


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