namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var pwd = "Test1236";
var r = new PasswordChecker(pwd);
;
}
}
public class PasswordChecker
{
private readonly char[] _upper = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', };
private readonly char[] _digit = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
private readonly char[] _special = new char[] { '!', '@', '#', '$', '%', '^', '&', '*', '?', '_', '~' };
private readonly int _strongPasswordLength;
private readonly string _password;
public bool IsLengthOk => _password.Length > _strongPasswordLength;
public bool HasUpper { get; private set; }
public bool HasDigit { get; private set; }
public bool HasSpecial { get; private set; }
public PasswordChecker(string password, int passwordLength=8)
{
_password = password;
_strongPasswordLength = passwordLength;
foreach (var ch in _password)
{
HasUpper = _upper.Any(x => x == ch);
HasDigit = _digit.Any(x => x == ch);
HasSpecial = _special.Any(x => x == ch);
}
}
}
}
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var server = "https://ya.ru";
var template = $@"namespace StsServerIdentity {{
public class Settings
{{
public const string Server = ""{server}"";
public const int Port = 80;
public const string User = """";
public const string Password = """";
}}
}}
";
Console.WriteLine(template);
}
}
}
#region License
// Разработано: Коротенко Владимиром Николаевичем (Vladimir N. Korotenko)
// email: koroten@ya.ru
// skype:vladimir-korotenko
// https://vkorotenko.ru
// Создано: 09.04.2019 23:04
#endregion
using SpecialForcesDirectory.Code;
using System.IO;
namespace SpecialForcesDirectory.Dbl
{
public class DataContext
{
private static readonly object Lock = new object();
private static DataContext _ctx;
public ContentDatabase ContentData { get; private set; }
public UserDatabase UserDatabase { get; private set; }
private DataContext()
{
ContentData = new ContentDatabase();
UserDatabase = new UserDatabase();
}
public static DataContext Instance
{
get
{
lock (Lock)
{
if (_ctx != null) return _ctx;
_ctx = new DataContext();
return _ctx;
}
}
}
public static void Close()
{
if (_ctx == null) return;
lock (Lock)
{
if (_ctx.ContentData != null)
{
_ctx.ContentData.Clear().Wait();
_ctx.ContentData = null;
}
if (_ctx.UserDatabase == null) return;
_ctx.UserDatabase.Clear().Wait();
_ctx.UserDatabase = null;
_ctx = null;
}
}
/// <summary>
/// Перезаписывает базу данных при обновлении, корректно закрывая ресурсы.
/// </summary>
/// <param name="file"></param>
public static void UpdateFile(byte[] file)
{
var fp = BaseContentDatabase.DatabasePath;
Close();
lock (Lock)
{
File.WriteAllBytes(fp, file);
_ctx = new DataContext();
}
}
public static void DropFile()
{
var fullPath = BaseContentDatabase.DatabasePath;
var userDb = BaseUserDatabase.DatabasePath;
Close();
lock (Lock)
{
File.Delete(fullPath);
File.Delete(userDb);
}
}
}
}
#region License
// // Разработано: Коротенко Владимиром Николаевичем (Vladimir N. Korotenko)
// // email: koroten@ya.ru
// // skype:vladimir-korotenko
// // https://vkorotenko.ru
// // Создано: 13.08.2020 14:07
#endregion
using System.Collections.Generic;
using System.Threading.Tasks;
using SpecialForcesDirectory.Code;
using SpecialForcesDirectory.Models;
using SQLite;
namespace SpecialForcesDirectory.Dbl
{
public class ContentDatabase : BaseContentDatabase
{
#region Category repository
private async Task<SQLiteAsyncConnection> GetCategoryConn()
{
return await GetDatabaseConnection<Category>().ConfigureAwait(false);
}
public async Task<IEnumerable<Category>> GetCategories()
{
var conn = await GetCategoryConn();
return await AttemptAndRetry(() => conn.Table<Category>().ToListAsync()).ConfigureAwait(false);
}
public async Task<Category> GetCategory(int id)
{
var conn = await GetCategoryConn();
return await AttemptAndRetry(() => conn.GetAsync<Category>(id)).ConfigureAwait(false);
}
#endregion
#region Content Repository
private async Task<SQLiteAsyncConnection> GetCtxConn()
{
return await GetDatabaseConnection<Content>().ConfigureAwait(false);
}
public async Task<IEnumerable<Content>> GetItems()
{
var conn = await GetCtxConn();
return await AttemptAndRetry(() => conn.Table<Content>().ToListAsync()).ConfigureAwait(false);
}
public async Task<Content> GetItem(int id)
{
var conn = await GetCtxConn();
return await AttemptAndRetry(() => conn.GetAsync<Content>(id)).ConfigureAwait(false);
}
public async Task<int> DeleteItem(int id)
{
var conn = await GetCtxConn();
return await AttemptAndRetry(() => conn.DeleteAsync<Content>(id)).ConfigureAwait(false);
}
public async Task SaveItem(Content item)
{
var conn = await GetCtxConn();
if (item.Id == 0) await AttemptAndRetry(() => conn.InsertAsync(item)).ConfigureAwait(false);
await AttemptAndRetry(() => conn.UpdateAsync(item)).ConfigureAwait(false);
}
public async Task<IEnumerable<SRawItem>> GetItemsByQuery(string q, int lim)
{
var qu = q.ToUpper();
var list = new List<SRawItem>();
var conn = await GetCtxConn();
var result = conn.Table<Content>()
.Where(x => x.EnableTab1 == 1 && x.Tab1.ToUpper().Contains(qu)
|| x.EnableTab2 == 1 && x.Tab2.ToUpper().Contains(qu)
|| x.EnableTab3 == 1 && x.Tab3.ToUpper().Contains(qu)).Take(lim);
var r = await result.ToListAsync();
foreach (var content in r)
{
var st = GetSt(content, qu);
var title = await conn.Table<Category>().Where(x => x.Id == content.CatId).FirstAsync();
var ni = new SRawItem
{
Body = st.Body,
CatId = content.CatId.ToString(),
Title = title.Title,
Id = content.Id.ToString(),
MType = "a",
Tab = st.Tab
};
list.Add(ni);
}
return list;
}
private static TabStruct GetSt(Content content, string q)
{
if (content.Tab1.ToUpper().Contains(q))
return new TabStruct { Tab = "1", Body = content.Tab1 };
if (content.Tab2.ToUpper().Contains(q))
return new TabStruct { Tab = "2", Body = content.Tab2 };
return new TabStruct { Tab = "3", Body = content.Tab3 };
}
private struct TabStruct
{
public string Body { get; set; }
public string Tab { get; set; }
}
#endregion
public async Task Clear()
{
await BaseContentDatabase.Close();
}
}
}
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace ConsoleApp2
{
/// <summary>
/// Не используйте транслит! Любой китаец или индус поймет английский,
/// а вот русский только поржет.
/// </summary>
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string ImportDate { get; set; }
public string Description { get; set; }
/// <summary>
/// Рубли умноженные на 10000. помним об этом то есть у вас копейка имеет 2знака после запятой!!!!
/// </summary>
public Int64 Price { get; set; }
public int Discount { get; set; }
public string Category { get; set; }
/// <summary>
/// Дата списания
/// </summary>
public string DueDate { get; set; }
public string ДляОсобоУпоротыхЭтоТакиРаботает { get; set; }
}
public static class Extensions
{
/// <summary>
/// Convert string from format dd.MM.yyyy to DateTime
/// </summary>
/// <param name="inputDate"></param>
/// <returns></returns>
public static DateTime ParseDateDayMounthYear(this string inputDate) =>
DateTime.ParseExact(inputDate, "dd.MM.yyyy", CultureInfo.InvariantCulture);
}
class Program
{
static void Main(string[] args)
{
#region заполняем список товаров
List<Product> tovar = new List<Product>()
{
new Product(){Id = 2,
Name = "Яблоки",
ImportDate = "11.11.2022",
Description = "Свежие яблоки.",
Price = 1000000,
Discount = 5,
DueDate="11.11.2022",
Category = "Овощи"},
new Product(){Id = 2,Name = "Молоко",
ImportDate = "16.10.2021",
DueDate="16.10.2021",
Description = "Свежее молоко.",
Price = 800000,
Discount = 10,
Category = "Кисломолочные"}
};
#endregion
// число месяц год
var data = tovar.Where(item => item.DueDate.ParseDateDayMounthYear() < DateTime.Today).ToList();
}
}
}
<StackPanel>
<TextBlock Text="Этот телефон Xiaomi стоит:"/>
<TextBlock Text="{Binding XiomiPrice}"/>
</StackPanel>