예제 #1
0
        /// <summary>
        /// Returns an instruction according to specified type name
        /// </summary>
        /// <param name="instructionType">Type of instruction to generate</param>
        /// <returns>Corresponding instruction</returns>
        public static PatchInstruction MakeInstruction(string instructionType)
        {
            PatchInstruction resultPI = null;

            if (!string.IsNullOrEmpty(instructionType))
            {
                instructionType = String2.ToPascalCase(instructionType);

                string fullClassName = string.Format(_FORMAT_INSTRUCTION_CLASS, instructionType);

                // To solve culture issues ??
                ObjectHandle dynamicObject = Activator.CreateInstance(null, fullClassName, false, BindingFlags.CreateInstance, null, null, CultureInfo.InvariantCulture, null, null);

                if (dynamicObject != null)
                {
                    resultPI = dynamicObject.Unwrap() as PatchInstruction;

                    if (resultPI != null)
                    {
                        resultPI._Type = (InstructionName)Enum.Parse(typeof(InstructionName), instructionType, true);
                    }
                }
            }

            return(resultPI);
        }
예제 #2
0
        /// <summary>
        /// Returns a variable according to specified name
        /// </summary>
        /// <param name="varName">Name of variable to generate</param>
        /// <returns>Corresponding variable</returns>
        public static PatchVariable MakeVariable(string varName)
        {
            PatchVariable resultV = null;

            if (!string.IsNullOrEmpty(varName))
            {
                varName = String2.ToPascalCase(varName);

                string       fullClassName = string.Format(_FORMAT_VARIABLE_CLASS, varName);
                ObjectHandle dynamicObject = Activator.CreateInstance(null, fullClassName);

                if (dynamicObject != null)
                {
                    resultV = dynamicObject.Unwrap() as PatchVariable;
                }
            }

            return(resultV);
        }
예제 #3
0
        /// <summary>
        /// Returns a parameter according to the specified name
        /// </summary>
        /// <param name="parameterName">Name of parameter to generate</param>
        /// <returns>Corresponding parameter</returns>
        public static PatchInstructionParameter MakeParameter(string parameterName)
        {
            PatchInstructionParameter resultP = null;

            if (!string.IsNullOrEmpty(parameterName))
            {
                parameterName = String2.ToPascalCase(parameterName);

                string fullClassName = string.Format(_FORMAT_PARAMETER_CLASS, parameterName);
                //ObjectHandle dynamicObject = Activator.CreateInstance(null, fullClassName);
                // To solve culture issues ??
                ObjectHandle dynamicObject = Activator.CreateInstance(null, fullClassName, false, BindingFlags.CreateInstance, null, null, CultureInfo.InvariantCulture, null, null);

                if (dynamicObject != null)
                {
                    resultP = dynamicObject.Unwrap() as PatchInstructionParameter;
                }
            }

            return(resultP);
        }