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