Beispiel #1
0
        public bool Equals(GroupResponse input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Detail == input.Detail ||
                     (Detail != null && Detail.Equals(input.Detail))
                     ) &&
                 (
                     Founder == input.Founder ||
                     (Founder != null && Founder.Equals(input.Founder))
                 ) &&
                 (
                     AlliedIds == input.AlliedIds ||
                     (AlliedIds != null && AlliedIds.SequenceEqual(input.AlliedIds))
                 ) &&
                 (
                     ParentGroup == input.ParentGroup ||
                     (ParentGroup != null && ParentGroup.Equals(input.ParentGroup))
                 ) &&
                 (
                     AllianceStatus == input.AllianceStatus ||
                     (AllianceStatus != null && AllianceStatus.Equals(input.AllianceStatus))
                 ) &&
                 (
                     GroupJoinInviteCount == input.GroupJoinInviteCount ||
                     (GroupJoinInviteCount.Equals(input.GroupJoinInviteCount))
                 ) &&
                 (
                     CurrentUserMembershipsInactiveForDestiny == input.CurrentUserMembershipsInactiveForDestiny ||
                     (CurrentUserMembershipsInactiveForDestiny != null && CurrentUserMembershipsInactiveForDestiny.Equals(input.CurrentUserMembershipsInactiveForDestiny))
                 ) &&
                 (
                     CurrentUserMemberMap == input.CurrentUserMemberMap ||
                     (CurrentUserMemberMap != null && CurrentUserMemberMap.SequenceEqual(input.CurrentUserMemberMap))
                 ) &&
                 (
                     CurrentUserPotentialMemberMap == input.CurrentUserPotentialMemberMap ||
                     (CurrentUserPotentialMemberMap != null && CurrentUserPotentialMemberMap.SequenceEqual(input.CurrentUserPotentialMemberMap))
                 ));
        }
        /// <summary>
        /// A method is used to get the WOPIsrc value and the token value.
        /// </summary>
        /// <param name="wopiResourceUrl">A parameter represents the WOPI resource URL</param>
        /// <returns>A return value represents a name-value pairs collection which includes the WOPIsrc value and the token value. The token value can be get by "Token" key, the WOPIsrc value can be get by "WOPISrc" key.</returns>
        protected static Dictionary <string, string> GetWOPISrcAndTokenValueFromWOPIResourceUrl(string wopiResourceUrl)
        {
            if (string.IsNullOrEmpty(wopiResourceUrl))
            {
                throw new ArgumentNullException("wopiResourceUrl");
            }

            Uri currentUri = null;

            if (!Uri.TryCreate(wopiResourceUrl, UriKind.Absolute, out currentUri))
            {
                throw new ArgumentException("It must be a valid absolute URL", "wopiResourceUrl");
            }

            #region verify the URL.

            NameValueCollection queryParameterValues = HttpUtility.ParseQueryString(currentUri.Query);
            if (null == queryParameterValues || 0 == queryParameterValues.Count)
            {
                string errorMsg = string.Format("The WOPI resource URL must contain the URL query parameter. current URL:[{0}] \r\n", wopiResourceUrl);
                HelperBase.AppendLogs(typeof(TokenAndRequestUrlHelper), errorMsg);
                throw new InvalidOperationException(errorMsg);
            }

            string expectedQueryParameter = @"access_token";

            // Verify the query parameters whether contain "access_token"
            if (!queryParameterValues.AllKeys.Any(Founder => Founder.Equals(expectedQueryParameter, StringComparison.OrdinalIgnoreCase)))
            {
                string errorMsg = string.Format("The WOPI resource URL must contain [access_token] parameter. current URL:[{0}] \r\n", wopiResourceUrl);
                HelperBase.AppendLogs(typeof(TokenAndRequestUrlHelper), errorMsg);
                throw new InvalidOperationException(errorMsg);
            }

            #endregion

            string wopiSrcUrl = currentUri.GetLeftPart(UriPartial.Path);
            Dictionary <string, string> wopiSrcAndTokenValues = new Dictionary <string, string>();
            wopiSrcAndTokenValues.Add("WOPISrc", wopiSrcUrl);
            wopiSrcAndTokenValues.Add("Token", queryParameterValues[expectedQueryParameter]);
            return(wopiSrcAndTokenValues);
        }