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


C# Dynamic.SetMemberBinder類代碼示例

本文整理匯總了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;
    }
開發者ID:ajayumi,項目名稱:Jumony,代碼行數:28,代碼來源:DynamicElement.cs

示例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;
			}
開發者ID:JIANGSHUILANG,項目名稱:TestSelfblog,代碼行數:27,代碼來源:DynamicDictionary.cs

示例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;
   }
 }
開發者ID:TLevitt,項目名稱:DryLogic,代碼行數:29,代碼來源:DryLogicProxy.cs

示例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;
        }
開發者ID:TheEvilDev,項目名稱:ConfigurationFx,代碼行數:25,代碼來源:DynamicXmlNode.cs

示例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;
        }
開發者ID:alphaleonis,項目名稱:AlphaVSX,代碼行數:33,代碼來源:ProjectProperties.cs

示例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;
 }
開發者ID:J4S0Nc,項目名稱:Useful.Utilities,代碼行數:7,代碼來源:DynamicRow.cs

示例7: TrySetMember

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            viewData[binder.Name] = value;
            HttpContext.Current.Items[this.GetType()] = this;

            return true;
        }
開發者ID:rexwhitten,項目名稱:Siege,代碼行數:7,代碼來源:ViewModel.cs

示例8: TrySetMember

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            Console.WriteLine("TrySetMember");

            new IHTMLPre { innerText = "TrySetMember: " + new { value } }.AttachToDocument();
            return true;
        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:7,代碼來源:Application.cs

示例9: TrySetMember

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {

            InternalValues[binder.Name] = value;
            FirePropertyChanged(binder.Name);
            return true;
        }
開發者ID:NikolayKostadinov,項目名稱:TelerikAkademy,代碼行數:7,代碼來源:DynamicDictionary.cs

示例10: TrySetMember

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            var key = binder.Name;
            AddOrUpdateSetting(key, (string)value);

            return true;
        }
開發者ID:Code52,項目名稱:Ideastrike,代碼行數:7,代碼來源:Settings.cs

示例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;
 }
開發者ID:curtisrutland,項目名稱:RottenTomatoes.NET,代碼行數:7,代碼來源:DynamicJsonObject.cs

示例12: TrySetMember

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            var name = binder.Name;

            _properties[name] = value;
            return true;
        }
開發者ID:gregnehus,項目名稱:MalleableObject,代碼行數:7,代碼來源:MalleableObject.cs

示例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;
        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:35,代碼來源:WebGLDynamicUniforms.cs

示例14: TrySetMember

 public override bool TrySetMember(SetMemberBinder binder, object value)
 {
     _data[binder.Name] = value;
     OnPropertyChanged(binder.Name);
     OnPropertyChanged("");
     return true;
 }
開發者ID:expanz,項目名稱:expanz-Microsoft-XAML-SDKs,代碼行數:7,代碼來源:DynamicDataObject.cs

示例15: TrySetMember

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            string propertyName = binder.Name;
            this.dictionary[propertyName] = value;

            return true;
        }
開發者ID:Motaz-Al-Zoubi,項目名稱:xaml-sdk,代碼行數:7,代碼來源:DynamicDataObject.cs


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