示例#1
0
        /// <summary>
        /// Register all actions of a TagHandler. Overwrites duplicates in favor of new actions. The actions can have side-effects.
        /// </summary>
        /// <param name="th">The tag handler from which tag actions will be consumed</param>
        public List <string> ForceRegisterHandler(ITagHandler th)
        {
            _tagHandlers.Add(th);
            _postprocesses.Add(th);

            var report = new List <string>();

            th.GetTagFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_tagFuncs.ContainsKey(x.Key))
                {
                    report.Add(TagName(x.Key));
                }

                _tagFuncs[x.Key] = x.Value;
            });
            th.GetRegexFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_regexFuncs.FirstOrDefault(pair => pair.Key.ToString().Equals(x.Key.ToString())).Key != null)
                {
                    report.Add(x.Key.ToString());
                }

                _regexFuncs[x.Key] = x.Value;
            });
            return(report);
        }
        /// <summary>
        /// Register all actions of a TagHandler. Overwrites duplicates in favor of new actions. The actions can have side-effects.
        /// </summary>
        /// <param name="th">The tag handler from which tag actions will be consumed</param>
        public IReadOnlyList <string> ForceRegisterHandler(ITagHandler th)
        {
            th = th ?? throw new ArgumentNullException(nameof(th));

            _tagHandlers.Add(th);
            _postprocesses.Add(th);

            var report = new List <string>();

            th.GetTagFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_tagFuncs.ContainsKey(x.Key))
                {
                    report.Add(TagName(x.Key));
                }

                _tagFuncs[x.Key] = x.Value;
            });
            th.GetRegexFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);

                if (_regexFuncs.FirstOrDefault(pair => pair.Key.ToString().Equals(x.Key.ToString(), StringComparison.Ordinal)).Key != null)
                {
                    report.Add(x.Key.ToString());
                }

                _regexFuncs[x.Key] = x.Value;
            });
            return(report);
        }
示例#3
0
        public static TextSnippet[] ParseMessage(string text, Color baseColor)
        {
            MatchCollection    matchCollection = Regexes.Format.Matches(text);
            List <TextSnippet> list            = new List <TextSnippet>();
            int num = 0;

            foreach (Match item in matchCollection)
            {
                if (item.Index > num)
                {
                    list.Add(new TextSnippet(text.Substring(num, item.Index - num), baseColor));
                }
                num = item.Index + item.Length;
                string      value   = item.Groups["tag"].Value;
                string      value2  = item.Groups["text"].Value;
                string      value3  = item.Groups["options"].Value;
                ITagHandler handler = GetHandler(value);
                if (handler != null)
                {
                    list.Add(handler.Parse(value2, baseColor, value3));
                    list[list.Count - 1].TextOriginal = item.ToString();
                }
                else
                {
                    list.Add(new TextSnippet(value2, baseColor));
                }
            }
            if (text.Length > num)
            {
                list.Add(new TextSnippet(text.Substring(num, text.Length - num), baseColor));
            }
            return(list.ToArray());
        }
示例#4
0
        private void ProcessTag(ParsedTag tag, Queue <string> contentTokens, StringBuilder sb)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Process tag " + tag.TagName))
            {
                var handlers = TagProvider.GetHandlers();

                if (handlers.ContainsKey(tag.TagName))
                {
                    ITagHandler handler = handlers[tag.TagName];
                    if (handler != null)
                    {
                        string contentsFlat = string.Empty;
                        foreach (string s in contentTokens)
                        {
                            contentsFlat += s;
                        }
                        using (profiler.Step("Handler Processing: " + tag.TagName))
                        {
                            handler.Process(sb, this.MTApp, this.ViewBag, this.TagProvider, tag, contentsFlat);
                        }
                    }
                }
            }
        }
示例#5
0
        protected void ExecuteCustomTag(Tag tag)
        {
            ITagHandler tagHandler = customTags[tag.Name];

            bool processInnerElements = true;
            bool captureInnerContent  = false;

            tagHandler.TagBeginProcess(this, tag, ref processInnerElements, ref captureInnerContent);

            string innerContent = null;

            if (processInnerElements)
            {
                TextWriter saveWriter = writer;

                if (captureInnerContent)
                {
                    writer = new StringWriter();
                }

                try
                {
                    ProcessElements(tag.InnerElements);

                    innerContent = writer.ToString();
                }
                finally
                {
                    writer = saveWriter;
                }
            }

            tagHandler.TagEndProcess(this, tag, innerContent);
        }
示例#6
0
        // Token: 0x06000C56 RID: 3158 RVA: 0x003D8758 File Offset: 0x003D6958
        public static List <TextSnippet> ParseMessage(string text, Color baseColor)
        {
            MatchCollection    arg_13_0 = ChatManager.Regexes.Format.Matches(text);
            List <TextSnippet> list     = new List <TextSnippet>();
            int num = 0;

            foreach (Match match in arg_13_0)
            {
                if (match.Index > num)
                {
                    list.Add(new TextSnippet(text.Substring(num, match.Index - num), baseColor, 1f));
                }
                num = match.Index + match.Length;
                string      arg_A4_0 = match.Groups["tag"].Value;
                string      value    = match.Groups["text"].Value;
                string      value2   = match.Groups["options"].Value;
                ITagHandler handler  = ChatManager.GetHandler(arg_A4_0);
                if (handler != null)
                {
                    list.Add(handler.Parse(value, baseColor, value2));
                    list[list.Count - 1].TextOriginal = match.ToString();
                }
                else
                {
                    list.Add(new TextSnippet(value, baseColor, 1f));
                }
            }
            if (text.Length > num)
            {
                list.Add(new TextSnippet(text.Substring(num, text.Length - num), baseColor, 1f));
            }
            return(list);
        }
示例#7
0
        public static List <TextSnippet> ParseMessage(string text, Color baseColor)
        {
            MatchCollection    matchCollection = ChatManager.Regexes.Format.Matches(text);
            List <TextSnippet> textSnippetList = new List <TextSnippet>();
            int startIndex = 0;

            foreach (Match match in matchCollection)
            {
                if (match.Index > startIndex)
                {
                    textSnippetList.Add(new TextSnippet(text.Substring(startIndex, match.Index - startIndex), baseColor, 1f));
                }
                startIndex = match.Index + match.Length;
                string      tagName = match.Groups["tag"].Value;
                string      text1   = match.Groups["text"].Value;
                string      options = match.Groups["options"].Value;
                ITagHandler handler = ChatManager.GetHandler(tagName);
                if (handler != null)
                {
                    textSnippetList.Add(handler.Parse(text1, baseColor, options));
                    textSnippetList[textSnippetList.Count - 1].TextOriginal = match.ToString();
                }
                else
                {
                    textSnippetList.Add(new TextSnippet(text1, baseColor, 1f));
                }
            }
            if (text.Length > startIndex)
            {
                textSnippetList.Add(new TextSnippet(text.Substring(startIndex, text.Length - startIndex), baseColor, 1f));
            }
            return(textSnippetList);
        }
示例#8
0
 public ReaderManager(IRFIDGUI newgui, ITagHandler handleTagNew)
 {
     gui = newgui;
     SetDefaultReaderConfig();
     SetDefaultInventoryConfig();
     reader     = new RFIDReader(this);
     handleTags = handleTagNew;
 }
示例#9
0
 public ReaderManager(IRFIDGUI newgui, ITagHandler handleTagNew)
 {
     gui = newgui;
     SetDefaultReaderConfig();
     SetDefaultInventoryConfig();
     reader = new RFIDReader(this);
     handleTags = handleTagNew; 
 }
示例#10
0
        /// <summary>
        /// Remplacer les éléments trouvés.
        /// </summary>
        /// <param name="currentPart">OpenXmlPart courant.</param>
        /// <param name="currentXmlElement">XmlElement courant.</param>
        /// <param name="currentDataSource">Source de données courante.</param>
        /// <param name="documentId">Id document en cours.</param>
        /// <param name="isXmlData">Si la source en xml.</param>
        public static void Process(OpenXmlPart currentPart, CustomXmlElement currentXmlElement, object currentDataSource, Guid documentId, bool isXmlData)
        {
            using (ITagHandler tagHandler = CreateTagHandler(currentPart, currentXmlElement, currentDataSource, documentId, isXmlData)) {
                IEnumerable <OpenXmlElement> newElementList = tagHandler.HandleTag();
                OpenXmlElement parent = currentXmlElement.Parent;
                if (newElementList == null)
                {
                    if (currentXmlElement.Parent.GetType() != typeof(Paragraph) && currentXmlElement.Parent.GetType() != typeof(TableRow) && currentXmlElement.Parent.GetType() != typeof(Table) && currentXmlElement.Parent.GetType() != typeof(Body) && currentXmlElement.Parent.GetType() != typeof(CustomXmlRow))
                    {
                        Paragraph p = new Paragraph();
                        if (currentXmlElement.Parent.GetType() == typeof(TableCell))
                        {
                            if (currentXmlElement.Descendants <ParagraphProperties>() != null)
                            {
                                IEnumerator <ParagraphProperties> ppEnum = currentXmlElement.Descendants <ParagraphProperties>().GetEnumerator();
                                ppEnum.MoveNext();
                                if (ppEnum.Current != null)
                                {
                                    p.AppendChild <OpenXmlElement>(ppEnum.Current.CloneNode(true));
                                }
                            }
                        }

                        parent.InsertBefore(p, currentXmlElement);
                    }
                    else if (parent.GetType() == typeof(TableRow))
                    {
                        Paragraph p2 = new Paragraph();
                        TableCell tc = new TableCell();
                        if (currentXmlElement.Descendants <ParagraphProperties>() != null)
                        {
                            IEnumerator <ParagraphProperties> ppEnum = currentXmlElement.Descendants <ParagraphProperties>().GetEnumerator();
                            ppEnum.MoveNext();
                            p2.AppendChild <OpenXmlElement>(ppEnum.Current.CloneNode(true));
                        }

                        tc.AppendChild <Paragraph>(p2);
                        parent.InsertBefore(tc, currentXmlElement);
                    }
                }
                else
                {
                    OpenXmlElement lastElement = currentXmlElement;
                    foreach (OpenXmlElement currentChild in newElementList)
                    {
                        OpenXmlElement currentChildClone = (OpenXmlElement)currentChild;
                        parent.InsertAfter(currentChildClone, lastElement);
                        lastElement = currentChildClone;
                    }

                    newElementList = null;
                }

                currentXmlElement.Remove();
                currentXmlElement = null;
            }
        }
示例#11
0
 public UserController(
     IUserHandler userHandler, ITagHandler tagHandler, IRefListHandler refListHandler, IFavoriteHandler favoriteHandler
     )
     : base(userHandler)
 {
     _tagHandler      = tagHandler;
     _refListHandler  = refListHandler;
     _favoriteHandler = favoriteHandler;
 }
示例#12
0
        public ReaderManager(IRFIDGUI newgui, ITagHandler handleTagNew)
        {
            gui = newgui;
            SetDefaultReaderConfig();
            SetDefaultInventoryConfig();
            reader = new RFIDReader(this);
            handleTags = handleTagNew;

            // Initialization
            mobility_probe_round = 0;
            mobility_rssi_diff = 0;
            mobility_fading_diff = 0;

            mobility_pattern = new int[2, 50];
            tagInfo.rssi = new int[50];
            for (int ii = 0; ii < 50; ii++)
            {
                tagInfo.rssi[ii] = 0;
            }
            channel_counter = 0;
            // Load channel/rssi template information
            channelTemplate = new double[7, 50];
            rssiTemplate = new short[7, 50];
            using (StreamReader sr = new StreamReader("loss_fast_probe.dat"))
            {
                String line;
                int lineNum = 0;
                line = sr.ReadLine();
                while (line != null)
                {
                    String[] lineSplit = line.Split();
                    for (int ii = 0; ii < 50; ii++)
                    {
                        channelTemplate[lineNum, ii] = Convert.ToDouble(lineSplit[ii]);
                    }
                    lineNum += 1;
                    line = sr.ReadLine();
                }
            }
            using (StreamReader sr = new StreamReader("rssi_fast_probe.dat"))
            {
                String line;
                int lineNum = 0;
                line = sr.ReadLine();
                while (line != null)
                {
                    String[] lineSplit = line.Split();
                    for (int ii = 0; ii < 50; ii++)
                    {
                        rssiTemplate[lineNum, ii] = Convert.ToInt16(lineSplit[ii]);
                    }
                    lineNum += 1;
                    line = sr.ReadLine();
                }
            }
        }
示例#13
0
        public ReaderManager(IRFIDGUI newgui, ITagHandler handleTagNew)
        {
            gui = newgui;
            SetDefaultReaderConfig();
            SetDefaultInventoryConfig();
            reader     = new RFIDReader(this);
            handleTags = handleTagNew;

            // Initialization
            mobility_probe_round = 0;
            mobility_rssi_diff   = 0;
            mobility_fading_diff = 0;

            mobility_pattern = new int[2, 50];
            tagInfo.rssi     = new int[50];
            for (int ii = 0; ii < 50; ii++)
            {
                tagInfo.rssi[ii] = 0;
            }
            channel_counter = 0;
            // Load channel/rssi template information
            channelTemplate = new double[7, 50];
            rssiTemplate    = new short[7, 50];
            using (StreamReader sr = new StreamReader("loss_fast_probe.dat"))
            {
                String line;
                int    lineNum = 0;
                line = sr.ReadLine();
                while (line != null)
                {
                    String[] lineSplit = line.Split();
                    for (int ii = 0; ii < 50; ii++)
                    {
                        channelTemplate[lineNum, ii] = Convert.ToDouble(lineSplit[ii]);
                    }
                    lineNum += 1;
                    line     = sr.ReadLine();
                }
            }
            using (StreamReader sr = new StreamReader("rssi_fast_probe.dat"))
            {
                String line;
                int    lineNum = 0;
                line = sr.ReadLine();
                while (line != null)
                {
                    String[] lineSplit = line.Split();
                    for (int ii = 0; ii < 50; ii++)
                    {
                        rssiTemplate[lineNum, ii] = Convert.ToInt16(lineSplit[ii]);
                    }
                    lineNum += 1;
                    line     = sr.ReadLine();
                }
            }
        }
示例#14
0
 public ListController(
     IUserHandler userHandler, ITagHandler tagHandler, IRefListHandler refListHandler, IFavoriteHandler favoriteHandler,
     RefListViewModelReader refListViewModelReader
     )
     : base(userHandler)
 {
     _tagHandler             = tagHandler;
     _refListHandler         = refListHandler;
     _favoriteHandler        = favoriteHandler;
     _refListViewModelReader = refListViewModelReader;
 }
示例#15
0
        public void RegisterTag(string tagName, ITagHandler tagHandler)
        {
            if (tagName == null)
                throw new ArgumentNullException("tagName");
            if (tagHandler == null)
                throw new ArgumentNullException("tagHandler");

            if (customTags.ContainsKey(tagName))
                throw new ArgumentException(String.Format("Tag {0} is already registered.", tagName));

            customTags.Add(tagName, tagHandler);
        }
示例#16
0
        public RefListHandler(
            IRefsContext refsContext, ISearchEngine searchEngine, IUserHandler userHandler, ITagHandler tagHandler,
            IChannel channel
            )
        {
            _refsContext  = refsContext;
            _searchEngine = searchEngine;
            _userHandler  = userHandler;
            _tagHandler   = tagHandler;

            _channel = channel;
        }
示例#17
0
 private void ProcessTag(ParsedTag tag, Queue <string> contents, StringBuilder sb)
 {
     if (Handlers.ContainsKey(tag.TagName))
     {
         ITagHandler handler = Handlers[tag.TagName];
         if (handler != null)
         {
             string contentsFlat = string.Empty;
             foreach (string s in contents)
             {
                 contentsFlat += s;
             }
             sb.Append(handler.Process(this.MTApp, Handlers, tag, contentsFlat));
         }
     }
 }
        private void CheckExamplesExist(ITagHandler th, AnonFunc f)
        {
            if (_testingmode)
            {
                return;
            }

            var exampMethod = th.GetType().GetMethod(f.Method.Name + "Examples");

            if (exampMethod == null)
            {
                throw new FormatException(string.Format(CultureInfo.InvariantCulture, "{0}:{1} Examples are missing.", f.Target.GetType().FullName, f.Method.Name));
            }
            if (!exampMethod.IsStatic)
            {
                throw new FormatException(string.Format(CultureInfo.InvariantCulture, "{0}:{1} should be static.", f.Target.GetType().FullName, f.Method.Name));
            }
        }
示例#19
0
        /// <summary>
        /// Register all actions of a TagHandler. If a tag is already handled, we throw an error.
        /// </summary>
        /// <param name="th">The tag handler from which tag actions will be consumed</param>
        public void RegisterHandler(ITagHandler th)
        {
            _tagHandlers.Add(th);
            _postprocesses.Add(th);

            // TODO: check that handlers respect VR
            th.GetTagFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);
                _tagFuncs.Add(x.Key, x.Value);
            });
            th.GetRegexFuncs()?.ToList().ForEach(x =>
            {
                CheckAnonymizationAttributesExist(x.Value);
                CheckExamplesExist(th, x.Value);
                _regexFuncs.Add(x.Key, x.Value);
            });
        }
示例#20
0
 private void AddHandler(Dictionary<string, ITagHandler> handlers, ITagHandler handler)
 {
     handlers.Add(handler.TagName, handler);
 }
示例#21
0
        private void ProcessTag(JToken obj, JObject root, App app, List <TagReturn> tagReturn, ITagHandler handler)
        {
            JToken tokenToProcess = null;

            if (obj.Children().Any() && obj.Children().First().Type == JTokenType.Array)
            {
                tokenToProcess = obj.Children().First();
            }
            else
            {
                tokenToProcess = obj.Value <JToken>();
            }

            try
            {
                List <TagReturn> result =
                    (List <TagReturn>)handler.ProcessTag(tokenToProcess, root, this.allPages, this.Actions, app,
                                                         tagReturn);
                if (result != null)
                {
                    tagReturn.AddRange(result);
                }
            }
            catch (Exception)
            {
                // Swallow if skip set
                if (!this.SkipError)
                {
                    throw;
                }
            }
        }
示例#22
0
 public TagUseController(IUserHandler userHandler, ITagHandler tagHandler, IRefListHandler refListHandler)
     : base(userHandler)
 {
     _tagHandler     = tagHandler;
     _refListHandler = refListHandler;
 }
 /// <summary>
 /// registers custom tag processor
 /// </summary>
 public void RegisterCustomTag(string tagName, ITagHandler handler)
 {
     CustomTags.Add(tagName, handler);
 }
示例#24
0
 /// <summary>
 /// registers custom tag processor
 /// </summary>
 public void RegisterCustomTag(string tagName, ITagHandler handler)
 {
     CustomTags.Add(tagName, handler);
 }
示例#25
0
 private void AddHandler(Dictionary <string, ITagHandler> handlers, ITagHandler handler)
 {
     handlers.Add(handler.TagName, handler);
 }
示例#26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Load values from data object
            if (ObjectID.HasValue)
            {
                dataObject = DataObject.Load <DataObject>(ObjectID, null, true);

                this.Copyright.SelectedValue = dataObject.Copyright.ToString();
                if (dataObject.Geo_Lat != double.MinValue && dataObject.Geo_Long != double.MinValue)
                {
                    this.TxtGeoLat.Text  = dataObject.Geo_Lat.ToString();
                    this.TxtGeoLong.Text = dataObject.Geo_Long.ToString();
                }
                this.HFZip.Value     = dataObject.Zip;
                this.HFCity.Value    = dataObject.City;
                this.HFStreet.Value  = dataObject.Street;
                this.HFCountry.Value = dataObject.CountryCode;
            }

            // Overwrite values with query string
            if (!string.IsNullOrEmpty(Request.QueryString["CR"]))
            {
                this.Copyright.SelectedValue = Request.QueryString["CR"];
            }

            string[] geoLatLong = Request.QueryString["GC"] == null ? null : Request.QueryString["GC"].Split(',');
            if (geoLatLong != null && geoLatLong.Length == 2)
            {
                this.TxtGeoLat.Text  = geoLatLong[0];
                this.TxtGeoLong.Text = geoLatLong[1];
            }
            if (!string.IsNullOrEmpty(Request.QueryString["ZP"]))
            {
                this.HFZip.Value = Server.UrlDecode(Request.QueryString["ZP"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["CI"]))
            {
                this.HFCity.Value = Server.UrlDecode(Request.QueryString["CI"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["RE"]))
            {
                this.HFStreet.Value = Server.UrlDecode(Request.QueryString["RE"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["CO"]))
            {
                this.HFCountry.Value = Server.UrlDecode(Request.QueryString["CO"]);
            }

            // Load view control
            if (!string.IsNullOrEmpty(Helper.GetObjectType(ObjectType).ViewHandlerCtrl))
            {
                string viewHandlerControl = Helper.GetObjectType(ObjectType).ViewHandlerCtrl;
                objectViewHandler                  = (IViewHandler)this.LoadControl(viewHandlerControl);
                objectViewHandler.DataObject       = dataObject;
                objectViewHandler.ParentDataObject = CommunityID.HasValue ? DataObject.Load <DataObject>(CommunityID, null, true) : null;
                this.PhView.Controls.Add((Control)objectViewHandler);
            }

            // Load tag control
            if (!string.IsNullOrEmpty(Helper.GetObjectType(ObjectType).TagHandlerCtrl))
            {
                string tagHandlerControl = !string.IsNullOrEmpty(OverrideTagHandlerControl) ? OverrideTagHandlerControl : Helper.GetObjectType(ObjectType).TagHandlerCtrl;
                objectTagHandler = (ITagHandler)this.LoadControl(tagHandlerControl);
                if (dataObject != null)
                {
                    objectTagHandler.SetTags(dataObject.TagList);
                }
                this.PhTagging.Controls.Add((Control)objectTagHandler);
            }

            // Load community control
            if (ObjectType == Helper.GetObjectTypeNumericID("Community") && ObjectID.HasValue && !CommunityID.HasValue)
            {
                DataObjectCommunity communtiy = DataObject.Load <DataObjectCommunity>(ObjectID, null, true);
                foreach (Telerik.Web.UI.RadComboBoxItem item in this.RCBCtyGroups.Items)
                {
                    item.Text = language.GetString(string.Format("LableForumRights{0}", item.Value));
                }
                foreach (Telerik.Web.UI.RadComboBoxItem item in this.RCBCtyUpload.Items)
                {
                    item.Text = language.GetString(string.Format("LableForumRights{0}", item.Value));
                }
                this.PnlCtyGroups.Visible       = true;
                this.RCBCtyGroups.SelectedValue = ((int)communtiy.CreateGroupUser).ToString();
                this.PnlCtyUpload.Visible       = true;
                this.RCBCtyUpload.SelectedValue = ((int)communtiy.UploadUsers).ToString();
            }

            // Load geotagging
            if (CustomizationSection.CachedInstance.Modules["Geotagging"].Enabled && Helper.GetObjectType(ObjectType).IsGeoTaggable)
            {
                PnlGeoTagging.Visible = true;
                this.LnkOpenMap.Attributes.Add("onClick", string.Format("OpenGeoTagWindow('{0}', '{1}');", this.ClientID, languageShared.GetString("TitleMap").StripForScript()));
            }
        }