예제 #1
0
        private static FormatViewDefinition RehydrateFormatViewDefinition(
            PSObject deserializedViewDefinition)
        {
            string    propertyValue1 = DeserializingTypeConverter.GetPropertyValue <string>(deserializedViewDefinition, "Name");
            Guid      propertyValue2 = DeserializingTypeConverter.GetPropertyValue <Guid>(deserializedViewDefinition, "InstanceId");
            PSControl propertyValue3 = DeserializingTypeConverter.GetPropertyValue <PSControl>(deserializedViewDefinition, "Control");

            return(new FormatViewDefinition(propertyValue1, propertyValue3, propertyValue2));
        }
예제 #2
0
        protected override void ProcessRecord()
        {
            List <ViewDefinition> viewDefinitionList = base.Context.FormatDBManager.Database.viewDefinitionsSection.viewDefinitionList;
            Dictionary <string, List <FormatViewDefinition> > dictionary = new Dictionary <string, List <FormatViewDefinition> >();

            foreach (ViewDefinition definition in viewDefinitionList)
            {
                foreach (TypeOrGroupReference reference in definition.appliesTo.referenceList)
                {
                    PSControl control = null;
                    if (definition.mainControl is TableControlBody)
                    {
                        control = new TableControl((TableControlBody)definition.mainControl);
                    }
                    if (definition.mainControl is ListControlBody)
                    {
                        control = new ListControl((ListControlBody)definition.mainControl);
                    }
                    if (definition.mainControl is WideControlBody)
                    {
                        control = new WideControl((WideControlBody)definition.mainControl);
                    }
                    if (control != null)
                    {
                        FormatViewDefinition item = new FormatViewDefinition(definition.name, control, definition.InstanceId);
                        foreach (WildcardPattern pattern in this._filter)
                        {
                            if (pattern.IsMatch(reference.name))
                            {
                                if (!dictionary.ContainsKey(reference.name))
                                {
                                    dictionary.Add(reference.name, new List <FormatViewDefinition>());
                                }
                                dictionary[reference.name].Add(item);
                            }
                        }
                    }
                }
            }
            foreach (string str in dictionary.Keys)
            {
                base.WriteObject(new ExtendedTypeDefinition(str, dictionary[str]));
            }
        }