Example #1
0
		public DTrans(Spec s, Dfa dfa)
		{
			this.dtrans = new int[s.dtrans_ncols];
			this.label = s.dtrans_list.Count;
			this.accept = dfa.GetAccept();
			this.anchor = dfa.GetAnchor();
		}
Example #2
0
		public Dfa(int l)
		{
			this.mark = false;
			this.accept = null;
			this.anchor = 0;
			this.nfa_set = null;
			this.nfa_bit = null;
			this.label = l;
		}
Example #3
0
        /// <summary>
        /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryChangesSince(string, out string, uint?, uint?, string, string, RequestParameter[])">QueryChangesSince</see>
        /// </summary>
        public TMultiple DynamicQuery(
            string whereClause,
            uint?navigationPage     = null,
            uint?navigationPageSize = null,
            string zoneId           = null,
            string contextId        = null,
            params RequestParameter[] requestParameters)
        {
            if (!RegistrationService.Registered)
            {
                throw new InvalidOperationException("Consumer has not been registered.");
            }

            RequestParameter[] messageParameters = (requestParameters ?? (new RequestParameter[0]));
            messageParameters = string.IsNullOrWhiteSpace(whereClause)
                ? messageParameters
                : messageParameters.Concat(new RequestParameter[] { new DynamicQueryParameter(whereClause) }).ToArray();
            var url = new StringBuilder(EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate))
                      .Append($"/{TypeName}s")
                      .Append(HttpUtils.MatrixParameters(zoneId, contextId))
                      .Append(GenerateQueryParameterString(messageParameters))
                      .ToString();
            string responseBody;

            if (navigationPage.HasValue && navigationPageSize.HasValue)
            {
                responseBody = HttpUtils.GetRequest(
                    url,
                    RegistrationService.AuthorisationToken,
                    ConsumerSettings.CompressPayload,
                    navigationPage: (int)navigationPage,
                    navigationPageSize: (int)navigationPageSize,
                    contentTypeOverride: ContentType.ToDescription(),
                    acceptOverride: Accept.ToDescription());
            }
            else
            {
                responseBody = HttpUtils.GetRequest(
                    url,
                    RegistrationService.AuthorisationToken,
                    ConsumerSettings.CompressPayload,
                    contentTypeOverride: ContentType.ToDescription(),
                    acceptOverride: Accept.ToDescription());
            }

            return(DeserialiseMultiple(responseBody));
        }
        /// <summary>
        /// 初始化请求
        /// </summary>
        /// <param name="context"></param>
        internal void InitializeWebRequest(HttpContext context)
        {
            var request = context.WebRequest;

            if (!Accept.IsNullOrEmpty())
            {
                request.Accept = Accept;
            }
            if (!ContentType.IsNullOrEmpty())
            {
                request.ContentType = ContentType;
            }
            else if (Method == HttpMethod.POST)
            {
                request.ContentType = "application/x-www-form-urlencoded";
            }
            if (IfModifiedSince != null)
            {
                request.IfModifiedSince = this.IfModifiedSince.Value;
            }
            if (Range != null)
            {
                request.AddRange(this.Range.Value.Key, this.Range.Value.Value);
            }
            if (AppendAjaxHeader)
            {
                request.Headers.Add("X-Requested-With", "XMLHttpRequest");
            }
            request.KeepAlive = KeepAlive;
            if (Timeout > 0)
            {
                request.Timeout = request.ReadWriteTimeout = Timeout.Value;
            }
#if NET4
            if (!string.IsNullOrEmpty(Host))
            {
                request.Host = Host;
                Host         = null;
            }
#endif
            request.AllowAutoRedirect      = AllowAutoRedirect;
            request.AutomaticDecompression = DecompressionMethods.None;
            if (ReferUri != null)
            {
                request.Referer = ReferUri.ToString();
            }
        }
Example #5
0
        public void When_a_materializer_throws_then_an_informative_exception_message_is_given()
        {
            var command = Command("the-command", "",
                                  Option("-o|--one", "",
                                         Accept.ExactlyOneArgument()
                                         .MaterializeAs(o => int.Parse(o.Arguments.Single()))));

            var result = command.Parse("the-command -o not-an-int");

            Action getValue = () => result["the-command"]["one"].Value();

            getValue.ShouldThrow <ParseException>()
            .Which
            .Message
            .Should()
            .Be("An exception occurred while getting the value for option 'one' based on argument(s): not-an-int.");
        }
Example #6
0
 public static Command Publish() =>
 CreateWithRestoreOptions.Command(
     "publish",
     LocalizableStrings.AppDescription,
     Accept.ZeroOrMoreArguments()
     .With(name: CommonLocalizableStrings.SolutionOrProjectArgumentName,
           description: CommonLocalizableStrings.SolutionOrProjectArgumentDescription),
     CommonOptions.HelpOption(),
     Create.Option(
         "-o|--output",
         LocalizableStrings.OutputOptionDescription,
         Accept.ExactlyOneArgument()
         .With(name: LocalizableStrings.OutputOption)
         .ForwardAsSingle(o => $"-property:PublishDir={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
     CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
     CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
     CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
     CommonOptions.VersionSuffixOption(),
     Create.Option(
         "--manifest",
         LocalizableStrings.ManifestOptionDescription,
         Accept.OneOrMoreArguments()
         .With(name: LocalizableStrings.ManifestOption)
         .ForwardAsSingle(o => $"-property:TargetManifestFiles={string.Join("%3B", o.Arguments.Select(CommandDirectoryContext.GetFullPath))}")),
     Create.Option(
         "--no-build",
         LocalizableStrings.NoBuildOptionDescription,
         Accept.NoArguments().ForwardAs("-property:NoBuild=true")),
     Create.Option(
         "--self-contained",
         LocalizableStrings.SelfContainedOptionDescription,
         Accept.ZeroOrOneArgument()
         .WithSuggestionsFrom("true", "false")
         .ForwardAsSingle(o =>
 {
     string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
     return($"-property:SelfContained={value}");
 })),
     Create.Option(
         "--nologo|/nologo",
         LocalizableStrings.CmdNoLogo,
         Accept.NoArguments()
         .ForwardAs("-nologo")),
     CommonOptions.InteractiveMsBuildForwardOption(),
     CommonOptions.NoRestoreOption(),
     CommonOptions.VerbosityOption());
 public static Command ToolUninstall()
 {
     return(Create.Command("uninstall",
                           LocalizableStrings.CommandDescription,
                           Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageId)
                           .With(name: LocalizableStrings.PackageIdArgumentName,
                                 description: LocalizableStrings.PackageIdArgumentDescription),
                           Create.Option(
                               "-g|--global",
                               LocalizableStrings.GlobalOptionDescription,
                               Accept.NoArguments()),
                           Create.Option(
                               "--tool-path",
                               LocalizableStrings.ToolPathDescription,
                               Accept.ExactlyOneArgument()),
                           CommonOptions.HelpOption()));
 }
Example #8
0
        private void Accept_table()
        {
            int           size     = spec.accept_list.Count;
            int           lastelem = size - 1;
            StringBuilder sb       = new StringBuilder(Lex.MAXSTR);

            sb.Append("private static int[] yy_acpt = new int[]\n  {\n");
            for (int elem = 0; elem < size; elem++)
            {
                sb.Append("  /* ");
                sb.Append(elem);
                sb.Append(" */ ");
                string s      = "  YY_NOT_ACCEPT"; // default to NOT
                Accept accept = (Accept)spec.accept_list[elem];
                if (accept != null)
                {
                    bool is_start = ((spec.anchor_array[elem] & Spec.START) != 0);
                    bool is_end   = ((spec.anchor_array[elem] & Spec.END) != 0);

                    if (is_start && is_end)
                    {
                        s = "  YY_START | YY_END";
                    }
                    else if (is_start)
                    {
                        s = "  YY_START";
                    }
                    else if (is_end)
                    {
                        s = "  YY_END";
                    }
                    else
                    {
                        s = "  YY_NO_ANCHOR";
                    }
                }
                sb.Append(s);
                if (elem < lastelem)
                {
                    sb.Append(",");
                }
                sb.Append("\n");
            }
            sb.Append("  };\n");
            outstream.Write(sb.ToString());
        }
Example #9
0
 public static Command Clean() =>
 Create.Command(
     "clean",
     LocalizableStrings.AppFullName,
     Accept.ZeroOrMoreArguments()
     .With(name: CommonLocalizableStrings.ProjectArgumentName,
           description: CommonLocalizableStrings.ProjectArgumentDescription),
     CommonOptions.HelpOption(),
     Create.Option("-o|--output",
                   LocalizableStrings.CmdOutputDirDescription,
                   Accept.ExactlyOneArgument()
                   .With(name: LocalizableStrings.CmdOutputDir)
                   .ForwardAsSingle(o => $"-property:OutputPath={o.Arguments.Single()}")),
     CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
     CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
     CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
     CommonOptions.VerbosityOption());
Example #10
0
        public void When_one_or_more_arguments_are_expected_and_none_are_provided_then_Value_returns_empty()
        {
            var command = Command("the-command", "",
                                  Option("-x", "", Accept.OneOrMoreArguments()));

            var result = command.Parse("the-command -x");

            var value = result["the-command"]["x"].Value();

            value.Should().BeAssignableTo <IReadOnlyCollection <string> >();

            var values = (IReadOnlyCollection <string>)value;

            values
            .Should()
            .BeEmpty();
        }
Example #11
0
 public static Command Run() =>
 CreateWithRestoreOptions.Command(
     "run",
     LocalizableStrings.AppFullName,
     treatUnmatchedTokensAsErrors: false,
     arguments: Accept.ZeroOrMoreArguments()
     .MaterializeAs(o => new RunCommand
                    (
                        configuration: o.SingleArgumentOrDefault("--configuration"),
                        framework: o.SingleArgumentOrDefault("--framework"),
                        runtime: o.SingleArgumentOrDefault("--runtime"),
                        noBuild: o.HasOption("--no-build"),
                        project: o.SingleArgumentOrDefault("--project"),
                        launchProfile: o.SingleArgumentOrDefault("--launch-profile"),
                        noLaunchProfile: o.HasOption("--no-launch-profile"),
                        noRestore: o.HasOption("--no-restore") || o.HasOption("--no-build"),
                        interactive: o.HasOption(Utils.Constants.RestoreInteractiveOption),
                        restoreArgs: o.OptionValuesToBeForwarded(),
                        args: o.Arguments
                    )),
     options: new[]
 {
     CommonOptions.HelpOption(),
     CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
     CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
     CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
     Create.Option(
         "-p|--project",
         LocalizableStrings.CommandOptionProjectDescription,
         Accept.ExactlyOneArgument()),
     Create.Option(
         "--launch-profile",
         LocalizableStrings.CommandOptionLaunchProfileDescription,
         Accept.ExactlyOneArgument()),
     Create.Option(
         "--no-launch-profile",
         LocalizableStrings.CommandOptionNoLaunchProfileDescription,
         Accept.NoArguments()),
     Create.Option(
         "--no-build",
         LocalizableStrings.CommandOptionNoBuildDescription,
         Accept.NoArguments()),
     CommonOptions.InteractiveOption(),
     CommonOptions.NoRestoreOption(),
     CommonOptions.VerbosityOption()
 });
Example #12
0
 public ListCommand()
     : base(
         name: "list",
         help: LocalizableStrings.NetListCommand,
         options: new Option[]
 {
     CommonOptions.HelpOption(),
     ListPackageReferencesCommandParser.ListPackageReferences(),
     ListProjectToProjectReferencesCommandParser.ListProjectToProjectReferences(),
 },
         arguments: Accept.ZeroOrOneArgument()
         .With(
             name: CommonLocalizableStrings.SolutionOrProjectArgumentName,
             description: CommonLocalizableStrings.SolutionOrProjectArgumentDescription)
         .DefaultToCurrentDirectory())
 {
 }
Example #13
0
 private void EmitAcceptTable()
 {
     this.outstream.WriteLine("private static AcceptConditions[] acceptCondition = new AcceptConditions[]");
     this.outstream.WriteLine("{");
     this.outstream.Indent++;
     for (int i = 0; i < this.spec.accept_list.Count; i++)
     {
         Accept accept = this.spec.accept_list[i];
         if (accept != null)
         {
             bool flag  = (this.spec.anchor_array[i] & 1) != 0;
             bool flag2 = (this.spec.anchor_array[i] & 2) != 0;
             if (flag && flag2)
             {
                 this.outstream.Write("AcceptConditions.AcceptOnStart | AcceptConditions.AcceptOnEnd");
             }
             else
             {
                 if (flag)
                 {
                     this.outstream.Write("AcceptConditions.AcceptOnStart");
                 }
                 else
                 {
                     if (flag2)
                     {
                         this.outstream.Write("AcceptConditions.AcceptOnEnd");
                     }
                     else
                     {
                         this.outstream.Write("AcceptConditions.Accept");
                     }
                 }
             }
         }
         else
         {
             this.outstream.Write("AcceptConditions.NotAccept");
         }
         this.outstream.Write(", // ");
         this.outstream.WriteLine(i);
     }
     this.outstream.Indent--;
     this.outstream.WriteLine("};");
     this.outstream.WriteLine();
 }
Example #14
0
        public static HttpWebResponse Get(string url, Accept accept, Accept encoding, CookieCollection cookies = null, bool allowRedirect = false)
        {
            if (!url.StartsWith("http://"))
            {
                url = url.Insert(0, "http://");
            }

            Uri uri = new Uri(url);

            HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(uri);

            wreq.Headers["X-Requested-With"] = "XMLHttpRequest";
            wreq.Accept            = accept == Accept.Html ? "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" : "application/vnd.lichess.v1+json";
            wreq.Headers["Origin"] = uri.Host;
            if (encoding == Accept.Json)
            {
                wreq.Headers["Accept-Encoding"] = "gzip, deflate";
            }
            else if (encoding == Accept.Html)
            {
                wreq.Headers["Accept-Encoding"] = "html";
            }
            wreq.Headers["Accept-Language"] = string.Format("{0},{1};q=0.8", CultureInfo.CurrentCulture.IetfLanguageTag, CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            wreq.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
            wreq.Headers["Cache-Control"] = "max-age=0";
            wreq.Method                 = "GET";
            wreq.AllowAutoRedirect      = allowRedirect;
            wreq.AutomaticDecompression = (encoding == Accept.Json) ? DecompressionMethods.GZip : DecompressionMethods.None;

            wreq.CookieContainer = new CookieContainer();
            if (cookies != null)
            {
                wreq.CookieContainer.Add(cookies);
            }

            try
            {
                return((HttpWebResponse)(wreq.GetResponse()));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(string.Format("Error: {0}\nStacktrace:\n{1}", ex.Message, ex.StackTrace));
                return(null);
            }
        }
 public static Command ListPackageReferences() => Create.Command(
     "package",
     LocalizableStrings.AppFullName,
     Accept.NoArguments(),
     CommonOptions.HelpOption(),
     Create.Option("--outdated",
                   LocalizableStrings.CmdOutdatedDescription,
                   Accept.NoArguments().ForwardAs("--outdated")),
     Create.Option("--deprecated",
                   LocalizableStrings.CmdDeprecatedDescription,
                   Accept.NoArguments().ForwardAs("--deprecated")),
     Create.Option("--vulnerable",
                   LocalizableStrings.CmdVulnerableDescription,
                   Accept.NoArguments().ForwardAs("--vulnerable")),
     Create.Option("--framework",
                   LocalizableStrings.CmdFrameworkDescription,
                   Accept.OneOrMoreArguments()
                   .With(name: LocalizableStrings.CmdFramework)
                   .ForwardAsMany(o => ForwardedArguments("--framework", o.Arguments))),
     Create.Option("--include-transitive",
                   LocalizableStrings.CmdTransitiveDescription,
                   Accept.NoArguments().ForwardAs("--include-transitive")),
     Create.Option("--include-prerelease",
                   LocalizableStrings.CmdPrereleaseDescription,
                   Accept.NoArguments().ForwardAs("--include-prerelease")),
     Create.Option("--highest-patch",
                   LocalizableStrings.CmdHighestPatchDescription,
                   Accept.NoArguments().ForwardAs("--highest-patch")),
     Create.Option("--highest-minor",
                   LocalizableStrings.CmdHighestMinorDescription,
                   Accept.NoArguments().ForwardAs("--highest-minor")),
     Create.Option("--config",
                   LocalizableStrings.CmdConfigDescription,
                   Accept.ExactlyOneArgument()
                   .With(name: LocalizableStrings.CmdConfig)
                   .ForwardAsMany(o => new [] { "--config", o.Arguments.Single() })),
     Create.Option("--source",
                   LocalizableStrings.CmdSourceDescription,
                   Accept.OneOrMoreArguments()
                   .With(name: LocalizableStrings.CmdSource)
                   .ForwardAsMany(o => ForwardedArguments("--source", o.Arguments))),
     Create.Option("--interactive",
                   CommonLocalizableStrings.CommandInteractiveOptionDescription,
                   Accept.NoArguments().ForwardAs("--interactive")),
     CommonOptions.VerbosityOption(o => $"--verbosity:{o.Arguments.Single()}"));
Example #16
0
        private void AcceptCallback(IAsyncResult ar)
        {
            Socket accepted;

            try
            {
                accepted = Connection.EndAccept(ar);
                Connections.Add(accepted);
                Connection.BeginAccept(AcceptCallback, null);
                SocketArgs args = new SocketArgs(accepted);
                Accept?.Invoke(this, args);
                accepted.BeginReceive(rcvBuffer, 0, GeneralBufferSize, SocketFlags.None, (ReceiveCallback), accepted);
            }
            catch
            {
                return;
            }
        }
Example #17
0
        /*
         * Function: Bunch
         * Description: Constructor.
         */
        public Bunch(List <Nfa> nfa_start_states)
        {
            int size = nfa_start_states.Count;

            nfa_set = new List <Nfa>(nfa_start_states);
            nfa_bit = new BitSet(size);
            accept  = null;
            anchor  = Spec.NONE;

            /* Initialize bit set. */
            for (int i = 0; i < size; i++)
            {
                int label = ((Nfa)nfa_set[i]).GetLabel();
                nfa_bit.Set(label, true);
            }

            accept_index = Utility.INT_MAX;
        }
Example #18
0
        static void Main(string[] args)
        {
            Accept a = new Accept();

            a.AcceptDetails();

            Print AcceptDetails;

            AcceptDetails = new Print(a.firstname, a.lastname);

            Console.WriteLine(AcceptDetails.Describe());

            MyProfile mp = new MyProfile();

            mp.DisplayMyProfile();

            Console.ReadLine();
        }
 internal static Command Migrate() =>
 Create.Command("migrate",
                "Migrate projects to modern Visual Studio CPS format (non-interactive)",
                ItemsArgument,
                Create.Option("-n|--no-backup",
                              "Skip moving project.json, global.json, and *.xproj to a `Backup` directory after successful migration."),
                ForceOption,
                KeepAssemblyInfoOption,
                TargetFrameworksOption,
                Create.Option("-o|--old-output-path",
                              "Preserve legacy behavior by not creating a subfolder with the target framework in the output path."),
                Create.Option(
                    "-ft|--force-transformations",
                    "Force execution of transformations despite project conversion state by their specified names. " +
                    "Specify multiple times for multiple enforced transformations.",
                    Accept.OneOrMoreArguments()
                    .With("Transformation names to enforce execution", "names")),
                HelpOption());
Example #20
0
 public static Command ToolUpdate()
 {
     return(Create.Command("update",
                           LocalizableStrings.CommandDescription,
                           Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageId)
                           .With(name: LocalizableStrings.PackageIdArgumentName,
                                 description: LocalizableStrings.PackageIdArgumentDescription),
                           Create.Option(
                               "-g|--global",
                               LocalizableStrings.GlobalOptionDescription,
                               Accept.NoArguments()),
                           Create.Option(
                               "--tool-path",
                               LocalizableStrings.ToolPathOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.ToolPathOptionName)),
                           Create.Option(
                               "--configfile",
                               LocalizableStrings.ConfigFileOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.ConfigFileOptionName)),
                           Create.Option(
                               "--add-source",
                               LocalizableStrings.AddSourceOptionDescription,
                               Accept.OneOrMoreArguments()
                               .With(name: LocalizableStrings.AddSourceOptionName)),
                           Create.Option(
                               "--framework",
                               LocalizableStrings.FrameworkOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.FrameworkOptionName)),
                           Create.Option(
                               "--version",
                               LocalizableStrings.VersionOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.VersionOptionName)),
                           ToolCommandRestorePassThroughOptions.DisableParallelOption(),
                           ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption(),
                           ToolCommandRestorePassThroughOptions.NoCacheOption(),
                           ToolCommandRestorePassThroughOptions.InteractiveRestoreOption(),
                           CommonOptions.HelpOption(),
                           CommonOptions.VerbosityOption()));
 }
Example #21
0
 public static Command CreateCommand()
 {
     return(Create.Command(
                "shutdown",
                LocalizableStrings.CommandDescription,
                Create.Option(
                    "--msbuild",
                    LocalizableStrings.MSBuildOptionDescription,
                    Accept.NoArguments()),
                Create.Option(
                    "--vbcscompiler",
                    LocalizableStrings.VBCSCompilerOptionDescription,
                    Accept.NoArguments()),
                Create.Option(
                    "--razor",
                    LocalizableStrings.RazorOptionDescription,
                    Accept.NoArguments()),
                CommonOptions.HelpOption()));
 }
Example #22
0
 public static Command NuGet() =>
 Create.Command(
     "nuget",
     Parser.CompletionOnlyDescription,
     Create.Option("-h|--help", Parser.CompletionOnlyDescription),
     Create.Option("--version", Parser.CompletionOnlyDescription),
     Create.Option("-v|--verbosity", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
     Create.Command(
         "delete",
         Parser.CompletionOnlyDescription,
         Accept.OneOrMoreArguments(),
         Create.Option("-h|--help", Parser.CompletionOnlyDescription),
         Create.Option("--force-english-output", Parser.CompletionOnlyDescription),
         Create.Option("-s|--source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("--non-interactive", Parser.CompletionOnlyDescription),
         Create.Option("-k|--api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("--no-service-endpoint", Parser.CompletionOnlyDescription)),
     Create.Command(
         "locals",
         Parser.CompletionOnlyDescription,
         Accept.AnyOneOf(
             "all",
             "http-cache",
             "global-packages",
             "temp"),
         Create.Option("-h|--help", Parser.CompletionOnlyDescription),
         Create.Option("--force-english-output", Parser.CompletionOnlyDescription),
         Create.Option("-c|--clear", Parser.CompletionOnlyDescription),
         Create.Option("-l|--list", Parser.CompletionOnlyDescription)),
     Create.Command(
         "push",
         Parser.CompletionOnlyDescription,
         Accept.OneOrMoreArguments(),
         Create.Option("-h|--help", Parser.CompletionOnlyDescription),
         Create.Option("--force-english-output", Parser.CompletionOnlyDescription),
         Create.Option("-s|--source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-ss|--symbol-source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-t|--timeout", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-k|--api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-sk|--symbol-api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-d|--disable-buffering", Parser.CompletionOnlyDescription),
         Create.Option("-n|--no-symbols", Parser.CompletionOnlyDescription),
         Create.Option("--no-service-endpoint", Parser.CompletionOnlyDescription)));
Example #23
0
 public override void DispatchMessage(Message result)
 {
     //Console.WriteLine("{0}", result.GetType().Name.ToString());
     if (result.GetType().Name.ToString() == "Proposal")
     {
         Proposal propose = (Proposal)result;
         if (propose.ProposalNumber >= this.ProposalNumber)
         {
             //Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!{0}", this.PreviousAcceptedNumber);
             SendMessage(new Promise
             {
                 Originator             = this,
                 Destination            = propose.Originator,
                 ProposalNumber         = propose.ProposalNumber,
                 PreviousAcceptedNumber = this.PreviousAcceptedNumber,
                 PreviousAcceptedValue  = this.PreviousAcceptedValue
             });
             this.ProposalNumber = propose.ProposalNumber;
         }
         Console.WriteLine("send Promise");
     }
     else if (result.GetType().Name.ToString() == "Accept")
     {
         Accept accept = (Accept)result;
         foreach (var learner in learners)
         {
             SendMessage(new Accepted
             {
                 Originator     = this,
                 Destination    = learner,
                 ProposalNumber = accept.ProposalNumber,
                 AcceptedValue  = accept.ProposalValue
             });
         }
         Console.WriteLine("send Accepted to learners");
         this.PreviousAcceptedNumber = accept.ProposalNumber;
         this.PreviousAcceptedValue  = accept.ProposalValue;
         //ExecuteWork = false;
     }
     //Thread.Sleep(500);
     //waitForMessages.Release(1);
     //Thread.Sleep(10);
 }
Example #24
0
        /// <summary>
        /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TMultiple, bool?, string, string, RequestParameter[])">Create</see>
        /// </summary>
        public virtual MultipleCreateResponse Create(
            TMultiple obj,
            bool?mustUseAdvisory = null,
            string zoneId        = null,
            string contextId     = null,
            params RequestParameter[] requestParameters)
        {
            if (!RegistrationService.Registered)
            {
                throw new InvalidOperationException("Consumer has not registered.");
            }

            var url = new StringBuilder(EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate))
                      .Append($"/{TypeName}s")
                      .Append(HttpUtils.MatrixParameters(zoneId, contextId))
                      .Append(GenerateQueryParameterString(requestParameters))
                      .ToString();
            string requestBody  = SerialiseMultiple(obj);
            string responseBody = HttpUtils.PostRequest(
                url,
                RegistrationService.AuthorisationToken,
                requestBody,
                ConsumerSettings.CompressPayload,
                contentTypeOverride: ContentType.ToDescription(),
                acceptOverride: Accept.ToDescription(),
                mustUseAdvisory: mustUseAdvisory);

            if (log.IsDebugEnabled)
            {
                log.Debug("Response from POST request ...");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug(responseBody);
            }

            createResponseType createResponseType =
                SerialiserFactory.GetSerialiser <createResponseType>(Accept).Deserialise(responseBody);
            MultipleCreateResponse createResponse =
                MapperFactory.CreateInstance <createResponseType, MultipleCreateResponse>(createResponseType);

            return(createResponse);
        }
Example #25
0
        /// <summary>
        /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(uint?, uint?, string, string, RequestParameter[])">Query</see>
        /// </summary>
        public virtual TMultiple Query(
            uint?navigationPage     = null,
            uint?navigationPageSize = null,
            string zoneId           = null,
            string contextId        = null,
            params RequestParameter[] requestParameters)
        {
            if (!RegistrationService.Registered)
            {
                throw new InvalidOperationException("Consumer has not registered.");
            }

            var url = new StringBuilder(EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate))
                      .Append($"/{TypeName}s")
                      .Append(HttpUtils.MatrixParameters(zoneId, contextId))
                      .Append(GenerateQueryParameterString(requestParameters))
                      .ToString();
            string responseBody;

            if (navigationPage.HasValue && navigationPageSize.HasValue)
            {
                responseBody = HttpUtils.GetRequest(
                    url,
                    RegistrationService.AuthorisationToken,
                    ConsumerSettings.CompressPayload,
                    navigationPage: (int)navigationPage,
                    navigationPageSize: (int)navigationPageSize,
                    contentTypeOverride: ContentType.ToDescription(),
                    acceptOverride: Accept.ToDescription());
            }
            else
            {
                responseBody = HttpUtils.GetRequest(
                    url,
                    RegistrationService.AuthorisationToken,
                    ConsumerSettings.CompressPayload,
                    contentTypeOverride: ContentType.ToDescription(),
                    acceptOverride: Accept.ToDescription());
            }

            return(DeserialiseMultiple(responseBody));
        }
 public static Microsoft.DotNet.Cli.CommandLine.Command DotnetDependencyToolInvoker() =>
 Create.Command(
     "dotnet-dependency-tool-invoker",
     "DotNet Dependency Tool Invoker",
     Accept.ExactlyOneArgument()
     .With(name: "COMMAND",
           description: "The command to execute."),
     false,
     Create.Option(
         "-h|--help",
         "Show help information",
         Accept.NoArguments(),
         materialize: o => o.Option.Command().HelpView()),
     Create.Option(
         "-p|--project-path",
         "Path to Project.json that contains the tool dependency",
         Accept.ExactlyOneArgument()
         .With(name: "PROJECT_JSON_PATH",
               defaultValue: () =>
               PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()))),
     Create.Option(
         "-c|--configuration",
         "Configuration under which to build",
         Accept.ExactlyOneArgument()
         .With(name: "CONFIGURATION",
               defaultValue: () => Constants.DefaultConfiguration)),
     Create.Option(
         "-o|--output",
         "Directory in which to find the binaries to be run",
         Accept.ExactlyOneArgument()
         .With(name: "OUTPUT_DIR")),
     Create.Option(
         "-f|--framework",
         "Looks for test binaries for a specific framework",
         Accept.ExactlyOneArgument()
         .With(name: "FRAMEWORK")
         .MaterializeAs(p => NuGetFramework.Parse(p.Arguments.Single()))),
     Create.Option(
         "-r|--runtime",
         "Look for test binaries for a for the specified runtime",
         Accept.ExactlyOneArgument()
         .With(name: "RUNTIME_IDENTIFIER")));
Example #27
0
        /// <summary>
        /// Retrieves a Queue that will be used by the Consumer using the subscription id.
        /// </summary>
        /// <param name="subscriptionId">The subscription's identifier.</param>
        /// <returns>Instance of the Subscription if id is valid and subscription is found, null otherwise.</returns>
        private subscriptionType RetrieveSubscription(string subscriptionId)
        {
            string url          = $"{EnvironmentUtils.ParseServiceUrl(Environment, ServiceType.UTILITY, InfrastructureServiceNames.subscriptions)}/{subscriptionId}";
            string responseBody = HttpUtils.GetRequest(
                url,
                RegistrationService.AuthorisationToken,
                contentTypeOverride: ContentType.ToDescription(),
                acceptOverride: Accept.ToDescription());

            if (log.IsDebugEnabled)
            {
                log.Debug($"Response from GET {url} request ...");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug(responseBody);
            }

            return(DeserialiseSubscription(responseBody));
        }
Example #28
0
 public static Command ToolList()
 {
     return(Create.Command(
                "list",
                LocalizableStrings.CommandDescription,
                Create.Option(
                    "-g|--global",
                    LocalizableStrings.GlobalOptionDescription,
                    Accept.NoArguments()),
                Create.Option(
                    "--local",
                    LocalizableStrings.ToolPathOptionName,
                    Accept.NoArguments()),
                Create.Option(
                    "--tool-path",
                    LocalizableStrings.ToolPathOptionDescription,
                    Accept.ExactlyOneArgument()
                    .With(name: LocalizableStrings.ToolPathOptionName)),
                CommonOptions.HelpOption()));
 }
        // Creates a command setup with the args for "new", plus args for the input template parameters.
        public static Command CreateNewCommandWithArgsForTemplate(string commandName, string templateName,
                                                                  IReadOnlyList <ITemplateParameter> parameterDefinitions,
                                                                  IDictionary <string, string> longNameOverrides,
                                                                  IDictionary <string, string> shortNameOverrides,
                                                                  out IReadOnlyDictionary <string, IReadOnlyList <string> > templateParamMap)
        {
            IList <Option>   paramOptionList       = new List <Option>();
            HashSet <string> initiallyTakenAliases = ArgsForBuiltInCommands;

            Dictionary <string, IReadOnlyList <string> > canonicalToVariantMap = new Dictionary <string, IReadOnlyList <string> >();
            AliasAssignmentCoordinator assignmentCoordinator = new AliasAssignmentCoordinator(parameterDefinitions, longNameOverrides, shortNameOverrides, initiallyTakenAliases);

            if (assignmentCoordinator.InvalidParams.Count > 0)
            {
                string unusableDisplayList = string.Join(", ", assignmentCoordinator.InvalidParams);
                throw new Exception($"Template is malformed. The following parameter names are invalid: {unusableDisplayList}");
            }

            foreach (ITemplateParameter parameter in parameterDefinitions.Where(x => x.Priority != TemplateParameterPriority.Implicit))
            {
                Option         option;
                IList <string> aliasesForParam = new List <string>();

                if (assignmentCoordinator.LongNameAssignments.TryGetValue(parameter.Name, out string longVersion))
                {
                    aliasesForParam.Add(longVersion);
                }

                if (assignmentCoordinator.ShortNameAssignments.TryGetValue(parameter.Name, out string shortVersion))
                {
                    aliasesForParam.Add(shortVersion);
                }

                if (parameter is IAllowDefaultIfOptionWithoutValue parameterWithNoValueDefault &&
                    !string.IsNullOrEmpty(parameterWithNoValueDefault.DefaultIfOptionWithoutValue))
                {
                    // This switch can be provided with or without a value.
                    // If the user doesn't specify a value, it gets the value of DefaultIfOptionWithoutValue
                    option = Create.Option(string.Join("|", aliasesForParam), parameter.Documentation,
                                           Accept.ZeroOrOneArgument());
                }
Example #30
0
 public static Command AddPackage()
 {
     return(Create.Command(
                "package",
                LocalizableStrings.AppFullName,
                Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageReference)
                .WithSuggestionsFrom(QueryNuGet)
                .With(name: LocalizableStrings.CmdPackage,
                      description: LocalizableStrings.CmdPackageDescription),
                CommonOptions.HelpOption(),
                Create.Option("-v|--version",
                              LocalizableStrings.CmdVersionDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdVersion)
                              .ForwardAsSingle(o => $"--version {o.Arguments.Single()}")),
                Create.Option("-f|--framework",
                              LocalizableStrings.CmdFrameworkDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdFramework)
                              .ForwardAsSingle(o => $"--framework {o.Arguments.Single()}")),
                Create.Option("-n|--no-restore",
                              LocalizableStrings.CmdNoRestoreDescription),
                Create.Option("-s|--source",
                              LocalizableStrings.CmdSourceDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdSource)
                              .ForwardAsSingle(o => $"--source {o.Arguments.Single()}")),
                Create.Option("--package-directory",
                              LocalizableStrings.CmdPackageDirectoryDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdPackageDirectory)
                              .ForwardAsSingle(o => $"--package-directory {o.Arguments.Single()}")),
                Create.Option("--interactive",
                              CommonLocalizableStrings.CommandInteractiveOptionDescription,
                              Accept.NoArguments()
                              .ForwardAs("--interactive")),
                Create.Option("--prerelease",
                              CommonLocalizableStrings.CommandPrereleaseOptionDescription,
                              Accept.NoArguments()
                              .ForwardAs("--prerelease"))));
 }
Example #31
0
		public void Should_accept_the_value()
		{
			var acceptor = new Acceptor<string>(_serviceId)
			{
				Bus = _bus,
			};

			InboundMessageHeaders.SetCurrent(x =>
				{
					x.ReceivedOn(_bus);
					x.SetObjectBuilder(_builder);
					x.SetResponseAddress("loopback://localhost/queue");
				});

			Prepare<string> prepare = new Prepare<string>
				{
					BallotId = 1,
					CorrelationId = _serviceId,
					LeaderId = _leaderId,
				};

			acceptor.RaiseEvent(Acceptor<string>.Prepare, prepare);

			acceptor.CurrentState.ShouldEqual(Acceptor<string>.Prepared);

			var accept = new Accept<string>
			{
				BallotId = 1,
				CorrelationId = _serviceId,
				LeaderId = _leaderId,
				Value = "Chris",
			};

			acceptor.RaiseEvent(Acceptor<string>.Accept, accept);

			acceptor.CurrentState.ShouldEqual(Acceptor<string>.SteadyState);
			acceptor.Value.ShouldEqual(accept.Value);
			acceptor.BallotId.ShouldEqual(accept.BallotId);

			_endpoint.VerifyAllExpectations();
		}
Example #32
0
        protected void btnCheckOut_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandArgument == null)
            {
                return;
            }
            ClientCheckoutDao clientCheckoutDao = new ClientCheckoutDao();
            Accept            accept            = clientCheckoutDao.getAcceptById(e.CommandArgument.ToString().Trim());

            if (accept == null)
            {
                return;
            }
            string postData  = "";
            string seperator = "";
            string resQS     = "";
            int    paras     = 7;
            string vpcURL    = "http://onepay.vn/onecomm-pay/Vpcdps.op";


            string[,] MyArray =
            {
                { "vpc_AccessCode",  "GWJBCBJX"    },
                { "vpc_Command",     "queryDR"     },
                { "vpc_MerchTxnRef", accept.GenId  },
                { "vpc_Merchant",    "NGUYENPHONG" },
                { "vpc_Password",    "op123456"    },
                { "vpc_User",        "op01"        },
                { "vpc_Version",     "1"           }
            };
            for (int i = 0; i < paras; i++)
            {
                postData  = postData + seperator + Server.UrlEncode(MyArray[i, 0]) + "=" + Server.UrlEncode(MyArray[i, 1]);
                seperator = "&";
            }

            resQS = doPost(vpcURL, postData);
            Session["isCheckPay"]   = true;
            Session["AcceptSlipNo"] = accept.AcceptSlipNo;
            Response.Redirect("checkpay.aspx?" + Server.UrlDecode(resQS));
        }
Example #33
0
        private async Task HandleAccept(InvocationContext context, Accept accept)
        {
            var dlc = await GetDLC(accept.TemporaryContractId);

            context.AssertState("signed", dlc, true, DLCNextStep.CheckSigs, Network);
            var builder = new DLCTransactionBuilder(dlc.BuilderState !.ToString(), Network);

            try
            {
                builder.Sign1(accept);
                dlc.BuilderState = builder.ExportStateJObject();
                dlc.Accept       = accept;
                await Repository.SaveDLC(dlc);

                context.WritePSBT(builder.GetFundingPSBT());
            }
            catch (Exception ex)
            {
                throw new CommandException("signed", $"Invalid signatures. ({ex.Message})");
            }
        }
Example #34
0
		private static void Usage () {

				Console.WriteLine ("brief");
				Console.WriteLine ("");

				{
#pragma warning disable 219
					Reset		Dummy = new Reset ();
#pragma warning restore 219

					Console.Write ("{0}reset ", UsageFlag);
					Console.WriteLine ();

					Console.WriteLine ("    Delete all test profiles");

				}

				{
#pragma warning disable 219
					Device		Dummy = new Device ();
#pragma warning restore 219

					Console.Write ("{0}device ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.DeviceID.Usage (null, "id", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceDescription.Usage (null, "dd", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Default.Usage ("default", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Create new device profile");

				}

				{
#pragma warning disable 219
					Personal		Dummy = new Personal ();
#pragma warning restore 219

					Console.Write ("{0}personal ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Portal.Usage (null, "portal", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Description.Usage (null, "pd", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Next.Usage ("next", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceNew.Usage ("new", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceUDF.Usage ("dudf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceID.Usage ("did", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceDescription.Usage ("dd", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Create new personal profile");

				}

				{
#pragma warning disable 219
					Register		Dummy = new Register ();
#pragma warning restore 219

					Console.Write ("{0}register ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.UDF.Usage (null, "udf", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage (null, "portal", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Register the specified profile at a new portal");

				}

				{
#pragma warning disable 219
					Sync		Dummy = new Sync ();
#pragma warning restore 219

					Console.Write ("{0}sync ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Synchronize local copies of Mesh profiles with the server");

				}

				{
#pragma warning disable 219
					Escrow		Dummy = new Escrow ();
#pragma warning restore 219

					Console.Write ("{0}escrow ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Quorum.Usage ("quorum", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Shares.Usage ("shares", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Create a set of key escrow shares");

				}

				{
#pragma warning disable 219
					Export		Dummy = new Export ();
#pragma warning restore 219

					Console.Write ("{0}export ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.File.Usage (null, "file", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Export the specified profile data to the specified file");

				}

				{
#pragma warning disable 219
					Import		Dummy = new Import ();
#pragma warning restore 219

					Console.Write ("{0}import ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.File.Usage (null, "file", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Import the specified profile data to the specified file");

				}

				{
#pragma warning disable 219
					List		Dummy = new List ();
#pragma warning restore 219

					Console.Write ("{0}list ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    List all profiles on the local machine");

				}

				{
#pragma warning disable 219
					Dump		Dummy = new Dump ();
#pragma warning restore 219

					Console.Write ("{0}dump ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Describe the specified profile");

				}

				{
#pragma warning disable 219
					Pending		Dummy = new Pending ();
#pragma warning restore 219

					Console.Write ("{0}pending ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Get list of pending connection requests");

				}

				{
#pragma warning disable 219
					Connect		Dummy = new Connect ();
#pragma warning restore 219

					Console.Write ("{0}connect ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Portal.Usage (null, "portal", UsageFlag));
					Console.Write ("[{0}] ", Dummy.PIN.Usage ("pin", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceNew.Usage ("new", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceUDF.Usage ("dudf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceID.Usage ("did", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.DeviceDescription.Usage ("dd", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Connect to an existing profile registered at a portal");

				}

				{
#pragma warning disable 219
					Accept		Dummy = new Accept ();
#pragma warning restore 219

					Console.Write ("{0}accept ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.DeviceUDF.Usage (null, "udf", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Accept a pending connection");

				}

				{
#pragma warning disable 219
					Complete		Dummy = new Complete ();
#pragma warning restore 219

					Console.Write ("{0}complete ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Complete a pending connection request");

				}

				{
#pragma warning disable 219
					Password		Dummy = new Password ();
#pragma warning restore 219

					Console.Write ("{0}password ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Add a web application profile to a personal profile");

				}

				{
#pragma warning disable 219
					AddPassword		Dummy = new AddPassword ();
#pragma warning restore 219

					Console.Write ("{0}pwadd ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Site.Usage (null, "site", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Username.Usage (null, "user", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Password.Usage (null, "password", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Add password entry");

				}

				{
#pragma warning disable 219
					GetPassword		Dummy = new GetPassword ();
#pragma warning restore 219

					Console.Write ("{0}pwget ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Site.Usage (null, "site", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Lookup password entry");

				}

				{
#pragma warning disable 219
					DeletePassword		Dummy = new DeletePassword ();
#pragma warning restore 219

					Console.Write ("{0}pwdelete ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Site.Usage (null, "site", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Delete password entry");

				}

				{
#pragma warning disable 219
					DumpPassword		Dummy = new DumpPassword ();
#pragma warning restore 219

					Console.Write ("{0}pwdump ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.JSON.Usage (null, "json", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Describe password entry");

				}

				{
#pragma warning disable 219
					Mail		Dummy = new Mail ();
#pragma warning restore 219

					Console.Write ("{0}mail ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.address.Usage (null, "address", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Add a mail application profile to a personal profile");

				}

				{
#pragma warning disable 219
					SSH		Dummy = new SSH ();
#pragma warning restore 219

					Console.Write ("{0}ssh ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.Host.Usage (null, "host", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Client.Usage (null, "client", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Add a ssh application profile to a personal profile");

				}

			} // Usage 
Example #35
0
		public virtual void Accept ( Accept Options
				) {

			char UsageFlag = '-';
				{
#pragma warning disable 219
					Accept		Dummy = new Accept ();
#pragma warning restore 219

					Console.Write ("{0}accept ", UsageFlag);
					Console.Write ("[{0}] ", Dummy.DeviceUDF.Usage (null, "udf", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag));
					Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag));
					Console.WriteLine ();

					Console.WriteLine ("    Accept a pending connection");

				}

				Console.WriteLine ("    {0}\t{1} = [{2}]", "String", 
							"DeviceUDF", Options.DeviceUDF);
				Console.WriteLine ("    {0}\t{1} = [{2}]", "Flag", 
							"Verbose", Options.Verbose);
				Console.WriteLine ("    {0}\t{1} = [{2}]", "Flag", 
							"Report", Options.Report);
				Console.WriteLine ("    {0}\t{1} = [{2}]", "String", 
							"Portal", Options.Portal);
				Console.WriteLine ("    {0}\t{1} = [{2}]", "String", 
							"UDF", Options.UDF);
			Console.WriteLine ("Not Yet Implemented");
			}
Example #36
0
		public Nfa()
		{
			this.edge = '�';
			this.cset = null;
			this.next = null;
			this.sibling = null;
			this.accept = null;
			this.anchor = 0;
			this.label = -1;
			this.states = null;
		}
Example #37
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Options">Command line parameters</param>
        public override void Accept(Accept Options) {
            SetReporting(Options.Report, Options.Verbose);
            GetProfile(Options.Portal, Options.UDF);
            GetMeshClient();

            Utils.NYI();
            }
Example #38
0
		public void mimic(Nfa nfa)
		{
			this.edge = nfa.edge;
			if (nfa.cset != null)
			{
				if (this.cset == null)
				{
					this.cset = new CharSet();
				}
				this.cset.mimic(nfa.cset);
			}
			else
			{
				this.cset = null;
			}
			this.next = nfa.next;
			this.sibling = nfa.sibling;
			this.accept = nfa.accept;
			this.anchor = nfa.anchor;
			if (nfa.states != null)
			{
				this.states = new BitSet(nfa.states);
				return;
			}
			this.states = null;
		}
        private IEncoding SelectCompression(IDictionary<string, object> environment)
        {
            var request = new OwinRequest(environment);

            var bestAccept = new Accept { Encoding = "identity", Quality = 0 };
            IEncoding bestEncoding = null;

            string[] acceptEncoding = request.GetHeaderUnmodified("accept-encoding");
            if (acceptEncoding != null)
            {
                foreach (var segment in new HeaderSegmentCollection(acceptEncoding))
                {
                    if (!segment.Data.HasValue)
                    {
                        continue;
                    }
                    Accept accept = Parse(segment.Data.Value);
                    if (accept.Quality == 0 || accept.Quality < bestAccept.Quality)
                    {
                        continue;
                    }
                    IEncoding compression = _options.EncodingProvider.GetCompression(accept.Encoding);
                    if (compression == null)
                    {
                        continue;
                    }
                    bestAccept = accept;
                    bestEncoding = compression;
                    if (accept.Quality == 1000)
                    {
                        break;
                    }
                }
            }
            return bestEncoding;
        }
        private IEncoding SelectCompression(IDictionary<string, object> environment)
        {
            var request = new OwinRequest(environment);

            var bestAccept = new Accept { Encoding = "identity", Quality = 0 };
            IEncoding bestEncoding = null;

            IList<string> acceptEncoding = request.Headers.GetValues("accept-encoding");
            if (acceptEncoding != null)
            {
                foreach (var segment in acceptEncoding)
                {
                    Accept accept = Parse(segment);
                    if (accept.Quality == 0 || accept.Quality < bestAccept.Quality)
                    {
                        continue;
                    }
                    IEncoding compression = _options.EncodingProvider.GetCompression(accept.Encoding);
                    if (compression == null)
                    {
                        continue;
                    }
                    bestAccept = accept;
                    bestEncoding = compression;
                    if (accept.Quality == 1000)
                    {
                        break;
                    }
                }
            }
            return bestEncoding;
        }
Example #41
0
        /// <summary>
        /// This method is called from the client (or from an email link) to accept an offer
        /// </summary>
        /// <param name="id"></param>
        /// <param name="uid"></param>
        /// <returns></returns>
        public ActionResult RejectOffer(string id, long? uid)
        {
            Guid offerGuid;

            if (Guid.TryParse(id, out offerGuid))
            {
                // Select this offer id if not confirmed yet
                Offer offer = this.DB.Offer.Where(o => o.OfferId == offerGuid && null == o.AcceptedById).FirstOrDefault();

                if (null != offer)
                {
                    var fbContext = FacebookWebContext.Current;

                    if (null != uid && fbContext.UserId != uid.Value)
                    {
                        ViewData.Model = "Wrong User Account...";
                        return View("Redirect");
                    }

                    TennisUserModel tennisUser = ModelUtils.GetTennisUsers(this.DB).Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();
                    string message = "Unknown Error";

                    // Check if this was an offer for a specific opponent
                    if (offer.SpecificOpponentId != null)
                    {
                        // Confirm it is the specific opponent who is accepting
                        if (fbContext.UserId == offer.SpecificOpponentId)
                        {
                            offer.AcceptedById = offer.SpecificOpponentId;
                            SendMatchCancellation(offer);

                            this.DB.Offer.DeleteOnSubmit(offer);
                            this.DB.SubmitChanges();
                        }
                        else
                        {
                            // Unexpected since this offer id was meant for a different opponent
                            message = "This offer is not valid. Please submit feedback if you keep getting this message.";
                        }
                    }
                    else
                    {
                        if (!DB.Accept.Any(a => a.FacebookId == fbContext.UserId && a.OfferId == offer.OfferId))
                        {
                            // Create an accept entry and add to the accept table
                            Accept accept = new Accept();
                            accept.FacebookId = fbContext.UserId;
                            accept.OfferId = offer.OfferId;
                            accept.Accepted = false;

                            this.DB.Accept.InsertOnSubmit(accept);
                            this.DB.SubmitChanges();

                            message = "Match requestor notified.  You will be contacted if he/she accepts...";
                        }
                        else
                        {
                            message = "You have accepted this offer already - please wait for confirmation from match requestor. Redirecting you to homepage.";
                        }
                    }

                    // BUGBUG: when will it not be an ajax request?
                    if (!Request.IsAjaxRequest())
                    {
                        ViewData.Model = message;
                        return View("Redirect");
                    }

                    return Json
                    (
                        new
                        {
                            PotentialOffers = RenderPartialViewToString("PotentialOffers", ModelUtils.GetModel<PotentialOffersModel>(FacebookWebContext.Current.UserId, this.DB)),
                            ConfirmedMatches = RenderPartialViewToString("ConfirmedMatches", ModelUtils.GetModel<ConfirmedMatchesModel>(FacebookWebContext.Current.UserId, this.DB))
                        }
                     );
                }
                else
                {
                    // BUGBUG: return message that the offer might have already been taken or might have been revoked
                    ViewData.Model = "Invalid offer - the offer might have been revoked or no longer exists";
                    return View("Redirect");
                }
            }
            else // Unparseable offer id
            {
                if (!Request.IsAjaxRequest())
                {
                    ViewData.Model = "This offer is not valid. Please submit feedback if you keep getting this message.";
                    return View("Redirect");
                }

                return Json("");
            }
        }
Example #42
0
		private static void Handle_Accept (
					Shell Dispatch, string[] args, int index) {
			Accept		Options = new Accept ();

			var Registry = new Goedel.Registry.Registry ();

			Options.DeviceUDF.Register ("udf", Registry, (int) TagType_Accept.DeviceUDF);
			Options.Verbose.Register ("verbose", Registry, (int) TagType_Accept.Verbose);
			Options.Report.Register ("report", Registry, (int) TagType_Accept.Report);
			Options.Portal.Register ("portal", Registry, (int) TagType_Accept.Portal);
			Options.UDF.Register ("udf", Registry, (int) TagType_Accept.UDF);

			// looking for parameter Param.Name}
			if (index < args.Length && !IsFlag (args [index][0] )) {
				// Have got the parameter, call the parameter value method
				Options.DeviceUDF.Parameter (args [index]);
				index++;
				}

#pragma warning disable 162
			for (int i = index; i< args.Length; i++) {
				if 	(!IsFlag (args [i][0] )) {
					throw new System.Exception ("Unexpected parameter: " + args[i]);}			
				string Rest = args [i].Substring (1);

				TagType_Accept TagType = (TagType_Accept) Registry.Find (Rest);

				// here have the cases for what to do with it.

				switch (TagType) {
					case TagType_Accept.Verbose : {
						int OptionParams = Options.Verbose.Tag (Rest);
						
						if (OptionParams>0 && ((i+1) < args.Length)) {
							if 	(!IsFlag (args [i+1][0] )) {
								i++;								
								Options.Verbose.Parameter (args[i]);
								}
							}
						break;
						}
					case TagType_Accept.Report : {
						int OptionParams = Options.Report.Tag (Rest);
						
						if (OptionParams>0 && ((i+1) < args.Length)) {
							if 	(!IsFlag (args [i+1][0] )) {
								i++;								
								Options.Report.Parameter (args[i]);
								}
							}
						break;
						}
					case TagType_Accept.Portal : {
						int OptionParams = Options.Portal.Tag (Rest);
						
						if (OptionParams>0 && ((i+1) < args.Length)) {
							if 	(!IsFlag (args [i+1][0] )) {
								i++;								
								Options.Portal.Parameter (args[i]);
								}
							}
						break;
						}
					case TagType_Accept.UDF : {
						int OptionParams = Options.UDF.Tag (Rest);
						
						if (OptionParams>0 && ((i+1) < args.Length)) {
							if 	(!IsFlag (args [i+1][0] )) {
								i++;								
								Options.UDF.Parameter (args[i]);
								}
							}
						break;
						}
					default : throw new System.Exception ("Internal error");
					}
				}

#pragma warning restore 162
			Dispatch.Accept (Options);

			}
Example #43
0
		private Anchor()
		{
			this.accept = null;
			this.anchor = 0;
		}
Example #44
0
		public void SetAccept(Accept a)
		{
			this.accept = a;
		}