当前位置: 首页>>代码示例>>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;未经允许,请勿转载。