C#将属性添加到框架类

时间:2018-08-15 08:02:06

标签: c# skypedeveloper lync-client-sdk

我使用Lync SDK 2013,并且想要扩展特定的类Contact。联系人对象可以通过使用

获得显示的姓名

string displayName = contact.GetContactInformation(ContactInformationType.DisplayName);

,我想创建一个名为User的新类,以扩展此联系人类。例如User将具有一个属性

public object DisplayName { get { return GetContactInformation(ContactInformationType.DisplayName); } }

别人只需要写

user.DisplayName

获取联系人的显示名称。不幸的是,从Contact

继承时,我必须设置一个构造函数
    public User() : base()
    {
    }

,Contact的构造函数接受一些参数。但是我不知道基本构造函数需要哪些参数。

是否可以在不知道参数的情况下编写“使用相同的构造函数”?

否则我不知道在哪里找到构造函数

#region Assembly Microsoft.Lync.Model, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
// projectPath\packages\Lync2013SDK.15.0.4466.1000\lib\net40\Microsoft.Lync.Model.dll
#endregion

using System;
using System.Collections.Generic;
using Microsoft.Lync.Model.Conversation;
using Microsoft.Lync.Model.Group;
using Microsoft.Lync.Model.Internal;

namespace Microsoft.Lync.Model
{
    //
    // Summary:
    //     Represents a contact within the Lync client. A contact can be person, bot or
    //     phone number.
    public class Contact : UCWFull
    {
        //
        ~Contact();

        //
        // Summary:
        //     Gets the contact URI.
        public string Uri { get; }
        //
        // Summary:
        //     Returns the Unified Communication type of this contact.
        public UnifiedCommunicationType UnifiedCommunicationType { get; }
        //
        // Summary:
        //     Gets a collection of contact settings.
        public IDictionary<ContactSetting, object> Settings { get; }
        //
        // Summary:
        //     Gets the list of all groups of which this contact is a member of.
        public GroupCollection CustomGroups { get; }
        //
        // Summary:
        //     Gets the parent Contact and Group Manager of this contact.
        public ContactManager ContactManager { get; }

        //
        // Summary:
        //     Occurs when one or more pieces of contact information are changed.
        //
        // Hints:
        //     Application logic must subscribe to contact information publication before the
        //     ContactInformationChanged event can be received. Call the CreateSubscription
        //     method on the ContactManager object and then add the Contact to be subscribed
        //     and the ContactInformationTypes that you are interested in. Finally, call the
        //     Subscribe method on the ContactSubscription object.
        public event EventHandler<ContactInformationChangedEventArgs> ContactInformationChanged;
        //
        // Summary:
        //     Occurs when the value of a contact property changes.
        public event EventHandler<ContactSettingChangedEventArgs> SettingChanged;
        //
        // Summary:
        //     Occurs when the contact URI is changed.
        public event EventHandler<UriChangedEventArgs> UriChanged;

        //
        // Summary:
        //     Sets a setting associated with this contact.
        public IAsyncResult BeginChangeSetting(ContactSetting contactSettingType, object contactSettingValue, AsyncCallback contactCallback, object state);
        //
        // Summary:
        //     Gets the Organization Info of this contact.
        public IAsyncResult BeginGetOrganizationInformation(OrganizationStructureTypes orgInfoTypes, AsyncCallback contactCallback, object state);
        //
        // Summary:
        //     Moves this contact from a source group to a target group.
        public IAsyncResult BeginMoveToGroup(Group.Group targetGroup, Group.Group sourceGroup, AsyncCallback contactCallback, object state);
        //
        // Summary:
        //     Checks if the setting can be set for this contact.
        //
        // Returns:
        //     System.Boolean
        public bool CanChangeSetting(ContactSetting contactSetting);
        //
        // Summary:
        //     Checks if this contact can be moved from a source group to a target group.
        //
        // Returns:
        //     System.Boolean
        public bool CanMoveToGroup(Group.Group targetGroup, Group.Group sourceGroup);
        //
        // Summary:
        //     Checks if this contact can start a given mode of communication (modality
        //
        // Returns:
        //     System.Boolean
        public bool CanStart(ModalityTypes modalityTypes);
        //
        // Summary:
        //     Creates a collaboration endpoint object from a telephone number.
        public ContactEndpoint CreateContactEndpoint(string telephoneUri);
        //
        // Summary:
        //     Sets a setting associated with this contact.
        public void EndChangeSetting(IAsyncResult asyncResult);
        //
        // Summary:
        //     Gets the Organization Info of this contact.
        public void EndGetOrganizationInformation(out ContactCollection managers, out ContactCollection peers, out ContactCollection directors, IAsyncResult asyncResult);
        //
        // Summary:
        //     Moves this contact from a source group to a target group.
        public void EndMoveToGroup(IAsyncResult asyncResult);
        //
        // Summary:
        //     Gets a single contact information from this contact.
        //
        // Returns:
        //     System.Object
        public object GetContactInformation(ContactInformationType contactInformationType);
        //
        // Summary:
        //     Gets contact information from this contact.
        public IDictionary<ContactInformationType, object> GetContactInformation(IEnumerable<ContactInformationType> contactInformationTypes);
    }
}

1 个答案:

答案 0 :(得分:2)

您考虑创建extension method

而不是从类继承
public static string DisplayName(this Contact contact)
{
     return contact.GetContactInformation(ContactInformationType.DisplayName).ToString();
}