首页 \ 问答 \ 如何编写我的包装类以使用部分泛型类型推断?(How do I write my wrapper class to use partial generic type inference?)

如何编写我的包装类以使用部分泛型类型推断?(How do I write my wrapper class to use partial generic type inference?)

这与这个问题有关

我想创建一个通用的包装类:

public abstract class Wrapper<T>
{
    internal protected T Wrapped { get; set; }
}

有以下扩展:

public static class WrapperExtensions
{
    public static W Wrap<W,T>(this T wrapped) where W:Wrapper<T>,new()
    {
        return new W {Wrapped = wrapped};
    }

    public static T Unwrap<T>(this Wrapper<T> w)
    {
        return w.Wrapped;
    }
}

现在假设一个具体的包装器:

public class MyIntWrapper : Wrapper<int>
{
    public override string ToString()
    {
        return "I am wrapping an integer with value " + Wrapped;
    }
}

我想要这样调用Wrap扩展:

MyIntWrapper wrapped = 42.Wrap<MyIntWrapper>(); 

这是不可能的,因为在c#中我们需要为Wrap扩展提供两个类型参数。 (这是全部或没有)

显然F#中可能有部分推理。

上面的代码在F#中看起来如何?

有可能从C#使用它吗?


This is related to this question.

I'd like to create a generic wrapper class:

public abstract class Wrapper<T>
{
    internal protected T Wrapped { get; set; }
}

With the following extensions:

public static class WrapperExtensions
{
    public static W Wrap<W,T>(this T wrapped) where W:Wrapper<T>,new()
    {
        return new W {Wrapped = wrapped};
    }

    public static T Unwrap<T>(this Wrapper<T> w)
    {
        return w.Wrapped;
    }
}

Now assume a concrete Wrapper:

public class MyIntWrapper : Wrapper<int>
{
    public override string ToString()
    {
        return "I am wrapping an integer with value " + Wrapped;
    }
}

I would like to call the Wrap extension like this:

MyIntWrapper wrapped = 42.Wrap<MyIntWrapper>(); 

This is not possible because in c# we need to provide both type arguments to the Wrap extension. (it's all or nothing)

Apparently partial inference is possible in F#.

How would the above code look in F#?

Would it be possible to use it from C#?


原文:https://stackoverflow.com/questions/14058654
更新时间:2023-02-04 21:02

最满意答案

所以我想知道,是否有可能?

是。 这是可能的。 您可以将所有功能放在一个APK中,并且可以检查您正在运行的平台(制造商)并执行制造商特定的API。

如果是,那么想了解在应用商店中创建不同供应商特定应用的原因。

我不确定HTC应用程序。

人们创建(之前)独立三星应用程序的原因是签名。 执行privedged API的代码应该由三星签署。 MDM公司不希望将他们想要放在Google Play上的每个次要版本提交给三星签署(它将很容易消耗很多时间框架)。

因此,MDM公司将其分解为两个APK。 一个非常有限的制造商特定API,它很少变化,很少由三星签署。 另一个使用公共代码,可以通过自己的密钥进行更改和签名。

三星改变了如何使用这些API的方式。 您无需向他们发送应用以进行审批。 然而,许多公司从未回过头来改变它。


So I want to know, is it possible or not?

Yes. It's possible. You can put all of your functionality in one APK and you can check on which platform (manufacturer) you are running and execute manufacturer specific API's.

If yes then would like to know the reason behind creating different vendor specific apps in app store.

I am not sure about HTC app.

The reason why people created (before) standalone Samsung app was to the signing. The code which executed privedged API's should have been signed by Samsung. MDM companies didn't want to submit each minor version which they want to put on Google Play to Samsung to sign (it will easily consume a lot of timeframe).

So, MDM companies broke it down to two APK. One with very limited manufacturer specific API's, which changes rarely and signed rarely by Samsung. And another with the common code, which can be changed and signed by their own keys.

Samsung changed the way how you can use these API's. You don't have to send apps to them for approval. However, a lot of companies never went back to change it.

相关问答

更多
  • 由于没有人回答,我正在回答自己。 基于此链接多个服务器连接到具有相同SSL证书的APNS ,我们只需要将我们的生产APNS证书分发给客户。 我想我们需要在客户网站即将到期时更新生产证书。 顺便说一句,也有可能为不同的客户看到链接有不同的生产APNS证书,我想挑战将是如何在有很多时管理这些证书。 如果您有这方面的经验,欢迎任何评论。 Since no one is answering, I am answering myself. Based on this link Multiple Servers Con ...
  • iOS 5增加了使用MDM将URL推送到应用程序清单到设备的功能,此时将询问用户是否要安装应用程序。 Apple MDM文档已更新为包含支持此操作所需的XML。 iOS 5 has added the ability to push a URL to the application manifest to the device using MDM, at which point the user will be asked if they want to install the application. T ...
  • 实际上,iOS MDM纯粹是服务器技术。 这意味着MDM客户端已集成在iOS中。 您可能已经看到的是一些安装在iOS设备上的MDM boostratp应用程序。 但是,它们所做的只是触发设备配置(安装MDM配置文件)。 但是,作为MDM协议的一部分,您可以获取设备的UDID(使用DeviceInformation命令)。 但是,您可以在服务器上(而不是在iOS应用程序中)获取它。 Actually, iOS MDM is purely server technology. Meaning that MDM ...
  • 所以我想知道,是否有可能? 是。 这是可能的。 您可以将所有功能放在一个APK中,并且可以检查您正在运行的平台(制造商)并执行制造商特定的API。 如果是,那么想了解在应用商店中创建不同供应商特定应用的原因。 我不确定HTC应用程序。 人们创建(之前)独立三星应用程序的原因是签名。 执行privedged API的代码应该由三星签署。 MDM公司不希望将他们想要放在Google Play上的每个次要版本提交给三星签署(它将很容易消耗很多时间框架)。 因此,MDM公司将其分解为两个APK。 一个非常有限的制造 ...
  • 据我所知,它基于这封邮件移到这里 : 如果您在iOS Developer Enterprise计划中创建了APNS MDM证书,请参阅Apple推送证书门户网站上的“了解有关MDM推送证书迁移的更多信息”链接 As I understand it moved here based on this mail: If you created your APNS MDM certificate in the iOS Developer Enterprise Program, please see the "Lea ...
  • 首先,请注意,目前只支持IOS和Android设备的MAM策略。 您的案例中的Windows应用程序不适用于MAM。 据我所知,Intune中没有用于处理用户身份验证的内置功能。 Intune中的用户实际上使用Azure AD进行身份验证。 但是,您可以使用Azure AD和ADFS来实现SSO,多重身份验证,条件访问等功能。 Firstly, please note that the MAM policies are only supported on IOS and Android devices at ...
  • 即使未安装协同服务器,应用程序也可以在手表上独立运行。 无论是否安装了手表应用程序,应用程序都可以在手机上运行。 在没有其他代理的情况下,应用程序是否仍然可以运行将取决于您的应用程序设计。 您需要安装Samsung Gear Manager应用程序。 在三星手机上,手机通常会自动指示用户在与手表配对时安装应用程序。 在Android应用程序上,他们需要从App商店中获取它。 最简单的检查方法是尝试连接它(findPeerAgent)。 如果未安装,您将无法找到对等代理。 虽然不是你问题的一部分,但有些人想知 ...
  • 是的,该应用程序可以在MDM之外工作(除非您使用传统的应用程序包装技术,现在不常用,例如Knox v1 app签名服务)。 重要提示:当应用程序运行时,依赖于MDM的功能需要以这样的方式进行编码,以便在MDM不可用时优雅地回退(例如,提示用户输入或禁用功能) Yes, the app can work outside of MDM (unless you use a legacy app-wrapping techniques, not commonly implemented today, e.g. Kn ...
  • 如果您使用“Ad-Hoc”配置文件对应用程序进行签名,则它将锁定到您在系统中拥有的设备的UDID。 这应该可以正常工作,只要您: 使用XCode解锁手机 确保同一部手机是个人资料的一部分 注册那个电话 推动应用程序 为了通过mdm将应用程序推送到世界上任何设备,您需要客户注册为ENTERPRISE开发人员计划(此注册需要DUNS编号,费用为300美元/年)。 完成后,您将能够创建允许在任何设备上安装的配置文件。 If you sign the app with 'Ad-Hoc' provisioning p ...
  • 是的你可以。 每个SDK通常都有自己的init方法,因此您可以构建逻辑来try..catch 。 但是,取决于您依赖的MDM功能以及您所使用的平台,所有MDM解决方案都可能提供,也可能不提供。 Yes you can. Each SDK typically has it's own kind of init method so you can build the logic to try..catch that. However, depending on MDM functionality you rel ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。