Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
FormattingObjects.cs396 linesDownload Raw Back to common
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4// This file contains the definitions for the objects5// used in the communication protocol between formatting6// and output commands. the format/xxx commands instantiate7// these objects and write them to the pipeline. The out-xxx8// commands read them from the pipeline.9//10// NOTE:11// Since format/xxx and out-xxx commands can be separated by12// serialization boundaries, the structure of these objects13// must adhere to the Monad serialization constraints.14//15// Since the out-xxx commands heavily access these objects and16// there is an up front need for protocol validation, the out-xxx17// commands do deserialize the objects back from the property bag18// representation that mig have been introduced by serialization.19//20// There is also the need to preserve type information across serialization21// boundaries, therefore the objects provide a GUID based mechanism to22// preserve the information.23//24 25using System.Collections.Generic;26using System.Management.Automation;27 28namespace Microsoft.PowerShell.Commands.Internal.Format29{30    #region Root of Class Hierarchy31    /// <summary>32    /// Base class from which all the formatting objects33    /// will derive from.34    /// It provides the mechanism to preserve type information.35    /// </summary>36    internal abstract partial class FormatInfoData37    {38        /// <summary>39        /// Name of the "get" property that allows access to CLSID information.40        /// This is needed by the ERS API's.41        /// </summary>42        internal const string classidProperty = "ClassId2e4f51ef21dd47e99d3c952918aff9cd";43 44        /// <summary>45        /// String containing a GUID, to be set by each derived class46        /// "get" property to get CLSID information.47        /// It is named with a GUID like name to avoid potential collisions with48        /// properties of payload objects.49        /// </summary>50        public abstract string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get; }51    }52 53    #endregion54 55    #region Top Level Messages56 57    internal abstract class PacketInfoData : FormatInfoData58    {59    }60 61    internal abstract partial class ControlInfoData : PacketInfoData62    {63        /// <summary>64        /// Null by default, present only if grouping specified.65        /// </summary>66        public GroupingEntry groupingEntry = null;67    }68 69    internal abstract partial class StartData : ControlInfoData70    {71        /// <summary>72        /// It needs to be either on FormatStartData or GroupStartData73        /// but not both or neither.74        /// </summary>75        public ShapeInfo shapeInfo;76    }77 78    /// <summary>79    /// Sequence start: the very first message sent.80    /// </summary>81    internal sealed partial class FormatStartData : StartData82    {83        internal const string CLSID = "033ecb2bc07a4d43b5ef94ed5a35d280";84 85        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }86 87        /// <summary>88        /// Optional.89        /// </summary>90        public PageHeaderEntry pageHeaderEntry;91 92        /// <summary>93        /// Optional.94        /// </summary>95        public PageFooterEntry pageFooterEntry;96 97        /// <summary>98        /// Autosize formatting directive. If present, the output command is instructed99        /// to get the autosize "best fit" for the device screen according to the flags100        /// this object contains.101        /// </summary>102        public AutosizeInfo autosizeInfo;103    }104 105    /// <summary>106    /// Sequence end: the very last message sent.107    /// </summary>108    internal sealed class FormatEndData : ControlInfoData109    {110        internal const string CLSID = "cf522b78d86c486691226b40aa69e95c";111 112        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }113    }114 115    /// <summary>116    /// Group start: message marking the beginning of a group.117    /// </summary>118    internal sealed class GroupStartData : StartData119    {120        internal const string CLSID = "9e210fe47d09416682b841769c78b8a3";121 122        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }123    }124 125    /// <summary>126    /// Group end: message marking the end of a group.127    /// </summary>128    internal sealed class GroupEndData : ControlInfoData129    {130        internal const string CLSID = "4ec4f0187cb04f4cb6973460dfe252df";131 132        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }133    }134 135    /// <summary>136    /// Generic entry containing payload data and related formatting info.137    /// </summary>138    internal sealed partial class FormatEntryData : PacketInfoData139    {140        internal const string CLSID = "27c87ef9bbda4f709f6b4002fa4af63c";141 142        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }143 144        /// <summary>145        /// Mandatory, but depending on the shape we send in146        /// it must match what got sent in the format start message.147        /// </summary>148        public FormatEntryInfo formatEntryInfo = null;149 150        public bool outOfBand = false;151        public WriteStreamType writeStream = WriteStreamType.None;152        internal bool isHelpObject = false;153    }154    #endregion155 156    #region Shape Info Classes157 158    internal abstract class ShapeInfo : FormatInfoData159    {160    }161 162    internal sealed partial class WideViewHeaderInfo : ShapeInfo163    {164        internal const string CLSID = "b2e2775d33d544c794d0081f27021b5c";165 166        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }167 168        /// <summary>169        /// Desired number of columns on the screen.170        /// Advisory, the outputter can decide otherwise171        ///172        /// A zero value signifies let the outputter get the173        /// best fit on the screen (possibly blocking until the end)174        /// </summary>175        public int columns = 0;176    }177 178    internal sealed partial class TableHeaderInfo : ShapeInfo179    {180        internal const string CLSID = "e3b7a39c089845d388b2e84c5d38f5dd";181 182        public TableHeaderInfo()183        {184            tableColumnInfoList = new List<TableColumnInfo>();185        }186 187        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }188 189        public bool hideHeader;190        public bool repeatHeader;191        public List<TableColumnInfo> tableColumnInfoList;192    }193 194    internal sealed partial class TableColumnInfo : FormatInfoData195    {196        internal const string CLSID = "7572aa4155ec4558817a615acf7dd92e";197 198        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }199 200        /// <summary>201        /// Width of the column:202        /// == 0 -> let the outputter decide203        /// > 0 -> user provided value.204        /// </summary>205        public int width = 0;206 207        public int alignment = TextAlignment.Left;208        public string label = null;209        public string propertyName = null;210        public bool HeaderMatchesProperty = true;211    }212 213    internal sealed class ListViewHeaderInfo : ShapeInfo214    {215        internal const string CLSID = "830bdcb24c1642258724e441512233a4";216 217        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }218    }219 220    internal sealed class ComplexViewHeaderInfo : ShapeInfo221    {222        internal const string CLSID = "5197dd85ca6f4cce9ae9e6fd6ded9d76";223 224        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }225    }226 227    #endregion228 229    #region Formatting Entries Classes230 231    internal abstract class FormatEntryInfo : FormatInfoData232    {233    }234 235    internal sealed partial class RawTextFormatEntry : FormatEntryInfo236    {237        internal const string CLSID = "29ED81BA914544d4BC430F027EE053E9";238 239        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }240 241        public string text = null;242    }243 244    internal abstract partial class FreeFormatEntry : FormatEntryInfo245    {246        public List<FormatValue> formatValueList = new List<FormatValue>();247    }248 249    internal sealed partial class ListViewEntry : FormatEntryInfo250    {251        internal const string CLSID = "cf58f450baa848ef8eb3504008be6978";252 253        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }254 255        public List<ListViewField> listViewFieldList = new List<ListViewField>();256    }257 258    internal sealed partial class ListViewField : FormatInfoData259    {260        internal const string CLSID = "b761477330ce4fb2a665999879324d73";261 262        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }263 264        public string label = null;265        public string propertyName = null;266        public FormatPropertyField formatPropertyField = new FormatPropertyField();267    }268 269    internal sealed partial class TableRowEntry : FormatEntryInfo270    {271        internal const string CLSID = "0e59526e2dd441aa91e7fc952caf4a36";272 273        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }274 275        public List<FormatPropertyField> formatPropertyFieldList = new List<FormatPropertyField>();276        public bool multiLine = false;277    }278 279    internal sealed partial class WideViewEntry : FormatEntryInfo280    {281        internal const string CLSID = "59bf79de63354a7b9e4d1697940ff188";282 283        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }284 285        public FormatPropertyField formatPropertyField = new FormatPropertyField();286    }287 288    internal sealed class ComplexViewEntry : FreeFormatEntry289    {290        internal const string CLSID = "22e7ef3c896449d4a6f2dedea05dd737";291 292        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }293    }294 295    internal sealed class GroupingEntry : FreeFormatEntry296    {297        internal const string CLSID = "919820b7eadb48be8e202c5afa5c2716";298 299        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }300    }301 302    internal sealed class PageHeaderEntry : FreeFormatEntry303    {304        internal const string CLSID = "dd1290a5950b4b27aa76d9f06199c3b3";305 306        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }307    }308 309    internal sealed class PageFooterEntry : FreeFormatEntry310    {311        internal const string CLSID = "93565e84730645c79d4af091123eecbc";312 313        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }314    }315 316    internal sealed partial class AutosizeInfo : FormatInfoData317    {318        internal const string CLSID = "a27f094f0eec4d64845801a4c06a32ae";319 320        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }321 322        /// <summary>323        /// Number of objects to compute the best fit.324        /// Zero: all the objects325        /// a positive number N: use the first N.326        /// </summary>327        public int objectCount = 0;328    }329 330    #endregion331 332    #region Format Values333 334    internal abstract class FormatValue : FormatInfoData335    {336    }337 338    internal sealed class FormatNewLine : FormatValue339    {340        internal const string CLSID = "de7e8b96fbd84db5a43aa82eb34580ec";341 342        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }343    }344 345    internal sealed partial class FormatTextField : FormatValue346    {347        internal const string CLSID = "b8d9e369024a43a580b9e0c9279e3354";348 349        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }350 351        public string text;352    }353 354    internal sealed partial class FormatPropertyField : FormatValue355    {356        internal const string CLSID = "78b102e894f742aca8c1d6737b6ff86a";357 358        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }359 360        public string propertyValue = null;361        public int alignment = TextAlignment.Undefined;362    }363 364    internal sealed partial class FormatEntry : FormatValue365    {366        internal const string CLSID = "fba029a113a5458d932a2ed4871fadf2";367 368        public FormatEntry()369        {370            formatValueList = new List<FormatValue>();371        }372 373        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }374 375        public List<FormatValue> formatValueList;376 377        /// <summary>378        /// Optional information of frame data (indentation, etc.)379        /// </summary>380        public FrameInfo frameInfo;381    }382 383    internal sealed partial class FrameInfo : FormatInfoData384    {385        internal const string CLSID = "091C9E762E33499eBE318901B6EFB733";386 387        public override string ClassId2e4f51ef21dd47e99d3c952918aff9cd { get { return CLSID; } }388 389        public int leftIndentation = 0;390        public int rightIndentation = 0;391        public int firstLine = 0;392    }393 394    #endregion395}396