Exemplo n.º 1
0
        //This parses out the keywords and replaces them with the dynamic data
        private string ParseFeed(string content)
        {
            ReplacerController controller = new ReplacerController();

            List <ReplacerModel> replacerModels = controller.LoadReplacers();

            StringBuilder builder = new StringBuilder(content);

            State state = new State();

            foreach (ReplacerModel replacerModel in replacerModels)
            {
                try
                {
                    PropertyInfo property = typeof(CustomerModel).GetProperty(replacerModel.DataField);

                    builder.Replace(replacerModel.Keyword, System.Convert.ToString(property.GetValue(customer, null)));
                }
                catch (Exception ex)
                {
                    Logger.CreateLog(CustomerId, Referrer, "Parsing of content failed. " + ex.InnerException, 1);
                    state.Cache().SetError(ex);
                    Response.Redirect("Error.aspx");
                }
            }

            return(builder.ToString());
        }
Exemplo n.º 2
0
        private void LoadReplacers()
        {
            ReplacerController replacerController = new ReplacerController();

            List <ReplacerModel> replaceModels = replacerController.LoadReplacers();

            ReplacerList.DataSource = replaceModels;
            ReplacerList.DataBind();

            List <string> possibleFields = new List <string>();

            //loading customer object to iterate through properties and display them
            CustomerModel model = new CustomerModel();

            PropertyInfo[] properties = model.GetType().GetProperties();

            foreach (PropertyInfo prop in properties)
            {
                possibleFields.Add(prop.Name);
            }

            PossibleFields.Text = string.Join(", ", possibleFields.ToArray());
        }