Exemplo n.º 1
0
 public string Read(CookieType CookieName)
 {
     return(cookie.Read(CookieName.ToString()));
 }
Exemplo n.º 2
0
 public void Delete(CookieType CookieName)
 {
     cookie.Delete(CookieName.ToString());
 }
Exemplo n.º 3
0
 public void Write(CookieType CookieName, object Value)
 {
     cookie.Write(CookieName.ToString(), (int)CookieName, Value.ToString());
 }
Exemplo n.º 4
0
 public static void SaveCookie(this HttpContext httpContext, CookieType cookieType, string data, int hours = 24) =>
 httpContext.Response.Cookies.Append(cookieType.ToString().ToLower(), data, CreateCookieOptions(hours));
Exemplo n.º 5
0
 public static string GetCookie(this HttpContext httpContext, CookieType cookieType) =>
 httpContext.Request.Cookies[cookieType.ToString().ToLower()];
        /// <summary>
        /// The process record.
        /// </summary>
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            try
            {
                Status status = null;
                if (ParameterSetName.Equals("HttpCookie"))
                {
                    status =
                        Connection.ApiClient.CreatePersistenceProfileHttpCookie(Network.id, Name, ServerFarm.id,
                                                                                TimeoutMinutes, CookieName, CookieType).Result;
                }
                else
                {
                    status =
                        Connection.ApiClient.CreatePersistenceProfileIpNetmask(Network.id, Name, ServerFarm.id, TimeoutMinutes,
                                                                               Direction, Netmask).Result;
                }
                if (status != null && PassThru.IsPresent)
                {
                    // Regex to extract the Id from the status result detail: Real-Server (id:b1a3aea6-37) created
                    var   regexObj = new Regex(@"\x28id\x3A([-\w]*)\x29");
                    Match match    = regexObj.Match(status.resultDetail);
                    if (match.Success && match.Groups.Count > 1)
                    {
                        var persprofile = new PersistenceProfile
                        {
                            id           = match.Groups[1].Value,
                            name         = Name,
                            serverFarmId = ServerFarm.id,
                            timeout      = TimeoutMinutes.ToString(CultureInfo.InvariantCulture),
                        };
                        if (ParameterSetName.Equals("HttpCookie"))
                        {
                            persprofile.type       = PersistenceProfileType.HTTP_COOKIE;
                            persprofile.cookieName = CookieName;
                            persprofile.cookieType = CookieType.ToString();
                        }
                        else
                        {
                            persprofile.type      = PersistenceProfileType.IP_NETMASK;
                            persprofile.netmask   = Netmask;
                            persprofile.direction = Direction.ToString();
                        }

                        WriteObject(persprofile);
                    }
                    else
                    {
                        WriteError(new ErrorRecord(new CloudComputePsException("object Id not returned from API"), "-1",
                                                   ErrorCategory.InvalidData, status));
                    }
                }

                WriteDebug(
                    string.Format(
                        "{0} resulted in {1} ({2}): {3}",
                        status.operation,
                        status.result,
                        status.resultCode,
                        status.resultDetail));
            }
            catch (AggregateException ae)
            {
                ae.Handle(
                    e =>
                {
                    if (e is ComputeApiException)
                    {
                        WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection));
                    }
                    else
                    {
// if (e is HttpRequestException)
                        ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection));
                    }

                    return(true);
                });
            }
        }
Exemplo n.º 7
0
    void Update()
    {
        SearchEnemy();
        AtackFlag();

        switch (movepattern)
        {
        case MovePattern._Wait:
            if (wait)
            {
                Invoke("Wait", time);
                break;
            }
            break;

        case MovePattern._Search:
            wait = true;
            if (GameObject.FindGameObjectWithTag(cookieType.ToString()))
            {
                atackarea            = false;
                movepattern          = MovePattern._Stalking;
                NMA.stoppingDistance = 0f;
                NMA.autoBraking      = false;
                break;
            }

            /*else if (GameObject.FindGameObjectWithTag("Prediction"))
             * {
             *  atackarea = false;
             *  movepattern = MovePattern._Stalking;
             *  NMA.stoppingDistance = 2f;
             *  NMA.autoBraking = false;
             *  break;
             * }*/
            Search();
            break;


        case MovePattern._Stalking:
            if (atackarea && vision)
            {
                movepattern   = MovePattern._Atack;
                NMA.isStopped = true;
                break;
            }
            if (!GameObject.FindGameObjectWithTag((cookieType.ToString())))
            {
                movepattern = MovePattern._Wait;
                break;
            }
            Stalking();
            break;


        case MovePattern._Atack:
            if (!GameObject.FindGameObjectWithTag((cookieType.ToString())))
            {
                movepattern = MovePattern._Wait;
                break;
            }
            else if (!atackarea && !vision)
            {
                movepattern = MovePattern._Stalking;
            }
            Atack();
            break;


        case MovePattern._Death:
            Death();
            break;
        }
    }