コード例 #1
0
        async void FindReplacementsAsync()
        {
            Replacements.Clear();
            replacementsModel.SetReplaced(DisplayedCourses.ElementAt(SelectedCourseIndex).Model);

            List <ReplacementModel> result = null;

            result = await Task.Run(() => {
                try
                {
                    return(replacementsModel.GetReplacementsFromData());
                }
                catch (DataServiceException e)
                {
                    Debug.WriteLine(e.Message);
                    ShowAlert();
                }
                return(result);
            });

            if (result != null)
            {
                foreach (ReplacementModel rm in result)
                {
                    Replacements.Add(new ReplacementViewModel(rm));
                }
            }
        }
コード例 #2
0
        public HtmlTypographerSettings Replace(string pattern, string replacement,
                                               StringReplacementMode mode, RegexOptions options)
        {
            StringReplacementRule rule = new StringReplacementRule(mode, pattern, replacement);

            rule.Options = options;

            Replacements.Add(rule);
            return(this);
        }
コード例 #3
0
        public ParameterManipulator(IDictionary <string, string> replacements, ParameterOptions options)
        {
            Options |= options;

            foreach (var item in replacements)
            {
                var re    = new Regex(string.Format(Pattern, item.Key));
                var value = MakeSqlValue(item.Value);
                Replacements.Add(re, value);
            }
        }
コード例 #4
0
 /// <summary>
 /// Adds a replacement value for a token.
 /// </summary>
 public void AddReplacement(string token, object replacement)
 {
     if (replacement is bool)
     {
         Replacements.Add(token, ((bool)replacement) ? "true" : "false");
     }
     else
     {
         Replacements.Add(token, string.Format("{0}", replacement));
     }
 }
コード例 #5
0
        /// <summary>
        /// Display a dialog to collect settings
        /// </summary>
        public override void ShowSettingsDialog()
        {
            Replacements.Add(ItemPropertyValues.FieldEditorUserControl, "<Field Name=\"FieldEditorUserControl\">/_controltemplates/$rootname$FieldEditor.ascx</Field>");
            Replacements.Add(ItemPropertyValues.HideCustomProperty, "TRUE");

            //DialogResult dr = MessageBox.Show("Do you want to use a custom control on the edit field page? Due to a SharePoint bug (http://support.microsoft.com/kb/932055), this is required if the 12/4/2007 hotfix is not applied.", "Use custom field editor?", MessageBoxButtons.YesNo);
            //useFieldEditorUserControl = dr == DialogResult.Yes;

            //if (!useFieldEditorUserControl)
            //{
            //    Replacements.Add("$FieldEditorUserControl$", "<!-- A SharePoint bug (http://support.microsoft.com/kb/932055) may prevent the custom properties below working. Use a custom field editor control or see http://thomascarpe.com/Lists/Posts/Post.aspx?ID=25 for an alternative workaround. -->");
            //    Replacements.Add("$HideCustomProperty$", "FALSE");
            //}
            //else
            //{
            //    Replacements.Add("$FieldEditorUserControl$", "<Field Name=\"FieldEditorUserControl\">/_controltemplates/$rootname$FieldEditor.ascx</Field>");
            //    Replacements.Add("$HideCustomProperty$", "TRUE");
            //}
        }
コード例 #6
0
        /// <summary>
        /// Creates the object to make copy of the web files template replacing texts
        /// </summary>
        /// <returns>The text replacements tool</returns>
        private Replacements CreateTextReplacements()
        {
            // Generate search form HTML code:
            // TODO: Remove html resources
            //string textSearch = Project.FullTextSearch ? Resources.SearchFormFullText : Resources.SearchFormSimple;

            // Ugly thing: On search.aspx page there can be page header an footer, and they can contain
            // links to previous, next and home. Make a static replacement now:
            string header = Decorator.HeaderHtmlCode.Replace(HtmlPageDecorator.HOMEPAGELINK, "#")
                            .Replace(HtmlPageDecorator.PREVIOUSPAGELINK, "#")
                            .Replace(HtmlPageDecorator.NEXTPAGELINK, "#");
            string footer = Decorator.FooterHtmlCode.Replace(HtmlPageDecorator.HOMEPAGELINK, "#")
                            .Replace(HtmlPageDecorator.PREVIOUSPAGELINK, "#")
                            .Replace(HtmlPageDecorator.NEXTPAGELINK, "#");

            // Create standard replacements:
            Replacements replacements = new Replacements();

            replacements.Add("%BOOLFULLSEARCH%", Project.FullTextSearch ? "true" : "false");
            replacements.Add("%TITLE%", HttpUtility.HtmlEncode(Project.HelpTitle));
            replacements.Add("%TREE%", CreateHtmlTree("contentsTree", "contentTree"));
            replacements.Add("%TOPICS%", GenerateWebIndex());
            replacements.Add("%FIRSTPAGEURL%", Document.FirstNodeWithContent.Href);
            replacements.Add("%FIRSTPAGECONTENT%", Document.FirstSplittedContent);
            replacements.Add("%WEBDESCRIPTION%", Decorator.MetaDescriptionTag);
            replacements.Add("%KEYWORDS%", Decorator.MetaKeywordsTag);
            replacements.Add("%HEADER%", header);
            replacements.Add("%FOOTER%", footer);
            replacements.Add("%HEADINCLUDE%", Decorator.HeadIncludeHtmlCode);

            // Load translation files.
            string translationFile = Path.Combine(System.Windows.Forms.Application.StartupPath, "webTranslations");

            translationFile = Path.Combine(translationFile, Project.WebLanguage + ".txt");
            try
            {
                replacements.AddReplacementsFromFile(translationFile);
            }
            catch (Exception ex)
            {
                UI.Log("Error opening web translations file" + translationFile + ": " + ex.Message, ChmLogLevel.ERROR);
                UI.Log(ex);
            }

            return(replacements);
        }
コード例 #7
0
ファイル: crAccessoryTXT.cs プロジェクト: q4a/ToxicRagers
        public AccessoryBreak(DocumentParser sr)
        {
            bool inBreak = true;

            string[] settings;

            if (!Accessory.TestLine("Breakable", sr.ReadNextLine(), out string line))
            {
                Console.WriteLine("Unexpected value: {0}", line);
            }

            while (inBreak)
            {
                line = sr.ReadNextLine();
                if (line == null)
                {
                    break;
                }

                settings = line.Split(' ');

                switch (settings[0].ToLower())
                {
                case "break":
                case "break_impulse":
                    BreakImpulse = settings[settings.Length - 1].ToInt();
                    break;

                case "detach_children":
                case "detatch_children":
                    DetatchChildren = true;
                    break;

                case "destroy_children":
                    DestroyChildren = true;
                    break;

                case "explode":
                case "explode_force":
                    ExplodeForce = settings[settings.Length - 1].ToInt();
                    break;

                case "random_rotation":
                    if (settings.Length == 2)
                    {
                        RandomRotation = Vector2.Parse(settings[1]);
                    }
                    else
                    {
                        RandomRotation = new Vector2(settings[1].ToSingle(), settings[2].ToSingle());
                    }
                    break;

                case "sound":
                    Sound = settings[1];
                    break;

                case "trigger_particles":
                    TriggerParticles = true;
                    break;

                case "collision_with_world_will_break_me":
                    Console.WriteLine("collision_with_world_will_break_me: {0}", settings[1]);
                    break;

                case "replace":
                    if (settings.Length == 3)
                    {
                        Replacements.Add(new AccessoryBreakReplacement(settings[1], settings[2]));
                    }
                    else
                    {
                        Replacements.Add(new AccessoryBreakReplacement(settings[1]));
                    }
                    break;

                default:
                    inBreak = false;

                    if (!settings[0].StartsWith("[") && !settings[0].StartsWith("<"))
                    {
                        Console.WriteLine("Unexpected setting: {0}", settings[0]);
                    }
                    else
                    {
                        sr.Rewind();
                    }
                    break;
                }
            }
        }
コード例 #8
0
 protected void AddReplacement(string find, string replaceBy, bool isRegex)
 {
     Replacements.Add(new Replacement {
         Find = find, ReplaceBy = replaceBy, IsRegex = isRegex
     });
 }