public override int GetHashCode()
        {
            int hash = 1;

            if (operationCase_ == OperationOneofCase.Insert)
            {
                hash ^= Insert.GetHashCode();
            }
            if (operationCase_ == OperationOneofCase.Update)
            {
                hash ^= Update.GetHashCode();
            }
            if (operationCase_ == OperationOneofCase.InsertOrUpdate)
            {
                hash ^= InsertOrUpdate.GetHashCode();
            }
            if (operationCase_ == OperationOneofCase.Replace)
            {
                hash ^= Replace.GetHashCode();
            }
            if (operationCase_ == OperationOneofCase.Delete)
            {
                hash ^= Delete.GetHashCode();
            }
            hash ^= (int)operationCase_;
            return(hash);
        }
Exemple #2
0
        void ReplaceHandler(Replace replace)
        {
            Tracer.Trace("TrackRoamerBrickProximityBoardService::ReplaceHandler()");

            _state = replace.Body;
            replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
        }
        public void When_Document_Exists_Replace_Succeeds()
        {
            const string key = "Replace.When_Document_Exists_Replace_Succeeds";

            //delete the value if it exists
            var delete = new Delete(key, GetVBucket(), Converter, Serializer);
            var result = IOStrategy.Execute(delete);

            Console.WriteLine(result.Message);

            //add the new doc
            var add     = new Add <dynamic>(key, new { foo = "foo" }, GetVBucket(), Converter, Serializer);
            var result1 = IOStrategy.Execute(add);

            Assert.IsTrue(result1.Success);

            //replace it the old doc with a new one
            var replace = new Replace <dynamic>(key, new { bar = "bar" }, GetVBucket(), Converter, Serializer);
            var result2 = IOStrategy.Execute(replace);

            Assert.IsTrue(result2.Success);

            //check that doc has been updated
            var get     = new Get <dynamic>(key, GetVBucket(), Converter, Serializer);
            var result3 = IOStrategy.Execute(get);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(result3.Value.bar.Value, "bar");
        }
        public void ReplaceShouldReturnAReplacedStringAccordingToParamsWhenStartIxIs3()
        {
            var func   = new Replace();
            var result = func.Execute(FunctionsHelper.CreateArgs("testar", 3, 3, "hej"), _parsingContext);

            Assert.AreEqual("tehejr", result.Result);
        }
Exemple #5
0
 private void ReplaceAll(int startIndex, Replace instruction)
 {
     //index  - lenght
     FixedHex.Replace(startIndex - instruction.BeforeHex.Count, instruction.BeforeHex);
     FixedHex.Replace(startIndex, instruction.InsideHex);
     FixedHex.Replace(startIndex + instruction.InsideHex.Count, instruction.AfterHex);
 }
Exemple #6
0
        private void Update(EvaluationContext context)
        {
            var content = OriginalString.GetValue(context);

            if (string.IsNullOrEmpty(content))
            {
                Result.Value = string.Empty;
                return;
            }


            //const string pattern = @"(-)(\d+)(-)";
            var pattern = SearchPattern.GetValue(context);

            var replace = Replace.GetValue(context).Replace("\\n", "\n");

            try
            {
                Result.Value = Regex.Replace(content, pattern, replace, RegexOptions.Multiline | RegexOptions.Singleline);
            }
            catch (Exception)
            {
                Log.Error($"'{pattern}' is an incorrect search pattern", SymbolChildId);
            }
        }
        public void When_Document_Exists_Replace_Succeeds()
        {
            const string key = "Replace.When_Document_Exists_Replace_Succeeds";

            //delete the value if it exists
            var delete = new Delete(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
            var result = IOService.Execute(delete);
            Console.WriteLine(result.Message);

            //add the new doc
            var add = new Add<dynamic>(key, new { foo = "foo" }, GetVBucket(), Transcoder, OperationLifespanTimeout);
            var result1 = IOService.Execute(add);
            Assert.IsTrue(result1.Success);

            //replace it the old doc with a new one
            var replace = new Replace<dynamic>(key, new { bar = "bar" }, GetVBucket(), Transcoder, OperationLifespanTimeout);
            var result2 = IOService.Execute(replace);
            Assert.IsTrue(result2.Success);

            //check that doc has been updated
            var get = new Get<dynamic>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
            var result3 = IOService.Execute(get);
            Assert.IsTrue(result3.Success);
            Assert.AreEqual(result3.Value.bar.Value, "bar");
        }
Exemple #8
0
 // TODO: Add some overloads to this.
 /// <summary>
 /// Runs the specified find operation.
 /// </summary>
 /// <param name="replace">Specifies how many replacements are to be made: one, all, or none. Can be any Replace constant.</param>
 /// <returns>True if the find operation is successful.</returns>
 public bool Execute(Replace replace)
 {
     return(Convert.ToBoolean(InternalObject.GetType().InvokeMember("Execute", System.Reflection.BindingFlags.InvokeMethod, null, InternalObject,
                                                                    new object[] { replace },
                                                                    null,
                                                                    System.Threading.Thread.CurrentThread.CurrentCulture,
                                                                    new string[] { "Replace" })));
 }
Exemple #9
0
 public IEnumerator <ITask> ReplaceHandler(Replace replace)
 {
     ProcessConfigurationString(ref _state, replace.Body.configuration);
     replace.ResponsePort.Post(new dssp.DefaultReplaceResponseType());
     _subMgrPort.Post(new submgr.Submit(_state, DsspActions.ReplaceRequest));
     _state = replace.Body;
     yield break;
 }
            public static string Replace(string preName, Replace rep)
            {
                var _newName = "";

                _newName = preName.Replace(rep.WordFrom, rep.WordTo);

                return(_newName);
            }
Exemple #11
0
 // TODO: Add some overloads to this.
 /// <summary>
 /// Runs the specified find operation. 
 /// </summary>
 /// <param name="replace">Specifies how many replacements are to be made: one, all, or none. Can be any Replace constant.</param>
 /// <returns>True if the find operation is successful.</returns>
 public bool Execute(Replace replace)
 {
     return Convert.ToBoolean(InternalObject.GetType().InvokeMember("Execute", System.Reflection.BindingFlags.InvokeMethod, null, InternalObject,
         new object[] { replace },
         null,
         System.Threading.Thread.CurrentThread.CurrentCulture,
         new string[] { "Replace" }));
 }
Exemple #12
0
        public IEnumerator <ITask> ReplaceHandler(Replace replace)
        {
            AddCube(new Vector3(0, 3f, 0)); //just for fun, drop more cubes

            _state = replace.Body;
            replace.ResponsePort.Post(new DefaultReplaceResponseType());
            yield break;
        }
 public void Replace_DateTimeNow()
 {
     //unfortunately I cannot get this to work :(
     using (Replace.Property(() => System.DateTime.Now).With(() => FirstJanuaray2000))
     {
         Assert.AreEqual(2000, System.DateTime.Now.Year, "ngened methods dont work yet");
     }
 }
Exemple #14
0
 /* Replaces every occurrence of "fish" with "fowl"
   */
 public static void Main()
 {
     Console.Write
           ("Enter a String which includes \"fish\": ");
     Replace phrase = new Replace(Console.ReadLine());
     String changed = phrase.MyReplace("fish", "fowl");
     Console.WriteLine("The new string is: {0}", changed);
 }
Exemple #15
0
            public void By_Returns_An_Instance_Of_IExceptionHandlerData_Which_Generates_An_Instance_Of_ReplaceHandler()
            {
                var result = Replace.By <Exception>(Message)
                             .GetExceptionHandler();

                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(ReplaceHandler));
            }
Exemple #16
0
        public void ReplaceWithInvalidArgumentReturnsPoundValue()
        {
            var func   = new Replace();
            var args   = FunctionsHelper.CreateArgs();
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Exemple #17
0
        private void changeToolStripMenuItem_Click(object sender, EventArgs e)          //REPLACE
        {
            Replace r = new Replace();

            r.ShowDialog();
            richTextBox1.Find(findText);
            richTextBox1.SelectedText = replaceText;
        }
        public virtual IEnumerator <ITask> ReplaceHandler(Replace replace)
        {
            _state = replace.Body;
            replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);

            SendNotification(_submgr, replace);
            yield break;
        }
Exemple #19
0
    public void Paint(Texture2D newCanvas, P3D_Matrix newMatrix)
    {
        canvas  = newCanvas;
        canvasW = newCanvas.width;
        canvasH = newCanvas.height;
        matrix  = newMatrix;
        if (this.CalculateRect(ref rect))
        {
            inverse     = newMatrix.Inverse;
            opacity     = this.Opacity;
            color       = this.Color;
            direction   = this.Direction;
            shape       = this.Shape;
            detail      = this.Detail;
            detailScale = this.DetailScale;
            if (OnPrePaint != null)
            {
                OnPrePaint(canvas, rect);
            }
            switch (this.Blend)
            {
            case P3D_BlendMode.AlphaBlend:
                AlphaBlend.Paint();
                break;

            case P3D_BlendMode.AlphaBlendRgb:
                AlphaBlendRGB.Paint();
                break;

            case P3D_BlendMode.AlphaErase:
                AlphaErase.Paint();
                break;

            case P3D_BlendMode.AdditiveBlend:
                AdditiveBlend.Paint();
                break;

            case P3D_BlendMode.SubtractiveBlend:
                SubtractiveBlend.Paint();
                break;

            case P3D_BlendMode.NormalBlend:
                NormalBlend.Paint();
                break;

            case P3D_BlendMode.Replace:
                Replace.Paint();
                break;

            default:
                break;
            }
            if (OnPostPaint != null)
            {
                OnPostPaint(canvas, rect);
            }
        }
    }
        public virtual IEnumerator <ccr.ITask> ReplaceHandler(Replace replace)
        {
            _state = replace.Body;

            replace.ResponsePort.Post(dssp.DefaultReplaceResponseType.Instance);
            base.SendNotification <Replace>(_subMgr, replace);

            yield break;
        }
Exemple #21
0
 private void ReplaceIdentifiers(Snippet snippet, Replace identifierReplacement)
 {
     // The identifierReplacement explains what the new identifier will be.
     // The map calls this method to create replacements, but also tracks for collisions or
     // whether or not an identifier should acutlly be replaced
     _map          = new ReplacementMap(_blacklist, identifierReplacement);
     _replacedCode = snippet.RenameIdentifiers(_map.Replace);
     Console.WriteLine(_replacedCode);
 }
Exemple #22
0
        /// <summary>
        /// Replaces a document for a given key if it exists, otherwise fails.
        /// </summary>
        /// <typeparam name="T">The Type of the value to be inserted.</typeparam>
        /// <param name="key">The unique key for indexing.</param>
        /// <param name="value">The value for the key.</param>
        /// <param name="expiration">The time-to-live (ttl) for the key in seconds.</param>
        /// <returns>An object implementing the <see cref="IOperationResult{T}"/>interface.</returns>
        public IOperationResult <T> Replace <T>(string key, T value, uint expiration)
        {
            var operation = new Replace <T>(key, value, null, _converter, _transcoder)
            {
                Expires = expiration
            };

            return(SendWithRetry(operation));
        }
 public void Replace_StaticMethod()
 {
     Assert.AreEqual(2, ClassUnderTest2.StaticMethod2());
     using (Replace.Method(() => ClassUnderTest2.StaticMethod2()).With(() => ClassUnderTest1.StaticMethod1()))
     {
         Assert.AreEqual(1, ClassUnderTest2.StaticMethod2());
     }
     Assert.AreEqual(2, ClassUnderTest2.StaticMethod2());
 }
 public void Replace_StaticProperty()
 {
     Assert.AreEqual(2, ClassUnderTest2.StaticProperty2);
     using (Replace.Property(() => ClassUnderTest2.StaticProperty2).With(() => ClassUnderTest1.StaticProperty1))
     {
         Assert.AreEqual(1, ClassUnderTest2.StaticProperty2);
     }
     Assert.AreEqual(2, ClassUnderTest2.StaticProperty2);
 }
Exemple #25
0
 /// <summary>
 /// Return a mod's current status
 /// This can't be static because the user's installation plans are part of the object.
 /// This function is extremely performance-sensitive because it's the default sort for
 /// the main mod list, so anything in here should be O(1) and fast.
 /// </summary>
 /// <param name="manager">Game instance manager containing the instances</param>
 /// <param name="registry">Registry of instance being displayed</param>
 /// <param name="identifier">The mod</param>
 /// <returns>
 /// Status of mod
 /// </returns>
 public InstallStatus GetModStatus(GameInstanceManager manager, IRegistryQuerier registry, string identifier)
 {
     if (registry.IsInstalled(identifier, false))
     {
         if (Remove.Contains(identifier))
         {
             return(InstallStatus.Removing);
         }
         else if (registry.HasUpdate(identifier, manager.CurrentInstance.VersionCriteria()))
         {
             if (Upgrade.Contains(identifier))
             {
                 return(InstallStatus.Upgrading);
             }
             else
             {
                 return(InstallStatus.Upgradeable);
             }
         }
         else if (registry.IsAutodetected(identifier))
         {
             return(InstallStatus.AutoDetected);
         }
         else if (Replace.Contains(identifier))
         {
             return(InstallStatus.Replacing);
         }
         else if (registry.GetReplacement(identifier, manager.CurrentInstance.VersionCriteria()) != null)
         {
             return(InstallStatus.Replaceable);
         }
         else if (!IsAnyAvailable(registry, identifier))
         {
             return(InstallStatus.Unavailable);
         }
         else if (registry.InstalledModule(identifier)?.AutoInstalled ?? false)
         {
             return(InstallStatus.AutoInstalled);
         }
         else
         {
             return(InstallStatus.Installed);
         }
     }
     else
     {
         foreach (CkanModule m in Install)
         {
             if (m.identifier == identifier)
             {
                 return(InstallStatus.Installing);
             }
         }
         return(InstallStatus.NotInstalled);
     }
 }
        public IEnumerator <ITask> UpsertGrammarEntryHandler(UpsertGrammarEntry upsert)
        {
            if (this.state.GrammarType != GrammarType.DictionaryStyle)
            {
                // Since we are switching grammar mode make sure there exists a valid,
                // empty dictionary
                if (this.state.DictionaryGrammar == null)
                {
                    this.state.DictionaryGrammar = new Dictionary <string, string>();
                }
                else
                {
                    this.state.DictionaryGrammar.Clear();
                }
            }

            #region Set up load grammar request and load grammar
            // Set up load grammar request
            LoadGrammarRequest loadRequest = new LoadGrammarRequest();
            loadRequest.GrammarType       = GrammarType.DictionaryStyle;
            loadRequest.DictionaryGrammar = new Dictionary <string, string>(state.DictionaryGrammar);
            GrammarUtilities.UpsertDictionary(loadRequest.DictionaryGrammar, upsert.Body.DictionaryGrammar);

            // Load new grammar
            SuccessFailurePort loadGrammarPort = new SuccessFailurePort();
            SpawnIterator <LoadGrammarRequest, SuccessFailurePort>(
                loadRequest,
                loadGrammarPort,
                LoadGrammar
                );

            // Check loading outcome
            yield return((Choice)loadGrammarPort);

            Exception exception = (Exception)loadGrammarPort;
            if (exception != null)
            {
                LogWarning(exception);
                upsert.ResponsePort.Post(Fault.FromCodeSubcodeReason(
                                             FaultCodes.Receiver,
                                             DsspFaultCodes.OperationFailed,
                                             exception.Message
                                             ));
                yield break;
            }
            #endregion

            SaveState(this.state);

            // Notify subscribers of state change
            Replace replace = new Replace();
            replace.Body = this.state;
            SendNotification <Replace>(this.subMgrPort, replace);

            upsert.ResponsePort.Post(DefaultUpsertResponseType.Instance);
        }
        public IEnumerator <ITask> DeleteGrammarEntryHandler(DeleteGrammarEntry delete)
        {
            // Make sure current grammar type is dictionary-style
            if (this.state.GrammarType != GrammarType.DictionaryStyle)
            {
                Fault fault = Fault.FromCodeSubcodeReason(
                    FaultCodes.Receiver,
                    DsspFaultCodes.OperationFailed,
                    "Cannot delete entries from grammar dictionary because grammar"
                    + "currently in use is not DictionaryStyle."
                    );
                LogInfo(fault.ToException());
                delete.ResponsePort.Post(fault);
                yield break;
            }

            #region Set up load grammar request and load grammar
            // Set up load grammar request
            LoadGrammarRequest loadRequest = new LoadGrammarRequest();
            loadRequest.GrammarType       = GrammarType.DictionaryStyle;
            loadRequest.DictionaryGrammar = new Dictionary <string, string>(state.DictionaryGrammar);
            GrammarUtilities.DeleteDictionary(loadRequest.DictionaryGrammar, delete.Body.DictionaryGrammar);

            // Load new grammar
            SuccessFailurePort loadGrammarPort = new SuccessFailurePort();
            SpawnIterator <LoadGrammarRequest, SuccessFailurePort>(
                loadRequest,
                loadGrammarPort,
                LoadGrammar
                );

            // Check loading outcome
            yield return((Choice)loadGrammarPort);

            Exception exception = (Exception)loadGrammarPort;
            if (exception != null)
            {
                LogWarning(exception);
                delete.ResponsePort.Post(Fault.FromCodeSubcodeReason(
                                             FaultCodes.Receiver,
                                             DsspFaultCodes.OperationFailed,
                                             exception.Message
                                             ));
                yield break;
            }
            #endregion

            SaveState(this.state);

            // Notify subscribers of state change
            Replace replace = new Replace();
            replace.Body = this.state;
            SendNotification <Replace>(this.subMgrPort, replace);

            delete.ResponsePort.Post(DefaultDeleteResponseType.Instance);
        }
Exemple #28
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Replace=" + Replace.ToString());
            sb.AppendLine("ReplacementType=" + ReplacementType.ToString());
            sb.AppendLine("Search=" + Search.ToString());

            return(sb.ToString());
        }
Exemple #29
0
        /// <summary>
        /// Compute the inverse of a patch
        /// </summary>
        public static Patch <EqA, A> inverse <EqA, A>(Patch <EqA, A> patch) where EqA : struct, Eq <A>
        {
            (int, Edit <EqA, A>) go(int off, Edit <EqA, A> edit) =>
            edit is Edit <EqA, A> .Insert ins ? (off + 1, Edit <EqA, A> .Delete.New(off + ins.Position, ins.Element) as Edit <EqA, A>)
              : edit is Edit <EqA, A> .Delete del ? (off - 1, Edit <EqA, A> .Insert.New(off + del.Position, del.Element) as Edit <EqA, A>)
              : edit is Edit <EqA, A> .Replace rpl ? (off, Edit <EqA, A> .Replace.New(off + rpl.Position, rpl.ReplaceElement, rpl.Element) as Edit <EqA, A>)
              : throw new NotSupportedException();

            return(new Patch <EqA, A>(PatchInternal.mapAccumL(go, 0, patch.Edits).Item2));
        }
Exemple #30
0
        /// <summary>
        /// Detects backtracking patterns and return a list of detected instances.
        /// </summary>
        /// <param name="logProvider">The log provider.</param>
        /// <returns>
        /// Detected instances of BacktrackingPatternInstance.
        /// </returns>
        public override IEnumerable <PatternInstance> DetectAsPatternInstances(ILogProvider logProvider)
        {
            List <Event> completeList = logProvider.LoggedEvents.ToList();
            List <Event> dcList       = logProvider.LoggedEvents.Where(x => x is DocumentChange || x is FileOpenCommand).ToList();

            this.Patterns = new List <BacktrackingPatternInstance>();

            // Initialize
            this.CurrentFile    = null;
            this.Snapshots      = new Dictionary <string, string>();
            this.InsertSegments = new Dictionary <string, List <InsertSegment> >();
            this.DeleteSegments = new List <DeleteSegment>();

            foreach (int i in Enumerable.Range(0, dcList.Count))
            {
                if (dcList[i] is FileOpenCommand)
                {
                    this.ProcessFileOpenCommand(dcList, i, logProvider);
                }
                else if (dcList[i] is Insert)
                {
                    Insert insert = (Insert)dcList[i];
                    this.ProcessInsert(insert, insert.Offset, insert.Text, logProvider);
                }
                else if (dcList[i] is Delete)
                {
                    Delete delete = (Delete)dcList[i];
                    this.ProcessDelete(delete, delete.Offset, delete.Length, logProvider);
                }
                else if (dcList[i] is Replace)
                {
                    // Process as if this was a two separate Delete / Insert commands.
                    Replace replace = (Replace)dcList[i];
                    if (replace.InsertedText.StartsWith(replace.DeletedText))
                    {
                        if (replace.InsertedText.Length > replace.DeletedText.Length)
                        {
                            this.ProcessInsert(replace, replace.Offset + replace.Length, replace.InsertedText.Substring(replace.Length), logProvider);
                        }
                    }
                    else
                    {
                        this.ProcessDelete(replace, replace.Offset, replace.Length, logProvider);
                        this.ProcessInsert(replace, replace.Offset, replace.InsertedText, logProvider);
                    }
                }
                else if (dcList[i] is Move)
                {
                    // Process the snapshot, but don't count this as backtracking...? How??
                    Move move = (Move)dcList[i];
                }
            }

            return(this.Patterns);
        }
Exemple #31
0
        public async Task <RepositoryResult <ControllerResult> > Replace(Replace model)
        {
            User user = this.context.GetAll <User>().FirstOrDefault(u => u.ReplaceCode == model.ReplaceCode);

            RepositoryResult <ControllerResult> result = new RepositoryResult <ControllerResult>();

            if (user == null || user.ReplaceCode == Guid.Empty)
            {
                logger.WriteError(string.Format("Пользователь с кодом подтверждения {0} не найден.", model.ReplaceCode));

                result.ResultType = RepositoryResultType.Bad;
                result.Responce   = new ControllerResult()
                {
                    IsSucces = false,
                    Message  = "Код не найден, проверьте правильность введённого кода. Если всё правильно попробуйте повторить операцию. Если ошибка не исчезает обратитесь в техническую поддержку."
                };
            }
            else
            {
                Salt salt = user.Salt;

                this.context.Delete(salt);

                user.Salt         = new Salt();
                user.PasswordHash = User.HashPassword(model.Password, user.Salt);
                user.ReplaceCode  = Guid.Empty;

                int changes = await this.context.SaveChangesAsync();

                if (changes == 0)
                {
                    logger.WriteError("Данные не были сохранены.");

                    result.ResultType = RepositoryResultType.Bad;
                    result.Responce   = new ControllerResult()
                    {
                        IsSucces = false,
                        Message  = "Ошибка на серевере. Сервер временно недоступен, приносим свои извинения."
                    };
                }
                else
                {
                    logger.WriteInformation("Пароль успешно изменён.");

                    result.ResultType = RepositoryResultType.OK;
                    result.Responce   = new ControllerResult()
                    {
                        IsSucces = true,
                        Message  = "Пароль успешно сменён, пожалуйста войдите в систему."
                    };
                }
            }

            return(result);
        }
        public void Replace_InstanceProperty()
        {
            var tc = new ClassUnderTest2();

            Assert.AreEqual(2, tc.Property2);
            using (Replace.Property <ClassUnderTest2>(c => c.Property2).With <ClassUnderTest1>(c => c.Property1))
            {
                Assert.AreEqual(1, tc.Property2);
            }
            Assert.AreEqual(2, tc.Property2);
        }
        public void Replace_PrivateInstanceMethod()
        {
            var tc = new ClassUnderTest2();

            Assert.AreEqual(2, tc.CallPrivateMethod2());
            using (Replace.Method <ClassUnderTest2>("PrivateMethod2").With <ClassUnderTest1>("PrivateMethod1"))
            {
                Assert.AreEqual(1, tc.CallPrivateMethod2());
            }
            Assert.AreEqual(2, tc.CallPrivateMethod2());
        }
Exemple #34
0
        private string ReplaceCharFromStringWithString(Replace replace)
        {
            int length = replace.FromString.Length;
            if (length == 0) return "";

            string lastCharToCheckFrom = GetComparisonBetweenCharAndString(replace);

            string newFromString = "";
            for (var i = 0; i < length - 1; i++) newFromString += replace.FromString[i];
            replace.FromString = newFromString;

            return (length == 1 ? "" : ReplaceCharFromStringWithString(replace)) + lastCharToCheckFrom;
        }
 public void Test_Clone()
 {
     var operation = new Replace<string>("key", "somevalue", GetVBucket(), Transcoder, OperationLifespanTimeout)
     {
         Cas = 1123
     };
     var cloned = operation.Clone();
     Assert.AreEqual(operation.CreationTime, cloned.CreationTime);
     Assert.AreEqual(operation.Cas, cloned.Cas);
     Assert.AreEqual(operation.VBucket.Index, cloned.VBucket.Index);
     Assert.AreEqual(operation.Key, cloned.Key);
     Assert.AreEqual(operation.Opaque, cloned.Opaque);
     Assert.AreEqual(operation.RawValue, ((OperationBase<string>)cloned).RawValue);
 }
        public void When_Document_Does_Not_Exist_Replace_Fails()
        {
            const string key = "Replace.When_Document_Does_Not_Exist_Replace_Fails";

            //delete the value if it exists
            var delete = new Delete(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
            var result = IOService.Execute(delete);
            Console.WriteLine(result.Message);

            //replace it the old doc with a new one
            var replace = new Replace<dynamic>(key, new { bar = "bar" }, GetVBucket(), Transcoder, OperationLifespanTimeout);
            var result2 = IOService.Execute(replace);
            Assert.IsFalse(result2.Success);
            Assert.AreEqual(ResponseStatus.KeyNotFound, result2.Status);
        }
Exemple #37
0
 public static void Main()
 {
     String s = "hat";
     Console.WriteLine(s[2]);
     String t = String.Copy(s);
     double d = 3.14159265;
     String w = String.Format("The price is {0:C}", d);
     Console.WriteLine(w);
     Console.WriteLine(t);
     Replace r1 = new Replace("house");
     Replace r2 = new Replace("house");
     Console.WriteLine(r1 == r2);
     Color c = Color.Red;
     Console.WriteLine(c == Color.Green);
 }
Exemple #38
0
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            if (_state == null)
            {
                _state = new GameControllerState();
            }
            base.Start();

            // post a replace message to ourself, this causes the correct initialization
            Replace replace = new Replace(_state);
            _mainPort.Post(replace);

            // start the timer
            Spawn(DateTime.Now, TimerHandler);
        }
Exemple #39
0
 public void TestReplaceSingleChar()
 {
     string comparer = "acces";
     Replace replace = new Replace('c', "aces", "cc");
     Assert.AreEqual(comparer, ReplaceCharFromStringWithString(replace));
 }
Exemple #40
0
    //全ノードがくるっと回転して状態遷移するやつ 再配置関数を引数に
    public IEnumerator ReplaceRotate(Replace repMethod)
    {
        //Log.Debug("ReplaceRotate : " + repMethod);
        isSlide = true;     //この回転中に操作できないように
        //全ノードを90°回転tween
        RotateAllNode(90.0f, Ease.InSine);
        yield return new WaitForSeconds(repRotateTime / 2.0f);
        //全ノードを-180°回転
        foreach (var xList in gameNodeScripts)
        {
            foreach (var it in xList)
            {
                it.transform.Rotate(0, -180, 0);
            }
        }

        //置き換え処理
        repMethod();

        //若干遅らせることで再生成時に完成した枝ができてた時の処理を先にさせる
        yield return new WaitForSeconds(0.01f);

        ForceRotateZ();

        //全ノードを90°回転
        RotateAllNode(0.0f, Ease.OutSine);
        yield return new WaitForSeconds(repRotateTime / 2.0f);
        isSlide = false;    //終わったら操作できるように
        CheckLink();
    }
		public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
		{
            LogInfo("TrackRoamerBrickPowerService:ReplaceHandler()");

			Close();
			
            _state = replace.Body;
			_state.Connected = false;
			_state.Connected = ReConnect();
            _state.TimeStamp = DateTime.Now;
            
            replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
			yield break;
		}
        void ReplaceHandler(Replace replace)
        {
            Tracer.Trace("TrackRoamerBrickProximityBoardService::ReplaceHandler()");

            _state = replace.Body;
            replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
        }
 public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
 {
     throw (new Exception("Replace is used for notifications only"));
 }
 public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
 {
     _state = replace.Body;
     replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
     yield break;
 }
Exemple #45
0
        public void ReplaceContentClass(IContentClass replacement, IDictionary<string, string> oldToNewMapping, Replace replace)
        {
            const string REPLACE_CC =
                @"<PAGE action=""changetemplate"" guid=""{0}"" changeall=""{1}"" holdreferences=""1"" holdexportsettings=""1"" holdauthorizations=""1"" holdworkflow=""1""><TEMPLATE originalguid=""{2}"" changeguid=""{3}"">{4}</TEMPLATE></PAGE>";

            const string REPLACE_ELEMENT = @"<ELEMENT originalguid=""{0}"" changeguid=""{1}""/>";
            var oldElements = ContentClass.Elements;
            var newElements = replacement.Elements;

            var unmappedElements = oldElements.Where(element => !oldToNewMapping.ContainsKey(element.Name));
            var unmappedStr = unmappedElements.Aggregate(
                                                         "",
                                                         (s, element) => s + REPLACE_ELEMENT.RQLFormat(element, RQL.SESSIONKEY_PLACEHOLDER));
            var mappedStr = string.Join(
                                        "",
                                        from entry in oldToNewMapping
                                        let oldElement = oldElements[entry.Key]
                                        let newElement = newElements.GetByName(entry.Value)
                                        select REPLACE_ELEMENT.RQLFormat(oldElement, newElement));

            var isReplacingAll = replace == Replace.ForAllPagesOfContentClass;
            var query = REPLACE_CC.RQLFormat(this, isReplacingAll, ContentClass, replacement, mappedStr + unmappedStr);

            Project.ExecuteRQL(query, RqlType.SessionKeyInProject);

            _contentClass = null;
            _ccGuid = default(Guid);
        }
 public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
 {
     // "Native" sensor does not support Replace
     throw (new Exception("Replace is used for notifications only"));
 }
Exemple #47
0
 public void TestReplaceFail()
 {
     string comparer = "abc";
     Replace replace = new Replace('d', "adc", "x");
     Assert.AreEqual(comparer, ReplaceCharFromStringWithString(replace));
 }
Exemple #48
0
 public void TestReplaceMultipleChars()
 {
     string comparer = "The quick br123wn f123x jumps 123ver the lazy d123g";
     Replace replace = new Replace('o', "The quick brown fox jumps over the lazy dog", "123");
     Assert.AreEqual(comparer, ReplaceCharFromStringWithString(replace));
 }
Exemple #49
0
        public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
        {
            _state.Controller.Dispose();

            _state = replace.Body;

            _state.Controller.FindInstance();

            replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
            yield break;
        }
Exemple #50
0
        public IEnumerator<ITask> ReplaceHandler(Replace replace)
        {
            AddCube(new Vector3(0, 3f, 0)); //just for fun, drop more cubes

            _state = replace.Body;
            replace.ResponsePort.Post(new DefaultReplaceResponseType());
            yield break;
        }
Exemple #51
0
        public virtual IEnumerator<ITask> GetHandler(Get get)
        {
            Replace replace = new Replace();
            replace.Body = _state;
            replace.Body.Cubes++;
            _mainPort.Post(replace);

            get.ResponsePort.Post(_state);
            yield break;
        }
Exemple #52
0
 private string GetComparisonBetweenCharAndString(Replace replace)
 {
     char lastChar = replace.FromString[replace.FromString.Length - 1];
     return lastChar == replace.CharToReplace ? replace.WithString : lastChar.ToString();
 }
Exemple #53
0
        void ReplaceHandler(Replace replace)
        {
            Tracer.Trace("SickLRF::ReplaceHandler()");

            _state = replace.Body;
            replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
        }
Exemple #54
0
 public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
 {
     //if (_state.ComPort != replace.Body.ComPort)
     //{
     //    _state = replace.Body;
     //    var ePort = new Port<Exception>();
     //    Dispatcher.AddCausality(new Causality("connect to scribbler", ePort));
     //    Activate(ePort.Receive(delegate(Exception e) { replace.ResponsePort.Post(RSUtils.FaultOfException(e)); }));
     //    yield return new IterativeTask(ConnectToScribbler);
     //    replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
     //}
     //else
     //{
     _state = replace.Body;
     replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
     //}
     yield break;
 }