예제 #1
0
 public LibraryMutations(
     LibraryGenerator libraryGenerator,
     AppSettings appSettings
     )
 {
     this.LibraryGenerator = libraryGenerator;
     this.AppSettings      = appSettings;
 }
예제 #2
0
        public RootQueryGraphType(
            MovieRepository movieRepository,
            SourceRepository sourceRepository,
            LibraryGenerator libraryGenerator,
            MovieMetadataProcessor MovieMetadataProcessor,
            MediaItemRepository mediaItemRepository,
            UserRepository userRepository,
            MovieGraphType movieGraphType,
            DatabaseGraphType databaseGraphType
            )
        {
            this.Name = "Query";
            databaseGraphType.Register(this);

            Field <ListGraphType <MovieGraphType>, IEnumerable <Movie> >()
            .Name("movies")
            .Description("A list of movies")
            .Argument <ListGraphType <IntGraphType> >("ids", "A list of ids of the polls to fetch")
            .Argument <IntGraphType>("top", "Pick the top N results")
            .Argument <IntGraphType>("skip", "skip the first N results")
            .ResolveAsync(async(ctx) =>
            {
                var filters = movieRepository.GetArgumentFilters(ctx);
                var results = await movieRepository.Query(filters, ctx.SubFields.Keys);
                return(results);
            });

            Field <ListGraphType <SourceGraphType> >()
            .Name("sources")
            .Description("The sources of media for this library")
            .ResolveAsync(async(ctx) =>
            {
                var results = await sourceRepository.GetAll();
                return(results);
            });

            Field <LibraryGeneratorStatusGraphType>()
            .Name("libraryGeneratorStatus")
            .Description("The status of the library generator")
            .Resolve((ResolveFieldContext <object> ctx) =>
            {
                var status = libraryGenerator.GetStatus();
                return(status);
            });

            Field <ListGraphType <MovieMetadataSearchResultGraphType> >()
            .Name("movieMetadataSearchResults")
            .Description("A list of TMDB movie search results")
            .Argument <StringGraphType>("searchText", "The text to use to search for results")
            .ResolveAsync(async(ctx) =>
            {
                var searchText = ctx.GetArgument <string>("searchText");
                return(await MovieMetadataProcessor.GetSearchResultsAsync(searchText));
            });

            Field <MovieMetadataComparisonGraphType>()
            .Name("movieMetadataComparison")
            .Description("A comparison of a metadata search result to what is currently in the system")
            .Argument <IntGraphType>("tmdbId", "The TMDB of the incoming movie")
            .Argument <IntGraphType>("movieId", "The id of the current movie in the system")
            .ResolveAsync(async(ctx) =>
            {
                var tmdbId  = ctx.GetArgument <int>("tmdbId");
                var movieId = ctx.GetArgument <int>("movieId");
                return(await MovieMetadataProcessor.GetComparisonAsync(tmdbId, movieId));
            });

            Field <ListGraphType <MediaHistoryRecordGraphType> >().Name("mediaHistory")
            .Description("A list of media items consumed and their current progress and duration of viewing")
            .Argument <ListGraphType <IntGraphType> >("mediaItemIds", "A list of mediaItem IDs")
            .ResolveAsync(async(ctx) =>
            {
                var arguments = ctx.GetArguments(new MediaHistoryArguments());
                var results   = await mediaItemRepository.GetHistory(userRepository.CurrentProfileId, null, null, arguments.MediaItemIds);
                return(results);
            });

            Field <ListGraphType <MediaItemGraphType> >().Name("mediaItems")
            .Description("A list of media items (i.e. movies, shows, episodes, etc). This is a union graph type, so you must specify inline fragments ")
            .Argument <ListGraphType <IntGraphType> >("mediaItemIds", "A list of mediaItem IDs")
            .Argument <StringGraphType>("searchText", "A string to use to search for media items")
            .ResolveAsync(async(ctx) =>
            {
                var arguments = ctx.GetArguments(new MediaItemArguments());
                if (arguments.MediaItemIds != null)
                {
                    return(await mediaItemRepository.GetByIds(arguments.MediaItemIds));
                }
                else if (arguments.SearchText != null)
                {
                    return(await mediaItemRepository.GetSearchResults(arguments.SearchText));
                }
                else
                {
                    throw new Exception("No valid arguments provided");
                }
            });
        }
예제 #3
0
        private void generateButton_Click(object sender, System.EventArgs e)
        {
            DirectoryInfo outputDir = new DirectoryInfo(outputPathTextBox.Text);

            if (outputDir.Exists == false)
            {
                MessageBox.Show(this, "Output Path is invalid", "Code Generator");
                return;
            }

            // POSIX, Windows, PocketPC Code Generation
            LibraryGenerator libgen = new LibraryGenerator();

            genOutputTextBox.Clear();

            switch (platformComboBox.SelectedIndex)
            {
            case 0:
                libgen.Platform  = LibraryGenerator.PLATFORMS.POSIX;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                break;

            case 1:
                libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                libgen.WinSock   = 1;
                break;

            case 2:
                libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                libgen.WinSock   = 2;
                break;

            case 3:
                libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.PPC2003;
                libgen.WinSock   = 1;
                break;
            }

            switch (languageComboBox.SelectedIndex)
            {
            case 0:
                libgen.Language = LibraryGenerator.LANGUAGES.C;
                break;

            case 1:
                libgen.Language = LibraryGenerator.LANGUAGES.CPP;
                break;
            }

            switch (newLineComboBox.SelectedIndex)
            {
            case 0:
                libgen.CodeNewLine = "\r\n";
                break;

            case 1:
                libgen.CodeNewLine = "\n";
                break;
            }

            switch (callConventionComboBox.SelectedIndex)
            {
            case 0:
                libgen.CallingConvention = ""; break;

            case 1:
                libgen.CallingConvention = "_stdcall "; break;

            case 2:
                libgen.CallingConvention = "_fastcall "; break;
            }

            switch (indentComboBox.SelectedIndex)
            {
            case 0:
                libgen.CodeTab = "\t"; break;

            case 1:
                libgen.CodeTab = " "; break;

            case 2:
                libgen.CodeTab = "  "; break;

            case 3:
                libgen.CodeTab = "   "; break;

            case 4:
                libgen.CodeTab = "    "; break;

            case 5:
                libgen.CodeTab = "     "; break;

            case 6:
                libgen.CodeTab = "      "; break;
            }

            libgen.CallPrefix    = libPrefixTextBox.Text;
            libgen.CallLibPrefix = libPrefixTextBox.Text;
            libgen.VersionString = "Intel DeviceBuilder Build#" + Application.ProductVersion;
            libgen.ClassName     = classNameTextBox.Text;

            // Setup License
            string license = licenseTextBox.Text;

            license        = license.Replace("<AUTHOR>", "Intel Corporation, Intel Device Builder");
            license        = license.Replace("<REVISION>", "#" + Application.ProductVersion);
            license        = license.Replace("<DATE>", DateTime.Now.ToLongDateString());
            libgen.License = license;

            string lib;

            if (modulesCheckedListBox.GetItemCheckState(3) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_AsyncSocket(libPrefixTextBox.Text, outputDir);
            }
            if (modulesCheckedListBox.GetItemCheckState(4) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_AsyncServerSocket(libPrefixTextBox.Text, outputDir);
            }
            if (modulesCheckedListBox.GetItemCheckState(5) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_WebClient(libPrefixTextBox.Text, outputDir, false);
            }
            if (modulesCheckedListBox.GetItemCheckState(6) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_WebServer(libPrefixTextBox.Text, outputDir, false);
            }

            libgen.OnLogOutput += new LibraryGenerator.LogOutputHandler(Log);
            try
            {
                if (modulesCheckedListBox.GetItemCheckState(0) == CheckState.Checked)
                {
                    SourceCodeRepository.Generate_Parsers(libPrefixTextBox.Text, outputDir);
                }
                if (modulesCheckedListBox.GetItemCheckState(1) == CheckState.Checked)
                {
                    libgen.Build_UPnPHTTPClient(outputDir);
                }
                if (modulesCheckedListBox.GetItemCheckState(2) == CheckState.Checked)
                {
                    SourceCodeRepository.Generate_SSDPClient(libPrefixTextBox.Text, outputDir, true);
                }
            }
            catch
            {
                MessageBox.Show(this, "Error Generating Code", "Code Generator");
            }

            libgen.OnLogOutput -= new LibraryGenerator.LogOutputHandler(Log);
        }
        public void generateButton_Click(object sender, System.EventArgs e)
        {
            DirectoryInfo outputDir = new DirectoryInfo(outputPathTextBox.Text);

            if (outputDir.Exists == false)
            {
                MessageBox.Show(this, "Output Path is invalid", "Code Generator");
                return;
            }

            string buttonText = generateButton.Text;

            generateButton.Text    = "Generating Stack...";
            generateButton.Enabled = false;

            if (UPnP1dot1Enabled.Checked == true)
            {
                device.ArchitectureVersion = "1.1";
            }
            else
            {
                device.ArchitectureVersion = "1.0";
            }

            if (platformComboBox.SelectedIndex == 4)
            {
                // .net
                CPDotNetGenerator gen = new CPDotNetGenerator(classNameTextBox.Text);
                genOutputTextBox.Clear();

                gen.VersionString = "Intel StackBuilder Build#" + Application.ProductVersion;
                gen.StartupPath   = Application.StartupPath;
                gen.OnLogOutput  += new CPDotNetGenerator.LogOutputHandler(Log);
                try
                {
                    gen.Generate(device, outputDir, serviceNames);
                }
                catch
                {
                    MessageBox.Show(this, "Error Generating Code", "Code Generator");
                }
                gen.OnLogOutput -= new CPDotNetGenerator.LogOutputHandler(Log);
            }
            else
            {
                CPEmbeddedCGenerator gen    = new CPEmbeddedCGenerator();
                LibraryGenerator     libgen = new LibraryGenerator();

                genOutputTextBox.Clear();

                gen.EnableDefaultIPAddressMonitor = IPAddressMonitor.Checked;

                switch (platformComboBox.SelectedIndex)
                {
                case 0:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.POSIX;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NONE;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.POSIX;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                    break;

                case 1:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.WINDOWS;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NONE;
                    gen.WinSock      = 1;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                    libgen.WinSock   = 1;
                    break;

                case 2:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.WINDOWS;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NONE;
                    gen.WinSock      = 2;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                    libgen.WinSock   = 2;
                    break;

                case 3:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.WINDOWS;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.PPC2003;
                    gen.WinSock      = 1;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.PPC2003;
                    libgen.WinSock   = 1;
                    break;

                case 4:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.POSIX;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NUCLEUS;
                    gen.WinSock      = 1;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.POSIX;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NUCLEUS;
                    libgen.WinSock   = 1;
                    break;
                }

                switch (languageComboBox.SelectedIndex)
                {
                case 0:
                    gen.Language    = CPEmbeddedCGenerator.LANGUAGES.C;
                    libgen.Language = LibraryGenerator.LANGUAGES.C;
                    break;

                case 1:
                    gen.Language    = CPEmbeddedCGenerator.LANGUAGES.CPP;
                    libgen.Language = LibraryGenerator.LANGUAGES.CPP;
                    break;
                }

                switch (newLineComboBox.SelectedIndex)
                {
                case 0:
                    gen.CodeNewLine = "\r\n"; break;

                case 1:
                    gen.CodeNewLine = "\n"; break;
                }

                switch (callConventionComboBox.SelectedIndex)
                {
                case 0:
                    gen.CallingConvention = ""; break;

                case 1:
                    gen.CallingConvention = "_stdcall "; break;

                case 2:
                    gen.CallingConvention = "_fastcall "; break;
                }

                switch (indentComboBox.SelectedIndex)
                {
                case 0:
                    gen.CodeTab = "\t"; break;

                case 1:
                    gen.CodeTab = " "; break;

                case 2:
                    gen.CodeTab = "  "; break;

                case 3:
                    gen.CodeTab = "   "; break;

                case 4:
                    gen.CodeTab = "    "; break;

                case 5:
                    gen.CodeTab = "     "; break;

                case 6:
                    gen.CodeTab = "      "; break;
                }

                gen.CallPrefix          = prefixTextBox.Text;
                gen.CallLibPrefix       = libPrefixTextBox.Text;
                gen.Settings            = Settings;
                gen.FragResponseActions = FragResponseActions;
                gen.EscapeActions       = EscapeActions;
                gen.VersionString       = "Intel DeviceBuilder Build#" + Application.ProductVersion;
                gen.ClassName           = classNameTextBox.Text;
                gen.UseVersion          = Application.ProductVersion.Substring(0, Application.ProductVersion.LastIndexOf("."));
                gen.BasicHTTP           = !(HTTP.Checked);

                libgen.CodeNewLine       = gen.CodeNewLine;
                libgen.CallingConvention = gen.CallingConvention;
                libgen.CodeTab           = gen.CodeTab;
                libgen.CodeNewLine       = gen.CodeNewLine;
                libgen.CallPrefix        = libPrefixTextBox.Text;
                libgen.VersionString     = gen.VersionString;
                libgen.ClassName         = gen.ClassName;

                foreach (System.Data.DataRow r in dataSet1.Tables[0].Rows)
                {
                    gen.CustomTagList.Add(new object[2] {
                        (string)r.ItemArray[0], (string)r.ItemArray[1]
                    });
                }


                // Setup License
                string license = licenseTextBox.Text;
                license        = license.Replace("<AUTHOR>", "Intel Corporation, Intel Device Builder");
                license        = license.Replace("<REVISION>", "#" + Application.ProductVersion);
                license        = license.Replace("<DATE>", DateTime.Now.ToLongDateString());
                gen.License    = license;
                libgen.License = license;

                gen.OnLogOutput    += new CPEmbeddedCGenerator.LogOutputHandler(Log);
                libgen.OnLogOutput += new LibraryGenerator.LogOutputHandler(Log);

                try
                {
                    SourceCodeRepository.Generate_UPnPControlPointStructs(libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_Parsers(this.libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_SSDPClient(this.libPrefixTextBox.Text, outputDir, UPnP1dot1Enabled.Checked);

                    SourceCodeRepository.Generate_AsyncSocket(this.libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_AsyncServerSocket(this.libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_WebClient(this.libPrefixTextBox.Text, outputDir, !HTTP.Checked);
                    SourceCodeRepository.Generate_WebServer(this.libPrefixTextBox.Text, outputDir, !HTTP.Checked);

                    gen.Generate(device, outputDir, serviceNames, !(bool)gen.Settings["SupressSample"]);
                }
                catch (Exception ddd)
                {
                    MessageBox.Show(this, "Error Generating Code", "Code Generator");
                }

                libgen.OnLogOutput -= new LibraryGenerator.LogOutputHandler(Log);
                gen.OnLogOutput    -= new CPEmbeddedCGenerator.LogOutputHandler(Log);
            }

            generateButton.Enabled = true;
            generateButton.Text    = buttonText;
        }