Пример #1
0
        /// <summary>
        /// Read textures from base-64 encoded strings. Automatically selects assets based
        /// upon whether the light or dark (pro) skin is active.
        /// </summary>
        private static void LoadResourceAssets()
        {
            var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin;

            s_Cached = new Texture2D[skin.Length];

            string name;

            for (var i = 0; i < s_Cached.Length; ++i)
            {
                name = $"{EmbeddedResourceProvider.VISUAL_SCRIPTING_PACKAGE}.ReorderableList." + i;

                Texture2D tex = EmbeddedResourceProvider.LoadFromMemoryResources(name);

                if (s_Cached[i] == null)
                {
                    // Get image data (PNG) from base64 encoded strings.
                    var imageData = Convert.FromBase64String(skin[i]);

                    // Gather image size from image data.
                    int texWidth, texHeight;
                    GetImageSize(imageData, out texWidth, out texHeight);

                    // Generate texture asset.
                    tex = EmbeddedResourceProvider.CreatePixelTexture(name, Color.clear, texWidth, texHeight);

                    tex.LoadImage(imageData);
                }

                s_Cached[i] = tex;
            }
            s_LightSkin = null;
            s_DarkSkin  = null;
        }
Пример #2
0
        public async Task Run_DefaultConfig_ShouldBootstrapDatabase()
        {
            // arrange
            var cancellationToken = new CancellationToken();
            var loggerFactory     = LoggerFactory.Create(
                builder => builder.AddConsole(options => options.FormatterName = "systemd"));
            var optionsMonitorMock = new Mock <IOptionsMonitor <MigrationOptions> >();

            optionsMonitorMock.Setup(x => x.CurrentValue).Returns(() => new MigrationOptions
            {
                MigrationPath = "../../../../../database/migrations/"
            });
            var dbContextFactory = new DefaultDbContextFactory();
            var resourceProvider = new EmbeddedResourceProvider();
            var migrator         = new DbMigrationRunner(
                loggerFactory.CreateLogger <DbMigrationRunner>(),
                optionsMonitorMock.Object,
                dbContextFactory, resourceProvider);

            // act

            await migrator.Run(cancellationToken);

            // assert
        }
Пример #3
0
 private void SetupVerifiableScanElementCall(IWebElement elementContext, string serialzedOptions)
 {
     jsExecutorMock.Setup(js => js.ExecuteAsyncScript(
                              EmbeddedResourceProvider.ReadEmbeddedFile("scan.js"),
                              elementContext,
                              It.Is <string>(options => options == serialzedOptions))).Returns(testAxeResult).Verifiable();
 }
        public async Task InvokeAsync(HttpContext httpContext)
        {
            var path = httpContext.Request.Path.ToString();

            if (!path.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase))
            {
                await Next(httpContext);

                return;
            }

            path = path.Substring(Prefix.Length);

            var file = PublicAppEmbeddedResourceProvider.GetFile(path) ?? PublicComponentEmbeddedResourceProvider.GetFile(path);

            if (file == null)
            {
                await Next(httpContext);

                return;
            }

            if (path.EndsWith(".js"))
            {
                httpContext.Response.ContentType = "application/javascript";
            }

            using (var read = EmbeddedResourceProvider.Open(file))
            {
                await read.CopyToAsync(httpContext.Response.Body);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            var path = context.Request.Path;

            if (!path.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new Exception($"This handler should only be used within the Portal basepath ({Prefix})");
            }

            path = path.Substring(Prefix.Length);

            var file = PublicAppEmbeddedResourceProvider.GetFile(path) ?? PublicComponentEmbeddedResourceProvider.GetFile(path);

            if (file == null)
            {
                throw new Exception($"This handler should only be used on an existing embedded resource");
            }

            context.Response.ContentType = MimeMapping.GetMimeMapping(Path.GetExtension(path));

            using (var read = EmbeddedResourceProvider.Open(file))
            {
                read.CopyTo(context.Response.OutputStream);
            }
        }
Пример #6
0
        void Context_BeginRequest(object sender, EventArgs e)
        {
            if (BasePathProvider == null)
            {
                BasePathProvider = DependencyResolver.Current.GetService <IBasePathProvider>();
                Prefix           = $"/{BasePathProvider.BasePath}/";
            }

            if (EmbeddedResourceProvider == null)
            {
                EmbeddedResourceProvider = DependencyResolver.Current.GetService <IEmbeddedResourceProvider>();
            }

            var context = ((HttpApplication)sender).Context;
            var path    = context.Request.Path;

            if (!path.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            path = path.Substring(Prefix.Length);

            var file = EmbeddedResourceProvider.GetFile(path);

            if (file == null)
            {
                return;
            }

            context.RemapHandler(new EmbeddedResourceHandler());
        }
Пример #7
0
        public void EmbeddedResourceProvider_CanFindExistingResource()
        {
            var provider = new EmbeddedResourceProvider();
            var resource = provider.Get("Templates/EmbeddedResourceTemplate.tmpl");

            Assert.IsNotNull(resource);
            Assert.IsTrue(resource.Length > 0);
        }
Пример #8
0
        /// <summary>
        /// Generate special textures.
        /// </summary>
        private static void GenerateSpecialTextures()
        {
            string name = $"{EmbeddedResourceProvider.VISUAL_SCRIPTING_PACKAGE}.Highlight.Color";

            if (texHighlightColor == null)
            {
                texHighlightColor = EmbeddedResourceProvider.CreatePixelTexture(name, ReorderableListStyles.SelectionBackgroundColor, 1, 1);
            }
        }
Пример #9
0
        static ReorderableListStyles()
        {
            Title                   = new GUIStyle();
            Title.border            = new RectOffset(2, 2, 2, 1);
            Title.margin            = new RectOffset(5, 5, 5, 0);
            Title.padding           = new RectOffset(5, 5, 3, 3);
            Title.alignment         = TextAnchor.MiddleLeft;
            Title.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.TitleBackground);
            Title.normal.textColor  = EditorGUIUtility.isProSkin
                ? new Color(0.8f, 0.8f, 0.8f)
                : new Color(0.2f, 0.2f, 0.2f);

            Container                   = new GUIStyle();
            Container.border            = new RectOffset(2, 2, 2, 2);
            Container.margin            = new RectOffset(5, 5, 0, 0);
            Container.padding           = new RectOffset(2, 2, 2, 2);
            Container.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.ContainerBackground);

            Container2 = new GUIStyle(Container);
            Container2.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Container2Background);

            FooterButton                   = new GUIStyle();
            FooterButton.fixedHeight       = 18;
            FooterButton.alignment         = TextAnchor.MiddleCenter;
            FooterButton.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button_Normal);
            FooterButton.active.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button_Active);
            FooterButton.border            = new RectOffset(3, 3, 1, 3);
            FooterButton.padding           = new RectOffset(2, 2, 0, 2);
            FooterButton.clipping          = TextClipping.Overflow;

            FooterButton2                   = new GUIStyle();
            FooterButton2.fixedHeight       = 18;
            FooterButton2.alignment         = TextAnchor.MiddleCenter;
            FooterButton2.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button2_Normal);
            FooterButton2.active.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button2_Active);
            FooterButton2.border            = new RectOffset(3, 3, 3, 3);
            FooterButton2.padding           = new RectOffset(2, 2, 2, 2);
            FooterButton2.clipping          = TextClipping.Overflow;

            ItemButton = new GUIStyle();

            string name = $"{EmbeddedResourceProvider.VISUAL_SCRIPTING_PACKAGE}.Dark Pixel (List GUI)";

            Texture2D background = EmbeddedResourceProvider.CreatePixelTexture(name, new Color32(18, 18, 18, 255), 1, 1);

            ItemButton.active.background = background;
            ItemButton.imagePosition     = ImagePosition.ImageOnly;
            ItemButton.alignment         = TextAnchor.MiddleCenter;
            ItemButton.overflow          = new RectOffset(0, 0, -1, 0);
            ItemButton.padding           = new RectOffset(0, 0, 1, 0);
            ItemButton.contentOffset     = new Vector2(0, -1f);

            SelectedItem = new GUIStyle();
            SelectedItem.normal.background = ReorderableListResources.texHighlightColor;
            SelectedItem.normal.textColor  = Color.white;
            SelectedItem.fontSize          = 12;
        }
Пример #10
0
        public SaveVM()
        {
            SavevPngCommand  = new Command(() => Save(MediaFileType.Image, EmbeddedMedia.baboonPng));
            SaveJpgCommand   = new Command(() => Save(MediaFileType.Image, EmbeddedMedia.lomonosovJpg));
            SaveGifCommand   = new Command(() => Save(MediaFileType.Image, EmbeddedMedia.newtonsCradleGif));
            SaveVideoCommand = new Command(() => Save(MediaFileType.Video, EmbeddedMedia.earthMp4));

            PngSource = EmbeddedResourceProvider.GetImageSource(EmbeddedMedia.baboonPng);
            JpgSource = EmbeddedResourceProvider.GetImageSource(EmbeddedMedia.lomonosovJpg);
            GifSource = EmbeddedResourceProvider.GetImageSource(EmbeddedMedia.newtonsCradleGif);
        }
Пример #11
0
        private void SetupVerifiableAxeInjectionCall()
        {
            webDriverMock
            .Setup(d => d.FindElements(It.IsAny <By>()))
            .Returns(new ReadOnlyCollection <IWebElement>(new List <IWebElement>(0)));

            webDriverMock.Setup(d => d.SwitchTo()).Returns(targetLocatorMock.Object);

            jsExecutorMock
            .Setup(js => js.ExecuteScript(EmbeddedResourceProvider.ReadEmbeddedFile("axe.min.js"))).Verifiable();
        }
Пример #12
0
        public void EmbeddedResourceProvider_CanFindLocalizedResource()
        {
            var provider = new EmbeddedResourceProvider();
            var resource = provider.Get("Templates/EmbeddedResourceTemplate.tmpl", new CultureInfo("ru-RU"));

            Assert.IsNotNull(resource);
            using (var streamReader = new StreamReader(resource))
            {
                var templateString = streamReader.ReadToEnd();
                Assert.IsTrue(templateString.Contains("русском"));
            }
        }
        public ITranslationRepository Create(string path)
        {
            var file = EmbeddedResourceProvider.GetFile(path);

            if (file == null)
            {
                throw new FileNotFoundException(path);
            }

            using (var read = EmbeddedResourceProvider.Open(file))
            {
                return(new TranslationRepository(TranslationParser.Parse(read)));
            }
        }
        private void CreateDb(string masterDbConnectionString)
        {
            this.logger.LogTrace("The database was not found and will be created");

            using (var con = new SqlConnection(masterDbConnectionString))
            {
                con.Open();
                this.ExecuteNonQuery(EmbeddedResourceProvider.GetResourceString("CreateNewDatabase.sql", "DBScripts.ExternalSqlCreation"), con);
                this.ExecuteNonQuery(EmbeddedResourceProvider.GetResourceString("CreateServiceAccountLoginToServer.sql", "DBScripts.ExternalSqlCreation"), con);
                this.ExecuteNonQuery(EmbeddedResourceProvider.GetResourceString("CreateServiceAccountLoginToDB.sql", "DBScripts.ExternalSqlCreation"), con);
                this.ExecuteNonQuery(EmbeddedResourceProvider.GetResourceString("CreateServiceAccountPermissionToDB.sql", "DBScripts.ExternalSqlCreation"), con);
            }

            this.logger.LogTrace("The [AccessManager] database was created");
        }
Пример #15
0
        public void ResolveEmbeddedResources()
        {
            var rootDir = ProjectResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project;
            bool projectFound = Project.TryGetProject(testProjectFolder, out project);
            Assert.True(projectFound);

            var resolver = new EmbeddedResourceProvider();
            var embeddedResource = resolver.GetResources(project);

            Assert.Equal("testproject.owntext.txt", embeddedResource[0].Name);
            Assert.Equal("testproject.subfolder.nestedtext.txt", embeddedResource[1].Name);
            Assert.Equal("testproject.OtherText.txt", embeddedResource[2].Name);
        }
Пример #16
0
        public void ResolveEmbeddedResources()
        {
            var rootDir           = ProjectRootResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project;
            bool    projectFound = Project.TryGetProject(testProjectFolder, out project);

            Assert.True(projectFound);

            var resolver         = new EmbeddedResourceProvider();
            var embeddedResource = resolver.GetResources(project);

            Assert.Equal("testproject.owntext.txt", embeddedResource[0].Name);
            Assert.Equal("testproject.subfolder.nestedtext.txt", embeddedResource[1].Name);
            Assert.Equal("testproject.OtherText.txt", embeddedResource[2].Name);
        }
Пример #17
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Add additional virtual path provider to allow access to embedded resources
            EmbeddedResourceProvider.Register();


            GlobalSettings global = DefaultModel.Global;

            // Make sure SOETools specific default config file service settings exist
            CategorizedSettingsElementCollection systemSettings = ConfigurationFile.Current.Settings["systemSettings"];

            systemSettings.Add("ConnectionString", "Data Source=pqdashboard; Initial Catalog=PQDashboard; Integrated Security=SSPI", "Configuration connection string.");
            systemSettings.Add("DataProviderString", "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection; AdapterType=System.Data.SqlClient.SqlDataAdapter", "Configuration database ADO.NET data provider assembly type creation string used");
            systemSettings.Add("CompanyName", "Grid Protection Alliance", "The name of the company who owns this instance of the PQDashboard.");
            systemSettings.Add("CompanyAcronym", "GPA", "The acronym representing the company who owns this instance of the PQDashboard.");
            systemSettings.Add("DateFormat", "MM/dd/yyyy", "The default date format to use when rendering timestamps.");
            systemSettings.Add("TimeFormat", "HH:mm.ss.fff", "The default time format to use when rendering timestamps.");

            // Load default configuration file based model settings
            global.CompanyName    = systemSettings["CompanyName"].Value;
            global.CompanyAcronym = systemSettings["CompanyAcronym"].Value;
            global.DateFormat     = systemSettings["DateFormat"].Value;
            global.TimeFormat     = systemSettings["TimeFormat"].Value;
            global.DateTimeFormat = $"{global.DateFormat} {global.TimeFormat}";

            // Modify the JSON serializer to serialize dates as UTC -
            // otherwise, timezone will not be appended to date strings
            // and browsers will select whatever timezone suits them
            JsonSerializerSettings settings = JsonUtility.CreateDefaultSerializerSettings();

            settings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            JsonSerializer serializer = JsonSerializer.Create(settings);

            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);

#if DEBUG
            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromMinutes(30);
#endif
        }
        public IFileInfo GetFileInfo(string subpath)
        {
            if (!subpath.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase))
            {
                return(null);
            }

            subpath = subpath.Substring(Prefix.Length);

            var file = EmbeddedResourceProvider.GetFile(subpath);

            if (file == null)
            {
                return(null);
            }

            return(new EmbeddedFileInfo(EmbeddedResourceProvider, file));
        }
Пример #19
0
        async void Save(MediaFileType type, string name)
        {
            var status = await PermissionHelper.CheckAndReques <SaveMediaPermission>(
                "The application needs permission to save media files",
                DisplayAlertAsync);

            if (status != PermissionStatus.Granted)
            {
                await DisplayAlertAsync("The application did not get the necessary permission to save media files");

                return;
            }

            try
            {
                using var stream = EmbeddedResourceProvider.Load(name);

                if (FromStream)
                {
                    await MediaGallery.SaveAsync(type, stream, name);
                }
                else if (FromByteArray)
                {
                    using var memoryStream = new MemoryStream();
                    stream.CopyTo(memoryStream);

                    await MediaGallery.SaveAsync(type, memoryStream.ToArray(), name);
                }
                else if (FromCacheDirectory)
                {
                    var filePath = await FilesHelper.SaveToCacheAsync(stream, name);

                    await MediaGallery.SaveAsync(type, filePath);
                }

                await DisplayAlertAsync("Save Completed Successfully");
            }
            catch (Exception ex)
            {
                await DisplayAlertAsync(ex.Message);
            }
        }
Пример #20
0
        static TimeZones()
        {
            var timezoneXML = EmbeddedResourceProvider.GetResource(EmbeddedResourceProvider.ResourceTypeOptions.TimeZonesXML);

            _timeZonesXML = XDocument.Parse(timezoneXML);
        }
Пример #21
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Add additional virtual path provider to allow access to embedded resources
            EmbeddedResourceProvider.Register();


            GlobalSettings global = DefaultModel.Global;

            // Make sure SOETools specific default config file service settings exist
            CategorizedSettingsElementCollection systemSettings   = ConfigurationFile.Current.Settings["systemSettings"];
            CategorizedSettingsElementCollection securityProvider = ConfigurationFile.Current.Settings["securityProvider"];

            systemSettings.Add("ConnectionString", "Data Source=pqdashboard; Initial Catalog=PQDashboard; Integrated Security=SSPI", "Configuration connection string.");
            systemSettings.Add("DataProviderString", "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection; AdapterType=System.Data.SqlClient.SqlDataAdapter", "Configuration database ADO.NET data provider assembly type creation string used");
            systemSettings.Add("CompanyName", "Grid Protection Alliance", "The name of the company who owns this instance of the PQDashboard.");
            systemSettings.Add("CompanyAcronym", "GPA", "The acronym representing the company who owns this instance of the PQDashboard.");
            systemSettings.Add("DateFormat", "MM/dd/yyyy", "The default date format to use when rendering timestamps.");
            systemSettings.Add("TimeFormat", "HH:mm.ss.fff", "The default time format to use when rendering timestamps.");
            systemSettings.Add("DefaultSecurityRoles", "Administrator, Engineer, Viewer", "The default security roles that should exist for the application.");
            securityProvider.Add("PasswordRequirementsRegex", AdoSecurityProvider.DefaultPasswordRequirementsRegex, "Regular expression used to validate new passwords for database users.");
            securityProvider.Add("PasswordRequirementsError", AdoSecurityProvider.DefaultPasswordRequirementsError, "Error message to be displayed when new database user password fails regular expression test.");

            // Load default configuration file based model settings
            global.CompanyName               = systemSettings["CompanyName"].Value;
            global.CompanyAcronym            = systemSettings["CompanyAcronym"].Value;
            global.DateFormat                = systemSettings["DateFormat"].Value;
            global.TimeFormat                = systemSettings["TimeFormat"].Value;
            global.DateTimeFormat            = $"{global.DateFormat} {global.TimeFormat}";
            global.PasswordRequirementsRegex = securityProvider["PasswordRequirementsRegex"].Value;
            global.PasswordRequirementsError = securityProvider["PasswordRequirementsError"].Value;

            // Load database driven model settings
            using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
            {
                //EncryptScores(dataContext);

                // Validate default security roles exist
                ValidateSecurityRoles(connection, systemSettings["DefaultSecurityRoles"].Value);

                // Validate users and groups exist in the database as SIDs
                ValidateAccountsAndGroups(connection);


                //// Load global web settings
                //Dictionary<string, string> appSetting = connection.LoadDatabaseSettings("app.setting");
                //global.ApplicationName = appSetting["applicationName"];
                //global.ApplicationDescription = appSetting["applicationDescription"];
                //global.ApplicationKeywords = appSetting["applicationKeywords"];


                //// Cache application settings
                //foreach (KeyValuePair<string, string> item in appSetting)
                //    global.ApplicationSettings.Add(item.Key, item.Value);
            }


            // Modify the JSON serializer to serialize dates as UTC -
            // otherwise, timezone will not be appended to date strings
            // and browsers will select whatever timezone suits them
            JsonSerializerSettings settings = JsonUtility.CreateDefaultSerializerSettings();

            settings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            JsonSerializer serializer = JsonSerializer.Create(settings);

            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);

#if DEBUG
            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromMinutes(30);
#endif
        }
Пример #22
0
 public Stream CreateReadStream()
 {
     return(EmbeddedResourceProvider.Open(File));
 }
        public static ICollection <ValidationResult> ValidateMinimalNeeded(this IIAddress address)
        {
            var currentThread    = Thread.CurrentThread;
            var currentUiCulture = currentThread.CurrentUICulture;

            try
            {
                string addressCulture = CountryCodeToCulture(address.Country);

                if (addressCulture != null && currentUiCulture.IetfLanguageTag != addressCulture)
                {
                    currentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(addressCulture);
                }

                AddressImplementor a;
                if (typeof(AddressImplementor).IsInstanceOfType(address))
                {
                    a = (AddressImplementor)address;
                }
                else
                {
                    a = new AddressImplementor();
                    address.CopyTo(a);
                }

                //Get flags indicating if we need to validate specific fields
                XDocument countries = XDocument.Load(
                    EmbeddedResourceProvider.GetResourceStream(EmbeddedResourceProvider.ResourceTypeOptions.CountryProvinceCityXML)
                    );

                bool require_postal_code = true;
                bool require_city        = true;
                var  countryNode         = countries.Root.Elements("country").FirstOrDefault(c => c.Attribute("code").Value == address.Country);
                if (countryNode != null)
                {
                    require_postal_code = countryNode.Attribute("require_postal_code") == null ? require_postal_code : Convert.ToBoolean(countryNode.Attribute("require_postal_code").Value);
                    require_city        = countryNode.Attribute("require_city") == null ? require_city : Convert.ToBoolean(countryNode.Attribute("require_city").Value);
                }

                var ret = new List <ValidationResult>();
                if (require_postal_code && string.IsNullOrWhiteSpace(address.PostalCode))
                {
                    if (require_city && string.IsNullOrWhiteSpace(address.City))
                    {
                        ret.Add(new ValidationResult("Expected City or Postal Code", new string[] { "PostalCode", "City" }));
                    }
                    if (typeof(IAddress).IsInstanceOfType(address))
                    {
                        var address2 = (IAddress)address;
                        if (string.IsNullOrWhiteSpace(address2.Province) && string.IsNullOrWhiteSpace(address2.ProvinceName))
                        {
                            ret.Add(new ValidationResult("Expected Province Code, Province Name or Postal Code", new string[] { "PostalCode", "Province" }));
                        }
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(address.Province))
                        {
                            ret.Add(new ValidationResult("Expected Province or Postal Code", new string[] { "PostalCode", "Province" }));
                        }
                    }
                }

                var vc = new ValidationContext(a, null, null);
                vc.MemberName = "Country";
                Validator.TryValidateProperty(address.Country, vc, ret);

                if (!string.IsNullOrWhiteSpace(address.Address1))
                {
                    vc.MemberName = "Address1";
                    Validator.TryValidateProperty(address.Address1, vc, ret);
                }

                if (require_postal_code && !string.IsNullOrWhiteSpace(address.PostalCode))
                {
                    vc.MemberName = "PostalCode";
                    Validator.TryValidateProperty(address.PostalCode, vc, ret);
                }

                if (require_city && !string.IsNullOrWhiteSpace(address.City))
                {
                    vc.MemberName = "City";
                    Validator.TryValidateProperty(address.City, vc, ret);
                }

                if (!string.IsNullOrWhiteSpace(address.Province))
                {
                    vc.MemberName = "Province";
                    Validator.TryValidateProperty(address.Province, vc, ret);
                }

                return(ret);
            }
            finally
            {
                currentThread.CurrentUICulture = currentUiCulture;
            }
        }
 public string GetScript() => EmbeddedResourceProvider.ReadEmbeddedFile("axe.min.js");