private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so) { ConsolidatedString internalTypeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames); foreach (WideControlEntryDefinition definition in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo))) { return(definition); } } if (match.BestMatch != null) { return(match.BestMatch as WideControlEntryDefinition); } Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames); if (typeNames != null) { match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames); foreach (WideControlEntryDefinition definition2 in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo))) { return(definition2); } } if (match.BestMatch != null) { return(match.BestMatch as WideControlEntryDefinition); } } return(wideBody.defaultEntryDefinition); }
private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so) { ConsolidatedString internalTypeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames); foreach (WideControlEntryDefinition definition in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo))) { return definition; } } if (match.BestMatch != null) { return (match.BestMatch as WideControlEntryDefinition); } Collection<string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames); if (typeNames != null) { match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames); foreach (WideControlEntryDefinition definition2 in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo))) { return definition2; } } if (match.BestMatch != null) { return (match.BestMatch as WideControlEntryDefinition); } } return wideBody.defaultEntryDefinition; }
private WideViewEntry GenerateWideViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { WideControlBody mainControl = (WideControlBody)base.dataBaseInfo.view.mainControl; WideControlEntryDefinition activeWideControlEntryDefinition = this.GetActiveWideControlEntryDefinition(mainControl, so); return(new WideViewEntry { formatPropertyField = base.GenerateFormatPropertyField(activeWideControlEntryDefinition.formatTokenList, so, enumerationLimit) }); }
internal WideControl(WideControlBody widecontrolbody) { this._entries = new List<WideControlEntryItem>(); this._columns = (int) widecontrolbody.columns; this._aligment = (System.Management.Automation.Alignment) widecontrolbody.alignment; this._entries.Add(new WideControlEntryItem(widecontrolbody.defaultEntryDefinition)); foreach (WideControlEntryDefinition definition in widecontrolbody.optionalEntryList) { this._entries.Add(new WideControlEntryItem(definition)); } }
private void LoadWideControlEntries(XmlNode wideControlEntriesNode, WideControlBody wideBody) { using (this.StackFrame(wideControlEntriesNode)) { int entryIndex = 0; foreach (XmlNode n in wideControlEntriesNode.ChildNodes) { if (MatchNodeName(n, XmlTags.WideEntryNode)) { WideControlEntryDefinition wved = LoadWideControlEntry(n, entryIndex++); if (wved == null) { // Error at XPath {0} in file {1}: Invalid {2}. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, ComputeCurrentXPath(), FilePath, XmlTags.WideEntryNode)); return; } // determine if we have a default entry and if it's already set if (wved.appliesTo == null) { if (wideBody.defaultEntryDefinition == null) { wideBody.defaultEntryDefinition = wved; } 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.WideEntryNode)); wideBody.defaultEntryDefinition = null; return; // fatal error } } else { wideBody.optionalEntryList.Add(wved); } } else { this.ProcessUnknownNode(n); } } if (wideBody.defaultEntryDefinition == 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.WideEntryNode)); } } }
private WideViewEntry GenerateWideViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { WideControlBody wideBody = (WideControlBody)this.dataBaseInfo.view.mainControl; WideControlEntryDefinition activeWideControlEntryDefinition = GetActiveWideControlEntryDefinition(wideBody, so); WideViewEntry wve = new WideViewEntry(); wve.formatPropertyField = GenerateFormatPropertyField(activeWideControlEntryDefinition.formatTokenList, so, enumerationLimit); //wve.alignment = activeWideViewEntryDefinition.alignment; return(wve); }
private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so) { // see if we have an override that matches var typeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames); foreach (WideControlEntryDefinition x in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return(x); } } if (match.BestMatch != null) { return(match.BestMatch as WideControlEntryDefinition); } else { Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (typesWithoutPrefix != null) { match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix); foreach (WideControlEntryDefinition x in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return(x); } } if (match.BestMatch != null) { return(match.BestMatch as WideControlEntryDefinition); } } // we do not have any override, use default return(wideBody.defaultEntryDefinition); } }
private void LoadWideControlEntries(System.Xml.XmlNode wideControlEntriesNode, WideControlBody wideBody) { using (base.StackFrame(wideControlEntriesNode)) { int num = 0; foreach (System.Xml.XmlNode node in wideControlEntriesNode.ChildNodes) { if (base.MatchNodeName(node, "WideEntry")) { WideControlEntryDefinition item = this.LoadWideControlEntry(node, num++); if (item == null) { base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, new object[] { base.ComputeCurrentXPath(), base.FilePath, "WideEntry" })); return; } if (item.appliesTo == null) { if (wideBody.defaultEntryDefinition == null) { wideBody.defaultEntryDefinition = item; continue; } base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, new object[] { base.ComputeCurrentXPath(), base.FilePath, "WideEntry" })); wideBody.defaultEntryDefinition = null; return; } wideBody.optionalEntryList.Add(item); } else { base.ProcessUnknownNode(node); } } if (wideBody.defaultEntryDefinition == null) { base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, new object[] { base.ComputeCurrentXPath(), base.FilePath, "WideEntry" })); } } }
private WideControlBody LoadWideControl(System.Xml.XmlNode controlNode) { using (base.StackFrame(controlNode)) { WideControlBody wideBody = new WideControlBody(); bool flag = false; bool flag2 = false; bool flag3 = false; foreach (System.Xml.XmlNode node in controlNode.ChildNodes) { if (base.MatchNodeName(node, "AutoSize")) { bool flag4; if (flag2) { base.ProcessDuplicateAlternateNode(node, "AutoSize", "ColumnNumber"); return null; } flag2 = true; if (!this.ReadBooleanNode(node, out flag4)) { return null; } wideBody.autosize = new bool?(flag4); } else if (base.MatchNodeName(node, "ColumnNumber")) { if (flag3) { base.ProcessDuplicateAlternateNode(node, "AutoSize", "ColumnNumber"); return null; } flag3 = true; if (!this.ReadPositiveIntegerValue(node, out wideBody.columns)) { return null; } } else if (base.MatchNodeName(node, "WideEntries")) { if (!flag) { flag = true; this.LoadWideControlEntries(node, wideBody); if (wideBody.defaultEntryDefinition == null) { return null; } } else { base.ProcessDuplicateNode(node); } } else { base.ProcessUnknownNode(node); } } if (flag2 && flag3) { base.ProcessDuplicateAlternateNode("AutoSize", "ColumnNumber"); return null; } if (!flag) { base.ReportMissingNode("WideEntries"); return null; } return wideBody; } }
private WideControlBody LoadWideControl(XmlNode controlNode) { using (this.StackFrame(controlNode)) { WideControlBody wideBody = new WideControlBody(); bool wideViewEntriesFound = false; // mutually exclusive bool autosizeNodeFound = false; // cardinality 0..1 bool columnsNodeFound = false; // cardinality 0..1 foreach (XmlNode n in controlNode.ChildNodes) { if (MatchNodeName(n, XmlTags.AutoSizeNode)) { if (autosizeNodeFound) { this.ProcessDuplicateAlternateNode(n, XmlTags.AutoSizeNode, XmlTags.ColumnNumberNode); return(null); // fatal error } autosizeNodeFound = true; bool tempVal; if (!this.ReadBooleanNode(n, out tempVal)) { return(null); // fatal error } wideBody.autosize = tempVal; } else if (MatchNodeName(n, XmlTags.ColumnNumberNode)) { if (columnsNodeFound) { this.ProcessDuplicateAlternateNode(n, XmlTags.AutoSizeNode, XmlTags.ColumnNumberNode); return(null); // fatal error } columnsNodeFound = true; if (!ReadPositiveIntegerValue(n, out wideBody.columns)) { return(null); // fatal error } } else if (MatchNodeName(n, XmlTags.WideEntriesNode)) { if (wideViewEntriesFound) { this.ProcessDuplicateNode(n); continue; } wideViewEntriesFound = true; // now read the entries section LoadWideControlEntries(n, wideBody); if (wideBody.defaultEntryDefinition == null) { // if we have an default entry, it means there was a failure return(null); // fatal error } } else { this.ProcessUnknownNode(n); } } if (autosizeNodeFound && columnsNodeFound) { this.ProcessDuplicateAlternateNode(XmlTags.AutoSizeNode, XmlTags.ColumnNumberNode); return(null); // fatal error } if (!wideViewEntriesFound) { this.ReportMissingNode(XmlTags.WideEntriesNode); return(null); // fatal error } return(wideBody); } }
private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so) { // see if we have an override that matches var typeNames = so.InternalTypeNames; TypeMatch match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames); foreach (WideControlEntryDefinition x in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return x; } } if (match.BestMatch != null) { return match.BestMatch as WideControlEntryDefinition; } else { Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (null != typesWithoutPrefix) { match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix); foreach (WideControlEntryDefinition x in wideBody.optionalEntryList) { if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo))) { return x; } } if (match.BestMatch != null) { return match.BestMatch as WideControlEntryDefinition; } } // we do not have any override, use default return wideBody.defaultEntryDefinition; } }
/// <summary> /// Load the WideControl into the WideControlBody /// </summary> /// <param name="wide"></param> /// <param name="viewIndex"></param> /// <param name="typeName"></param> /// <returns></returns> private WideControlBody LoadWideControlFromObjectModel(WideControl wide, int viewIndex, string typeName) { WideControlBody wideBody = new WideControlBody(); // Contains: // Columns --- ColumnNumbers cardinality 0..1 // Entries --- WideEntries cardinality 1 wideBody.columns = (int)wide.Columns; if (wide.AutoSize) wideBody.autosize = true; LoadWideControlEntriesFromObjectModel(wideBody, wide.Entries, viewIndex, typeName); if (wideBody.defaultEntryDefinition == null) { // if we have no default entry definition, it means there was a failure return null; } return wideBody; }
private void LoadWideControlEntries(XmlNode wideControlEntriesNode, WideControlBody wideBody) { using (this.StackFrame(wideControlEntriesNode)) { int entryIndex = 0; foreach (XmlNode n in wideControlEntriesNode.ChildNodes) { if (MatchNodeName(n, XmlTags.WideEntryNode)) { WideControlEntryDefinition wved = LoadWideControlEntry(n, entryIndex++); if (wved == null) { //Error at XPath {0} in file {1}: Invalid {2}. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, ComputeCurrentXPath(), FilePath, XmlTags.WideEntryNode)); return; } // determine if we have a default entry and if it's already set if (wved.appliesTo == null) { if (wideBody.defaultEntryDefinition == null) { wideBody.defaultEntryDefinition = wved; } 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.WideEntryNode)); wideBody.defaultEntryDefinition = null; return; // fatal error } } else { wideBody.optionalEntryList.Add(wved); } } else { this.ProcessUnknownNode(n); } } if (wideBody.defaultEntryDefinition == 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.WideEntryNode)); } } }
private WideControlBody LoadWideControl(XmlNode controlNode) { using (this.StackFrame(controlNode)) { WideControlBody wideBody = new WideControlBody(); bool wideViewEntriesFound = false; // mutually exclusive bool autosizeNodeFound = false; // cardinality 0..1 bool columnsNodeFound = false; // cardinality 0..1 foreach (XmlNode n in controlNode.ChildNodes) { if (MatchNodeName(n, XmlTags.AutoSizeNode)) { if (autosizeNodeFound) { this.ProcessDuplicateAlternateNode(n, XmlTags.AutoSizeNode, XmlTags.ColumnNumberNode); return null; // fatal error } autosizeNodeFound = true; bool tempVal; if (!this.ReadBooleanNode(n, out tempVal)) { return null; // fatal error } wideBody.autosize = tempVal; } else if (MatchNodeName(n, XmlTags.ColumnNumberNode)) { if (columnsNodeFound) { this.ProcessDuplicateAlternateNode(n, XmlTags.AutoSizeNode, XmlTags.ColumnNumberNode); return null; // fatal error } columnsNodeFound = true; if (!ReadPositiveIntegerValue(n, out wideBody.columns)) { return null; // fatal error } } else if (MatchNodeName(n, XmlTags.WideEntriesNode)) { if (wideViewEntriesFound) { this.ProcessDuplicateNode(n); continue; } wideViewEntriesFound = true; // now read the entries section LoadWideControlEntries(n, wideBody); if (wideBody.defaultEntryDefinition == null) { // if we have an default entry, it means there was a failure return null; // fatal error } } else { this.ProcessUnknownNode(n); } } if (autosizeNodeFound && columnsNodeFound) { this.ProcessDuplicateAlternateNode(XmlTags.AutoSizeNode, XmlTags.ColumnNumberNode); return null; // fatal error } if (!wideViewEntriesFound) { this.ReportMissingNode(XmlTags.WideEntriesNode); return null; // fatal error } return wideBody; } }
internal WideControl(WideControlBody widecontrolbody, ViewDefinition viewDefinition) : this() { OutOfBand = viewDefinition.outOfBand; GroupBy = PSControlGroupBy.Get(viewDefinition.groupBy); AutoSize = widecontrolbody.autosize.HasValue && widecontrolbody.autosize.Value; Columns = (uint)widecontrolbody.columns; Entries.Add(new WideControlEntryItem(widecontrolbody.defaultEntryDefinition)); foreach (WideControlEntryDefinition definition in widecontrolbody.optionalEntryList) { Entries.Add(new WideControlEntryItem(definition)); } }
private void LoadWideControlEntriesFromObjectModel(WideControlBody wideBody, List<WideControlEntryItem> wideEntries, int viewIndex, string typeName) { foreach (WideControlEntryItem item in wideEntries) { WideControlEntryDefinition definition = this.LoadWideControlEntryFromObjectModel(item, viewIndex, typeName); if (definition == null) { base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidFormattingData, new object[] { typeName, viewIndex, "WideEntry" }), typeName); wideBody.defaultEntryDefinition = null; return; } if (definition.appliesTo == null) { if (wideBody.defaultEntryDefinition == null) { wideBody.defaultEntryDefinition = definition; continue; } base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntryInFormattingData, new object[] { typeName, viewIndex, "WideEntry" }), typeName); wideBody.defaultEntryDefinition = null; return; } wideBody.optionalEntryList.Add(definition); } if (wideBody.defaultEntryDefinition == null) { base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntryInFormattingData, new object[] { typeName, viewIndex, "WideEntry" }), typeName); } }
private WideControlBody LoadWideControlFromObjectModel(WideControl wide, int viewIndex, string typeName) { WideControlBody wideBody = new WideControlBody { columns = (int) wide.Columns }; this.LoadWideControlEntriesFromObjectModel(wideBody, wide.Entries, viewIndex, typeName); if (wideBody.defaultEntryDefinition == null) { return null; } return wideBody; }
/// <summary> /// Load WideEntries /// </summary> /// <param name="wideBody"></param> /// <param name="wideEntries"></param> /// <param name="viewIndex"></param> /// <param name="typeName"></param> private void LoadWideControlEntriesFromObjectModel(WideControlBody wideBody, List<WideControlEntryItem> wideEntries, int viewIndex, string typeName) { foreach (WideControlEntryItem wideItem in wideEntries) { WideControlEntryDefinition wved = LoadWideControlEntryFromObjectModel(wideItem, viewIndex, typeName); if (wved == null) { this.ReportErrorForLoadingFromObjectModel( StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidFormattingData, typeName, viewIndex, XmlTags.WideEntryNode), typeName); wideBody.defaultEntryDefinition = null; return; } // determine if we have a default entry and if it's already set if (wved.appliesTo == null) { if (wideBody.defaultEntryDefinition == null) { wideBody.defaultEntryDefinition = wved; } else { //Error at XPath {0} in file {1}: There cannot be more than one default {2}. this.ReportErrorForLoadingFromObjectModel( StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntryInFormattingData, typeName, viewIndex, XmlTags.WideEntryNode), typeName); wideBody.defaultEntryDefinition = null; return; // fatal error } } else { wideBody.optionalEntryList.Add(wved); } } if (wideBody.defaultEntryDefinition == null) { this.ReportErrorForLoadingFromObjectModel( StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntryInFormattingData, typeName, viewIndex, XmlTags.WideEntryNode), typeName); } }