private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(ComplexControlBody complexBody, PSObject so) { ConsolidatedString internalTypeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(this.expressionFactory, this.db, internalTypeNames); foreach (ComplexControlEntryDefinition definition in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo))) { return(definition); } } if (match.BestMatch != null) { return(match.BestMatch as ComplexControlEntryDefinition); } Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames); if (typeNames != null) { match = new TypeMatch(this.expressionFactory, this.db, typeNames); foreach (ComplexControlEntryDefinition definition2 in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo))) { return(definition2); } } if (match.BestMatch != null) { return(match.BestMatch as ComplexControlEntryDefinition); } } return(complexBody.defaultEntry); }
private bool ExecuteFormatControl(TraversalInfo level, ControlBase control, PSObject so, List <FormatValue> formatValueList) { // we are looking for a complex control to execute ComplexControlBody complexBody = null; // we might have a reference ControlReference controlReference = control as ControlReference; if (controlReference != null && controlReference.controlType == typeof(ComplexControlBody)) { // retrieve the reference complexBody = DisplayDataQuery.ResolveControlReference( _db, _controlDefinitionList, controlReference) as ComplexControlBody; } else { // try as an in line control complexBody = control as ComplexControlBody; } // finally, execute the control body if (complexBody != null) { // we have an inline control, just execute it ExecuteFormatControlBody(level, so, complexBody, formatValueList); return(true); } return(false); }
private void ExecuteFormatControlBody(TraversalInfo level, PSObject so, ComplexControlBody complexBody, List <FormatValue> formatValueList) { ComplexControlEntryDefinition activeControlEntryDefinition = GetActiveComplexControlEntryDefinition(complexBody, so); ExecuteFormatTokenList(level, so, activeControlEntryDefinition.itemDefinition.formatTokenList, formatValueList); }
private void LoadComplexControlEntries(XmlNode complexControlEntriesNode, ComplexControlBody complexBody) { using (this.StackFrame(complexControlEntriesNode)) { int entryIndex = 0; foreach (XmlNode n in complexControlEntriesNode.ChildNodes) { if (MatchNodeName(n, XmlTags.ComplexEntryNode)) { ComplexControlEntryDefinition cced = LoadComplexControlEntryDefinition(n, entryIndex++); if (cced == null) { // Error at XPath {0} in file {1}: {2} failed to load. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailed, ComputeCurrentXPath(), FilePath, XmlTags.ComplexEntryNode)); complexBody.defaultEntry = null; return; // fatal error } // determine if we have a default entry and if it's already set if (cced.appliesTo == null) { if (complexBody.defaultEntry == null) { complexBody.defaultEntry = cced; } else { // Error at XPath {0} in file {1}: There cannot be more than one default {2}. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.ComplexEntryNode)); complexBody.defaultEntry = null; return; // fatal error } } else { complexBody.optionalEntryList.Add(cced); } } else { this.ProcessUnknownNode(n); } } if (complexBody.defaultEntry == null) { // Error at XPath {0} in file {1}: There must be at least one default {2}. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.ComplexEntryNode)); } } }
private void LoadComplexControlEntries(XmlNode complexControlEntriesNode, ComplexControlBody complexBody) { using (this.StackFrame(complexControlEntriesNode)) { int entryIndex = 0; foreach (XmlNode n in complexControlEntriesNode.ChildNodes) { if (MatchNodeName(n, XmlTags.ComplexEntryNode)) { ComplexControlEntryDefinition cced = LoadComplexControlEntryDefinition(n, entryIndex++); if (cced == null) { //Error at XPath {0} in file {1}: {2} failed to load. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailed, ComputeCurrentXPath(), FilePath, XmlTags.ComplexEntryNode)); complexBody.defaultEntry = null; return; // fatal error } // determine if we have a default entry and if it's already set if (cced.appliesTo == null) { if (complexBody.defaultEntry == null) { complexBody.defaultEntry = cced; } else { //Error at XPath {0} in file {1}: There cannot be more than one default {2}. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.ComplexEntryNode)); complexBody.defaultEntry = null; return; // fatal error } } else { complexBody.optionalEntryList.Add(cced); } } else { this.ProcessUnknownNode(n); } } if (complexBody.defaultEntry == null) { //Error at XPath {0} in file {1}: There must be at least one default {2}. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.ComplexEntryNode)); } } }
private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(ComplexControlBody complexBody, PSObject so) { // see if we have an override that matches var typeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(_expressionFactory, _db, typeNames); foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo, so))) { return(x); } } if (match.BestMatch != null) { return(match.BestMatch as ComplexControlEntryDefinition); } else { Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (typesWithoutPrefix != null) { match = new TypeMatch(_expressionFactory, _db, typesWithoutPrefix); foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return(x); } } if (match.BestMatch != null) { return(match.BestMatch as ComplexControlEntryDefinition); } } // we do not have any override, use default return(complexBody.defaultEntry); } }
private ComplexControlBody LoadComplexControl(XmlNode controlNode) { using (this.StackFrame(controlNode)) { ComplexControlBody complexBody = new ComplexControlBody(); bool entriesFound = false; foreach (XmlNode n in controlNode.ChildNodes) { if (MatchNodeName(n, XmlTags.ComplexEntriesNode)) { if (entriesFound) { this.ProcessDuplicateNode(n); continue; } entriesFound = true; // now read the columns section LoadComplexControlEntries(n, complexBody); if (complexBody.defaultEntry == null) { return(null); // fatal error } } else { this.ProcessUnknownNode(n); } } if (!entriesFound) { this.ReportMissingNode(XmlTags.ComplexEntriesNode); return(null); // fatal error } return(complexBody); } }
private bool ExecuteFormatControl(TraversalInfo level, ControlBase control, PSObject so, List <FormatValue> formatValueList) { ComplexControlBody complexBody = null; ControlReference controlReference = control as ControlReference; if ((controlReference != null) && (controlReference.controlType == typeof(ComplexControlBody))) { complexBody = DisplayDataQuery.ResolveControlReference(this.db, this.controlDefinitionList, controlReference) as ComplexControlBody; } else { complexBody = control as ComplexControlBody; } if (complexBody != null) { this.ExecuteFormatControlBody(level, so, complexBody, formatValueList); return(true); } return(false); }
private ComplexControlBody LoadComplexControl(XmlNode controlNode) { using (this.StackFrame(controlNode)) { ComplexControlBody complexBody = new ComplexControlBody(); bool entriesFound = false; foreach (XmlNode n in controlNode.ChildNodes) { if (MatchNodeName(n, XmlTags.ComplexEntriesNode)) { if (entriesFound) { this.ProcessDuplicateNode(n); continue; } entriesFound = true; // now read the columns section LoadComplexControlEntries(n, complexBody); if (complexBody.defaultEntry == null) { return null; // fatal error } } else { this.ProcessUnknownNode(n); } } if (!entriesFound) { this.ReportMissingNode(XmlTags.ComplexEntriesNode); return null; // fatal error } return complexBody; } }
internal CustomControl(ComplexControlBody body, ViewDefinition viewDefinition) { // viewDefinition can be null for nested controls if (viewDefinition != null) { OutOfBand = viewDefinition.outOfBand; GroupBy = PSControlGroupBy.Get(viewDefinition.groupBy); } Entries = new List<CustomControlEntry>(); // Default entry var cce = new CustomControlEntry(body.defaultEntry); Entries.Add(cce); foreach (var entry in body.optionalEntryList) { cce = new CustomControlEntry(entry); Entries.Add(cce); } }
private void ExecuteFormatControlBody(TraversalInfo level, PSObject so, ComplexControlBody complexBody, List<FormatValue> formatValueList) { ComplexControlEntryDefinition activeComplexControlEntryDefinition = this.GetActiveComplexControlEntryDefinition(complexBody, so); this.ExecuteFormatTokenList(level, so, activeComplexControlEntryDefinition.itemDefinition.formatTokenList, formatValueList); }
private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(ComplexControlBody complexBody, PSObject so) { ConsolidatedString internalTypeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(this.expressionFactory, this.db, internalTypeNames); foreach (ComplexControlEntryDefinition definition in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo))) { return definition; } } if (match.BestMatch != null) { return (match.BestMatch as ComplexControlEntryDefinition); } Collection<string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames); if (typeNames != null) { match = new TypeMatch(this.expressionFactory, this.db, typeNames); foreach (ComplexControlEntryDefinition definition2 in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo))) { return definition2; } } if (match.BestMatch != null) { return (match.BestMatch as ComplexControlEntryDefinition); } } return complexBody.defaultEntry; }
private void LoadComplexControlEntries(System.Xml.XmlNode complexControlEntriesNode, ComplexControlBody complexBody) { using (base.StackFrame(complexControlEntriesNode)) { int num = 0; foreach (System.Xml.XmlNode node in complexControlEntriesNode.ChildNodes) { if (base.MatchNodeName(node, "CustomEntry")) { ComplexControlEntryDefinition item = this.LoadComplexControlEntryDefinition(node, num++); if (item == null) { base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailed, new object[] { base.ComputeCurrentXPath(), base.FilePath, "CustomEntry" })); complexBody.defaultEntry = null; return; } if (item.appliesTo == null) { if (complexBody.defaultEntry == null) { complexBody.defaultEntry = item; continue; } base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, new object[] { base.ComputeCurrentXPath(), base.FilePath, "CustomEntry" })); complexBody.defaultEntry = null; return; } complexBody.optionalEntryList.Add(item); } else { base.ProcessUnknownNode(node); } } if (complexBody.defaultEntry == null) { base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, new object[] { base.ComputeCurrentXPath(), base.FilePath, "CustomEntry" })); } } }
private ComplexControlBody LoadComplexControl(System.Xml.XmlNode controlNode) { using (base.StackFrame(controlNode)) { ComplexControlBody complexBody = new ComplexControlBody(); bool flag = false; foreach (System.Xml.XmlNode node in controlNode.ChildNodes) { if (base.MatchNodeName(node, "CustomEntries")) { if (!flag) { flag = true; this.LoadComplexControlEntries(node, complexBody); if (complexBody.defaultEntry == null) { return null; } } else { base.ProcessDuplicateNode(node); } } else { base.ProcessUnknownNode(node); } } if (!flag) { base.ReportMissingNode("CustomEntries"); return null; } return complexBody; } }
private ComplexControlBody LoadCustomControlFromObjectModel(CustomControl custom, int viewIndex, string typeName) { if (custom._cachedBody != null) return custom._cachedBody; var ccb = new ComplexControlBody(); foreach (var entry in custom.Entries) { var cced = LoadComplexControlEntryDefinitionFromObjectModel(entry, viewIndex, typeName); if (cced.appliesTo == null) { ccb.defaultEntry = cced; } else { ccb.optionalEntryList.Add(cced); } } Interlocked.CompareExchange(ref custom._cachedBody, ccb, null); return ccb; }
private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(ComplexControlBody complexBody, PSObject so) { // see if we have an override that matches var typeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(_expressionFactory, _db, typeNames); foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return x; } } if (match.BestMatch != null) { return match.BestMatch as ComplexControlEntryDefinition; } else { Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (null != typesWithoutPrefix) { match = new TypeMatch(_expressionFactory, _db, typesWithoutPrefix); foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return x; } } if (match.BestMatch != null) { return match.BestMatch as ComplexControlEntryDefinition; } } // we do not have any override, use default return complexBody.defaultEntry; } }