有谁知道这个错误意味着什么?
它来自我的一个单位.添加空格或换档有时会解决它,有时候不会......
我正在使用Delphi 2007.
TRTTIProperty.SetValue()接受一个TValue实例,但如果提供的TValue实例基于不同的类型然后属性,事情就会爆炸.
例如
TMyObject = class
published
property StringValue: string read FStringValue write FStringValue;
end;
procedure SetProperty(obj: TMyObject);
var
context: TRTTIContext;
rtti: TRTTIType;
prop: TRTTIProperty;
value: TValue;
begin
context := TRTTIContext.Create;
rtti := context.GetType(TMyObject);
prop := rtti.GetProperty('StringValue');
value := 1000;
prop.SetValue(obj, value);
end;
Run Code Online (Sandbox Code Playgroud)
试图将值转换为字符串也不会工作.
prop.SetValue(obj, value.AsString);
prop.SetValue(obj, value.Cast(prop.PropertyType.Handle));
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
更新:
有些人想知道我为什么要为字符串分配一个整数,我会尝试解释.(实际上,我更希望将字符串分配给整数,但这不是那么相关......)
我想要实现的目标是在gui和模型之间建立一个普通的"中间人".我想以某种方式将textedit字段挂钩到属性.我没有为每个模型制作这样的中间人,而是希望新的RTTI/TValue对我有用.
我也是仿制药的新手,所以我不确定仿制药是如何帮助的.是否可以在运行时使用动态决定的类型实例化泛型,或者编译需要知道吗?
例如
TMyGeneric<T> = class
end;
procedure DoSomething( );
begin
prop := rtti.getProperty('StringValue');
mygen := TMyGeneric<prop.PropertyType>.Create;
//or
mygen := TMyGeneric<someModel.Class>.Create;
end;
Run Code Online (Sandbox Code Playgroud)
也许魔法的时代还未到来......我想我可以管理几个大案例结构......
我有一个带底部标签栏的视图.此视图在导航控制器上推送,因此顶部还有一个导航栏.在这个视图中,我想展示一个表视图,我从它自己的nib创建.当我将此视图添加为子视图时,它会与标签栏重叠.
有没有办法让这个子视图自动调整大小到顶部和底部栏之间的空闲空间?
如果没有,那么调整尺寸以适应的"正确"方法是什么?
-Vegar
我有一个带有一些TObjectList <>的对象 - 我尝试使用帮助形式SuperObject编码为JSON的字段.
TLogs = TObjectList<TLog>;
TMyObject = class(TObject)
private
FLogs: TLogs;
end;
Run Code Online (Sandbox Code Playgroud)
在SuperObjects代码内部,有一个ToClass过程,迭代字段并将它们添加到json结果中.
在此循环中,检查TRttiFields FieldType.如果它为零,则跳过该对象.
for f in Context.GetType(Value.AsObject.ClassType).GetFields do
if f.FieldType <> nil then
begin
v := f.GetValue(value.AsObject);
result.AsObject[GetFieldName(f)] := ToJson(v, index);
end
Run Code Online (Sandbox Code Playgroud)
我的通用列表字段的FieldType为nil.为什么?
如何让SuperObject序列化我的对象列表?
我想从xml文件中获取一组元素,但是一旦元素涉及名称空间,它就会失败.
这是xml文件的一个片段:
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
version="1.0" creator="Groundspeak Pocket Query"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0 http://www.groundspeak.com/cache/1/0/cache.xsd"
xmlns="http://www.topografix.com/GPX/1/0">
<name>My Finds Pocket Query</name>
<desc>Geocache file generated by Groundspeak</desc>
<author>Groundspeak</author>
<email>contact@groundspeak.com</email>
<time>2010-09-15T16:18:55.9846906Z</time>
<keywords>cache, geocache, groundspeak</keywords>
<bounds minlat="41.89687" minlon="5.561883" maxlat="70.669967" maxlon="25.74735" />
<wpt lat="62.244933" lon="25.74735">
<time>2010-01-11T08:00:00Z</time>
<name>GC22W1T</name>
<desc>Kadonneet ja karanneet by ooti, Traditional Cache (1.5/2)</desc>
<url>http://www.geocaching.com/seek/cache_details.aspx?guid=4af28fe9-401b-44df-b058-5fd5399fc083</url>
<urlname>Kadonneet ja karanneet</urlname>
<sym>Geocache Found</sym>
<type>Geocache|Traditional Cache</type>
<groundspeak:cache id="1521507" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0">
<groundspeak:name>Kadonneet ja karanneet</groundspeak:name>
<groundspeak:placed_by>ooti</groundspeak:placed_by>
<groundspeak:owner id="816431">ooti</groundspeak:owner>
<groundspeak:type>Traditional Cache</groundspeak:type>
<groundspeak:container>Small</groundspeak:container>
<groundspeak:difficulty>1.5</groundspeak:difficulty>
<groundspeak:terrain>2</groundspeak:terrain>
<groundspeak:country>Finland</groundspeak:country>
<groundspeak:state>
</groundspeak:state>
<groundspeak:short_description html="True">
</groundspeak:short_description>
<groundspeak:encoded_hints>
</groundspeak:encoded_hints> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Thinktecture.IdentityModel 中的ResourceAuthorize
属性,但一切都停止了,因为没有 owin 上下文。
我有一个设置授权管理器的 owin 启动类
[assembly: OwinStartup(typeof(My.WebApi.Startup))]
namespace My.WebApi
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
AuthConfig.Configure(app);
}
}
}
public class AuthConfig
{
public static void Configure(IAppBuilder app)
{
app.UseResourceAuthorization(new ResourceAuthorizationMiddlewareOptions
{
Manager = GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IResourceAuthorizationManager)) as IResourceAuthorizationManager
});
}
}
Run Code Online (Sandbox Code Playgroud)
我知道它被检测到并被调用。但是后来,当从 中点击以下代码时IdentityModel
,我得到一个空指针异常:
public static Task<bool> CheckAccessAsync(this HttpRequestMessage request, IEnumerable<Claim> actions, IEnumerable<Claim> resources)
{
var authorizationContext = new ResourceAuthorizationContext(
request.GetOwinContext().Authentication.User ?? Principal.Anonymous,
actions,
resources);
return request.CheckAccessAsync(authorizationContext);
}
Run Code Online (Sandbox Code Playgroud)
我已经通过并看到它是由 GetOwinContext() …
我有一个TextBlock,使用当前文化的标准短日期格式显示日期.
String.Format(culture, "{0:d}", someDate)
Run Code Online (Sandbox Code Playgroud)
现在,产品经理希望以粗体突出显示年份.起初,我认为这很容易; 有一次运行绑定到日/月 - 部分,第二次运行到年份部分.
<TextBlock>
<Run Text="{Binding DayMonthPart}"/>
<Run FontWeight="Bold" Text="{Binding YearPart}"/>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
但那不会,因为不同的文化有不同的顺序.有些人把年份放在首位,有些人把它放在最后.
那么,我该如何实现呢?
有任何想法吗?
我正在使用resteasy做一个休息api ,并且放心地测试它.
假设我有message
一个属性的类text
.
@XmlRootElement
public class message {
@XmlElement
public String text;
}
Run Code Online (Sandbox Code Playgroud)
以下测试将尝试将此对象发布到给定的URL:
message msg = new message();
msg.text = "some message";
expect()
.statusCode(200)
.given()
.contentType("application/json")
.body(msg)
.when()
.post("/message");
Run Code Online (Sandbox Code Playgroud)
msg对象被序列化为json并发布,但不是按照我想要的方式 - 而不是以resteasy需要的方式,即.
发布了什么:
{ "text": "some message" }
Run Code Online (Sandbox Code Playgroud)
什么工作:
{ "message": { "text": "some message" } }
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何按预期工作?
我想这可能是一个"丢失的案例",但是可以用密码保护DocPad生成的一个或多个页面吗?
是否有可能制作一个插件或让你protected = true
在页面的元数据部分说出来的东西?
或者我必须使用.htaccess或类似物来保护我的页面?
我正在尝试使用nodegit打开一个包含以下代码的git存储库:
var git = require('nodegit');
git.Repo(repoPath, function(error, repository) {
if (error) throw error;
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误,无论我分配repoPath
变量:
git.Repo(repoPath, function(error, repository) {
^
Error: git_repository is required.
Run Code Online (Sandbox Code Playgroud)
我试过路径到本地文件夹,我已经尝试过路径到本地文件夹,包括.git
文件夹,我已经尝试过使用url的远程仓库.没什么.
任何人都可以帮忙吗?
我正在使用
节点v0.10.24
nodegit v0.1.4.
git 1.9.0.msysgit.0
win 8.1 pro 64bit