我有几个不同的对象,但我必须对它们做类似的操作.什么是更好的使用:1.几种方法,并使用这些对象作为类型参数.2.使用一个将System.Object作为参数的方法.在这个方法中,我将检查参数类型并执行一些操作.
例如,我应该发送一些动作的通知.我有对象Action1,Action2,Action3 ... ActionN,其中包含这些操作的详细信息.我应该使用:
public void SendNotificationForAction1(Action1 action) {}
public void SendNotificationForAction2(Action2 action) {}
public void SendNotificationForActionN(ActionN action) {}
Run Code Online (Sandbox Code Playgroud)
要么
public void SendNotification(Object action)
{
//here I will check type of action and do something
}
Run Code Online (Sandbox Code Playgroud) 我有一个图片库,里面有文件夹。根文件夹包含另一个以年份命名的文件夹。每个年份文件夹包含多个专辑文件夹。至少每张专辑箔纸都包含图片。我创建了新的布尔字段“IsCover”,它定义专辑的封面图像。然后我尝试通过 REST API 获取包含文件的相册文件夹,我想知道哪个文件被覆盖,但响应不包含此类字段。
http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{4E99ABFD-51A3-460F-9B34-1A1962F3C2CF},1,2",
"CustomizedPageStatus": 0,
"ETag": "\"{4E99ABFD-51A3-460F-9B34-1A1962F3C2CF},1\"",
"Exists": true,
"Length": "98331",
"Level": 1,
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "IMG_3474.JPG",
"ServerRelativeUrl": "/MediaGallery/2016/NY/IMG_3474.JPG",
"TimeCreated": "2016-03-20T21:00:27Z",
"TimeLastModified": "2016-03-20T21:00:27Z",
"Title": null,
"UIVersion": 512,
"UIVersionLabel": "1.0"
Run Code Online (Sandbox Code Playgroud)
如果我尝试获取图书馆中的所有项目,那没关系,它会向我显示我的字段。
http://portal/_api/web/lists('guid')/Items
Run Code Online (Sandbox Code Playgroud)
我试图获取字段,$select但它不起作用。
http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files&$select=Name,Files/ServerRelativeUrl,Files/IsCover
Run Code Online (Sandbox Code Playgroud)