In the style of Studio Ghibli, close-up, a young woman in her 20s to 30s, with long black hair either naturally loose or caually tied up. She has a gental and smoothing expression with a warm smile, and healthy complexion.
Windows PowerShell is a command-line shell and scripting language designed especially for system administration. It’s analogue in Linux is called as Bash Scripting. Built on the .NET Framework, Windows PowerShell helps IT professionals to control and automate the administration of the Windows operating system and applications that run on Windows Server environment.
v5 vs v7
v5 based on .net 4.5
v6 based on .net core 2.0. already expired
v7 based on .net core 8.0
Install
Install v7
IDE
PowerShell ISE, build-in at windows system, support until v7
Install visual studio code extension, recommended
Cmdlets
A cmdlet (pronounced “command-let”) is a compiled command. A cmdlet can be developed in .NET or .NET Core and invoked as a command within PowerShell. Thousands of cmdlets are available in your PowerShell installation. You can create and invoke them programmatically through Windows PowerShell APIs.
Cmdlets are named according to a verb-noun naming standard. This pattern can help you to understand what they do and how to search for them. It also helps cmdlet developers create consistent names. You can see the list of approved verbs by using the Get-Verb cmdlet. Verbs are organized according to activity type and function.
$PSVersionTable
$PSVersionTable.PSVersion
Get-Variable
`Get-Verb
Get-Command
Get-Help
Get-Command -Noun alias*
Get-Command -Verb Get -Noun alias*
Get-Command -Noun File*
Get-Command -Verb Get -Noun File*
Location
Get-Service “vm*” | Get-Member`
Scripting
variables
Variable name should start with $ and can contain alphanumeric characters and underscore
$location = Get-Location
vs 项目升级到了.net 9.0,提示错误:Unhandled exception. System.Management.Automation.Runspaces.PSSnapInException: Cannot load PowerShell snap-in Microsoft.PowerShell.Diagnostics because of the following error: Could not find file ‘…\bin\Release\net9.0\runtimes\win\lib\net9.0\Microsoft.PowerShell.Commands.Diagnostics.dll
安装 Microsoft.PowerShell.SDK
确认所有关联项目都升级到了9.0
vs项目 运行出错,Unhandled exception. System.Management.Automation.PSSecurityException: File …\test-boolean.ps1 cannot be loaded because running scripts is disabled on this system
说明你当前系统的 PowerShell 执行策略 (ExecutionPolicy)禁止运行 .ps1脚本。这是 Windows 系统的一个默认安全设置。
SELECT column1, column2....columnN
FROM table_name
WHERE column_name GLOB { PATTERN };
匹配模式使用通配符:
- `*`:匹配任意长度的任意字符
- `?`:匹配单个任意字符
- `[abc]`:匹配指定集合中任一字符
- `[a-z]`:匹配字符范围
ALTER TABLE
ALTER TABLE table_name ADD COLUMN column_def...;
ALTER TABLE table_name RENAME TO new_table_name;
Transaction
BEGIN;
or
BEGIN EXCLUSIVE TRANSACTION;
COMMIT;
SAVEPOINT
SAVEPOINT savepoint_name;
RELEASE savepoint_name;
ROLLBACK
ROLLBACK;
or
ROLLBACK TO SAVEPOINT savepoint_name;
CREATE INDEX
CREATE INDEX index_name ON table_name ( column_name COLLATE NOCASE );
CREATE UNIQUE INDEX index_name ON table_name ( column1, column2,...columnN);
DROP INDEX database_name.index_name;
CREATE TRIGGER database_name.trigger_name
BEFORE INSERT ON table_name FOR EACH ROW
BEGIN
stmt1; stmt2; ....
END;
DROP INDEX database_name.trigger_name;
CREATE VIEW
CREATE VIEW database_name.view_name AS SELECT statement....;
DROP INDEX database_name.view_name;
CREATE VIRTUAL TABLE
CREATE VIRTUAL TABLE database_name.table_name USING weblog( access.log );
or
CREATE VIRTUAL TABLE database_name.table_name USING fts3( );
EXISTS
SELECT column1, column2....columnN FROM table_name WHERE column_name EXISTS (SELECT * FROM table_name );
EXPLAIN Statement
EXPLAIN INSERT statement...;
or
EXPLAIN QUERY PLAN SELECT statement...;
CREATE TABLE example (
id INTEGER, -- 类型亲和性 INTEGER
name TEXT, -- 类型亲和性 TEXT
value NUMERIC -- 类型亲和性 NUMERIC
);
INSERT INTO example VALUES ('123', 456, 78.9);
WPF stands for Windows Presentation Foundation. It is a powerful framework for building Windows applications.
早起的GUI程序中,比如Windows Forms,程序的外观和行为没有完全分离,都用同一种语言开发,比如C#,往往需要同时修改UI和逻辑代码,维护成本高。
In WPF, UI elements are designed in XAML while behaviors can be implemented in procedural languages such C# and VB.Net. So it very easy to separate behavior from the designer code.
With XAML, the programmers can work in parallel with the designers. The separation between a GUI and its behavior can allow us to easily change the look of a control by using styles and templates.
WPF架构
Setup
Microsoft provides two important tools for WPF application development. Both the tools can create WPF projects, but the fact is that Visual Studio is used more by developers, while Blend is used more often by designers.
Visual Studio
Expression Blend
XAML
Conceptions
Logical Tree vs Visual Tree
Visual tree includes logic tree.
开发中常用-逻辑树,可以聚焦在写代码
Dependency property
依赖属性不是普通的c#内部属性字段,他可以注册到WPF的属性系统中统一管理。有很多新特性,比如双向绑定,样式,动画,资源等等,是一种超级属性。
依赖属性必须继承 DependencyObject class
Routed Events
本质上是一个事件event,能监听树。
有3种:
Direct Event - 等同与Windows form的event
Bubbling Event,从下往上传递,顶层是Window
Tunnel Event
Controls
WPF有100多种视觉控件。
Data binding
有多种数据绑定方法
DataContext is used in View to bind data with ViewModel。最常用
比如有一个view model
```csharp
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
A trigger basically enables you to change property values or take actions based on the value of a property.
XAML中的 Trigger是一种在 界面层(View)控制样式和行为的机制,本质上和 ViewModel没有直接关系,它的作用是根据某个属性的值来触发样式变化或动作,属于 UI 响应式逻辑的一部分。
Trigger是 XAML 中用于“当某个条件满足时,就改变样式或属性”的机制。
有3种trigger
Property Triggers: when a change occurs in one property, it will bring either an immediate or an animated change in another property.
Data Triggers: it performs some actions when the bound data satisfies some conditions.
Event Triggers: it performs some actions when a specific event is fired.
XAML stands for Extensible Application Markup Language. Its a simple and declarative language based on XML.
In XAML, it very easy to create, initialize, and set properties of objects with hierarchical relations.
It is mainly used for designing GUIs, however it can be used for other purposes as well, e.g., to declare workflow in Workflow Foundation.
XAML文件会由专门的解析器处理,编译成内部代码,再与c#代码link并编译,最后生成app。