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


C# Dynamic.GetMemberBinder類代碼示例

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


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

示例1: TryGetMember

        /// <summary>
        /// Finds text resource
        /// </summary>
        /// <param name="binder">GetMemberBinder with dynamic text key</param>
        /// <param name="result">Text item</param>
        /// <returns>Returns a value or a non existing value from the <see cref="ITextResource"/> implementation</returns>
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result =
                new DynamicMemberChainer(binder.Name, this.context, this.textResource);

            return true;
        }
開發者ID:Borzoo,項目名稱:Nancy,代碼行數:13,代碼來源:TextResourceFinder.cs

示例2: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = Repository.FindModel(binder.Name);

            //result = string.Format("{{ Site.{0} }}", binder.Name); //default result;
            return true;
        }
開發者ID:mlouage,項目名稱:Prototypr,代碼行數:7,代碼來源:Site.cs

示例3: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (!_dictionary.TryGetValue(binder.Name, out result))
            {
                // return null to avoid exception.  caller can check for null this way...
                result = null;
                return true;
            }

            var dictionary = result as IDictionary<string, object>;
            if (dictionary != null)
            {
                result = new DictionaryObject(dictionary);
                return true;
            }

            var arrayList = result as ArrayList;
            if (arrayList != null && arrayList.Count > 0)
            {
                if (arrayList[0] is IDictionary<string, object>)
                    result = new List<object>(arrayList.Cast<IDictionary<string, object>>().Select(x => new DictionaryObject(x)));
                else
                    result = new List<object>(arrayList.Cast<object>());
            }

            return true;
        }
開發者ID:yangwen27,項目名稱:moonlit,代碼行數:27,代碼來源:DictionaryObject.cs

示例4: TryGetMember

        /// <summary>
        /// Returns a value from the current DataReader record
        /// If the field doesn't exist null is returned.
        /// DbNull values are turned into .NET nulls.
        /// </summary>
        /// <param name="binder"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = null;

            // 'Implement' common reader properties directly
            if (binder.Name == "IsClosed")
                result = DataReader.IsClosed;
            else if (binder.Name == "RecordsAffected")
                result = DataReader.RecordsAffected;
            // lookup column names as fields
            else
            {
                try
                {
                    result = DataReader[binder.Name];
                    if (result == DBNull.Value)
                        result = null;
                }
                catch
                {
                    result = null;
                    return false;
                }
            }

            return true;
        }
開發者ID:Mr0Cake,項目名稱:Permission-Granter,代碼行數:35,代碼來源:DynamicDataReader.cs

示例5: TryGetMember

            public override bool TryGetMember(GetMemberBinder binder, out object result)
            {
                if (!this.dictionary.TryGetValue(binder.Name, out result))
                {
                    result = null;
                    return true;
                }

                var dictionary = result as IDictionary<string, object>;
                if (dictionary != null)
                {
                    result = new DynamicJsonObject(dictionary);
                    return true;
                }

                var arrayList = result as ArrayList;
                if (arrayList != null)
                {
                    if (arrayList.Count > 0 && arrayList[0] is IDictionary<string, object>)
                        result = new List<object>(arrayList.Cast<IDictionary<string, object>>().Select(x => new DynamicJsonObject(x)));
                    else
                        result = new List<object>(arrayList.Cast<object>());
                }

                return true;
            }
開發者ID:krsnaa,項目名稱:m2x-dot-net,代碼行數:26,代碼來源:DynamicJsonConverter.cs

示例6: TryGetMember

 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     //return base.TryGetMember(binder, out result);
       CurrentList = CurrentList ??  new BiggyList<dynamic>(dbName: binder.Name);
       result = CurrentList;
       return true;
 }
開發者ID:phaufe,項目名稱:biggy,代碼行數:7,代碼來源:BiggyDB.cs

示例7: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (_dictionary.TryGetValue(binder.Name, out result) == false)
                if (_dictionary.TryGetValue(binder.Name.ToLower(), out result) == false)
                    return false;// throw new Exception("property not found " + binder.Name);

            if (result is IDictionary<string, object>)
            {
                result = new DynamicJson(result as IDictionary<string, object>);
            }
            else if (result is List<object>)
            {
                List<object> list = new List<object>();
                foreach (object item in (List<object>)result)
                {
                    if (item is IDictionary<string, object>)
                        list.Add(new DynamicJson(item as IDictionary<string, object>));
                    else
                        list.Add(item);
                }
                result = list;
            }

            return _dictionary.ContainsKey(binder.Name);
        }
開發者ID:joonhwan,項目名稱:NPoco,代碼行數:25,代碼來源:dynamic.cs

示例8: BindGetMember

        public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
            ContractUtils.RequiresNotNull(binder, "binder");
            string name = binder.Name;

            if (name == _info.Name) {
                name = "TypeLibDesc";
            } else if (name != "Guid" &&
                name != "Name" &&
                name != "VersionMajor" &&
                name != "VersionMinor") {

                return binder.FallbackGetMember(this);
            }

            return new DynamicMetaObject(
                Expression.Convert(
                    Expression.Property(
                        AstUtils.Convert(Expression, typeof(ComTypeLibInfo)),
                        typeof(ComTypeLibInfo).GetProperty(name)
                    ),
                    typeof(object)
                ),
                ComTypeLibInfoRestrictions(this)
            );
        }
開發者ID:Hank923,項目名稱:ironruby,代碼行數:25,代碼來源:TypeLibInfoMetaObject.cs

示例9: TryGetMember

 public override bool TryGetMember(
     GetMemberBinder binder, out object result)
 {
     result = null;
     if (binder.Name == "Value")
         result = _elements[0].Value;
     else if (binder.Name == "Count")
         result = _elements.Count;
     else
     {
         var attr = _elements[0].Attribute(
             XName.Get(binder.Name ) );
         if (attr != null)
             result = attr.Value;
         else
         {
             var items = _elements.Descendants(
                 XName.Get(binder.Name ) );
             if (items == null || items.Count() == 0)
                 return false;
             result = new DynamicXml( items );
         }
     }
     return true;
 }
開發者ID:meadiagenic,項目名稱:DraftTracker,代碼行數:25,代碼來源:DynamicXml.cs

示例10: TryGetMember

 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     try
     {
         Variable variable;
         if(!variables.TryGetValue(binder.Name, out variable))
         {
             int idx = GetGlobalVarIndexByName(binder.Name);
             var ptr = GetAddressOfGlobalVar(idx);
             if(ptr == IntPtr.Zero)
             {
                 result = null;
                 return true;
             }
             int tid;
             GetGlobalVar(idx, out tid);
             var instance = ScriptEngine.GetVariable(ptr, tid);
             variables[binder.Name] = variable = new Variable(instance, ptr, tid);
         }
         result = ScriptEngine.GetVariable(variable.Address, variable.TypeId, variable.Instance);
         return true;
     }
     catch(Exception ex)
     {
         ScriptEngine.Log ("Exception caught while fetching '{0}' variable of module '{1}': {2}.", binder.Name, Name, ex.Message);
         result = null;
         return false;
     }
 }
開發者ID:wladimiiir,項目名稱:vault112,代碼行數:29,代碼來源:ScriptModule.cs

示例11: TryGetMember

 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     var child = elementFactory.CreateElementWithNameForParent(binder.Name, element);
     element.AddChild(child);
     result = DynamicElementFor(child);
     return true;
 }
開發者ID:baks,項目名稱:Simple.Xml,代碼行數:7,代碼來源:DynamicElement.cs

示例12: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (binder.Name == "__Fields")
            {
                result = (from field in m_type.Fields where field.Type != null select new { Name = field.Name, Type = field.Type.Name }).ToArray();
                return true;
            }
            if (binder.Name == "__StaticFields")
            {
                result = (from field in m_type.StaticFields where field.Type != null select new { Name = field.Name, Type = field.Type.Name }).ToArray();
                return true;
            }
            if (binder.Name == "__ThreadStaticFields")
            {
                result = (from field in m_type.ThreadStaticFields where field.Type != null select new { Name = field.Name, Type = field.Type.Name }).ToArray();
                return true;
            }
            if (binder.Name == "__Name")
            {
                result = m_type.Name;
                return true;
            }

            if (GetStaticField(m_heap, m_type, binder, out result))
                return true;

            throw new InvalidOperationException(string.Format("Type '{0}' does not contain a static '{1}' field.", m_type.Name, binder.Name));
        }
開發者ID:goldshtn,項目名稱:msos,代碼行數:28,代碼來源:ClrDynamicClass.cs

示例13: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            var propertyInfo = m_type.GetProperty(
                binder.Name,
                BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);

            if (propertyInfo != null)
            {
                result = propertyInfo.GetValue(null, null);
                return true;
            }

            var fieldInfo = m_type.GetField(
                binder.Name,
                BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);

            if (fieldInfo != null)
            {
                result = fieldInfo.GetValue(null);
                return true;
            }

            result = null;
            return false;
        }
開發者ID:larsw,項目名稱:NSync,代碼行數:25,代碼來源:ExposedClass.cs

示例14: TryGetMember

 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     if (cache == null) CacheLoad();
     if (!cache.TryGetValue(binder.Name, out result))
         result = GetDefault(binder.ReturnType);
     return true;
 }
開發者ID:coder0xff,項目名稱:Alterity,代碼行數:7,代碼來源:SessionData.cs

示例15: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            PropertyInfo propInfo = _realObject.GetType().GetProperty(binder.Name);

            if (propInfo == null) {
                PropertyInfo[] properties = _realObject.GetType().GetProperties();
                if (properties.Length == 0) {
                    throw new InvalidOperationException(
                        String.Format(CultureInfo.CurrentCulture,
                                      MvcResources.DynamicViewPage_NoProperties,
                                      binder.Name)
                    );
                }

                string propNames = properties.Select(p => p.Name)
                                             .OrderBy(name => name)
                                             .Aggregate((left, right) => left + ", " + right);

                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                                  MvcResources.DynamicViewPage_PropertyDoesNotExist,
                                  binder.Name,
                                  propNames)
                );

            }

            result = Wrap(propInfo.GetValue(_realObject, null));
            return true;
        }
開發者ID:jenrom,項目名稱:Spikes,代碼行數:30,代碼來源:DynamicReflectionObject.cs


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