本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
示例5: TrySetIndex
public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
{
if (indexes.Length >= 1)
dictionary[indexes[0].ToString()] = value;
return true;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}