本文整理汇总了C#中System.Dynamic.SetMemberBinder类的典型用法代码示例。如果您正苦于以下问题:C# SetMemberBinder类的具体用法?C# SetMemberBinder怎么用?C# SetMemberBinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SetMemberBinder类属于System.Dynamic命名空间,在下文中一共展示了SetMemberBinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrySetMember
public override bool TrySetMember( SetMemberBinder binder, object value )
{
string str = value as string;
if ( str != null )
{
switch ( binder.Name )
{
case "tagName":
throw new NotSupportedException( "元素名不能被修改" );
case "innerText":
Element.InnerText( str );
return true;
case "innerHTML":
Element.InnerHtml( str );
return true;
}
Element.SetAttribute( binder.Name, str );
}
return false;
}
示例2: BindSetMember
public override DynamicMetaObject BindSetMember(SetMemberBinder binder,
DynamicMetaObject value)
{
// Method to call in the containing class:
string methodName = "SetDictionaryEntry";
// setup the binding restrictions.
BindingRestrictions restrictions =
BindingRestrictions.GetTypeRestriction(Expression, LimitType);
// setup the parameters:
Expression[] args = new Expression[2];
// First parameter is the name of the property to Set
args[0] = Expression.Constant(binder.Name);
// Second parameter is the value
args[1] = Expression.Convert(value.Expression, typeof(object));
// Setup the 'this' reference
Expression self = Expression.Convert(Expression, base.LimitType);
// Setup the method call expression
Expression methodCall = Expression.Call(self,
typeof(DynamicDictionary).GetMethod(methodName),
args);
// Create a meta object to invoke Set later:
DynamicMetaObject setDictionaryEntry = new DynamicMetaObject(
methodCall,
restrictions);
// return that dynamic object
return setDictionaryEntry;
}
示例3: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
//if this is not a DomainProperty...
if (!objectInstance.ObjectDefinition.Properties.ContainsKey(binder.Name))
{
//...try to set it as a normal property
PropertyInfo propInfo = this.proxiedObject.GetType().GetProperty(binder.Name);
if (propInfo != null)
{
propInfo.SetValue(this.proxiedObject, value, null);
return true;
}
else //property not found.
{
if (Debugger.IsAttached)
{
Debug.WriteLine("BOVProxy TrySetMember failed: Property '{0}' could not be found on object '{1}'", binder.Name, objectInstance.ObjectDefinition.SystemName);
}
return false;
}
}
else
{
var propertyDefinition = objectInstance.ObjectDefinition.Properties[binder.Name];
var propertyValue = propertyDefinition.GetUntypedValue(objectInstance);
propertyValue.StringValue = value.ToString();
return true;
}
}
示例4: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
if (value.GetType().IsValueType || value is string)
{
var existing = Attributes.FirstOrDefault(a => a.Name.LocalName.EqualsIgnoreCase(binder.Name));
if (existing != null)
{
Attributes.Remove(existing);
}
Attributes.Add(new XAttribute(binder.Name, value));
}
var element = Elements.FirstOrDefault(a => a.Name.EqualsIgnoreCase(binder.Name));
if (element != null)
{
Elements.Remove(element);
}
Elements.Add(Serialize(value));
return true;
}
示例5: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
if (value == null)
throw new NotSupportedException("Cannot set null value for item properties.");
if (dteProject != null)
{
Property property;
try
{
property = dteProject?.Value?.Properties.Item(binder.Name);
}
catch (ArgumentException)
{
property = null;
}
if (property != null)
{
try
{
property.Value = value;
return true;
}
catch
{
return false;
}
}
}
return false;
}
示例6: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
var retVal = _row.Table.Columns.Contains(binder.Name);
if (retVal)
_row[binder.Name] = value;
return retVal;
}
示例7: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
viewData[binder.Name] = value;
HttpContext.Current.Items[this.GetType()] = this;
return true;
}
示例8: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
Console.WriteLine("TrySetMember");
new IHTMLPre { innerText = "TrySetMember: " + new { value } }.AttachToDocument();
return true;
}
示例9: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
InternalValues[binder.Name] = value;
FirePropertyChanged(binder.Name);
return true;
}
示例10: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
var key = binder.Name;
AddOrUpdateSetting(key, (string)value);
return true;
}
示例11: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value) {
if (!jsonObject.ContainsKey(binder.Name))
jsonObject.Add(binder.Name, (dynamic)value);
else
jsonObject[binder.Name] = (dynamic)value;
return true;
}
示例12: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
var name = binder.Name;
_properties[name] = value;
return true;
}
示例13: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
// cache location
// this class if for floats. ints will need their own class
var isvec2 = value is __vec2;
if (isvec2)
{
var value_vec2 = (__vec2)value;
gl.uniform2f(
gl.getUniformLocation(program, binder.Name),
value_vec2
);
return true;
}
var isvec3 = value is __vec3;
if (isvec3)
{
var value_vec3 = (__vec3)value;
gl.uniform3f(
gl.getUniformLocation(program, binder.Name),
value_vec3
);
return true;
}
gl.uniform1f(gl.getUniformLocation(program, binder.Name), (float)value);
return true;
}
示例14: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
_data[binder.Name] = value;
OnPropertyChanged(binder.Name);
OnPropertyChanged("");
return true;
}
示例15: TrySetMember
public override bool TrySetMember(SetMemberBinder binder, object value)
{
string propertyName = binder.Name;
this.dictionary[propertyName] = value;
return true;
}