首页 文章 精选 留言 我的

精选列表

搜索[c 17],共10016篇文章
优秀的个人博客,低调大师

Solon 1.6.15 发布,增加部分 JDK 17 特性支持

关于官网 千呼万唤始出来:https://solon.noear.org。整了一个月多了。。。还得不断接着整! 关于 Solon Solon 是一个轻量级应用开发框架。支持 Web、Data、Job、Remoting、Cloud 等任何开发场景。短小而精悍! 强调,克制 + 简洁 + 开放的原则 力求,更小、更快、更自由的体验 目前已有近130个生态插件,含盖了日常开发的各种需求。 关于 Solon Cloud Solon Cloud 定义了一系列分布式开发的接口标准和配置规范,相当于DDD模式里的防腐层概念。是 Solon 的微服务架构模式开发解决方案。 本次主要更新 增加对 kotlin data class 和 jdk14+ record 的序列化、反序列化及注入支持 public record User(String username, Integer age) { } @Controller public class DemoController{ @Mapping("/test") public void test(User user){ } } @Service 增加 name, typed 属性 //通过 name 指定 bean name;通过 typed 注册类型 bean,即 DemoService 的默认实现 @Service(name="DemoService-CN", typed=true) public class DemoServiceCnImpl implements DemoService{ } //上面这种方式需要“编译时”确定默认bean(注:当没有name时,都是默认bean) // //基于Solon的特性,还有一种“运行时”确定的方案 // @Service(name="DemoService-CN") public class DemoServiceCnImpl implements DemoService{ public DemoServiceCnImpl(){ if("CN".equals(Solon.cfg().get("datacenter.region", "CN"))){ Aop.wrapAndPut(DemoService.class, this); } } } 优化 sqltoy-solon-plugin 插件,增加便利的多数据源控制和切换 @Service public class DemoService{ @Db SqlToyLazyDao dao1; @Db("db2") SqlToyLazyDao dao2; } 新增 solon.extend.async 插件 @Service public class AsyncTask { //会被异步运行(提交到异步执行器运行)//不要有返回值(返回也拿不到) @Async public void test(String hint){ System.out.println(Thread.currentThread().getName()); } } 修复 当主应用配置有变量时,应用环境配置无法替换的问题 优化 Aop.beanForeach ,进行去重处理 增加 三种日期格式自动解析 快速了解 Solon 《想法与架构笔记》 《生态预览》 《与 Spring Boot 的区别?》 《与 Spring Cloud 的区别?》

优秀的个人博客,低调大师

ios17--自定义控件2改进

控制器: // // XMGViewController.h #import <UIKit/UIKit.h> @interface XMGViewController : UIViewController@end // // XMGViewController.m #import "XMGViewController.h" #import "XMGShop.h" #import "XMGShopView.h" @interface XMGViewController () @property (weak, nonatomic) IBOutlet UIView *shopCarView; @property (weak, nonatomic) IBOutlet UIButton *addButton; @property (weak, nonatomic) IBOutlet UIButton *removeButton; @property (nonatomic, strong) NSArray *dataArr; @end @implementation XMGViewController /** * 懒加载 */ - (NSArray *)dataArr{ if (_dataArr == nil) { // 加载数据 // 1.获取全路径 NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"shopData.plist" ofType:nil]; self.dataArr = [NSArray arrayWithContentsOfFile:dataPath]; // 字典转模型 // 创建临时数组 NSMutableArray *tempArray = [NSMutableArray array]; for (NSDictionary *dict in _dataArr) { // 创建shop对象 XMGShop *shop = [XMGShop shopWithDict:dict]; // 把模型装入数组 [tempArray addObject:shop]; } self.dataArr = tempArray; } return _dataArr; } // 初始化数据 - (void)viewDidLoad { [super viewDidLoad]; } /** * 添加到购物车 * * @param button 按钮 */ - (IBAction)add:(UIButton *)button { /***********************1.定义一些常量*****************************/ // 1.总列数 NSInteger allCols = 3; // 2.商品的宽度 和 高度 CGFloat width = 80; CGFloat height = 100; // 3.求出水平间距 和 垂直间距 CGFloat hMargin = (self.shopCarView.frame.size.width - allCols * width) / (allCols -1); CGFloat vMargin = (self.shopCarView.frame.size.height - 2 * height) / 1; // 4. 设置索引 NSInteger index = self.shopCarView.subviews.count; // 5.求出x值 CGFloat x = (hMargin + width) * (index % allCols); CGFloat y = (vMargin + height) * (index / allCols); /***********************2.创建一个商品*****************************/ /* 原来的分开创建: // 1.创建商品的view UIView *shopView = [[UIView alloc] init]; // 2.设置frame shopView.frame = CGRectMake(x, y, width, height); // 3.设置背景颜色 shopView.backgroundColor = [UIColor greenColor]; // 4.添加到购物车 [self.shopCarView addSubview:shopView]; // 5.创建商品的UIImageView对象 UIImageView *iconView = [[UIImageView alloc] init]; iconView.frame = CGRectMake(0, 0, width, width); iconView.backgroundColor = [UIColor blueColor]; [shopView addSubview:iconView]; // 6.创建商品标题对象 UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.frame = CGRectMake(0, width, width, height - width); titleLabel.backgroundColor = [UIColor yellowColor]; titleLabel.textAlignment = NSTextAlignmentCenter; // 居中 [shopView addSubview:titleLabel]; */ XMGShopView *shopView = [[XMGShopView alloc] init]; shopView.frame = CGRectMake(x, y, width, height); [self.shopCarView addSubview:shopView]; // shopView.titleLabel = nil; /***********************3.设置数据*****************************/ // 设置数据 XMGShop *shop = self.dataArr[index]; /* shopView.iconView.image = [UIImage imageNamed:shop.icon]; shopView.titleLabel.text = shop.name; */ [shopView setIcon:shop.icon]; [shopView setName:shop.name]; /***********************4.设置按钮的状态*****************************/ button.enabled = (index != 5); // 5.设置删除按钮的状态 self.removeButton.enabled = YES; } /** * 从购物车中删除 * * @param button 按钮 */ - (IBAction)remove:(UIButton *)button { // 1. 删除最后一个商品 UIView *lastShopView = [self.shopCarView.subviews lastObject]; [lastShopView removeFromSuperview]; // 3. 设置添加按钮的状态 self.addButton.enabled = YES; // 4. 设置删除按钮的状态 self.removeButton.enabled = (self.shopCarView.subviews.count != 0); } @end 自定义控件: // // XMGShopView.h #import <UIKit/UIKit.h> @interface XMGShopView : UIView // readonly 只会调用get方法 /** 图片控件 */ //@property (nonatomic, weak, readonly) UIImageView *iconView;// [self addSubview:iconView];已经有强指针引用了,这里用weak /** 标题控件 */ //@property (nonatomic, weak, readonly) UILabel *titleLabel; // 提供接口方法 - (void)setIcon: (NSString *)icon; - (void)setName: (NSString *)name; @end // // XMGShopView.m #import "XMGShopView.h" @interface XMGShopView () //扩展属性 @property (nonatomic, strong) UIImageView *iconView;//[self addSubview:iconView];有强指针指向了,用weak @property (nonatomic, strong) UILabel *titleLabel; @end @implementation XMGShopView /** * 初始化子控件(不要设置frame) * */ - (instancetype)init{ if (self = [super init]) { // 1.创建商品的UIImageView对象 UIImageView *iconView = [[UIImageView alloc] init]; iconView.backgroundColor = [UIColor blueColor]; [self addSubview:iconView]; _iconView = iconView; // 2.创建商品标题对象 UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.backgroundColor = [UIColor yellowColor]; titleLabel.textAlignment = NSTextAlignmentCenter; // 居中 [self addSubview:titleLabel]; _titleLabel = titleLabel; } return self; } /** * 布局子控件(可以拿到frame) */ - (void)layoutSubviews{ // 0.一定要调用super [super layoutSubviews]; // 1.获取当前控件的尺寸 CGFloat width = self.frame.size.width; CGFloat height = self.frame.size.height; // 2.设置子控件的frame self.iconView.frame = CGRectMake(0, 0, width, width); self.titleLabel.frame = CGRectMake(0, width, width, height - width); } - (void)setIcon:(NSString *)icon{ // 设置数据 self.iconView.image = [UIImage imageNamed:icon]; } - (void)setName:(NSString *)name{ // 设置数据 self.titleLabel.text = name; } @end bean: // // XMGShop.h #import <Foundation/Foundation.h> @interface XMGShop : NSObject /** 图片的名称 */ @property (nonatomic, copy) NSString *icon; /** 商品的名称 */ @property (nonatomic, copy) NSString *name; // 提供构造方法 /* - (instancetype)initWithIcon: (NSString *)icon name: (NSString *)name; + (instancetype)shopWithIcon: (NSString *)icon name: (NSString *)name; */ - (instancetype)initWithDict:(NSDictionary *)dict; + (instancetype)shopWithDict:(NSDictionary *)dict; @end // // XMGShop.m #import "XMGShop.h" @implementation XMGShop /* - (instancetype)initWithIcon:(NSString *)icon name:(NSString *)name{ if (self = [super init]) { self.icon = icon; self.name = name; } return self; } + (instancetype)shopWithIcon:(NSString *)icon name:(NSString *)name{ return [[self alloc] initWithIcon:icon name:name]; } */ - (instancetype)initWithDict:(NSDictionary *)dict{ if (self = [super init]) { self.icon = dict[@"icon"]; self.name = dict[@"name"]; } return self; } + (instancetype)shopWithDict:(NSDictionary *)dict{ return [[self alloc] initWithDict:dict]; } @end 本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/7466778.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

C# 调用C++ DLL

总结遇到的引用各种问题:(建议使用x86的编译方式)​ [DllImport(@"XXX.dll", EntryPoint = "TOEC_ComInit", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] public static extern int Com_Init(int flag); 第一个参数:就是引用的DLL名称; 第二个参数【EntryPoint】:指示要调用的 DLL 入口点的名称或序号;就是DLL中要调用的方法名称; 第三个参数【CharSet】:指示如何向方法封送字符串参数,并控制名称重整;就是编码格式; 第四个参数【ExactSpelling】:控制 System.Runtime.InteropServices.DllImportAttribute.CharSet 字段是否使公共语言运行时在非托管,DLL 中搜索入口点名称,而不使用指定的入口点名称。 第五个参数【CallingConvention】:指示入口点的调用约定 (1)Winapi:此成员实际上不是调用约定,而是使用了默认平台调用约定。例如,在 Windows 上默认为 System.Runtime.InteropServices.CallingConvention.StdCall,在Windows CE.NET 上默认为 System.Runtime.InteropServices.CallingConvention.Cdecl。(2)Cdecl:调用方清理堆栈。这使您能够调用具有 varargs 的函数(如 Printf),使之可用于接受可变数目的参数的方法。(3)StdCall:被调用方清理堆栈。这是使用平台 invoke 调用非托管函数的默认约定。(4)ThisCall:第一个参数是 this 指针,它存储在寄存器 ECX 中。其他参数被推送到堆栈上。此调用约定用于对从非托管 DLL 导出的类调用方法。(5)FastCall:不支持此调用约定。 遇到的问题:CallBack::Invoke”类型的已垃圾回收委托进行了回调。这可能会导致应用程序崩溃、损坏和数据丢失。向非托管代码传递委托时,托管应用程序必须让这些委托保持活动状态,直到确信不会再次调用它们。 解决办法: 回调函数写成全局静态成员函数。 原始错误的写法: [DllImport(@"COM_DLL.dll", EntryPoint = "TOEC_ComRun", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Winapi)] public static extern int CPP_Run(CallBack cb); public delegate void CallBack(tagOutInfo data); CPP_Run(handle_sx, par, CallBack_Function); public static void CallBack_Function(tagOutInfo data) { //..... } 正确的写法: [DllImport(@"COM_DLL.dll", EntryPoint = "TOEC_ComRun", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Winapi)] public static extern int CPP_Run(CallBack cb); public delegate void CallBack(tagOutInfo data); private CallBack cb_f; CPP_Run(handle_sx, par, cb_f ); public void Init(){ cb_f=CallBack_Function; } public void CallBack_Function(tagOutInfo data) { //.....回调函数体 } ​

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册