小编dev*_*969的帖子

开机后启动画面处理/删除

我在xamarin android应用程序中启动了启动屏幕,发生的是启动屏幕始终作为背景出现在其他页面上。

无论我做什么,都在那里。

我试图“完成”该活动,NoHistory = true,但是什么也没有,使后台的其他页面无法显示。

取自 https://alexdunn.org/2017/02/07/creating-a-splash-page-for-xamarin-forms-android/

有什么想法吗?

      [Activity(Label = "MyApp",
    Theme = "@style/MyTheme.Splash",
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    NoHistory = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.tabs;
            ToolbarResource = Resource.Layout.toolbar;

            base.OnCreate(bundle);

            Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App(new AndroidInitializer()));      

        }
    }


     [Activity(
            Theme = "@style/MyTheme.Splash",
            MainLauncher = true,
            NoHistory = true,
            ScreenOrientation = ScreenOrientation.Portrait)]
        public class SplashActivity : AppCompatActivity
        {

            public override void OnCreate(Bundle savedInstanceState, PersistableBundle …
Run Code Online (Sandbox Code Playgroud)

xamarin.android xamarin

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

HttpResponseMessage 你处理了吗?

在等待新的闪亮HttpClientFactory解决所有问题的同时HttpClient

我仍然无法找到是否HttpResponseMessageHttpRequestMessage应该处置的答案。

像下面这样的东西是一种很好的做法吗?

您是否使用 Using 语句HttpResponseMessage

//httpClient has been injected

using (HttpResponseMessage messageResponse = await httpClient.GetAsync(uri, cancellationToken).ConfigureAwait(false))
{
    using (HttpContent content = messageResponse.Content)
    {
        if (messageResponse.IsSuccessStatusCode)
        {
            var json  = await content.ReadAsStringAsync();
            var response = await Task.Run(() => JsonConvert.DeserializeObject<TResponse>(json, serializerSettings));

            return new MyWrapperResponse<TResponse>(messageResponse,response);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# dotnet-httpclient asp.net-web-api2 asp.net-core-webapi

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

Xamarin Essentials FileSystem 可以保存异步吗

查看 Xamarin 基本要素并想知道 FileSystem 的目的是什么。

我一直在寻找可以立即为我异步加载和保存文件的东西。

它在我看来,可能是我不理解它给您的唯一功能是保存和加载文件的位置,并且没有实际为您保存它的功能,例如“旧 PCLStorage”

这样对吗?

xamarin

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

如何设置子模块 Azure DevOps

有人可以澄清 SubModule 如何在 azure devops 中工作

MyDevOps 根文件夹

我有一个名为 MyCore.sln 的解决方案,其中包含 4-5 个项目

我有一个名为 MyMain.sln 的主解决方案,其中包含另外 4-5 个引用 MyCore.sln 项目的项目

  • 这一切都在本地编译和工作,但在 azure devops 中构建时失败

  • 进入powershell中的MyMain.sln文件夹并执行如下

  • 执行如下 git submodule add https://myGroup@dev.azure.com/MyGroup/MyProjec/_git/MyCore

  • 我现在可以在我的 Main Repo 中看到一个名为 MyCore 的文件夹,里面有项目,我开始引用它们
  • 我可以看到 .gitmodules 文件

    但是,当我去构建管道时,它找不到引用的项目(属于 myCore 存储库)

我错过了明显的吗?

是否有关于如何在 azure devops 中设置子模块的全面说明?

我可以在任何地方想象这个吗?

git git-submodules azure-devops azure-pipelines azure-repos

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

如何以xamarin形式检测设备是大还是小

如何检测设备是小还是大?我不需要检测是否是平板电脑。

这个概念取自https://devblogs.microsoft.com/xamarin/styling-for-multiple-device-resolutions/

我们使用下面的方法并相应地加载适当的样式,但是因为我没有考虑密度,所以它不准确。

我怎样才能改进或重写这个方法,以便它给我一个更好的结果,并更准确地检测设备是大还是小。

当前的

const int smallWightResolution = 768;
const int smallHeightResolution = 1280;

public static bool IsASmallDevice()
{
        // Get Metrics
        var mainDisplayInfo = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo;

        // Width (in pixels)
        var width = mainDisplayInfo.Width;

        // Height (in pixels)
        var height = mainDisplayInfo.Height;
        return (width <= smallWightResolution && height <= smallHeightResolution);
  }
Run Code Online (Sandbox Code Playgroud)

尝试使用密度但不知道公式是什么

public static bool IsSmallDevice()
{ 
    //we don't support tablet so tablet don't apply.

    int smallWidthResolution = 768;
    int smallHeightResolution = 1280;
    double screenWidth;
    double screenHeight;
    bool …
Run Code Online (Sandbox Code Playgroud)

xamarin.forms xamarin.essentials

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

如何嵌套/合并 2 个或更多部分类 .net vs2022

我有一组部分类,我想嵌套。

如果我想手动完成,我需要修改什么?过去有一些 Visual Studio 扩展,但不适用于 vs2022

谢谢

更新

假设我有一个名为 MyService.cs 的类,但我想创建像这样的部分类

MyService.AAA.cs MyService.BBB.cs MyService.CCC.cs

我希望它们像下面的图片一样嵌套(只是一个示例)

在此输入图像描述

c# visual-studio

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

从 .net core api2 调用 asmx 服务

我需要从 .net core web api 调用旧的 asmx web 服务(我无法控制)

是否可以?

谢谢

asp.net-web-api .net-core

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

Prism Xamarin GetCurrentPage 是否有可能

将 Prism 用于 xamarin 时,是否可以获取导航堆栈中的当前页面?

我注意到有

 PageUtilities.GetCurrentPage(mainPage).
Run Code Online (Sandbox Code Playgroud)

上面的用法是什么?

我正在寻找类似 navigationService.GetCurrentPage() 的东西

非常感谢

prism xamarin.forms

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

.tfignore与2017年不兼容

我见过很少的网络帖子和解决方案,但似乎没有用。我想念明显的东西吗?这就是我所拥有的

在解决方案级别而不是程序包所在的位置,我有一个文件夹,如下图所示

在此处输入图片说明

.tfignore包含以下内容

# Ignore NuGet Packages
    *.nupkg   

    # Ignore the NuGet packages folder in the root of the repository. If needed, prefix 'packages'
    # with additional folder names if it's not in the same folder as .tfignore.   
    packages


    # Omit temporary files
    project.lock.json
    project.assets.json
    *.nuget.props
Run Code Online (Sandbox Code Playgroud)

nuget.config.xml包含

        <?xml version="1.0" encoding="utf-8"?>
        <configuration>
          <solution>
            <add key="disableSourceControlIntegration" value="true" />
          </solution>
        </configuration>
Run Code Online (Sandbox Code Playgroud)

当我尝试在Visual Studio 2017中签入项目时,它仍显示所有包。

有人可以帮我解决我做错的事情吗?

谢谢

tfs visual-studio-2017

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

替换 bash 和 azuredevops 类中的字符串(ios xamarin 管道)

我正在尝试编写一个 bash 脚本来更改我的 azure devops 管道的类中的字符串。但无法使其工作。

从https://github.com/Microsoft/appcenter-build-scripts-examples/blob/master/xamarin/app-constants/appcenter-pre-build.sh复制脚本

我的 bash 尝试:

  1. 添加了 bash 任务(内联脚本)
  2. 创建了一个环境变量 API_URL,其值为“https://product.com/api”
  3. 我的班级要改变

    namespace Core
    {
       public class AppConstant
       {
         public const string ApiUrl = "https://production.com/api";
         public const string AnotherOne="AAA";
       }
    }        
    
    Run Code Online (Sandbox Code Playgroud)

我的剧本

    if [ ! -n "$API_URL" ]
    then
        echo "You need define the API_URL variable"
        exit
    fi

    APP_CONSTANT_FILE=$(Build.SourcesDirectory)/MyProject/Core/AppConstant.cs

    if [ -e "$APP_CONSTANT_FILE" ]
    then
        echo "Updating ApiUrl to $API_URL in AppConstant.cs"
        sed -i '' 's#ApiUrl = "[a-z:./]*"#ApiUrl = "'$API_URL'"#' $APP_CONSTANT_FILE

        echo "File content:"
        cat …
Run Code Online (Sandbox Code Playgroud)

bash azure-devops

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