void AddChildren(TemplateCategory category)
 {
     foreach (var childCodon in ChildNodes.OfType <TemplateCategoryCodon> ())
     {
         category.AddCategory(childCodon.ToTemplateCategory());
     }
 }
 internal override void OnProjectSet()
 {
     base.OnProjectSet();
     foreach (var p in ChildNodes.OfType <MSBuildProperty> ())
     {
         p.ResolvePath();
     }
 }
        public MSBuildProperty GetProperty(string name, string condition)
        {
            MSBuildProperty prop;

            properties.TryGetValue(name, out prop);
            if (!string.IsNullOrEmpty(condition) && prop != null && prop.Condition != condition)
            {
                // There may be more than one property with the same name and different condition. Try to find the correct one.
                prop = ChildNodes.OfType <MSBuildProperty> ().FirstOrDefault(pr => pr.Name == name && pr.Condition == condition) ?? prop;
            }
            return(prop);
        }
Esempio n. 4
0
        protected override void OnNodeInit()
        {
            Expression = ChildNodes.OfType <IExpressionNode>().FirstOrDefault();
            Name       = ChildNodes.OfType <ObjectNameNode>().FirstOrDefault();

            var aliasNode = this.FindByName("select_as_opt");

            if (aliasNode != null)
            {
                Alias = aliasNode.FindNode <IdentifierNode>();
            }
        }
Esempio n. 5
0
 IEnumerable <HtmlElement> GetRows()
 {
     foreach (var childNode in ChildNodes.OfType <HtmlElement>())
     {
         if (childNode is HtmlTableRowElement)
         {
             yield return(childNode);
         }
         else if (childNode is HtmlTableSectionElement)
         {
             foreach (var sectionRow in childNode.ChildNodes.OfType <HtmlTableRowElement>())
             {
                 yield return(sectionRow);
             }
         }
     }
 }
Esempio n. 6
0
        public XmlElement GetProjectExtension(string section)
        {
            var elem = ChildNodes.OfType <MSBuildXmlElement> ().FirstOrDefault(n => n.Name == section);

            if (elem != null)
            {
                var w = new StringWriter();
                using (var tw = new XmlTextWriter(w))
                    elem.Write(tw, new WriteContext());
                var doc = new XmlDocument();
                doc.LoadXml(w.ToString());
                return(doc.DocumentElement);
            }
            else
            {
                return(null);
            }
        }
        internal void CopyFrom(MSBuildPropertyGroup other)
        {
            AssertCanModify();
            foreach (var node in other.ChildNodes)
            {
                var prop = node as MSBuildProperty;
                if (prop != null)
                {
                    var cp = prop.Clone();
                    var currentPropIndex = ChildNodes.FindIndex(p => (p is MSBuildProperty) && ((MSBuildProperty)p).Name == prop.Name);
                    if (currentPropIndex != -1)
                    {
                        var currentProp = (MSBuildProperty)ChildNodes [currentPropIndex];
                        ChildNodes = ChildNodes.SetItem(currentPropIndex, cp);
                    }
                    else
                    {
                        ChildNodes = ChildNodes.Add(cp);
                    }
                    properties [cp.Name] = cp;
                    cp.ParentNode        = PropertiesParent;
                    cp.Owner             = this;
                    cp.ResetIndent(false);
                }
                else
                {
                    ChildNodes = ChildNodes.Add(node);
                }
            }
            foreach (var prop in ChildNodes.OfType <MSBuildProperty> ().ToArray())
            {
                if (!other.HasProperty(prop.Name))
                {
                    RemoveProperty(prop);
                }
            }

            NotifyChanged();
        }
Esempio n. 8
0
        private void InsertPageTexts(XmlNode baseNode, int pageNumber)
        {
            var insertParent = baseNode;

            foreach (var child in this.pageTextsNode !.ChildNodes.OfType <XmlNode>())
            {
                var copiedChild  = insertParent.OwnerDocument !.ImportNode(child, deep: true);
                var textElements = copiedChild.SelectNodes($"//{TextNode}");
                if (textElements == null)
                {
                    continue;
                }

                string pageNumberText = pageNumber.ToString(CultureInfo.InvariantCulture);
                foreach (var element in textElements.OfType <XmlElement>())
                {
                    element.InnerText = element.InnerText.Replace(
                        "{pageNumber}", pageNumberText, StringComparison.InvariantCultureIgnoreCase);
                }

                insertParent.ParentNode !.InsertAfter(copiedChild, insertParent);
                insertParent = copiedChild;
            }
        }
    public static void Parse(XmlDocument document)
    {
        foreach (var element in document.GetElementsByTagName("Main").OfType <XmlElement>().First() !.ChildNodes.OfType <XmlElement>())
        {
            switch (element.Name)
            {
            case "CheckBox":
                var checkbox = new SimpleCustomCheckBoxVisualElement(element.GetAttribute("Variable"), element["Icon"] !.InnerText, element["Localisation"] !.InnerText, element["PositiveTrigger"] !.InnerText, element["NegativeTrigger"] !.InnerText)
                {
                    Owner = MainSavable.Instance
                };
                MainSavable.Instance.Elements.Add(checkbox);

                break;

            case nameof(Trait):
                var trait = new Trait(element);
                MainSavable.Instance.Elements.Add(trait);
                trait.Owner = MainSavable.Instance;
                break;

            case nameof(CheckboxLogicalGroup):
                var group = new CheckboxLogicalGroup(element);
                MainSavable.Instance.Elements.Add(group);
                if (!element.GetAttribute("IsOwnerMain").ToBool())
                {
                    ISavable.All.Add(group);
                }
                break;

            case nameof(DropDown):
                var dropdown = new DropDown(element)
                {
                    Owner = MainSavable.Instance
                };
                MainSavable.Instance.Elements.Add(dropdown);
                break;;

            case nameof(ReligionFilter):
                var family = new ReligionFilter(element);
                ISavable.All.Add(family);
                break;;
            }
        }
    }
Esempio n. 10
0
 public IEnumerable <MSBuildItem> GetAllItems()
 {
     return(GetAllItems(ChildNodes.OfType <MSBuildObject> ()));
 }
Esempio n. 11
0
 public IEnumerable <MSBuildObject> GetAllObjects()
 {
     return(ChildNodes.OfType <MSBuildObject> ());
 }
Esempio n. 12
0
 internal HtmlTableSectionElement(HtmlDocument ownerDocument, string tagName) : base(ownerDocument, tagName)
 {
     Rows = new HtmlCollection(() => ChildNodes.OfType <HtmlTableRowElement>());
 }
Esempio n. 13
0
 internal IEnumerable <MSBuildChooseOption> GetOptions()
 {
     return(ChildNodes.OfType <MSBuildChooseOption> ());
 }
Esempio n. 14
0
 internal HtmlTableElement(Document ownerDocument) : base(ownerDocument, TagsNames.Table)
 {
     Rows    = new HtmlCollection(GetRows);
     TBodies = new HtmlCollection(() => ChildNodes.OfType <HtmlTableSectionElement>().Where(x => x.TagName == TagsNames.TBody));
 }
Esempio n. 15
0
        private Element BuildElement(IData data,
                                     DynamicValuesHelperReplaceContext replaceContext,
                                     TreeNodeDynamicContext dynamicContext,
                                     bool localizationEnabled,
                                     List <object> itemKeys,
                                     ref IEnumerable <object> keysJoinedByParentFilters,
                                     EntityToken parentEntityToken
                                     )
        {
            replaceContext.CurrentDataItem = data;

            object keyValue = this.KeyPropertyInfo.GetValue(data, null);

            bool itemLocalizationEnabledAndForeign = localizationEnabled && !data.DataSourceId.LocaleScope.Equals(UserSettings.ActiveLocaleCultureInfo);

            if (itemLocalizationEnabledAndForeign && itemKeys.Contains(keyValue))
            {
                return(null);
            }

            var currentEntityToken = data.GetDataEntityToken();

            var element = new Element(new ElementHandle
                                      (
                                          dynamicContext.ElementProviderName,
                                          currentEntityToken,
                                          dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken)
                                      ));


            bool           hasChildren;
            bool           isDisabled = false;
            ResourceHandle icon, openedIcon;

            if (itemLocalizationEnabledAndForeign)
            {
                hasChildren = false;
                isDisabled  = !data.IsTranslatable();

                if (this.Icon != null)
                {
                    icon       = this.Icon;
                    openedIcon = this.OpenedIcon;
                }
                else
                {
                    icon       = data.GetForeignIcon();
                    openedIcon = icon;
                }
            }
            else
            {
                if (this.Display != LeafDisplayMode.Auto)
                {
                    hasChildren = ChildNodes.Any();
                }
                else
                {
                    hasChildren = ChildNodes.OfType <SimpleElementTreeNode>().Any();

                    if (!hasChildren)
                    {
                        if (keysJoinedByParentFilters != null)
                        {
                            keysJoinedByParentFilters = keysJoinedByParentFilters.Evaluate();

                            hasChildren = keysJoinedByParentFilters.Contains(keyValue);
                        }
                    }

                    // Checking children filtered by FunctionFilters
                    if (!hasChildren)
                    {
                        foreach (var childNode in this.ChildNodes.OfType <DataElementsTreeNode>()
                                 .Where(n => n.FilterNodes.OfType <FunctionFilterNode>().Any()))
                        {
                            var newDynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down)
                            {
                                ElementProviderName = dynamicContext.ElementProviderName,
                                Piggybag            = dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken),
                                CurrentEntityToken  = currentEntityToken
                            };

                            if (childNode.GetDataset(newDynamicContext, false).DataItems.Any())
                            {
                                hasChildren = true;
                                break;
                            }
                        }
                    }
                }

                if (this.Icon != null)
                {
                    icon       = this.Icon;
                    openedIcon = this.OpenedIcon;
                }
                else
                {
                    openedIcon = icon = data.GetIcon();
                }
            }

            string label = this.Label.IsNullOrEmpty()
                            ? data.GetLabel()
                            : this.LabelDynamicValuesHelper.ReplaceValues(replaceContext);

            string toolTip = this.ToolTip.IsNullOrEmpty()
                            ? label
                            : this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext);

            if (itemLocalizationEnabledAndForeign)
            {
                label = string.Format("{0} ({1})", label, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo));

                if (!data.IsTranslatable())
                {
                    toolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.DisabledData");
                }
                else
                {
                    toolTip = string.Format("{0} ({1})", toolTip, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo));
                }
            }

            element.VisualData = new ElementVisualizedData
            {
                Label       = label,
                ToolTip     = toolTip,
                HasChildren = hasChildren,
                Icon        = icon,
                OpenedIcon  = openedIcon,
                IsDisabled  = isDisabled
            };


            if (InternalUrls.DataTypeSupported(data.DataSourceId.InterfaceType))
            {
                var dataReference = data.ToDataReference();

                if (DataUrls.CanBuildUrlForData(dataReference))
                {
                    string internalUrl = InternalUrls.TryBuildInternalUrl(dataReference);

                    if (internalUrl != null)
                    {
                        element.PropertyBag.Add("Uri", internalUrl);
                    }
                }
            }


            if (itemLocalizationEnabledAndForeign)
            {
                var actionToken = new WorkflowActionToken(
                    WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.LocalizeDataWorkflow"),
                    LocalizeDataPermissionTypes);

                element.AddAction(new ElementAction(new ActionHandle(actionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataLabel"),
                        ToolTip        = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataToolTip"),
                        Icon           = LocalizeDataTypeIcon,
                        Disabled       = false,
                        ActionLocation = ActionLocation.OtherPrimaryActionLocation
                    }
                });
            }

            return(element);
        }
Esempio n. 16
0
        ///--------------------------------------------------------------------------------
        /// <summary>Interpret this node to produce code, output, or model data..</summary>
        ///
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="parameters">Template parameters.</param>
        ///--------------------------------------------------------------------------------
        public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, NameObjectCollection parameters)
        {
            try
            {
                if (templateContext.IsWatchTemplate == false)
                {
                    solutionContext.TemplatesExecuted++;
                    solutionContext.TemplatesUsed[templateContext.TemplateName] = true;
                }
                templateContext.IsBreaking  = false;
                templateContext.IsReturning = false;
                if (templateContext.IsWatchTemplate == false)
                {
                    // clear context stack if not temporary watch template
                    templateContext.ModelContextStack = null;
                }
                templateContext.PushModelContext(modelContext);
                templateContext.PopCount = 0;
                foreach (IStatementNode childNode in ChildNodes.OfType <IStatementNode>())
                {
                    if (childNode.HandleDebug(interpreterType, solutionContext, templateContext, modelContext) == false)
                    {
                        return;
                    }
                    if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                    {
                        templateContext.IsBreaking = false;
                        break;
                    }
                    if (childNode is BreakStatementNode || childNode is ReturnStatementNode)
                    {
                        break;
                    }
                    childNode.InterpretNode(interpreterType, solutionContext, templateContext, modelContext);

                    if (childNode is ParamStatementNode && parameters != null)
                    {
                        string variableName = (childNode as ParamStatementNode).VariableName;
                        if (parameters.HasKey(variableName) == true)
                        {
                            // apply parameter value
                            templateContext.Parameters[variableName] = parameters[variableName];
                            parameters.Remove(variableName);
                        }
                    }
                }
                templateContext.IsBreaking         = false;
                templateContext.IsReturning        = false;
                templateContext.ModelContextStack  = null;
                templateContext.PopCount           = 0;
                templateContext.IsTemplateUtilized = true;
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
            }
        }
Esempio n. 17
0
 public IEnumerable <MSBuildProperty> GetProperties()
 {
     return(ChildNodes.OfType <MSBuildProperty> ());
 }
Esempio n. 18
0
 public IEnumerator <ScriptAst> GetEnumerator()
 {
     return(ChildNodes.OfType <ScriptAst>().GetEnumerator());
 }
    public static void Parse()
    {
        var layoutsDocument = new XmlDocument();

        layoutsDocument.Load("layout.xml");

        foreach (var element in layoutsDocument.GetElementsByTagName("Main").OfType <XmlElement>().First() !.ChildNodes.OfType <XmlElement>())
        {
            switch (element.Name)
            {
            case nameof(VisualOrganizationGroup):

                var group = new VisualOrganizationGroup(element);
                foreach (var layout in element.ChildNodes.OfType <XmlElement>())
                {
                    group.Layouts.Add(layout.Name switch
                    {
                        nameof(NormalLayout) => new NormalLayout(layout),
                        nameof(StarLayout) => new StarLayout(layout),
                        nameof(ThreePackLayout) => new ThreePackLayout(layout),
                        nameof(SixPackLayout) => new SixPackLayout(layout),
                        "SkillLayout" => Skill.ParseTwoSkillsLayout(layout),
                        nameof(CustomLayout) => new CustomLayout(layout),
                        nameof(DropDown) => DropDown.All.Single(d => d.Name == layout.GetAttribute(nameof(d.Name))),
                        nameof(Divider) => new Divider(),
                        _ => throw new Exception("Invalid layout.txt file")
                    });
                }

                break;
            }
Esempio n. 20
0
 /// <summary>Find child code elements with a predicate.</summary>
 /// <param name="predicate">The predicate to filter with.</param>
 /// <returns>A enumerable of codes.</returns>
 public virtual IEnumerable <CodeElement> Codes(Func <CodeElement, bool> predicate)
 {
     return(ChildNodes.OfType <CodeElement>().Where(predicate));
 }
Esempio n. 21
0
 /// <summary>Find child code elements with a given name.</summary>
 /// <param name="name">The name to search for.</param>
 /// <returns>A enumerable of codes.</returns>
 public virtual IEnumerable <CodeElement> Codes(string name)
 {
     return(ChildNodes.OfType <CodeElement>().Where(n => n.Name == name));
 }
Esempio n. 22
0
 /// <summary>Get all child code elements.</summary>
 /// <returns>A enumerable of codes.</returns>
 public virtual IEnumerable <CodeElement> Codes()
 {
     return(ChildNodes.OfType <CodeElement>());
 }
Esempio n. 23
0
 internal HtmlTableRowElement(Document ownerDocument) : base(ownerDocument, TagsNames.Tr)
 {
     Cells = new HtmlCollection(() => ChildNodes.OfType <HtmlTableCellElement>());
 }
Esempio n. 24
0
 /// <summary>
 /// Gets the siblings of the provided elements. Optionally uses a CSS
 /// selector to filter the results.
 /// </summary>
 /// <param name="elements">The elements with siblings.</param>
 /// <param name="selector">The CSS selector to use, if any.</param>
 /// <returns>A filtered list containing the siblings.</returns>
 public static IEnumerable <IElement> Siblings(this IEnumerable <IElement> elements, ISelector?selector = null)
 {
     return(elements.GetMany(m => m.Parent !.ChildNodes.OfType <IElement>().Except(m), selector));
 }