Beispiel #1
0
        /// <summary>
        /// Converts a Resource into a CSharpFile.
        /// </summary>
        /// <param name="resource">The resource</param>
        /// <returns>The converted CSharpFile.</returns>
        public static CSharpFile ToCSharpFile(this Resource resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }

            // Get the C# file details
            CSharpFile cSharpFile = new CSharpFile(resource.RelativeFilePath + ".cs")
            {
                Usings  = CSharpFileHelper.GetDefaultUsings(),
                Classes = resource.CreateClasses(),
            };

            return(cSharpFile);
        }
        /// <summary>
        /// Converts an ObjectFactoryCmdlet into a CSharpFile.
        /// </summary>
        /// <param name="cmdlet">The object factory cmdlet</param>
        /// <returns>The converted CSharpFile.</returns>
        public static CSharpFile ToCSharpFile(this ObjectFactoryCmdlet cmdlet)
        {
            if (cmdlet == null)
            {
                throw new ArgumentNullException(nameof(cmdlet));
            }

            // Get the C# file details
            CSharpFile cSharpFile = new CSharpFile(cmdlet.RelativeFilePath + ".cs")
            {
                Usings  = CSharpFileHelper.GetDefaultUsings(),
                Classes = cmdlet.ToCSharpClass().SingleObjectAsEnumerable(),
            };

            return(cSharpFile);
        }