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


C# Dynamic.SetIndexBinder类代码示例

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



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

示例1: BindSetIndex

        public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
            //
            // Demand Full Trust to proceed with the binding.
            //

            new PermissionSet(PermissionState.Unrestricted).Demand();

            ComMethodDesc method;
            var target = _callable.DispatchComObject;
            var name = _callable.MemberName;

            bool holdsNull = value.Value == null && value.HasValue;
            if (target.TryGetPropertySetter(name, out method, value.LimitType, holdsNull) ||
                target.TryGetPropertySetterExplicit(name, out method, value.LimitType, holdsNull)) {

                bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref indexes);
                isByRef = isByRef.AddLast(false);
                var result = BindComInvoke(method, indexes.AddLast(value), binder.CallInfo, isByRef);

                // Make sure to return the value; some languages need it.
                return new DynamicMetaObject(
                    Expression.Block(result.Expression, Expression.Convert(value.Expression, typeof(object))),
                    result.Restrictions
                );
            }

            return base.BindSetIndex(binder, indexes, value);
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:28,代码来源:DispCallableMetaObject.cs


示例2: TrySetIndex

 public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
 {
     // The indexed property is always named "Item" in C#
     IProperty prop = GetIndexProperty();
     prop.SetValue(RealObject, value, indexes);
     return true;
 }
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:7,代码来源:PrivateReflectionDynamicObject.cs


示例3: TrySetIndex

 public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) {
     string key = GetKey(indexes);
     if (!String.IsNullOrEmpty(key)) {
         _values[key] = Json.WrapObject(value);
     }
     return true;
 }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:7,代码来源:DynamicJsonObject.cs


示例4: BindSetIndex

        public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
        {
            ComMethodDesc method;
            var target = _callable.DispatchComObject;
            var name = _callable.MemberName;

            bool holdsNull = value.Value == null && value.HasValue;
            if (target.TryGetPropertySetter(name, out method, value.LimitType, holdsNull) ||
                target.TryGetPropertySetterExplicit(name, out method, value.LimitType, holdsNull))
            {
                List<ParameterExpression> temps = new List<ParameterExpression>();
                List<Expression> initTemps = new List<Expression>();

                bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(method, ref indexes, temps, initTemps);
                isByRef = isByRef.AddLast(false);

                // Convert the value to the target type
                DynamicMetaObject updatedValue = new DynamicMetaObject(value.CastOrConvertMethodArgument(
                                value.LimitType,
                                name,
                                "SetIndex",
                                temps,
                                initTemps), value.Restrictions);

                var result = BindComInvoke(method, indexes.AddLast(updatedValue), binder.CallInfo, isByRef, temps, initTemps);

                // Make sure to return the value; some languages need it.
                return new DynamicMetaObject(
                    Expression.Block(result.Expression, Expression.Convert(value.Expression, typeof(object))),
                    result.Restrictions
                );
            }

            return base.BindSetIndex(binder, indexes, value);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:35,代码来源:DispCallableMetaObject.cs


示例5: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
        {
            if (indexes.Length >= 1)
                dictionary[indexes[0].ToString()] = value;

            return true;
        }
开发者ID:Necat0r,项目名称:Automation,代码行数:7,代码来源:SettingsObject.cs


示例6: TrySetIndex

        // Set the property value by index.
        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) {
            if (typeof(long).IsAssignableFrom(indexes[0].GetType())) {
                Values[(long)indexes[0]] = SConvert.ToSettings(value);
                return true;
            }

            return false;
        }
开发者ID:sjbisch,项目名称:Orchard,代码行数:9,代码来源:SArray.cs


示例7: TrySetIndex

 public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
 {
     if (indexes == null)
         throw new ArgumentNullException("indexes");
     if (indexes.Length != 1)
         throw new ArgumentException("Only support a single indexer parameter", "indexes");
     _dictionary[indexes[0]] = value;
     return true;
 }
开发者ID:DelLitt,项目名称:opmscoral,代码行数:9,代码来源:HashtableDynamicObject.cs


示例8: TrySetIndex

            public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
            {
                if (indexes.Length == 1 && indexes[0] is string)
                {
                    return this.TrySetMember((string)indexes[0], value);
                }

                return base.TrySetIndex(binder, indexes, value);
            }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:9,代码来源:VsProject.SpecificConfigurationAndPlatformProperties.cs


示例9: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
        {
            if (!(indexes[0] is string))
            {
                return false;
            }

            _members[indexes[0] as string] = new MemberDescription(indexes[0] as string, value, new Type[] { });
            return true;
        }
开发者ID:jonneale,项目名称:Egg,代码行数:10,代码来源:ExtendedDynamicObject.cs


示例10: TrySetIndex

		public bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value, TrySetIndexDelegate baseTrySetIndex)
		{
			if (indexes.Length > 1 || !(indexes[0] is string))
				return baseTrySetIndex(binder, indexes, value);

			var propertyName = (string)indexes[0];

			if (!accessor.TrySetProperty(propertyName, value))
				return baseTrySetIndex(binder, indexes, value);

			return true;
		}
开发者ID:MobileEssentials,项目名称:clide,代码行数:12,代码来源:DynamicPropertyAccessor.cs


示例11: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
        {
            if (indexes == null || indexes.Length != 1)
            {
                throw new ArgumentException("Invalid number of indexes");
            }

            object index = indexes[0];
            // This cast should always succeed assuming TValue is dynamic.
            this[(string)index] = value;
            return true;
        }
开发者ID:464884492,项目名称:Mvc,代码行数:12,代码来源:ViewData.cs


示例12: TrySetIndex

 public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
 {
     if (indexes[0] is string)
       {
     var key = indexes[0] as string;
     UpdateDictionary(key, value);
     return true;
       }
       else
       {
     return base.TrySetIndex(binder, indexes, value);
       }
 }
开发者ID:niemandr,项目名称:champ,代码行数:13,代码来源:BetterExpando.cs


示例13: TrySetIndex

 public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
 {
     var token = JToken.FromObject(value);
     var i = (int)indexes[0];
     if (i >= array.Count)
     {
         while (array.Count != i)
             array.Add(null);
         array.Add(token);
     }
     else
         array[i] = token;
     return true;
 }
开发者ID:Thinking-Beard,项目名称:civilsalary,代码行数:14,代码来源:DynamicJsonArray.cs


示例14: BindSetIndex

        public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
            ComMethodDesc method;
            var target = _callable.DispatchComObject;
            var name = _callable.MemberName;

            bool holdsNull = value.Value == null && value.HasValue;
            if (target.TryGetPropertySetter(name, out method, value.LimitType, holdsNull) ||
                target.TryGetPropertySetterExplicit(name, out method, value.LimitType, holdsNull)) {

                bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref indexes);
                isByRef = isByRef.AddLast(false);
                return BindComInvoke(method, indexes.AddLast(value), binder.CallInfo, isByRef);
            }

            return base.BindSetIndex(binder, indexes, value);
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:16,代码来源:DispCallableMetaObject.cs


示例15: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
        {
            string index = ((string)indexes[0]).ToLower();
            Logger.Debug("TrySetIndex For " + index);

            if (_dictionary.ContainsKey(index))
            {
                _dictionary[index] = value;
            }
            else
            {
                _dictionary.Add(index, value);
            }

            return true;
        }
开发者ID:alex-klock,项目名称:razor-mediator-4-tridion,代码行数:16,代码来源:DynamicDictionary.cs


示例16: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) {
            if (indexes == null || indexes.Length != 1) {
                throw new ArgumentException(WebPageResources.DynamicDictionary_InvalidNumberOfIndexes);
            }

            string key = indexes[0] as string;
            if (key != null) {
                _state[key] = value;
                return true;
            }
            else {
                // HttpApplicationState only supports keys of type string when setting values, so any attempt 
                // to use other types will result in an error. We throw an exception here to explain to the user what is wrong.
                // Returning false will instead cause a runtime binder error which might be confusing to the user.
                throw new ArgumentException(WebPageResources.DynamicHttpApplicationState_UseOnlyStringToSet);
            }
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:17,代码来源:DynamicHttpApplicationState.cs


示例17: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) {
            if (indexes.Count() != 1) {
                return base.TrySetIndex(binder, indexes, value);
            }

            var index = indexes.Single();

            // try to access an existing member
            var strinIndex = index as string;

            if (strinIndex != null && TrySetMemberImpl(strinIndex, value)) {
                return true;
            }

            _props[indexes.Single()] = value;
            return true;
        }
开发者ID:Timbioz,项目名称:SciTechTest,代码行数:17,代码来源:Composite.cs


示例18: BindSetIndex

        public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
            if (indexes.Any(arg => ComBinderHelpers.IsStrongBoxArg(arg))) {
                return ComBinderHelpers.RewriteStrongBoxAsRef(binder, this, indexes.AddLast(value), true);
            }

            ComMethodDesc method;
            var target = _callable.DispatchComObject;
            var name = _callable.MemberName;

            if (target.TryGetPropertySetter(name, out method, value.LimitType) ||
                target.TryGetPropertySetterExplicit(name, out method, value.LimitType)) {

                return BindComInvoke(method, indexes.AddLast(value), binder.Arguments);
            }

            return base.BindSetIndex(binder, indexes, value);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:17,代码来源:DispCallableMetaObject.cs


示例19: BindSetIndex

        public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
            ComMethodDesc method;
            var target = _callable.DispatchComObject;
            var name = _callable.MemberName;

            bool holdsNull = value.Value == null && value.HasValue;
            if (target.TryGetPropertySetter(name, out method, value.LimitType, holdsNull) ||
                target.TryGetPropertySetterExplicit(name, out method, value.LimitType, holdsNull)) {

                IList<ArgumentInfo> argInfos = binder.Arguments;
                ComBinderHelpers.ProcessArgumentsForCom(ref indexes, ref argInfos);
                // add an arginfo for the value
                argInfos = argInfos.AddLast(Expression.PositionalArg(argInfos.Count));

                return BindComInvoke(method, indexes.AddLast(value), argInfos);
            }

            return base.BindSetIndex(binder, indexes, value);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:19,代码来源:DispCallableMetaObject.cs


示例20: TrySetIndex

        public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
        {
            var index = indexes.FirstOrDefault();

            if (index == null)
                return false;

            Attempt attempt;
            var s = index as string;
            if (s != null)
            {
                attempt = Attempt.Do(() => _row[s] = value);
            }
            else
            {
                var isInt = index.AttemptGet(Convert.ToInt32);
                if (isInt.Succeeded)
                    attempt = Attempt.Do(() => _row[isInt.Value] = value);
                else return false;
            }

            return attempt.Succeeded;
        }
开发者ID:thomas-parrish,项目名称:Common,代码行数:23,代码来源:DynamicDataRow.cs



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