Пример #1
0
 public GenericConversionAction /*!*/ GenericConversionAction(Type /*!*/ type)
 {
     lock (_conversionActions) {
         GenericConversionAction result;
         if (!_genericConversionActions.TryGetValue(type, out result))
         {
             _genericConversionActions.Add(type, result = new GenericConversionAction(_context, type));
         }
         return(result);
     }
 }
Пример #2
0
            public override DynamicMetaObject /*!*/ FallbackConvert(DynamicMetaObject /*!*/ target, DynamicMetaObject errorSuggestion)
            {
#if !SILVERLIGHT
                DynamicMetaObject result;
                if (Microsoft.Scripting.ComInterop.ComBinder.TryConvert(this, target, out result))
                {
                    return(result);
                }
#endif
                var metaBuilder = new MetaObjectBuilder(this, target, DynamicMetaObject.EmptyMetaObjects);

                if (!GenericConversionAction.BuildConversion(metaBuilder, target, Ast.Constant(_context), Type, errorSuggestion == null))
                {
                    Debug.Assert(errorSuggestion != null);
                    // no conversion applicable so we didn't do any operation with arguments that would require restrictions converted to conditions:
                    metaBuilder.SetMetaResult(errorSuggestion, false);
                }

                return(metaBuilder.CreateMetaObject(this));
            }