示例#1
0
        public async Task EnableWebFeatureAlreadyActivatedAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                var id = new Guid("fa6a1bcc-fb4b-446b-8460-f4de5f7411d5"); // SharePoint Viewers - Web Scoped

                if (web.Features.AsRequested().Any(o => o.DefinitionId == id))
                {
                    // Already Activated
                }
                else
                {
                    // Not Activated lets activate
                    IFeature feature = await web.Features.EnableAsync(id);

                    Assert.IsNotNull(feature);
                    Assert.IsNotNull(feature.DefinitionId);
                    Assert.IsTrue(feature.DefinitionId != Guid.Empty);
                }

                await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(async() =>
                {
                    await web.Features.EnableAsync(id);
                });

                // Deactivate again
                await web.Features.DisableAsync(id);
            }
        }
        private async Task <List <FieldData> > GetFieldsFromCache(IFile targetFile, IWeb targetWeb, ISite targetSite)
        {
            // Define the cache key
            var fieldsCacheKey = $"Fields|{targetSite.Id}|{targetWeb.Id}|{targetFile.ListId}";

            List <FieldData> result = null;

            if (!this.memoryCache.TryGetValue(fieldsCacheKey, out result))
            {
                // Get the fields of the current list
                var targetList = await targetFile.PnPContext.Web.Lists.GetByIdAsync(targetFile.ListId,
                                                                                    l => l.Id,
                                                                                    l => l.Fields.QueryProperties(f => f.Id, f => f.StaticName, f => f.TypeAsString, f => f.Hidden)
                                                                                    ).ConfigureAwait(false);

                // Exclude hidden and built-in fields
                result = targetList.Fields.AsRequested()
                         .Where(f => !f.Hidden && !BuiltInFields.Contains(f.StaticName)).Select(f => new FieldData
                {
                    Id   = f.Id,
                    Name = f.StaticName,
                    Type = f.TypeAsString
                }).ToList();

                // Store the list of fields in cache for future use
                this.memoryCache.Set(fieldsCacheKey, result);
            }

            return(result);
        }
        private async Task GenerateTargetCanvasControlsAsync(IWeb targetWeb, IPage targetPage, MappingProviderOutput mappingOutput, Guid taskId)
        {
            // Prepare global tokens
            var globalTokens = await PrepareGlobalTokensAsync(targetWeb).ConfigureAwait(false);

            // Get the list of components available in the current site
            var componentsToAdd = await GetClientSideComponentsAsync(targetPage).ConfigureAwait(false);

            int sectionOrder = 0;

            foreach (var section in mappingOutput.TargetPage.Sections)
            {
                section.Order = sectionOrder;
                targetPage.AddSection(section.CanvasTemplate, sectionOrder);
                var targetSection = targetPage.Sections[sectionOrder];
                sectionOrder++;

                int columnOrder  = 0;
                int controlOrder = 0;
                foreach (var column in section.Columns)
                {
                    var targetColumn = targetSection.Columns[columnOrder];
                    columnOrder++;
                    controlOrder++;

                    foreach (var control in column.Controls)
                    {
                        GenerateTargetCanvasControl(targetPage, componentsToAdd, controlOrder, targetColumn, control, globalTokens, taskId);
                    }
                }
            }
        }
示例#4
0
        public async Task EnableDisableWebFeatureActivateBatchAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                var id = new Guid("fa6a1bcc-fb4b-446b-8460-f4de5f7411d5"); // SharePoint Viewers - Web Scoped

                if (web.Features.AsRequested().Any(o => o.DefinitionId == id))
                {
                    // Ensure disabled
                    web.Features.Disable(id);
                }

                IFeature feature = await web.Features.EnableBatchAsync(id);

                await context.ExecuteAsync(); //Trigger Batch

                Assert.IsNotNull(feature);
                Assert.IsNotNull(feature.DefinitionId);
                Assert.IsTrue(feature.DefinitionId != Guid.Empty);

                await web.Features.DisableBatchAsync(id);

                await context.ExecuteAsync(); //Trigger Batch

                Assert.IsTrue(!web.Features.AsRequested().Any(o => o.DefinitionId == id));
            }
        }
        static void Main(string[] args)
        {
            IWeb       web        = null;
            WebAdapter webAdapter = new WebAdapter(web);

            webAdapter.Send();
        }
 /// <summary>
 /// The Web Search API lets you send a search query to Bing and get back search
 /// results that include links to webpages, images, and more.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='query'>
 /// The user's search query term. The term may not be empty. The term may
 /// contain Bing Advanced Operators. For example, to limit results to a
 /// specific domain, use the site: operator.
 /// </param>
 /// <param name='acceptLanguage'>
 /// A comma-delimited list of one or more languages to use for user interface
 /// strings. The list is in decreasing order of preference. For additional
 /// information, including expected format, see
 /// [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
 /// header and the setLang query parameter are mutually exclusive; do not
 /// specify both. If you set this header, you must also specify the cc query
 /// parameter. Bing will use the first supported language it finds from the
 /// list, and combine that language with the cc parameter value to determine
 /// the market to return results for. If the list does not include a supported
 /// language, Bing will find the closest language and market that supports the
 /// request, and may use an aggregated or default market for the results
 /// instead of a specified one. You should use this header and the cc query
 /// parameter only if you specify multiple languages; otherwise, you should use
 /// the mkt and setLang query parameters. A user interface string is a string
 /// that's used as a label in a user interface. There are very few user
 /// interface strings in the JSON response objects. Any links in the response
 /// objects to Bing.com properties will apply the specified language.
 /// </param>
 /// <param name='pragma'>
 /// By default, Bing returns cached content, if available. To prevent Bing from
 /// returning cached content, set the Pragma header to no-cache (for example,
 /// Pragma: no-cache).
 /// </param>
 /// <param name='userAgent'>
 /// The user agent originating the request. Bing uses the user agent to provide
 /// mobile users with an optimized experience. Although optional, you are
 /// strongly encouraged to always specify this header. The user-agent should be
 /// the same string that any commonly used browser would send. For information
 /// about user agents, see [RFC
 /// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
 /// </param>
 /// <param name='clientId'>
 /// Bing uses this header to provide users with consistent behavior across Bing
 /// API calls. Bing often flights new features and improvements, and it uses
 /// the client ID as a key for assigning traffic on different flights. If you
 /// do not use the same client ID for a user across multiple requests, then
 /// Bing may assign the user to multiple conflicting flights. Being assigned to
 /// multiple conflicting flights can lead to an inconsistent user experience.
 /// For example, if the second request has a different flight assignment than
 /// the first, the experience may be unexpected. Also, Bing can use the client
 /// ID to tailor web results to that client ID’s search history, providing a
 /// richer experience for the user. Bing also uses this header to help improve
 /// result rankings by analyzing the activity generated by a client ID. The
 /// relevance improvements help with better quality of results delivered by
 /// Bing APIs and in turn enables higher click-through rates for the API
 /// consumer. IMPORTANT: Although optional, you should consider this header
 /// required. Persisting the client ID across multiple requests for the same
 /// end user and device combination enables 1) the API consumer to receive a
 /// consistent user experience, and 2) higher click-through rates via better
 /// quality of results from the Bing APIs. Each user that uses your application
 /// on the device must have a unique, Bing generated client ID. If you do not
 /// include this header in the request, Bing generates an ID and returns it in
 /// the X-MSEdge-ClientID response header. The only time that you should NOT
 /// include this header in a request is the first time the user uses your app
 /// on that device. Use the client ID for each Bing API request that your app
 /// makes for this user on the device. Persist the client ID. To persist the ID
 /// in a browser app, use a persistent HTTP cookie to ensure the ID is used
 /// across all sessions. Do not use a session cookie. For other apps such as
 /// mobile apps, use the device's persistent storage to persist the ID. The
 /// next time the user uses your app on that device, get the client ID that you
 /// persisted. Bing responses may or may not include this header. If the
 /// response includes this header, capture the client ID and use it for all
 /// subsequent Bing requests for the user on that device. If you include the
 /// X-MSEdge-ClientID, you must not include cookies in the request.
 /// </param>
 /// <param name='clientIp'>
 /// The IPv4 or IPv6 address of the client device. The IP address is used to
 /// discover the user's location. Bing uses the location information to
 /// determine safe search behavior. Although optional, you are encouraged to
 /// always specify this header and the X-Search-Location header. Do not
 /// obfuscate the address (for example, by changing the last octet to 0).
 /// Obfuscating the address results in the location not being anywhere near the
 /// device's actual location, which may result in Bing serving erroneous
 /// results.
 /// </param>
 /// <param name='location'>
 /// A semicolon-delimited list of key/value pairs that describe the client's
 /// geographical location. Bing uses the location information to determine safe
 /// search behavior and to return relevant local content. Specify the key/value
 /// pair as &lt;key&gt;:&lt;value&gt;. The following are the keys that you use
 /// to specify the user's location. lat (required): The latitude of the
 /// client's location, in degrees. The latitude must be greater than or equal
 /// to -90.0 and less than or equal to +90.0. Negative values indicate southern
 /// latitudes and positive values indicate northern latitudes. long (required):
 /// The longitude of the client's location, in degrees. The longitude must be
 /// greater than or equal to -180.0 and less than or equal to +180.0. Negative
 /// values indicate western longitudes and positive values indicate eastern
 /// longitudes. re (required): The radius, in meters, which specifies the
 /// horizontal accuracy of the coordinates. Pass the value returned by the
 /// device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m
 /// for cell tower triangulation, and 18,000m for reverse IP lookup. ts
 /// (optional): The UTC UNIX timestamp of when the client was at the location.
 /// (The UNIX timestamp is the number of seconds since January 1, 1970.) head
 /// (optional): The client's relative heading or direction of travel. Specify
 /// the direction of travel as degrees from 0 through 360, counting clockwise
 /// relative to true north. Specify this key only if the sp key is nonzero. sp
 /// (optional): The horizontal velocity (speed), in meters per second, that the
 /// client device is traveling. alt (optional): The altitude of the client
 /// device, in meters. are (optional): The radius, in meters, that specifies
 /// the vertical accuracy of the coordinates. Specify this key only if you
 /// specify the alt key. Although many of the keys are optional, the more
 /// information that you provide, the more accurate the location results are.
 /// Although optional, you are encouraged to always specify the user's
 /// geographical location. Providing the location is especially important if
 /// the client's IP address does not accurately reflect the user's physical
 /// location (for example, if the client uses VPN). For optimal results, you
 /// should include this header and the X-MSEdge-ClientIP header, but at a
 /// minimum, you should include this header.
 /// </param>
 /// <param name='answerCount'>
 /// The number of answers that you want the response to include. The answers
 /// that Bing returns are based on ranking. For example, if Bing returns
 /// webpages, images, videos, and relatedSearches for a request and you set
 /// this parameter to two (2), the response includes webpages and images.If you
 /// included the responseFilter query parameter in the same request and set it
 /// to webpages and news, the response would include only webpages.
 /// </param>
 /// <param name='countryCode'>
 /// A 2-character country code of the country where the results come from. This
 /// API supports only the United States market. If you specify this query
 /// parameter, it must be set to us. If you set this parameter, you must also
 /// specify the Accept-Language header. Bing uses the first supported language
 /// it finds from the languages list, and combine that language with the
 /// country code that you specify to determine the market to return results
 /// for. If the languages list does not include a supported language, Bing
 /// finds the closest language and market that supports the request, or it may
 /// use an aggregated or default market for the results instead of a specified
 /// one. You should use this query parameter and the Accept-Language query
 /// parameter only if you specify multiple languages; otherwise, you should use
 /// the mkt and setLang query parameters. This parameter and the mkt query
 /// parameter are mutually exclusive—do not specify both.
 /// </param>
 /// <param name='count'>
 /// The number of search results to return in the response. The default is 10
 /// and the maximum value is 50. The actual number delivered may be less than
 /// requested.Use this parameter along with the offset parameter to page
 /// results.For example, if your user interface displays 10 search results per
 /// page, set count to 10 and offset to 0 to get the first page of results. For
 /// each subsequent page, increment offset by 10 (for example, 0, 10, 20). It
 /// is possible for multiple pages to include some overlap in results.
 /// </param>
 /// <param name='freshness'>
 /// Filter search results by the following age values: Day—Return webpages that
 /// Bing discovered within the last 24 hours. Week—Return webpages that Bing
 /// discovered within the last 7 days. Month—Return webpages that discovered
 /// within the last 30 days. This filter applies only to webpage results and
 /// not to the other results such as news and images. Possible values include:
 /// 'Day', 'Week', 'Month'
 /// </param>
 /// <param name='market'>
 /// The market where the results come from. Typically, mkt is the country where
 /// the user is making the request from. However, it could be a different
 /// country if the user is not located in a country where Bing delivers
 /// results. The market must be in the form &lt;language code&gt;-&lt;country
 /// code&gt;. For example, en-US. The string is case insensitive. If known, you
 /// are encouraged to always specify the market. Specifying the market helps
 /// Bing route the request and return an appropriate and optimal response. If
 /// you specify a market that is not listed in Market Codes, Bing uses a best
 /// fit market code based on an internal mapping that is subject to change.
 /// This parameter and the cc query parameter are mutually exclusive—do not
 /// specify both.
 /// </param>
 /// <param name='offset'>
 /// The zero-based offset that indicates the number of search results to skip
 /// before returning results. The default is 0. The offset should be less than
 /// (totalEstimatedMatches - count). Use this parameter along with the count
 /// parameter to page results. For example, if your user interface displays 10
 /// search results per page, set count to 10 and offset to 0 to get the first
 /// page of results. For each subsequent page, increment offset by 10 (for
 /// example, 0, 10, 20). it is possible for multiple pages to include some
 /// overlap in results.
 /// </param>
 /// <param name='promote'>
 /// A comma-delimited list of answers that you want the response to include
 /// regardless of their ranking. For example, if you set answerCount) to two
 /// (2) so Bing returns the top two ranked answers, but you also want the
 /// response to include news, you'd set promote to news. If the top ranked
 /// answers are webpages, images, videos, and relatedSearches, the response
 /// includes webpages and images because news is not a ranked answer. But if
 /// you set promote to video, Bing would promote the video answer into the
 /// response and return webpages, images, and videos. The answers that you want
 /// to promote do not count against the answerCount limit. For example, if the
 /// ranked answers are news, images, and videos, and you set answerCount to 1
 /// and promote to news, the response contains news and images. Or, if the
 /// ranked answers are videos, images, and news, the response contains videos
 /// and news. Possible values are Computation, Images, News, RelatedSearches,
 /// SpellSuggestions, TimeZone, Videos, Webpages. Use only if you specify
 /// answerCount.
 /// </param>
 /// <param name='responseFilter'>
 /// A comma-delimited list of answers to include in the response. If you do not
 /// specify this parameter, the response includes all search answers for which
 /// there's relevant data. Possible filter values are Computation, Images,
 /// News, RelatedSearches, SpellSuggestions, TimeZone, Videos, Webpages.
 /// Although you may use this filter to get a single answer, you should instead
 /// use the answer-specific endpoint in order to get richer results. For
 /// example, to receive only images, send the request to one of the Image
 /// Search API endpoints. The RelatedSearches and SpellSuggestions answers do
 /// not support a separate endpoint like the Image Search API does (only the
 /// Web Search API returns them). To include answers that would otherwise be
 /// excluded because of ranking, see the promote query parameter.
 /// </param>
 /// <param name='safeSearch'>
 /// A filter used to filter adult content. Off: Return webpages with adult
 /// text, images, or videos. Moderate: Return webpages with adult text, but not
 /// adult images or videos. Strict: Do not return webpages with adult text,
 /// images, or videos. The default is Moderate. If the request comes from a
 /// market that Bing's adult policy requires that safeSearch is set to Strict,
 /// Bing ignores the safeSearch value and uses Strict. If you use the site:
 /// query operator, there is the chance that the response may contain adult
 /// content regardless of what the safeSearch query parameter is set to. Use
 /// site: only if you are aware of the content on the site and your scenario
 /// supports the possibility of adult content. Possible values include: 'Off',
 /// 'Moderate', 'Strict'
 /// </param>
 /// <param name='setLang'>
 /// The language to use for user interface strings. Specify the language using
 /// the ISO 639-1 2-letter language code. For example, the language code for
 /// English is EN. The default is EN (English). Although optional, you should
 /// always specify the language. Typically, you set setLang to the same
 /// language specified by mkt unless the user wants the user interface strings
 /// displayed in a different language. This parameter and the Accept-Language
 /// header are mutually exclusive; do not specify both. A user interface string
 /// is a string that's used as a label in a user interface. There are few user
 /// interface strings in the JSON response objects. Also, any links to Bing.com
 /// properties in the response objects apply the specified language.
 /// </param>
 /// <param name='textDecorations'>
 /// A Boolean value that determines whether display strings should contain
 /// decoration markers such as hit highlighting characters. If true, the
 /// strings may include markers. The default is false. To specify whether to
 /// use Unicode characters or HTML tags as the markers, see the textFormat
 /// query parameter.
 /// </param>
 /// <param name='textFormat'>
 /// The type of markers to use for text decorations (see the textDecorations
 /// query parameter). Possible values are Raw—Use Unicode characters to mark
 /// content that needs special formatting. The Unicode characters are in the
 /// range E000 through E019. For example, Bing uses E000 and E001 to mark the
 /// beginning and end of query terms for hit highlighting. HTML—Use HTML tags
 /// to mark content that needs special formatting. For example, use &lt;b&gt;
 /// tags to highlight query terms in display strings. The default is Raw. For
 /// display strings that contain escapable HTML characters such as &lt;, &gt;,
 /// and &amp;, if textFormat is set to HTML, Bing escapes the characters as
 /// appropriate (for example, &lt; is escaped to &amp;lt;). Possible values
 /// include: 'Raw', 'Html'
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SearchResponse> SearchAsync(this IWeb operations, string query, string acceptLanguage = default(string), string pragma = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), int?answerCount = default(int?), string countryCode = default(string), int?count = default(int?), string freshness = default(string), string market = "en-us", int?offset = default(int?), IList <string> promote = default(IList <string>), IList <string> responseFilter = default(IList <string>), string safeSearch = default(string), string setLang = default(string), bool?textDecorations = default(bool?), string textFormat = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.SearchWithHttpMessagesAsync(query, acceptLanguage, pragma, userAgent, clientId, clientIp, location, answerCount, countryCode, count, freshness, market, offset, promote, responseFilter, safeSearch, setLang, textDecorations, textFormat, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#7
0
        public async Task AddWebFieldLookupSpecificTest()
        {
            // CAUTION : Add Lookup field DOES NOT SUPPORT specifying some options at creation (e.g. Group, Hidden, ...)
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb currentWeb = await context.Web.GetAsync();

                IList  documents  = currentWeb.Lists.GetByTitle("Documents", l => l.Id);
                IField addedField = await currentWeb.Fields.AddLookupAsync("ADDED FIELD16", new FieldLookupOptions()
                {
                    Required        = true,
                    LookupFieldName = "Title",
                    LookupListId    = documents.Id,
                    LookupWebId     = currentWeb.Id
                });

                // Test the created object
                Assert.IsNotNull(addedField);
                Assert.AreEqual("ADDED FIELD16", addedField.Title);
                Assert.AreEqual(FieldType.Lookup, addedField.FieldTypeKind);
                Assert.AreEqual("Title", addedField.LookupField);
                Assert.AreEqual(documents.Id, Guid.Parse(addedField.LookupList));
                Assert.AreEqual(currentWeb.Id, addedField.LookupWebId);

                await addedField.DeleteAsync();
            }
        }
示例#8
0
        public async Task GetFeaturesWebAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                Assert.IsTrue(web.Features.Length > 0);
            }
        }
示例#9
0
        public WebClient(String nom, String reg, IWeb iweb)
        {
            client      = new HttpClient();
            nomBusqueda = nom;
            regBusqueda = reg;
            this.iweb   = iweb;

            Invocador inv = new Invocador();

            inv.SummonerName = nomBusqueda;
            inv.Region       = reg;
        }
示例#10
0
 /// <summary>
 /// Popuplate the data from IWeb object
 /// </summary>
 /// <param name="webData"></param>
 /// <remarks>
 /// This method only populate the simple type properties.The WebPages will not populate from IWeb
 /// </remarks>
 public void Popuplate(IWeb webData)
 {
     this.DefaultLocale   = webData.DefaultLocale;
     this.Copyright       = string.IsNullOrEmpty(webData.Copyright) ? "" : webData.Copyright;
     this.CssText         = string.IsNullOrEmpty(webData.CssText) ? "" : webData.CssText;
     this.LogoImageUrl    = string.IsNullOrEmpty(webData.LogoImageUrl) ? "" : webData.LogoImageUrl;
     this.DefaultUrl      = string.IsNullOrEmpty(webData.DefaultUrl) ? "" : webData.DefaultUrl;
     this.ShortcutIconUrl = string.IsNullOrEmpty(webData.ShortcutIconUrl) ? "" : webData.ShortcutIconUrl;
     this.Title           = webData.Title;
     this.Description     = webData.Description;
     this.Theme           = webData.Theme;
     //if (includePages && this.Pages != null)
     //this.WebPages = (IEnumerable<IWebPage>)this.Pages;
 }
示例#11
0
        public async Task DisableWebFeatureDoesNotExistAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                var id = new Guid("fa6a1bcc-fb4b-446b-8460-f4de5f700000"); // fake

                await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(async() =>
                {
                    await web.Features.DisableAsync(id);
                });
            }
        }
示例#12
0
        public async Task DisableWebFeatureAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                var id = new Guid("fa6a1bcc-fb4b-446b-8460-f4de5f7411d5"); // SharePoint Viewers - Web Scoped

                // Enable first
                await web.Features.EnableAsync(id);

                await web.Features.DisableAsync(id);

                Assert.IsTrue(!web.Features.AsRequested().Any(o => o.DefinitionId == id));
            }
        }
示例#13
0
        public async Task EnableDisableWebFeatureActivateExceptionsBatchAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                var id = new Guid("fa6a1bcc-fb4b-446b-8460-f4de5f740000"); // Fake

                await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(async() =>
                {
                    await web.Features.EnableBatchAsync(id);
                    await web.Features.EnableBatchAsync(id);
                    await context.ExecuteAsync(); //Trigger Batch
                });
            }
        }
示例#14
0
        public async Task ContentTypesGetTest()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                await context.Web.LoadAsync(p => p.ContentTypes);

                IWeb web = context.Web;

                Assert.IsTrue(web.ContentTypes.Length > 0);

                IContentType contentType = web.ContentTypes.AsRequested().FirstOrDefault(p => p.Name == "Item");
                // Test a string property
                Assert.AreEqual(contentType.Name, "Item");
                // Test a boolean property
                Assert.IsFalse(contentType.Hidden);
            }
        }
        /// <summary>
        /// Prepares global tokens for target environment
        /// </summary>
        /// <returns></returns>
        private async Task <Dictionary <string, string> > PrepareGlobalTokensAsync(IWeb web)
        {
            Dictionary <string, string> globalTokens = new Dictionary <string, string>(5);

            await web.EnsurePropertiesAsync(w => w.Id, w => w.Url, w => w.ServerRelativeUrl).ConfigureAwait(false);

            var site = web.PnPContext.Site;
            await site.EnsurePropertiesAsync(s => s.Id, s => s.RootWeb.QueryProperties(rw => rw.ServerRelativeUrl)).ConfigureAwait(false);

            // Add the fixed properties
            globalTokens.Add("Host", $"{web.Url.Scheme}://{web.Url.DnsSafeHost}");
            globalTokens.Add("Web", web.ServerRelativeUrl.TrimEnd('/'));
            globalTokens.Add("SiteCollection", site.RootWeb.ServerRelativeUrl.TrimEnd('/'));
            globalTokens.Add("WebId", web.Id.ToString());
            globalTokens.Add("SiteId", site.Id.ToString());

            return(globalTokens);
        }
示例#16
0
        public async Task GetWebFieldsTest()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Fields);

                Assert.IsTrue(web.Fields.Length > 0);

                IField field = web.Fields.FirstOrDefault(p => p.InternalName == "Title");
                // Test a string property
                Assert.AreEqual("Title", field.InternalName);
                // Test a boolean property
                Assert.IsFalse(field.Hidden);
                // Test special types
                Assert.AreEqual(FieldType.Text, field.FieldTypeKind);
            }
        }
示例#17
0
        public async Task ContentTypesGetPropertiesTest()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                await context.Web.LoadAsync(p => p.ContentTypes);

                IWeb web = context.Web;
                Assert.IsTrue(web.ContentTypes.Length > 0);

                IContentType contentType = web.ContentTypes.AsRequested().FirstOrDefault(p => p.Name == "Item");
                // Test a string property
                Assert.AreEqual(contentType.Name, "Item");

                //ClientFormCustomFormatter
                Assert.IsTrue(string.IsNullOrEmpty(contentType.ClientFormCustomFormatter));
                Assert.AreEqual(contentType.Description, "Create a new list item.");
                Assert.AreEqual(contentType.DisplayFormTemplateName, "ListForm");
                Assert.AreEqual(contentType.DisplayFormUrl, "");
                Assert.AreEqual(contentType.DocumentTemplate, "");
                Assert.AreEqual(contentType.DocumentTemplateUrl, "");
                Assert.AreEqual(contentType.EditFormTemplateName, "ListForm");
                Assert.IsTrue(string.IsNullOrEmpty(contentType.EditFormUrl));
                Assert.AreEqual(contentType.Group, "List Content Types");
                Assert.AreEqual(contentType.Hidden, false);
                Assert.AreEqual(contentType.JSLink, "");
                Assert.AreEqual(contentType.MobileDisplayFormUrl, "");
                Assert.AreEqual(contentType.MobileEditFormUrl, "");
                Assert.AreEqual(contentType.MobileNewFormUrl, "");
                Assert.AreEqual(contentType.Name, "Item");
                Assert.AreEqual(contentType.NewFormTemplateName, "ListForm");
                Assert.AreEqual(contentType.NewFormUrl, "");
                Assert.AreEqual(contentType.ReadOnly, false);
                Assert.IsTrue(!string.IsNullOrEmpty(contentType.SchemaXml));
                // Testing on site names is not possible as this will fail when the tests are running live again
                //Assert.AreEqual(contentType.Scope, "/sites/pnpcoresdktestgroup");
                Assert.AreEqual(contentType.Sealed, false);
                Assert.AreEqual(contentType.StringId, "0x01");

                // Test a boolean property
                Assert.IsFalse(contentType.Hidden);
            }
        }
示例#18
0
        public async Task EnableWebFeatureAsync()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                IWeb web = await context.Web.GetAsync(p => p.Features);

                var id = new Guid("fa6a1bcc-fb4b-446b-8460-f4de5f7411d5"); // SharePoint Viewers - Web Scoped

                IFeature feature = await web.Features.EnableAsync(id);

                Assert.IsNotNull(feature);
                Assert.IsNotNull(feature.DefinitionId);
                Assert.IsTrue(feature.DefinitionId != Guid.Empty);

                // Ensure the feature is disabled again
                await web.Features.DisableAsync(id);
            }
        }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Web      = new Web(this);
     BaseUri  = "{Endpoint}/bing/v7.0";
     Endpoint = "https://api.cognitive.microsoft.com";
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new  List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter <WebWebGrouping>("_type"));
     DeserializationSettings.Converters.Add(new  PolymorphicDeserializeJsonConverter <WebWebGrouping>("_type"));
     SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter <ResponseBase>("_type"));
     DeserializationSettings.Converters.Add(new  PolymorphicDeserializeJsonConverter <ResponseBase>("_type"));
     CustomInitialize();
 }
 public FlexKidsCookieWebClient(IWeb web, FlexKidsCookieConfig config)
 {
     this.web    = web;
     this.config = config;
 }
示例#21
0
 /// <summary>
 /// Setup data and resources needed by HTTP tracker.
 /// </summary>
 /// <param name="trackerURL"></param>
 public AnnouncerHTTP(string _, IWeb web)
 {
     _web     = web;
     _Bencode = new Bencode();
 }
 public EmpsController(IWeb <Emps> _EmpRepo, IWeb <Department> DepRep)
 {
     //_context = context;
     this.EmpRepo = _EmpRepo;
     this.DepRep  = DepRep;
 }
示例#23
0
 public WebProxy(IWeb webServer)
 {
     _webServer = webServer;
 }
示例#24
0
 /// <summary>
 /// Establishes WebApi
 /// </summary>
 /// <param name="web"></param>
 /// <param name="hostname"></param>
 public WebApi(IWeb web, string hostname)
 {
     _web      = web;
     _hostname = new Uri(hostname).Append("/api/v2/");
 }
示例#25
0
 public WebAdapter(IWeb web)
 {
     this.web = web;
 }
示例#26
0
文件: IWeb.cs 项目: xiawei32/EditorXR
 /// <summary>
 /// Download the given URL using a DownloadTextureHandler
 /// </summary>
 /// <param name="url">The URL to request</param>
 /// <param name="completed">A method to be called on completion</param>
 public static void DownloadTexture(this IWeb obj, string url, Action <DownloadHandlerTexture> completed)
 {
     downloadTexture(url, completed);
 }
示例#27
0
文件: IWeb.cs 项目: xiawei32/EditorXR
 /// <summary>
 /// Download the given URL to a file on disk
 /// </summary>
 /// <param name="url">The URL to request</param>
 /// <param name="destination">The file in which to store the results</param>
 /// <param name="completed">A method to be called on completion</param>
 public static void Download(this IWeb obj, string url, string destination, Action completed)
 {
     downloadToDisk(url, destination, completed);
 }
示例#28
0
 public DepartmentsController(IWeb <Department> _DepRepo)
 {
     DepRepo = _DepRepo;
 }
示例#29
0
 /// <summary>
 /// Establishes WebApi
 /// </summary>
 /// <param name="web"></param>
 /// <param name="hostname"></param>
 public WebApi(IWeb web, string hostname)
 {
     _web = web;
     _hostname = new Uri(hostname).Append("/api/v2/");
 }
示例#30
0
 public Excel(IWeb web, IInteropExcelWrapper interopExcelWrapper)
 {
     Web = web;
     InteropExcelWrapper = interopExcelWrapper;
 }
 public ProductValuesController(IWeb webService)
 {
     _webService = webService;
 }