小编Art*_*iom的帖子

拦截浏览器中的链接以打开我的Android应用

我希望能够在用户点击给定模式的URL而不是允许浏览器打开它时提示我的应用程序打开链接.这可能是当用户在浏览器或电子邮件客户端中的网页上或在新鲜应用中的WebView中时.

例如,从手机中的任意位置点击YouTube链接,您就有机会打开YouTube应用.

我如何为自己的应用程序实现此目的?

android url-interception intentfilter android-intent

105
推荐指数
1
解决办法
6万
查看次数

CodeFirst EF4.1 MVC针对遗留数据库 - 多重性冲突

无论我把它混合在一起,都会给我带来错误.我有一种感觉,我错过了一些明显的东西,因为我不断收到这些错误.

在模型生成期间检测到一个或多个验证错误:

System.Data.Edm.EdmAssociationType :: Multiplicity与关系'Venue_Courses'中Role'Venue_Courses_Source'中的引用约束冲突.由于"从属角色"中的所有属性都是不可为空的,因此"主体角色"的多重性必须为"1".

System.Data.Edm.EdmAssociationEnd :: Multiplicity在关系'Venue_Courses'中的角色'Venue_Courses_Target'中无效.由于"从属角色"是指关键属性,因此从属角色的多重性的上限必须为1.

一个课程只能有一个场地,许多课程都可以使用场地

public class Course
{
    [Key]
    public virtual int Id { get; set; }
    public string Title { get; set; }
    public DateTime StartDate { get; set; }
    public int VenueId { get; set; }

    public virtual Venue Venue { get; set; }
}

public class Venue
{
    [Key]
    public int Id { get; set; }
    public string Name { get; set; }

    public virtual ICollection<Course> Courses { get; set; }
} …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework ef-code-first asp.net-mvc-3

53
推荐指数
1
解决办法
2万
查看次数

如何使用样式中的附加属性?

我在ButtonStyle中创建了一个Image.现在我创建了一个附加属性,以便我可以为该图像设置Source.应该是直截了当但我坚持下去.

这是我缩短的ButtonStyle:

<Style x:Key="ToolBarButtonStyle"
        TargetType="Button">
    ...
    <Image x:Name="toolbarImage"
            Source="{TemplateBinding PrismExt:ImageSourceAttachable:ImageSource}"
            Width="48"
            Height="48" />
    ...
</Style>
Run Code Online (Sandbox Code Playgroud)

这是附加的属性定义,注意我不知道如何修复回调,因为dependencyproperty似乎是按钮而不是图像.而Button不会在我的风格中暴露我的Image.这很棘手.

namespace SalesContactManagement.Infrastructure.PrismExt
{
    public class ImgSourceAttachable
    {
        public static void SetImgSource(DependencyObject obj, string imgSource)
        {
            obj.SetValue(ImgSourceProperty, imgSource);
        }

        public static string GetImgSource(DependencyObject obj)
        {
            return obj.GetValue(ImgSourceProperty).ToString();
        }

        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ImgSourceProperty =
            DependencyProperty.RegisterAttached("ImgSource", typeof(string), typeof(ImgSourceAttachable), new PropertyMetadata(Callback));

        private static void Callback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //((Button)d).Source = …
Run Code Online (Sandbox Code Playgroud)

.net silverlight wpf dependency-properties attached-properties

35
推荐指数
1
解决办法
2万
查看次数

使用'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'找到的构造函数都没有

当我尝试使用Xml配置设置PARAMETER时,我收到以下错误:

在'LM.AM.Core.Services.EmailService'类型的'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'中找到的构造函数都不能使用可用的服务和参数调用:无法解析参数'System.String testSmtp'的构造函数'Void .ctor(System.String)'.

以下是相关文件:

web.config中

  <configSections>
    <section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
  </configSections>

  <autofac>
    <components>
      <component type="LM.AM.Core.Services.EmailService , LM.AM.Core" service="LM.AM.Core.Infrastructure.Services.IEmailService , LM.AM.Core.Infrastructure">
        <parameters>
          <parameter name="testSmtp" value="abc" />
        </parameters>
      </component>
    </components>
  </autofac>
Run Code Online (Sandbox Code Playgroud)

服务类

public class EmailService : IEmailService
{
    public string _testSmtp;

    public EmailService (string testSmtp)
    {
        _testSmtp = testSmtp;
    }
}
Run Code Online (Sandbox Code Playgroud)

注册

builder.RegisterType<EmailService>().As<IEmailService>().SingleInstance();
Run Code Online (Sandbox Code Playgroud)

Global.asax中

var builder = new ContainerBuilder();
builder.RegisterModule(new ConfigurationSettingsReader("autofac"));

builder.RegisterModule<Core.ModuleInstaller>();

builder.RegisterControllers(typeof(MvcApplication).Assembly);
AutofacContainer.Container = builder.Build();

var emailSvc = AutofacContainer.Container.Resolve<IEmailService>();
Run Code Online (Sandbox Code Playgroud)

我已经检查过容器是否知道xml参数,我尽可能接近Wiki,但由于某种原因,参数没有在唯一的构造函数上解析而且我收到了上述错误.

这应该很简单.任何人都可以提供一些建议,我可以尝试使其工作吗?

autofac

28
推荐指数
2
解决办法
6万
查看次数

如何设置Entity Framework Core迁移超时?

我正在使用最新的(1.0.0)版本的EF Core.我有一个迁移到一个相当大的数据库上运行.

我跑:

dotnet ef数据库更新-c ApplicationDbContext

得到:

超时已过期.操作完成之前经过的超时时间或服务器没有响应.

在连接字符串中,我明确地设置了超时,如下所示:

连接超时= 150000

不幸的是,它没有帮助.我该怎么做?

c# entity-framework entity-framework-core

20
推荐指数
3
解决办法
1万
查看次数

Android中的错误"SuperNotCalledException:Activity没有调用super.OnCreate()"

未捕获的处理程序:由于未捕获的异常,线程主要退出android.app.SuperNotCalledException:Activity没有调用super.OnCreate()

我的代码是:

  public void onCreate(Bundle savedInstanceState) {
        boolean isEnabled = Settings.System.getInt(this.getApplicationContext().getContentResolver(),Settings.System.AIRPLANE_MODE_ON, 0) == 1;


                Settings.System.putInt(this.getApplicationContext().getContentResolver(),Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);

                // Post an intent to reload
                Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
                //intent.putExtra("state",! isEnabled);//Call ON
                try {
                    Thread.sleep(15000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                intent.putExtra("state", isEnabled);
                                                                                           this.getApplicationContext().sendBroadcast(intent);


}
Run Code Online (Sandbox Code Playgroud)

android

16
推荐指数
2
解决办法
2万
查看次数

WPF和Listview.Shift - 选择多个项目.错误的开始项目

问题解释:

给出包含10个项目的列表.

  1. 我的第一个动作是(鼠标)点击第二个项目.
  2. 其次我有一个按钮,应该以编程方式选择一个项目.

例如:

listView.SelectedIndex = 4; 
//or
listView.SelectedItems.Add(listView.Items[4]);
Run Code Online (Sandbox Code Playgroud)

该项目已正确选择.

  1. 如果我现在按SHIFT并选择最后一项,则选择将从单击的项目开始,而不是以编程方式选择的项目.

一种解决方案是模拟鼠标点击事件,该事件有效,但有副作用.它也是hacky的方式.

似乎鼠标事件存储起始项目.

有什么我忽略了吗?

wpf listview multipleselection

9
推荐指数
1
解决办法
3489
查看次数

从 LiteDB 获取数据

我想知道如何将 console.writeline 数据存储在我的 litedb 数据库文件中。这是我的 POCO 课程

[BsonId]
public int Id { get; set; }
public DateTime Updated { get; set; }
public DateTime Last { get; set; }
public override string ToString()
{
    return string.Format("Id : {0}, Updated : {1}, Last Message : {2}",
        Id,
        Updated,
        Last);
}
Run Code Online (Sandbox Code Playgroud)

我在数据库中插入信息:

using (var db = new LiteDatabase(_dbLocation))
{
    var hist = db.GetCollection<MailBoxInfo>("History");
    var mail = new MailBoxInfo
    {
        Updated = DateTime.Now,
        Last = datemsg
    };
    hist.Insert(mail);
    hist.EnsureIndex("Updated");
}
Run Code Online (Sandbox Code Playgroud)

最后,尝试输出它:

using (var …
Run Code Online (Sandbox Code Playgroud)

c# litedb

6
推荐指数
1
解决办法
3938
查看次数

将DataGrid嵌入到WPF Treeview节点中

我需要在树视图中显示Hierarchy .但是细节应该显示在数据网格中.

我多么喜欢它

我如何编写模板来实现这一目标?我现在误解模板中的smth.

    <TreeView ItemsSource="{Binding Path=Categories}">
        <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type stackProjects:Category}" ItemsSource="{Binding Path=SubCategories}">
                <TextBlock Margin="3" Text="{Binding Path=CategoryName}"/>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type stackProjects:SubCategory}" ItemsSource="{Binding Path=Details}">
                <TextBlock Text="{Binding Path=SubCategoryName}"/>
            </HierarchicalDataTemplate>

            <DataTemplate DataType="{x:Type stackProjects:Detail}" >
                <StackPanel Orientation="Horizontal">
                    <TextBlock Margin="3" Text="{Binding Path=Name}"/>
                    <TextBlock Margin="3" Text=" - "/>
                    <TextBlock Margin="3" Text="{Binding Path=Info}"/>
                </StackPanel>
            </DataTemplate>
        </TreeView.Resources>
    </TreeView>
Run Code Online (Sandbox Code Playgroud)

wpf treeview datagrid datatemplate hierarchicaldatatemplate

4
推荐指数
1
解决办法
3924
查看次数

使用LINQ代替两个for循环

我想将这两个"丑陋" for循环转换为LINQ表达式.谁能帮我吗?我对LINQ很新.提前致谢!

foreach (Edge edge in distinctEdge)
{
    var c = 0;
    foreach(Edge e in EdgeList)
    {
        if(e.target == edge.target && e.source == edge.source)
        {
            c++;
        }
    }
    edge.value = c;
}
Run Code Online (Sandbox Code Playgroud)

c# linq

4
推荐指数
1
解决办法
631
查看次数