小编Tim*_*äki的帖子

如何从 IGrouping 中获取值?

我在列表上应用了 IGrouping<> - 这是它的样子:

IEnumerable<IGrouping<TierRequest,PingtreeNode>> Tiers
{
    get { return ActiveNodes.GroupBy(x => new TierRequest(x.TierID, x.TierTimeout, x.TierMaxRequests)); }
}
Run Code Online (Sandbox Code Playgroud)

稍后在我的代码中,我遍历层。使用 Key 元素获取关键数据很简单,但是如何获取IEnumerable<PingtreeNode>构成值部分的数据呢?

提前致谢

c# linq igrouping

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

AsyncInvoker没有发布Thread

我正在AsyncInvoker使用Jersey 2.0.这对我来说很好.但是,在完成返回后,线程不会结束.请注意,我不希望对我打电话的服务有任何回应.

public Future<Response> fire(WebTarget webTarget) {
    Future<Response> response = null;

    try {
        response = webTarget.request(MediaType.APPLICATION_JSON_TYPE)
                             .accept(MediaType.APPLICATION_JSON_TYPE)
                             .headers(headers)
                             .async().get();
    }

    catch (Exception e) {  
        e.printStackTrace();
    } 

    return response;
}
Run Code Online (Sandbox Code Playgroud)

java multithreading jax-rs jersey-client jersey-2.0

5
推荐指数
1
解决办法
296
查看次数

Roslyn / CSharpScript-如何保存/加载编译以避免编译等待时间

我正在尝试将c#脚本集成到我的数据库应用程序中。我正在使用globals对象来使全局变量可从脚本访问。

如果脚本是第一次编译,我对等待时间不满意。
如何保存和加载编译以避免等待时间?

Script<object> script = CSharpScript.Create(scriptCode, globalsType: typeof(MyGlobals));
script.Compile();   //<-- load the Compilation from database/file here
script.RunAsync(myGlobalsInstance).Wait();
Run Code Online (Sandbox Code Playgroud)

c# scripting roslyn

5
推荐指数
1
解决办法
2418
查看次数

Notification.Builder 添加操作

我想知道按下了哪个按钮,所以我在 onReceive 上执行此操作

Log.e(TAG, "Clicked " + extras.getInt("ACTION"));
Run Code Online (Sandbox Code Playgroud)

而且我总是,无论我按哪个按钮,都会得到 3 (ActionEnum.GO_TO_REMINDERS),即setContentIntent.

另一个问题是,除非我按下通知好友,否则通知不会关闭,但是当我按下按钮时它不会关闭。

public void createNotification(Context context, Reminder reminder) {
    // Build notification
    Notification noti = new Notification.Builder(context)
            .setContentTitle(reminder.getDisplayString())
            .setContentText("Pick Action")
            .setSmallIcon(R.drawable.icon_remider)
            .setContentIntent(
                    getPendingAction(context, reminder,
                            ActionEnum.GO_TO_REMINDERS))
            .addAction(R.drawable.icon, "Take",
                    getPendingAction(context, reminder, ActionEnum.TAKE))
            .addAction(R.drawable.icon, "Snooze",
                    getPendingAction(context, reminder, ActionEnum.SNOOZE))
            .addAction(R.drawable.icon, "Remove",
                    getPendingAction(context, reminder, ActionEnum.REMOVE))
            .build();

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    // hide the notification after its selected
    noti.flags |= Notification.FLAG_AUTO_CANCEL;

    notificationManager.notify(0, noti);

}

public PendingIntent getPendingAction(Context context, Reminder reminder,
        ActionEnum …
Run Code Online (Sandbox Code Playgroud)

notifications android push android-pendingintent

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

无法从其他应用程序(窗口)获取文本

我正在尝试从另一个应用程序中提取文本。这个应用程序现在可能很简单,我只是希望它能够工作(目前)。

我使用的代码:

public static class ModApi
{
    [DllImport("user32.dll", EntryPoint = "SendMessageTimeout", SetLastError =     true, CharSet = CharSet.Unicode)]
    public static extern uint SendMessageTimeoutText(IntPtr hWnd, int Msg, int countOfChars, StringBuilder text, uint flags, uint uTimeoutj, uint result);

    public static string GetText(IntPtr hwnd)
    {
        var text = new StringBuilder(1024);

        if (SendMessageTimeoutText(hwnd, 0xd, 1024, text, 0x2, 5000, 0) != 0)
        {
            return text.ToString();
        }

        MessageBox.Show(text.ToString());
        return "";
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用以下方式调用此代码:

IntPtr MytestHandle = new IntPtr(0x00788600);
HandleRef hrefHWndTarget = new HandleRef(null, MytestHandle);
Run Code Online (Sandbox Code Playgroud)

其中0x00788600是我正在运行的应用程序之一的示例(我 …

c# text extract

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

Visual Studio未显示已安装的Android api级别

我正在开发Visual Studio中的Android应用程序.在Android SDK管理器中,安装了从API级别23(Android 6.0)到API级别25(Android 7.1)的所有API.

但是当我在Visual Studio中打开项目属性时,"使用Android版编译"选项仅显示apis直到23(Android 6.0).我希望以7.1为目标,因为大多数智能手机现在都拥有它.

如果我使用Android 6.0,还有另一个问题.某些软件包如Xamarin.Firebase.Messaging无法安装,但出现以下错误.

Install-Package: Could not install package 'Xamarin.Firebase.Messaging 42.1001.0'. 
You are trying to install this package into a 
project that targets 'MonoAndroid,Version=v6.0', but the package does not contain
any assembly references or content files that are 
compatible with that framework. For more information, contact the package author.
Run Code Online (Sandbox Code Playgroud)

我可以看到API级别25下的所有可用选项都安装在SDK管理器中.请帮助我,以便我可以从Visual Studio Android应用程序中定位Android 7.1.谢谢

android xamarin.android xamarin visual-studio-2015

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

如何在 Xamarin.Forms 中的运行时动态添加条目字段

我正在使用 Xamarin.Forms 开发一个项目,我需要在运行时动态创建条目字段。

例如,用户会被要求输入一个团队中的球员数量,并根据用户提供的数据Entry为每个球员创建诸如姓名、年龄、联系人等字段。

c# xamarin xamarin.forms

4
推荐指数
2
解决办法
8233
查看次数

Xamarin.Forms HttpWebResponse 挂起/冻结

HttpWebResponse我的内部对象出现问题Task<T>

public async Task<string> Get(string url)
{
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri(urlAddress);
        WebRequest request = WebRequest.Create(url);

        Debug.WriteLine($"CHECKING 5000");

        using (var resp = (HttpWebResponse)await request.GetResponseAsync() as HttpWebResponse)
        {
            Debug.WriteLine($"CHECKING 10000");

            if (resp.StatusCode == HttpStatusCode.OK)
            {
                //var json = await result.Content.ReadAsStringAsync();
                //status = JsonConvert.DeserializeObject<MyResultObject>(json);

                Debug.WriteLine($"CHECKING = {resp.StatusCode}");
            }
        }
    }

    return "";
}
Run Code Online (Sandbox Code Playgroud)

我在这里有一些Debug.WriteLine()可以轻松查看我的代码到达的部分。

我可以看到Debug.WriteLine($"CHECKING 5000");
我看不到Debug.WriteLine($"CHECKING 10000");

我可以在浏览器中正常访问该网站,所以我不确定这里的问题是什么。

我可以做什么来查看为什么它不起作用然后修复它?

c# httpwebrequest xamarin xamarin.forms

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

将cookie放在Xamarin的WebView上

我在Xamarin项目中有以下计划:

  • 用户在MainPage上输入他的用户名和密码.
  • 如果数据正确(存在API),请导航到WebView并自动在此页面上登录用户.

现有API(非公共)提供System.Net.CookieCollection.

如何使用带有这些cookie的POST请求来实现我的想法?这是我的基础:

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class WebPage : ContentPage
{
    public WebPage(string url, CookieCollection cookies)
    {
        InitializeComponent();
        BindingContext = new MainPageViewModel();
        MyWebView.Source = "https://" + url;

    }
}
Run Code Online (Sandbox Code Playgroud)

亲切的问候,localhorst27

c# cookies post xamarin xamarin.forms

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

如何在xamarin.forms中的xaml中大写/小写resx绑定?

遵循xamarin本地化主题和样本TodoLocalized,我使我的应用程序多语言.我的问题有时候,我需要使用有时单词大写,我不想在resx文件中创建另一个翻译作为同一个单词的大写版本.实现这一目标的最佳方法是什么?如果可能延长这个translateextension?或者我应该使用IValueConvertor?如果是,如何在xaml中绑定它

    // You exclude the 'Extension' suffix when using in Xaml markup
        [ContentProperty("Text")]
        public class TranslateExtension : IMarkupExtension
        {
            readonly CultureInfo ci;
            const string ResourceId = "myApp.Resx.AppRes";

            public TranslateExtension()
            {
                if (Device.OS == TargetPlatform.iOS || Device.OS == TargetPlatform.Android)
                {
                    ci = DependencyService.Get<ILocalize>().GetCurrentCultureInfo();
                }
            }

            public string Text { get; set; }

            public object ProvideValue(IServiceProvider serviceProvider)
            {
                if (Text == null)
                    return "";

                ResourceManager resmgr = new ResourceManager(ResourceId
                                    , typeof(TranslateExtension).GetTypeInfo().Assembly);

                var translation = resmgr.GetString(Text, ci);

                if (translation …
Run Code Online (Sandbox Code Playgroud)

resx xamarin xamarin.forms

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

更新 Firebase 软件包后,“InstanceID”不包含“SetApnsToken”的定义

在我的 Xamarin.iOS 项目中,我更新了 Firebase nuget 包,完成更新后我开始收到此代码的错误

//You'll need this method if you set "FirebaseAppDelegateProxyEnabled": NO in GoogleService-Info.plist
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
    SISConst.PushInfo = new PushNotification();
    SISConst.PushInfo.DeviceID = deviceToken.ToString();
    NSUserDefaults.StandardUserDefaults.SetString(deviceToken.ToString(),"dToken");

#if DEBUG
    Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Sandbox);
#if RELEASE
    Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Prod);
}
Run Code Online (Sandbox Code Playgroud)

下面的行显示错误

Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Sandbox);
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅屏幕截图

在此处输入图片说明

我该如何解决这个问题?

xamarin.ios ios firebase xamarin firebase-cloud-messaging

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