コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tag"></param>
        private void SkipTag(string tag)
        {
            Stack <String> startElements = new Stack <string>();

            startElements.Push(tag);
            while (NextEvent())
            {
                switch (_xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (CurrentTag.Equals(tag) && !_xmlReader.IsEmptyElement)
                    {
                        startElements.Push(tag);
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (CurrentTag.Equals(tag))
                    {
                        startElements.Pop();
                    }
                    break;
                }
                if (startElements.Count <= 0)
                {
                    break;
                }
            }
        }
コード例 #2
0
        }         // end Open

        /// <summary>
        /// Trace content, from inside a tag. No stackDepth increase; we're inside an
        /// existing method.
        /// </summary>
        /// <param name="what">the tracing content</param>
        /// <param name="sectionVerbosity"></param>
        public void SectionTrace(string what, int sectionVerbosity)
        {
            if (sectionVerbosity >= this.verbosity)
            {            // maximum verbosity leves is zero. Higher verbosity-levels prune the lower-level messages.
                lock (typeof(LogSinkDb.Library.SinkDb))
                {
                    try                    // silent log
                    {
                        if (hasPermissionsToWrite)
                        {
                            string currentTagName = "unspecified";
                            if (0 < this.tagStack.Count)
                            {
                                // peek current section, to give a signature to the tracing.
                                CurrentTag currentTag = ((CurrentTag)this.tagStack.Peek());
                                currentTagName = currentTag.tagName;
                            }// else currentTagName defaults on "unspecified".
                            bool result =                             // result==false on db-write failure.
                                          this.trace(this.TableName,                       // current TableName
                                                     't',             // 't'==trace
                                                     this.stackDepth, // current stack depth.
                                                     currentTagName,  //functionName: currentTagName defaults on "unspecified".
                                                     what);           // tracing content.
                        }                                             // endif. otherwise, without write-permission, silently skip
                    }                                                 // end try
                    catch (Exception ex)
                    {
                        this.operationException = ex.Message;
                    }
                } // end lock
            }     // otherwise just skip, non-required tracing
        }         // end trace method
コード例 #3
0
 private void OnCancel()
 {
     if (CurrentTag != null)
     {
         CurrentTag.RejectChanges();
     }
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="root"></param>
        /// <param name="currentFieldDescriptor"></param>
        private void DeserializeWrappedComposite(object root, FieldDescriptor currentFieldDescriptor)
        {
            String currentTag = CurrentTag;

            while (NextEvent() && !(_xmlReader.NodeType == XmlNodeType.EndElement && CurrentTag.Equals(currentTag)))
            {
                DeserializeComposite(root, currentFieldDescriptor);
            }
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="root"></param>
        /// <param name="fd"></param>
        private void DeserializeScalarCollection(object root, FieldDescriptor fd)
        {
            String currentTag = CurrentTag;

            while (NextEvent() && !(_xmlReader.NodeType == XmlNodeType.EndElement && CurrentTag.Equals(currentTag)))
            {
                DeserializeScalarCollectionElement(root, fd);
            }
        }
コード例 #6
0
        private void UpdateMenuButtons(ScreenMenuCategory category)
        {
            MenuItems = CreateMenuButtons(category, CurrentPageNo, CurrentTag ?? "");

            SubCategories.Clear();
            SubCategories.AddRange(
                category.GetScreenMenuCategories(CurrentTag)
                .Select(x => new ScreenSubCategoryButton(x, SubCategoryCommand, GetCategorySubButtonColor(x, category), category.MainFontSize, category.SubButtonHeight)));

            if (!string.IsNullOrEmpty(CurrentTag))
            {
                var backButton = new ScreenSubCategoryButton(CurrentTag.Replace(CurrentTag.Split(',').Last(), "").Trim(new[] { ',', ' ' }), SubCategoryCommand, "Gainsboro", category.MainFontSize, category.SubButtonHeight, true);
                SubCategories.Add(backButton);
            }

            if (Categories != null && MenuItems.Count == 0)
            {
                if (category.NumeratorType == 2 && SubCategories.Count == 0)
                {
                    InteractionService.ShowKeyboard();
                }

                MenuItems.Clear();

                if (category.MaxItems > 0)
                {
                    IEnumerable <ScreenMenuItem> sitems = category.ScreenMenuItems.OrderBy(x => x.SortOrder);
                    if (SubCategories.Count == 0)
                    {
                        sitems = Categories.Select(x => x.Category).SelectMany(x => x.ScreenMenuItems);
                    }
                    var items = sitems.Select(x => new ScreenMenuItemButton(x, MenuItemCommand, SelectedCategory));
                    MenuItems.AddRange(items.Take(category.MaxItems));
                }
            }

            RaisePropertyChanged(() => MenuItems);
            RaisePropertyChanged(() => IsPageNumberNavigatorVisible);
            RaisePropertyChanged(() => MenuItemsVerticalAlignment);
            RaisePropertyChanged(() => SubButtonRows);
        }
コード例 #7
0
        }             // end Dispose

        #endregion


        /// <summary>
        /// open the tag
        /// </summary>
        /// <param name="curTag"></param>
        /// <param name="sectionVerbosity"></param>
        public void SectionOpen(string curTag, int sectionVerbosity)
        {
            if (sectionVerbosity >= this.verbosity)
            {                                     // maximum verbosity leves is zero. Higher verbosity-levels prune the lower-level messages.
                lock (typeof(LogSinkDb.Library.SinkDb))
                {                                 // the lock avoids multiple file-creations
                    try                           // this should happen due to interrupts during the execution of the current lock-block content
                    {
                        if (null != this.tagStack //NB. it's null on failed db-connection, and throws.
                            )
                        {
                            // push the Tag anyway on the stack. It is necessary even if it's below this.verbosity.
                            // when closing the section, the verbosity will be checked to decide wether to write.
                            CurrentTag currentTag = new CurrentTag(curTag, sectionVerbosity);
                            this.tagStack.Push(currentTag);
                            this.stackDepth++;// another method enters the stack.
                        }
                        else
                        {
                            return;// stack empty
                        }
                        //
                        if (hasPermissionsToWrite)
                        {
                            bool result =                             // TODO result==false??
                                          this.trace(this.TableName,  // current TableName
                                                     'o',             // 'o'==open
                                                     stackDepth,
                                                     curTag,
                                                     "___opening___"); // no content in a opening
                        }                                              // otherwise, without write-permission, silently skip
                    }
                    catch (Exception ex)
                    {
                        this.operationException = ex.Message;
                    }
                } // end lock
            }     // otherwise just skip, non-required tracing
        }         // end Open
コード例 #8
0
        }         // end trace method

        /// <summary>
        /// close the tag that is on the stack top.
        /// </summary>
        public void SectionClose( )
        {
            CurrentTag currentTag = null;

            if (null != this.tagStack &&           //NB. it's null on failed db-connection, and throws.
                0 < this.tagStack.Count)
            {
                //  pop the section. It will be written down only if the section verbosity is above this.verbosity.
                currentTag = ((CurrentTag)this.tagStack.Pop());
            }
            else
            {
                return;                // stack empty
            }
            //
            if (currentTag.sectionVerbosity >= this.verbosity)
            {            // maximum verbosity leves is zero. Higher verbosity-levels prune the lower-level messages.
                lock (typeof(LogSinkDb.Library.SinkDb))
                {
                    try
                    {
                        if (hasPermissionsToWrite)
                        {
                            bool result =                                // TODO result==false??
                                          this.trace(this.TableName,     // current TableName
                                                     'c',                // 'c'==close
                                                     this.stackDepth--,  // delete from the stack, after exiting.
                                                     currentTag.tagName, //functionName,
                                                     "___closing___");   // no other content in a closure.
                        }                                                // otherwise, without write-permission, silently skip
                    }                                                    // end try
                    catch (Exception ex)
                    {
                        this.operationException = ex.Message;
                    }
                } // end lock
            }     // otherwise just skip, non-required tracing
        }         // end trace method
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="root"></param>
        /// <param name="rootClassDescriptor"></param>
        /// <param name="rootTag"></param>
        private void CreateObjectModel(object root, ClassDescriptor rootClassDescriptor, string rootTag)
        {
            FieldDescriptor currentFieldDescriptor = new FieldDescriptor();

            while (NextEvent() && (_xmlReader.NodeType != XmlNodeType.EndElement || !CurrentTag.Equals(rootTag)))
            {
                if (_xmlReader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (currentFieldDescriptor.FdType != FieldTypes.Wrapper)
                {
                    currentFieldDescriptor = rootClassDescriptor.GetFieldDescriptorByTag(CurrentTag);
                }

                if (currentFieldDescriptor == null)
                {
                    //Debug.WriteLine("ignoring tag " + CurrentTag);
                    currentFieldDescriptor = FieldDescriptor.MakeIgnoredFieldDescriptor(CurrentTag);

                    if (!_xmlReader.IsEmptyElement)
                    {
                        SkipTag(CurrentTag);
                    }
                    continue;
                }

                switch (currentFieldDescriptor.FdType)
                {
                case FieldTypes.Scalar:
                    DeserializeScalar(root, currentFieldDescriptor);
                    break;

                case FieldTypes.CompositeElement:
                    DeserializeComposite(root, currentFieldDescriptor);
                    break;

                case FieldTypes.CollectionScalar:
                    DeserializeScalarCollectionElement(root, currentFieldDescriptor);
                    break;

                case FieldTypes.CollectionElement:
                    DeserializeCompositeCollectionElement(root, currentFieldDescriptor);
                    break;

                case FieldTypes.MapElement:
                    DeserializeCompositeMapElement(root, currentFieldDescriptor);
                    break;

                case FieldTypes.Wrapper:
                    currentFieldDescriptor = currentFieldDescriptor.WrappedFd;
                    switch (currentFieldDescriptor.FdType)
                    {
                    case FieldTypes.CollectionScalar:
                        DeserializeScalarCollection(root, currentFieldDescriptor);
                        break;

                    case FieldTypes.CollectionElement:
                        DeserializeCompositeCollection(root, currentFieldDescriptor);
                        break;

                    case FieldTypes.MapElement:
                        DeserializeCompositeMap(root, currentFieldDescriptor);
                        break;

                    case FieldTypes.CompositeElement:
                        DeserializeWrappedComposite(root, currentFieldDescriptor);
                        break;
                    }
                    break;

                case FieldTypes.IgnoredElement:
                    SkipTag(CurrentTag);
                    break;

                default:
                    NextEvent();
                    break;
                }
            }

            DeserializationPostHook(root, translationContext);
            if (deserializationHookStrategy != null)
            {
                deserializationHookStrategy.DeserializationPostHook(root, null);
            }
        }
コード例 #10
0
 private void OnSave()
 {
     CurrentTag.AcceptChanges();
 }