public ProjectionNotFoundException(string action, string typeName, ProjectionFormat format)
     : base("A projection could not be found to carry out action '" + action + "', entity type '" + typeName + "' and output format '" + format + "'.")
 {
     Action = action;
     TypeName = typeName;
     Format = format;
 }
        /// <summary>
        /// Locates the projection info for performing the specified action with the specified type by looking at the interfaces of the provided type.
        /// </summary>
        /// <param name="action">The action that is to be performed by the projection.</param>
        /// <param name="type">The type that is involved in the action.</param>
        /// <param name="format">The output format of the projection to location.</param>
        /// <returns>The projection info for the specified scenario.</returns>
        public ProjectionInfo LocateFromInterfaces(string action, Type type, ProjectionFormat format)
        {
            ProjectionInfo projectionInfo = null;

            using (LogGroup logGroup = LogGroup.StartDebug("Locating projection from type interfaces."))
            {
                Type[] interfaceTypes = type.GetInterfaces();

                // Loop backwards through the interface types
                for (int i = interfaceTypes.Length - 1; i >= 0; i--)
                {
                    Type interfaceType = interfaceTypes[i];

                    string key = Projections.GetProjectionKey(action, interfaceType.Name, format);

                    if (Projections.ContainsKey(key))
                    {
                        projectionInfo = Projections.GetByKey(key);

                        break;
                    }
                }
            }

            return(projectionInfo);
        }
        /// <summary>
        /// Locates the projection info for performing the specified action with the specified type by looking at the base types of the provided type.
        /// </summary>
        /// <param name="action">The action that is to be performed by the projection.</param>
        /// <param name="type">The type that is involved in the action.</param>
        /// <param name="format">The output format of the projection to locate.</param>
        /// <returns>The projection info for the specified scenario.</returns>
        public ProjectionInfo LocateFromBaseTypes(string action, Type type, ProjectionFormat format)
        {
            ProjectionInfo projectionInfo = null;

            using (LogGroup logGroup = LogGroup.StartDebug("Locating projection from base types."))
            {
                TypeNavigator navigator = new TypeNavigator(type);

                while (navigator.HasNext && projectionInfo == null)
                {
                    Type nextType = navigator.Next();

                    string key = Projections.GetProjectionKey(action, nextType.Name, format);

                    // If a projection exists for the base type then use it
                    if (Projections.ContainsKey(key))
                    {
                        projectionInfo = Projections.GetByKey(key);

                        break;
                    }
                }
            }
            return(projectionInfo);
        }
        public void Test_GetFormat_Xslt()
        {
            ProjectionMapper mapper = new ProjectionMapper();

            string fileName = "TestPage.xslt.aspx";

            ProjectionFormat format = mapper.GetFormat(fileName);

            Assert.AreEqual(ProjectionFormat.Xslt, format, "Doesn't match what is expected.");
        }
        /// <summary>
        /// Locates the projection info for performing the specified action with the specified type.
        /// </summary>
        /// <param name="action">The action that is to be performed by the projection.</param>
        /// <param name="typeName">The short type name of the entity that is involved in the action.</param>
        /// <param name="format">The output format of the projection to locate.</param>
        /// <returns>The projection info for the specified scenario.</returns>
        public ProjectionInfo Locate(string action, string typeName, ProjectionFormat format)
        {
            // Create the projection info variable to hold the return value
            ProjectionInfo projectionInfo = null;

            using (LogGroup logGroup = LogGroup.StartDebug("Locating projection with action '" + action + "', type name '" + typeName + "', and format '" + format.ToString() + "'."))
            {
                // Get the specified type
                Type type = null;

                if (Entities.EntityState.Entities.Contains(typeName))
                {
                    type = Entities.EntityState.Entities[typeName].GetEntityType();
                }

                // Create a direct projection key for the specified type
                string key = Projections.GetProjectionKey(action, typeName, format);

                LogWriter.Debug("Key: " + key);

                // Check the direct key to see if a projection exists
                if (Projections.ContainsKey(key))
                {
                    projectionInfo = Projections.GetByKey(key);
                }
                // If not then navigate up the heirarchy looking for a matching projection
                else if (type != null)
                {
                    projectionInfo = LocateFromHeirarchy(action, type, format);
                }

                /*// If the projection wasn't found in memory then try loading it
                 * if (EnableLoading && projectionInfo == null)
                 * {
                 *      LogWriter.Debug("Projection not found in memory. Loading from file.");
                 *
                 *      projectionInfo = new ProjectionLoader().LoadInfoFromFile(
                 *              new ProjectionFileNamer().CreateInfoFilePath(action, typeName, format)
                 *      );
                 *
                 *      Projections.Add(projectionInfo);
                 * }*/

                if (projectionInfo == null)
                {
                    LogWriter.Debug("No projection found.");
                }
                else
                {
                    LogWriter.Debug("Projection found - Action: " + projectionInfo.Action + " | Type name: " + projectionInfo.TypeName + " | Title: " + projectionInfo.MenuTitle + " | Category: " + projectionInfo.MenuCategory + " | Format: " + projectionInfo.Format.ToString());
                }
            }
            return(projectionInfo);
        }
Пример #6
0
        public string GetInternalPath(string originalPath)
        {
            string path = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Generating the internal path."))
            {
                if (!Skip(originalPath))
                {
                    string shortPath = GetShortPath(originalPath);

                    LogWriter.Debug("Short path: " + shortPath);

                    string fileName = Path.GetFileName(shortPath);

                    LogWriter.Debug("File name: " + fileName);

                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);

                    LogWriter.Debug("File name without extension: " + fileNameWithoutExtension);

                    string command = GetCommandName(originalPath);

                    LogWriter.Debug("Command name: " + command);

                    ProjectionFormat format = GetFormat(fileName);

                    LogWriter.Debug("Format: " + format.ToString());

                    // If the command name has a dash - in it then it's in the format of [Action]-[TypeName]
                    if (command.IndexOf("-") > -1)
                    {
                        path = GetInternalPathFromCommand(originalPath, command, format);
                    }
                    // Otherwise it's the name of the projection
                    else if (ProjectionState.Projections.Contains(command))
                    {
                        string projectionName = command;

                        path = GetInternalPathFromName(originalPath, projectionName, format);
                    }



                    LogWriter.Debug("Path: " + path);
                }
                else
                {
                    LogWriter.Debug("Skipping rewrite.");
                }
            }
            return(path);
        }
        /// <summary>
        /// Retrieves the projection with the provided action and type.
        /// </summary>
        /// <param name="action">The action that the projection performs.</param>
        /// <param name="typeName">The type of entity involved in the projection</param>
        /// <param name="format">The output format of the desired projection.</param>
        /// <param name="throwExceptionIfNotFound">A value indicating whether to throw an exception if no projection was found.</param>
        /// <returns>The projection matching the provided action and type.</returns>
        public ProjectionInfo GetProjection(string action, string typeName, ProjectionFormat format, bool throwExceptionIfNotFound)
        {
            ProjectionLocator locator = new ProjectionLocator(this);

            ProjectionInfo foundProjection = locator.Locate(action, typeName, format);

            if (foundProjection == null && throwExceptionIfNotFound)
            {
                throw new ProjectionNotFoundException(action, typeName, format);
            }


            return(foundProjection);
        }
        public bool Contains(string name, ProjectionFormat format)
        {
            bool doesContain = false;

            using (LogGroup logGroup = LogGroup.StartDebug("Checking whether projection is found with name '" + name + "'."))
            {
                LogWriter.Debug("Format: " + format);

                doesContain = (GetProjection(name, format, false) != null);

                LogWriter.Debug("Does contain projection: " + doesContain.ToString());
            }
            return(doesContain);
        }
        /// <summary>
        /// Locates the projection info for performing the specified action with the specified type by looking at the base types and interfaces of the provided type.
        /// </summary>
        /// <param name="action">The action that is to be performed by the projection.</param>
        /// <param name="type">The type that is involved in the action.</param>
        /// <param name="format">The output format of the projection to location.</param>
        /// <returns>The projection info for the specified scenario.</returns>
        public ProjectionInfo LocateFromHeirarchy(string action, Type type, ProjectionFormat format)
        {
            ProjectionInfo projectionInfo = null;

            using (LogGroup logGroup = LogGroup.StartDebug("Locating projection from type heirarchy."))
            {
                projectionInfo = LocateFromInterfaces(action, type, format);

                if (projectionInfo == null)
                {
                    projectionInfo = LocateFromBaseTypes(action, type, format);
                }
            }
            return(projectionInfo);
        }
Пример #10
0
        public string GetRealPageName(string friendlyUrl)
        {
            string ext = GetExtension(friendlyUrl);

            ProjectionFormat format = GetFormat(ext);

            string realPageName = "Projector.aspx";

            if (format == ProjectionFormat.Xslt ||
                format == ProjectionFormat.Xml)
            {
                realPageName = "XmlProjector.aspx";
            }

            return(realPageName);
        }
Пример #11
0
        /// <summary>
        /// Creates a raw/standard URL to the page corresponding with the specified action and entity.
        /// </summary>
        /// <param name="action">The action to be performed at the target page.</param>
        /// <param name="entity">The entity involved in the action.</param>
        /// <param name="format">The format of the target projection.</param>
        /// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
        public string CreateStandardUrl(string action, IEntity entity, ProjectionFormat format)
        {
            string link = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Creating a standard URL for the specified action and provided entity type, with the specified format."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Entity type: " + entity.ShortTypeName);
                LogWriter.Debug("Format: " + format.ToString());

                link = ApplicationPath + "/Projector.aspx?a=" + PrepareForUrl(action) + "&t=" + PrepareForUrl(entity.ShortTypeName) + "&f=" + PrepareForUrl(format.ToString()) + "&" + PrepareForUrl(entity.ShortTypeName) + "-ID=" + PrepareForUrl(entity.ID.ToString());
                link = AddResult(link);

                LogWriter.Debug("Link: " + link);
            }
            return(link);
        }
Пример #12
0
        /// <summary>
        /// Creates a raw/standard URL to the page corresponding with the specified action and specified type.
        /// </summary>
        /// <param name="action">The action to be performed at the target page.</param>
        /// <param name="typeName">The name of the type being acted upon at the target page.</param>
        /// <param name="format">The format of the target projection.</param>
        /// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
        public string CreateStandardUrl(string action, string typeName, ProjectionFormat format)
        {
            string link = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Creating a standard URL for the specified action and type, with the specified format."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Type name: " + typeName);

                LogWriter.Debug("Format: " + format);

                link = ApplicationPath + "/Projector.aspx?a=" + PrepareForUrl(action) + "&t=" + PrepareForUrl(typeName) + "&f=" + PrepareForUrl(format.ToString());
                link = AddResult(link);

                LogWriter.Debug("Link: " + link);
            }
            return(link);
        }
        /// <summary>
        /// Retrieves the projection with the provided name.
        /// </summary>
        /// <param name="name">The name of the projection.</param>
        /// <param name="format">The output format of the desired projection.</param>
        /// <param name="throwExceptionIfNotFound">A value indicating whether to throw an exception if no projection was found.</param>
        /// <returns>The projection with the specified name.</returns>
        public ProjectionInfo GetProjection(string name, ProjectionFormat format, bool throwExceptionIfNotFound)
        {
            ProjectionInfo foundProjection = null;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving projection with name '" + name + "'."))
            {
                string key = GetProjectionKey(name, format);

                LogWriter.Debug("Key: " + key);

                foundProjection = base[key];

                if (foundProjection == null && throwExceptionIfNotFound)
                {
                    throw new ProjectionNotFoundException(name, format);
                }
            }

            return(foundProjection);
        }
Пример #14
0
        public ProjectionFormat GetFormat(string fileName)
        {
            ProjectionFormat format = ProjectionFormat.Html;

            using (LogGroup logGroup = LogGroup.StartDebug("Detecting the format of the specified file."))
            {
                int a = fileName.IndexOf('.');
                int b = fileName.LastIndexOf('.');

                // If the file name contains two dots (.)
                if (a > -1 &&              // first dot is found
                    b > -1 &&                 // second dot is found
                    b - a > 0)                                       // length is greater than zero
                {
                    string formatString = fileName.Substring(a,      // a is the position of the first dot so a+1 is the position of the first character in the sub extension
                                                             b - a); // b (position) minus a (position) minus 1 (to exclude the dot) gives the length
                    formatString = formatString.Trim('.').ToLower();

                    if (formatString == "xml")
                    {
                        format = ProjectionFormat.Xml;
                    }

                    else if (formatString == "xslt")
                    {
                        format = ProjectionFormat.Xslt;
                    }

                    else
                    {
                        throw new NotSupportedException("Sub type not yet supported: " + formatString);
                    }
                }
            }

            return(format);
        }
 /// <summary>
 /// Gets/sets the projection for the specifid action and type.
 /// </summary>
 public ProjectionInfo this[string action, Type type, ProjectionFormat format]
 {
     get { return(GetProjection(action, type.Name, format)); }
     set { SetProjection(action, type.Name, format, value); }
 }
 public bool Contains(string action, string typeName, ProjectionFormat format)
 {
     return(GetProjection(action, typeName, format, false) != null);
 }
Пример #17
0
        /// <summary>
        /// Creates a raw/standard URL to the page corresponding with the specified action and specified type.
        /// </summary>
        /// <param name="action">The action to be performed at the target page.</param>
        /// <param name="typeName">The name of the type being acted upon at the target page.</param>
        /// <param name="propertyName">The name of the property to filter the specified type by.</param>
        /// <param name="value">The value of the property to filter the specified type by.</param>
        /// <param name="format">The format of the target projection.</param>
        /// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
        public string CreateStandardUrl(string action, string typeName, string propertyName, string value, ProjectionFormat format)
        {
            string link = String.Empty;
            using (LogGroup logGroup = LogGroup.StartDebug("Creating a standard URL for the specified action and provided entity type, with the specified property name and value, as well as the specified format."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Type name: " + typeName);

                LogWriter.Debug("Property name: " + propertyName);
                LogWriter.Debug("Value: " + value);

                LogWriter.Debug("Format: " + format.ToString());

                link = ApplicationPath + "/Projector.aspx?a=" + PrepareForUrl(action) + "&t=" + PrepareForUrl(typeName) + "&f=" + PrepareForUrl(format.ToString()) + "&" + PrepareForUrl(typeName) + "-" + PrepareForUrl(propertyName) + "=" + PrepareForUrl(value);
                link = AddResult(link);

                LogWriter.Debug("Link: " + link);
            }
            return link;
        }
        /// <summary>
        /// Retrieves the key for the specifid action and type.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public string GetProjectionKey(string name, ProjectionFormat format)
        {
            string fullKey = name.Replace("-", "_") + "_" + format.ToString();

            return(fullKey);
        }
Пример #19
0
 public ProjectionNotFoundException(string name, ProjectionFormat format) : base("A projection could not be found with the name '" + name + "' and output format '" + format + "'.")
 {
     Name   = name;
     Format = format;
 }
Пример #20
0
        public string GetInternalPathFromActionAndType(string originalPath, string action, string typeName, ProjectionFormat format)
        {
            string newPath = string.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the internal path corresponding with original path '" + originalPath + "', action '" + action + "', and type '" + typeName + "'."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Type name: " + typeName);

                string shortPath = GetShortPath(originalPath);

                // If a projection is found with the action and type name
                if (ProjectionState.Projections.Contains(action, typeName))
                {
                    string projectionName = ProjectionState.Projections[action, typeName].Name;

                    LogWriter.Debug("Found projection by action and type name.");

                    newPath = String.Format("{0}/{1}?a={2}&t={3}&f={4}",
                                            ApplicationPath,
                                            GetRealPageName(originalPath),
                                            UrlEncode(action),
                                            UrlEncode(typeName),
                                            format);

                    newPath = AddQueryStrings(originalPath, newPath, action, typeName);
                }
                else
                {
                    LogWriter.Debug("No projection found with action '" + action + "' and type '" + typeName + "'.");
                }

                LogWriter.Debug("New path: " + newPath);
            }
            return(newPath);
        }
Пример #21
0
        /// <summary>
        /// Creates a raw/standard URL to the page corresponding with the specified action and specified type.
        /// </summary>
        /// <param name="action">The action to be performed at the target page.</param>
        /// <param name="typeName">The name of the type being acted upon at the target page.</param>
        /// <param name="format">The format of the target projection.</param>
        /// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
        public string CreateStandardUrl(string action, string typeName, ProjectionFormat format)
        {
            string link = String.Empty;
            using (LogGroup logGroup = LogGroup.StartDebug("Creating a standard URL for the specified action and type, with the specified format."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Type name: " + typeName);

                LogWriter.Debug("Format: " + format);

                link = ApplicationPath + "/Projector.aspx?a=" + PrepareForUrl(action) + "&t=" + PrepareForUrl(typeName) + "&f=" + PrepareForUrl(format.ToString());
                link = AddResult(link);

                LogWriter.Debug("Link: " + link);
            }
            return link;
        }
Пример #22
0
        public string GetInternalPathFromCommand(string originalPath, string command, ProjectionFormat format)
        {
            string internalPath = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the internal path corresponding with original path '" + originalPath + "' and command '" + command + "'."))
            {
                string[] parts = command.Split('-');

                if (parts.Length == 2)
                {
                    string typeName = String.Empty;
                    string action = String.Empty;

                    if (EntityState.IsType(parts[0]))
                    {
                        LogWriter.Debug("First file name part matches an entity.");

                        typeName = parts[0];
                        action = parts[1];
                    }
                    else if (EntityState.IsType(parts[1]))
                    {
                        LogWriter.Debug("Second file name part matches an entity.");

                        typeName = parts[1];
                        action = parts[0];
                    }
                    else
                        throw new Exception("Cannot find a type '" + parts[0] + "' or '" + parts[1] + "'.");

                    internalPath = GetInternalPathFromActionAndType(originalPath, action, typeName, format);
                }
                else
                    internalPath = GetInternalPathFromName(originalPath, command, format);

                LogWriter.Debug("Internal path: " + internalPath);
            }
            return internalPath;
        }
Пример #23
0
        public string GetInternalPathFromCommand(string originalPath, string command, ProjectionFormat format)
        {
            string internalPath = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the internal path corresponding with original path '" + originalPath + "' and command '" + command + "'."))
            {
                string[] parts = command.Split('-');

                if (parts.Length == 2)
                {
                    string typeName = String.Empty;
                    string action   = String.Empty;

                    if (EntityState.IsType(parts[0]))
                    {
                        LogWriter.Debug("First file name part matches an entity.");

                        typeName = parts[0];
                        action   = parts[1];
                    }
                    else if (EntityState.IsType(parts[1]))
                    {
                        LogWriter.Debug("Second file name part matches an entity.");

                        typeName = parts[1];
                        action   = parts[0];
                    }
                    else
                    {
                        throw new Exception("Cannot find a type '" + parts[0] + "' or '" + parts[1] + "'.");
                    }

                    internalPath = GetInternalPathFromActionAndType(originalPath, action, typeName, format);
                }
                else
                {
                    internalPath = GetInternalPathFromName(originalPath, command, format);
                }

                LogWriter.Debug("Internal path: " + internalPath);
            }
            return(internalPath);
        }
Пример #24
0
        /// <summary>
        /// Extracts the page format from teh provided URL and adds it to the query strings dictionary.
        /// </summary>
        /// <param name="friendlyUrl"></param>
        /// <param name="queryStrings"></param>
        /// <returns></returns>
        public void ExtractFormatQueryString(string friendlyUrl, Dictionary <string, string> queryStrings)
        {
            ProjectionFormat format = GetFormat(GetExtension(friendlyUrl));

            queryStrings.Add("f", format.ToString());
        }
 public bool ProjectionExists(string action, string typeName, ProjectionFormat format)
 {
     return(StateValueExists(GetProjectionKey(action, typeName, format)));
 }
Пример #26
0
 public ProjectionNotFoundException(string action, string typeName, ProjectionFormat format) : base("A projection could not be found to carry out action '" + action + "', entity type '" + typeName + "' and output format '" + format + "'.")
 {
     Action   = action;
     TypeName = typeName;
     Format   = format;
 }
 /// <summary>
 /// Gets/sets the specified projection.
 /// </summary>
 public ProjectionInfo this[string name, ProjectionFormat format]
 {
     get { return(GetProjection(name, format)); }
     set { SetProjection(name, format, value); }
 }
 /// <summary>
 /// Sets the projection with the provided action and type.
 /// </summary>
 /// <param name="action">The action that the projection performs.</param>
 /// <param name="type">The type of entity involved in the projection</param>
 /// <param name="projection">The projection that corresponds with the specified action and type.</param>
 /// <param name="format">The output format of the projection.</param>
 public void SetProjection(string action, string type, ProjectionFormat format, ProjectionInfo projection)
 {
     base[GetProjectionKey(action, type, format)] = projection;
 }
 public ProjectionNotFoundException(string name, ProjectionFormat format)
     : base("A projection could not be found with the name '" + name + "' and output format '" + format + "'.")
 {
     Name = name;
     Format = format;
 }
        /// <summary>
        /// Sets the projection with the provided name.
        /// </summary>
        /// <param name="action">The name of the projection.</param>
        /// <param name="projection">The projection that corresponds with the specified action and type.</param>
        /// <param name="format">The output format of the projection.</param>
        public void SetProjection(string name, ProjectionFormat format, ProjectionInfo projection)
        {
            string key = GetProjectionKey(name, format);

            base[key] = projection;
        }
Пример #31
0
        /// <summary>
        /// Creates a raw/standard URL to the page corresponding with the specified action and entity.
        /// </summary>
        /// <param name="action">The action to be performed at the target page.</param>
        /// <param name="entity">The entity involved in the action.</param>
        /// <param name="format">The format of the target projection.</param>
        /// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
        public string CreateStandardUrl(string action, IEntity entity, ProjectionFormat format)
        {
            string link = String.Empty;
            using (LogGroup logGroup = LogGroup.StartDebug("Creating a standard URL for the specified action and provided entity type, with the specified format."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Entity type: " + entity.ShortTypeName);
                LogWriter.Debug("Format: " + format.ToString());

                link = ApplicationPath + "/Projector.aspx?a=" + PrepareForUrl(action) + "&t=" + PrepareForUrl(entity.ShortTypeName) + "&f=" + PrepareForUrl(format.ToString()) + "&" + PrepareForUrl(entity.ShortTypeName) + "-ID=" + PrepareForUrl(entity.ID.ToString());
                link = AddResult(link);

                LogWriter.Debug("Link: " + link);
            }
            return link;
        }
        /// <summary>
        /// Retrieves the key for the specifid action and type.
        /// </summary>
        /// <param name="action"></param>
        /// <param name="type"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public string GetProjectionKey(string action, string type, ProjectionFormat format)
        {
            string fullKey = type + "_" + action + "_" + format.ToString();

            return(fullKey);
        }
 /// <summary>
 /// Retrieves the projection with the provided action and type.
 /// </summary>
 /// <param name="action">The action that the projection performs.</param>
 /// <param name="typeName">The type of entity involved in the projection</param>
 /// <param name="format">The output format of the desired projection.</param>
 /// <returns>The projection matching the provided action and type.</returns>
 public ProjectionInfo GetProjection(string action, string typeName, ProjectionFormat format)
 {
     return(GetProjection(action, typeName, format, true));
 }
Пример #34
0
        /// <summary>
        /// Creates a raw/standard URL to the page corresponding with the specified action and specified type.
        /// </summary>
        /// <param name="action">The action to be performed at the target page.</param>
        /// <param name="typeName">The name of the type being acted upon at the target page.</param>
        /// <param name="propertyName">The name of the property to filter the specified type by.</param>
        /// <param name="value">The value of the property to filter the specified type by.</param>
        /// <param name="format">The format of the target projection.</param>
        /// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
        public string CreateStandardUrl(string action, string typeName, string propertyName, string value, ProjectionFormat format)
        {
            string link = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Creating a standard URL for the specified action and provided entity type, with the specified property name and value, as well as the specified format."))
            {
                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Type name: " + typeName);

                LogWriter.Debug("Property name: " + propertyName);
                LogWriter.Debug("Value: " + value);

                LogWriter.Debug("Format: " + format.ToString());

                link = ApplicationPath + "/Projector.aspx?a=" + PrepareForUrl(action) + "&t=" + PrepareForUrl(typeName) + "&f=" + PrepareForUrl(format.ToString()) + "&" + PrepareForUrl(typeName) + "-" + PrepareForUrl(propertyName) + "=" + PrepareForUrl(value);
                link = AddResult(link);

                LogWriter.Debug("Link: " + link);
            }
            return(link);
        }
Пример #35
0
        public string GetInternalPathFromActionAndType(string originalPath, string action, string typeName, ProjectionFormat format)
        {
            string newPath = string.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the internal path corresponding with original path '" + originalPath + "', action '" + action + "', and type '" + typeName + "'."))
            {

                LogWriter.Debug("Action: " + action);
                LogWriter.Debug("Type name: " + typeName);

                string shortPath = GetShortPath(originalPath);

                // If a projection is found with the action and type name
                if (ProjectionState.Projections.Contains(action, typeName))
                {
                    string projectionName = ProjectionState.Projections[action, typeName].Name;

                    LogWriter.Debug("Found projection by action and type name.");

                    newPath = String.Format("{0}/{1}?a={2}&t={3}&f={4}",
                                            ApplicationPath,
                                            GetRealPageName(originalPath),
                                            UrlEncode(action),
                                            UrlEncode(typeName),
                                            format);

                    newPath = AddQueryStrings(originalPath, newPath, action, typeName);
                }
                else
                    LogWriter.Debug("No projection found with action '" + action + "' and type '" + typeName + "'.");

                LogWriter.Debug("New path: " + newPath);

            }
            return newPath;
        }
 /// <summary>
 /// Retrieves the projection with the provided name.
 /// </summary>
 /// <param name="name">The name of the projection.</param>
 /// <param name="format">The output format of the desired projection.</param>
 /// <returns>The projection with the specified name.</returns>
 public ProjectionInfo GetProjection(string name, ProjectionFormat format)
 {
     return(GetProjection(name, format, true));
 }
Пример #37
0
        public string GetInternalPathFromName(string originalPath, string projectionName, ProjectionFormat format)
        {
            string newPath = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the internal path corresponding with original path '" + originalPath + "' and projection name '" + projectionName + "'."))
            {
                LogWriter.Debug("Found projection by name");

                newPath = String.Format("{0}/{1}?n={2}&f={3}",
                                        ApplicationPath,
                                        GetRealPageName(originalPath),
                                        UrlEncode(projectionName),
                                        format);

                newPath = AddQueryStrings(originalPath, newPath);

                LogWriter.Debug("Internal path: " + newPath);
            }
            return newPath;
        }
Пример #38
0
        public string GetInternalPathFromName(string originalPath, string projectionName, ProjectionFormat format)
        {
            string newPath = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the internal path corresponding with original path '" + originalPath + "' and projection name '" + projectionName + "'."))
            {
                LogWriter.Debug("Found projection by name");

                newPath = String.Format("{0}/{1}?n={2}&f={3}",
                                        ApplicationPath,
                                        GetRealPageName(originalPath),
                                        UrlEncode(projectionName),
                                        format);

                newPath = AddQueryStrings(originalPath, newPath);

                LogWriter.Debug("Internal path: " + newPath);
            }
            return(newPath);
        }