Exemplo n.º 1
0
        /// <summary>
        /// Enclose property setter with an encoder method
        /// </summary>
        public static void AddEncoderMethodToPropertySet(ref string jsCode, string propertyFullName, string encoderMethodName)
        {
            string    encodingMethod = encoderMethodName + _JSMethodStart;
            int       index          = 0;
            TextRange position;

            do
            {
                // Find property position
                position = JSParser.FindPropertySetterRange(ref jsCode, propertyFullName, index);

                // There is no more property
                if (position.Start == -1)
                {
                    break;
                }

                // Next search
                index = position.Start;

                if (position.End > -1)
                {
                    // Set next searching position
                    index = position.End + encodingMethod.Length;

                    // first method ending then method name
                    jsCode = jsCode.Insert(position.End, _JSMethodEnd);
                    jsCode = jsCode.Insert(position.Start, encodingMethod);
                }
            }while (index != -1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Enclose property setter with an encoder method
        /// </summary>
        public static void ReplacePropertySetCommand(ref string jsCode, string propertyFullName, string replacemntCommand)
        {
            int       index = 0;
            TextRange position;

            do
            {
                // Find property position
                position = JSParser.FindPropertySetterRange(ref jsCode, propertyFullName, index);

                // There is no more property
                if (position.Start == -1)
                {
                    break;
                }

                // Next search
                index = position.Start;

                if (position.End > -1)
                {
                    // Set next searching position
                    index = position.Start + replacemntCommand.Length;

                    // remove the original command
                    jsCode = jsCode.Remove(position.Start, position.End - position.Start);

                    // insert the new command
                    jsCode = jsCode.Insert(position.Start, replacemntCommand);
                }
            }while (index != -1);
        }