當前位置: 首頁>>代碼示例>>C#>>正文


C# Dynamic.SetIndexBinder類代碼示例

本文整理匯總了C#中System.Dynamic.SetIndexBinder的典型用法代碼示例。如果您正苦於以下問題:C# SetIndexBinder類的具體用法?C# SetIndexBinder怎麽用?C# SetIndexBinder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SetIndexBinder類屬於System.Dynamic命名空間,在下文中一共展示了SetIndexBinder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.Dynamic.SetIndexBinder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。