Exemplo n.º 1
0
        private static CmdletParameter CreateEntityParameter(
            OdcmProperty property,
            Type powerShellType,
            bool markAsPowerShellParameter,
            bool isBaseType,
            string entityTypeFullName,
            bool isReadOnly = false,
            bool allowPipelineInputByName   = true,
            IEnumerable <string> enumValues = null)
        {
            var result = new CmdletParameter(property.Name, powerShellType)
            {
                Mandatory                       = property.IsRequired,
                IsPowerShellParameter           = markAsPowerShellParameter && !isReadOnly,
                ValueFromPipelineByPropertyName = allowPipelineInputByName,
                DerivedTypeName                 = markAsPowerShellParameter || isBaseType
                                ? null
                                : entityTypeFullName,
                IsExpandable  = property.IsExpandable(),
                IsSortable    = !markAsPowerShellParameter && !property.IsCollection,
                Documentation = new CmdletParameterDocumentation()
                {
                    Descriptions = new string[] {
                        $"The \"{property.Name}\" property, of type \"{property.Type.FullName}\".",
                        $"This property is on the \"{entityTypeFullName}\" type.",
                        property.Description,
                    },
                    ValidValues = enumValues,
                }
            };

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether the property can be part of an OData route.
        /// </summary>
        /// <param name="property">The property</param>
        /// <returns>True if the property can be part of an OData route, otherwise false.</returns>
        public static bool IsODataRouteSegment(this OdcmProperty property, bool isTopLevelProperty)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            bool result = // Make sure that this property is:
                          // top-level
                          isTopLevelProperty
                          // or expandable
                          || property.IsExpandable()
                          // or a data stream property
                          || property.IsStream();

            return(result);
        }