示例#1
0
 public override sealed MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
 {
     if (!((bindingAttr & ~SupportedBindingFlags) == 0) && modifiers == null && culture == null && names == null)
         throw new NotImplementedException();
     state = null;
     return LimitedBinder.BindToMethod(match, ref args);
 }
 private RuntimeFatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, ReflectionDomain reflectionDomain, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
     : base(member, position, reflectionDomain, reader, typeHandle, typeContext)
 {
     _methodHandle = methodHandle;
     _parameterHandle = parameterHandle;
     _parameter = parameterHandle.GetParameter(reader);
 }
示例#3
0
        public override sealed MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
        {
            if (!((bindingAttr & ~SupportedBindingFlags) == 0) && modifiers == null)
                throw new NotImplementedException();

            return LimitedBinder.SelectMethod(match, types);
        }
示例#4
0
        public override MethodBase BindToMethod(
            BindingFlags bindingAttr,
            MethodBase[] match,
            ref object[] args,
            ParameterModifier[] modifiers,
            CultureInfo culture,
            string[] names,
            out object state)
        {
            if (match == null)
            {
                throw new ArgumentNullException("match");
            }
            // Arguments are not being reordered.
            state = null;
            // Find a parameter match and return the first method with
            // parameters that match the request.
            foreach (MethodBase mb in match)
            {
                ParameterInfo[] parameters = mb.GetParameters();

                if (ParametersMatch(parameters, args))
                {
                    return mb;
                }
            }
            return null;
        }
    public object Intercept(MethodBase decoratedMethod, MethodBase implementationMethod, object[] arguments)
    {
        if (this.implementationMethodTarget == null)
        {
            throw new InvalidOperationException("Something has gone seriously wrong with StaticProxy.Fody." +
                ".Initialize(implementationMethodTarget) must be called once before any .Intercept(..)");
        }

        // since we only support methods, not constructors, this is actually a MethodInfo
        var decoratedMethodInfo = (MethodInfo)decoratedMethod;
        
        ITargetInvocation targetInvocation = this.targetInvocationFactory.Create(this.implementationMethodTarget, implementationMethod);
        
        IInvocation invocation = this.invocationFactory
            .Create(targetInvocation, decoratedMethodInfo, arguments, this.interceptors.ToArray());

        invocation.Proceed();

        if (invocation.ReturnValue == null && !this.typeInformation.IsNullable(decoratedMethodInfo.ReturnType))
        {
            string message = string.Format(
                CultureInfo.InvariantCulture,
                "Method {0}.{1} has return type {2} which is a value type. After the invocation the invocation the return value was null. Please ensure that your interceptors call IInvocation.Proceed() or sets a valid IInvocation.ReturnValue.",
                this.implementationMethodTarget.GetType().FullName,
                decoratedMethodInfo,
                decoratedMethodInfo.ReturnType.FullName);
            throw new InvalidOperationException(message);
        }

        return invocation.ReturnValue;
    }
        public static String ComputeToString(MethodBase contextMethod, RuntimeType[] methodTypeArguments, RuntimeParameterInfo[] runtimeParametersAndReturn)
        {
            StringBuilder sb = new StringBuilder(30);
            sb.Append(runtimeParametersAndReturn[0].ParameterTypeString);
            sb.Append(' ');
            sb.Append(contextMethod.Name);
            if (methodTypeArguments.Length != 0)
            {
                String sep = "";
                sb.Append('[');
                foreach (RuntimeType methodTypeArgument in methodTypeArguments)
                {
                    sb.Append(sep);
                    sep = ",";
                    String name = methodTypeArgument.InternalNameIfAvailable;
                    if (name == null)
                        name = ToStringUtils.UnavailableType;
                    sb.Append(methodTypeArgument.Name);
                }
                sb.Append(']');
            }
            sb.Append('(');
            sb.Append(ComputeParametersString(runtimeParametersAndReturn, 1));
            sb.Append(')');

            return sb.ToString();
        }
 protected RuntimeMethodParameterInfo(MethodBase member, int position, ReflectionDomain reflectionDomain, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
     : base(member, position)
 {
     _reflectionDomain = reflectionDomain;
     Reader = reader;
     _typeHandle = typeHandle;
     _typeContext = typeContext;
 }
 public override void Init(object instance, MethodBase method, object[] args)
 {
     _instance = instance;
     _method = method;
     _args = args;
     if (method.Name == "ApiHandler") _logoType = "接口通道ApiHandler";
     else if (method.Name == "InfoApiHandler") _logoType = "接口通道InfoApiHandler";
     else if (method.Name == "StreamApiHandler") _logoType = "接口通道StreamApiHandler";
 }
示例#9
0
 // returns array of the types of the parameters of the method specified by methodinfo
 public static Type[] GetParameterTypes( MethodBase methodbase )
 {
     ParameterInfo[] parameterinfos = methodbase.GetParameters();
     Type[] paramtypes = new Type[ parameterinfos.GetUpperBound(0) + 1 ];
     for( int i = 0; i < parameterinfos.GetUpperBound(0) + 1; i ++ )
     {
         paramtypes[i] = parameterinfos[i].ParameterType;
     }
     return paramtypes;
 }
示例#10
0
		public static void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi)
		{
			var declaringType = mi.DeclaringType;
			if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition)
				declaringType = declaringType.GetGenericTypeDefinition ();

			// Get generic definition
			var bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			foreach (var m in declaringType.GetMethods (bindingflags)) {
				if (m.MetadataToken == mi.MetadataToken) {
					mi = m;
					break;
				}
			}

			sb.Append (declaringType.ToString ());

			sb.Append (".");
			sb.Append (mi.Name);

			if (mi.IsGenericMethod) {
				Type[] gen_params = mi.GetGenericArguments ();
				sb.Append ("[");
				for (int j = 0; j < gen_params.Length; j++) {
					if (j > 0)
						sb.Append (",");
					sb.Append (gen_params [j].Name);
				}
				sb.Append ("]");
			}

			ParameterInfo[] p = mi.GetParameters ();

			sb.Append (" (");
			for (int i = 0; i < p.Length; ++i) {
				if (i > 0)
					sb.Append (", ");

				Type pt = p[i].ParameterType;
				if (pt.IsGenericType && ! pt.IsGenericTypeDefinition)
					pt = pt.GetGenericTypeDefinition ();

				sb.Append (pt.ToString());

				if (p [i].Name != null) {
					sb.Append (" ");
					sb.Append (p [i].Name);
				}
			}
			sb.Append (")");
		}
	// Constructor.
	internal ParameterBuilder(TypeBuilder type, MethodBase method,
							  int position, ParameterAttributes attributes,
							  String strParamName)
			{
				// Initialize the internal state.
				this.type = type;
				this.method = method;

				// Register this item to be detached later.
				type.module.assembly.AddDetach(this);

				// Create the parameter.
				lock(typeof(AssemblyBuilder))
				{
					this.privateData = ClrParameterCreate
						(((IClrProgramItem)method).ClrHandle,
						 position, attributes, strParamName);
				}
			}
示例#12
0
 MethodBase[] GetVTableMethods(VTableFixups fixups)
 {
     var methods = new MethodBase[fixups.Count];
     byte[] buf = new byte[8];
     int fixuprva = fixups.RVA;
     for (int i = 0; i < fixups.Count; i++)
     {
         module.__ReadDataFromRVA(fixuprva, buf, 0, 4);
         methods[i] = module.ResolveMethod(BitConverter.ToInt32(buf, 0));
         if ((fixups.Type & COR_VTABLE_32BIT) != 0)
         {
             fixuprva += 4;
         }
         if ((fixups.Type & COR_VTABLE_64BIT) != 0)
         {
             fixuprva += 8;
         }
     }
     return methods;
 }
示例#13
0
        public static IQueryable <T> ExpandEntity <T, L>(this IQueryable <T> source, Expression <Func <T, L> > entitySelector, ExpandEntity expandEntity)
            where L : class, IEntity
        {
            if (source == null)
            {
                throw new ArgumentNullException("query");
            }

            return(source.Provider.CreateQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T), typeof(L) }), new Expression[] { source.Expression, Expression.Quote(entitySelector), Expression.Constant(expandEntity) })));
        }
示例#14
0
文件: Ldloc.cs 项目: vdt/AtomOS
        public override void Execute(ILOpCode instr, MethodBase aMethod)
        {
            var xVar       = ((OpVar)instr).Value;
            var xBody      = aMethod.GetMethodBody();
            var xField     = xBody.LocalVariables[xVar];
            var xSize      = xField.LocalType.SizeOf();
            var StackCount = xSize.Align() / 4;
            var EBPOffset  = ILHelper.MemoryOffset(xBody, xVar);

            switch (ILCompiler.CPUArchitecture)
            {
                #region _x86_
            case CPUArch.x86:
            {
                switch (xSize)
                {
                case 1:
                case 2:
                {
                    bool IsSigned = xField.LocalType.IsSigned();
                    if (IsSigned)
                    {
                        Core.AssemblerCode.Add(new Movsx
                                {
                                    DestinationReg     = Registers.EAX,
                                    SourceReg          = Registers.EBP,
                                    SourceIndirect     = true,
                                    SourceDisplacement = 0 - (int)(EBPOffset + 4),
                                    Size = 0x10
                                });
                        Core.AssemblerCode.Add(new Push()
                                {
                                    DestinationReg = Registers.EAX
                                });
                    }
                    else
                    {
                        Core.AssemblerCode.Add(new Movzx
                                {
                                    DestinationReg     = Registers.EAX,
                                    SourceReg          = Registers.EBP,
                                    SourceIndirect     = true,
                                    SourceDisplacement = 0 - (int)(EBPOffset + 4),
                                    Size = 0x10
                                });
                        Core.AssemblerCode.Add(new Push()
                                {
                                    DestinationReg = Registers.EAX
                                });
                    }
                }
                break;

                case 4:
                {
                    Core.AssemblerCode.Add(new Push
                            {
                                DestinationReg          = Registers.EBP,
                                DestinationIndirect     = true,
                                DestinationDisplacement = 0 - (int)(EBPOffset + 4),
                            });
                }
                break;

                default:
                {
                    for (int i = StackCount; i > 0; i--)
                    {
                        //push dword [EBP - 0x*]
                        Core.AssemblerCode.Add(new Push
                                {
                                    DestinationReg          = Registers.EBP,
                                    DestinationIndirect     = true,
                                    DestinationDisplacement = 0 - (int)(EBPOffset + i * 4),
                                });
                    }
                }
                break;
                }
            }
            break;

                #endregion
                #region _x64_
            case CPUArch.x64:
            {
            }
            break;

                #endregion
                #region _ARM_
            case CPUArch.ARM:
            {
            }
            break;
                #endregion
            }
            Core.vStack.Push(xSize.Align(), xField.LocalType);
        }
示例#15
0
 /// <summary>
 /// This butto click event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Props.Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     try
     {
         PrintDialog printDialog = new PrintDialog();
         if (printDialog.ShowDialog() == true)
         {
             printDialog.PrintVisual(null, "My First Print Job");
         }
     }
     catch (Exception ex)
     {
         LogHelper.LogErrorToDb(ex);
         bool displayErrorOnUI = false;
         CommonSettings.logger.LogError(this.GetType(), ex);
         if (displayErrorOnUI)
         {
             throw;
         }
     }
     finally
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Props.Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     }
 }
示例#16
0
 public MethodInfo GetMethod(MethodBase original) => patchWrapper.GetMethod(original);
        public async Task <ApiResponse> Get(string listName)
        {
            LogManager.LogStartFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name);

            JArray result = await _httpClientService.Get <JArray>(_dataProvider.dataProviderApiUrl,
                                                                  _dataProvider.GeneralListsApi,
                                                                  listName);

            LogManager.LogEndFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name);

            return(new ApiOkResponse(result));
        }
示例#18
0
 public void Paste(string text)
 {
     NotImplemented(MethodBase.GetCurrentMethod(), text);
 }
		internal object ToMethodOrConstructor(bool copy)
		{
#if FIRST_PASS
			return null;
#else
			object method = reflectionMethod;
			if (method == null)
			{
				Link();
				ClassLoaderWrapper loader = this.DeclaringType.GetClassLoader();
				TypeWrapper[] argTypes = GetParameters();
				java.lang.Class[] parameterTypes = new java.lang.Class[argTypes.Length];
				for (int i = 0; i < argTypes.Length; i++)
				{
					parameterTypes[i] = argTypes[i].EnsureLoadable(loader).ClassObject;
				}
				java.lang.Class[] checkedExceptions = GetExceptions();
				if (this.Name == StringConstants.INIT)
				{
					method = new java.lang.reflect.Constructor(
						this.DeclaringType.ClassObject,
						parameterTypes,
						checkedExceptions,
						(int)this.Modifiers | (this.IsInternal ? 0x40000000 : 0),
						Array.IndexOf(this.DeclaringType.GetMethods(), this),
						this.DeclaringType.GetGenericMethodSignature(this),
						null,
						null
					);
				}
				else
				{
					method = new java.lang.reflect.Method(
						this.DeclaringType.ClassObject,
						this.Name,
						parameterTypes,
						this.ReturnType.EnsureLoadable(loader).ClassObject,
						checkedExceptions,
						(int)this.Modifiers | (this.IsInternal ? 0x40000000 : 0),
						Array.IndexOf(this.DeclaringType.GetMethods(), this),
						this.DeclaringType.GetGenericMethodSignature(this),
						null,
						null,
						null
					);
				}
				lock (this)
				{
					if (reflectionMethod == null)
					{
						reflectionMethod = method;
					}
					else
					{
						method = reflectionMethod;
					}
				}
			}
			if (copy)
			{
				java.lang.reflect.Constructor ctor = method as java.lang.reflect.Constructor;
				if (ctor != null)
				{
					return ctor.copy();
				}
				return ((java.lang.reflect.Method)method).copy();
			}
			return method;
#endif
		}
示例#20
0
        //
        // Returns the ParameterInfo objects for the method parameters and return parameter.
        //
        // The ParameterInfo objects will report "contextMethod" as their Member property and use it to get type variable information from
        // the contextMethod's declaring type. The actual metadata, however, comes from "this."
        //
        // The methodTypeArguments provides the fill-ins for any method type variable elements in the parameter type signatures.
        //
        // Does not array-copy.
        //
        public                                   RuntimeParameterInfo[] GetRuntimeParameters(MethodBase contextMethod, RuntimeTypeInfo[] methodTypeArguments, out RuntimeParameterInfo returnParameter)
        {
            MetadataReader reader      = _reader;
            TypeContext    typeContext = contextMethod.DeclaringType.CastToRuntimeTypeInfo().TypeContext;

            typeContext = new TypeContext(typeContext.GenericTypeArguments, methodTypeArguments);
            MethodSignature methodSignature = this.MethodSignature;

            Handle[] typeSignatures = new Handle[methodSignature.Parameters.Count + 1];
            typeSignatures[0] = methodSignature.ReturnType;
            int paramIndex = 1;

            foreach (Handle parameterTypeSignatureHandle in methodSignature.Parameters)
            {
                typeSignatures[paramIndex++] = parameterTypeSignatureHandle;
            }
            int count = typeSignatures.Length;

            VirtualRuntimeParameterInfoArray result = new VirtualRuntimeParameterInfoArray(count);

            foreach (ParameterHandle parameterHandle in _method.Parameters)
            {
                Parameter parameterRecord = parameterHandle.GetParameter(_reader);
                int       index           = parameterRecord.Sequence;
                result[index] =
                    RuntimeFatMethodParameterInfo.GetRuntimeFatMethodParameterInfo(
                        contextMethod,
                        _methodHandle,
                        index - 1,
                        parameterHandle,
                        reader,
                        typeSignatures[index],
                        typeContext);
            }
            for (int i = 0; i < count; i++)
            {
                if (result[i] == null)
                {
                    result[i] =
                        RuntimeThinMethodParameterInfo.GetRuntimeThinMethodParameterInfo(
                            contextMethod,
                            i - 1,
                            reader,
                            typeSignatures[i],
                            typeContext);
                }
            }

            returnParameter = result.First;
            return(result.Remainder);
        }
        public void AddResponseAddNewResponseReturnCount()
        {
            var option = new DbContextOptionsBuilder <EvaluationContext>()
                         .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                         .Options;

            using (var memoryContext = new EvaluationContext(option))
            {
                //Arrange
                IFormRepository                formRepository                = new FormRepository(memoryContext);
                IResponseRepository            responseRepository            = new ResponseRepository(memoryContext);
                IQuestionRepository            questionRepository            = new QuestionRepository(memoryContext);
                ISubmissionRepository          submissionRepository          = new SubmissionRepository(memoryContext);
                IQuestionPropositionRepository questionPropositionRepository = new QuestionPropositionRepository(memoryContext);

                #region Form

                var Form1 = new FormTO
                {
                    Name = new MultiLanguageString
                           (
                        "Daily evaluation form",
                        "Formulaire d'évaluation journalier",
                        "Dagelijks evaluatieformulier"
                           ),
                };
                var formAdded1 = formRepository.Add(Form1);
                memoryContext.SaveChanges();

                #endregion

                #region Questions

                var Question1 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 1,
                    Libelle  = new MultiLanguageString
                               (
                        "What is your general impression after this first day of training ?",
                        "Quelle est votre impression générale après cette première journée de formation ?",
                        "Wat is je algemene indruk na deze eerste dag van training ?"
                               ),
                    Type = QuestionType.SingleChoice,
                };

                var Question2 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 2,
                    Libelle  = new MultiLanguageString
                               (
                        "Is the pace right for you ?",
                        "Est-ce que le rythme vous convient ?",
                        "Is het tempo geschikt voor u ?"
                               ),
                    Type = QuestionType.SingleChoice,
                };

                var Question3 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 3,
                    Libelle  = new MultiLanguageString
                               (
                        "Do you have questions related to the subject studied today ?",
                        "Avez-vous des questions relatives à la matière étudiée aujourd’hui ?",
                        "Heb je vragen over het onderwerp dat vandaag is bestudeerd ?"
                               ),
                    Type = QuestionType.Open
                };

                var Question4 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 4,
                    Libelle  = new MultiLanguageString
                               (
                        "Do you have specific questions / particular topics that you would like deepen during this training ?",
                        "Avez-vous des questions spécifiques/sujets particuliers que vous aimeriez approfondir durant cette formation ?",
                        "Heeft u specifieke vragen / specifieke onderwerpen die u graag zou willen verdiepen tijdens deze training ?"
                               ),
                    Type = QuestionType.Open
                };

                var Question5 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 5,
                    Libelle  = new MultiLanguageString
                               (
                        "What objectives do you pursue by following this training ?",
                        "Quels objectifs poursuivez-vous en suivant cette formation ?",
                        "Welke doelstellingen streeft u na door deze training te volgen?"
                               ),
                    Type = QuestionType.Open
                };

                var questionAdded1 = questionRepository.Add(Question1);
                var questionAdded2 = questionRepository.Add(Question2);
                var questionAdded3 = questionRepository.Add(Question3);
                var questionAdded4 = questionRepository.Add(Question4);
                var questionAdded5 = questionRepository.Add(Question5);
                memoryContext.SaveChanges();

                #endregion

                #region QuestionProposition
                var QuestionProposition1 = new QuestionPropositionTO
                {
                    Question = questionAdded1,
                    Libelle  = new MultiLanguageString("good", "bonne", "goed"),
                    Position = 1
                };

                var QuestionProposition2 = new QuestionPropositionTO
                {
                    Question = questionAdded1,
                    Libelle  = new MultiLanguageString("medium", "moyenne", "gemiddelde"),
                    Position = 2
                };

                var QuestionProposition3 = new QuestionPropositionTO
                {
                    Question = questionAdded1,
                    Libelle  = new MultiLanguageString("bad", "mauvaise", "slecht"),
                    Position = 3
                };

                var QuestionProposition4 = new QuestionPropositionTO
                {
                    Question = questionAdded2,
                    Libelle  = new MultiLanguageString("yes", "oui", "ja"),
                    Position = 1
                };

                var QuestionProposition5 = new QuestionPropositionTO
                {
                    Question = questionAdded2,
                    Libelle  = new MultiLanguageString("too fast", "trop rapide", "te snel"),
                    Position = 2
                };

                var QuestionProposition6 = new QuestionPropositionTO
                {
                    Question = questionAdded2,
                    Libelle  = new MultiLanguageString("too slow", "trop lent", "te langzaam"),
                    Position = 3
                };

                var questionPropositionAdded1 = questionPropositionRepository.Add(QuestionProposition1);
                var questionPropositionAdded2 = questionPropositionRepository.Add(QuestionProposition2);
                var questionPropositionAdded3 = questionPropositionRepository.Add(QuestionProposition3);
                var questionPropositionAdded4 = questionPropositionRepository.Add(QuestionProposition4);
                var questionPropositionAdded5 = questionPropositionRepository.Add(QuestionProposition5);
                var questionPropositionAdded6 = questionPropositionRepository.Add(QuestionProposition6);

                memoryContext.SaveChanges();

                #endregion

                #region Submission
                var submission1 = new SubmissionTO
                {
                    SessionId  = 30,
                    AttendeeId = 1012,
                    Date       = DateTime.Today,
                };
                var submission2 = new SubmissionTO
                {
                    SessionId  = 31,
                    AttendeeId = 2607,
                    Date       = DateTime.Today,
                };
                var submission3 = new SubmissionTO
                {
                    SessionId  = 2,
                    AttendeeId = 1612,
                    Date       = DateTime.Today,
                };

                var submissionAdded1 = submissionRepository.Add(submission1);
                var submissionAdded2 = submissionRepository.Add(submission2);
                var submissionAdded3 = submissionRepository.Add(submission3);
                memoryContext.SaveChanges();

                #endregion

                #region Responses
                var response1 = new ResponseTO
                {
                    Question            = questionAdded1,
                    Submission          = submissionAdded1,
                    QuestionProposition = questionPropositionAdded1,
                };

                var response2 = new ResponseTO
                {
                    Question            = questionAdded2,
                    Submission          = submissionAdded2,
                    QuestionProposition = questionPropositionAdded2,
                };

                var response3 = new ResponseTO
                {
                    Question   = questionAdded3,
                    Submission = submissionAdded3,
                    Text       = "Ceci est une réponse à une question ouverte",
                    //QuestionProposition = QuestionProposition3,
                };

                var response4 = new ResponseTO
                {
                    Question   = questionAdded4,
                    Submission = submissionAdded1,
                    Text       = "Ceci est une réponse à une question ouverte",
                };

                //Assert
                var responseAdded1 = responseRepository.Add(response1);
                var responseAdded2 = responseRepository.Add(response2);
                var responseAdded3 = responseRepository.Add(response3);
                var responseAdded4 = responseRepository.Add(response4);
                memoryContext.SaveChanges();

                #endregion
                //Act
                Assert.IsNotNull(responseAdded1);
                Assert.IsNotNull(responseAdded2);
                Assert.IsNotNull(responseAdded3);
                Assert.IsNotNull(responseAdded4);

                Assert.AreEqual(4, memoryContext.Responses.Count());
            }
        }
示例#22
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions, MethodBase original)
        {
            transpileCount++;
            var list = instructions.ToList();

            if (original.IsConstructor is false)
            {
                list.Insert(list.Count - 1, CodeInstruction.Call(() => Fix("")));
            }
            return(list.AsEnumerable());
        }
示例#23
0
        public void YongHuXinXi002()
        {
            try
            {
                Log.Info("开始执行用例");
                //打开首页
                baseURL = UserHT["url"].ToString();
                driver.Navigate().GoToUrl(baseURL);
                //登录
                LoginOn loginOn = new LoginOn(driver);
                loginOn.CNLoginOn(UserHT["测试用户登录名"].ToString(), UserHT["测试用户登陆密码"].ToString());

                Thread.Sleep(MinSleepTime);

                //展开个人中心菜单
                driver.FindElement(By.Id("menu_person_icon_id")).Click();
                Thread.Sleep(MinSleepTime);
                driver.FindElement(By.Id("ctl00_MainContentPlaceHolder_PageLeft1_MyAccount")).Click();
                //证书判断
                if (SeleniumFun.IsExists(driver, By.Id("overridelink")))
                {
                    driver.FindElement(By.Id("overridelink")).Click();
                    Thread.Sleep(3000);
                }
                Thread.Sleep(MinSleepTime);
                CtripAssert.Contains(driver, driver.FindElement(By.Id("info_title_id")).Text, "个人信息设置", "验证个人账户链接跳转");
                //修改个人信息
                driver.FindElement(By.Id("nickName")).Clear();
                driver.FindElement(By.Id("nickName")).SendKeys("一统江湖");
                driver.FindElement(By.Id("name")).Click();
                driver.FindElement(By.Id("name")).Clear();
                driver.FindElement(By.Id("name")).SendKeys("东方不败");
                driver.FindElement(By.Id("radioSexWoman")).Click();
                driver.FindElement(By.Id("btnSave")).Click();
                Thread.Sleep(MinSleepTime);
                driver.FindElement(By.Id("infoUpdateConfirmPwd")).Click();
                driver.FindElement(By.Id("infoUpdateConfirmPwd")).SendKeys(UserHT["测试用户登陆密码"].ToString());
                driver.FindElement(By.Id("btnInfoUpdateConfirm")).Click();
                Thread.Sleep(MIDSleepTime);
                CtripAssert.Contains(driver, driver.FindElement(By.XPath("//container/div[2]/div[2]/div[1]")).Text, "信息修改成功", "修改个人信息成功");
                Thread.Sleep(MIDSleepTime);
                driver.FindElement(By.Id("btnInfoUpdateSuccessConfirm")).Click();
                Thread.Sleep(MIDSleepTime);
                bool flag = driver.FindElement(By.Id("radioSexWoman")).Selected;
                CtripAssert.AreEqual(driver, flag.ToString(), "True", "");
                CtripAssert.AreEqual(driver, driver.FindElement(By.Id("nickName")).GetAttribute("value"), "一统江湖", "");
                CtripAssert.AreEqual(driver, driver.FindElement(By.Id("name")).GetAttribute("value"), "东方不败", "修改成功");
                //数据回滚
                driver.FindElement(By.Id("nickName")).Clear();
                driver.FindElement(By.Id("nickName")).SendKeys("独步天下");
                driver.FindElement(By.Id("name")).Click();
                driver.FindElement(By.Id("name")).Clear();
                driver.FindElement(By.Id("name")).SendKeys("令狐冲");
                driver.FindElement(By.Id("radioSexMan")).Click();
                driver.FindElement(By.Id("btnSave")).Click();
                Thread.Sleep(MinSleepTime);
                driver.FindElement(By.Id("infoUpdateConfirmPwd")).Click();
                driver.FindElement(By.Id("infoUpdateConfirmPwd")).SendKeys(UserHT["测试用户登陆密码"].ToString());
                driver.FindElement(By.Id("btnInfoUpdateConfirm")).Click();
                Thread.Sleep(MinSleepTime);
                driver.FindElement(By.Id("btnInfoUpdateSuccessConfirm")).Click();
                Thread.Sleep(MinSleepTime);
                //修改个人密码
                driver.FindElement(By.XPath("//ul/li/div[3]/div[2]/div/h3")).Click();
                driver.FindElement(By.Id("oldPwd")).SendKeys(UserHT["测试用户登陆密码"].ToString());
                driver.FindElement(By.Id("newPwd")).SendKeys("111111");
                driver.FindElement(By.Id("confirmNewPwd")).SendKeys("111111");
                driver.FindElement(By.Id("btnPwdSave")).Click();
                Thread.Sleep(MinSleepTime);
                CtripAssert.Contains(driver, "密码修改成功。", driver.FindElement(By.XPath("//container/div[2]/div[2]/div[1]")).Text, "密码修改功能验证");
                Thread.Sleep(MinSleepTime);
                driver.FindElement(By.Id("btnPwdUpdateSuccessConfirm")).Click();
                Thread.Sleep(MIDSleepTime);
                //数据回滚
                driver.FindElement(By.XPath("//ul/li/div[3]/div[2]/div/h3")).Click();
                driver.FindElement(By.Id("oldPwd")).SendKeys("111111");
                driver.FindElement(By.Id("newPwd")).SendKeys(UserHT["测试用户登陆密码"].ToString());
                driver.FindElement(By.Id("confirmNewPwd")).SendKeys(UserHT["测试用户登陆密码"].ToString());
                driver.FindElement(By.Id("btnPwdSave")).Click();
                Thread.Sleep(MIDSleepTime);
                driver.FindElement(By.XPath("//container/div[2]/div[2]/div[1]")).Click();
            }

            catch (Exception e)
            {
                new CtripException(driver, e.ToString(), this.GetType().ToString(), MethodBase.GetCurrentMethod().ToString());
            }
        }
示例#24
0
 public void YongHuXinXi010()
 {
     try
     {
         Log.Info("开始执行用例");
         //打开首页
         baseURL = UserHT["url"].ToString();
         driver.Navigate().GoToUrl(baseURL);
         //登录
         LoginOn loginOn = new LoginOn(driver);
         loginOn.CNLoginOn(UserHT["测试用户登录名"].ToString(), UserHT["测试用户登陆密码"].ToString());
         Thread.Sleep(MinSleepTime);
         //验证常用旅客信息链接存在并点击
         Log.Info("验证常用旅客信息链接");
         driver.FindElement(By.Id("ctl00_MainContentPlaceHolder_PageLeft1_menu_manage_id")).Click();
         Thread.Sleep(MinSleepTime);
         driver.FindElement(By.Id("ctl00_MainContentPlaceHolder_PageLeft1_Passenger")).Click();
         //证书判断
         SeleniumFun.CheckSecurity(driver);
         Thread.Sleep(MinSleepTime);
         //验证列表显示正常
         driver.FindElement(By.Id("txt_keyword")).SendKeys("test");
         driver.FindElement(By.Id("bt_Search")).Click();
         Thread.Sleep(MinSleepTime);
         CtripAssert.AreEqual(driver, driver.FindElement(By.XPath("//ul/li/div[3]/div[2]/table/tbody/tr[1]/td[2]")).Text, "test/test", "列表显示正常");
         //修改常用旅客信息
         driver.FindElement(By.XPath("//ul/li/div[3]/div[2]/table/tbody/tr[1]/td[9]/a[1]")).Click();
         Thread.Sleep(MIDSleepTime);
         driver.FindElement(By.Id("txt_namecn")).Clear();
         driver.FindElement(By.Id("txt_namecn")).SendKeys("令狐冲");
         driver.FindElement(By.Id("txt_mobile")).Clear();
         driver.FindElement(By.Id("txt_mobile")).SendKeys("13888888888");
         SeleniumFun.SelectByText(driver.FindElement(By.ClassName("vam")), "身份证");
         driver.FindElement(By.XPath("//ul/li/div[3]/div[5]/div[2]/div[3]/ul/li[1]/input[1]")).Clear();
         driver.FindElement(By.XPath("//ul/li/div[3]/div[5]/div[2]/div[3]/ul/li[1]/input[1]")).SendKeys("21080219900409251x");
         driver.FindElement(By.Id("bt_SaveAdd")).Click();
         driver.FindElement(By.Id("input_pwd_check")).SendKeys(UserHT["测试用户登陆密码"].ToString());
         driver.FindElement(By.ClassName("btn_l3")).Click();
         Thread.Sleep(MinSleepTime);
         //验证修改是否正确
         driver.FindElement(By.XPath("//ul/li/div[3]/div[2]/table/tbody/tr[1]/td[9]/a[1]")).Click();
         CtripAssert.AreEqual(driver, driver.FindElement(By.Id("txt_namecn")).GetAttribute("value"), "令狐冲");
         CtripAssert.AreEqual(driver, driver.FindElement(By.Id("txt_mobile")).GetAttribute("value"), "13888888888");
         CtripAssert.AreEqual(driver, driver.FindElement(By.ClassName("vam")).GetAttribute("value"), "1");
         CtripAssert.AreEqual(driver, driver.FindElement(By.XPath("//ul/li/div[3]/div[5]/div[2]/div[3]/ul/li[1]/input[1]")).GetAttribute("value"), "21080219900409251x", "修改成功");
         //数据回滚
         driver.FindElement(By.XPath("//ul/li/div[3]/div[2]/table/tbody/tr[1]/td[9]/a[1]")).Click();
         Thread.Sleep(MIDSleepTime);
         driver.FindElement(By.Id("txt_namecn")).Clear();
         driver.FindElement(By.Id("txt_mobile")).Clear();
         driver.FindElement(By.Id("txt_mobile")).SendKeys("13111111111");
         SeleniumFun.SelectByText(driver.FindElement(By.ClassName("vam")), "护照");
         driver.FindElement(By.XPath("//ul/li/div[3]/div[5]/div[2]/div[3]/ul/li[1]/input[1]")).Clear();
         driver.FindElement(By.XPath("//ul/li/div[3]/div[5]/div[2]/div[3]/ul/li[1]/input[1]")).SendKeys("chinesehz001");
         driver.FindElement(By.XPath("//ul/li/div[3]/div[5]/div[2]/div[3]/ul/li[1]/input[2]")).SendKeys("2015-01-01");
         driver.FindElement(By.Id("bt_SaveAdd")).Click();
         driver.FindElement(By.Id("input_pwd_check")).SendKeys(UserHT["测试用户登陆密码"].ToString());
         driver.FindElement(By.ClassName("btn_l3")).Click();
         Thread.Sleep(MinSleepTime);
     }
     catch (Exception e)
     {
         new CtripException(driver, e.ToString(), this.GetType().ToString(), MethodBase.GetCurrentMethod().ToString());
     }
 }
示例#25
0
 private static bool IsInterceptedAtTheCallSite(MethodBase method)
 {
     return(method.IsConstructor);
 }
示例#26
0
 public static int GetIndexOfMatchingShim(MethodBase methodBase, object obj)
 => GetIndexOfMatchingShim(methodBase, methodBase.DeclaringType, obj);
		internal static MethodWrapper Create(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
		{
			Debug.Assert(declaringType != null && name!= null && sig != null && method != null);

			if(declaringType.IsGhost)
			{
				// HACK since our caller isn't aware of the ghost issues, we'll handle the method swapping
				if(method.DeclaringType.IsValueType)
				{
					Type[] types = new Type[parameterTypes.Length];
					for(int i = 0; i < types.Length; i++)
					{
						types[i] = parameterTypes[i].TypeAsSignatureType;
					}
					method = declaringType.TypeAsBaseType.GetMethod(method.Name, types);
				}
				return new GhostMethodWrapper(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags);
			}
			else if(method is ConstructorInfo)
			{
				return new SmartConstructorMethodWrapper(declaringType, name, sig, (ConstructorInfo)method, parameterTypes, modifiers, flags);
			}
			else
			{
				return new SmartCallMethodWrapper(declaringType, name, sig, (MethodInfo)method, returnType, parameterTypes, modifiers, flags, SimpleOpCode.Call, method.IsStatic ? SimpleOpCode.Call : SimpleOpCode.Callvirt);
			}
		}
示例#28
0
        protected override string GetMemberAttributes(MemberInfo member)
        {
            MethodBase method = (MethodBase)member;

            return(((int)(method.Attributes & ~MethodAttributes.ReservedMask)).ToString(CultureInfo.InvariantCulture));
        }
		internal void ResolveMethod()
		{
			// if we've still got the builder object, we need to replace it with the real thing before we can call it
			if(method is MethodBuilder)
			{
				method = method.Module.ResolveMethod(((MethodBuilder)method).GetToken().Token);
			}
			if(method is ConstructorBuilder)
			{
				method = method.Module.ResolveMethod(((ConstructorBuilder)method).GetToken().Token);
			}
		}
示例#30
0
    //生成 CheckTypes() 里面的参数列表
    static string GenParamTypes(ParameterInfo[] p, MethodBase mb)
    {
        StringBuilder sb = new StringBuilder();
        List<Type> list = new List<Type>();
        bool isStatic = mb.IsConstructor ? true : mb.IsStatic;

        if (!isStatic)
        {
            list.Add(type);
        }

        for (int i = 0; i < p.Length; i++)
        {
            if (IsParams(p[i]))
            {
                continue;
            }

            if (p[i].Attributes != ParameterAttributes.Out)
            {
                list.Add(GetGenericBaseType(mb, p[i].ParameterType));
            }
            else
            {
                Type genericClass = typeof(LuaOut<>);
                Type t = genericClass.MakeGenericType(p[i].ParameterType);
                list.Add(t);
            }
        }

        for (int i = 0; i < list.Count - 1; i++)
        {
            sb.Append(GetTypeOf(list[i], ", "));
        }

        sb.Append(GetTypeOf(list[list.Count - 1], ""));
        return sb.ToString();
    }
        public async Task <ApiResponse> Get(int siteId, string listCode)
        {
            LogManager.LogStartFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name);
            try {
                JArray result = await _httpClientService.Get <JArray>(_dataProvider.dataProviderApiUrl,
                                                                      _dataProvider.GeneralListsApi,
                                                                      new Dictionary <string, string>() { { "siteId", siteId.ToString() }, { "listCode", listCode } });

                LogManager.LogInfo(MethodBase.GetCurrentMethod().DeclaringType.ToString(),
                                   MethodBase.GetCurrentMethod().Name, new Dictionary <string, object>()
                {
                    { "siteId", siteId }, { "listCode", listCode },
                    { "result", result }
                }, "Success get list from dataProvider");

                return(new ApiOkResponse(result));
            }
            catch (Exception ex) {
                LogManager.LogError(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name, ex,
                                    new Dictionary <string, object>()
                {
                    { "siteId", siteId }, { "listCode", listCode }
                }, "error get list from dataProvider");
            }

            LogManager.LogEndFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name);

            return(new ApiOkResponse(null));
        }
示例#32
0
    static int GetMethodType(MethodBase md, out PropertyInfo pi)
    {
        int methodType = 0;
        pi = null;
        int pos = allProps.FindIndex((p) => { return p.GetGetMethod() == md || p.GetSetMethod() == md; });

        if (pos >= 0)
        {
            methodType = 1;
            pi = allProps[pos];

            if (md == pi.GetGetMethod())
            {
                if (md.GetParameters().Length > 0)
                {
                    methodType = 2;
                }
            }
            else if (md == pi.GetSetMethod())
            {
                if (md.GetParameters().Length > 1)
                {
                    methodType = 2;
                }
            }
        }

        return methodType;
    }
        // Call each hook object and return it's response.
        private object Internal_OnCall(RuntimeMethodHandle rmh, object thisObj, object[] args, IntPtr[] refArgs, int[] refArgMatch)
        {
            // Without Unity Engine as context, we don't execute the hook.
            // This is to prevent accidentally calling unity functions without the proper
            // initialisation.
            if (!_isWithinUnity)
            {
                return(null);
            }

            MethodBase method = null;

            try
            {
                // Try to directly resolve the method definition.
                method = MethodBase.GetMethodFromHandle(rmh);
            }
            catch (ArgumentException)
            {
                // Direct resolution of method definition doesn't work, probably because of generic parameters.
                // We use the blueprints that were registered to try and decode this generic instantiated type.
                foreach (RuntimeTypeHandle declHandle in _declaringTypes)
                {
                    method = MethodBase.GetMethodFromHandle(rmh, declHandle);
                    if (method != null)
                    {
                        break;
                    }
                }
            }

            // Panic if the method variable is still not set.
            if (method == null)
            {
                Panic("Could not resolve the method handle!");
            }

            // Fetch usefull information from the method definition.
            // Use that information to log the call.
            string typeName   = method.DeclaringType.FullName;
            string methodName = method.Name;
            // TODO: replace with parameters of function.
            string paramString = "..";

            // Coming from UnityEngine.dll - UnityEngine.Debug.Log(..)
            // This method prints into the game's debug log
            Internal_Debug("Called by `{0}.{1}({2})`", typeName, methodName, paramString);

            // Execute each hook, because we don't know which one to actually target
            foreach (Callback cb in _callbacks)
            {
                object o = cb(typeName, methodName, thisObj, args, refArgs, refArgMatch);
                // If the hook did not return null, return it's response.
                // This test explicitly ends the enclosing FOR loop, so hooks that were
                // not executed yet will not run.
                if (o != null)
                {
                    return(o);
                }
            }
            return(null);
        }
示例#34
0
    static int ProcessParams(MethodBase md, int tab, bool beConstruct, bool beCheckTypes = false)
    {
        ParameterInfo[] paramInfos = md.GetParameters();
        bool beExtend = IsExtendFunction(md);

        if (beExtend)
        {
            ParameterInfo[] pt = new ParameterInfo[paramInfos.Length - 1];
            Array.Copy(paramInfos, 1, pt, 0, pt.Length);
            paramInfos = pt;
        }

        int count = paramInfos.Length;
        string head = string.Empty;
        PropertyInfo pi = null;
        int methodType = GetMethodType(md, out pi);
        int offset = ((md.IsStatic && !beExtend )|| beConstruct) ? 1 : 2;

        if (md.Name == "op_Equality")
        {
            beCheckTypes = true;
        }

        for (int i = 0; i < tab; i++)
        {
            head += "\t";
        }

        if ((!md.IsStatic && !beConstruct) || beExtend)
        {
            if (md.Name == "Equals")
            {
                if (!type.IsValueType && !beCheckTypes)
                {
                    CheckObject(head, type, className, 1);
                }
                else
                {
                    sb.AppendFormat("{0}{1} obj = ({1})ToLua.ToObject(L, 1);\r\n", head, className);
                }
            }
            else if (!beCheckTypes)// && methodType == 0)
            {
                CheckObject(head, type, className, 1);
            }
            else
            {
                ToObject(head, type, className, 1);
            }
        }

        for (int j = 0; j < count; j++)
        {
            ParameterInfo param = paramInfos[j];
            string arg = "arg" + j;
            bool beOutArg = param.Attributes == ParameterAttributes.Out;
            bool beParams = IsParams(param);
            Type t = GetGenericBaseType(md, param.ParameterType);
            ProcessArg(t, head, arg, offset + j, beCheckTypes, beParams ,beOutArg);
        }

        StringBuilder sbArgs = new StringBuilder();
        List<string> refList = new List<string>();
        List<Type> refTypes = new List<Type>();

        for (int j = 0; j < count; j++)
        {
            ParameterInfo param = paramInfos[j];

            if (!param.ParameterType.IsByRef)
            {
                sbArgs.Append("arg");
            }
            else
            {
                if (param.Attributes == ParameterAttributes.Out)
                {
                    sbArgs.Append("out arg");
                }
                else
                {
                    sbArgs.Append("ref arg");
                }

                refList.Add("arg" + j);
                refTypes.Add(GetRefBaseType(param.ParameterType));
            }

            sbArgs.Append(j);

            if (j != count - 1)
            {
                sbArgs.Append(", ");
            }
        }

        if (beConstruct)
        {
            sb.AppendFormat("{2}{0} obj = new {0}({1});\r\n", className, sbArgs.ToString(), head);
            string str = GetPushFunction(type);
            sb.AppendFormat("{0}ToLua.{1}(L, obj);\r\n", head, str);

            for (int i = 0; i < refList.Count; i++)
            {
                GenPushStr(refTypes[i], refList[i], head);
            }

            return refList.Count + 1;
        }

        string obj = (md.IsStatic && !beExtend) ? className : "obj";
        MethodInfo m = md as MethodInfo;

        if (m.ReturnType == typeof(void))
        {
            if (md.Name == "set_Item")
            {
                if (methodType == 2)
                {
                    string str = sbArgs.ToString();
                    string[] ss = str.Split(',');
                    str = string.Join(",", ss, 0, ss.Length - 1);

                    sb.AppendFormat("{0}{1}[{2}] ={3};\r\n", head, obj, str, ss[ss.Length - 1]);
                }
                else if (methodType == 1)
                {
                    sb.AppendFormat("{0}{1}.Item = arg0;\r\n", head, obj, pi.Name);
                }
                else
                {
                    sb.AppendFormat("{0}{1}.{2}({3});\r\n", head, obj, md.Name, sbArgs.ToString());
                }
            }
            else if (methodType == 1)
            {
                sb.AppendFormat("{0}{1}.{2} = arg0;\r\n", head, obj, pi.Name);
            }
            else
            {
                sb.AppendFormat("{3}{0}.{1}({2});\r\n", obj, md.Name, sbArgs.ToString(), head);
            }
        }
        else
        {
            Type retType = GetGenericBaseType(md, m.ReturnType);
            string ret = GetTypeStr(retType);

            if (md.Name.StartsWith("op_"))
            {
                CallOpFunction(md.Name, tab, ret);
            }
            else if (md.Name == "get_Item")
            {
                if (methodType == 2)
                {
                    sb.AppendFormat("{0}{1} o = {2}[{3}];\r\n", head, ret, obj, sbArgs.ToString());
                }
                else if (methodType == 1)
                {
                    sb.AppendFormat("{0}{1} o = {2}.Item;\r\n", head, ret, obj);
                }
                else
                {
                    sb.AppendFormat("{0}{1} o = {2}.{3}({4});\r\n", head, ret, obj, md.Name, sbArgs.ToString());
                }
            }
            else if (md.Name == "Equals")
            {
                if (type.IsValueType)
                {
                    sb.AppendFormat("{0}{1} o = obj.Equals({2});\r\n", head, ret, sbArgs.ToString());
                }
                else
                {
                    sb.AppendFormat("{0}{1} o = obj != null ? obj.Equals({2}) : arg0 == null;\r\n", head, ret, sbArgs.ToString());
                }
            }
            else if (methodType == 1)
            {
                sb.AppendFormat("{0}{1} o = {2}.{3};\r\n", head, ret, obj, pi.Name);
            }
            else
            {
                sb.AppendFormat("{0}{1} o = {2}.{3}({4});\r\n", head, ret, obj, md.Name, sbArgs.ToString());
            }

            bool isbuffer = IsByteBuffer(m);
            GenPushStr(m.ReturnType, "o", head, isbuffer);
        }

        for (int i = 0; i < refList.Count; i++)
        {
            GenPushStr(refTypes[i], refList[i], head);
        }

        if (!md.IsStatic && type.IsValueType && md.Name != "ToString")
        {
            sb.Append(head + "ToLua.SetBack(L, 1, obj);\r\n");
        }

        return refList.Count;
    }
示例#35
0
 /// <summary>
 /// This constructor for Date out Processing Model to open print window
 /// </summary>
 /// <param name="objPortStorageVehiclePrintModel"></param>
 public PrintWindow(DateoutProcessingModel objPortStorageVehiclePrintModel)
 {
     CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Props.Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     try
     {
         InitializeComponent();
         this.DataContext = new PrintVM(objPortStorageVehiclePrintModel);
     }
     catch (Exception ex)
     {
         LogHelper.LogErrorToDb(ex);
         bool displayErrorOnUI = false;
         CommonSettings.logger.LogError(this.GetType(), ex);
         if (displayErrorOnUI)
         {
             throw;
         }
     }
     finally
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Props.Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     }
 }
示例#36
0
    //-1 不存在替换, 1 保留左面, 2 保留右面
    static int CompareMethod(MethodBase l, MethodBase r)
    {
        int s = 0;

        if (!CompareParmsCount(l,r))
        {
            return -1;
        }
        else
        {
            ParameterInfo[] lp = l.GetParameters();
            ParameterInfo[] rp = r.GetParameters();

            List<Type> ll = new List<Type>();
            List<Type> lr = new List<Type>();

            if (!l.IsStatic)
            {
                ll.Add(type);
            }

            if (!r.IsStatic)
            {
                lr.Add(type);
            }

            for (int i = 0; i < lp.Length; i++)
            {
                ll.Add(lp[i].ParameterType);
            }

            for (int i = 0; i < rp.Length; i++)
            {
                lr.Add(rp[i].ParameterType);
            }

            for (int i = 0; i < ll.Count; i++)
            {
                if (!typeSize.ContainsKey(ll[i]) || !typeSize.ContainsKey(lr[i]))
                {
                    if (ll[i] == lr[i])
                    {
                        continue;
                    }
                    else
                    {
                        return -1;
                    }
                }
                else if (ll[i].IsPrimitive && lr[i].IsPrimitive && s == 0)
                {
                    s = typeSize[ll[i]] >= typeSize[lr[i]] ? 1 : 2;
                }
                else if (ll[i] != lr[i])
                {
                    return -1;
                }
            }

            if (s == 0 && l.IsStatic)
            {
                s = 2;
            }
        }

        return s;
    }
示例#37
0
 public Type GetDelegateType(MethodBase methodBase)
 {
     return(realMethodToNewMethod[methodBase].delegateType);
 }
		// Define each type attribute (in/out/ref) and
		// the argument names.
		public void ApplyAttributes (IMemberContext mc, MethodBase builder)
		{
			if (Count == 0)
				return;

			MethodBuilder mb = builder as MethodBuilder;
			ConstructorBuilder cb = builder as ConstructorBuilder;
			var pa = mc.Module.PredefinedAttributes;

			for (int i = 0; i < Count; i++) {
				this [i].ApplyAttributes (mb, cb, i + 1, pa);
			}
		}
示例#39
0
        private void SelectNodeMI_Click(object sender, EventArgs e)
        {
            try {
                ReferenceDescription reference = new SelectNodeDlg().ShowDialog(m_browser, ObjectTypes.BaseEventType);

                if (reference != null)
                {
                    Node node = m_session.NodeCache.Find(reference.NodeId) as Node;

                    if (node == null)
                    {
                        return;
                    }

                    ContentFilterElement element = null;

                    // build the relative path.
                    QualifiedNameCollection browsePath = new QualifiedNameCollection();
                    NodeId typeId = m_session.NodeCache.BuildBrowsePath(node, browsePath);

                    switch (node.NodeClass)
                    {
                    case NodeClass.Variable: {
                        IVariable variable = node as IVariable;

                        if (variable == null)
                        {
                            break;
                        }

                        // create attribute operand.
                        SimpleAttributeOperand attribute = new SimpleAttributeOperand(
                            m_session.FilterContext,
                            typeId,
                            browsePath);

                        // create default value.
                        object value = GuiUtils.GetDefaultValue(variable.DataType, variable.ValueRank);

                        // create attribute filter.
                        element = m_filter.Push(FilterOperator.Equals, attribute, value);
                        break;
                    }

                    case NodeClass.Object: {
                        // create attribute operand.
                        SimpleAttributeOperand attribute = new SimpleAttributeOperand(
                            m_session.FilterContext,
                            typeId,
                            browsePath);

                        attribute.AttributeId = Attributes.NodeId;

                        // create attribute filter.
                        element = m_filter.Push(FilterOperator.IsNull, attribute);
                        break;
                    }

                    case NodeClass.ObjectType: {
                        element = m_filter.Push(FilterOperator.OfType, node.NodeId);
                        break;
                    }

                    default: {
                        throw new ArgumentException("Selected an invalid node.");
                    }
                    }

                    // add element.
                    if (element != null)
                    {
                        AddItem(element);
                        AdjustColumns();
                    }
                }
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
		internal SmartMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
			: base(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags)
		{
		}
示例#41
0
        protected override void AddExtraData(XmlNode p, MemberInfo member)
        {
            base.AddExtraData(p, member);

            ParameterData parms = new ParameterData(document, p,
                                                    ((MethodBase)member).GetParameters());

            parms.DoOutput();

            if (!(member is MethodBase))
            {
                return;
            }

            MethodBase mbase = (MethodBase)member;

            if (mbase.IsAbstract)
            {
                AddAttribute(p, "abstract", "true");
            }
            if (mbase.IsVirtual)
            {
                AddAttribute(p, "virtual", "true");
            }
            if (mbase.IsFinal)
            {
                AddAttribute(p, "final", "true");
            }
            if (mbase.IsStatic)
            {
                AddAttribute(p, "static", "true");
            }

            if (!(member is MethodInfo))
            {
                return;
            }

            MethodInfo method = (MethodInfo)member;

            AddAttribute(p, "returntype", method.ReturnType.ToString());

            AttributeData.OutputAttributes(document, p,
                                           method.ReturnTypeCustomAttributes.GetCustomAttributes(false));
#if NET_2_0
            // Generic constraints
            Type []    gargs    = method.GetGenericArguments();
            XmlElement ngeneric = (gargs.Length == 0) ? null :
                                  document.CreateElement("generic-method-constraints");
            foreach (Type garg in gargs)
            {
                Type [] csts = garg.GetGenericParameterConstraints();
                if (csts.Length == 0 || csts [0] == typeof(object))
                {
                    continue;
                }
                XmlElement el = document.CreateElement("generic-method-constraint");
                el.SetAttribute("name", garg.ToString());
                el.SetAttribute("generic-attribute",
                                garg.GenericParameterAttributes.ToString());
                ngeneric.AppendChild(el);
                foreach (Type ct in csts)
                {
                    XmlElement cel = document.CreateElement("type");
                    cel.AppendChild(document.CreateTextNode(ct.FullName));
                    el.AppendChild(cel);
                }
            }
            if (ngeneric != null && ngeneric.FirstChild != null)
            {
                p.AppendChild(ngeneric);
            }
#endif
        }
        public ErrorCollection Write()
        {
            if (this.IsValid())
            {
                try
                {
                    this.Delete();

                    foreach (BluRayDiscInfo disc in _bluRayDiscInfoList.Where(d => d.IsSelected))
                    {
                        foreach (BluRaySummaryInfo summary in disc.BluRaySummaryInfoList.Where(s => s.IsSelected).OrderBy(s => s.EpisodeNumber))
                        {
                            IFFMSIndexOutputService ffmsIndexOutputService = new FFMSIndexOutputService(_eac3toConfiguration, _eac3ToOutputNamingService, disc.BluRayPath, summary);
                            string ffmsIndexPart   = ffmsIndexOutputService.GetFFMSIndexPathPart();
                            string videoStreamPart = ffmsIndexOutputService.GetVideoStreamPart();

                            using (StreamWriter sw = new StreamWriter(_eac3toConfiguration.FFMSIndextBatchFilePath, true))
                            {
                                sw.WriteLine(string.Format("{0} {1}", ffmsIndexPart, videoStreamPart));
                                sw.WriteLine();
                                sw.WriteLine();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    _log.ErrorFormat(Program.GetLogErrorFormat(), ex.Message, ex.StackTrace, MethodBase.GetCurrentMethod().Name);
                    _errors.Add(new Error()
                    {
                        Description = "There was an error while creating the ffmsindex batch file."
                    });
                }
            }
            return(_errors);
        }
示例#43
0
    static Type GetGenericBaseType(MethodBase md, Type t)
    {
        if (!md.IsGenericMethod)
        {
            return t;
        }

        List<Type> list = new List<Type>(md.GetGenericArguments());

        if (list.Contains(t))
        {
            return t.BaseType;
        }

        return t;
    }
示例#44
0
        public static bool MustDocumentMethod(MethodBase method, bool includeExplicit)
        {
            bool explicitImpl;

            return(MustDocumentMethod(method, includeExplicit, out explicitImpl));
        }
示例#45
0
    static bool IsExtendFunction(MethodBase mb)
    {
        MethodInfo m = mb as MethodInfo;

        if (m != null)
        {
            return extendMethod.Contains(m);
        }

        return false;
    }
示例#46
0
        [System.Security.SecuritySafeCritical] // System.Diagnostics.StackTrace cannot be accessed from transparent code (PSM, 2.12)
        static internal string ExtractFormattedStackTrace(StackTrace stackTrace)
        {
            StringBuilder sb = new StringBuilder(255);
            int           iIndex;

            // need to skip over "n" frames which represent the
            // System.Diagnostics package frames
            for (iIndex = 0; iIndex < stackTrace.FrameCount; iIndex++)
            {
                StackFrame frame = stackTrace.GetFrame(iIndex);

                MethodBase mb = frame.GetMethod();
                if (mb == null)
                {
                    continue;
                }

                Type classType = mb.DeclaringType;
                if (classType == null)
                {
                    continue;
                }

                // Add namespace.classname:MethodName
                String ns = classType.Namespace;
                if (ns != null && ns.Length != 0)
                {
                    sb.Append(ns);
                    sb.Append(".");
                }

                sb.Append(classType.Name);
                sb.Append(":");
                sb.Append(mb.Name);
                sb.Append("(");

                // Add parameters
                int             j           = 0;
                ParameterInfo[] pi          = mb.GetParameters();
                bool            fFirstParam = true;
                while (j < pi.Length)
                {
                    if (fFirstParam == false)
                    {
                        sb.Append(", ");
                    }
                    else
                    {
                        fFirstParam = false;
                    }

                    sb.Append(pi[j].ParameterType.Name);
                    j++;
                }
                sb.Append(")");

                // Add path name and line number - unless it is a Debug.Log call, then we are only interested
                // in the calling frame.
                string path = frame.GetFileName();
                if (path != null)
                {
                    bool shouldStripLineNumbers =
                        (classType.Name == "Debug" && classType.Namespace == "UnityEngine") ||
                        (classType.Name == "Logger" && classType.Namespace == "UnityEngine") ||
                        (classType.Name == "DebugLogHandler" && classType.Namespace == "UnityEngine") ||
                        (classType.Name == "Assert" && classType.Namespace == "UnityEngine.Assertions") ||
                        (mb.Name == "print" && classType.Name == "MonoBehaviour" && classType.Namespace == "UnityEngine")
                    ;

                    if (!shouldStripLineNumbers)
                    {
                        sb.Append(" (at ");

                        if (!string.IsNullOrEmpty(projectFolder))
                        {
                            if (path.Replace("\\", "/").StartsWith(projectFolder))
                            {
                                path = path.Substring(projectFolder.Length, path.Length - projectFolder.Length);
                            }
                        }

                        sb.Append(path);
                        sb.Append(":");
                        sb.Append(frame.GetFileLineNumber().ToString());
                        sb.Append(")");
                    }
                }

                sb.Append("\n");
            }

            return(sb.ToString());
        }
示例#47
0
    static int Compare(MethodBase lhs, MethodBase rhs)
    {
        int off1 = lhs.IsStatic ? 0 : 1;
        int off2 = rhs.IsStatic ? 0 : 1;

        ParameterInfo[] lp = lhs.GetParameters();
        ParameterInfo[] rp = rhs.GetParameters();

        int pos1 = GetOptionalParamPos(lp);
        int pos2 = GetOptionalParamPos(rp);

        if (pos1 >= 0 && pos2 < 0)
        {
            return 1;
        }
        else if (pos1 < 0 && pos2 >= 0)
        {
            return -1;
        }
        else if(pos1 >= 0 && pos2 >= 0)
        {
            pos1 += off1;
            pos2 += off2;

            if (pos1 != pos2)
            {
                return pos1 > pos2 ? -1 : 1;
            }
            else
            {
                pos1 -= off1;
                pos2 -= off2;

                if (lp[pos1].ParameterType.GetElementType() == typeof(object) && rp[pos2].ParameterType.GetElementType() != typeof(object))
                {
                    return 1;
                }
                else if (lp[pos1].ParameterType.GetElementType() != typeof(object) && rp[pos2].ParameterType.GetElementType() == typeof(object))
                {
                    return -1;
                }
            }
        }

        int c1 = off1 + lp.Length;
        int c2 = off2 + rp.Length;

        if (c1 > c2)
        {
            return 1;
        }
        else if (c1 == c2)
        {
            List<ParameterInfo> list1 = new List<ParameterInfo>(lp);
            List<ParameterInfo> list2 = new List<ParameterInfo>(rp);

            if (list1.Count > list2.Count)
            {
                if (list1[0].ParameterType == typeof(object))
                {
                    return 1;
                }

                list1.RemoveAt(0);
            }
            else if (list2.Count > list1.Count)
            {
                if (list2[0].ParameterType == typeof(object))
                {
                    return -1;
                }

                list2.RemoveAt(0);
            }

            for (int i = 0; i < list1.Count; i++)
            {
                if (list1[i].ParameterType == typeof(object) && list2[i].ParameterType != typeof(object))
                {
                    return 1;
                }
                else if (list1[i].ParameterType != typeof(object) && list2[i].ParameterType == typeof(object))
                {
                    return -1;
                }
            }

            return 0;
        }
        else
        {
            return -1;
        }
    }
示例#48
0
 public CachedMethodBase(MethodBase target, string storageFieldName)
 {
     this.Target           = target;
     this.StorageFieldName = storageFieldName;
 }
示例#49
0
		public MethodBase GetMetaInfo ()
		{
			//
			// inflatedMetaInfo is extra field needed for cases where we
			// inflate method but another nested type can later inflate
			// again (the cache would be build with inflated metaInfo) and
			// TypeBuilder can work with method definitions only
			//
			if (inflatedMetaInfo == null) {
				if ((state & StateFlags.PendingMetaInflate) != 0) {
					var dt_meta = DeclaringType.GetMetaInfo ();

					if (DeclaringType.IsTypeBuilder) {
						if (IsConstructor)
							inflatedMetaInfo = TypeBuilder.GetConstructor (dt_meta, (ConstructorInfo) MemberDefinition.Metadata);
						else
							inflatedMetaInfo = TypeBuilder.GetMethod (dt_meta, (MethodInfo) MemberDefinition.Metadata);
					} else {
#if STATIC
						// it should not be reached
						throw new NotImplementedException ();
#else
						inflatedMetaInfo = MethodInfo.GetMethodFromHandle (MemberDefinition.Metadata.MethodHandle, dt_meta.TypeHandle);
#endif
					}

					state &= ~StateFlags.PendingMetaInflate;
				} else {
					inflatedMetaInfo = MemberDefinition.Metadata;
				}
			}

			if ((state & StateFlags.PendingMakeMethod) != 0) {
				var sre_targs = new MetaType[targs.Length];
				for (int i = 0; i < sre_targs.Length; ++i)
					sre_targs[i] = targs[i].GetMetaInfo ();

				inflatedMetaInfo = ((MethodInfo) inflatedMetaInfo).MakeGenericMethod (sre_targs);
				state &= ~StateFlags.PendingMakeMethod;
			}

			return inflatedMetaInfo;
		}
示例#50
0
        private void EditMI_Click(object sender, EventArgs e)
        {
            try
            {
                if (ItemsLV.SelectedItems.Count != 1)
                {
                    return;
                }

                ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState;

                if (!IsEditableType(state.Component))
                {
                    return;
                }

                object value = null;

                /*
                 * object value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType());
                 *
                 * if (value == null)
                 * {
                 *  return;
                 * }
                 * */

                if (state.Value is IEncodeable)
                {
                    PropertyInfo property = (PropertyInfo)state.ComponentId;

                    MethodInfo[] accessors = property.GetAccessors();

                    for (int ii = 0; ii < accessors.Length; ii++)
                    {
                        if (accessors[ii].ReturnType == typeof(void))
                        {
                            accessors[ii].Invoke(state.Value, new object[] { value });
                            state.Component = value;
                            break;
                        }
                    }
                }

                DataValue datavalue = state.Value as DataValue;

                if (datavalue != null)
                {
                    int component = (int)state.ComponentId;

                    switch (component)
                    {
                    case 0: { datavalue.Value = value; break; }
                    }
                }

                if (state.Value is IList)
                {
                    int ii = (int)state.ComponentId;
                    ((IList)state.Value)[ii] = value;
                    state.Component          = value;
                }

                m_expanding = false;
                int  index     = 0;
                bool overwrite = true;
                ShowValue(ref index, ref overwrite, state.Value);
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
 /// <summary>
 /// Used by MethodTimer.
 /// </summary>
 /// <param name="methodBase"></param>
 /// <param name="milliseconds"></param>
 public static void Log(MethodBase methodBase, long milliseconds)
 {
     Log(methodBase.DeclaringType, methodBase.Name, milliseconds);
 }
        /// <summary>
        /// This method is used to get message from storeprocedure.
        /// </summary>
        /// <param name="BatchId"></param>
        /// <param name="User"></param>
        /// <returns></returns>
        public PortStorageVehicleImportProp ImportPortStorageVehicles(int BatchId, string User)
        {
            PortStorageVehicleImportProp portStorageVehicleImportProp = new PortStorageVehicleImportProp();

            // creating the object of PortStorageEntities Database
            using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
            {
                //int result = 0;
                ((IObjectContextAdapter)objAppWorksEntities).ObjectContext.CommandTimeout = 1800;
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                try
                {
                    string status = string.Empty;
                    /// Calling The Stored Procedure
                    var result = objAppWorksEntities.spImportPortStorageVehiclesData(BatchId, User).FirstOrDefault();
                    if (result != null)
                    {
                        portStorageVehicleImportProp.ReturnCode    = result.ReturnCode;
                        portStorageVehicleImportProp.ReturnMessage = result.ReturnMessage;
                    }

                    return(portStorageVehicleImportProp);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                }
            }
        }
			internal GhostMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
				: base(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags)
			{
				// make sure we weren't handed the ghostMethod in the wrapper value type
				Debug.Assert(method == null || method.DeclaringType.IsInterface);
			}
        /// <summary>
        /// This method is used to Get Port Storage Vehicle List
        /// </summary>
        /// <param name="BatchId"></param>
        /// <returns></returns>
        public List <PortStorageVehicleImportProp> GetPortStorageVehicleImportList(int BatchId)
        {
            CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

            try
            {
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    var query = (from qry in objAppWorksEntities.PortStorageVehiclesImports
                                 where qry.BatchID == BatchId
                                 orderby qry.PortStorageVehiclesImportID
                                 select new PortStorageVehicleImportProp
                    {
                        PortStorageVehiclesImportID = qry.PortStorageVehiclesImportID,
                        BatchId = qry.BatchID,
                        Vin = qry.VIN,
                        DateIn = qry.DateIn,
                        DealerCode = qry.DealerCode,
                        ModelYear = qry.ModelYear,
                        ModelName = qry.ModelName,
                        Color = qry.Color,
                        Location = qry.Location,
                        RecordStatus = qry.RecordStatus,
                    }
                                 ).AsQueryable();


                    return(query.ToList());
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
		internal MethodWrapper(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
			: base(declaringType, name, sig, modifiers, flags)
		{
			Profiler.Count("MethodWrapper");
			this.method = method;
			Debug.Assert(((returnType == null) == (parameterTypes == null)) || (returnType == PrimitiveTypeWrapper.VOID));
			this.returnTypeWrapper = returnType;
			this.parameterTypeWrappers = parameterTypes;
			if (Intrinsics.IsIntrinsic(this))
			{
				SetIntrinsicFlag();
			}
			UpdateNonPublicTypeInSignatureFlag();
		}
        /// <summary>
        /// This method is used to Load Batch list from database/
        /// </summary>
        /// <returns></returns>
        public List <PortStorageVehicleImportProp> LoadVehiclesBatchList(string Vin)
        {
            List <PortStorageVehicleImportProp> lstBatch = new List <PortStorageVehicleImportProp>();

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    ((IObjectContextAdapter)objAppWorksEntities).ObjectContext.CommandTimeout = 180;
                    string internalQuery = SqlConstants.VEHICLE_BATCH_LIST_ALL;
                    if (!string.IsNullOrEmpty(Vin))
                    {
                        internalQuery = string.Format(SqlConstants.VEHICLE_BATCH_LIST_SEARCH, Vin);
                    }
                    var sqlQuery     = objAppWorksEntities.Database.SqlQuery <PortStorageVehicleImportProp>(internalQuery);
                    var batchRecords = sqlQuery.GroupBy(grp => grp.BatchId).Select(x => new PortStorageVehicleImportProp
                    {
                        BatchId      = x.Key,
                        Vin          = x.FirstOrDefault().Vin,
                        BatchCount   = x.ToList().Count,
                        CreationDate = x.FirstOrDefault().CreationDate
                    }).OrderByDescending(x => x.BatchId);
                    return(batchRecords.ToList());
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            //return lstBatch;
        }
		protected virtual void DoLinkMethod()
		{
			method = this.DeclaringType.LinkMethod(this);
		}
        /// <summary>
        /// This method is used to Get Port Storage Import File Directory
        /// </summary>
        /// <returns>string</returns>
        public string GetPortStorageVehiclesImportFileDirectory()
        {
            string ImportFileDirectory = string.Empty;

            try
            {
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    var query = (from qry in objAppWorksEntities.SettingTables
                                 where qry.ValueKey.Equals("PortStorageReadDirectory")
                                 select new { ImportFileDirectory = qry.ValueDescription }).FirstOrDefault();
                    ImportFileDirectory = query.ImportFileDirectory;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(ImportFileDirectory);
        }
			internal InvokeArgsProcessor(MethodWrapper mw, MethodBase method, object original_obj, object[] original_args, [email protected] callerID)
			{
				TypeWrapper[] argTypes = mw.GetParameters();

				if(!mw.IsStatic && method.IsStatic && mw.Name != "<init>")
				{
					// we've been redirected to a static method, so we have to copy the 'obj' into the args
					object[] nargs = new object[original_args.Length + 1];
					nargs[0] = original_obj;
					original_args.CopyTo(nargs, 1);
					this.obj = null;
					this.args = nargs;
					for(int i = 0; i < argTypes.Length; i++)
					{
						if(!argTypes[i].IsUnloadable && argTypes[i].IsGhost)
						{
							object v = Activator.CreateInstance(argTypes[i].TypeAsSignatureType);
							argTypes[i].GhostRefField.SetValue(v, args[i + 1]);
							args[i + 1] = v;
						}
					}
				}
				else
				{
					this.obj = original_obj;
					this.args = original_args;
					for(int i = 0; i < argTypes.Length; i++)
					{
						if(!argTypes[i].IsUnloadable && argTypes[i].IsGhost)
						{
							if(this.args == original_args)
							{
								this.args = (object[])args.Clone();
							}
							object v = Activator.CreateInstance(argTypes[i].TypeAsSignatureType);
							argTypes[i].GhostRefField.SetValue(v, args[i]);
							this.args[i] = v;
						}
					}
				}

				if(mw.HasCallerID)
				{
					object[] nargs = new object[args.Length + 1];
					Array.Copy(args, nargs, args.Length);
					nargs[args.Length] = callerID;
					args = nargs;
				}
			}
示例#60
0
 public static bool MustDocumentMethod(MethodBase method)
 {
     // All other methods
     return(method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly);
 }