MVVMLight学习笔记(五)---RelayCommand深究
一、概述
有时候,单纯的命令绑定不一定能满足我们的开发需求,比如我们需要在命令绑定的时候传递一个参数,这个时候,我们就需要使用RelayCommand的泛型版本了。
RelayCommand的泛型版本的构造函数以下:
public RelayCommand(Action<T> execute, bool keepTargetAlive = false);
public RelayCommand(Action<T> execute, Func<T, bool> canExecute, bool keepTargetAlive = false);
构造函数传入的是委托类型的参数,Execute 和 CanExecute执行委托方法。
二、带一个参数的命令绑定
代码片段如下:
<StackPanel>
<GroupBox Header="带string类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserList:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<Label Content="{Binding Path=UserList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<TextBox Width="200" Name="tbUser"></TextBox>
<Button Content="AddUser" Command="{Binding AddUserCommand}" CommandParameter="{Binding ElementName=tbUser,Path=Text}"></Button>
<CheckBox Content="IsCanAdd" VerticalAlignment="Center" FontSize="16" IsChecked="{Binding IsCanAddUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel>
private RelayCommand<string> addUserCommand;
public RelayCommand<string> AddUserCommand
{
get
{
if (addUserCommand == null)
{
addUserCommand = new RelayCommand<string>(AddUser, (string p) => { return IsCanAddUser; });
}
return addUserCommand;
}
set { addUserCommand = value; }
}
private void AddUser(string par)
{
UserList = UserList + " " + par;
}
三、带多个参数的命令绑定
给命令传递多个参数,建议使用以下方式:
使用MultiBinding将多绑定的各个值转换成我们所需的对象或者实例模型,再传递给ViewModel中的命令。
代码片段如下:
<Window x:Class="MvvmLightDemo1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmLightDemo1"
xmlns:cvt="clr-namespace:MvvmLightDemo1.Converter"
xmlns:mvvm="http://www.galasoft.ch/mvvmlight"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
Title="MVVMLIghtDemo1" Height="500" Width="700" >
<Window.Resources>
<cvt:UserInfoConverter x:Key="userInfoConverter"></cvt:UserInfoConverter>
</Window.Resources>
<Window.DataContext>
<Binding Path="Main" Source="{StaticResource Locator}"></Binding>
</Window.DataContext>
<StackPanel>
<StackPanel>
<GroupBox Header="带string类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserList:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<Label Content="{Binding Path=UserList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<TextBox Width="200" Name="tbUser"></TextBox>
<Button Content="AddUser" Command="{Binding AddUserCommand}" CommandParameter="{Binding ElementName=tbUser,Path=Text}"></Button>
<CheckBox Content="IsCanAdd" VerticalAlignment="Center" FontSize="16" IsChecked="{Binding IsCanAddUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="带对象类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FF127C0D" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxUser" FontSize="16" />
<Label Content="Password:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxPwd" FontSize="16" />
<Button Content="AddUser" Command="{Binding AddUserCommandWithObjPar}">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource userInfoConverter}">
<Binding ElementName="tbxUser" Path="Text"/>
<Binding ElementName="tbxPwd" Path="Text"/>
</MultiBinding>
</Button.CommandParameter> </Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Parameter:" FontSize="16" ></Label>
<Label Content="{Binding ObjParameter}" FontSize="16" ></Label> </StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="事件转命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel>
<ListBox x:Name="lb" ItemsSource="{Binding ListBoxData}" BorderThickness="0" SelectedIndex="{Binding SelectIndex}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<mvvm:EventToCommand Command="{Binding SelectionChangedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel> <ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="AntiqueWhite" BorderThickness="1">
<StackPanel Margin="2"> <Image Source="{Binding Img}" Width="96" Height="96"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding Info}"/> </StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label Content="您选择的是:" FontSize="16" ></Label>
<Label Content="{Binding Path=SelResult,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" />
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> </StackPanel>
</Window>
1 using GalaSoft.MvvmLight;
2
3 namespace MvvmLightDemo1.ViewModel
4 {
5 public class UserModel: ObservableObject
6 {
7 private string userName;
8
9 public string UserName
10 {
11 get { return userName; }
12 set
13 {
14 userName = value;
15 RaisePropertyChanged();
16 }
17 }
18
19 private string passWord;
20
21 public string PassWord
22 {
23 get { return passWord; }
24 set
25 {
26 passWord = value;
27 RaisePropertyChanged();
28 }
29 }
30
31
32 }
33 }
using MvvmLightDemo1.ViewModel;
using System;
using System.Linq;
using System.Windows.Data; namespace MvvmLightDemo1.Converter
{
public class UserInfoConverter: IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!values.Cast<string>().Any(text => string.IsNullOrEmpty(text)) && values.Count() == 2)
{
UserModel userModel = new UserModel() { UserName = values[0].ToString(), PassWord = values[1].ToString()};
return userModel;
} return null;
} public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
private RelayCommand<UserModel> addUserCommandWithObjPar;
public RelayCommand<UserModel> AddUserCommandWithObjPar
{
get
{
if (addUserCommandWithObjPar == null)
{
addUserCommandWithObjPar = new RelayCommand<UserModel>(AddUserWithObjPar);
}
return addUserCommandWithObjPar;
}
set { addUserCommandWithObjPar = value; }
}
private void AddUserWithObjPar(UserModel par)
{
ObjParameter = "UserName: "+ par.UserName + " Password: " + par.PassWord;
}
后记:
从MVVM的模式来说,其实命令中的参数传递未必是必要的。与其维护一段额外的参数代码,还不如把所有的交互参数细化成为当前DataContext下的全局属性。View开发人员和ViewModel开发人员共同维护好这份命令清单和属性清单即可。
四、EventToCommand
在WPF中,并不是所有控件都有Command,例如TextBox,那么当文本改变,我们需要处理一些逻辑,这些逻辑在ViewModel中,没有Command如何绑定呢?
这个时候我们就用到EventToCommand,事件转命令,可以将一些事件例如TextChanged,Checked等事件转换成命令的方式。
接下来我们就以ListBox为例子,来看看具体的实例:
View代码:(这边声明了i特性和mvvm特性,一个是为了拥有触发器和行为附加属性的能力,当事件触发时,会去调用相应的命令,EventName代表触发的事件名称;一个是为了使用MVVMLight中 EventToCommand功能。)
这边就是当ListBox执行SelectionChanged事件的时候,会相应去执行ViewModel中 SelectionChangedCommand命令。
代码片段如下:
<Window x:Class="MvvmLightDemo1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmLightDemo1"
xmlns:cvt="clr-namespace:MvvmLightDemo1.Converter"
xmlns:mvvm="http://www.galasoft.ch/mvvmlight"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
Title="MVVMLIghtDemo1" Height="500" Width="700" >
<Window.Resources>
<cvt:UserInfoConverter x:Key="userInfoConverter"></cvt:UserInfoConverter>
</Window.Resources>
<Window.DataContext>
<Binding Path="Main" Source="{StaticResource Locator}"></Binding>
</Window.DataContext>
<StackPanel>
<StackPanel>
<GroupBox Header="带string类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserList:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<Label Content="{Binding Path=UserList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<TextBox Width="200" Name="tbUser"></TextBox>
<Button Content="AddUser" Command="{Binding AddUserCommand}" CommandParameter="{Binding ElementName=tbUser,Path=Text}"></Button>
<CheckBox Content="IsCanAdd" VerticalAlignment="Center" FontSize="16" IsChecked="{Binding IsCanAddUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="带对象类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FF127C0D" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxUser" FontSize="16" />
<Label Content="Password:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxPwd" FontSize="16" />
<Button Content="AddUser" Command="{Binding AddUserCommandWithObjPar}">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource userInfoConverter}">
<Binding ElementName="tbxUser" Path="Text"/>
<Binding ElementName="tbxPwd" Path="Text"/>
</MultiBinding>
</Button.CommandParameter> </Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Parameter:" FontSize="16" ></Label>
<Label Content="{Binding ObjParameter}" FontSize="16" ></Label> </StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="事件转命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel>
<ListBox x:Name="lb" ItemsSource="{Binding ListBoxData}" BorderThickness="0" SelectedIndex="{Binding SelectIndex}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<mvvm:EventToCommand Command="{Binding SelectionChangedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel> <ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="AntiqueWhite" BorderThickness="1">
<StackPanel Margin="2"> <Image Source="{Binding Img}" Width="96" Height="96"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding Info}"/> </StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label Content="您选择的是:" FontSize="16" ></Label>
<Label Content="{Binding Path=SelResult,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" />
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> </StackPanel>
</Window>
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using MvvmLightDemo1.Model;
using System.Collections;
using System.Collections.ObjectModel;
using System.Windows.Input; namespace MvvmLightDemo1.ViewModel
{
public class MainViewModel : ViewModelBase
{
private WelcomeModel welcomeModel;
public WelcomeModel WelcomeModel
{
get { return welcomeModel; }
set { welcomeModel = value; RaisePropertyChanged(() => WelcomeModel); }
} private string objParameter = ""; public string ObjParameter
{
get { return objParameter; }
set
{
objParameter = value;
RaisePropertyChanged();
}
} private int selectIndex = -1; public int SelectIndex
{
get { return selectIndex; }
set
{
selectIndex = value;
RaisePropertyChanged();
}
}
private string selResult = ""; public string SelResult
{
get { return selResult; }
set
{
selResult = value;
RaisePropertyChanged();
}
}
private IEnumerable listBoxData = new ObservableCollection<DataModel>()
{
new DataModel(){ Img="/MvvmLightDemo1;component/Img/1.png",Info=" Honey Peach " },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/2.png",Info="Tomato" },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/3.png",Info="Banana" },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/4.png",Info="Chilli " },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/5.png",Info="Apple" },
};
/// <summary>
/// LisBox数据模板
/// </summary>
public IEnumerable ListBoxData
{
get { return listBoxData; }
set { listBoxData = value; RaisePropertyChanged(() => ListBoxData); }
}
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
WelcomeModel = new WelcomeModel() { WelcomeMsg = "Welcome to MVVMLight World!" };
} private string userList = "Mary"; public string UserList
{
get { return userList; }
set
{
userList = value;
RaisePropertyChanged();
}
}
private string user = ""; public string User
{
get { return user; }
set { user = value; }
}
private bool isCanAddUser = true; public bool IsCanAddUser
{
get { return isCanAddUser; }
set { isCanAddUser = value; }
} #region Command
private RelayCommand<string> addUserCommand; public RelayCommand<string> AddUserCommand
{
get
{
if (addUserCommand == null)
{
addUserCommand = new RelayCommand<string>(AddUser, (string p) => { return IsCanAddUser; });
}
return addUserCommand;
}
set { addUserCommand = value; }
}
private void AddUser(string par)
{
UserList = UserList + " " + par;
} private RelayCommand<UserModel> addUserCommandWithObjPar; public RelayCommand<UserModel> AddUserCommandWithObjPar
{
get
{
if (addUserCommandWithObjPar == null)
{
addUserCommandWithObjPar = new RelayCommand<UserModel>(AddUserWithObjPar);
}
return addUserCommandWithObjPar;
}
set { addUserCommandWithObjPar = value; }
}
private void AddUserWithObjPar(UserModel par)
{
ObjParameter = "UserName: "+ par.UserName + " Password: " + par.PassWord;
} private RelayCommand selectionChangedCommand; public RelayCommand SelectionChangedCommand
{
get
{
if (selectionChangedCommand == null)
{
selectionChangedCommand = new RelayCommand(SelectChange);
}
return selectionChangedCommand;
}
set { selectionChangedCommand = value; }
}
private void SelectChange()
{
int i = 0;
foreach(var a in ListBoxData)
{
if(i == SelectIndex)
{
SelResult = (a as DataModel).Info;
break;
}
i++;
}
}
#endregion }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MvvmLightDemo1.Model
{
public class DataModel
{
private string img; public string Img
{
get { return img; }
set { img = value; }
} private string info; public string Info
{
get { return info; }
set { info = value; }
}
}
}
运行结果如下:
五、带原事件参数的命令绑定
代码片段如下:
<StackPanel>
<GroupBox Header="带事件参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FF127C0D" Margin="2"> <StackPanel Orientation="Horizontal">
<Button Content="拖拽上传文件" AllowDrop="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Drop">
<mvvm:EventToCommand PassEventArgsToCommand="True" Command="{Binding DropCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Label Content="FilePath:" FontSize="16" ></Label>
<Label Content="{Binding DraggedFilePath}" FontSize="16" ></Label> </StackPanel> </GroupBox>
</StackPanel>
private RelayCommand<DragEventArgs> dropCommand;
/// <summary>
/// 传递原事件参数
/// </summary>
public RelayCommand<DragEventArgs> DropCommand
{
get
{
if (dropCommand == null)
dropCommand = new RelayCommand<DragEventArgs>(e => ExecuteDrop(e));
return dropCommand;
}
set { dropCommand = value; }
} private void ExecuteDrop(DragEventArgs e)
{
DraggedFilePath = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(0).ToString();
}
注:本系列文章参考
https://www.cnblogs.com/wzh2010/p/6607702.html
MVVMLight学习笔记(五)---RelayCommand深究的更多相关文章
- C#可扩展编程之MEF学习笔记(五):MEF高级进阶
好久没有写博客了,今天抽空继续写MEF系列的文章.有园友提出这种系列的文章要做个目录,看起来方便,所以就抽空做了一个,放到每篇文章的最后. 前面四篇讲了MEF的基础知识,学完了前四篇,MEF中比较常用 ...
- (转)Qt Model/View 学习笔记 (五)——View 类
Qt Model/View 学习笔记 (五) View 类 概念 在model/view架构中,view从model中获得数据项然后显示给用户.数据显示的方式不必与model提供的表示方式相同,可以与 ...
- java之jvm学习笔记五(实践写自己的类装载器)
java之jvm学习笔记五(实践写自己的类装载器) 课程源码:http://download.csdn.net/detail/yfqnihao/4866501 前面第三和第四节我们一直在强调一句话,类 ...
- Learning ROS for Robotics Programming Second Edition学习笔记(五) indigo computer vision
中文译著已经出版,详情请参考:http://blog.csdn.net/ZhangRelay/article/category/6506865 Learning ROS for Robotics Pr ...
- Typescript 学习笔记五:类
中文网:https://www.tslang.cn/ 官网:http://www.typescriptlang.org/ 目录: Typescript 学习笔记一:介绍.安装.编译 Typescrip ...
- ES6学习笔记<五> Module的操作——import、export、as
import export 这两个家伙对应的就是es6自己的 module功能. 我们之前写的Javascript一直都没有模块化的体系,无法将一个庞大的js工程拆分成一个个功能相对独立但相互依赖的小 ...
- muduo网络库学习笔记(五) 链接器Connector与监听器Acceptor
目录 muduo网络库学习笔记(五) 链接器Connector与监听器Acceptor Connector 系统函数connect 处理非阻塞connect的步骤: Connetor时序图 Accep ...
- python3.4学习笔记(五) IDLE显示行号问题,插件安装和其他开发工具介绍
python3.4学习笔记(五) IDLE显示行号问题,插件安装和其他开发工具介绍 IDLE默认不能显示行号,使用ALT+G 跳到对应行号,在右下角有显示光标所在行.列.pycharm免费社区版.Su ...
- Go语言学习笔记五: 条件语句
Go语言学习笔记五: 条件语句 if语句 if 布尔表达式 { /* 在布尔表达式为 true 时执行 */ } 竟然没有括号,和python很像.但是有大括号,与python又不一样. 例子: pa ...
- 【opencv学习笔记五】一个简单程序:图像读取与显示
今天我们来学习一个最简单的程序,即从文件读取图像并且创建窗口显示该图像. 目录 [imread]图像读取 [namedWindow]创建window窗口 [imshow]图像显示 [imwrite]图 ...
随机推荐
- 鸟哥的Linux私房菜基础学习篇--进程(process)一 归纳总结
权限!权限!权限! 没有权限,一些资源你是没办法使用的.在Linux中cat filename,结果屏幕显示了filename的内容,为什么你能看见,而我不能?权限.与UID/GID有关,与文件的属性 ...
- 家庭账本开发day06
编写查询页面,学习layUI的动态表格使用,绑定数据源, table.render({ elem: '#currentTableId', url: '../ ...
- 42 张图带你撸完 MySQL 优化
Hey guys,这里是程序员cxuan,欢迎你阅读我最新一期的文章,这篇文章是 MySQL 调优的汇总版,我加了一下日常开发过程中的调优经验,希望对各位小伙伴们有所帮助.下面开始正文. 一般传统互联 ...
- JAVA-Scaneer对象
Scanner对象 我们可以通过scanner来获取用户的输入 基本语法 Scanner s = new Scanner(System.in); nextLine():输入 import java.u ...
- synchronized锁定类方法、volatile关键字及其他(八)
同步静态方法 synchronized还可以应用在静态方法上,如果这么写,则代表的是对当前.java文件对应的Class类加锁.看一下例子,注意一下printC()并不是一个静态方法: public ...
- HTMLTestRunner.py 文件,已修改完成
""" A TestRunner for use with the Python unit testing framework. It generates a HTML ...
- 性能测试之查看cpu命令
top -m 用户空间进程(us). 内核空间进程(sy). 高nice值的用户空间进程(ni). 空闲(id). 空闲等待io(wa). 中断上半部(hi). 中断下半部(si). 以及steal时 ...
- Intouch/ifix语音报警系统制作(3-利用自定义过程和函数,重构先前版本)
在语音模块嵌入了半年左右的时间,经过实际使用发现,代码冗余,重复太多,维护较难,新增也不易,故而对整个框架进行整理,实现简单添加,维护容易的目的. 1.代码优化 1.1构建自定义过程 name 参数代 ...
- 如何在 NetCore 中定义我们自己的JSON配置文件的管理器。
一.介绍 微软已经对外提供了新的平台,我们叫它们是 Net Core 平台,这个平台和 Net Framework 平台有本质的区别,这个最本质的区别就是微软的C#代码可以跨平台了.当前我们主流的3大 ...
- 18Oracle入门
1 Oracle的服务 Oracle的监听服务:OralceOraDB12Home1TNSListener 需要通过程序链接数据库进行开发的时候,此服务必须打开,如果只是在本机使用,此服务可不启动 O ...