当前位置: 首页>>代码示例>>C#>>正文


C# ResolveContext类代码示例

本文整理汇总了C#中ResolveContext的典型用法代码示例。如果您正苦于以下问题:C# ResolveContext类的具体用法?C# ResolveContext怎么用?C# ResolveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResolveContext类属于命名空间,在下文中一共展示了ResolveContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoResolve

        protected override Expression DoResolve(ResolveContext ec)
        {
            //
            // It's null when lifting non-nullable type
            //
            if (unwrap == null) {
                // S -> T? is wrap only
                if (TypeManager.IsNullableType (type))
                    return Wrap.Create (expr, type);

                // S -> T can be simplified
                return expr;
            }

            // Wrap target for T?
            if (TypeManager.IsNullableType (type)) {
                expr = Wrap.Create (expr, type);
                if (expr == null)
                    return null;

                null_value = LiftedNull.Create (type, loc);
            } else {
                null_value = new NullConstant (type, loc);
            }

            eclass = ExprClass.Value;
            return this;
        }
开发者ID:speier,项目名称:shake,代码行数:28,代码来源:nullable.cs

示例2: ResolveField

        object ResolveField(FieldInfo fieldInfo, ResolveContext context, ZenUtil.InjectInfo injectInfo)
        {
            var desiredType = fieldInfo.FieldType;
            var valueObj = _container.TryResolve(desiredType, context);

            if (valueObj == null)
            {
                // If it's a list it might map to a collection
                if (ReflectionUtil.IsGenericList(desiredType))
                {
                    var subTypes = desiredType.GetGenericArguments();

                    if (subTypes.Length == 1)
                    {
                        var subType = subTypes[0];

                        // Dependencies that are lists are only optional if declared as such using the inject attribute
                        bool optional = (injectInfo == null ? false : injectInfo.Optional);

                        valueObj = _container.ResolveMany(subType, context, optional);
                    }
                }
            }

            return valueObj;
        }
开发者ID:hyakugei,项目名称:Zenject,代码行数:26,代码来源:PropertiesInjecter.cs

示例3: CreateDelegateType

		public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
		{
			Namespace type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);
			if (type_ns == null) {
				return null;
			}
			if (returnType == rc.BuiltinTypes.Void) {
				var actArgs = parameters.Types;
				var actionSpec = type_ns.LookupType (rc.Module, "Action", actArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (actionSpec == null) {
					return null;
				}
				if (actArgs.Length == 0)
					return actionSpec;
				else
					return actionSpec.MakeGenericType(rc, actArgs);
			} else {
				TypeSpec[] funcArgs = new TypeSpec[parameters.Types.Length + 1];
				parameters.Types.CopyTo(funcArgs, 0);
				funcArgs[parameters.Types.Length] = returnType;
				var funcSpec = type_ns.LookupType (rc.Module, "Func", funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (funcSpec == null)
					return null;
				return funcSpec.MakeGenericType(rc, funcArgs);
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:26,代码来源:delegate.cs

示例4: ImplicitConversionRequired

		public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type, Location loc)
		{
			Constant c = ConvertImplicitly (type);
			if (c == null)
				Error_ValueCannotBeConverted (ec, type, false);

			return c;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:8,代码来源:constant.cs

示例5: Error_MemberLookupFailed

			protected override Expression Error_MemberLookupFailed (ResolveContext ec, Type container_type, Type qualifier_type,
				Type queried_type, string name, string class_name, MemberTypes mt, BindingFlags bf)
			{
				ec.Report.Error (1935, loc, "An implementation of `{0}' query expression pattern could not be found. " +
					"Are you missing `System.Linq' using directive or `System.Core.dll' assembly reference?",
					name);
				return null;
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:linq.cs

示例6: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			var results = new List<string> ();

			ec.CurrentMemberDefinition.GetCompletionStartingWith (Prefix, results);

			throw new CompletionResult (Prefix, results.Distinct ().Select (l => l.Substring (Prefix.Length)).ToArray ());
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:8,代码来源:complete.cs

示例7: Resolve

        public override object Resolve(ResolveContext context, DependencyRegistration registration)
        {
            if (registration.RegistrationKind == RegistrationKind.FactoryFunction)
            {
                return registration.FactoryFunction(context.Resolver);
            }

            return context.Builder.CreateObject(registration);
        }
开发者ID:AnthonySteele,项目名称:openrasta-core,代码行数:9,代码来源:TransientLifetimeManager.cs

示例8: Error_ValueCannotBeConverted

		public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl)
		{
			if (!expl && IsLiteral && 
				BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) &&
				BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) {
				ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
					GetValueAsLiteral (), TypeManager.CSharpName (target));
			} else {
				base.Error_ValueCannotBeConverted (ec, target, expl);
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:11,代码来源:constant.cs

示例9: Resolve

 public object Resolve(ResolveContext context)
 {
     if (_instance == null)
     {
         lock (this)
         {
             if (_instance == null)
             {
                 _instance = _innerResolver.Resolve(context);
             }
         }
     }
     return _instance;
 }
开发者ID:ArturD,项目名称:Daemons,代码行数:14,代码来源:SingletonLifetimeResolverWrapper.cs

示例10: DoResolve

		public override Expression DoResolve (ResolveContext ec)
		{
			int counter = QueryBlock.TransparentParameter.Counter;

			Expression e = BuildQueryClause (ec, null);
			e = e.Resolve (ec);

			//
			// Reset counter in probing mode to ensure that all transparent
			// identifier anonymous types are created only once
			//
			if (ec.IsInProbingMode)
				QueryBlock.TransparentParameter.Counter = counter;

			return e;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:16,代码来源:linq.cs

示例11: Inject

        public void Inject(object injectable)
        {
            Assert.That(injectable != null);

            var fields = ZenUtil.GetFieldDependencies(injectable.GetType());

            var parentDependencies = new List<Type>(_container.LookupsInProgress);

            foreach (var fieldInfo in fields)
            {
                var injectInfo = ZenUtil.GetInjectInfo(fieldInfo);
                Assert.That(injectInfo != null);

                bool foundAdditional = false;
                foreach (object obj in _additional)
                {
                    if (fieldInfo.FieldType.IsAssignableFrom(obj.GetType()))
                    {
                        fieldInfo.SetValue(injectable, obj);
                        _additional.Remove(obj);
                        foundAdditional = true;
                        break;
                    }
                }
                if (foundAdditional)
                {
                    continue;
                }

                var context = new ResolveContext()
                {
                    Target = injectable.GetType(),
                    FieldName = fieldInfo.Name,
                    Name = injectInfo.Name,
                    Parents = parentDependencies,
                    TargetInstance = injectable,
                };

                var valueObj = ResolveField(fieldInfo, context, injectInfo);

                Assert.That(valueObj != null || injectInfo.Optional, () =>
                        "Unable to find field with type '" + fieldInfo.FieldType +
                        "' when injecting dependencies into '" + injectable + "'. \nObject graph:\n" + _container.GetCurrentObjectGraph());

                fieldInfo.SetValue(injectable, valueObj);
            }
        }
开发者ID:hyakugei,项目名称:Zenject,代码行数:47,代码来源:PropertiesInjecter.cs

示例12: DoBinaryNumericPromotions

		//
		// Performs the numeric promotions on the left and right expresions
		// and deposits the results on `lc' and `rc'.
		//
		// On success, the types of `lc' and `rc' on output will always match,
		// and the pair will be one of:
		//
		// TODO: BinaryFold should be called as an optimization step only,
		// error checking here is weak
		//		
		static bool DoBinaryNumericPromotions (ResolveContext rc, ref Constant left, ref Constant right)
		{
			TypeSpec ltype = left.Type;
			TypeSpec rtype = right.Type;

			foreach (TypeSpec t in rc.BuiltinTypes.BinaryPromotionsTypes) {
				if (t == ltype)
					return t == rtype || ConvertPromotion (rc, ref right, ref left, t);

				if (t == rtype)
					return t == ltype || ConvertPromotion (rc, ref left, ref right, t);
			}

			left = left.ConvertImplicitly (rc.BuiltinTypes.Int);
			right = right.ConvertImplicitly (rc.BuiltinTypes.Int);
			return left != null && right != null;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:27,代码来源:cfold.cs

示例13: ConvertPromotion

		static bool ConvertPromotion (ResolveContext rc, ref Constant prim, ref Constant second, TypeSpec type)
		{
			Constant c = prim.ConvertImplicitly (type);
			if (c != null) {
				prim = c;
				return true;
			}

			if (type.BuiltinType == BuiltinTypeSpec.Type.UInt) {
				type = rc.BuiltinTypes.Long;
				prim = prim.ConvertImplicitly (type);
				second = second.ConvertImplicitly (type);
				return prim != null && second != null;
			}

			return false;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:17,代码来源:cfold.cs

示例14: Error_ValueCannotBeConverted

		public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec t, bool expl)
		{
			if (t.IsGenericParameter) {
				ec.Report.Error(403, loc,
					"Cannot convert null to the type parameter `{0}' because it could be a value " +
					"type. Consider using `default ({0})' instead", t.Name);
				return;
			}

			if (TypeSpec.IsValueType (t)) {
				ec.Report.Error(37, loc, "Cannot convert null to `{0}' because it is a value type",
					TypeManager.CSharpName(t));
				return;
			}

			base.Error_ValueCannotBeConverted (ec, t, expl);
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:17,代码来源:literal.cs

示例15: BuildQueryClause

        public virtual Expression BuildQueryClause(ResolveContext ec, Expression lSide)
        {
            Arguments args;
            CreateArguments (ec, out args);
            lSide = CreateQueryExpression (lSide, args);
            if (next != null) {
                Select s = next as Select;
                if (s == null || s.IsRequired)
                    return next.BuildQueryClause (ec, lSide);

                // Skip transparent select clause if any clause follows
                if (next.next != null)
                    return next.next.BuildQueryClause (ec, lSide);
            }

            return lSide;
        }
开发者ID:speier,项目名称:shake,代码行数:17,代码来源:linq.cs


注:本文中的ResolveContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。