首页 \ 问答 \ 将事件接收器附加到内容类型(Attaching a event receiver to a content type)

将事件接收器附加到内容类型(Attaching a event receiver to a content type)

我创建了一些网站列/内容类型和列表定义作为功能的一部分。 我想将一个eventreceiver附加到内容类型。 我添加了将事件接收器附加到内容类型的代码。 使用spmanager我可以看到事件接收器附加到内容类型,但是当我从内容类型创建列表时,事件接收器丢失。 有任何想法吗。 我的代码如下

  public override void FeatureActivated(SPFeatureReceiverProperties properties)
            {
                string asmName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
                string itemReceiverName = "xxxxxx.Intranet.SP.xxxxx.PermissionsUpdaterEventReceiver";

                ////surely a better way to get all lists than this
                ////re - do
                using (SPSite thisSite = (SPSite)properties.Feature.Parent) {
                    using (SPWeb web = thisSite.RootWeb) {
                        SPContentType RambollNewsContentType = web.ContentTypes["RambollNewsContentType"];
                        RambollNewsContentType.EventReceivers.Add(SPEventReceiverType.ItemAdded, asmName, itemReceiverName);
                        RambollNewsContentType.Update(true);
                    }
                }    
            }

I created some site columns / a content type and a list definition as part of a feature. I want to attach an eventreceiver to the content type. I added code to attach the event receiver to the content type. Using spmanager i can see that the event receiver is attached to the content type however when i create lists from the content type the event reciever is missing. Any ideas. My code is below

  public override void FeatureActivated(SPFeatureReceiverProperties properties)
            {
                string asmName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
                string itemReceiverName = "xxxxxx.Intranet.SP.xxxxx.PermissionsUpdaterEventReceiver";

                ////surely a better way to get all lists than this
                ////re - do
                using (SPSite thisSite = (SPSite)properties.Feature.Parent) {
                    using (SPWeb web = thisSite.RootWeb) {
                        SPContentType RambollNewsContentType = web.ContentTypes["RambollNewsContentType"];
                        RambollNewsContentType.EventReceivers.Add(SPEventReceiverType.ItemAdded, asmName, itemReceiverName);
                        RambollNewsContentType.Update(true);
                    }
                }    
            }

原文:https://stackoverflow.com/questions/15364112
更新时间:2022-05-24 13:05

最满意答案

不,你不会被拒绝。 Apple只是在您的应用上运行测试以查看它使用的API。 如果该API公开于您的应用程序的Base SDK,那么您没有问题。 事实上,现在的公共API在您的应用程序的早期部署目标中是私有的,这是无关紧要的。

此外,Apple如何判断您的应用是否仅在API实际公开的设备上使用现在的公共API。

如果Apple拒绝了一个应用程序,该应用程序针对您的Base SDK公开使用的API,但对于您的Deployment Target而言是私有的,那么太多的应用程序会因尝试使用更新的API而被拒绝,同时仍支持较旧的iOS版本。 这将是一个糟糕的决定。

更大的问题是,以前的私有API可能会比较笨重,或者在私有的iOS版本中以不同的方式工作。 因此,需要担心的实际问题是让您的应用程序避免在iOS版本中使用现在的公共API,因为旧版私有版本可能无法正常工作,因为它在公开的iOS新版本中可能无法正常工作。


No, you will not be rejected. Apple simply runs a test on your app to see what APIs it uses. If the API is public for your app's Base SDK then you are fine. The fact that the now public API was private in your app's earlier Deployment target is irrelevant.

Besides, how could Apple tell if your app is using the now public API only on devices where the API is actually public.

If Apple rejected an app for using an API that is public for your Base SDK but private for your Deployment Target, far too many apps would be rejected for trying to use updated APIs while still supporting older iOS versions. It would be a bad decision.

The bigger issue is that the formerly private API is likely to be buggier or work differently in the versions of iOS where it was private. So the actual problem to worry about is having your app avoid using the now public API in versions of iOS where it was private because the older private version may not work as well as it does in the newer versions of iOS where it is public.

相关问答

更多
  • 我最后一次遇到这种情况是因为我的代码中的方法和Cocoa API中的私有方法之间的命名空间冲突。 你也可以使用grep来找出你正在使用这些选择器的地方: grep -R 'setResult:' * The last time I encountered this was because of a namespace collision between methods in my code and private methods in the Cocoa API. You can also use gre ...
  • setAnimationDidStopSelector:的全部意义在于,您告诉系统在动画完成时调用您自己的自定义方法。 所以,如果要传入该选择器,则需要自己在类中定义该方法: - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { // do whatever. } 注意setAnimationDidStopSelector:的文档setAnima ...
  • 不,你不会被拒绝。 Apple只是在您的应用上运行测试以查看它使用的API。 如果该API公开于您的应用程序的Base SDK,那么您没有问题。 事实上,现在的公共API在您的应用程序的早期部署目标中是私有的,这是无关紧要的。 此外,Apple如何判断您的应用是否仅在API实际公开的设备上使用现在的公共API。 如果Apple拒绝了一个应用程序,该应用程序针对您的Base SDK公开使用的API,但对于您的Deployment Target而言是私有的,那么太多的应用程序会因尝试使用更新的API而被拒绝,同 ...
  • setContentToHTMLString是UITextView的未记录方法。 您可能需要将其删除。 您不能访问私有API。 setContentToHTMLString is an undocumented method of UITextView. You may need to remove it. You are NOT allowed to access the private API.
  • iOS数据存储指南指出,只有用户使用您的应用创建的内容(例如文档,新文件,编辑等)可以存储在/ Documents目录中 - 并由iCloud备份。 应用程序使用的临时文件只能存储在/ tmp目录中; 请记得在用户退出应用程序时删除存储在此位置的文件。 可以重新创建数据但必须持续保持应用程序正常运行的数据 - 或者因为客户希望它可供脱机使用 - 应该标记为“不备份”属性。 对于NSURL对象,请添加NSURLIsExcludedFromBackupKey属性以防止备份相应的文件。 对于CFURLRef对象, ...
  • 如果您通过https://test.sagepay.com/simulator/登录Sagepay上的模拟器帐户,您可以告诉它返回哪些响应。 您可以指示它返回随机响应,或者MALFORMED,INVALID,ERROR,NOTAUTHED,REJECTED,3DAUTH。 不幸的是,您必须通过管理面板更改这些内容,然后它们会应用每个事务,而不是使用不同的详细信息来触发不同的响应。 If you login to your simulator account on Sagepay via https://te ...
  • 因此,您希望您的Kong实例与您的上游服务器通信只有您知道的秘密,以便您可以确定上游服务器的流量来自您的Kong实例? 当然可以! 有几种方法可以做到这一点。 您可以使用https://getkong.org/plugins/request-transformer/添加包含一些秘密字符串的标头(然后可能使用https://getkong.org/plugins/response-transformer/删除该标头之前回应客户)。 实际上,它取决于您的上游服务器在请求验证方面支持的内容。 您还提到了为最终用户 ...
  • 由于这个原因,我还有两个应用程序更新被拒绝。 在同一时期,我已经批准了其他人。 被拒绝的两个App更新之间的一个常见项是在我的项目中使用以下属性集: true I've also had two App updates rejected due to this reason. Over the same period I've had others approved. One common ...
  • Apple最近不允许开发人员访问设备的UDID(唯一设备标识符) ,但某些第三方库尚未更新。 如果您在应用中使用Google Analytics ,则可能需要负责创建此类问题。 还有一些其他问题: 应用程序被拒绝,但我不使用UDID 。 Apple如何知道您正在使用私有API? 如果您不使用任何私有API,那么您的代码中的方法与私有API具有相同的名称。 转到并更改该名称并重新提交您的应用程序。 Apple recently disallowed developers from accessing the ...
  • 您的应用程序因Paypal(MECL)库而被拒绝,它使用uniqueIdentifier 。 我也问过这个问题,我收到了PayPal的回复,但问题仍然没有解决。 但您可以使用此链接查看曲目。 查看他来自PayPal的mettler的答案。 希望这会帮助你。 祝一切顺利 !!! Your app is reject because of Paypal(MECL) library, it uses a uniqueIdentifier. I have also asked question about that ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。