Esempio n. 1
0
        /// <summary>
        /// Builds a context descriptor with the given parameters that will provide a url link to the correct area in FLEx.
        /// </summary>
        internal static ContextDescriptor GenerateContextDescriptor(string filePath, string guid, string label)
        {
            var appId         = "FLEx";
            var directory     = Path.GetDirectoryName(filePath);
            var lastDirectory = Path.GetFileName(directory);

            if (lastDirectory == "Scripture")
            {
                appId = "TE";
            }
            // figure out here which we need.
            var fwAppArgs = new FwAppArgs(appId, "current", "", "default", guid);

            // Add the "label" information which the Chorus Notes browser extracts to identify the object in the UI.
            // This is just for a label and we can't have & or = in the value. So replace them if they occur.
            fwAppArgs.AddProperty("label", label.Replace("&", " and ").Replace("=", " equals "));
            // The FwUrl has all the query part encoded.
            // Chorus needs it unencoded so it can extract the label.
            var fwUrl      = fwAppArgs.ToString();
            var hostLength = fwUrl.IndexOf("?", StringComparison.Ordinal);
            var host       = fwUrl.Substring(0, hostLength);
            var query      = HttpUtilityFromMono.UrlDecode(fwUrl.Substring(hostLength + 1));
            var url        = host + "?" + query;

            return(new ContextDescriptor(label, url));
        }