• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDynamicMetaObjectProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDynamicMetaObjectProvider的典型用法代码示例。如果您正苦于以下问题:C# IDynamicMetaObjectProvider类的具体用法?C# IDynamicMetaObjectProvider怎么用?C# IDynamicMetaObjectProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDynamicMetaObjectProvider类属于命名空间,在下文中一共展示了IDynamicMetaObjectProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetMember

 internal static void SetMember(IDynamicMetaObjectProvider o, string name, object value)
 {
     CallSite<Action<CallSite, object, object>> site;
     if(!setSites.TryGetValue(name, out site)) {
         site = CallSite<Action<CallSite, object, object>>.Create(new DoHelpersSetMemberBinder(name));
         setSites.Add(name, site);
     }
     site.Target(site, o, value);
 }
开发者ID:Alxandr,项目名称:Totem-2.0,代码行数:9,代码来源:DynamicObjectHelpers.cs


示例2: IDOIndexSet

 internal static void IDOIndexSet(IDynamicMetaObjectProvider Instance, object[] Arguments, string[] ArgumentNames)
 {
     SaveCopyBack back = new SaveCopyBack(null);
     using (back)
     {
         object[] packedArgs = null;
         CallInfo callInfo = null;
         IDOUtils.PackArguments(1, ArgumentNames, Arguments, ref packedArgs, ref callInfo);
         IDOUtils.CreateFuncCallSiteAndInvoke(new VBIndexSetBinder(callInfo), Instance, packedArgs);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:IDOBinder.cs


示例3: TryGetMember

 internal bool TryGetMember(IDynamicMetaObjectProvider dynamicProvider, string name, out object value)
 {
     ValidationUtils.ArgumentNotNull(dynamicProvider, "dynamicProvider");
     var callSite = _callSiteGetters.Get(name);
     var result = callSite.Target(callSite, dynamicProvider);
     if (!ReferenceEquals(result, NoThrowExpressionVisitor.ErrorResult))
     {
         value = result;
         return true;
     }
     value = null;
     return false;
 }
开发者ID:sat1582,项目名称:CODEFramework,代码行数:13,代码来源:JsonDynamicContract.cs


示例4: ExecuteFileInScope

 // ExecuteFileInScope executes the file in the given module scope.  This
 // does NOT store the module scope on Globals.  This function returns
 // nothing.
 //
 public void ExecuteFileInScope(string filename,
                                IDynamicMetaObjectProvider moduleEO) {
     var f = new StreamReader(filename);
     // Simple way to convey script rundir for RuntimeHelpes.SymplImport
     // to load .sympl files.
     DynamicObjectHelpers.SetMember(moduleEO, "__file__", 
                                    Path.GetFullPath(filename));
     try {
         var moduleFun = ParseFileToLambda(filename, f);
         var d = moduleFun.Compile();
         d(this, moduleEO);
     } finally {
         f.Close();
     }
 }
开发者ID:TerabyteX,项目名称:main,代码行数:19,代码来源:Sympl.cs


示例5: ForwardingMetaObject

 public ForwardingMetaObject(
     Expression expression,
     BindingRestrictions restrictions,
     object forwarder,
     IDynamicMetaObjectProvider forwardee,
     Func<Expression, Expression> forwardeeGetter
     )
     : base(expression, restrictions, forwarder)
 {
     // We'll use forwardee's meta-object to bind dynamic operations.
     metaForwardee = forwardee.GetMetaObject(
         forwardeeGetter(
             Expression.Convert(expression, forwarder.GetType())   // [1]
         )
     );
 }
开发者ID:qujck,项目名称:MarkdownEditor,代码行数:16,代码来源:ForwardingMetaObject.cs


示例6: IDOGet

 internal static object IDOGet(IDynamicMetaObjectProvider Instance, string MemberName, object[] Arguments, string[] ArgumentNames, bool[] CopyBack)
 {
     object obj2;
     SaveCopyBack back = new SaveCopyBack(CopyBack);
     using (back)
     {
         object[] packedArgs = null;
         CallInfo callInfo = null;
         IDOUtils.PackArguments(0, ArgumentNames, Arguments, ref packedArgs, ref callInfo);
         try
         {
             return IDOUtils.CreateRefCallSiteAndInvoke(new VBGetBinder(MemberName, callInfo), Instance, packedArgs);
         }
         finally
         {
             IDOUtils.CopyBackArguments(callInfo, packedArgs, Arguments);
         }
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:IDOBinder.cs


示例7: ProtoTypalObjectWithMethods

 public ProtoTypalObjectWithMethods( IDynamicMetaObjectProvider prototype )
     : base(prototype)
 {
     StaticMethodWithNoReturnValueOrParametersWasCalled = false;
 }
开发者ID:larsw,项目名称:Archetype,代码行数:5,代码来源:ProtoTypalObjectWithMethods.cs


示例8: TheDude

 public TheDude( IDynamicMetaObjectProvider module )
     : base(module)
 {
 }
开发者ID:idavis,项目名称:Archetype,代码行数:4,代码来源:Person.cs


示例9: GetDynamicProperties

        private static PropertyReader[] GetDynamicProperties(IDynamicMetaObjectProvider provider)
        {
            var metaObject = provider.GetMetaObject(Expression.Constant(provider));

            var memberNames = metaObject.GetDynamicMemberNames(); // may return property names as well as method names, etc.

            var result = new List<PropertyReader>();

            foreach (var name in memberNames)
            {
                try
                {
                    var argumentInfo = new[] {CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)};

                    var binder = Binder.GetMember(CSharpBinderFlags.None, name, provider.GetType(), argumentInfo);

                    var site = CallSite<Func<CallSite, object, object>>.Create(binder);

                    var value = site.Target(site, provider); // will throw if no valid property getter

                    result.Add(new PropertyReader
                    {
                        Name = name,
                        DeclaringType = provider.GetType(),
                        Read = o => value
                    });
                }
                catch (RuntimeBinderException)
                {
                }
            }

            return result.ToArray();
        }
开发者ID:naraga,项目名称:DeepEqual,代码行数:34,代码来源:ReflectionCache.cs


示例10: Scope

 /// <summary>
 /// Creates a new scope which is backed by an arbitrary object for it's storage.
 /// </summary>
 /// <param name="storage"></param>
 public Scope(IDynamicMetaObjectProvider storage)
 {
     _extensions = ScopeExtension.EmptyArray;
     _storage = storage;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:Scope.cs


示例11: CreateScope

 public ScriptScope CreateScope(string languageId, IDynamicMetaObjectProvider storage) {
     return GetEngine(languageId).CreateScope(storage);
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:ScriptRuntime.cs


示例12: HasPropertyNaive

        private static bool HasPropertyNaive(IDynamicMetaObjectProvider dynamicProvider, string name)
        {
            try
            {
                var callSite =
                                CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.None, name, typeof(Program),
                                                         new[]
                                                                 {
                                                                     CSharpArgumentInfo.Create(
                                                                         CSharpArgumentInfoFlags.None, null)
                                                                 }));
                callSite.Target(callSite, dynamicProvider);
                return true;
            }
            catch (RuntimeBinderException)
            {

                return false;
            }
        }
开发者ID:renestein,项目名称:DynamicCheckPropertyExistence,代码行数:20,代码来源:Program.cs


示例13: ExecuteExpr

 // Execute a single expression parsed from string in the provided module
 // scope and returns the resulting value.
 //
 public object ExecuteExpr(string expr_str,
                           IDynamicMetaObjectProvider moduleEO) {
     var moduleFun = ParseExprToLambda(new StringReader(expr_str));
     var d = moduleFun.Compile();
     return d(this, moduleEO);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:Sympl.cs


示例14: CreateFromDynamicMetaObject

        private static TableItem CreateFromDynamicMetaObject( IDynamicMetaObjectProvider entity, bool throwOnReservedPropertyName )
        {
            var properties = new Dictionary<string, Tuple<object, Type>>();
             IEnumerable<string> memberNames = Dynamic.GetMemberNames( entity );
             foreach ( var memberName in memberNames )
             {
            dynamic result = Dynamic.InvokeGet( entity, memberName );
            properties[memberName] = new Tuple<object, Type>( (object) result, result.GetType() );
             }

             return new TableItem( properties, throwOnReservedPropertyName );
        }
开发者ID:TechSmith,项目名称:hyde,代码行数:12,代码来源:TableItem.cs


示例15: _OnStartExecute

        private void _OnStartExecute(IDynamicMetaObjectProvider executingScope, SourceUnit sourceUnit)
        {
            ContractUtils.Requires(executingScope is Scope);

            ExecutingScope = executingScope as Scope;
            ExecutingScopeStorage = ExecutingScope.Storage;

            //We should update the context under which this LuaTable is executing
            //so that it resolves metamethod overrides correctly.
            //TODO: Decide whether we should keep this if it is non-null, it may be that this is coming from a different
            //      CodeContext which has some metamethod stuff set particularly for this scope, or its contents, and we
            //      shouldn't change this.
            if (ExecutingScopeStorage is LuaTable)
                (ExecutingScopeStorage as LuaTable).Context = this;

            _LoadedPackages.Clear();
            _FunctionStacks.Clear();
            _EnvironmentMappings.Clear();   //We clear this here as opposed to in OnFinishExecute in case the last execution failed
        }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:19,代码来源:CodeContext.Expressions.cs


示例16: AsPrototypalObject

 public static PrototypalObject AsPrototypalObject( IDynamicMetaObjectProvider prototype )
 {
     if ( prototype == null )
     {
         return new PrototypalObject();
     }
     return prototype as PrototypalObject ?? new PrototypalObject( prototype );
 }
开发者ID:larsw,项目名称:Archetype,代码行数:8,代码来源:PrototypalObject.cs


示例17: Iterate

 private static void Iterate(
     ObjectEnumeratorBindingContext context,
     IDynamicMetaObjectProvider target,
     Action<TextWriter, object> template,
     Action<TextWriter, object> ifEmpty)
 {
     if (HandlebarsUtils.IsTruthy(target))
     {
         context.Index = 0;
         var meta = target.GetMetaObject(Expression.Constant(target));
         foreach (var name in meta.GetDynamicMemberNames())
         {
             context.Key = name;
             var value = GetProperty(target, name);
             context.First = (context.Index == 0);
             template(context.TextWriter, value);
             context.Index++;
         }
         if (context.Index == 0)
         {
             ifEmpty(context.TextWriter, context.Value);
         }
     }
     else
     {
         ifEmpty(context.TextWriter, context.Value);
     }
 }
开发者ID:amaclean,项目名称:Handlebars.Net,代码行数:28,代码来源:IteratorBinder.cs


示例18: SerializeDynamic

	/// <summary>
	/// Serializes the dynamic.
	/// </summary>
	/// <param name="writer">The writer.</param>
	/// <param name="value">The value.</param>
	/// <param name="contract">The contract.</param>
	private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract)
	{
		contract.InvokeOnSerializing(value, Serializer.Context);
		SerializeStack.Add(value);

		writer.WriteStartObject();

		foreach (string memberName in value.GetDynamicMemberNames())
		{
		object memberValue;
		if (DynamicUtils.TryGetMember(value, memberName, out memberValue))
		{
			string resolvedPropertyName = (contract.PropertyNameResolver != null)
			? contract.PropertyNameResolver(memberName)
			: memberName;
			
			writer.WritePropertyName(resolvedPropertyName);
			SerializeValue(writer, memberValue, GetContractSafe(memberValue), null, null);
		}
		}

		writer.WriteEndObject();

		SerializeStack.RemoveAt(SerializeStack.Count - 1);
		contract.InvokeOnSerialized(value, Serializer.Context);
	}
开发者ID:ThePiachu,项目名称:BitNet,代码行数:32,代码来源:JsonSerializerInternalWriter.cs


示例19: DynamicWrapper

 public DynamicWrapper(IDynamicMetaObjectProvider target)
 {
     this.target = target;
 }
开发者ID:yusufuzun,项目名称:fast-member,代码行数:4,代码来源:ObjectAccessor.cs


示例20: GetNamedPropertyValue

        /// <summary>
        /// Gets the value of an IDynamicMetaObjectProvider
        /// implementation's named property.
        /// </summary>
        /// <param name="item">
        /// The IDynamicMetaObjectProvider implementation, from
        /// which to extract a named property's value.
        /// </param>
        /// <param name="propertyName">
        /// The name of the property.
        /// </param>
        /// <param name="usesCaseSensitivePropertyNameMatch">
        /// A value indicating whether the property name match should be
        /// case-sensitive.
        /// </param>
        /// <param name="exceptionThrownIfNoMatch">
        /// A value indicating whether an exception should be thrown if
        /// no matching property can be found.
        /// </param>
        /// <returns>
        /// The value of the property named by propertyName on item,
        /// or a null reference if exceptionThrownIfNoMatch is false and
        /// propertyName does not name a property on item.
        /// </returns>
        private static object GetNamedPropertyValue(
            IDynamicMetaObjectProvider item,
            string propertyName,
            bool usesCaseSensitivePropertyNameMatch,
            bool exceptionThrownIfNoMatch)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentException("propertyName is a null reference or empty string.", "propertyName");
            }

            if (!usesCaseSensitivePropertyNameMatch || exceptionThrownIfNoMatch)
            {
                StringComparison comparisonType = StringComparison.CurrentCultureIgnoreCase;
                if (usesCaseSensitivePropertyNameMatch)
                {
                    comparisonType = StringComparison.CurrentCulture;
                }

                propertyName = D.Dynamic.GetMemberNames(item, true).FirstOrDefault(
                        t => string.Equals(t, propertyName, comparisonType));

                if (string.IsNullOrEmpty(propertyName))
                {
                    if (exceptionThrownIfNoMatch)
                    {
                        throw new ArgumentException("propertyName does not name a property on item", "propertyName");
                    }

                    return null;
                }
            }

            try
            {
                return D.Dynamic.InvokeGet(item, propertyName);
            }
            catch (RuntimeBinderException)
            {
                return null;
            }
        }
开发者ID:selam99,项目名称:azure-iot-remote-monitoring,代码行数:71,代码来源:ReflectionHelper.cs



注:本文中的IDynamicMetaObjectProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IE类代码示例发布时间:2022-05-24
下一篇:
C# IDvInvocation类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap