public WhoAmISubRequestType()
 {
     this.typeField = SubRequestAttributeType.WhoAmI;
 }
 public CellSubRequestType()
 {
     this.typeField = SubRequestAttributeType.Cell;
 }
 public ServerTimeSubRequestType()
 {
     this.typeField = SubRequestAttributeType.ServerTime;
 }
 public SchemaLockSubRequestType()
 {
     this.typeField = SubRequestAttributeType.SchemaLock;
 }
 public CoauthSubRequestType()
 {
     this.typeField = SubRequestAttributeType.Coauth;
 }
 public ExclusiveLockSubRequestType()
 {
     this.typeField = SubRequestAttributeType.ExclusiveLock;
 }
 public GetDocMetaInfoSubRequestType()
 {
     this.typeField = SubRequestAttributeType.GetDocMetaInfo;
 }
 public GetVersionsSubRequestType()
 {
     this.typeField = SubRequestAttributeType.GetVersions;
 }
 public EditorsTableSubRequestType()
 {
     this.typeField = SubRequestAttributeType.EditorsTable;
 }
        /// <summary>
        /// Convert special sub request to target object.
        /// </summary>
        /// <typeparam name="T">The type of target object.</typeparam>
        /// <param name="value">The instance of special sub request.</param>
        /// <returns>The instance of target object.</returns>
        public static T ConvertSubRequestToGenericType <T>(object value)
        {
            T targetObject = Activator.CreateInstance <T>();

            PropertyInfo[] props = value.GetType().GetProperties();

            foreach (PropertyInfo item in props)
            {
                object propValue = GetSpecifiedPropertyValueByName(value, item.Name);
                if (string.Compare("SubRequestData", item.Name, StringComparison.OrdinalIgnoreCase) == 0 && propValue != null)
                {
                    SetSpecifiedProtyValueByName(targetObject, item.Name, ConvertSubRequestToGenericType <SubRequestDataGenericType>(propValue));
                }
                else
                {
                    PropertyInfo optionalPropertyInGenericType    = GetSpecifiedPropertyByName(targetObject, item.Name + "Specified");
                    PropertyInfo optionalPropertyInSubRequestType = GetSpecifiedPropertyByName(value, item.Name + "Specified");
                    if (optionalPropertyInGenericType != null && optionalPropertyInSubRequestType == null)
                    {
                        SetSpecifiedProtyValueByName(targetObject, item.Name + "Specified", true);
                    }

                    SetSpecifiedProtyValueByName(targetObject, item.Name, propValue);
                }
            }

            if (targetObject.GetType() == typeof(SubRequestElementGenericType))
            {
                // set the type of sub request
                SubRequestAttributeType subRequestType = new SubRequestAttributeType();

                switch (value.GetType().Name)
                {
                case "CellSubRequestType":
                    subRequestType = SubRequestAttributeType.Cell;
                    break;

                case "CoauthSubRequestType":
                    subRequestType = SubRequestAttributeType.Coauth;
                    break;

                case "ExclusiveLockSubRequestType":
                    subRequestType = SubRequestAttributeType.ExclusiveLock;
                    break;

                case "SchemaLockSubRequestType":
                    subRequestType = SubRequestAttributeType.SchemaLock;
                    break;

                case "ServerTimeSubRequestType":
                    subRequestType = SubRequestAttributeType.ServerTime;
                    break;

                case "WhoAmISubRequestType":
                    subRequestType = SubRequestAttributeType.WhoAmI;
                    break;

                case "EditorsTableSubRequestType":
                    subRequestType = SubRequestAttributeType.EditorsTable;
                    break;

                case "GetDocMetaInfoSubRequestType":
                    subRequestType = SubRequestAttributeType.GetDocMetaInfo;
                    break;

                case "GetVersionsSubRequestType":
                    subRequestType = SubRequestAttributeType.GetVersions;
                    break;

                case "VersioningSubRequestType":
                    subRequestType = SubRequestAttributeType.Versioning;
                    break;

                case "FileOperationSubRequestType":
                    subRequestType = SubRequestAttributeType.FileOperation;
                    break;

                case "LockStatusSubRequestType":
                    subRequestType = SubRequestAttributeType.LockStatus;
                    break;

                default:
                    throw new InvalidOperationException("Invalid object type " + value.GetType().Name);
                }

                SetSpecifiedProtyValueByName(targetObject, "Type", subRequestType);
            }

            return(targetObject);
        }