Пример #1
0
        /// <summary>
        /// Allows setting a fall-back URI if the underlying CSS URI for this resource fails to load (for example, if a CDN is down).
        /// </summary>
        /// <param name="resourceFallbackPath"></param>
        /// <param name="testClass"></param>
        /// <param name="testProperty"></param>
        /// <param name="testPropertyValue"></param>
        /// <returns></returns>
        public ResourceInfo SetCSSFallback(string resourceFallbackPath, string testClass, string testProperty = null, string testPropertyValue = null)
        {
            if (Type != ResourceTypes.CSS)
            {
                throw new InvalidOperationException("You can only set a CSS fall-back URI on CSS resource."
                                                    + System.Environment.NewLine + "  Current Path: " + Path + " (" + Type.GetName() + ")"
                                                    + System.Environment.NewLine + "  Fall-back Path: " + resourceFallbackPath);
            }

            if (string.IsNullOrWhiteSpace(testClass) || string.IsNullOrWhiteSpace(testProperty) || string.IsNullOrWhiteSpace(testPropertyValue))
            {
                throw new InvalidOperationException("A test CSS class name, property name, and expected property value is required in order to complete a valid test.");
            }

            FallbackPath = string.IsNullOrWhiteSpace(resourceFallbackPath) ? null : resourceFallbackPath; // (must not be null or empty when setting this, otherwise null cancels it)

            FallbackTestClass         = testClass;
            FallbackTestProperty      = testProperty;
            FallbackTestPropertyValue = testPropertyValue;

            return(this);
        }