Example #1
0
 /// <summary>
 /// Public constructor for WideControlEntryItem.
 /// </summary>
 public WideControlEntryItem(DisplayEntry entry) : this()
 {
     if (entry == null)
     {
         throw PSTraceSource.NewArgumentNullException("entry");
     }
     this.DisplayEntry = entry;
 }
Example #2
0
        /// <summary>
        /// Public constructor for WideControlEntryItem.
        /// </summary>
        public WideControlEntryItem(DisplayEntry entry, IEnumerable <string> selectedBy) : this()
        {
            if (entry == null)
            {
                throw PSTraceSource.NewArgumentNullException("entry");
            }
            if (selectedBy == null)
            {
                throw PSTraceSource.NewArgumentNullException("selectedBy");
            }

            this.DisplayEntry    = entry;
            this.EntrySelectedBy = EntrySelectedBy.Get(selectedBy, null);
        }
Example #3
0
        internal WideControlEntryItem(WideControlEntryDefinition definition) : this()
        {
            FieldPropertyToken fpt = definition.formatTokenList[0] as FieldPropertyToken;

            if (fpt != null)
            {
                DisplayEntry = new DisplayEntry(fpt.expression);
                FormatString = fpt.fieldFormattingDirective.formatString;
            }

            if (definition.appliesTo != null)
            {
                EntrySelectedBy = EntrySelectedBy.Get(definition.appliesTo.referenceList);
            }
        }
Example #4
0
        internal ListControlEntryItem(ListControlItemDefinition definition)
        {
            if (definition.label != null)
            {
                Label = definition.label.text;
            }
            FieldPropertyToken fpt = definition.formatTokenList[0] as FieldPropertyToken;

            if (fpt != null)
            {
                if (fpt.fieldFormattingDirective.formatString != null)
                {
                    FormatString = fpt.fieldFormattingDirective.formatString;
                }

                DisplayEntry = new DisplayEntry(fpt.expression);
                if (definition.conditionToken != null)
                {
                    ItemSelectionCondition = new DisplayEntry(definition.conditionToken);
                }
            }
        }
Example #5
0
 private ExpressionToken LoadExpressionFromObjectModel(DisplayEntry displayEntry, int viewIndex, string typeName)
 {
     ExpressionToken token = new ExpressionToken();
     if (displayEntry.ValueType.Equals(DisplayEntryValueType.Property))
     {
         token.expressionValue = displayEntry.Value;
         return token;
     }
     if (displayEntry.ValueType.Equals(DisplayEntryValueType.ScriptBlock))
     {
         token.isScriptBlock = true;
         token.expressionValue = displayEntry.Value;
         try
         {
             base.expressionFactory.VerifyScriptBlockText(token.expressionValue);
         }
         catch (ParseException exception)
         {
             base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidScriptBlockInFormattingData, new object[] { typeName, viewIndex, exception.Message }), typeName);
             return null;
         }
         catch (Exception)
         {
             throw;
         }
         return token;
     }
     PSTraceSource.NewInvalidOperationException();
     return null;
 }
 internal bool SafeForExport()
 {
     return(DisplayEntry.SafeForExport());
 }
Example #7
0
        /// <summary>
        /// Load the expression information from DisplayEntry
        /// </summary>
        /// <param name="displayEntry"></param>
        /// <param name="viewIndex"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        private ExpressionToken LoadExpressionFromObjectModel(DisplayEntry displayEntry, int viewIndex, string typeName)
        {
            ExpressionToken token = new ExpressionToken();
            if (displayEntry.ValueType == DisplayEntryValueType.Property)
            {
                token.expressionValue = displayEntry.Value;
                return token;
            }
            else if (displayEntry.ValueType == DisplayEntryValueType.ScriptBlock)
            {
                token.isScriptBlock = true;
                token.expressionValue = displayEntry.Value;

                try
                {
                    // For faster startup, we don't validate any of the built-in formatting script blocks, where isFullyTrusted == built-in.
                    if (!LoadingInfo.isFullyTrusted)
                    {
                        this.expressionFactory.VerifyScriptBlockText(token.expressionValue);
                    }
                }
                catch (ParseException e)
                {
                    // Error at 
                    this.ReportErrorForLoadingFromObjectModel(
                        StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidScriptBlockInFormattingData, typeName, viewIndex, e.Message), typeName);
                    return null;
                }
                catch (Exception e) // will rethrow
                {
                    Diagnostics.Assert(false, "TypeInfoBaseLoader.VerifyScriptBlock unexpected exception " + e.GetType().FullName);
                    throw;
                }

                return token;
            }
            // this should never happen if the API is used correctly
            PSTraceSource.NewInvalidOperationException();
            return null;
        }
 internal TableControlColumn(string text, int alignment, bool isscriptblock, string formatString)
 {
     Alignment    = (Alignment)alignment;
     DisplayEntry = new DisplayEntry(text, isscriptblock ? DisplayEntryValueType.ScriptBlock : DisplayEntryValueType.Property);
     FormatString = formatString;
 }
 /// <summary>
 /// Public constructor for TableControlColumn.
 /// </summary>
 /// <param name="alignment"></param>
 /// <param name="entry"></param>
 public TableControlColumn(Alignment alignment, DisplayEntry entry)
 {
     this.Alignment    = alignment;
     this.DisplayEntry = entry;
 }
 internal TableControlColumn(string text, int alignment, bool isscriptblock, string formatString)
 {
     Alignment = (Alignment)alignment;
     DisplayEntry = new DisplayEntry(text, isscriptblock ? DisplayEntryValueType.ScriptBlock : DisplayEntryValueType.Property);
     FormatString = formatString;
 }
 /// <summary>
 /// Public constructor for TableControlColumn.
 /// </summary>
 /// <param name="alignment"></param>
 /// <param name="entry"></param>
 public TableControlColumn(Alignment alignment, DisplayEntry entry)
 {
     this.Alignment = alignment;
     this.DisplayEntry = entry;
 }
 /// <summary>
 /// Public constructor for ListControlEntryItem
 /// Label and Entry could be null
 /// </summary>
 /// <param name="label"></param>
 /// <param name="entry"></param>
 public ListControlEntryItem(string label, DisplayEntry entry)
 {
     this.Label = label;
     this.DisplayEntry = entry;
 }
        internal ListControlEntryItem(ListControlItemDefinition definition)
        {
            if (definition.label != null)
            {
                Label = definition.label.text;
            }
            FieldPropertyToken fpt = definition.formatTokenList[0] as FieldPropertyToken;
            if (fpt != null)
            {
                if (fpt.fieldFormattingDirective.formatString != null)
                {
                    FormatString = fpt.fieldFormattingDirective.formatString;
                }

                DisplayEntry = new DisplayEntry(fpt.expression);
                if (definition.conditionToken != null)
                {
                    ItemSelectionCondition = new DisplayEntry(definition.conditionToken);
                }
            }
        }
        /// <summary>
        /// Adds a property that is displayed if it the property has a value.
        /// </summary>
        /// <param name="property">The property to add.</param>
        /// <param name="label">A label for the entry.</param>
        /// <param name="format">A format string for the property value.</param>
        /// <returns>A reference to this instance after the append operation has completed.</returns>
        public ListEntryBuilder AddItemPropertyIfSet(string property, string label = null, string format = null)
        {
            var itemSelectionCondition = DisplayEntry.CreatePropertyEntry(property);

            return(AddItem(property, label, DisplayEntryValueType.Property, format, itemSelectionCondition));
        }
        internal WideControlEntryItem(WideControlEntryDefinition definition) : this()
        {
            FieldPropertyToken fpt = definition.formatTokenList[0] as FieldPropertyToken;
            if (fpt != null)
            {
                DisplayEntry = new DisplayEntry(fpt.expression);
                FormatString = fpt.fieldFormattingDirective.formatString;
            }

            if (definition.appliesTo != null)
            {
                EntrySelectedBy = EntrySelectedBy.Get(definition.appliesTo.referenceList);
            }
        }
 /// <summary>Adds a property list entry.</summary>
 /// <param name="property">The property to add.</param>
 /// <param name="label">A label for the entry.</param>
 /// <param name="format">A format string for the property value.</param>
 /// <param name="itemSelectionCondition">A condition that has to be met for the entry to be displayed.</param>
 /// <returns>A reference to this instance after the append operation has completed.</returns>
 public ListEntryBuilder AddItemProperty(string property, string label = null, string format = null, DisplayEntry itemSelectionCondition = null)
 {
     return(AddItem(property, label, DisplayEntryValueType.Property, format, itemSelectionCondition));
 }
 /// <summary>Adds a scriptblock list entry.</summary>
 /// <param name="scriptBlock">The content of the scriptblock to add.</param>
 /// <param name="label">A label for the entry.</param>
 /// <param name="format">A format string for the scriptblock result.</param>
 /// <param name="itemSelectionCondition">A condition that has to be met for the entry to be displayed.</param>
 /// <returns>A reference to this instance after the append operation has completed.</returns>
 public ListEntryBuilder AddItemScriptBlock(string scriptBlock, string label = null, string format = null, DisplayEntry itemSelectionCondition = null)
 {
     return(AddItem(scriptBlock, label, DisplayEntryValueType.ScriptBlock, format, itemSelectionCondition));
 }
        private ListEntryBuilder AddItem(string value, string label, DisplayEntryValueType kind, string format, DisplayEntry itemSelectionCondition)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw PSTraceSource.NewArgumentNullException("property");
            }

            _listEntry.Items.Add(new ListControlEntryItem
            {
                DisplayEntry           = new DisplayEntry(value, kind),
                Label                  = label,
                FormatString           = format,
                ItemSelectionCondition = itemSelectionCondition,
            });

            return(this);
        }
        /// <summary>
        /// Public constructor for WideControlEntryItem.
        /// </summary>
        public WideControlEntryItem(DisplayEntry entry, IEnumerable<string> selectedBy) : this()
        {
            if (entry == null)
                throw PSTraceSource.NewArgumentNullException("entry");
            if (selectedBy == null)
                throw PSTraceSource.NewArgumentNullException("selectedBy");

            this.DisplayEntry = entry;
            this.EntrySelectedBy = EntrySelectedBy.Get(selectedBy, null);
        }
 /// <summary>
 /// Public constructor for WideControlEntryItem.
 /// </summary>
 public WideControlEntryItem(DisplayEntry entry) : this()
 {
     if (entry == null)
         throw PSTraceSource.NewArgumentNullException("entry");
     this.DisplayEntry = entry;
 }
Example #21
0
 /// <summary>
 /// Public constructor for ListControlEntryItem
 /// Label and Entry could be null
 /// </summary>
 /// <param name="label"></param>
 /// <param name="entry"></param>
 public ListControlEntryItem(string label, DisplayEntry entry)
 {
     this.Label        = label;
     this.DisplayEntry = entry;
 }
Example #22
0
 internal bool SafeForExport()
 {
     return(DisplayEntry.SafeForExport() &&
            (ItemSelectionCondition == null || ItemSelectionCondition.SafeForExport()));
 }
Example #23
0
 internal bool SafeForExport()
 {
     return(DisplayEntry.SafeForExport() && (EntrySelectedBy == null || EntrySelectedBy.SafeForExport()));
 }
Example #24
0
 internal void WriteDisplayEntry(DisplayEntry displayEntry)
 {
     if (displayEntry.ValueType == DisplayEntryValueType.Property)
     {
         _writer.WriteElementString("PropertyName", displayEntry.Value);
     }
     else if (displayEntry.ValueType == DisplayEntryValueType.ScriptBlock)
     {
         _writer.WriteStartElement("ScriptBlock");
         _writer.WriteValue(_exportScriptBlock ? displayEntry.Value : ";");
         _writer.WriteEndElement(/*</ScriptBlock>*/);
     }
 }