Showing preview only (735K chars total). Download the full file or copy to clipboard to get everything.
Repository: ekonbenefits/dynamitey
Branch: master
Commit: c44f5c57cb8a
Files: 73
Total size: 705.5 KB
Directory structure:
gitextract_b38rdefz/
├── .appveyor.yml
├── .github/
│ └── workflows/
│ ├── dotnet.yml
│ └── dotnet48.yml
├── .gitignore
├── .vscode/
│ └── tasks.json
├── Directory.Build.props
├── Dynamitey/
│ ├── Builder.cs
│ ├── CacheableInvocation.cs
│ ├── Dynamic.cs
│ ├── DynamicObjects/
│ │ ├── BaseDictionary.cs
│ │ ├── BaseForwarder.cs
│ │ ├── BaseObject.cs
│ │ ├── Builder.cs
│ │ ├── Dictionary.cs
│ │ ├── Dummy.cs
│ │ ├── ExtensionToInstanceProxy.cs
│ │ ├── Factory.cs
│ │ ├── FauxType.cs
│ │ ├── FluentStringLookup.cs
│ │ ├── Get.cs
│ │ ├── LateType.cs
│ │ ├── Lazy.cs
│ │ ├── LinqInstanceProxy.cs
│ │ ├── List.cs
│ │ ├── Mimic.cs
│ │ ├── Recorder.cs
│ │ └── RegexMatch.cs
│ ├── Dynamitey.csproj
│ ├── Expando.cs
│ ├── FluentRegex.cs
│ ├── InlineLambdas.cs
│ ├── InlineLambdas.tt
│ ├── Internal/
│ │ ├── Compat/
│ │ │ └── Net40.cs
│ │ ├── Curry.cs
│ │ ├── InvokeSetters.cs
│ │ └── Optimization/
│ │ ├── BareBonesList.cs
│ │ ├── BinderHash.cs
│ │ ├── InvokeHelper-Regular.cs
│ │ ├── InvokeHelper.cs
│ │ ├── InvokeHelper.tt
│ │ └── Util.cs
│ ├── Invocation.cs
│ ├── InvokeArg.cs
│ ├── InvokeContext.cs
│ ├── InvokeMemberName.cs
│ ├── PartialApply.cs
│ ├── ThisFunctions.cs
│ ├── ThisFunctions.tt
│ ├── Tupler.cs
│ └── sn.snk
├── Dynamitey.sln
├── Dynamitey.sln.DotSettings
├── License.txt
├── NuGet.config
├── Readme.md
├── SupportLibrary/
│ ├── SupportLibrary.csproj
│ └── SupportTypes.cs
├── TestResult.xml
├── Tests/
│ ├── Curry.cs
│ ├── DynamicObjects.cs
│ ├── ExpandoObjs.cs
│ ├── Helper.cs
│ ├── Impromptu.cs
│ ├── Invoke.cs
│ ├── Linq.cs
│ ├── MimicTest.cs
│ ├── PrivateTest.cs
│ ├── SpeedTest.cs
│ ├── Tests.csproj
│ ├── TimeIt.cs
│ └── TuplerTest.cs
├── Version.props
└── build.fsx
================================================
FILE CONTENTS
================================================
================================================
FILE: .appveyor.yml
================================================
image: Visual Studio 2017
configuration: Debug
build: off
install:
- ps: nuget install FSharp.Compiler.Tools -ExcludeVersion -OutputDirectory extra
build_script:
- cmd: set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\extra\FSharp.Compiler.Tools\tools\
- cmd: fsi --exec ./build.fsx
test: off
artifacts:
- path: '**\bin\*\*.nupkg'
skip_branch_with_pr: true
skip_tags: true
deploy:
- provider: NuGet
server: https://www.myget.org/F/dynamitey-ci/api/v2/package
api_key:
secure: yKbBrG0QiTfXUvND1/cMMNHxH1Bgal5g7c0pWGwqvjCtKGTtWkpvE2KlZb6E2ZgB
skip_symbols: false
symbol_server: https://www.myget.org/F/dynamitey-ci/symbols/api/v2/package
for:
- branches:
except:
- /v.*/
environment:
vsuffix: alpha$(APPVEYOR_BUILD_NUMBER)
is_prerelease: true
- branches:
only:
- /v.*-beta/
environment:
vsuffix: beta$(APPVEYOR_BUILD_NUMBER)
is_prerelease: true
- branches:
only:
- /v[\d,.]*/
configuration: Release
environment:
vsuffix: $(APPVEYOR_BUILD_NUMBER)
is_prerelease: false
================================================
FILE: .github/workflows/dotnet.yml
================================================
name: Build .net core
on: [push]
jobs:
build:
name: Test ${{ matrix.os }} for dotnet ${{ matrix.dotnet }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
dotnet: [ '8.0.x' ]
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Build with dotnet core
run: dotnet build --configuration Release
- name: Tests
run: dotnet test Tests/Tests.csproj --configuration Release --no-build --no-restore --filter=TestCategory!=Performance
================================================
FILE: .github/workflows/dotnet48.yml
================================================
name: Build CrossComple .net core/.net framework Windows
on: [push]
jobs:
build:
name: Test Windows .net Framework and Core
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: NuGet/setup-nuget@v2
- uses: microsoft/setup-msbuild@v2
with:
dotnet-version: 4.8
- name: Restore Packages
run: nuget restore Dynamitey.sln
- name: Build solution
run: msbuild Dynamitey.sln -t:rebuild -property:Configuration=Release
- name: Test
uses: josepho0918/vstest-action@0e887de8dcfab5ce3eecaf4ad6320bb9b3ecf633
with:
testAssembly: Tests.dll
searchFolder: .\Tests\bin\Release\*\
runInParallel: true
otherConsoleOptions: /TestCaseFilter:"(TestCategory!=Performance)"
platform: x64
- name: Publish
run:
dotnet nuget push '${{ github.workspace }}\publish\*.nupkg' --source https://nuget.pkg.github.com/ekonbenefits/index.json --api-key ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
f
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
/dist/*.nupkg
*.userprefs
.fake/*
.nuget/NuGet.exe
.idea/*
.vs/*
.ionide/*
================================================
FILE: .vscode/tasks.json
================================================
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "./build.fsx",
"args": ["Test"],
"windows":{
"command": "C:\\Program Files (x86)\\Microsoft SDKs\\F#\\4.1\\Framework\\v4.0\\fsi",
"args": ["--exec", "./build.fsx", "Test"]
},
"isShellCommand": true,
"showOutput": "always",
"problemMatcher":"$msCompile"
}
================================================
FILE: Directory.Build.props
================================================
<Project>
<PropertyGroup>
<WithoutCrossCompile Condition="'$(GITHUB_ACTION)' != '' OR '$(LGTM_SRC)' != ''">True</WithoutCrossCompile>
</PropertyGroup>
</Project>
================================================
FILE: Dynamitey/Builder.cs
================================================
//
// Copyright 2011 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Linq;
using Dynamitey.DynamicObjects;
namespace Dynamitey
{
/// <summary>
/// Builds Objects with a Fluent Syntax
/// </summary>
public static class Builder
{
/// <summary>
/// New Builder
/// </summary>
/// <returns></returns>
public static IBuilder New()
{
return new Builder<ChainableDictionary>();
}
/// <summary>
/// New Builder
/// </summary>
/// <typeparam name="TObjectPrototype">The type of the object prototype.</typeparam>
/// <returns></returns>
public static IBuilder New<TObjectPrototype>() where TObjectPrototype : new()
{
return new Builder<TObjectPrototype>();
}
}
/// <summary>
/// Syntax for a quick new inline prototype object
/// </summary>
public static class Build
{
private static readonly dynamic _objectBuilder = new Builder<ChainableDictionary>().Object;
private static readonly dynamic _listBuilder =
Dynamic.Curry(new Builder<ChainableDictionary>().ListSetup<List>()).
List();
/// <summary>
/// Gets the new object builder.
/// </summary>
/// <value>The new object.</value>
public static dynamic NewObject => _objectBuilder;
/// <summary>
/// Gets the new list builder.
/// </summary>
/// <value>The new list.</value>
public static dynamic NewList => _listBuilder;
}
/// <summary>
/// Syntax for a quick inline object property setup
/// </summary>
/// <typeparam name="TObjectPrototype">The type of the object prototype.</typeparam>
public static class Build<TObjectPrototype> where TObjectPrototype : new()
{
// ReSharper disable StaticFieldInGenericType
private static readonly dynamic _typedBuilder = new Builder<TObjectPrototype>().Object;
// ReSharper restore StaticFieldInGenericType
// ReSharper disable StaticFieldInGenericType
private static readonly dynamic _typedListBuilder = Dynamic.Curry(new Builder<TObjectPrototype>().ListSetup<TObjectPrototype>()).List();
// ReSharper restore StaticFieldInGenericType
/// <summary>
/// Gets the new object builder.
/// </summary>
/// <value>The new.</value>
public static dynamic NewObject => _typedBuilder;
/// <summary>
/// Gets the new list builder.
/// </summary>
/// <value>The new list.</value>
public static dynamic NewList => _typedListBuilder;
}
/// <summary>
/// Encapsulates an Activator
/// </summary>
public class Activate
{
/// <summary>
/// Initializes a new instance of the <see cref="Activate"/> class.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="args">The args.</param>
public Activate(Type type, params object[] args)
{
Type = type;
var tArg = args.OfType<Func<object[]>>().SingleOrDefault();
if (tArg != null)
Arguments = tArg;
else
Arguments = () => args;
}
/// <summary>
/// Initializes a new instance of the <see cref="Activate"/> class. With Factory Function
/// </summary>
/// <param name="type">The type.</param>
/// <param name="args">The args.</param>
public Activate(Type type, Func<object[]> args)
{
Type = type;
Arguments = args;
}
/// <summary>
/// Gets or sets the constructor type.
/// </summary>
/// <value>The type.</value>
public virtual Type Type { get; private set; }
/// <summary>
/// Gets or sets the constructor arguments.
/// </summary>
/// <value>The arguments.</value>
public virtual Func<object[]> Arguments
{
get; private set;
}
/// <summary>
/// Creates this instance.
/// </summary>
/// <returns></returns>
public virtual dynamic Create()
{
object[] tArgs = Arguments();
return Dynamic.InvokeConstructor(Type, tArgs);
}
}
/// <summary>
/// Encapsulates an Activator
/// </summary>
/// <typeparam name="TObjectPrototype">The type of the object prototype.</typeparam>
public class Activate<TObjectPrototype> : Activate
{
/// <summary>
/// Initializes a new instance of the <see cref="Activate<TObjectPrototype>"/> class.
/// </summary>
/// <param name="args">The args.</param>
public Activate(params object[] args) : base(typeof(TObjectPrototype), args)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Activate<TObjectPrototype>"/> class. With Factory Function
/// </summary>
/// <param name="args">The args.</param>
public Activate(Func<object[]> args)
: base(typeof(TObjectPrototype), args)
{
}
/// <summary>
/// Creates this instance.
/// </summary>
/// <returns></returns>
public override dynamic Create()
{
var tArgs = Arguments();
if(tArgs.Any())
return base.Create();
TObjectPrototype tObjectPrototype;
try
{
tObjectPrototype = Activator.CreateInstance<TObjectPrototype>();//Try first because it's really fast, but won't work with optional parameters
}
catch (Exception)
{
tObjectPrototype = Dynamic.InvokeConstructor(typeof(TObjectPrototype));
}
return tObjectPrototype;
}
}
}
================================================
FILE: Dynamitey/CacheableInvocation.cs
================================================
using System;
using System.Dynamic;
using System.Linq;
using System.Runtime.CompilerServices;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
using System.Reflection;
using Dynamitey.Internal.Compat;
using System.Collections;
using System.Collections.Generic;
namespace Dynamitey
{
/// <summary>
/// Cacheable representation of an invocation without the target or arguments also by default only does public methods to make it easier to cache.
/// /// </summary>
public class CacheableInvocation:Invocation
{
/// <summary>
/// Creates the cacheable convert call.
/// </summary>
/// <param name="convertType">Type of the convert.</param>
/// <param name="convertExplicit">if set to <c>true</c> [convert explicit].</param>
/// <returns></returns>
public static CacheableInvocation CreateConvert(Type convertType, bool convertExplicit=false)
{
return new CacheableInvocation(InvocationKind.Convert, convertType: convertType, convertExplicit: convertExplicit);
}
/// <summary>
/// Creates the cacheable method or indexer or property call.
/// </summary>
/// <param name="kind">The kind.</param>
/// <param name="name">The name.</param>
/// <param name="callInfo">The callInfo.</param>
/// <param name="context">The context.</param>
/// <returns></returns>
public static CacheableInvocation CreateCall(InvocationKind kind, String_OR_InvokeMemberName name = null, CallInfo callInfo = null,object context = null)
{
var tArgCount = callInfo?.ArgumentCount ?? 0;
var tArgNames = callInfo?.ArgumentNames.ToArray();
return new CacheableInvocation(kind, name, tArgCount, tArgNames, context);
}
private readonly int _argCount;
private readonly string[] _argNames;
private readonly bool _staticContext;
private readonly Type _context;
//[NonSerialized]
private CallSite _callSite;
//[NonSerialized]
private CallSite _callSite2;
//[NonSerialized]
private CallSite _callSite3;
//[NonSerialized]
private CallSite _callSite4;
private readonly bool _convertExplicit;
private readonly Type _convertType;
/// <summary>
/// Initializes a new instance of the <see cref="CacheableInvocation"/> class.
/// </summary>
/// <param name="kind">The kind.</param>
/// <param name="name">The name.</param>
/// <param name="argCount">The arg count.</param>
/// <param name="argNames">The arg names.</param>
/// <param name="context">The context.</param>
/// <param name="convertType">Type of the convert.</param>
/// <param name="convertExplicit">if set to <c>true</c> [convert explict].</param>
/// <param name="storedArgs">The stored args.</param>
public CacheableInvocation(InvocationKind kind,
String_OR_InvokeMemberName name=null,
int argCount =0,
string[] argNames =null,
object context = null,
Type convertType = null,
bool convertExplicit = false,
object[] storedArgs = null)
: base(kind, name, storedArgs)
{
_convertType = convertType;
_convertExplicit = convertExplicit;
_argNames = argNames ?? new string[] {};
if (storedArgs != null)
{
_argCount = storedArgs.Length;
Args = Util.GetArgsAndNames(storedArgs, out var tArgNames);
if (_argNames.Length < tArgNames.Length)
{
_argNames = tArgNames;
}
}
switch (kind) //Set required argcount values
{
case InvocationKind.GetIndex:
if (argCount < 1)
{
throw new ArgumentException("Arg Count must be at least 1 for a GetIndex", nameof(argCount));
}
_argCount = argCount;
break;
case InvocationKind.SetIndex:
if (argCount < 2)
{
throw new ArgumentException("Arg Count Must be at least 2 for a SetIndex", nameof(argCount));
}
_argCount = argCount;
break;
case InvocationKind.Convert:
_argCount = 0;
if(convertType==null)
throw new ArgumentNullException(nameof(convertType)," Convert Requires Convert Type ");
break;
case InvocationKind.SubtractAssign:
case InvocationKind.AddAssign:
case InvocationKind.Set:
_argCount = 1;
break;
case InvocationKind.Get:
case InvocationKind.IsEvent:
_argCount = 0;
break;
default:
_argCount = Math.Max(argCount, _argNames.Length);
break;
}
if (_argCount > 0)//setup argName array
{
var tBlank = new string[_argCount];
if (_argNames.Length != 0)
Array.Copy(_argNames, 0, tBlank, tBlank.Length - _argNames.Length, _argNames.Length);
else
tBlank = null;
_argNames = tBlank;
}
if (context != null)
{
var dummy = context.GetTargetContext(out _context, out _staticContext); //lgtm [cs/useless-assignment-to-local]
}
else
{
_context = typeof (object);
}
}
/// <summary>
/// Equalses the specified other.
/// </summary>
/// <param name="other">The other.</param>
/// <returns></returns>
public bool Equals(CacheableInvocation other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return base.Equals(other)
&& other._argCount == _argCount
&& (_argNames ?? new string[] { }).SequenceEqual(other._argNames ?? new string[] { })
&& other._staticContext.Equals(_staticContext)
&& Equals(other._context, _context)
&& other._convertExplicit.Equals(_convertExplicit)
&& Equals(other._convertType, _convertType);
}
/// <summary>
/// Determines whether the specified <see cref="System.Object" /> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return Equals(obj as CacheableInvocation);
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
unchecked
{
int result = base.GetHashCode();
result = (result*397) ^ _argCount;
result = (result*397) ^ (_argNames != null ? ((IStructuralEquatable)_argNames).GetHashCode(EqualityComparer<string>.Default) : 0);
result = (result*397) ^ _staticContext.GetHashCode();
result = (result*397) ^ (_context != null ? _context.GetHashCode() : 0);
result = (result*397) ^ _convertExplicit.GetHashCode();
result = (result*397) ^ (_convertType != null ? _convertType.GetHashCode() : 0);
return result;
}
}
/// <summary>
/// Invokes the invocation on specified target with specific args.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentException">CacheableInvocation can't change conversion type on invoke.;args</exception>
/// <exception cref="System.InvalidOperationException">Unknown Invocation Kind: </exception>
public override object Invoke(object target, params object[] args)
{
if (target is InvokeContext tIContext)
{
target = tIContext.Target;
}
if (args == null)
{
args = new object[]{null};
}
if (args.Length != _argCount)
{
switch (Kind)
{
case InvocationKind.Convert:
if (args.Length > 0)
{
if (!Equals(args[0], _convertType))
throw new ArgumentException("CacheableInvocation can't change conversion type on invoke.", nameof(args));
}
if (args.Length > 1)
{
if(!Equals(args[1], _convertExplicit))
throw new ArgumentException("CacheableInvocation can't change explicit/implicit conversion on invoke.", nameof(args));
}
if(args.Length > 2)
goto default;
break;
default:
throw new ArgumentException("args",
$"Incorrect number of Arguments for CachedInvocation, Expected:{_argCount}");
}
}
switch (Kind)
{
case InvocationKind.Constructor:
var tTarget = (Type) target;
return InvokeHelper.InvokeConstructorCallSite(tTarget, tTarget.GetTypeInfo().IsValueType, args, _argNames,
ref _callSite);
case InvocationKind.Convert:
return InvokeHelper.InvokeConvertCallSite(target, _convertExplicit, _convertType, _context,
ref _callSite);
case InvocationKind.Get:
return InvokeHelper.InvokeGetCallSite(target, Name.Name, _context, _staticContext, ref _callSite);
case InvocationKind.Set:
InvokeHelper.InvokeSetCallSite(target, Name.Name, args[0], _context, _staticContext, ref _callSite);
return null;
case InvocationKind.GetIndex:
return InvokeHelper.InvokeGetIndexCallSite(target, args, _argNames, _context, _staticContext, ref _callSite);
case InvocationKind.SetIndex:
Dynamic.InvokeSetIndex(target, args);
return null;
case InvocationKind.InvokeMember:
return InvokeHelper.InvokeMemberCallSite(target, (InvokeMemberName) Name, args, _argNames, _context, _staticContext, ref _callSite);
case InvocationKind.InvokeMemberAction:
InvokeHelper.InvokeMemberActionCallSite(target, (InvokeMemberName)Name, args, _argNames, _context, _staticContext, ref _callSite);
return null;
case InvocationKind.InvokeMemberUnknown:
{
try
{
var tObj = InvokeHelper.InvokeMemberCallSite(target, (InvokeMemberName)Name, args, _argNames, _context, _staticContext, ref _callSite);
return tObj;
}
catch (RuntimeBinderException)
{
InvokeHelper.InvokeMemberActionCallSite(target, (InvokeMemberName)Name, args, _argNames, _context, _staticContext, ref _callSite2);
return null;
}
}
case InvocationKind.Invoke:
return InvokeHelper.InvokeDirectCallSite(target, args, _argNames, _context, _staticContext, ref _callSite);
case InvocationKind.InvokeAction:
InvokeHelper.InvokeDirectActionCallSite(target, args, _argNames, _context, _staticContext, ref _callSite);
return null;
case InvocationKind.InvokeUnknown:
{
try
{
var tObj = InvokeHelper.InvokeDirectCallSite(target, args, _argNames, _context, _staticContext, ref _callSite);
return tObj;
}
catch (RuntimeBinderException)
{
InvokeHelper.InvokeDirectActionCallSite(target, args, _argNames, _context, _staticContext, ref _callSite2);
return null;
}
}
case InvocationKind.AddAssign:
InvokeHelper.InvokeAddAssignCallSite(target, Name.Name, args, _argNames, _context, _staticContext,ref _callSite,ref _callSite2,ref _callSite3, ref _callSite4);
return null;
case InvocationKind.SubtractAssign:
InvokeHelper.InvokeSubtractAssignCallSite(target, Name.Name, args, _argNames, _context, _staticContext, ref _callSite, ref _callSite2, ref _callSite3, ref _callSite4);
return null;
case InvocationKind.IsEvent:
return InvokeHelper.InvokeIsEventCallSite(target, Name.Name, _context, ref _callSite);
default:
throw new InvalidOperationException("Unknown Invocation Kind: " + Kind);
}
}
}
}
================================================
FILE: Dynamitey/Dynamic.cs
================================================
//
// Copyright 2010 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using Dynamitey.Internal;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
using System.Text.RegularExpressions;
using Dynamitey.Internal.Compat;
namespace Dynamitey
{
using System;
/// <summary>
/// Main API
/// </summary>
public static class Dynamic
{
/// <summary>
/// Clears the dynamic binding caches.
/// </summary>
public static void ClearCaches()
{
InvokeHelper.ClearAllCaches();
}
private static readonly dynamic ComBinder
= new DynamicObjects.LateType("System.Dynamic.ComBinder, System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
// ReSharper disable once MemberCanBePrivate.Global
internal static readonly dynamic Impromptu
= new DynamicObjects.LateType("ImpromptuInterface.Impromptu, ImpromptuInterface, PublicKeyToken=0b1781c923b2975b");
// ReSharper disable once MemberCanBePrivate.Global
internal static readonly dynamic TypeDescriptor
= new DynamicObjects.LateType("System.ComponentModel.TypeDescriptor, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
private static readonly Type ComObjectType;
// ReSharper disable once MemberCanBePrivate.Global
internal static readonly Type TypeConverterAttributeSL;
static Dynamic()
{
try
{
ComObjectType = typeof(object).GetTypeInfo().Assembly.GetType("System.__ComObject");
}
catch
{
ComObjectType = null;
}
try
{
TypeConverterAttributeSL
= Type.GetType("System.ComponentModel.TypeConverter, System, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", false);
}
catch
{
TypeConverterAttributeSL = null;
}
}
/// <summary>
/// Creates a cached call site at runtime.
/// </summary>
/// <param name="delegateType">Type of the delegate.</param>
/// <param name="binder">The CallSite binder.</param>
/// <param name="name">Member Name</param>
/// <param name="context">Permissions Context type</param>
/// <param name="argNames">The arg names.</param>
/// <param name="staticContext">if set to <c>true</c> [static context].</param>
/// <param name="isEvent">if set to <c>true</c> [is event].</param>
/// <returns>The CallSite</returns>
/// <remarks>
/// Advanced usage only for serious custom dynamic invocation.
/// </remarks>
/// <seealso cref="CreateCallSite{T}"/>
public static CallSite CreateCallSite(Type delegateType, CallSiteBinder binder, String_OR_InvokeMemberName name,
Type context, string[] argNames = null, bool staticContext = false,
bool isEvent = false) =>
InvokeHelper.CreateCallSite(delegateType, binder.GetType(), InvokeHelper.Unknown,
() => binder, (InvokeMemberName)name, context, argNames, staticContext, isEvent);
/// <summary>
/// Creates the call site.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="binder">The binder.</param>
/// <param name="name">The name.</param>
/// <param name="context">The context.</param>
/// <param name="argNames">The arg names.</param>
/// <param name="staticContext">if set to <c>true</c> [static context].</param>
/// <param name="isEvent">if set to <c>true</c> [is event].</param>
/// <returns></returns>
/// ///
/// <example>
/// Unit test that exhibits usage
/// <code><![CDATA[
/// string tResult = String.Empty;
/// var tPoco = new MethOutPoco();
/// var tBinder =
/// Binder.InvokeMember(BinderFlags.None, "Func", null, GetType(),
/// new[]
/// {
/// Info.Create(
/// InfoFlags.None, null),
/// Info.Create(
/// InfoFlags.IsOut |
/// InfoFlags.UseCompileTimeType, null)
/// });
/// var tSite = Impromptu.CreateCallSite<DynamicTryString>(tBinder);
/// tSite.Target.Invoke(tSite, tPoco, out tResult);
/// Assert.AreEqual("success", tResult);
/// ]]></code>
/// </example>
/// <seealso cref="CreateCallSite"/>
public static CallSite<T> CreateCallSite<T>(CallSiteBinder binder, String_OR_InvokeMemberName name, Type context,
string[] argNames = null, bool staticContext = false,
bool isEvent = false) where T : class
=> InvokeHelper.CreateCallSite<T>(binder.GetType(), InvokeHelper.Unknown,
() => binder, (InvokeMemberName) name, context, argNames, staticContext, isEvent);
/// <summary>
/// Puts a dynamic linq proxy around the specified enumerable.
/// </summary>
/// <param name="enumerable">The enumerable.</param>
/// <returns></returns>
public static dynamic Linq(object enumerable)
{
if (enumerable
.GetType()
.GetTypeInfo()
.GetInterfaces()
.Where(it => it.GetTypeInfo().IsGenericType)
.Any(it => it.GetGenericTypeDefinition() == typeof(IEnumerable<>)))
{
return new DynamicObjects.LinqInstanceProxy(enumerable);
}
if (enumerable is IEnumerable tempEnumerable)
{
enumerable = tempEnumerable.Cast<object>();
}
return new DynamicObjects.LinqInstanceProxy(enumerable);
}
/// <summary>
/// Dynamically Invokes a member method using the DLR
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name. Can be a string it will be implicitly converted</param>
/// <param name="args">The args.</param>
/// <returns> The result</returns>
/// <example>
/// Unit test that exhibits usage:
/// <code>
/// <![CDATA[
/// dynamic tExpando = new ExpandoObject();
/// tExpando.Func = new Func<int, string>(it => it.ToString());
///
/// var tValue = 1;
/// var tOut = Impromptu.InvokeMember(tExpando, "Func", tValue);
///
/// Assert.AreEqual(tValue.ToString(), tOut);
/// ]]>
/// </code>
/// </example>
public static dynamic InvokeMember(object target, String_OR_InvokeMemberName name, params object[] args)
{
target = target.GetTargetContext(out var context, out var staticContext);
args = Util.GetArgsAndNames(args, out var argNames);
CallSite callSite = null;
return InvokeHelper.InvokeMemberCallSite(target, (InvokeMemberName)name, args, argNames, context, staticContext,
ref callSite);
}
/// <summary>
/// Invokes the binary operator.
/// </summary>
/// <param name="leftArg">The left arg.</param>
/// <param name="op">The op.</param>
/// <param name="rightArg">The right Arg.</param>
/// <returns></returns>
public static dynamic InvokeBinaryOperator(dynamic leftArg, ExpressionType op, dynamic rightArg)
{
switch (op)
{
case ExpressionType.Add:
return leftArg + rightArg;
case ExpressionType.AddAssign:
leftArg += rightArg;
return leftArg;
case ExpressionType.AndAssign:
leftArg &= rightArg;
return leftArg;
case ExpressionType.Divide:
return leftArg/rightArg;
case ExpressionType.DivideAssign:
leftArg /= rightArg;
return leftArg;
case ExpressionType.Equal:
return leftArg == rightArg;
case ExpressionType.ExclusiveOr:
return leftArg ^ rightArg;
case ExpressionType.ExclusiveOrAssign:
leftArg ^= rightArg;
return leftArg;
case ExpressionType.GreaterThan:
return leftArg > rightArg;
case ExpressionType.GreaterThanOrEqual:
return leftArg >= rightArg;
case ExpressionType.LeftShift:
return leftArg << rightArg;
case ExpressionType.LeftShiftAssign:
leftArg <<= rightArg;
return leftArg;
case ExpressionType.LessThan:
return leftArg < rightArg;
case ExpressionType.LessThanOrEqual:
return leftArg <= rightArg;
case ExpressionType.Modulo:
return leftArg%rightArg;
case ExpressionType.ModuloAssign:
leftArg %= rightArg;
return leftArg;
case ExpressionType.Multiply:
return leftArg*rightArg;
case ExpressionType.MultiplyAssign:
leftArg *= rightArg;
return leftArg;
case ExpressionType.NotEqual:
return leftArg != rightArg;
case ExpressionType.OrAssign:
leftArg |= rightArg;
return leftArg;
case ExpressionType.RightShift:
return leftArg >> rightArg;
case ExpressionType.RightShiftAssign:
leftArg >>= rightArg;
return leftArg;
case ExpressionType.Subtract:
return leftArg - rightArg;
case ExpressionType.SubtractAssign:
leftArg -= rightArg;
return leftArg;
case ExpressionType.Or:
return leftArg | rightArg;
case ExpressionType.And:
return leftArg & rightArg;
case ExpressionType.OrElse:
return leftArg || rightArg;
case ExpressionType.AndAlso:
return leftArg && rightArg;
default:
throw new ArgumentException("Unsupported Operator", nameof(op));
}
}
[Obsolete("Use `InvokeUnaryOperator` instead.")]
// ReSharper disable once IdentifierTypo
public static dynamic InvokeUnaryOpartor(ExpressionType op, dynamic arg)
=> InvokeUnaryOperator(op, (object)arg);
/// <summary>
/// Invokes the unary operator.
/// </summary>
/// <param name="arg">The arg.</param>
/// <param name="op">The op.</param>
/// <returns></returns>
public static dynamic InvokeUnaryOperator(ExpressionType op, dynamic arg)
{
switch (op)
{
case ExpressionType.Not:
return !arg;
case ExpressionType.Negate:
return -arg;
case ExpressionType.Decrement:
return --arg;
case ExpressionType.Increment:
return ++arg;
default:
throw new ArgumentException("Unsupported Operator", nameof(op));
}
}
/// <summary>
/// Invokes the specified target using the DLR;
/// </summary>
/// <param name="target">The target.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
public static dynamic Invoke(object target, params object[] args)
{
target = target.GetTargetContext(out var context, out var staticContext);
args = Util.GetArgsAndNames(args, out var argNames);
CallSite callSite = null;
return InvokeHelper.InvokeDirectCallSite(target, args, argNames, context, staticContext, ref callSite);
}
/// <summary>
/// Dynamically Invokes indexer using the DLR.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="indexes">The indexes.</param>
/// <returns></returns>
public static dynamic InvokeGetIndex(object target, params object[] indexes)
{
target = target.GetTargetContext(out var tContext, out var tStaticContext);
indexes = Util.GetArgsAndNames(indexes, out var tArgNames);
CallSite tCallSite = null;
return InvokeHelper.InvokeGetIndexCallSite(target, indexes, tArgNames, tContext, tStaticContext,
ref tCallSite);
}
/// <summary>
/// Convenience version of InvokeSetIndex that separates value and indexes.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="value">The value</param>
/// <param name="indexes">The indexes </param>
/// <returns></returns>
public static object InvokeSetValueOnIndexes(object target, object value, params object[] indexes)
{
var tList = new List<object>(indexes) {value};
return InvokeSetIndex(target, indexesThenValue: tList.ToArray());
}
/// <summary>
/// Invokes setindex.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="indexesThenValue">The indexes then value.</param>
public static object InvokeSetIndex(object target, params object[] indexesThenValue)
{
if (indexesThenValue.Length < 2)
{
throw new ArgumentException("Requires at least one index and one value", nameof(indexesThenValue));
}
target = target.GetTargetContext(out var tContext, out var tStaticContext);
indexesThenValue = Util.GetArgsAndNames(indexesThenValue, out var tArgNames);
CallSite tCallSite = null;
return InvokeHelper.InvokeSetIndexCallSite(target, indexesThenValue, tArgNames, tContext, tStaticContext,
ref tCallSite);
}
/// <summary>
/// Dynamically Invokes a member method which returns void using the DLR
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name.</param>
/// <param name="args">The args.</param>
/// <example>
/// Unit test that exhibits usage:
/// <code>
/// <![CDATA[
/// var tTest = "Wrong";
/// var tValue = "Correct";
///
/// dynamic tExpando = new ExpandoObject();
/// tExpando.Action = new Action<string>(it => tTest = it);
///
/// Impromptu.InvokeMemberAction(tExpando, "Action", tValue);
///
/// Assert.AreEqual(tValue, tTest);
/// ]]>
/// </code>
/// </example>
public static void InvokeMemberAction(object target, String_OR_InvokeMemberName name, params object[] args)
{
target = target.GetTargetContext(out var tContext, out var tStaticContext);
args = Util.GetArgsAndNames(args, out var tArgNames);
CallSite tCallSite = null;
InvokeHelper.InvokeMemberActionCallSite(target, (InvokeMemberName)name, args, tArgNames, tContext, tStaticContext,
ref tCallSite);
}
/// <summary>
/// Invokes the action using the DLR
/// </summary>
/// <param name="target">The target.</param>
/// <param name="args">The args.</param>
public static void InvokeAction(object target, params object[] args)
{
target = target.GetTargetContext(out var tContext, out var tStaticContext);
args = Util.GetArgsAndNames(args, out var tArgNames);
CallSite tCallSite = null;
InvokeHelper.InvokeDirectActionCallSite(target, args, tArgNames, tContext, tStaticContext, ref tCallSite);
}
/// <summary>
/// Dynamically Invokes a set member using the DLR.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
/// <example>
/// Unit test that exhibits usage:
/// <code>
/// <![CDATA[
/// dynamic tExpando = new ExpandoObject();
///
/// var tSetValue = "1";
///
/// Impromptu.InvokeSet(tExpando, "Test", tSetValue);
///
/// Assert.AreEqual(tSetValue, tExpando.Test);
/// ]]>
/// </code>
/// </example>
/// <remarks>
/// if you call a static property off a type with a static context the csharp dlr binder won't do it, so this method reverts to reflection
/// </remarks>
public static object InvokeSet(object target, string name, object value)
{
target = target.GetTargetContext(out var tContext, out var tStaticContext);
tContext = tContext.FixContext();
CallSite tCallSite = null;
return InvokeHelper.InvokeSetCallSite(target, name, value, tContext, tStaticContext, ref tCallSite);
}
/// <summary>
/// Invokes the set on the end of a property chain.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="propertyChain">The property chain.</param>
/// <param name="value">The value.</param>
public static object InvokeSetChain(object target, string propertyChain, object value)
{
var tProperties = _chainRegex.FluentMatches(propertyChain).ToList();
var tGetProperties = tProperties.Take(tProperties.Count - 1);
var tTarget = target;
foreach (var tProperty in tGetProperties)
{
var tGetter = tProperty.Getter;
var tIntIndexer = tProperty.IntIndexer;
var tStringIndexer = tProperty.StringIndexer;
if (tGetter != null)
tTarget = InvokeGet(tTarget, tGetter);
else if (tIntIndexer != null)
tTarget = InvokeGetIndex(tTarget, Dynamic.CoerceConvert(tIntIndexer, typeof(int)));
else if (tStringIndexer != null)
tTarget = InvokeGetIndex(tTarget, tStringIndexer);
else
{
throw new Exception($"Could Not Parse :'{propertyChain}'");
}
}
var tSetProperty = tProperties.Last();
var tSetGetter = tSetProperty.Getter;
var tSetIntIndexer = tSetProperty.IntIndexer;
var tSetStringIndexer = tSetProperty.StringIndexer;
if (tSetGetter != null)
return InvokeSet(tTarget, tSetGetter, value);
if (tSetIntIndexer != null)
return InvokeSetIndex(tTarget, Dynamic.CoerceConvert(tSetIntIndexer, typeof(int)), value);
if (tSetStringIndexer != null)
return InvokeSetIndex(tTarget, tSetStringIndexer, value);
throw new Exception($"Could Not Parse :'{propertyChain}'");
}
private static readonly dynamic _invokeSetAll = new InvokeSetters();
/// <summary>
/// Call Like method invokes set on target and a list of property/value. Invoke with dictionary, anonymous type or named arguments.
/// </summary>
/// <value>The invoke set all.</value>
public static dynamic InvokeSetAll => _invokeSetAll;
/// <summary>
/// Wraps a target to partial apply a method (or target if you can invoke target directly eg delegate).
/// </summary>
/// <param name="target">The target.</param>
/// <param name="totalArgCount">The total arg count.</param>
/// <returns></returns>
public static dynamic Curry(object target, int? totalArgCount = null)
{
if (target is Delegate && !totalArgCount.HasValue)
return Curry((Delegate) target);
return new Curry(target, totalArgCount);
}
/// <summary>
/// Wraps a delegate to partially apply it.
/// </summary>
/// <param name="target">The target.</param>
/// <returns></returns>
public static dynamic Curry(Delegate target)
{
return new Curry(target, target.GetMethodInfo().GetParameters().Length);
}
/// <summary>
/// Dynamically Invokes a get member using the DLR.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name.</param>
/// <returns>The result.</returns>
/// <example>
/// Unit Test that describes usage
/// <code>
/// <![CDATA[
/// var tSetValue = "1";
/// var tAnon = new { Test = tSetValue };
///
/// var tOut =Impromptu.InvokeGet(tAnon, "Test");
///
/// Assert.AreEqual(tSetValue, tOut);
/// ]]>
/// </code>
/// </example>
public static dynamic InvokeGet(object target, string name)
{
target = target.GetTargetContext(out var tContext, out var tStaticContext); CallSite tSite = null;
return InvokeHelper.InvokeGetCallSite(target, name, tContext, tStaticContext, ref tSite);
}
private static readonly Regex _chainRegex
= new Regex(@"((\.?(?<Getter>\w+))|(\[(?<IntIndexer>\d+)\])|(\['(?<StringIndexer>\w+)'\]))");
/// <summary>
/// Invokes the getter property chain.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="propertyChain">The property chain.</param>
/// <returns></returns>
public static dynamic InvokeGetChain(object target, string propertyChain)
{
var tProperties = _chainRegex.FluentMatches(propertyChain);
var tTarget = target;
foreach (var tProperty in tProperties)
{
var tGetter = tProperty.Getter;
var tIntIndexer = tProperty.IntIndexer;
var tStringIndexer = tProperty.StringIndexer;
if (tGetter != null)
tTarget = InvokeGet(tTarget, tGetter);
else if (tIntIndexer != null)
tTarget = InvokeGetIndex(tTarget, Dynamic.CoerceConvert(tIntIndexer,typeof(int)));
else if (tStringIndexer != null)
tTarget = InvokeGetIndex(tTarget, tStringIndexer);
else
{
throw new Exception($"Could Not Parse :'{propertyChain}'");
}
}
return tTarget;
}
/// <summary>
/// Determines whether the specified name on target is event. This allows you to know whether to InvokeMemberAction
/// add_{name} or a combo of {invokeGet, +=, invokeSet} and the corresponding remove_{name}
/// or a combo of {invokeGet, -=, invokeSet}
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name.</param>
/// <returns>
/// <c>true</c> if the specified target is event; otherwise, <c>false</c>.
/// </returns>
public static bool InvokeIsEvent(object target, string name)
{
target = target.GetTargetContext(out var tContext, out var tStaticContext);
tContext = tContext.FixContext();
CallSite tCallSite = null;
return InvokeHelper.InvokeIsEventCallSite(target, name, tContext, ref tCallSite);
}
/// <summary>
/// Invokes add assign with correct behavior for events.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
public static void InvokeAddAssignMember(object target, string name, object value)
{
CallSite callSiteAdd =null;
CallSite callSiteGet =null;
CallSite callSiteSet =null;
CallSite callSiteIsEvent = null;
target = target.GetTargetContext(out var context, out var staticContext);
var args = new[] { value };
args = Util.GetArgsAndNames(args, out var argNames);
InvokeHelper.InvokeAddAssignCallSite(target, name, args, argNames, context, staticContext, ref callSiteIsEvent, ref callSiteAdd, ref callSiteGet, ref callSiteSet);
}
/// <summary>
/// Invokes subtract assign with correct behavior for events.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
public static void InvokeSubtractAssignMember(object target, string name, object value)
{
target = target.GetTargetContext(out var context, out var staticContext);
var args = new[] { value };
args = Util.GetArgsAndNames(args, out var argNames);
CallSite callSiteIsEvent = null;
CallSite callSiteRemove = null;
CallSite callSiteGet = null;
CallSite callSiteSet = null;
InvokeHelper.InvokeSubtractAssignCallSite(target, name, args, argNames, context, staticContext, ref callSiteIsEvent, ref callSiteRemove, ref callSiteGet,ref callSiteSet);
}
/// <summary>
/// Invokes convert using the DLR.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="type">The type.</param>
/// <param name="explicit">if set to <c>true</c> [explicit].</param>
/// <returns></returns>
public static dynamic InvokeConvert(object target, Type type, bool @explicit =false)
{
target = target.GetTargetContext(out var tContext, out var tDummy);
CallSite tCallSite =null;
return InvokeHelper.InvokeConvertCallSite(target, @explicit, type, tContext, ref tCallSite);
}
internal static readonly IDictionary<Type, Delegate> CompiledExpressions = new Dictionary<Type, Delegate>();
/// <summary>
/// Coerces any invokable to specified delegate type.
/// </summary>
/// <param name="invokeableObject">The invokeable object.</param>
/// <param name="delegateType">Type of the delegate.</param>
/// <returns></returns>
public static dynamic CoerceToDelegate(object invokeableObject, Type delegateType)
{
var delegateTypeInfo = delegateType.GetTypeInfo();
if (!typeof(Delegate).GetTypeInfo().IsAssignableFrom(delegateTypeInfo.BaseType))
{
return null;
}
var tDelMethodInfo = delegateTypeInfo.GetMethod("Invoke");
if (tDelMethodInfo is null)
{
throw new Exception("This Delegate Didn't have and Invoke method! Impossible!");
}
var tReturnType = tDelMethodInfo.ReturnType;
var tAction = tReturnType == typeof(void);
var tParams = tDelMethodInfo.GetParameters();
var tLength = tDelMethodInfo.GetParameters().Length;
Delegate tBaseDelegate = tAction
? InvokeHelper.WrapAction(invokeableObject, tLength)
: InvokeHelper.WrapFunc(tReturnType, invokeableObject, tLength);
if (InvokeHelper.IsActionOrFunc(delegateType) &&
!tParams.Any(it => it.ParameterType.GetTypeInfo().IsValueType))
{
return tBaseDelegate;
}
if (CompiledExpressions.TryGetValue(delegateType, out var tGetResult))
{
return tGetResult.DynamicInvoke(tBaseDelegate);
}
var tParamTypes = tParams.Select(it => it.ParameterType).ToArray();
var tDelParam = Expression.Parameter(tBaseDelegate.GetType());
var tInnerParams = tParamTypes.Select(Expression.Parameter).ToArray();
var tI = Expression.Invoke(tDelParam,
tInnerParams.Select(it => (Expression)Expression.Convert(it, typeof(object))));
var tL = Expression.Lambda(delegateType, tI, tInnerParams);
tGetResult =
Expression.Lambda(Expression.GetFuncType(tBaseDelegate.GetType(), delegateType), tL,
tDelParam).Compile();
CompiledExpressions[delegateType] = tGetResult;
return tGetResult.DynamicInvoke(tBaseDelegate);
}
private static readonly dynamic LateConvert = new DynamicObjects.LateType(typeof(Convert));
/// <summary>
/// Determines whether value is DBNull dynamically (Useful for PCL)
/// </summary>
/// <param name="value">The value.</param>
/// <returns>
/// <c>true</c> if [is DBNull]; otherwise, <c>false</c>.
/// </returns>
public static bool IsDBNull(object value)
{
try
{
return LateConvert.IsDBNull(value);
}
catch
{
return false;
}
}
/// <summary>
/// Applies the equivalent type hint to dynamic object
/// </summary>
/// <param name="target">The target.</param>
/// <param name="types">The types.</param>
public static void ApplyEquivalentType(DynamicObjects.IEquivalentType target, params Type[] types)
{
if(types.Length == 1)
target.EquivalentType = types.First();
else
target.EquivalentType = new DynamicObjects.AggreType(types.ConvertEach<DynamicObjects.FauxType>().ToArray());
}
/// <summary>
/// Implicit or Explicit Converts the items of the specified enumerable.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable">The enumerable.</param>
/// <param name="explicit">if set to <c>true</c> [explicit].</param>
/// <returns></returns>
[Obsolete("Use ConvertEach.")]
public static IEnumerable<T> ConvertAll<T>(this System.Collections.IEnumerable enumerable, bool explict = false)
=> ConvertEach<T>(enumerable, explict);
/// <summary>
/// Implicit or Explicit Converts the items of the specified enumerable.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable">The enumerable.</param>
/// <param name="explicit">if set to <c>true</c> [explicit].</param>
/// <returns></returns>
public static IEnumerable<T> ConvertEach<T>(this System.Collections.IEnumerable enumerable, bool @explicit =false)
{
return enumerable.Cast<object>().Select(it => InvokeConvert(it, typeof (T), @explicit)).Cast<T>();
}
/// <summary>
/// Goes the extra mile to convert target to type.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public static dynamic CoerceConvert(object target, Type type)
{
var typeInfo = type.GetTypeInfo();
if (target != null && !typeInfo.IsInstanceOfType(target) && !IsDBNull(target))
{
var delegateConversion = CoerceToDelegate(target, type);
if (delegateConversion != null)
return delegateConversion;
if (typeInfo.IsInterface && Impromptu.IsAvailable)
{
if (target is IDictionary<string, object> tDict && !(tDict is DynamicObjects.BaseObject))
{
target = new DynamicObjects.Dictionary(tDict);
}
else if(!(target is DynamicObjects.BaseObject))
{
target = new DynamicObjects.Get(target);
}
target = Impromptu.DynamicActLike(target, type);
}
else
{
try
{
object tResult = Dynamic.InvokeConvert(target, type, @explicit: true);
target = tResult;
}
catch (RuntimeBinderException)
{
Type tReducedType = type;
if (typeInfo.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
{
tReducedType = typeInfo.GetGenericArguments().First();
}
if (typeof (Enum).GetTypeInfo().IsAssignableFrom(tReducedType) && target is string sVal)
{
target = Enum.Parse(tReducedType, sVal, true);
}
else if (target is IConvertible && typeof (IConvertible).GetTypeInfo().IsAssignableFrom(tReducedType))
{
target = Convert.ChangeType(target, tReducedType, Net40.GetDefaultThreadCurrentCulture());
}
else
{
try
{
dynamic converter = null;
if (TypeDescriptor.IsAvailable)
{
converter = TypeDescriptor.GetConverter(tReducedType);
}
else if (TypeConverterAttributeSL != null)
{
var tAttributes =
tReducedType.GetTypeInfo().GetCustomAttributes(TypeConverterAttributeSL, false);
dynamic attribute = tAttributes.FirstOrDefault();
if (attribute != null)
{
converter =
Impromptu.InvokeConstructor(Type.GetType(attribute.ConverterTypeName));
}
}
if (converter != null && converter.CanConvertFrom(target.GetType()))
{
target = converter.ConvertFrom(target);
}
}
catch (RuntimeBinderException)
{
//This runtime converter block is a hail mary
//lgtm [cs/empty-catch-block]
}
}
}
}
}
else if (((target == null) || IsDBNull(target )) && typeInfo.IsValueType)
{
target = Dynamic.InvokeConstructor(type);
}
else if (!typeInfo.IsInstanceOfType(target) && IsDBNull(target))
{
return null;
}
return target;
}
/// <summary>
/// Invokes the constructor.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
public static dynamic InvokeConstructor(Type type, params object[] args)
{
var tValue = type.GetTypeInfo().IsValueType;
if (tValue && args.Length == 0) //dynamic invocation doesn't see constructors of value types
{
return Activator.CreateInstance(type);
}
args = Util.GetArgsAndNames( args, out var tArgNames);
CallSite tCallSite = null;
return InvokeHelper.InvokeConstructorCallSite(type, tValue, args, tArgNames, ref tCallSite);
}
/// <summary>
/// FastDynamicInvoke extension method. Runs up to runs up to 20x faster than <see cref="System.Delegate.DynamicInvoke"/> .
/// </summary>
/// <param name="del">The del.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
public static object FastDynamicInvoke(this Delegate del, params object[] args)
{
if (del.GetMethodInfo().ReturnType != typeof(void))
{
return InvokeHelper.FastDynamicInvokeReturn(del, args);
}
InvokeHelper.FastDynamicInvokeAction(del, args);
return null;
}
/// <summary>
/// Given a generic parameter count and whether it returns void or not gives type of Action or Func
/// </summary>
/// <param name="paramCount">The param count.</param>
/// <param name="returnVoid">if set to <c>true</c> [return void].</param>
/// <returns>Type of Action or Func</returns>
public static Type GenericDelegateType(int paramCount, bool returnVoid = false)
{
var tParamCount = returnVoid ? paramCount : paramCount - 1;
if (tParamCount > 16)
throw new ArgumentException(
$"{(returnVoid ? "Action" : "Func")} only handle at most {(returnVoid ? 16 : 17)} parameters", nameof(paramCount));
if(tParamCount < 0)
throw new ArgumentException(
$"{(returnVoid ? "Action" : "Func")} must have at least {(returnVoid ? 0 : 1)} parameter(s)", nameof(paramCount));
return returnVoid
? InvokeHelper.ActionKinds[tParamCount]
: InvokeHelper.FuncKinds[tParamCount];
}
/// <summary>
/// Gets the member names of properties. Not all IDynamicMetaObjectProvider have support for this.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="dynamicOnly">if set to <c>true</c> [dynamic only]. Won't add reflected properties</param>
/// <returns></returns>
public static IEnumerable<string> GetMemberNames(object target, bool dynamicOnly = false)
{
var tList = new List<string>();
if (!dynamicOnly)
{
tList.AddRange(target.GetType().GetTypeInfo().GetProperties().Select(it => it.Name));
}
if (target is IDynamicMetaObjectProvider tTarget)
{
tList.AddRange(tTarget.GetMetaObject(Expression.Constant(tTarget)).GetDynamicMemberNames());
}else
{
if (ComObjectType != null && ComObjectType.GetTypeInfo().IsInstanceOfType(target) && ComBinder.IsAvailable)
{
tList.AddRange(ComBinder.GetDynamicDataMemberNames(target));
}
}
return tList;
}
/// <summary>
/// Dynamically invokes a method determined by the CallSite binder and be given an appropriate delegate type
/// </summary>
/// <param name="callSite">The Callsite</param>
/// <param name="target">The target.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
/// <remarks>
/// Advanced use only. Use this method for serious custom invocation, otherwise there are other convenience methods such as
/// <see cref="InvokeMember"></see>, <see cref="InvokeGet"></see>, <see cref="InvokeSet"></see> and <see cref="InvokeMemberAction"></see>
/// </remarks>
public static dynamic InvokeCallSite(CallSite callSite, object target, params object[] args)
{
var tParameters = new List<object> {callSite, target};
tParameters.AddRange(args);
MulticastDelegate tDelegate = ((dynamic)callSite).Target;
return tDelegate.FastDynamicInvoke(tParameters.ToArray());
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/BaseDictionary.cs
================================================
//
// Copyright 2011 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Threading;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Base class of Expando-Type objects
/// </summary>
public abstract class BaseDictionary : BaseObject, INotifyPropertyChanged
{
/// <summary>
/// Wrapped Dictionary
/// </summary>
protected IDictionary<string,object> _dictionary;
/// <summary>
/// Initializes a new instance of the <see cref="Dictionary"/> class.
/// </summary>
/// <param name="dict">The dict.</param>
protected BaseDictionary(IEnumerable<KeyValuePair<string, object>> dict =null)
{
if (dict == null)
{
_dictionary = new Dictionary<string, object>();
return;
}
if(dict is IDictionary<string,object>) //Don't need to enumerate if it's the right type.
_dictionary = (IDictionary<string,object>)dict;
else
_dictionary = dict.ToDictionary(k => k.Key, v => v.Value);
}
/// <summary>
/// Gets a value indicating whether this instance is read only.
/// </summary>
/// <value>
/// <c>true</c> if this instance is read only; otherwise, <c>false</c>.
/// </value>
public virtual bool IsReadOnly => false;
/// <summary>
/// Gets the keys.
/// </summary>
/// <value>The keys.</value>
public ICollection<string> Keys => _dictionary.Keys;
/// <summary>
/// Gets the values.
/// </summary>
/// <value>The values.</value>
public ICollection<object> Values => _dictionary.Values;
/// <summary>
/// Returns the enumeration of all dynamic member names.
/// </summary>
/// <returns>
/// A sequence that contains dynamic member names.
/// </returns>
public override IEnumerable<string> GetDynamicMemberNames()
{
return base.GetDynamicMemberNames().Concat(_dictionary.Keys).Distinct();
}
/// <summary>
/// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
/// </returns>
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (_dictionary.TryGetValue(binder.Name, out result))
{
return this.MassageResultBasedOnInterface(binder.Name, true, ref result);
}
result = null;
return this.MassageResultBasedOnInterface(binder.Name, false, ref result);
}
/// <summary>
/// Provides the implementation for operations that invoke a member. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as calling a method.
/// </summary>
/// <param name="binder">Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="args">The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, <paramref name="args"/> is equal to 100.</param>
/// <param name="result">The result of the member invocation.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
if (_dictionary.TryGetValue(binder.Name, out result))
{
var tFunc = result as Delegate;
if (result == null)
return false;
if (!binder.CallInfo.ArgumentNames.Any() && tFunc != null)
{
try
{
result = this.InvokeMethodDelegate(tFunc, args);
}
catch (RuntimeBinderException)//If it has out parmaters etc it can't be invoked dynamically like this.
//if we return false it will be handle by the GetProperty and then handled by the original dynamic invocation
{
return false;
}
}
else
{
try
{
result = Dynamic.Invoke(result, Util.NameArgsIfNecessary(binder.CallInfo, args));
}
catch (RuntimeBinderException)
//If it has out parmaters etc it can't be invoked dynamically like this.
//if we return false it will be handle by the GetProperty and then handled by the original dynamic invocation
{
return false;
}
}
return this.MassageResultBasedOnInterface(binder.Name, true, ref result);
}
return this.MassageResultBasedOnInterface(binder.Name, false, ref result);
}
/// <summary>
/// Provides the implementation for operations that set member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as setting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="value">The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, the <paramref name="value"/> is "Test".</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TrySetMember(SetMemberBinder binder, object value)
{
SetProperty(binder.Name,value);
return true;
}
/// <summary>
/// Adds the specified item.
/// </summary>
/// <param name="item">The item.</param>
public void Add(KeyValuePair<string, object> item)
{
SetProperty(item.Key, item.Value);
}
/// <summary>
/// Determines whether [contains] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns>
/// <c>true</c> if [contains] [the specified item]; otherwise, <c>false</c>.
/// </returns>
public bool Contains(KeyValuePair<string, object> item)
{
return _dictionary.Contains(item);
}
/// <summary>
/// Copies to.
/// </summary>
/// <param name="array">The array.</param>
/// <param name="arrayIndex">Index of the array.</param>
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
{
_dictionary.CopyTo(array,arrayIndex);
}
/// <summary>
/// Removes the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Remove(KeyValuePair<string, object> item)
{
if (TryGetValue(item.Key, out var tValue))
{
if (item.Value == tValue)
{
Remove(item.Key);
}
}
return false;
}
/// <summary>
/// Determines whether the specified key contains key.
/// </summary>
/// <param name="key">The key.</param>
/// <returns>
/// <c>true</c> if the specified key contains key; otherwise, <c>false</c>.
/// </returns>
public bool ContainsKey(string key)
{
return _dictionary.ContainsKey(key);
}
/// <summary>
/// Adds the specified key.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public void Add(string key, object value)
{
SetProperty(key,value);
}
/// <summary>
/// Removes the specified key.
/// </summary>
/// <param name="key">The key.</param>
/// <returns></returns>
public bool Remove(string key)
{
var tReturn = _dictionary.Remove(key);
OnPropertyChanged(key);
return tReturn;
}
/// <summary>
/// Tries the get value.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public bool TryGetValue(string key, out object value)
{
return _dictionary.TryGetValue(key, out value);
}
/// <summary>
/// Sets the property.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
protected void SetProperty(string key, object value)
{
if (!_dictionary.TryGetValue(key, out var tOldValue) || value != tOldValue)
{
_dictionary[key] = value;
OnPropertyChanged(key);
}
}
/// <summary>
/// Called when [property changed].
/// </summary>
/// <param name="key">The key.</param>
protected virtual void OnPropertyChanged(string key)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(key));
#if SILVERLIGHT
PropertyChanged(this, new PropertyChangedEventArgs("Item["+key+"]")); //Indexers are Updated on Dictionarys as well
#else
PropertyChanged(this, new PropertyChangedEventArgs("Item[]")); //Indexers are Updated on Dictionarys as well WPF does not support Item[key] syntax
#endif
}
}
/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Equalses the specified other.
/// </summary>
/// <param name="other">The other.</param>
/// <returns></returns>
public bool Equals(Dictionary other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(other._dictionary, _dictionary);
}
/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (Dictionary)) return _dictionary.Equals(obj);
return Equals((Dictionary) ((object) ((Dictionary) obj)));
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return _dictionary.GetHashCode();
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public override string ToString()
{
return _dictionary.ToString();
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/BaseForwarder.cs
================================================
//
// Copyright 2011 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp;
using Microsoft.CSharp.RuntimeBinder;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// An proxy object
/// </summary>
public interface IForwarder
{
/// <summary>
/// Gets the target.
/// </summary>
/// <value>The target.</value>
object Target { get; }
}
/// <summary>
/// Proxies Calls allows subclasser to override do extra actions before or after base invocation
/// </summary>
/// <remarks>
/// This may not be as efficient as other proxies that can work on just static objects or just dynamic objects...
/// Consider this when using.
/// </remarks>
public abstract class BaseForwarder : BaseObject, IForwarder
{
/// <summary>
/// Marks whether we are adding or removing the delegate
/// </summary>
public class AddRemoveMarker
{
/// <summary>
/// Implements the operator +.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static AddRemoveMarker operator +(AddRemoveMarker left, object right)
{
left.Delegate = right;
left.IsAdding = true;
return left;
}
/// <summary>
/// Implements the operator -.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static AddRemoveMarker operator -(AddRemoveMarker left, object right)
{
left.Delegate = right;
left.IsAdding = false;
return left;
}
/// <summary>
/// Gets or sets the delegate.
/// </summary>
/// <value>The delegate.</value>
public object Delegate { get; protected set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is adding.
/// </summary>
/// <value><c>true</c> if this instance is adding; otherwise, <c>false</c>.</value>
public bool IsAdding { get; protected set; }
}
/// <summary>
/// Initializes a new instance of the <see cref="BaseForwarder"/> class.
/// </summary>
/// <param name="target">The target.</param>
protected BaseForwarder(object target)
{
Target = target;
}
/// <summary>
/// Returns the enumeration of all dynamic member names.
/// </summary>
/// <returns>
/// A sequence that contains dynamic member names.
/// </returns>
public override IEnumerable<string> GetDynamicMemberNames()
{
var tDyanmic = Dynamic.GetMemberNames(CallTarget, dynamicOnly: true);
if (!tDyanmic.Any())
{
return Dynamic.GetMemberNames(CallTarget);
}
return base.GetDynamicMemberNames();
}
/// <summary>
/// Gets or sets the target.
/// </summary>
/// <value>The target.</value>
protected object Target { get; set; }
object IForwarder.Target => Target;
/// <summary>
/// Gets the call target.
/// </summary>
/// <value>The call target.</value>
protected virtual object CallTarget => Target;
/// <summary>
/// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
/// </returns>
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (CallTarget == null)
{
result = null;
return false;
}
if (Dynamic.InvokeIsEvent(CallTarget, binder.Name))
{
result = new AddRemoveMarker();
return true;
}
try
{
result = Dynamic.InvokeGet(CallTarget, binder.Name);
}
catch (RuntimeBinderException)
{
result = null;
return false;
}
return true;
}
#pragma warning disable 1734
/// <summary>
/// Provides the implementation for operations that invoke an object. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for operations such as invoking an object or a delegate.
/// </summary>
/// <param name="binder">Provides information about the invoke operation.</param>
/// <param name="args">The arguments that are passed to the object during the invoke operation. For example, for the sampleObject(100) operation, where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, <paramref name="args[0]" /> is equal to 100.</param>
/// <param name="result">The result of the object invocation.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.
/// </returns>
#pragma warning restore 1734
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
{
if (CallTarget == null)
{
result = null;
return false;
}
var tArgs = Util.NameArgsIfNecessary(binder.CallInfo, args);
try
{
result = Dynamic.Invoke(CallTarget, tArgs);
}
catch (RuntimeBinderException)
{
result = null;
try
{
Dynamic.InvokeAction(CallTarget, tArgs);
}
catch (RuntimeBinderException)
{
return false;
}
}
return true;
}
/// <summary>
/// Tries the invoke member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
if (CallTarget == null)
{
result = null;
return false;
}
object[] tArgs = Util.NameArgsIfNecessary(binder.CallInfo, args);
Type[] types = null;
try
{
//.net core
// Try and pull generic arguments from binder
IList<Type> typeList = Dynamic.InvokeGet(binder,
"TypeArguments");
if (typeList != null)
{
types = typeList.ToArray();
}
}
catch (RuntimeBinderException)
{
types = null;
}
if (types == null)
{
try
{
//.net 4.0
// Try and pull generic arguments from binder
IList<Type> typeList = Dynamic.InvokeGet(binder,
"Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder.TypeArguments");
if (typeList != null)
{
types = typeList.ToArray();
}
}
catch (RuntimeBinderException)
{
types = null;
}
}
var name = InvokeMemberName.Create;
var fullName = name(binder.Name, types);
try
{
result = Dynamic.InvokeMember(CallTarget, fullName, tArgs);
}
catch (RuntimeBinderException)
{
result = null;
try
{
Dynamic.InvokeMemberAction(CallTarget, fullName, tArgs);
}
catch (RuntimeBinderException)
{
return false;
}
}
return true;
}
/// <summary>
/// Tries the set member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public override bool TrySetMember(SetMemberBinder binder, object value)
{
if (CallTarget == null)
{
return false;
}
if (Dynamic.InvokeIsEvent(CallTarget, binder.Name) && value is AddRemoveMarker arm)
{
if (arm.IsAdding)
{
Dynamic.InvokeAddAssignMember(CallTarget, binder.Name, arm.Delegate);
}
else
{
Dynamic.InvokeSubtractAssignMember(CallTarget, binder.Name, arm.Delegate);
}
return true;
}
try
{
Dynamic.InvokeSet(CallTarget, binder.Name, value);
return true;
}
catch (RuntimeBinderException)
{
return false;
}
}
/// <summary>
/// Tries the index of the get.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
{
if (CallTarget == null)
{
result = null;
return false;
}
object[] tArgs = Util.NameArgsIfNecessary(binder.CallInfo, indexes);
try
{
result = Dynamic.InvokeGetIndex(CallTarget, tArgs);
return true;
}
catch (RuntimeBinderException)
{
result = null;
return false;
}
}
/// <summary>
/// Tries the index of the set.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
{
if (CallTarget == null)
{
return false;
}
var tCombinedArgs = indexes.Concat(new[] { value }).ToArray();
object[] tArgs = Util.NameArgsIfNecessary(binder.CallInfo, tCombinedArgs);
try
{
Dynamic.InvokeSetIndex(CallTarget, tArgs);
return true;
}
catch (RuntimeBinderException)
{
return false;
}
}
/// <summary>
/// Equals the specified other.
/// </summary>
/// <param name="other">The other.</param>
/// <returns></returns>
public bool Equals(BaseForwarder other)
{
if (ReferenceEquals(null, other)) return ReferenceEquals(null, CallTarget);
if (ReferenceEquals(this, other)) return true;
return Equals(other.CallTarget, CallTarget);
}
/// <summary>
/// Determines whether the specified <see cref="System.Object" /> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return ReferenceEquals(null, CallTarget);
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (BaseForwarder)) return false;
return Equals((BaseForwarder) obj);
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return (CallTarget != null ? CallTarget.GetHashCode() : 0);
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/BaseObject.cs
================================================
//
// Copyright 2010 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using Dynamitey.Internal.Compat;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Can Represent an equivalent static type to help dynamically convert member output
/// </summary>
public interface IEquivalentType
{
/// <summary>
/// Gets or sets the type of the equivalent.
/// </summary>
/// <value>
/// The type of the equivalent.
/// </value>
FauxType EquivalentType { get; set; }
}
/// <summary>
/// Dynamic Object that knows about the Impromtu Interface return types;
/// Override Typical Dynamic Object methods, and use TypeForName to get the return type of an interface member.
/// </summary>
public abstract class BaseObject : DynamicObject, IEquivalentType
{
/// <summary>
/// Initializes a new instance of the <see cref="BaseObject"/> class.
/// </summary>
protected BaseObject()
{
}
/// <summary>
/// Tries the name of the member to see if it has a type.
/// </summary>
/// <param name="binderName">Name of the binder.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public bool TryTypeForName(string binderName, out Type type)
{
var eqType = (IEquivalentType) this;
type = null;
if (eqType.EquivalentType == null)
return false;
var types = eqType.EquivalentType.GetMember(binderName)
.Select(it =>
{
switch (it)
{
case PropertyInfo p:
return p.PropertyType;
case MethodInfo m:
return m.ReturnType;
case EventInfo e:
return e.EventHandlerType;
#if NETFRAMEWORK || PROFILE158
case Type t:
return t;
#else
case TypeInfo t:
return t.UnderlyingSystemType;
#endif
default:
return typeof (object);
}
}).ToList();
;
if (!types.Any())
return false;
foreach (var currenttype in types)
{
if (type == null || type.Name == currenttype.Name)
type = currenttype;
else
type = typeof (object);
}
return true;
}
FauxType IEquivalentType.EquivalentType { get; set; }
}
}
================================================
FILE: Dynamitey/DynamicObjects/Builder.cs
================================================
//
// Copyright 2011 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Reflection;
using Dynamitey.Internal.Optimization;
using Dynamitey.Internal.Compat;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Interface for simplistic builder options
/// </summary>
public interface IBuilder
{
/// <summary>
/// Creates a prototype list
/// </summary>
/// <param name="contents">The contents.</param>
/// <returns></returns>
dynamic List(params dynamic[] contents);
/// <summary>
/// Setup List or Array, takes either one <see cref="Activate"/> or a list of constructor args that will use objects Type
/// </summary>
/// <param name="constructorArgs">The constructor args.</param>
/// <returns></returns>
dynamic ListSetup(params dynamic[] constructorArgs);
/// <summary>
/// Setup List or Array if list has a default constrcutor
/// </summary>
/// <typeparam name="TList"></typeparam>
/// <returns></returns>
dynamic ListSetup<TList>();
/// <summary>
/// Setup List or Array, takes either one <see cref="Activate"/> or a list of constructor args that will use objects Type
/// </summary>
/// <param name="constructorArgsFactory">The constructor args factory.</param>
/// <returns></returns>
dynamic ListSetup(Func<object[]> constructorArgsFactory);
/// <summary>
/// Setup List or Array if list has a default constrcutor
/// </summary>
/// <typeparam name="TList"></typeparam>
/// <returns></returns>
dynamic ArraySetup<TList>();
/// <summary>
/// Alternative name for <see cref="ListSetup(object[])"/>
/// </summary>
/// <param name="constructorArgs">The constructor args.</param>
/// <returns></returns>
dynamic ArraySetup(params dynamic[] constructorArgs);
/// <summary>
/// Alternative name for <see cref="ListSetup{TList}"/>
/// </summary>
/// <param name="constructorArgsFactory">The constructor args factory.</param>
/// <returns></returns>
dynamic ArraySetup(Func<object[]> constructorArgsFactory);
/// <summary>
/// Alternative name for <see cref="List"/>
/// </summary>
/// <param name="contents">The contents.</param>
/// <returns></returns>
dynamic Array(params dynamic[] contents);
/// <summary>
/// Generates Object, use by calling with named arguments <code>builder.Object(Prop1:"test",Prop2:"test")</code>
/// returns new object;
/// </summary>
dynamic Object { get; }
/// <summary>
/// Sets up object builder
/// </summary>
/// <param name="constructorArgs">The constructor args.</param>
/// <returns></returns>
dynamic ObjectSetup(params dynamic[] constructorArgs);
/// <summary>
/// Sets up object builder
/// </summary>
/// <param name="constructorArgsFactory"></param>
/// <returns></returns>
dynamic ObjectSetup(Func<object[]> constructorArgsFactory);
/// <summary>
/// Setups up named builders
/// </summary>
/// <value>The setup.</value>
dynamic Setup { get; }
}
/// <summary>
/// Builds Expando-Like Objects with an inline Syntax
/// </summary>
/// <typeparam name="TObjectProtoType">The type of the object proto type.</typeparam>
public class Builder<TObjectProtoType>: BaseObject, IBuilder
{
/// <summary>
/// Build factory storage
/// </summary>
protected IDictionary<string,Activate> _buildType;
/// <summary>
/// Initializes a new instance of the <see cref="Builder{TObjectProtoType}"/> class.
/// </summary>
public Builder(){
_buildType = new Dictionary<string, Activate>();
Setup = new SetupTrampoline<TObjectProtoType>(this);
Object = new BuilderTrampoline<TObjectProtoType>(this);
}
/// <summary>
/// Creates a prototype list
/// </summary>
/// <param name="contents">The contents.</param>
/// <returns></returns>
public dynamic List(params dynamic[] contents)
{
if (!_buildType.TryGetValue("List", out var tBuildType))
tBuildType = null;
if (tBuildType != null)
{
dynamic tList = tBuildType.Create();
if (contents != null)
{
foreach (var item in contents)
{
tList.Add(item);
}
}
return tList;
}
return new List(contents);
}
/// <summary>
/// Setup List or Array, takes either one <see cref="Activate" /> or a list of constructor args that will use objects Type
/// </summary>
/// <param name="constructorArgs">The constructor args.</param>
/// <returns></returns>
public dynamic ListSetup(params dynamic[] constructorArgs)
{
var tActivate =constructorArgs.OfType<Activate>().SingleOrDefault();
if (tActivate == null)
{
if (!_buildType.TryGetValue("Object", out tActivate))
tActivate = null;
if (tActivate != null)
{
tActivate = new Activate(tActivate.Type,constructorArgs);
}
if(tActivate == null)
tActivate = new Activate<List>(constructorArgs);
}
_buildType["List"] = tActivate;
_buildType["Array"] = tActivate;
return this;
}
/// <summary>
/// Setup List or Array if list has a default constrcutor
/// </summary>
/// <typeparam name="TList"></typeparam>
/// <returns></returns>
public dynamic ListSetup<TList>()
{
return ListSetup(new Activate<TList>());
}
/// <summary>
/// Setup List or Array, takes either one <see cref="Activate" /> or a list of constructor args that will use objects Type
/// </summary>
/// <param name="constructorArgsFactory">The constructor args factory.</param>
/// <returns></returns>
public dynamic ListSetup(Func<object[]> constructorArgsFactory)
{
return ListSetup((object)constructorArgsFactory);
}
/// <summary>
/// Setup List or Array if list has a default constrcutor
/// </summary>
/// <typeparam name="TList"></typeparam>
/// <returns></returns>
public dynamic ArraySetup<TList>()
{
return ListSetup(new Activate<TList>());
}
/// <summary>
/// Alternative name for <see cref="ListSetup(object[])" />
/// </summary>
/// <param name="constructorArgs">The constructor args.</param>
/// <returns></returns>
public dynamic ArraySetup(params dynamic[] constructorArgs)
{
return ListSetup(constructorArgs);
}
/// <summary>
/// Alternative name for <see cref="ListSetup{TList}" />
/// </summary>
/// <param name="constructorArgsFactory">The constructor args factory.</param>
/// <returns></returns>
public dynamic ArraySetup(Func<object[]> constructorArgsFactory)
{
return ListSetup((object)constructorArgsFactory);
}
/// <summary>
/// Alternative name for <see cref="List"/>
/// </summary>
/// <param name="contents">The contents.</param>
/// <returns></returns>
public dynamic Array(params dynamic[] contents)
{
return List(contents);
}
/// <summary>
/// Creates a Prototype object.
/// </summary>
/// <value>The object.</value>
public dynamic Object { get; }
/// <summary>
/// Sets up object builder
/// </summary>
/// <param name="constructorArgs">The constructor args.</param>
/// <returns></returns>
public dynamic ObjectSetup(params dynamic[] constructorArgs)
{
_buildType["Object"] = new Activate<TObjectProtoType>(constructorArgs);
return this;
}
/// <summary>
/// Sets up object builder
/// </summary>
/// <param name="constructorArgsFactory"></param>
/// <returns></returns>
public dynamic ObjectSetup(Func<object[]> constructorArgsFactory)
{
return ObjectSetup((object) constructorArgsFactory);
}
/// <summary>
/// Trapoline for setting up Builders
/// </summary>
public dynamic Setup { get; private set; }
///<summary>
/// Trampoline for builder
///</summary>
public class BuilderTrampoline<TInnerObjectProtoType> : DynamicObject
{
Builder<TInnerObjectProtoType> _buider;
/// <summary>
/// Initializes a new instance of the <see cref="Builder{TObjectProtoType}.BuilderTrampoline"/> class.
/// </summary>
/// <param name="builder">The builder.</param>
public BuilderTrampoline(Builder<TInnerObjectProtoType> builder)
{
_buider = builder;
}
/// <summary>
/// Tries the invoke.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
{
if (!_buider._buildType.TryGetValue("Object", out var tBuildType))
tBuildType = null;
result = InvokeHelper(binder.CallInfo, args, tBuildType);
return true;
}
}
/// <summary>
/// Trampoline for setup builder
/// </summary>
public class SetupTrampoline<TInnerObjectProtoType> : DynamicObject
{
Builder<TInnerObjectProtoType> _buider;
/// <summary>
/// Initializes a new instance of the <see cref="Builder{TObjectProtoType}.SetupTrampoline"/> class.
/// </summary>
/// <param name="builder">The builder.</param>
public SetupTrampoline(Builder<TInnerObjectProtoType> builder){
_buider = builder;
}
/// <summary>
/// Tries the invoke.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentException">Requires argument names for every argument</exception>
public override bool TryInvoke(InvokeBinder binder, dynamic[] args, out object result)
{
if (binder.CallInfo.ArgumentNames.Count != binder.CallInfo.ArgumentCount)
throw new ArgumentException("Requires argument names for every argument");
var tArgs = args.Select(it => it is Type ? new Activate(it) : (Activate) it);
foreach (var tKeyPair in binder.CallInfo.ArgumentNames.Zip(tArgs, (n, a) => new KeyValuePair<string, Activate>(n, a)))
{
_buider._buildType[tKeyPair.Key]=tKeyPair.Value;
}
result = _buider;
return true;
}
}
/// <summary>
/// Tries the set member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public override bool TrySetMember(SetMemberBinder binder, dynamic value){
if (value != null)
{
if (value is Type)
{
_buildType[binder.Name] = new Activate(value);
return true;
}
if (value is Activate)
{
_buildType[binder.Name] = value;
return true;
}
}
else
{
_buildType[binder.Name] = null;
return true;
}
return false;
}
/// <summary>
/// Tries the invoke member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
if(!_buildType.TryGetValue(binder.Name, out var tBuildType))
tBuildType = null;
if (tBuildType == null && !_buildType.TryGetValue("Object", out tBuildType))
tBuildType = null;
result = InvokeHelper(binder.CallInfo, args,tBuildType);
if (TryTypeForName(binder.Name, out var tType))
{
var typeInfo = tType.GetTypeInfo();
if (Dynamic.Impromptu.IsAvailable && typeInfo.IsInterface && result != null && !typeInfo.IsAssignableFrom(result.GetType()))
{
result = Dynamic.Impromptu.DynamicActLike(result, tType);
}
}
return true;
}
private static object InvokeHelper(CallInfo callinfo, IList<object> args, Activate buildType =null)
{
bool tSetWithName = true;
object tArg = null;
if (callinfo.ArgumentNames.Count == 0 && callinfo.ArgumentCount == 1)
{
tArg =args[0];
if (Util.IsAnonymousType(tArg) || tArg is IEnumerable<KeyValuePair<string, object>>)
{
tSetWithName = false;
}
}
if (tSetWithName && callinfo.ArgumentNames.Count != callinfo.ArgumentCount)
throw new ArgumentException("Requires argument names for every argument");
object result;
if (buildType != null)
{
result = buildType.Create();
}
else{
try
{
result = Activator.CreateInstance<TObjectProtoType>();//Try first because faster but doens't work with optional parameters
}
catch (Exception)
{
result = Dynamic.InvokeConstructor(typeof (TObjectProtoType));
}
}
if(tSetWithName)
{
tArg = callinfo.ArgumentNames.Zip(args, (n, a) => new KeyValuePair<string, object>(n, a));
}
return Dynamic.InvokeSetAll(result, tArg);
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/Dictionary.cs
================================================
//
// Copyright 2010 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Reflection;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Similar to Expando Objects but handles null values when the property is defined with an impromptu interface
/// </summary>
public class Dictionary:BaseDictionary,IDictionary<string,object>
{
/// <summary>
/// Initializes a new instance of the <see cref="Dictionary"/> class.
/// </summary>
public Dictionary()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Dictionary"/> class.
/// </summary>
/// <param name="dict">The dict.</param>
public Dictionary(IEnumerable<KeyValuePair<string, object>> dict) : base(dict)
{
}
/// <summary>
/// Gets the count.
/// </summary>
/// <value>The count.</value>
public int Count => _dictionary.Count;
/// <summary>
/// Gets the enumerator.
/// </summary>
/// <returns></returns>
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
return _dictionary.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <summary>
/// Clears this instance.
/// </summary>
public void Clear()
{
var tKeys = Keys;
_dictionary.Clear();
foreach (var tKey in tKeys)
{
OnPropertyChanged(tKey);
}
}
/// <summary>
/// Gets or sets the <see cref="System.Object"/> with the specified key.
/// </summary>
/// <value></value>
public object this[string key]
{
get => _dictionary[key];
set => SetProperty(key, value);
}
}
/// <summary>
/// Adds extra synatx to intialize properties to match up with clay
/// </summary>
public class ChainableDictionary:Dictionary{
/// <summary>
/// Initializes a new instance of the <see cref="ChainableDictionary"/> class.
/// </summary>
public ChainableDictionary()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Dictionary"/> class.
/// </summary>
/// <param name="dict">The dict.</param>
public ChainableDictionary(IEnumerable<KeyValuePair<string, object>> dict) : base(dict)
{
}
/// <summary>
/// Provides the implementation for operations that invoke a member. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for operations such as calling a method.
/// </summary>
/// <param name="binder">Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="args">The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, <paramref name="args" /> is equal to 100.</param>
/// <param name="result">The result of the member invocation.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TryInvokeMember (InvokeMemberBinder binder, object[] args, out object result)
{
if(base.TryInvokeMember (binder, args, out result)){
return true;
}
if(binder.CallInfo.ArgumentCount ==1){
SetProperty(binder.Name, args.FirstOrDefault());
result = this;
return true;
}
if (binder.CallInfo.ArgumentCount > 1)
{
SetProperty(binder.Name,new List(args));
result = this;
return true;
}
return false;
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/Dummy.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dynamitey.Internal.Optimization;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Dummy that just returns null or default for everything.
/// </summary>
public class Dummy:BaseObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Dummy"/> class.
/// </summary>
public Dummy()
{
}
/// <summary>
/// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
/// </returns>
public override bool TryGetMember(System.Dynamic.GetMemberBinder binder, out object result)
{
result = null;
return this.MassageResultBasedOnInterface(binder.Name, true, ref result);
}
/// <summary>
/// Provides the implementation for operations that set member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as setting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="value">The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, the <paramref name="value"/> is "Test".</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TrySetMember(System.Dynamic.SetMemberBinder binder, object value)
{
return true;
}
/// <summary>
/// Provides the implementation for operations that invoke a member. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as calling a method.
/// </summary>
/// <param name="binder">Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="args">The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, <paramref name="args"/> is equal to 100.</param>
/// <param name="result">The result of the member invocation.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder binder, object[] args, out object result)
{
result = null;
return this.MassageResultBasedOnInterface(binder.Name, true, ref result);
}
/// <summary>
/// Tries the index of the get.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
{
result = null;
return this.MassageResultBasedOnInterface(Invocation.IndexBinderName, true, ref result);
}
/// <summary>
/// Tries the index of the set.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
{
return true;
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/ExtensionToInstanceProxy.cs
================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.CSharp.RuntimeBinder;
using Dynamitey.Internal.Compat;
using Dynamitey.Internal.Optimization;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Proxy that can turn extension methods into instance methods
/// </summary>
public class ExtensionToInstanceProxy: BaseForwarder
{
private readonly Type _extendedType;
private readonly Type[] _staticTypes;
private readonly Type[] _instanceHints;
/// <summary>
/// Gets the instance hints.
/// </summary>
/// <value>
/// The instance hints.
/// </value>
public IEnumerable<Type> InstanceHints => _instanceHints;
/// <summary>
/// Initializes a new instance of the <see cref="ExtensionToInstanceProxy" /> class.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="extendedType">Type of the extended.</param>
/// <param name="staticTypes">The static types.</param>
/// <param name="instanceHints">The instance hints.</param>
/// <exception cref="System.ArgumentException">Don't Nest ExtensionToInstance Objects</exception>
public ExtensionToInstanceProxy(dynamic target, Type extendedType, Type[] staticTypes, Type[] instanceHints = null):base((object)target)
{
_staticTypes = staticTypes;
_extendedType = extendedType;
_instanceHints = instanceHints;
if(target is ExtensionToInstanceProxy)
throw new ArgumentException("Don't Nest ExtensionToInstance Objects");
if (IsExtendedType(target) || IsExtendedType(Util.GetTargetContext(target,out Type _, out bool _)))
{
return;
}
throw new ArgumentException($"Non a valid {_extendedType} to be wrapped.");
}
private object UnwrappedTarget(){
return Util.GetTargetContext(CallTarget, out Type _, out bool _);
}
/// <summary>
/// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result" />.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
/// </returns>
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (!base.TryGetMember(binder, out result))
{
var tInterface = UnwrappedTarget().GetType().GetTypeInfo().GetInterfaces().Single(it => it.Name == _extendedType.Name);
var typeInfo = tInterface.GetTypeInfo();
result = new Invoker(binder.Name,
typeInfo.IsGenericType ? typeInfo.GetGenericArguments() : new Type[] {},null, this);
}
return true;
}
/// <summary>
/// Basic Invoker syntax for dynamic generics
/// </summary>
public class Invoker:BaseObject
{
/// <summary>
/// The name
/// </summary>
protected string Name;
/// <summary>
/// The parent
/// </summary>
protected ExtensionToInstanceProxy Parent;
/// <summary>
/// The overload types
/// </summary>
protected IDictionary<int, Type[]> OverloadTypes;
/// <summary>
/// The generic params
/// </summary>
protected Type[] GenericParams;
/// <summary>
/// The generic method parameters
/// </summary>
protected Type[] GenericMethodParameters;
internal Invoker(string name, Type[] genericParameters, Type[] genericMethodParameters, ExtensionToInstanceProxy parent, Type[] overloadTypes = null)
{
Name = name;
Parent = parent;
GenericParams = genericParameters;
GenericMethodParameters = genericMethodParameters;
OverloadTypes = new Dictionary<int,Type[]>();
if (overloadTypes == null)
{
foreach (var tGenInterface in parent.InstanceHints)
{
var tNewType = tGenInterface;
if (tNewType.GetTypeInfo().IsGenericType)
{
tNewType = tNewType.MakeGenericType(GenericParams);
}
var members = tNewType.GetTypeInfo().GetMethods(BindingFlags.Instance |
BindingFlags.Public).Where(
it => it.Name == Name).ToList();
foreach (var tMethodInfo in members)
{
var tParams = tMethodInfo.GetParameters().Select(it => it.ParameterType).ToArray();
if (OverloadTypes.ContainsKey(tParams.Length))
{
OverloadTypes[tParams.Length] = new Type[] {};
}
else
{
OverloadTypes[tParams.Length] = tParams.Select(ReplaceGenericTypes).ToArray();
}
}
foreach (var tOverloadType in OverloadTypes.ToList())
{
if (tOverloadType.Value.Length == 0)
{
OverloadTypes.Remove(tOverloadType);
}
}
}
}
else
{
OverloadTypes[overloadTypes.Length] = overloadTypes;
}
}
private Type ReplaceGenericTypes(Type type)
{
var typeInfo = type.GetTypeInfo();
if (typeInfo.IsGenericType && typeInfo.ContainsGenericParameters)
{
var tArgs = typeInfo.GetGenericArguments();
tArgs = tArgs.Select(ReplaceGenericTypes).ToArray();
return type.GetGenericTypeDefinition().MakeGenericType(tArgs);
}
if (typeInfo.ContainsGenericParameters)
{
return typeof (object);
}
return type;
}
/// <summary>
/// Tries the get member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (binder.Name == "Overloads")
{
result = new OverloadInvoker(Name, GenericParams,GenericMethodParameters, Parent);
return true;
}
return base.TryGetMember(binder, out result);
}
/// <summary>
/// Tries the invoke.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
{
object[] tArgs = args;
if (OverloadTypes.ContainsKey(args.Length))
{
tArgs = OverloadTypes[args.Length].Zip(args, Tuple.Create)
.Select(it => it.Item2 != null ? Dynamic.InvokeConvert(it.Item2, it.Item1, @explicit: true) : null).ToArray();
}
var name = InvokeMemberName.Create(Name, GenericMethodParameters);
result = Parent.InvokeStaticMethod(name, tArgs);
return true;
}
/// <summary>
/// Tries the index of the get.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
{
result = new Invoker(Name, GenericParams, indexes.Select(it => Dynamic.InvokeConvert(it, typeof(Type), @explicit: true)).Cast<Type>().ToArray(), Parent);
return true;
}
}
/// <summary>
/// Overload Invoker
/// </summary>
public class OverloadInvoker:Invoker
{
internal OverloadInvoker(string name, Type[] genericParameters, Type[] genericMethodParameters, ExtensionToInstanceProxy parent)
: base(name, genericParameters,genericMethodParameters, parent)
{
}
/// <summary>
/// Tries the index of the get.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
{
result = new Invoker(Name, GenericParams, GenericMethodParameters, Parent, indexes.Select(it => Dynamic.InvokeConvert(it, typeof(Type), @explicit: true)).Cast<Type>().ToArray());
return true;
}
}
/// <summary>
/// Tries the invoke member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder binder, object[] args, out object result)
{
if (!base.TryInvokeMember(binder, args, out result))
{
Type[] types = null;
try
{
IList<Type> typeList =Dynamic.InvokeGet(binder,
"Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder.TypeArguments");
if(typeList != null)
{
types = typeList.ToArray();
}
}catch(RuntimeBinderException)
{
try
{
IList<Type> typeList = Dynamic.InvokeGet(binder,
"TypeArguments");
if (typeList != null)
{
types = typeList.ToArray();
}
}
catch (RuntimeBinderException)
{
types = null;
}
}
var name=InvokeMemberName.Create;
result = InvokeStaticMethod(name(binder.Name, types), args);
}
return true;
}
/// <summary>
/// Invokes the static method.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
protected object InvokeStaticMethod(String_OR_InvokeMemberName name, object[] args)
{
var staticType = InvokeContext.CreateStatic;
var nameArgs = InvokeMemberName.Create;
var tList = new List<object> { UnwrappedTarget() };
tList.AddRange(args);
object result =null;
var sucess = false;
var exceptionList = new List<Exception>();
var tGenericPossibles = new List<Type[]>();
if (name.GenericArgs != null && name.GenericArgs.Length > 0)
{
var tInterface = UnwrappedTarget().GetType().GetTypeInfo().GetInterfaces().Single(it => it.Name == _extendedType.Name);
var tTypeGenerics = (tInterface.GetTypeInfo().IsGenericType ? tInterface.GetTypeInfo().GetGenericArguments()
: new Type[] { }).Concat(name.GenericArgs).ToArray();
tGenericPossibles.Add(tTypeGenerics);
tGenericPossibles.Add(name.GenericArgs);
}
else
{
tGenericPossibles.Add(null);
}
foreach (var sType in _staticTypes)
{
foreach (var tGenericPossible in tGenericPossibles)
{
try
{
result = Dynamic.InvokeMember(staticType(sType), nameArgs(name.Name, tGenericPossible), tList.ToArray());
sucess = true;
break;
}
catch (RuntimeBinderException ex)
{
exceptionList.Add(ex);
}
}
if(sucess){
break;
}
}
if (!sucess)
{
throw exceptionList.First();
}
if (TryTypeForName(name.Name, out var tOutType))
{
var outTypeInfo = tOutType.GetTypeInfo();
if (outTypeInfo.IsInterface)
{
var tIsGeneric = outTypeInfo.IsGenericType;
if (outTypeInfo.IsGenericType)
{
tOutType = tOutType.GetGenericTypeDefinition();
}
if (InstanceHints.Select(it => tIsGeneric && it.GetTypeInfo().IsGenericType ? it.GetGenericTypeDefinition() : it)
.Any(it=> it.Name == tOutType.Name))
{
result = CreateSelf(result, _extendedType, _staticTypes, _instanceHints);
}
}
}
else
{
if (IsExtendedType(result))
{
result = CreateSelf(result, _extendedType, _staticTypes, _instanceHints);
}
}
return result;
}
/// <summary>
/// Creates the self.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="extendedType">Type of the extended.</param>
/// <param name="staticTypes">The static types.</param>
/// <param name="instanceHints">The instance hints.</param>
/// <returns></returns>
protected virtual ExtensionToInstanceProxy CreateSelf(object target, Type extendedType, Type[] staticTypes, Type[] instanceHints)
{
return new ExtensionToInstanceProxy(target,extendedType,staticTypes, instanceHints);
}
private bool IsExtendedType(object target)
{
if (target is ExtensionToInstanceProxy)
{
return false;
}
bool genericDef = _extendedType.GetTypeInfo().IsGenericTypeDefinition;
return target.GetType().GetTypeInfo().GetInterfaces().Any(
it => ((genericDef && it.GetTypeInfo().IsGenericType) ? it.GetGenericTypeDefinition() : it).Name == _extendedType.Name);
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/Factory.cs
================================================
//
// Copyright 2010 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Base Class for making a fluent factory using an Impromptu Interface return type.
/// </summary>
public class BaseFactory:BaseObject
{
/// <summary>
/// Provides the default implementation for operations that get instance as defined by <see cref="GetInstanceForDynamicMember"/>. Classes derived from the <see cref="T:ImpromptuInterface.ImpromptuObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
/// </returns>
public override bool TryGetMember(System.Dynamic.GetMemberBinder binder, out object result)
{
result = GetInstanceForDynamicMember(binder.Name);
return result != null;
}
/// <summary>
/// Provides the implementation for operations that invoke a member. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as calling a method.
/// </summary>
/// <param name="binder">Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="args">The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, <paramref name="args"/>[0] is equal to 100.</param>
/// <param name="result">The result of the member invocation.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder binder, object[] args, out object result)
{
result = GetInstanceForDynamicMember(binder.Name, args);
return result != null;
}
/// <summary>
/// Constructs the type. Override for changing type intialization property changes.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
protected virtual object CreateType(Type type, params object[] args)
{
return Dynamic.InvokeConstructor(type, args);
}
/// <summary>
/// Gets the instance for a dynamic member. Override for type constrcution behavoir changes based on property name.
/// </summary>
/// <param name="memberName">Name of the member.</param>
/// <param name="args">The args.</param>
/// <returns></returns>
protected virtual object GetInstanceForDynamicMember(string memberName, params object[] args)
{
return TryTypeForName(memberName, out var type) ? CreateType(type, args) : null;
}
}
/// <summary>
/// Base Class for making a singleton fluent factory using an Impromptu Interface return type.
/// </summary>
public class BaseSingleInstancesFactory : BaseFactory
{
/// <summary>
/// Store Singletons
/// </summary>
protected readonly Dictionary<string, dynamic> _hashFactoryTypes= new Dictionary<string, dynamic>();
/// <summary>
/// Lock for accessing singletons
/// </summary>
protected readonly object _lockTable = new object();
/// <summary>
/// Gets the instance for a dynamic member. Override for type constrcution behavoir changes based on property name.
/// </summary>
/// <param name="memberName">Name of the member.</param>
/// <param name="args"></param>
/// <returns></returns>
protected override object GetInstanceForDynamicMember(string memberName, params object[] args)
{
lock (_lockTable)
{
if (!_hashFactoryTypes.ContainsKey(memberName))
{
if (TryTypeForName(memberName, out var type))
{
_hashFactoryTypes.Add(memberName, CreateType(type, args));
}
else
{
return null;
}
}
return _hashFactoryTypes[memberName];
}
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/FauxType.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Dynamitey.Internal.Compat;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// A Fake Type
/// </summary>
public abstract class FauxType
{
/// <summary>
/// Fauxes the type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public static implicit operator FauxType(Type type)
{
return new RealType(type);
}
/// <summary>
/// Gets the members.
/// </summary>
/// <param name="binderName">Name of the binder.</param>
/// <returns></returns>
public abstract IEnumerable<MemberInfo> GetMember(string binderName);
/// <summary>
/// Gets the contained types.
/// </summary>
/// <returns></returns>
public abstract Type[] GetContainedTypes();
public abstract IEnumerable<string> GetMemberNames();
/// <summary>
/// Determines whether the specified type contains the type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>
/// <c>true</c> if the specified type contains type; otherwise, <c>false</c>.
/// </returns>
public virtual bool ContainsType(Type type)
{
return GetContainedTypes().Contains(type);
}
}
public class PropretySpecType : FauxType
{
public IDictionary<string, Type> PropertySpec { get; }
public PropretySpecType(IDictionary<string, Type> propertySpec)
{
PropertySpec = propertySpec;
}
public override IEnumerable<MemberInfo> GetMember(string binderName)
{
if (PropertySpec.TryGetValue(binderName, out var val))
{
return new[] {val.GetTypeInfo()};
}
return Enumerable.Empty<MemberInfo>();
}
public override IEnumerable<string> GetMemberNames()
{
return PropertySpec.Keys;
}
public override Type[] GetContainedTypes()
{
return new Type []{};
}
}
/// <summary>
/// A Fake Type that represents a real type
/// </summary>
public class RealType : FauxType
{
/// <summary>
/// RealType implicitly conversts to an actualy Type
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public static implicit operator Type(RealType type)
{
return type.TargetType;
}
/// <summary>
/// An actual Type implicitly conversts to a real type
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public static implicit operator RealType(Type type)
{
return new RealType(type);
}
/// <summary>
/// The target type
/// </summary>
protected readonly Type TargetType;
/// <summary>
/// Initializes a new instance of the <see cref="RealType" /> class.
/// </summary>
/// <param name="type">The type.</param>
public RealType(Type type)
{
TargetType = type;
}
/// <summary>
/// Gets the members.
/// </summary>
/// <param name="binderName">Name of the binder.</param>
/// <returns></returns>
public override IEnumerable<MemberInfo> GetMember(string binderName)
{
return TargetType.GetTypeInfo().GetMember(binderName);
}
public override IEnumerable<string> GetMemberNames()
{
var members = TargetType.GetTypeInfo()
.GetMembers(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance)
.Where(it=> !((it as MethodInfo)?.IsHideBySig ?? false))
.Select(it => it.Name)
.Distinct();
return members.ToList();
}
/// <summary>
/// Gets the contained types.
/// </summary>
/// <returns></returns>
public override Type[] GetContainedTypes()
{
return new[] { TargetType };
}
}
/// <summary>
/// A Fake Tupe that is an aggregate of other types
/// </summary>
public class AggreType : FauxType
{
/// <summary>
/// Makes the type appendable.
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public static AggreType MakeTypeAppendable(IEquivalentType type)
{
if (type.EquivalentType == null)
{
type.EquivalentType = new AggreType();
}
if (!(type.EquivalentType is AggreType))
{
type.EquivalentType = new AggreType(type.EquivalentType);
}
return (AggreType) type.EquivalentType;
}
private readonly List<FauxType> Types = new List<FauxType>();
/// <summary>
/// Initializes a new instance of the <see cref="AggreType" /> class.
/// </summary>
/// <param name="types">The types.</param>
public AggreType(params FauxType[] types)
{
Types.AddRange(types);
}
/// <summary>
/// Gets the interface types.
/// </summary>
/// <returns></returns>
public Type[] GetInterfaceTypes()
{
return Types.SelectMany(it => it.GetContainedTypes()).Where(it => it.GetTypeInfo().IsInterface).ToArray();
}
public override IEnumerable<string> GetMemberNames()
{
return Types.SelectMany(it => it.GetMemberNames()).Distinct();
}
/// <summary>
/// Adds the type.
/// </summary>
/// <param name="type">The type.</param>
public void AddType(Type type)
{
if (!ContainsType(type))
{
Types.Add(type);
}
}
/// <summary>
/// Adds the type.
/// </summary>
/// <param name="type">The type.</param>
public void AddType(FauxType type)
{
if (type is RealType)
{
foreach (var realType in type.GetContainedTypes())
{
AddType(realType);
}
}else if (type is AggreType)
{
foreach (var fauxType in ((AggreType)type).Types)
{
AddType(fauxType);
}
}
else
{
Types.Add(type);
}
}
/// <summary>
/// Gets the members.
/// </summary>
/// <param name="binderName">Name of the binder.</param>
/// <returns></returns>
public override IEnumerable<MemberInfo> GetMember(string binderName)
{
var list = new List<MemberInfo>();
foreach (FauxType t in Types)
{
list.AddRange(t.GetMember(binderName));
}
return list;
}
/// <summary>
/// Gets the contained types.
/// </summary>
/// <returns></returns>
public override Type[] GetContainedTypes()
{
return Types.SelectMany(it => it.GetContainedTypes()).ToArray();
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/FluentStringLookup.cs
================================================
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Building block to use Method calls as dynamic lookups
/// </summary>
public class FluentStringLookup:DynamicObject
{
private readonly Func<string, dynamic> _lookup;
/// <summary>
/// Initializes a new instance of the <see cref="FluentStringLookup"/> class.
/// </summary>
/// <param name="lookup">The lookup.</param>
public FluentStringLookup(Func<string,dynamic> lookup)
{
_lookup = lookup;
}
/// <summary>
/// Tries the invoke member.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
result = _lookup(binder.Name);
return true;
}
/// <summary>
/// Tries the invoke.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
{
result = null;
if (args.Length == 1 && args.First() is String)
{
result = _lookup(args[0] as String);
return true;
}
return false;
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/Get.cs
================================================
//
// Copyright 2011 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Dynamic Proxy that exposes any properties of objects, and can massage results based on interface
/// </summary>
public class Get:BaseForwarder
{
/// <summary>
/// Initializes a new instance of the <see cref="Get"/> class.
/// </summary>
/// <param name="target">The target.</param>
public Get(object target):base(target)
{
}
/// <summary>
/// Creates the proxy over the specified target.
/// </summary>
/// <param name="target">The target.</param>
/// <returns></returns>
public static dynamic Create(object target)
{
return new Get(target);
}
/// <summary>
/// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
/// </summary>
/// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
/// </returns>
public override bool TryGetMember(System.Dynamic.GetMemberBinder binder, out object result)
{
if (base.TryGetMember(binder, out result))
{
return this.MassageResultBasedOnInterface(binder.Name, true, ref result);
}
return false;
}
/// <summary>
/// Provides the implementation for operations that invoke a member. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as calling a method.
/// </summary>
/// <param name="binder">Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
/// <param name="args">The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, <paramref name="args"/> is equal to 100.</param>
/// <param name="result">The result of the member invocation.</param>
/// <returns>
/// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
/// </returns>
public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder binder, object[] args, out object result)
{
if (!base.TryInvokeMember(binder, args, out result))
{
try
{
//Check if there is a get property because it might return a function
result = Dynamic.InvokeGet(CallTarget, binder.Name);
}
catch (RuntimeBinderException)
{
return false;
}
if (result == null)
return false;
var tDel = result as Delegate;
if (!binder.CallInfo.ArgumentNames.Any() && tDel != null)
{
try
{
result = this.InvokeMethodDelegate(tDel, args);
}
catch (RuntimeBinderException)
//If it has out parmaters etc it can't be invoked dynamically like this.
//if we return false it will be handle by the GetProperty and then handled by the original dynamic invocation
{
return false;
}
}
try
{
result = Dynamic.Invoke(result, Util.NameArgsIfNecessary(binder.CallInfo, args));
}
catch (RuntimeBinderException)//If it has out parmaters etc it can't be invoked dynamically like this.
//if we return false it will be handle by the GetProperty and then handled by the original dynamic invocation
{
return false;
}
}
return this.MassageResultBasedOnInterface(binder.Name, true, ref result);
}
/// <summary>
/// Tries the index of the get.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="indexes">The indexes.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
{
if (base.TryGetIndex(binder, indexes, out result))
{
return this.MassageResultBasedOnInterface(Invocation.IndexBinderName, true, ref result);
}
return false;
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/LateType.cs
================================================
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using Dynamitey.Internal.Optimization;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Late bind types from libraries not not at compile type
/// </summary>
public class LateType:BaseForwarder
{
/// <summary>
/// Exception When The Late Type can not be found to bind.
/// </summary>
public class MissingTypeException:Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="MissingTypeException" /> class.
/// </summary>
/// <param name="typename">The typename.</param>
public MissingTypeException(string typename)
: base(String.Format("Could Not Find Type. {0}", typename))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MissingTypeException" /> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public MissingTypeException(string message, Exception innerException) : base(message, innerException)
{
}
}
/// <summary>
/// Initializes a new instance of the <see cref="LateType"/> class.
/// </summary>
/// <param name="type">The type.</param>
public LateType(Type type)
: base(type)
{
}
private readonly string TypeName;
public static Type FindType(string typeName, Assembly assembly = null)
{
try
{
if (assembly != null)
{
return assembly.GetType(typeName, false);
}
return Type.GetType(typeName, false);
}
catch
{
return null;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="LateType"/> class.
/// </summary>
/// <param name="typeName">Qualified Name of the type.</param>
public LateType(string typeName)
: base(FindType(typeName))
{
TypeName = typeName;
}
/// <summary>
/// Initializes a new instance of the <see cref="LateType" /> class.
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <param name="typeName">Name of the type.</param>
public LateType(Assembly assembly, string typeName)
: base(FindType(typeName, assembly))
{
TypeName = typeName;
}
/// <summary>
/// Returns a late bound constructor
/// </summary>
/// <value>The late bound constructor</value>
public dynamic @new => new ConstructorForward((Type)Target);
/// <summary>
/// Forward argument to constructor including named arguments
/// </summary>
public class ConstructorForward:DynamicObject
{
private readonly Type _type;
internal ConstructorForward(Type type)
{
_type = type;
}
/// <summary>
/// Tries the invoke.
/// </summary>
/// <param name="binder">The binder.</param>
/// <param name="args">The args.</param>
/// <param name="result">The result.</param>
/// <returns></returns>
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
{
result = Dynamic.InvokeConstructor(_type, Util.NameArgsIfNecessary(binder.CallInfo, args));
return true;
}
}
/// <summary>
/// Gets a value indicating whether this Type is available at runtime.
/// </summary>
/// <value>
/// <c>true</c> if this instance is available; otherwise, <c>false</c>.
/// </value>
public bool IsAvailable => Target != null;
/// <summary>
/// Gets the call target.
/// </summary>
/// <value>
/// The call target.
/// </value>
/// <exception cref="Dynamitey.DynamicObjects.LateType.MissingTypeException"></exception>
protected override object CallTarget
{
get
{
if(Target ==null)
throw new MissingTypeException(TypeName);
return InvokeContext.CreateStatic((Type)Target);
}
}
}
}
================================================
FILE: Dynamitey/DynamicObjects/Lazy.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Abstract base for the Generic class <see cref="Lazy{T}"/> with <see cref="Create{T}(System.Func{T})"/> fatory methods
/// </summary>
public abstract class Lazy:BaseForwarder
{
/// <summary>
/// Creates Lazy based on the specified valuefactory.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="valueFactory">The value factory.</param>
/// <returns></returns>
public static dynamic Create<T>(Func<T> valueFactory)
{
return new Lazy<T>(valueFactory);
}
/// <summary>
/// Creates Lazy based on the specified target.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="target">The target.</param>
/// <returns></returns>
public static dynamic Create<T>(System.Lazy<T> target)
{
return new Lazy<T>(target);
}
/// <summary>
/// Initializes a new instance of the <see cref="Lazy"/> class.
/// </summary>
/// <param name="target">The target.</param>
protected Lazy(object target) : base(target)
{
}
}
/// <summary>
/// Wraps a Lazy Type evalutaes on first method call
/// </summary>
/// <typeparam name="T"></typeparam>
public class Lazy<T> : Lazy
{
/// <summary>
/// Initializes a new instance of the <see cref="Lazy{T}"/> class.
/// </summary>
/// <param name="target">The target.</param>
public Lazy(System.Lazy<T> target) : base(target)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Lazy{T}"/> class.
/// </summary>
/// <param name="valueFactory">The value factory.</param>
public Lazy(Func<T> valueFactory ):base(new System.Lazy<T>(valueFactory))
{
}
/// <summary>
/// Returns the enumeration of all dynamic member names.
/// </summary>
/// <returns>
/// A sequence that contains dynamic member names.
/// </returns>
public override IEnumerable<string> GetDynamicMemberNames()
{
return ((System.Lazy<T>)Target).IsValueCreated
? base.GetDynamicMemberNames()
: Enumerable.Empty<string>();
}
/// <summary>
/// Gets the call target.
/// </summary>
/// <value>
/// The call target.
/// </value>
protected override object CallTarget => ((System.Lazy<T>) Target).Value;
}
}
================================================
FILE: Dynamitey/DynamicObjects/LinqInstanceProxy.cs
================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Extension to Intance Proxy Configured for LINQ IEnumerable methods
/// </summary>
public class LinqInstanceProxy : ExtensionToInstanceProxy, IEnumerable<object>
{
/// <summary>
/// Initializes a new instance of the <see cref="LinqInstanceProxy" /> class.
/// </summary>
/// <param name="target">The target.</param>
public LinqInstanceProxy(dynamic target)
:base(new InvokeContext(target, typeof(object)), typeof(IEnumerable<>), new[]{typeof(Enumerable)}, new[]{typeof(ILinq<>), typeof(IOrderedLinq<>)})
{
}
/// <summary>
/// Creates the self.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="extendedType">Type of the extended.</param>
/// <param name="staticTypes">The static types.</param>
/// <param name="instanceHints">The instance hints.</param>
/// <returns></returns>
protected override ExtensionToInstanceProxy CreateSelf(object target, Type extendedType, Type[] staticTypes, Type[] instanceHints)
{
return new LinqInstanceProxy(target);
}
/// <summary>
/// Gets the enumerator.
/// </summary>
/// <returns></returns>
public IEnumerator<object> GetEnumerator()
{
return ((dynamic) CallTarget).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
#pragma warning disable 1591
// ReSharper disable UnusedMember.Global
public interface ILinq<TSource> : IEnumerable<TSource>
{
TSource Aggregate(Func<TSource, TSource, TSource> func);
TAccumulate Aggregate<TAccumulate>(TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func);
TResult Aggregate<TAccumulate, TResult>(TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector);
Boolean All(Func<TSource, Boolean> predicate);
Boolean Any();
Boolean Any(Func<TSource, Boolean> predicate);
ILinq<TSource> AsEnumerable();
Double Average(Func<TSource, Int32> selector);
Nullable<Double> Average(Func<TSource, Nullable<Int32>> selector);
Double Average(Func<TSource, Int64> selector);
Nullable<Double> Average(Func<TSource, Nullable<Int64>> selector);
Single Average(Func<TSource, Single> selector);
Nullable<Single> Average(Func<TSource, Nullable<Single>> selector);
Double Average(Func<TSource, Double> selector);
Nullable<Double> Average(Func<TSource, Nullable<Double>> selector);
Decimal Average(Func<TSource, Decimal> selector);
Nullable<Decimal> Average(Func<TSource, Nullable<Decimal>> selector);
ILinq<TResult> Cast<TResult>();
ILinq<TSource> Concat(IEnumerable<TSource> second);
Boolean Contains(TSource value);
Boolean Contains(TSource value, IEqualityComparer<TSource> comparer);
Int32 Count();
Int32 Count(Func<TSource, Boolean> predicate);
ILinq<TSource> DefaultIfEmpty();
ILinq<TSource> DefaultIfEmpty(TSource defaultValue);
ILinq<TSource> Distinct();
ILinq<TSource> Distinct(IEqualityComparer<TSource> comparer);
TSource ElementAt(Int32 index);
TSource ElementAtOrDefault(Int32 index);
ILinq<TSource> Except(IEnumerable<TSource> second);
ILinq<TSource> Except(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer);
TSource First();
TSource First(Func<TSource, Boolean> predicate);
TSource FirstOrDefault();
TSource FirstOrDefault(Func<TSource, Boolean> predicate);
ILinq<IGrouping<TKey, TSource>> GroupBy<TKey>(Func<TSource, TKey> keySelector);
ILinq<IGrouping<TKey, TSource>> GroupBy<TKey>(Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer);
ILinq<IGrouping<TKey, TElement>> GroupBy<TKey, TElement>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector);
ILinq<IGrouping<TKey, TElement>> GroupBy<TKey, TElement>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer);
ILinq<TResult> GroupBy<TKey, TResult>(Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector);
ILinq<TResult> GroupBy<TKey, TElement, TResult>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector);
ILinq<TResult> GroupBy<TKey, TResult>(Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer);
ILinq<TResult> GroupBy<TKey, TElement, TResult>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer);
ILinq<TResult> GroupJoin<TInner, TKey, TResult>(IEnumerable<TInner> inner, Func<TSource, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TSource, IEnumerable<TInner>, TResult> resultSelector);
ILinq<TResult> GroupJoin<TInner, TKey, TResult>(IEnumerable<TInner> inner, Func<TSource, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TSource, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer);
ILinq<TSource> Intersect(IEnumerable<TSource> second);
ILinq<TSource> Intersect(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer);
ILinq<TResult> Join<TInner, TKey, TResult>(IEnumerable<TInner> inner, Func<TSource, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TSource, TInner, TResult> resultSelector);
ILinq<TResult> Join<TInner, TKey, TResult>(IEnumerable<TInner> inner, Func<TSource, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TSource, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer);
TSource Last();
TSource Last(Func<TSource, Boolean> predicate);
TSource LastOrDefault();
TSource LastOrDefault(Func<TSource, Boolean> predicate);
Int64 LongCount();
Int64 LongCount(Func<TSource, Boolean> predicate);
TSource Max();
Int32 Max(Func<TSource, Int32> selector);
Nullable<Int32> Max(Func<TSource, Nullable<Int32>> selector);
Int64 Max(Func<TSource, Int64> selector);
Nullable<Int64> Max(Func<TSource, Nullable<Int64>> selector);
Single Max(Func<TSource, Single> selector);
Nullable<Single> Max(Func<TSource, Nullable<Single>> selector);
Double Max(Func<TSource, Double> selector);
Nullable<Double> Max(Func<TSource, Nullable<Double>> selector);
Decimal Max(Func<TSource, Decimal> selector);
Nullable<Decimal> Max(Func<TSource, Nullable<Decimal>> selector);
TResult Max<TResult>(Func<TSource, TResult> selector);
TSource Min();
Int32 Min(Func<TSource, Int32> selector);
Nullable<Int32> Min(Func<TSource, Nullable<Int32>> selector);
Int64 Min(Func<TSource, Int64> selector);
Nullable<Int64> Min(Func<TSource, Nullable<Int64>> selector);
Single Min(Func<TSource, Single> selector);
Nullable<Single> Min(Func<TSource, Nullable<Single>> selector);
Double Min(Func<TSource, Double> selector);
Nullable<Double> Min(Func<TSource, Nullable<Double>> selector);
Decimal Min(Func<TSource, Decimal> selector);
Nullable<Decimal> Min(Func<TSource, Nullable<Decimal>> selector);
TResult Min<TResult>(Func<TSource, TResult> selector);
ILinq<TResult> OfType<TResult>();
IOrderedLinq<TSource> OrderBy<TKey>(Func<TSource, TKey> keySelector);
IOrderedLinq<TSource> OrderBy<TKey>(Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
IOrderedLinq<TSource> OrderByDescending<TKey>(Func<TSource, TKey> keySelector);
IOrderedLinq<TSource> OrderByDescending<TKey>(Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
ILinq<TSource> Reverse();
ILinq<TResult> Select<TResult>(Func<TSource, TResult> selector);
ILinq<TResult> Select<TResult>(Func<TSource, Int32, TResult> selector);
ILinq<TResult> SelectMany<TResult>(Func<TSource, IEnumerable<TResult>> selector);
ILinq<TResult> SelectMany<TResult>(Func<TSource, Int32, IEnumerable<TResult>> selector);
ILinq<TResult> SelectMany<TCollection, TResult>(Func<TSource, Int32, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector);
ILinq<TResult> SelectMany<TCollection, TResult>(Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector);
Boolean SequenceEqual(IEnumerable<TSource> second);
Boolean SequenceEqual(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer);
TSource Single();
TSource Single(Func<TSource, Boolean> predicate);
TSource SingleOrDefault();
TSource SingleOrDefault(Func<TSource, Boolean> predicate);
ILinq<TSource> Skip(Int32 count);
ILinq<TSource> SkipWhile(Func<TSource, Boolean> predicate);
ILinq<TSource> SkipWhile(Func<TSource, Int32, Boolean> predicate);
Int32 Sum(Func<TSource, Int32> selector);
Nullable<Int32> Sum(Func<TSource, Nullable<Int32>> selector);
Int64 Sum(Func<TSource, Int64> selector);
Nullable<Int64> Sum(Func<TSource, Nullable<Int64>> selector);
Single Sum(Func<TSource, Single> selector);
Nullable<Single> Sum(Func<TSource, Nullable<Single>> selector);
Double Sum(Func<TSource, Double> selector);
Nullable<Double> Sum(Func<TSource, Nullable<Double>> selector);
Decimal Sum(Func<TSource, Decimal> selector);
Nullable<Decimal> Sum(Func<TSource, Nullable<Decimal>> selector);
ILinq<TSource> Take(Int32 count);
ILinq<TSource> TakeWhile(Func<TSource, Boolean> predicate);
ILinq<TSource> TakeWhile(Func<TSource, Int32, Boolean> predicate);
TSource[] ToArray();
Dictionary<TKey, TSource> ToDictionary<TKey>(Func<TSource, TKey> keySelector);
Dictionary<TKey, TSource> ToDictionary<TKey>(Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer);
Dictionary<TKey, TElement> ToDictionary<TKey, TElement>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector);
Dictionary<TKey, TElement> ToDictionary<TKey, TElement>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer);
List<TSource> ToList();
ILookup<TKey, TSource> ToLookup<TKey>(Func<TSource, TKey> keySelector);
ILookup<TKey, TSource> ToLookup<TKey>(Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer);
ILookup<TKey, TElement> ToLookup<TKey, TElement>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector);
ILookup<TKey, TElement> ToLookup<TKey, TElement>(Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer);
ILinq<TSource> Union(IEnumerable<TSource> second);
ILinq<TSource> Union(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer);
ILinq<TSource> Where(Func<TSource, Boolean> predicate);
ILinq<TSource> Where(Func<TSource, Int32, Boolean> predicate);
ILinq<TResult> Zip<TSecond, TResult>(IEnumerable<TSecond> second, Func<TSource, TSecond, TResult> resultSelector);
}
public interface IOrderedLinq<TSource> : ILinq<TSource>, IOrderedEnumerable<TSource>
{
IOrderedLinq<TSource> ThenBy<TKey>(Func<TSource, TKey> keySelector);
IOrderedLinq<TSource> ThenBy<TKey>(Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
IOrderedLinq<TSource> ThenByDescending<TKey>(Func<TSource, TKey> keySelector);
IOrderedLinq<TSource> ThenByDescending<TKey>(Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
}
// ReSharper restore UnusedMember.Global
#pragma warning restore 1591
}
================================================
FILE: Dynamitey/DynamicObjects/List.cs
================================================
//
// Copyright 2011 Ekon Benefits
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.CSharp.RuntimeBinder;
namespace Dynamitey.DynamicObjects
{
/// <summary>
/// Expando-Type List for dynamic objects
/// </summary>
public class List : BaseDictionary, IList<object>, IDictionary<string, object>, INotifyCollectionChanged, IList
{
/// <summary>
/// Wrapped list
/// </summary>
protected IList<object> _list;
private static readonly object ListLock = new object();
/// <summary>
/// Initializes a new instance of the <see cref="List"/> class.
/// </summary>
/// <param name="contents">The contents.</param>
/// <param name="members">The members.</param>
public List(
IEnumerable<object> contents =null,
IEnumerable<KeyValuePair<string, object>> members =null):base(members)
{
if (contents == null)
{
_list = new List<object>();
return;
}
if (contents is IList<object>)
{
_list = contents as IList<object>;
}
else
{
_list = contents.ToList();
}
}
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
{
return _dictionary.GetEnumerator();
}
/// <summary>
/// Gets the enumerator.
/// </summary>
/// <returns></returns>
public IEnumerator<dynamic> GetEnumerator()
{
return _list.GetEnumerator();
}
/// <summary>
/// Adds the specified item.
/// </summary>
/// <param name="item">The item.</param>
public void Add(dynamic item)
{
InsertHelper(item);
}
/// <summary>
/// Clears this instance.
/// </summary>
public void Clear()
{
lock (ListLock)
{
_list.Clear();
}
OnCollectionChanged(NotifyCollectionChangedAction.Reset);
}
/// <summary>
/// Determines whether [contains] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns>
/// <c>true</c> if [contains] [the specified item]; otherwise, <c>false</c>.
/// </returns>
public bool Contains(dynamic item)
{
return _list.Contains(item);
}
/// <summary>
/// Copies to.
/// </summary>
/// <param name="array">The array.</param>
/// <param name="arrayIndex">Index of the array.</param>
public void CopyTo(object[] array, int arrayIndex)
{
_list.CopyTo(array, arrayIndex);
}
/// <summary>
/// Gets the count.
/// </summary>
/// <value>The count.</value>
public int Count => _list.Count;
/// <summary>
/// Indexes the of.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public int IndexOf(dynamic item)
{
lock (ListLock)
{
return _list.IndexOf(item);
}
}
/// <summary>
/// Inserts the specified index.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
public void Insert(int index, dynamic item)
{
InsertHelper(item,index);
}
private void InsertHelper(object item, int? index = null)
{
lock (ListLock)
{
if (!index.HasValue)
{
index = _list.Count;
_list.Add(item);
}
else
{
_list.Insert(index.Value, item);
}
}
OnCollectionChanged(NotifyCollectionChangedAction.Add, newItem: item, newIndex: index);
}
/// <summary>
/// Removes at.
/// </summary>
/// <param name="index">The index.</param>
public void RemoveAt(int index)
{
RemoveHelper(index: index);
}
/// <summary>
/// Removes the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Remove(dynamic item)
{
return RemoveHelper(item);
}
private bool RemoveHelper(object item = null, int? index =
gitextract_b38rdefz/ ├── .appveyor.yml ├── .github/ │ └── workflows/ │ ├── dotnet.yml │ └── dotnet48.yml ├── .gitignore ├── .vscode/ │ └── tasks.json ├── Directory.Build.props ├── Dynamitey/ │ ├── Builder.cs │ ├── CacheableInvocation.cs │ ├── Dynamic.cs │ ├── DynamicObjects/ │ │ ├── BaseDictionary.cs │ │ ├── BaseForwarder.cs │ │ ├── BaseObject.cs │ │ ├── Builder.cs │ │ ├── Dictionary.cs │ │ ├── Dummy.cs │ │ ├── ExtensionToInstanceProxy.cs │ │ ├── Factory.cs │ │ ├── FauxType.cs │ │ ├── FluentStringLookup.cs │ │ ├── Get.cs │ │ ├── LateType.cs │ │ ├── Lazy.cs │ │ ├── LinqInstanceProxy.cs │ │ ├── List.cs │ │ ├── Mimic.cs │ │ ├── Recorder.cs │ │ └── RegexMatch.cs │ ├── Dynamitey.csproj │ ├── Expando.cs │ ├── FluentRegex.cs │ ├── InlineLambdas.cs │ ├── InlineLambdas.tt │ ├── Internal/ │ │ ├── Compat/ │ │ │ └── Net40.cs │ │ ├── Curry.cs │ │ ├── InvokeSetters.cs │ │ └── Optimization/ │ │ ├── BareBonesList.cs │ │ ├── BinderHash.cs │ │ ├── InvokeHelper-Regular.cs │ │ ├── InvokeHelper.cs │ │ ├── InvokeHelper.tt │ │ └── Util.cs │ ├── Invocation.cs │ ├── InvokeArg.cs │ ├── InvokeContext.cs │ ├── InvokeMemberName.cs │ ├── PartialApply.cs │ ├── ThisFunctions.cs │ ├── ThisFunctions.tt │ ├── Tupler.cs │ └── sn.snk ├── Dynamitey.sln ├── Dynamitey.sln.DotSettings ├── License.txt ├── NuGet.config ├── Readme.md ├── SupportLibrary/ │ ├── SupportLibrary.csproj │ └── SupportTypes.cs ├── TestResult.xml ├── Tests/ │ ├── Curry.cs │ ├── DynamicObjects.cs │ ├── ExpandoObjs.cs │ ├── Helper.cs │ ├── Impromptu.cs │ ├── Invoke.cs │ ├── Linq.cs │ ├── MimicTest.cs │ ├── PrivateTest.cs │ ├── SpeedTest.cs │ ├── Tests.csproj │ ├── TimeIt.cs │ └── TuplerTest.cs ├── Version.props └── build.fsx
SYMBOL INDEX (1009 symbols across 52 files)
FILE: Dynamitey/Builder.cs
class Builder (line 26) | public static class Builder
method New (line 32) | public static IBuilder New()
method New (line 44) | public static IBuilder New<TObjectPrototype>() where TObjectPrototype ...
class Build (line 55) | public static class Build
class Build (line 80) | public static class Build<TObjectPrototype> where TObjectPrototype : new()
class Activate (line 106) | public class Activate
method Activate (line 113) | public Activate(Type type, params object[] args)
method Activate (line 131) | public Activate(Type type, Func<object[]> args)
method Create (line 155) | public virtual dynamic Create()
method Activate (line 172) | public Activate(params object[] args) : base(typeof(TObjectPrototype),...
method Activate (line 180) | public Activate(Func<object[]> args)
method Create (line 189) | public override dynamic Create()
class Activate (line 166) | public class Activate<TObjectPrototype> : Activate
method Activate (line 113) | public Activate(Type type, params object[] args)
method Activate (line 131) | public Activate(Type type, Func<object[]> args)
method Create (line 155) | public virtual dynamic Create()
method Activate (line 172) | public Activate(params object[] args) : base(typeof(TObjectPrototype),...
method Activate (line 180) | public Activate(Func<object[]> args)
method Create (line 189) | public override dynamic Create()
FILE: Dynamitey/CacheableInvocation.cs
class CacheableInvocation (line 18) | public class CacheableInvocation:Invocation
method CreateConvert (line 26) | public static CacheableInvocation CreateConvert(Type convertType, bool...
method CreateCall (line 39) | public static CacheableInvocation CreateCall(InvocationKind kind, Stri...
method CacheableInvocation (line 77) | public CacheableInvocation(InvocationKind kind,
method Equals (line 166) | public bool Equals(CacheableInvocation other)
method Equals (line 186) | public override bool Equals(object obj)
method GetHashCode (line 199) | public override int GetHashCode()
method Invoke (line 223) | public override object Invoke(object target, params object[] args)
FILE: Dynamitey/Dynamic.cs
class Dynamic (line 40) | public static class Dynamic
method ClearCaches (line 45) | public static void ClearCaches()
method Dynamic (line 68) | static Dynamic()
method CreateCallSite (line 104) | public static CallSite CreateCallSite(Type delegateType, CallSiteBinde...
method CreateCallSite (line 143) | public static CallSite<T> CreateCallSite<T>(CallSiteBinder binder, Str...
method Linq (line 155) | public static dynamic Linq(object enumerable)
method InvokeMember (line 198) | public static dynamic InvokeMember(object target, String_OR_InvokeMemb...
method InvokeBinaryOperator (line 216) | public static dynamic InvokeBinaryOperator(dynamic leftArg, Expression...
method InvokeUnaryOpartor (line 292) | [Obsolete("Use `InvokeUnaryOperator` instead.")]
method InvokeUnaryOperator (line 303) | public static dynamic InvokeUnaryOperator(ExpressionType op, dynamic arg)
method Invoke (line 326) | public static dynamic Invoke(object target, params object[] args)
method InvokeGetIndex (line 342) | public static dynamic InvokeGetIndex(object target, params object[] in...
method InvokeSetValueOnIndexes (line 360) | public static object InvokeSetValueOnIndexes(object target, object val...
method InvokeSetIndex (line 371) | public static object InvokeSetIndex(object target, params object[] ind...
method InvokeMemberAction (line 408) | public static void InvokeMemberAction(object target, String_OR_InvokeM...
method InvokeAction (line 423) | public static void InvokeAction(object target, params object[] args)
method InvokeSet (line 456) | public static object InvokeSet(object target, string name, object value)
method InvokeSetChain (line 472) | public static object InvokeSetChain(object target, string propertyChai...
method Curry (line 532) | public static dynamic Curry(object target, int? totalArgCount = null)
method Curry (line 544) | public static dynamic Curry(Delegate target)
method InvokeGet (line 570) | public static dynamic InvokeGet(object target, string name)
method InvokeGetChain (line 586) | public static dynamic InvokeGetChain(object target, string propertyChain)
method InvokeIsEvent (line 620) | public static bool InvokeIsEvent(object target, string name)
method InvokeAddAssignMember (line 634) | public static void InvokeAddAssignMember(object target, string name, o...
method InvokeSubtractAssignMember (line 654) | public static void InvokeSubtractAssignMember(object target, string na...
method InvokeConvert (line 679) | public static dynamic InvokeConvert(object target, Type type, bool @ex...
method CoerceToDelegate (line 696) | public static dynamic CoerceToDelegate(object invokeableObject, Type d...
method IsDBNull (line 755) | public static bool IsDBNull(object value)
method ApplyEquivalentType (line 774) | public static void ApplyEquivalentType(DynamicObjects.IEquivalentType ...
method ConvertAll (line 792) | [Obsolete("Use ConvertEach.")]
method ConvertEach (line 803) | public static IEnumerable<T> ConvertEach<T>(this System.Collections.IE...
method CoerceConvert (line 814) | public static dynamic CoerceConvert(object target, Type type)
method InvokeConstructor (line 926) | public static dynamic InvokeConstructor(Type type, params object[] args)
method FastDynamicInvoke (line 948) | public static object FastDynamicInvoke(this Delegate del, params objec...
method GenericDelegateType (line 964) | public static Type GenericDelegateType(int paramCount, bool returnVoid...
method GetMemberNames (line 986) | public static IEnumerable<string> GetMemberNames(object target, bool d...
method InvokeCallSite (line 1019) | public static dynamic InvokeCallSite(CallSite callSite, object target,...
FILE: Dynamitey/DynamicObjects/BaseDictionary.cs
class BaseDictionary (line 33) | public abstract class BaseDictionary : BaseObject, INotifyPropertyChanged
method BaseDictionary (line 45) | protected BaseDictionary(IEnumerable<KeyValuePair<string, object>> dic...
method GetDynamicMemberNames (line 85) | public override IEnumerable<string> GetDynamicMemberNames()
method TryGetMember (line 99) | public override bool TryGetMember(GetMemberBinder binder, out object r...
method TryInvokeMember (line 120) | public override bool TryInvokeMember(InvokeMemberBinder binder, object...
method TrySetMember (line 168) | public override bool TrySetMember(SetMemberBinder binder, object value)
method Add (line 179) | public void Add(KeyValuePair<string, object> item)
method Contains (line 191) | public bool Contains(KeyValuePair<string, object> item)
method CopyTo (line 201) | public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
method Remove (line 211) | public bool Remove(KeyValuePair<string, object> item)
method ContainsKey (line 230) | public bool ContainsKey(string key)
method Add (line 240) | public void Add(string key, object value)
method Remove (line 250) | public bool Remove(string key)
method TryGetValue (line 263) | public bool TryGetValue(string key, out object value)
method SetProperty (line 275) | protected void SetProperty(string key, object value)
method OnPropertyChanged (line 288) | protected virtual void OnPropertyChanged(string key)
method Equals (line 312) | public bool Equals(Dictionary other)
method Equals (line 326) | public override bool Equals(object obj)
method GetHashCode (line 340) | public override int GetHashCode()
method ToString (line 351) | public override string ToString()
FILE: Dynamitey/DynamicObjects/BaseForwarder.cs
type IForwarder (line 32) | public interface IForwarder
class BaseForwarder (line 49) | public abstract class BaseForwarder : BaseObject, IForwarder
class AddRemoveMarker (line 55) | public class AddRemoveMarker
method BaseForwarder (line 104) | protected BaseForwarder(object target)
method GetDynamicMemberNames (line 115) | public override IEnumerable<string> GetDynamicMemberNames()
method TryGetMember (line 152) | public override bool TryGetMember(GetMemberBinder binder, out object r...
method TryInvoke (line 190) | public override bool TryInvoke(InvokeBinder binder, object[] args, out...
method TryInvokeMember (line 228) | public override bool TryInvokeMember(InvokeMemberBinder binder, object...
method TrySetMember (line 311) | public override bool TrySetMember(SetMemberBinder binder, object value)
method TryGetIndex (line 353) | public override bool TryGetIndex(GetIndexBinder binder, object[] index...
method TrySetIndex (line 382) | public override bool TrySetIndex(SetIndexBinder binder, object[] index...
method Equals (line 410) | public bool Equals(BaseForwarder other)
method Equals (line 424) | public override bool Equals(object obj)
method GetHashCode (line 438) | public override int GetHashCode()
FILE: Dynamitey/DynamicObjects/BaseObject.cs
type IEquivalentType (line 30) | public interface IEquivalentType
class BaseObject (line 48) | public abstract class BaseObject : DynamicObject, IEquivalentType
method BaseObject (line 54) | protected BaseObject()
method TryTypeForName (line 67) | public bool TryTypeForName(string binderName, out Type type)
FILE: Dynamitey/DynamicObjects/Builder.cs
type IBuilder (line 31) | public interface IBuilder
method List (line 39) | dynamic List(params dynamic[] contents);
method ListSetup (line 46) | dynamic ListSetup(params dynamic[] constructorArgs);
method ListSetup (line 53) | dynamic ListSetup<TList>();
method ListSetup (line 60) | dynamic ListSetup(Func<object[]> constructorArgsFactory);
method ArraySetup (line 67) | dynamic ArraySetup<TList>();
method ArraySetup (line 74) | dynamic ArraySetup(params dynamic[] constructorArgs);
method ArraySetup (line 82) | dynamic ArraySetup(Func<object[]> constructorArgsFactory);
method Array (line 90) | dynamic Array(params dynamic[] contents);
method ObjectSetup (line 103) | dynamic ObjectSetup(params dynamic[] constructorArgs);
method ObjectSetup (line 110) | dynamic ObjectSetup(Func<object[]> constructorArgsFactory);
class Builder (line 124) | public class Builder<TObjectProtoType>: BaseObject, IBuilder
method Builder (line 135) | public Builder(){
method List (line 146) | public dynamic List(params dynamic[] contents)
method ListSetup (line 175) | public dynamic ListSetup(params dynamic[] constructorArgs)
method ListSetup (line 203) | public dynamic ListSetup<TList>()
method ListSetup (line 213) | public dynamic ListSetup(Func<object[]> constructorArgsFactory)
method ArraySetup (line 223) | public dynamic ArraySetup<TList>()
method ArraySetup (line 233) | public dynamic ArraySetup(params dynamic[] constructorArgs)
method ArraySetup (line 243) | public dynamic ArraySetup(Func<object[]> constructorArgsFactory)
method Array (line 253) | public dynamic Array(params dynamic[] contents)
method ObjectSetup (line 269) | public dynamic ObjectSetup(params dynamic[] constructorArgs)
method ObjectSetup (line 280) | public dynamic ObjectSetup(Func<object[]> constructorArgsFactory)
class BuilderTrampoline (line 294) | public class BuilderTrampoline<TInnerObjectProtoType> : DynamicObject
method BuilderTrampoline (line 302) | public BuilderTrampoline(Builder<TInnerObjectProtoType> builder)
method TryInvoke (line 314) | public override bool TryInvoke(InvokeBinder binder, object[] args, o...
class SetupTrampoline (line 327) | public class SetupTrampoline<TInnerObjectProtoType> : DynamicObject
method SetupTrampoline (line 335) | public SetupTrampoline(Builder<TInnerObjectProtoType> builder){
method TryInvoke (line 347) | public override bool TryInvoke(InvokeBinder binder, dynamic[] args, ...
method TrySetMember (line 368) | public override bool TrySetMember(SetMemberBinder binder, dynamic value){
method TryInvokeMember (line 398) | public override bool TryInvokeMember(InvokeMemberBinder binder, object...
method InvokeHelper (line 419) | private static object InvokeHelper(CallInfo callinfo, IList<object> ar...
FILE: Dynamitey/DynamicObjects/Dictionary.cs
class Dictionary (line 30) | public class Dictionary:BaseDictionary,IDictionary<string,object>
method Dictionary (line 36) | public Dictionary()
method Dictionary (line 44) | public Dictionary(IEnumerable<KeyValuePair<string, object>> dict) : ba...
method GetEnumerator (line 60) | public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
method GetEnumerator (line 65) | IEnumerator IEnumerable.GetEnumerator()
method Clear (line 73) | public void Clear()
class ChainableDictionary (line 101) | public class ChainableDictionary:Dictionary{
method ChainableDictionary (line 107) | public ChainableDictionary()
method ChainableDictionary (line 115) | public ChainableDictionary(IEnumerable<KeyValuePair<string, object>> d...
method TryInvokeMember (line 129) | public override bool TryInvokeMember (InvokeMemberBinder binder, objec...
FILE: Dynamitey/DynamicObjects/Dummy.cs
class Dummy (line 14) | public class Dummy:BaseObject
method Dummy (line 20) | public Dummy()
method TryGetMember (line 36) | public override bool TryGetMember(System.Dynamic.GetMemberBinder binde...
method TrySetMember (line 51) | public override bool TrySetMember(System.Dynamic.SetMemberBinder binde...
method TryInvokeMember (line 66) | public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder...
method TryGetIndex (line 82) | public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder,...
method TrySetIndex (line 96) | public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder,...
FILE: Dynamitey/DynamicObjects/ExtensionToInstanceProxy.cs
class ExtensionToInstanceProxy (line 20) | public class ExtensionToInstanceProxy: BaseForwarder
method ExtensionToInstanceProxy (line 46) | public ExtensionToInstanceProxy(dynamic target, Type extendedType, Ty...
method UnwrappedTarget (line 64) | private object UnwrappedTarget(){
method TryGetMember (line 76) | public override bool TryGetMember(GetMemberBinder binder, out object r...
class Invoker (line 93) | public class Invoker:BaseObject
method Invoker (line 116) | internal Invoker(string name, Type[] genericParameters, Type[] gener...
method ReplaceGenericTypes (line 169) | private Type ReplaceGenericTypes(Type type)
method TryGetMember (line 195) | public override bool TryGetMember(GetMemberBinder binder, out object...
method TryInvoke (line 214) | public override bool TryInvoke(InvokeBinder binder, object[] args, o...
method TryGetIndex (line 237) | public override bool TryGetIndex(GetIndexBinder binder, object[] ind...
class OverloadInvoker (line 247) | public class OverloadInvoker:Invoker
method OverloadInvoker (line 249) | internal OverloadInvoker(string name, Type[] genericParameters, Type...
method TryGetIndex (line 262) | public override bool TryGetIndex(GetIndexBinder binder, object[] ind...
method TryInvokeMember (line 277) | public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder...
method InvokeStaticMethod (line 326) | protected object InvokeStaticMethod(String_OR_InvokeMemberName name, o...
method CreateSelf (line 418) | protected virtual ExtensionToInstanceProxy CreateSelf(object target, T...
method IsExtendedType (line 423) | private bool IsExtendedType(object target)
FILE: Dynamitey/DynamicObjects/Factory.cs
class BaseFactory (line 27) | public class BaseFactory:BaseObject
method TryGetMember (line 39) | public override bool TryGetMember(System.Dynamic.GetMemberBinder binde...
method TryInvokeMember (line 54) | public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder...
method CreateType (line 67) | protected virtual object CreateType(Type type, params object[] args)
method GetInstanceForDynamicMember (line 78) | protected virtual object GetInstanceForDynamicMember(string memberName...
class BaseSingleInstancesFactory (line 90) | public class BaseSingleInstancesFactory : BaseFactory
method GetInstanceForDynamicMember (line 112) | protected override object GetInstanceForDynamicMember(string memberNam...
FILE: Dynamitey/DynamicObjects/FauxType.cs
class FauxType (line 14) | public abstract class FauxType
method GetMember (line 32) | public abstract IEnumerable<MemberInfo> GetMember(string binderName);
method GetContainedTypes (line 38) | public abstract Type[] GetContainedTypes();
method GetMemberNames (line 40) | public abstract IEnumerable<string> GetMemberNames();
method ContainsType (line 49) | public virtual bool ContainsType(Type type)
class PropretySpecType (line 58) | public class PropretySpecType : FauxType
method PropretySpecType (line 62) | public PropretySpecType(IDictionary<string, Type> propertySpec)
method GetMember (line 67) | public override IEnumerable<MemberInfo> GetMember(string binderName)
method GetMemberNames (line 77) | public override IEnumerable<string> GetMemberNames()
method GetContainedTypes (line 82) | public override Type[] GetContainedTypes()
class RealType (line 92) | public class RealType : FauxType
method RealType (line 124) | public RealType(Type type)
method GetMember (line 134) | public override IEnumerable<MemberInfo> GetMember(string binderName)
method GetMemberNames (line 139) | public override IEnumerable<string> GetMemberNames()
method GetContainedTypes (line 154) | public override Type[] GetContainedTypes()
class AggreType (line 166) | public class AggreType : FauxType
method MakeTypeAppendable (line 174) | public static AggreType MakeTypeAppendable(IEquivalentType type)
method AggreType (line 195) | public AggreType(params FauxType[] types)
method GetInterfaceTypes (line 204) | public Type[] GetInterfaceTypes()
method GetMemberNames (line 209) | public override IEnumerable<string> GetMemberNames()
method AddType (line 218) | public void AddType(Type type)
method AddType (line 230) | public void AddType(FauxType type)
method GetMember (line 257) | public override IEnumerable<MemberInfo> GetMember(string binderName)
method GetContainedTypes (line 271) | public override Type[] GetContainedTypes()
FILE: Dynamitey/DynamicObjects/FluentStringLookup.cs
class FluentStringLookup (line 16) | public class FluentStringLookup:DynamicObject
method FluentStringLookup (line 25) | public FluentStringLookup(Func<string,dynamic> lookup)
method TryInvokeMember (line 37) | public override bool TryInvokeMember(InvokeMemberBinder binder, object...
method TryInvoke (line 50) | public override bool TryInvoke(InvokeBinder binder, object[] args, out...
FILE: Dynamitey/DynamicObjects/Get.cs
class Get (line 31) | public class Get:BaseForwarder
method Get (line 39) | public Get(object target):base(target)
method Create (line 51) | public static dynamic Create(object target)
method TryGetMember (line 63) | public override bool TryGetMember(System.Dynamic.GetMemberBinder binde...
method TryInvokeMember (line 82) | public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder...
method TryGetIndex (line 134) | public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder,...
FILE: Dynamitey/DynamicObjects/LateType.cs
class LateType (line 16) | public class LateType:BaseForwarder
class MissingTypeException (line 23) | public class MissingTypeException:Exception
method MissingTypeException (line 29) | public MissingTypeException(string typename)
method MissingTypeException (line 40) | public MissingTypeException(string message, Exception innerException...
method LateType (line 50) | public LateType(Type type)
method FindType (line 59) | public static Type FindType(string typeName, Assembly assembly = null)
method LateType (line 80) | public LateType(string typeName)
method LateType (line 92) | public LateType(Assembly assembly, string typeName)
class ConstructorForward (line 108) | public class ConstructorForward:DynamicObject
method ConstructorForward (line 111) | internal ConstructorForward(Type type)
method TryInvoke (line 122) | public override bool TryInvoke(InvokeBinder binder, object[] args, o...
FILE: Dynamitey/DynamicObjects/Lazy.cs
class Lazy (line 14) | public abstract class Lazy:BaseForwarder
method Create (line 22) | public static dynamic Create<T>(Func<T> valueFactory)
method Create (line 32) | public static dynamic Create<T>(System.Lazy<T> target)
method Lazy (line 41) | protected Lazy(object target) : base(target)
method Lazy (line 58) | public Lazy(System.Lazy<T> target) : base(target)
method Lazy (line 66) | public Lazy(Func<T> valueFactory ):base(new System.Lazy<T>(valueFactory))
method GetDynamicMemberNames (line 78) | public override IEnumerable<string> GetDynamicMemberNames()
class Lazy (line 52) | public class Lazy<T> : Lazy
method Create (line 22) | public static dynamic Create<T>(Func<T> valueFactory)
method Create (line 32) | public static dynamic Create<T>(System.Lazy<T> target)
method Lazy (line 41) | protected Lazy(object target) : base(target)
method Lazy (line 58) | public Lazy(System.Lazy<T> target) : base(target)
method Lazy (line 66) | public Lazy(Func<T> valueFactory ):base(new System.Lazy<T>(valueFactory))
method GetDynamicMemberNames (line 78) | public override IEnumerable<string> GetDynamicMemberNames()
FILE: Dynamitey/DynamicObjects/LinqInstanceProxy.cs
class LinqInstanceProxy (line 16) | public class LinqInstanceProxy : ExtensionToInstanceProxy, IEnumerable<o...
method LinqInstanceProxy (line 23) | public LinqInstanceProxy(dynamic target)
method CreateSelf (line 37) | protected override ExtensionToInstanceProxy CreateSelf(object target, ...
method GetEnumerator (line 47) | public IEnumerator<object> GetEnumerator()
method GetEnumerator (line 52) | IEnumerator IEnumerable.GetEnumerator()
type ILinq (line 60) | public interface ILinq<TSource> : IEnumerable<TSource>
method Aggregate (line 62) | TSource Aggregate(Func<TSource, TSource, TSource> func);
method Aggregate (line 63) | TAccumulate Aggregate<TAccumulate>(TAccumulate seed, Func<TAccumulate,...
method Aggregate (line 64) | TResult Aggregate<TAccumulate, TResult>(TAccumulate seed, Func<TAccumu...
method All (line 65) | Boolean All(Func<TSource, Boolean> predicate);
method Any (line 66) | Boolean Any();
method Any (line 67) | Boolean Any(Func<TSource, Boolean> predicate);
method AsEnumerable (line 68) | ILinq<TSource> AsEnumerable();
method Average (line 69) | Double Average(Func<TSource, Int32> selector);
method Average (line 70) | Nullable<Double> Average(Func<TSource, Nullable<Int32>> selector);
method Average (line 71) | Double Average(Func<TSource, Int64> selector);
method Average (line 72) | Nullable<Double> Average(Func<TSource, Nullable<Int64>> selector);
method Average (line 73) | Single Average(Func<TSource, Single> selector);
method Average (line 74) | Nullable<Single> Average(Func<TSource, Nullable<Single>> selector);
method Average (line 75) | Double Average(Func<TSource, Double> selector);
method Average (line 76) | Nullable<Double> Average(Func<TSource, Nullable<Double>> selector);
method Average (line 77) | Decimal Average(Func<TSource, Decimal> selector);
method Average (line 78) | Nullable<Decimal> Average(Func<TSource, Nullable<Decimal>> selector);
method Cast (line 79) | ILinq<TResult> Cast<TResult>();
method Concat (line 80) | ILinq<TSource> Concat(IEnumerable<TSource> second);
method Contains (line 81) | Boolean Contains(TSource value);
method Contains (line 82) | Boolean Contains(TSource value, IEqualityComparer<TSource> comparer);
method Count (line 83) | Int32 Count();
method Count (line 84) | Int32 Count(Func<TSource, Boolean> predicate);
method DefaultIfEmpty (line 85) | ILinq<TSource> DefaultIfEmpty();
method DefaultIfEmpty (line 86) | ILinq<TSource> DefaultIfEmpty(TSource defaultValue);
method Distinct (line 87) | ILinq<TSource> Distinct();
method Distinct (line 88) | ILinq<TSource> Distinct(IEqualityComparer<TSource> comparer);
method ElementAt (line 89) | TSource ElementAt(Int32 index);
method ElementAtOrDefault (line 90) | TSource ElementAtOrDefault(Int32 index);
method Except (line 91) | ILinq<TSource> Except(IEnumerable<TSource> second);
method Except (line 92) | ILinq<TSource> Except(IEnumerable<TSource> second, IEqualityComparer<T...
method First (line 93) | TSource First();
method First (line 94) | TSource First(Func<TSource, Boolean> predicate);
method FirstOrDefault (line 95) | TSource FirstOrDefault();
method FirstOrDefault (line 96) | TSource FirstOrDefault(Func<TSource, Boolean> predicate);
method GroupBy (line 97) | ILinq<IGrouping<TKey, TSource>> GroupBy<TKey>(Func<TSource, TKey> keyS...
method GroupBy (line 98) | ILinq<IGrouping<TKey, TSource>> GroupBy<TKey>(Func<TSource, TKey> keyS...
method GroupBy (line 99) | ILinq<IGrouping<TKey, TElement>> GroupBy<TKey, TElement>(Func<TSource,...
method GroupBy (line 100) | ILinq<IGrouping<TKey, TElement>> GroupBy<TKey, TElement>(Func<TSource,...
method GroupBy (line 101) | ILinq<TResult> GroupBy<TKey, TResult>(Func<TSource, TKey> keySelector,...
method GroupBy (line 102) | ILinq<TResult> GroupBy<TKey, TElement, TResult>(Func<TSource, TKey> ke...
method GroupBy (line 103) | ILinq<TResult> GroupBy<TKey, TResult>(Func<TSource, TKey> keySelector,...
method GroupBy (line 104) | ILinq<TResult> GroupBy<TKey, TElement, TResult>(Func<TSource, TKey> ke...
method GroupJoin (line 105) | ILinq<TResult> GroupJoin<TInner, TKey, TResult>(IEnumerable<TInner> in...
method GroupJoin (line 106) | ILinq<TResult> GroupJoin<TInner, TKey, TResult>(IEnumerable<TInner> in...
method Intersect (line 107) | ILinq<TSource> Intersect(IEnumerable<TSource> second);
method Intersect (line 108) | ILinq<TSource> Intersect(IEnumerable<TSource> second, IEqualityCompare...
method Join (line 109) | ILinq<TResult> Join<TInner, TKey, TResult>(IEnumerable<TInner> inner, ...
method Join (line 110) | ILinq<TResult> Join<TInner, TKey, TResult>(IEnumerable<TInner> inner, ...
method Last (line 111) | TSource Last();
method Last (line 112) | TSource Last(Func<TSource, Boolean> predicate);
method LastOrDefault (line 113) | TSource LastOrDefault();
method LastOrDefault (line 114) | TSource LastOrDefault(Func<TSource, Boolean> predicate);
method LongCount (line 115) | Int64 LongCount();
method LongCount (line 116) | Int64 LongCount(Func<TSource, Boolean> predicate);
method Max (line 117) | TSource Max();
method Max (line 118) | Int32 Max(Func<TSource, Int32> selector);
method Max (line 119) | Nullable<Int32> Max(Func<TSource, Nullable<Int32>> selector);
method Max (line 120) | Int64 Max(Func<TSource, Int64> selector);
method Max (line 121) | Nullable<Int64> Max(Func<TSource, Nullable<Int64>> selector);
method Max (line 122) | Single Max(Func<TSource, Single> selector);
method Max (line 123) | Nullable<Single> Max(Func<TSource, Nullable<Single>> selector);
method Max (line 124) | Double Max(Func<TSource, Double> selector);
method Max (line 125) | Nullable<Double> Max(Func<TSource, Nullable<Double>> selector);
method Max (line 126) | Decimal Max(Func<TSource, Decimal> selector);
method Max (line 127) | Nullable<Decimal> Max(Func<TSource, Nullable<Decimal>> selector);
method Max (line 128) | TResult Max<TResult>(Func<TSource, TResult> selector);
method Min (line 129) | TSource Min();
method Min (line 130) | Int32 Min(Func<TSource, Int32> selector);
method Min (line 131) | Nullable<Int32> Min(Func<TSource, Nullable<Int32>> selector);
method Min (line 132) | Int64 Min(Func<TSource, Int64> selector);
method Min (line 133) | Nullable<Int64> Min(Func<TSource, Nullable<Int64>> selector);
method Min (line 134) | Single Min(Func<TSource, Single> selector);
method Min (line 135) | Nullable<Single> Min(Func<TSource, Nullable<Single>> selector);
method Min (line 136) | Double Min(Func<TSource, Double> selector);
method Min (line 137) | Nullable<Double> Min(Func<TSource, Nullable<Double>> selector);
method Min (line 138) | Decimal Min(Func<TSource, Decimal> selector);
method Min (line 139) | Nullable<Decimal> Min(Func<TSource, Nullable<Decimal>> selector);
method Min (line 140) | TResult Min<TResult>(Func<TSource, TResult> selector);
method OfType (line 141) | ILinq<TResult> OfType<TResult>();
method OrderBy (line 142) | IOrderedLinq<TSource> OrderBy<TKey>(Func<TSource, TKey> keySelector);
method OrderBy (line 143) | IOrderedLinq<TSource> OrderBy<TKey>(Func<TSource, TKey> keySelector, I...
method OrderByDescending (line 144) | IOrderedLinq<TSource> OrderByDescending<TKey>(Func<TSource, TKey> keyS...
method OrderByDescending (line 145) | IOrderedLinq<TSource> OrderByDescending<TKey>(Func<TSource, TKey> keyS...
method Reverse (line 146) | ILinq<TSource> Reverse();
method Select (line 147) | ILinq<TResult> Select<TResult>(Func<TSource, TResult> selector);
method Select (line 148) | ILinq<TResult> Select<TResult>(Func<TSource, Int32, TResult> selector);
method SelectMany (line 149) | ILinq<TResult> SelectMany<TResult>(Func<TSource, IEnumerable<TResult>>...
method SelectMany (line 150) | ILinq<TResult> SelectMany<TResult>(Func<TSource, Int32, IEnumerable<TR...
method SelectMany (line 151) | ILinq<TResult> SelectMany<TCollection, TResult>(Func<TSource, Int32, I...
method SelectMany (line 152) | ILinq<TResult> SelectMany<TCollection, TResult>(Func<TSource, IEnumera...
method SequenceEqual (line 153) | Boolean SequenceEqual(IEnumerable<TSource> second);
method SequenceEqual (line 154) | Boolean SequenceEqual(IEnumerable<TSource> second, IEqualityComparer<T...
method Single (line 155) | TSource Single();
method Single (line 156) | TSource Single(Func<TSource, Boolean> predicate);
method SingleOrDefault (line 157) | TSource SingleOrDefault();
method SingleOrDefault (line 158) | TSource SingleOrDefault(Func<TSource, Boolean> predicate);
method Skip (line 159) | ILinq<TSource> Skip(Int32 count);
method SkipWhile (line 160) | ILinq<TSource> SkipWhile(Func<TSource, Boolean> predicate);
method SkipWhile (line 161) | ILinq<TSource> SkipWhile(Func<TSource, Int32, Boolean> predicate);
method Sum (line 162) | Int32 Sum(Func<TSource, Int32> selector);
method Sum (line 163) | Nullable<Int32> Sum(Func<TSource, Nullable<Int32>> selector);
method Sum (line 164) | Int64 Sum(Func<TSource, Int64> selector);
method Sum (line 165) | Nullable<Int64> Sum(Func<TSource, Nullable<Int64>> selector);
method Sum (line 166) | Single Sum(Func<TSource, Single> selector);
method Sum (line 167) | Nullable<Single> Sum(Func<TSource, Nullable<Single>> selector);
method Sum (line 168) | Double Sum(Func<TSource, Double> selector);
method Sum (line 169) | Nullable<Double> Sum(Func<TSource, Nullable<Double>> selector);
method Sum (line 170) | Decimal Sum(Func<TSource, Decimal> selector);
method Sum (line 171) | Nullable<Decimal> Sum(Func<TSource, Nullable<Decimal>> selector);
method Take (line 172) | ILinq<TSource> Take(Int32 count);
method TakeWhile (line 173) | ILinq<TSource> TakeWhile(Func<TSource, Boolean> predicate);
method TakeWhile (line 174) | ILinq<TSource> TakeWhile(Func<TSource, Int32, Boolean> predicate);
method ToArray (line 175) | TSource[] ToArray();
method ToDictionary (line 176) | Dictionary<TKey, TSource> ToDictionary<TKey>(Func<TSource, TKey> keySe...
method ToDictionary (line 177) | Dictionary<TKey, TSource> ToDictionary<TKey>(Func<TSource, TKey> keySe...
method ToDictionary (line 178) | Dictionary<TKey, TElement> ToDictionary<TKey, TElement>(Func<TSource, ...
method ToDictionary (line 179) | Dictionary<TKey, TElement> ToDictionary<TKey, TElement>(Func<TSource, ...
method ToList (line 180) | List<TSource> ToList();
method ToLookup (line 181) | ILookup<TKey, TSource> ToLookup<TKey>(Func<TSource, TKey> keySelector);
method ToLookup (line 182) | ILookup<TKey, TSource> ToLookup<TKey>(Func<TSource, TKey> keySelector,...
method ToLookup (line 183) | ILookup<TKey, TElement> ToLookup<TKey, TElement>(Func<TSource, TKey> k...
method ToLookup (line 184) | ILookup<TKey, TElement> ToLookup<TKey, TElement>(Func<TSource, TKey> k...
method Union (line 185) | ILinq<TSource> Union(IEnumerable<TSource> second);
method Union (line 186) | ILinq<TSource> Union(IEnumerable<TSource> second, IEqualityComparer<TS...
method Where (line 187) | ILinq<TSource> Where(Func<TSource, Boolean> predicate);
method Where (line 188) | ILinq<TSource> Where(Func<TSource, Int32, Boolean> predicate);
method Zip (line 189) | ILinq<TResult> Zip<TSecond, TResult>(IEnumerable<TSecond> second, Func...
type IOrderedLinq (line 192) | public interface IOrderedLinq<TSource> : ILinq<TSource>, IOrderedEnumera...
method ThenBy (line 194) | IOrderedLinq<TSource> ThenBy<TKey>(Func<TSource, TKey> keySelector);
method ThenBy (line 195) | IOrderedLinq<TSource> ThenBy<TKey>(Func<TSource, TKey> keySelector, IC...
method ThenByDescending (line 196) | IOrderedLinq<TSource> ThenByDescending<TKey>(Func<TSource, TKey> keySe...
method ThenByDescending (line 197) | IOrderedLinq<TSource> ThenByDescending<TKey>(Func<TSource, TKey> keySe...
FILE: Dynamitey/DynamicObjects/List.cs
class List (line 32) | public class List : BaseDictionary, IList<object>, IDictionary<string, o...
method List (line 50) | public List(
method GetEnumerator (line 69) | IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<str...
method GetEnumerator (line 78) | public IEnumerator<dynamic> GetEnumerator()
method Add (line 89) | public void Add(dynamic item)
method Clear (line 97) | public void Clear()
method Contains (line 114) | public bool Contains(dynamic item)
method CopyTo (line 124) | public void CopyTo(object[] array, int arrayIndex)
method IndexOf (line 143) | public int IndexOf(dynamic item)
method Insert (line 156) | public void Insert(int index, dynamic item)
method InsertHelper (line 161) | private void InsertHelper(object item, int? index = null)
method RemoveAt (line 183) | public void RemoveAt(int index)
method Remove (line 193) | public bool Remove(dynamic item)
method RemoveHelper (line 198) | private bool RemoveHelper(object item = null, int? index = null)
method GetEnumerator (line 242) | IEnumerator IEnumerable.GetEnumerator()
method OnCollectionChanged (line 256) | protected virtual void OnCollectionChanged(NotifyCollectionChangedActi...
method Equals (line 311) | public bool Equals(List other)
method Equals (line 325) | public override bool Equals(object obj)
method GetHashCode (line 338) | public override int GetHashCode()
method GetRepresentedItem (line 359) | protected virtual dynamic GetRepresentedItem()
method CopyTo (line 373) | public void CopyTo(Array array, int index)
method Add (line 402) | int IList.Add(object value)
method Remove (line 408) | void IList.Remove(object value)
FILE: Dynamitey/DynamicObjects/Mimic.cs
class Mimic (line 13) | public class Mimic : DynamicObject
method TryBinaryOperation (line 22) | public override bool TryBinaryOperation(BinaryOperationBinder binder, ...
method TryConvert (line 34) | public override bool TryConvert(ConvertBinder binder, out object result)
method TryCreateInstance (line 48) | public override bool TryCreateInstance(CreateInstanceBinder binder, ob...
method TryDeleteIndex (line 60) | public override bool TryDeleteIndex(DeleteIndexBinder binder, object[]...
method TryDeleteMember (line 70) | public override bool TryDeleteMember(DeleteMemberBinder binder)
method TryGetIndex (line 82) | public override bool TryGetIndex(GetIndexBinder binder, object[] index...
method TryGetMember (line 94) | public override bool TryGetMember(GetMemberBinder binder, out object r...
method TryInvoke (line 107) | public override bool TryInvoke(InvokeBinder binder, object[] args, out...
method TryInvokeMember (line 120) | public override bool TryInvokeMember(InvokeMemberBinder binder, object...
method TrySetIndex (line 133) | public override bool TrySetIndex(SetIndexBinder binder, object[] index...
method TrySetMember (line 144) | public override bool TrySetMember(SetMemberBinder binder, object value)
method TryUnaryOperation (line 155) | public override bool TryUnaryOperation(UnaryOperationBinder binder, ou...
FILE: Dynamitey/DynamicObjects/Recorder.cs
class Recorder (line 31) | public class Recorder:BaseForwarder
method Recorder (line 37) | public Recorder():base(new Dummy())
method Recorder (line 53) | public Recorder(object target) : base(target)
method ReplayOn (line 62) | public T ReplayOn<T>(T target)
method TryGetMember (line 80) | public override bool TryGetMember(System.Dynamic.GetMemberBinder binde...
method TrySetMember (line 96) | public override bool TrySetMember(System.Dynamic.SetMemberBinder binde...
method TryInvokeMember (line 113) | public override bool TryInvokeMember(System.Dynamic.InvokeMemberBinder...
method TryGetIndex (line 130) | public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder,...
method TrySetIndex (line 147) | public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder,...
FILE: Dynamitey/DynamicObjects/RegexMatch.cs
type IRegexMatch (line 16) | public interface IRegexMatch
class RegexMatch (line 32) | public class RegexMatch : BaseObject, IRegexMatch
method RegexMatch (line 44) | public RegexMatch(Match match, Regex regex = null)
method GetDynamicMemberNames (line 55) | public override IEnumerable<string> GetDynamicMemberNames()
method TryGetMember (line 68) | public override bool TryGetMember(GetMemberBinder binder, out object r...
method ToString (line 138) | public override string ToString()
FILE: Dynamitey/Expando.cs
class Expando (line 21) | public class Expando : Builder<ExpandoObject>
method Expando (line 31) | public Expando()
FILE: Dynamitey/FluentRegex.cs
class FluentRegex (line 10) | public static class FluentRegex
method FluentFilter (line 19) | public static IEnumerable<dynamic> FluentFilter(this IEnumerable<strin...
method Matches (line 30) | public static IEnumerable<dynamic> Matches(string inputString, Regex r...
method Match (line 43) | public static dynamic Match(string inputString, Regex regex)
method FluentMatch (line 55) | public static dynamic FluentMatch(this Regex regex, string inputString)
method FluentMatches (line 67) | public static IEnumerable<dynamic> FluentMatches(this Regex regex, str...
FILE: Dynamitey/InlineLambdas.cs
class Return (line 25) | public static class Return<TR>
method Arguments (line 33) | public static Func<TR> Arguments(Func<TR> del)
method ThisAndArguments (line 44) | public static ThisFunc<TR> ThisAndArguments(ThisFunc<TR> del)
method Arguments (line 58) | public static Func<T1,TR> Arguments<T1>(Func<T1,TR> del)
method ThisAndArguments (line 69) | public static ThisFunc<TR,T1> ThisAndArguments<T1>(ThisFunc<TR,T1> del)
method Arguments (line 84) | public static Func<T1,T2,TR> Arguments<T1,T2>(Func<T1,T2,TR> del)
method ThisAndArguments (line 96) | public static ThisFunc<TR,T1,T2> ThisAndArguments<T1,T2>(ThisFunc<TR,T...
method Arguments (line 112) | public static Func<T1,T2,T3,TR> Arguments<T1,T2,T3>(Func<T1,T2,T3,TR> ...
method ThisAndArguments (line 125) | public static ThisFunc<TR,T1,T2,T3> ThisAndArguments<T1,T2,T3>(ThisFun...
method Arguments (line 142) | public static Func<T1,T2,T3,T4,TR> Arguments<T1,T2,T3,T4>(Func<T1,T2,T...
method ThisAndArguments (line 156) | public static ThisFunc<TR,T1,T2,T3,T4> ThisAndArguments<T1,T2,T3,T4>(T...
method Arguments (line 174) | public static Func<T1,T2,T3,T4,T5,TR> Arguments<T1,T2,T3,T4,T5>(Func<T...
method ThisAndArguments (line 189) | public static ThisFunc<TR,T1,T2,T3,T4,T5> ThisAndArguments<T1,T2,T3,T4...
method Arguments (line 208) | public static Func<T1,T2,T3,T4,T5,T6,TR> Arguments<T1,T2,T3,T4,T5,T6>(...
method ThisAndArguments (line 224) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6> ThisAndArguments<T1,T2,T3...
method Arguments (line 244) | public static Func<T1,T2,T3,T4,T5,T6,T7,TR> Arguments<T1,T2,T3,T4,T5,T...
method ThisAndArguments (line 261) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7> ThisAndArguments<T1,T2...
method Arguments (line 282) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,TR> Arguments<T1,T2,T3,T4,T...
method ThisAndArguments (line 300) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8> ThisAndArguments<T1...
method Arguments (line 322) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,TR> Arguments<T1,T2,T3,T...
method ThisAndArguments (line 341) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9> ThisAndArguments...
method Arguments (line 364) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TR> Arguments<T1,T2,...
method ThisAndArguments (line 384) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> ThisAndArgum...
method Arguments (line 408) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TR> Arguments<T1...
method ThisAndArguments (line 429) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> ThisAndA...
method Arguments (line 454) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TR> Argument...
method ThisAndArguments (line 476) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> This...
method Arguments (line 502) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TR> Argu...
method ThisAndArguments (line 525) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> ...
method Arguments (line 552) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TR> ...
method ThisAndArguments (line 576) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T...
method Arguments (line 604) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,...
method ThisAndArguments (line 629) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T...
method Arguments (line 658) | public static Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,...
method ThisAndArguments (line 684) | public static ThisFunc<TR,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T...
class ReturnVoid (line 695) | public static class ReturnVoid
method Arguments (line 702) | public static Action Arguments(Action del)
method ThisAndArguments (line 713) | public static ThisAction ThisAndArguments(ThisAction del)
method Arguments (line 727) | public static Action<T1> Arguments<T1>(Action<T1> del)
method ThisAndArguments (line 739) | public static ThisAction<T1> ThisAndArguments<T1>(ThisAction<T1> del)
method Arguments (line 753) | public static Action<T1,T2> Arguments<T1,T2>(Action<T1,T2> del)
method ThisAndArguments (line 766) | public static ThisAction<T1,T2> ThisAndArguments<T1,T2>(ThisAction<T1,...
method Arguments (line 781) | public static Action<T1,T2,T3> Arguments<T1,T2,T3>(Action<T1,T2,T3> del)
method ThisAndArguments (line 795) | public static ThisAction<T1,T2,T3> ThisAndArguments<T1,T2,T3>(ThisActi...
method Arguments (line 811) | public static Action<T1,T2,T3,T4> Arguments<T1,T2,T3,T4>(Action<T1,T2,...
method ThisAndArguments (line 826) | public static ThisAction<T1,T2,T3,T4> ThisAndArguments<T1,T2,T3,T4>(Th...
method Arguments (line 843) | public static Action<T1,T2,T3,T4,T5> Arguments<T1,T2,T3,T4,T5>(Action<...
method ThisAndArguments (line 859) | public static ThisAction<T1,T2,T3,T4,T5> ThisAndArguments<T1,T2,T3,T4,...
method Arguments (line 877) | public static Action<T1,T2,T3,T4,T5,T6> Arguments<T1,T2,T3,T4,T5,T6>(A...
method ThisAndArguments (line 894) | public static ThisAction<T1,T2,T3,T4,T5,T6> ThisAndArguments<T1,T2,T3,...
method Arguments (line 913) | public static Action<T1,T2,T3,T4,T5,T6,T7> Arguments<T1,T2,T3,T4,T5,T6...
method ThisAndArguments (line 931) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7> ThisAndArguments<T1,T2,...
method Arguments (line 951) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8> Arguments<T1,T2,T3,T4,T5...
method ThisAndArguments (line 970) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8> ThisAndArguments<T1,...
method Arguments (line 991) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9> Arguments<T1,T2,T3,T4...
method ThisAndArguments (line 1011) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9> ThisAndArguments<...
method Arguments (line 1033) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> Arguments<T1,T2,T...
method ThisAndArguments (line 1054) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> ThisAndArgume...
method Arguments (line 1077) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> Arguments<T1,...
method ThisAndArguments (line 1099) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> ThisAndAr...
method Arguments (line 1123) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> Arguments...
method ThisAndArguments (line 1146) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> ThisA...
method Arguments (line 1171) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> Argum...
method ThisAndArguments (line 1195) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> T...
method Arguments (line 1221) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> A...
method ThisAndArguments (line 1246) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T1...
method Arguments (line 1273) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T1...
method ThisAndArguments (line 1299) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T1...
method Arguments (line 1327) | public static Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T1...
method ThisAndArguments (line 1354) | public static ThisAction<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T1...
FILE: Dynamitey/Internal/Compat/Net40.cs
class Net40 (line 15) | public static class Net40
method GetTypeInfo (line 19) | public static Type GetTypeInfo(this Type type)
method GetMethodInfo (line 24) | public static MethodInfo GetMethodInfo(this Delegate del)
method GetDefaultThreadCurrentCulture (line 29) | public static CultureInfo GetDefaultThreadCurrentCulture() {
method GetDefaultThreadCurrentCulture (line 34) | public static CultureInfo GetDefaultThreadCurrentCulture() {
FILE: Dynamitey/Internal/Curry.cs
class Curry (line 30) | public class Curry : DynamicObject, IPartialApply
method Curry (line 48) | internal Curry(object target, int? totalArgCount=null)
method TryBinaryOperation (line 65) | public override bool TryBinaryOperation(BinaryOperationBinder binder, ...
method TryConvert (line 84) | public override bool TryConvert(ConvertBinder binder, out object result)
method GetCustomType (line 98) | public Type GetCustomType()
method TryInvokeMember (line 113) | public override bool TryInvokeMember(InvokeMemberBinder binder, objec...
method TryInvoke (line 127) | public override bool TryInvoke(InvokeBinder binder, object[] args, ou...
FILE: Dynamitey/Internal/InvokeSetters.cs
class InvokeSetters (line 16) | public class InvokeSetters : DynamicObject
method InvokeSetters (line 18) | internal InvokeSetters()
method TryInvoke (line 32) | public override bool TryInvoke(InvokeBinder binder, object[] args, out...
FILE: Dynamitey/Internal/Optimization/BareBonesList.cs
class BareBonesList (line 22) | internal class BareBonesList<T>: ICollection<T>
method BareBonesList (line 34) | public BareBonesList(int length)
method Add (line 40) | public void Add(T item)
method Clear (line 45) | public void Clear()
method Contains (line 50) | public bool Contains(T item)
method CopyTo (line 55) | public void CopyTo(T[] array, int arrayIndex)
method Remove (line 60) | public bool Remove(T item)
method GetEnumerator (line 73) | public IEnumerator<T> GetEnumerator()
method GetEnumerator (line 78) | IEnumerator IEnumerable.GetEnumerator()
class BareBonesEnumerator (line 84) | internal class BareBonesEnumerator : IEnumerator<T>
method BareBonesEnumerator (line 91) | public BareBonesEnumerator(T[] list, int length)
method Dispose (line 97) | public void Dispose()
method MoveNext (line 102) | public bool MoveNext()
method Reset (line 108) | public void Reset()
FILE: Dynamitey/Internal/Optimization/BinderHash.cs
class BinderHash (line 23) | internal class BinderHash
method BinderHash (line 27) | protected BinderHash(Type delegateType, String name, Type context, str...
method BinderHash (line 43) | protected BinderHash(Type delegateType, InvokeMemberName name, Type co...
method Equals (line 73) | public virtual bool Equals(BinderHash other)
method Equals (line 100) | public override bool Equals(object obj)
method GetHashCode (line 108) | public override int GetHashCode()
method Create (line 128) | public static BinderHash<T> Create(string name, Type context, string[]...
method Create (line 133) | public static BinderHash<T> Create(InvokeMemberName name, Type context...
method BinderHash (line 138) | protected BinderHash(InvokeMemberName name, Type context, string[] arg...
method BinderHash (line 143) | protected BinderHash(string name, Type context, string[] argNames, Typ...
method Equals (line 148) | public override bool Equals(BinderHash other)
class BinderHash (line 126) | internal class BinderHash<T> : BinderHash where T : class
method BinderHash (line 27) | protected BinderHash(Type delegateType, String name, Type context, str...
method BinderHash (line 43) | protected BinderHash(Type delegateType, InvokeMemberName name, Type co...
method Equals (line 73) | public virtual bool Equals(BinderHash other)
method Equals (line 100) | public override bool Equals(object obj)
method GetHashCode (line 108) | public override int GetHashCode()
method Create (line 128) | public static BinderHash<T> Create(string name, Type context, string[]...
method Create (line 133) | public static BinderHash<T> Create(InvokeMemberName name, Type context...
method BinderHash (line 138) | protected BinderHash(InvokeMemberName name, Type context, string[] arg...
method BinderHash (line 143) | protected BinderHash(string name, Type context, string[] argNames, Typ...
method Equals (line 148) | public override bool Equals(BinderHash other)
FILE: Dynamitey/Internal/Optimization/InvokeHelper-Regular.cs
class DummmyNull (line 15) | internal class DummmyNull
class InvokeHelper (line 21) | internal static partial class InvokeHelper
method ClearFullyDynamicCache (line 47) | internal static void ClearFullyDynamicCache()
method TryDynamicCachedCallSite (line 55) | private static bool TryDynamicCachedCallSite<T>(BinderHash<T> hash, in...
method EmitCallSiteFuncType (line 87) | internal static Type EmitCallSiteFuncType(IEnumerable<Type> argTypes, ...
method ClearAllCaches (line 115) | internal static void ClearAllCaches()
method SetDynamicCachedCallSite (line 132) | private static void SetDynamicCachedCallSite<T>(BinderHash<T> hash, in...
method IsActionOrFunc (line 172) | public static bool IsActionOrFunc(object target)
method InvokeMethodDelegate (line 188) | internal static object InvokeMethodDelegate(this object target, Delega...
method GetBindingArgumentList (line 211) | internal static IEnumerable<CSharpArgumentInfo> GetBindingArgumentList...
method CreateCallSite (line 256) | internal static CallSite CreateCallSite(
method CreateCallSite (line 329) | internal static CallSite<T> CreateCallSite<T>(
method CreateCallSite (line 353) | internal static CallSite<T> CreateCallSite<T>(
method DynamicInvokeStaticMember (line 394) | internal static dynamic DynamicInvokeStaticMember(Type tReturn, ref Ca...
method InvokeMember (line 434) | internal static TReturn InvokeMember<TReturn>(ref CallSite callsite, T...
method InvokeGetCallSite (line 444) | internal static object InvokeGetCallSite(object target, string name, T...
method InvokeSetCallSite (line 509) | internal static object InvokeSetCallSite(object target, string name, o...
method InvokeMemberCallSite (line 577) | internal static object InvokeMemberCallSite(object target, InvokeMemb...
method InvokeDirectCallSite (line 602) | internal static object InvokeDirectCallSite(object target, object[] ar...
method InvokeGetIndexCallSite (line 623) | internal static object InvokeGetIndexCallSite(object target, object[] ...
method InvokeSetIndexCallSite (line 643) | internal static object InvokeSetIndexCallSite(object target, object[] ...
method InvokeMemberActionCallSite (line 663) | internal static void InvokeMemberActionCallSite(object target,InvokeMe...
method InvokeDirectActionCallSite (line 692) | internal static void InvokeDirectActionCallSite(object target, object[...
class IsEventBinderDummy (line 717) | internal class IsEventBinderDummy{
method InvokeIsEventCallSite (line 720) | internal static bool InvokeIsEventCallSite(object target, string name,...
method InvokeAddAssignCallSite (line 733) | internal static void InvokeAddAssignCallSite(object target, string nam...
method InvokeSubtractAssignCallSite (line 749) | internal static void InvokeSubtractAssignCallSite(object target, strin...
method InvokeConvertCallSite (line 767) | internal static object InvokeConvertCallSite(object target, bool expli...
class InvokeConstructorDummy (line 792) | internal class InvokeConstructorDummy{};
method InvokeConstructorCallSite (line 796) | internal static object InvokeConstructorCallSite(Type type, bool isVal...
method WrapFunc (line 836) | internal static Delegate WrapFunc(Type returnType, object invokable, i...
FILE: Dynamitey/Internal/Optimization/InvokeHelper.cs
class BinderCache (line 26) | internal static class BinderCache<T> where T : class
class BinderGetCache (line 51) | internal static class BinderGetCache<T> where T : class
class BinderSetCache (line 76) | internal static class BinderSetCache<T> where T : class
class BinderConstructorCache (line 101) | internal static class BinderConstructorCache<T> where T : class
class BinderMemberCache (line 126) | internal static class BinderMemberCache<T> where T : class
class BinderDirectCache (line 151) | internal static class BinderDirectCache<T> where T : class
class InvokeHelper (line 177) | internal static partial class InvokeHelper
method InvokeHelper (line 189) | static InvokeHelper()
method TupleItem (line 253) | internal static dynamic TupleItem(dynamic tuple, int index){
method InvokeMemberAction (line 275) | internal static void InvokeMemberAction(ref CallSite callsite,
method InvokeMemberTargetType (line 460) | internal static TReturn InvokeMemberTargetType<TTarget,TReturn>(
method WrapFuncHelper (line 628) | internal static Delegate WrapFuncHelper<TReturn>(dynamic invokable, in...
method WrapAction (line 673) | internal static Delegate WrapAction(dynamic invokable, int length)
method FastDynamicInvokeReturn (line 718) | internal static object FastDynamicInvokeReturn(Delegate del, dynamic [...
method FastDynamicInvokeAction (line 768) | internal static void FastDynamicInvokeAction(Delegate del, params dyna...
FILE: Dynamitey/Internal/Optimization/Util.cs
class Util (line 34) | public static class Util
method Util (line 41) | static Util()
method IsAnonymousType (line 57) | public static bool IsAnonymousType(object target)
method NameArgsIfNecessary (line 77) | public static object[] NameArgsIfNecessary(CallInfo callInfo, object[]...
method GetTargetContext (line 97) | public static object GetTargetContext(this object target, out Type con...
method FixContext (line 120) | public static Type FixContext(this Type context)
method MassageResultBasedOnInterface (line 130) | internal static bool MassageResultBasedOnInterface(this BaseObject tar...
method GetArgsAndNames (line 176) | internal static object[] GetArgsAndNames(object[]args,out string[]argN...
FILE: Dynamitey/Invocation.cs
type InvocationKind (line 27) | public enum InvocationKind
class Invocation (line 100) | public class Invocation
method Create (line 147) | public static Invocation Create(InvocationKind kind, String_OR_InvokeM...
method Invocation (line 158) | public Invocation(InvocationKind kind, String_OR_InvokeMemberName name...
method Equals (line 170) | public bool Equals(Invocation other)
method Equals (line 184) | public override bool Equals(object obj)
method GetHashCode (line 198) | public override int GetHashCode()
method Invoke (line 215) | public virtual object Invoke(object target, params object[] args)
method InvokeWithStoredArgs (line 291) | public virtual object InvokeWithStoredArgs(object target)
FILE: Dynamitey/InvokeArg.cs
class InvokeArg (line 29) | public class InvokeArg
method InvokeArg (line 53) | public InvokeArg(string name, object value)
method InvokeArg (line 83) | public InvokeArg(string name, object value):base(name,value){}
class InvokeArg (line 76) | public class InvokeArg<T> : InvokeArg
method InvokeArg (line 53) | public InvokeArg(string name, object value)
method InvokeArg (line 83) | public InvokeArg(string name, object value):base(name,value){}
FILE: Dynamitey/InvokeContext.cs
class StaticContext (line 30) | public class StaticContext:InvokeContext
method StaticContext (line 46) | public StaticContext(Type target) : base(target, true, null)
class InvokeContext (line 54) | public class InvokeContext
method InvokeContext (line 100) | public InvokeContext(Type target, bool staticContext, object context)
method InvokeContext (line 116) | public InvokeContext(object target, object context)
FILE: Dynamitey/InvokeMemberName.cs
class String_OR_InvokeMemberName (line 13) | public abstract class String_OR_InvokeMemberName
class InvokeMemberName (line 49) | public sealed class InvokeMemberName:String_OR_InvokeMemberName
method InvokeMemberName (line 79) | public InvokeMemberName(string name, params Type[] genericArgs)
method InvokeMemberName (line 90) | public InvokeMemberName(string name, bool isSpecialName)
method Equals (line 102) | public bool Equals(InvokeMemberName other)
method EqualsHelper (line 109) | private bool EqualsHelper(InvokeMemberName other)
method Equals (line 133) | public override bool Equals(object obj)
method GetHashCode (line 147) | public override int GetHashCode()
FILE: Dynamitey/PartialApply.cs
class PartialApply (line 21) | public class PartialApply : DynamicObject, IPartialApply
method TryBinaryOperation (line 44) | public override bool TryBinaryOperation(BinaryOperationBinder binder, ...
method TryConvert (line 63) | public override bool TryConvert(ConvertBinder binder, out object result)
method PartialApply (line 79) | public PartialApply(object target, object[] args, string memberName = ...
method TryInvoke (line 143) | public override bool TryInvoke(InvokeBinder binder, object[] args, out...
type IPartialApply (line 192) | public interface IPartialApply
FILE: Dynamitey/ThisFunctions.cs
class ThisDelegate (line 163) | public static class ThisDelegate{
method IsSpecialThisDelegate (line 222) | public static bool IsSpecialThisDelegate(this Delegate del){
FILE: Dynamitey/Tupler.cs
class Tupler (line 32) | public static class Tupler
class TuplerFix (line 34) | private class TuplerFix
method Create (line 36) | private Tuple<T1, T2, T3, T4, T5, T6, T7, T8> Create<T1, T2, T3, T4,...
method Create (line 50) | public static dynamic Create(params object[] args)
method ToTuple (line 60) | public static dynamic ToTuple(this IEnumerable enumerable)
method First (line 77) | public static dynamic First(object tuple)
method Second (line 87) | public static dynamic Second(object tuple)
method Last (line 97) | public static dynamic Last(object tuple)
method ToList (line 107) | public static IList<dynamic> ToList(object tuple)
method HelperToList (line 117) | private static void HelperToList(List<dynamic> list, object tuple, boo...
method Index (line 140) | public static dynamic Index(object tuple, int index)
method HelperIndex (line 145) | private static dynamic HelperIndex(object tuple, int index, bool safe)
method IsTuple (line 178) | public static bool IsTuple(object target)
method HelperIsTuple (line 183) | private static bool HelperIsTuple(object target, out Type type, out Ty...
method Size (line 207) | public static int Size(object tuple)
method HelperSize (line 212) | private static int HelperSize(object tuple, bool safe)
FILE: SupportLibrary/SupportTypes.cs
class TestEvent (line 11) | public class TestEvent
method OnEvent (line 15) | public void OnEvent(object obj, EventArgs args)
class TestFuncs (line 22) | public static class TestFuncs
class PublicType (line 30) | public class PublicType
method PrivateMethod (line 34) | public bool PrivateMethod(object param)
class InternalType (line 41) | internal class InternalType
method InternalMethod (line 43) | public bool InternalMethod(object param)
type IDynamicArg (line 51) | public interface IDynamicArg
method ReturnIt (line 53) | dynamic ReturnIt(dynamic arg);
method Params (line 55) | bool Params(params dynamic[] args);
class PocoNonDynamicArg (line 58) | public class PocoNonDynamicArg
method ReturnIt (line 60) | public int ReturnIt(int i)
method ReturnIt (line 66) | public List<string> ReturnIt(List<string> i)
method Params (line 71) | public bool Params(object fallback)
method Params (line 76) | public bool Params(params int[] args)
class StaticType (line 82) | public static class StaticType
method Create (line 84) | public static TReturn Create<TReturn>(int type)
type ISimpeleClassProps (line 94) | public interface ISimpeleClassProps
type IInheritProp (line 103) | public interface IInheritProp : ISimpeleClassProps
type IPropPocoProp (line 109) | public interface IPropPocoProp
type IEventCollisions (line 114) | public interface IEventCollisions
type IEvent (line 120) | public interface IEvent
method OnEvent (line 123) | void OnEvent(object obj, EventArgs args);
class PocoEvent (line 126) | public class PocoEvent
method OnEvent (line 130) | public void OnEvent(object obj, EventArgs args)
class PocoOptConstructor (line 138) | public class PocoOptConstructor
method PocoOptConstructor (line 144) | public PocoOptConstructor(string one = "-1", string two = "-2", string...
type TestEnum (line 152) | public enum TestEnum
type IDynamicDict (line 159) | public interface IDynamicDict
type INonDynamicDict (line 172) | public interface INonDynamicDict
type ISimpleStringProperty (line 185) | public interface ISimpleStringProperty
type IRobot (line 191) | public interface IRobot
class Robot (line 195) | public class Robot
type ISimpleStringMethod (line 200) | public interface ISimpleStringMethod
method StartsWith (line 202) | bool StartsWith(string value);
type ISimpleStringMethodCollision (line 206) | public interface ISimpleStringMethodCollision
method StartsWith (line 208) | int StartsWith(string value);
type ISimpeleClassMeth (line 212) | public interface ISimpeleClassMeth
method Action1 (line 214) | void Action1();
method Action2 (line 215) | void Action2(bool value);
method Action3 (line 216) | string Action3();
type ISimpeleClassMeth2 (line 219) | public interface ISimpeleClassMeth2 : ISimpeleClassMeth
method Action4 (line 222) | string Action4(int arg);
type IGenericMeth (line 225) | public interface IGenericMeth
method Action (line 227) | string Action<T>(T arg);
method Action2 (line 229) | T Action2<T>(T arg);
type IStringIntIndexer (line 232) | public interface IStringIntIndexer
type IObjectStringIndexer (line 237) | public interface IObjectStringIndexer
type IGenericMethWithConstraints (line 242) | public interface IGenericMethWithConstraints
method Action (line 244) | string Action<T>(T arg) where T : class;
method Action2 (line 245) | string Action2<T>(T arg) where T : IComparable;
type IGenericType (line 248) | public interface IGenericType<T>
method Funct (line 250) | string Funct(T arg);
type IGenericTypeConstraints (line 255) | public interface IGenericTypeConstraints<T> where T : class
method Funct (line 257) | string Funct(T arg);
type IOverloadingMethod (line 262) | public interface IOverloadingMethod
method Func (line 264) | string Func(int arg);
method Func (line 266) | string Func(object arg);
class PropPoco (line 270) | public class PropPoco
type PropStruct (line 281) | public struct PropStruct
type IVoidMethod (line 293) | public interface IVoidMethod
method Action (line 295) | void Action();
class VoidMethodPoco (line 298) | public class VoidMethodPoco
method Action (line 300) | public void Action()
class OverloadingMethPoco (line 306) | public class OverloadingMethPoco
method Func (line 308) | public string Func(int arg)
method Func (line 313) | public string Func(object arg)
method Func (line 317) | public string Func(object arg, object arg2, object arg3, object arg4, ...
method Func (line 322) | public string Func(object one = null, object two = null, object three ...
class MethOutPoco (line 333) | public class MethOutPoco
method Func (line 335) | public bool Func(out string result)
class Thing (line 343) | public class Thing { }
type IGenericTest (line 345) | public interface IGenericTest
method GetThings (line 347) | List<T> GetThings<T>(Guid test) where T : Thing;
class OtherThing (line 349) | public class OtherThing
method GetThings (line 353) | List<T> GetThings<T>(Guid test) where T : Thing
class ForwardGenericMethodsTestClass (line 360) | public class ForwardGenericMethodsTestClass
method Create (line 364) | public T Create<T>(int arg) where T : ForwardGenericMethodsTestClass, ...
class GenericMethOutPoco (line 371) | public class GenericMethOutPoco
method Func (line 373) | public bool Func<T>(out T result)
type IGenericMethodOut (line 380) | public interface IGenericMethodOut
method Func (line 382) | bool Func<T>(out T result);
type IMethodOut2 (line 385) | public interface IMethodOut2
method Func (line 387) | bool Func(out int result);
class MethRefPoco (line 391) | public class MethRefPoco
method Func (line 393) | public bool Func(ref int result)
class PocoAdder (line 401) | public class PocoAdder
method Add (line 403) | public int Add(int x, int y)
class PocoDoubleProp (line 409) | public class PocoDoubleProp : IInheritProp, IPropPocoProp, IEnumerable
method GetEnumerator (line 429) | IEnumerator IEnumerable.GetEnumerator()
class PocoCollection (line 435) | public class PocoCollection : IList
method GetEnumerator (line 437) | public IEnumerator GetEnumerator()
method CopyTo (line 442) | public void CopyTo(Array array, int index)
method Add (line 453) | public int Add(object value)
method Contains (line 458) | public bool Contains(object value)
method Clear (line 463) | public void Clear()
method IndexOf (line 468) | public int IndexOf(object value)
method Insert (line 473) | public void Insert(int index, object value)
method Remove (line 478) | public void Remove(object value)
method RemoveAt (line 483) | public void RemoveAt(int index)
FILE: Tests/Curry.cs
class Curry (line 11) | [TestFixture]
method TestBasicDelegateCurry (line 14) | [Test]
method TestBasicNamedCurry (line 28) | [Test]
method TestBasicConvertDelegateCurry (line 40) | [Test]
method TestBasicConvertDelegateCurryReturnValueType (line 50) | [Test]
method TestBasicConvertNonGenericDelegate (line 62) | [Test]
method TestBasicConvertNonGenericDelegateAction (line 72) | [Test]
method TestBasicConvertDelegateCurryParamValueType (line 83) | [Test]
method TestBasicConvertMoreCurryParamValueType (line 94) | [Test]
method TestBasicConvertMoreMoreCurryParamValueType (line 105) | [Test]
method TestPococMethodCurry (line 120) | [Test]
method TestStaticMethodCurry (line 133) | [Test]
method TestStaticMethodLongCurry (line 146) | [Test]
method TestStaticMethodLongCurry2 (line 165) | [Test]
method TestDynamicMethodCurry (line 180) | [Test]
method UnboundedCurry (line 193) | [Test]
method UnboundedCurryCont (line 203) | [Test]
method BoundedCurryCont (line 215) | [Test]
method TestCurryNamedMethods (line 227) | [Test]
class Person (line 236) | private class Person
method Jump (line 238) | public void Jump(uint height, string cheer)
method TestPococMethodPartialApply (line 245) | [Test]
method UnboundedPartialApply (line 254) | [Test]
method BasicCurryTest (line 267) | [Test]
method CurryLeftPipeTest (line 283) | [Test]
method CurryRightPipeTest (line 295) | [Test]
FILE: Tests/DynamicObjects.cs
class DynamicObjs (line 17) | [TestFixture]
method GetterAnonTest (line 24) | [Test]
method GetterVoidTest (line 36) | [Test]
method GetterArrayTest (line 46) | [Test]
method GetterEventTest (line 59) | [Test]
method GetterEventTest2 (line 74) | [Test]
method GetterDynamicTest (line 89) | [Test]
class TestForwarder (line 105) | public class TestForwarder : Dynamitey.DynamicObjects.BaseForwarder
method TestForwarder (line 107) | public TestForwarder(object target)
method ForwardAnonTest (line 113) | [Test]
method ForwardVoidTest (line 125) | [Test]
method ForwardGenericMethodsTest (line 136) | [Test]
method ForwardDynamicTest (line 147) | [Test]
method DictionaryMethodsTest (line 163) | [Test]
method ForwardMethodsTest (line 185) | [Test]
method DictionaryMethodsOutTest (line 208) | [Test]
method TestOut (line 222) | private static object TestOut(CallSite dummy, object @in, out string @...
method DictionaryMethodsTestWithPropertyAccess (line 230) | [Test]
method DictionaryNullMethodsTest (line 250) | [Test]
method DynamicDictionaryWrappedTest (line 264) | [Test]
method InterfaceDictionaryWrappedTest (line 289) | [Test]
method DynamicObjectEqualsTest (line 335) | [Test]
method DynamicAnnonymousWrapper (line 365) | [Test]
method TestAnonInterface (line 388) | [Test]
method TestBuilder (line 412) | [Test]
method TestSetupOtherTypes (line 436) | [Test]
method TestClayFactorySyntax (line 464) | [Test]
method TestFactoryListSyntax (line 522) | [Test]
method TestQuicListSyntax (line 549) | [Test]
method TestRecorder (line 560) | [Test]
method TestCodeDomLateTypeBind (line 578) | [Test]
method TestLateLibrarybind (line 610) | [Test]
FILE: Tests/ExpandoObjs.cs
class ExpandoObjs (line 6) | [TestFixture]
method TestExpando (line 9) | [Test]
method TestExpando2 (line 34) | [Test]
FILE: Tests/Helper.cs
class Helper (line 6) | public class Helper:AssertionHelper
FILE: Tests/Impromptu.cs
class Impromptu (line 15) | [TestFixture(Category = "Impromptu")]
method DictionaryInterfaceNullMethodsTest (line 24) | [Test]
method FauxTypeTest (line 35) | [Test]
method PropertySpecTest (line 65) | [Test]
method InterfaceSpecTest (line 84) | [Test]
method DictionaryCurriedAcctlikeNullMethodsTest (line 101) | [Test]
type IBuilder (line 113) | public interface IBuilder
method Nester (line 115) | INest Nester(object props);
method Nester2 (line 116) | INested Nester2(object props);
method Nester (line 118) | [ImpromptuInterface.UseNamedArgument]
method Nester2 (line 121) | INested Nester2([ImpromptuInterface.UseNamedArgument] string NameLev...
type INest (line 124) | public interface INest
type INested (line 131) | public interface INested
method TestBuilderActLikeAnon (line 139) | [Test]
method TestBuilderActLikeNamed (line 157) | [Test]
FILE: Tests/Invoke.cs
class Invoke (line 17) | public class Invoke:Helper
method DestroyCaches (line 19) | [OneTimeTearDown]
method TestDynamicSet (line 26) | [Test]
method TestPocoSet (line 41) | [Test]
method TestStructSet (line 55) | [Test]
method TestCacheableDyanmicSetAndPocoSetAndSetNull (line 68) | [Test]
method TestConvert (line 98) | [Test]
method TestConvertCacheable (line 109) | [Test]
method TestConstruct (line 122) | [Test]
method TestCacheableConstruct (line 134) | [Test]
method TestConstructOptional (line 149) | [Test]
method TestCacheableConstructOptional (line 162) | [Test]
method TestOptionalArgumentActivationNoneAndCacheable (line 174) | [Test]
method TestConstructValueType (line 195) | [Test]
method TestCacheableConstructValueType (line 204) | [Test]
method TestConstructValueTypeJustDynamic (line 214) | [Test]
method TestConstructprimativetype (line 225) | [Test]
method TestConstructDateTimeNoParams (line 234) | [Test]
method TestConstructOBjectNoParams (line 242) | [Test]
method TestConstructNullableprimativetype (line 250) | [Test]
method TestConstructGuid (line 258) | [Test]
method TestCacheablePrimativeDateTimeObjectNullableAndGuidNoParams (line 266) | [Test]
method TestStaticCall (line 297) | [Test]
method TestCacheableStaticCall (line 308) | [Test]
class TestClass (line 321) | private class TestClass
method TestStaticPropertySetFollowedByGetTest (line 326) | [Test]
method TestImplicitConvert (line 336) | [Test]
method TestCoerceConverterColor (line 346) | [Test]
method TestCoerceConverterDBNULL (line 358) | [Test]
method TestCacheableImplicitConvert (line 375) | [Test]
method TestCacheableGet (line 388) | [Test]
method TestGetIndexer (line 410) | [Test]
method TestGetIndexerValue (line 425) | [Test]
method TestGetLengthArray (line 440) | [Test]
method TestGetIndexerArray (line 452) | [Test]
method TestCacheableIndexer (line 466) | [Test]
method TestSetIndexer (line 503) | [Test]
method TestCacheableSetIndexer (line 516) | [Test]
method TestMethodDynamicPassAndGetValue (line 534) | [Test]
method TestCacheableMethodDynamicPassAndGetValue (line 548) | [Test]
method TestMethodStaticOverloadingPassAndGetValue (line 564) | [Test]
method TestCachedMethodStaticOverloadingPassAndGetValue (line 587) | [Test]
method TestMethodPocoOverloadingPassAndGetValueArg (line 613) | [Test]
method TestMethodPocoOverloadingPassAndGetValueArgOptional (line 636) | [Test]
method TestCacheableMethodPocoOverloadingPassAndGetValueArgOptional (line 652) | [Test]
method TestCacheableMethodPocoOverloadingPassAndGetValueArgPostiionalOptional (line 669) | [Test]
method TestMethodPocoOverloadingPass2AndGetValueArgOptional (line 687) | [Test]
method TestMethodPocoOverloadingPassAndGetValueNull (line 703) | [Test]
method TestOutMethod (line 737) | [Test]
method TestMethodDynamicPassVoid (line 772) | [Test]
method TestCacheableMethodDynamicPassVoid (line 789) | [Test]
method TestCacheableMethodDynamicUnknowns (line 806) | [Test]
method TestMethodPocoGetValue (line 832) | [Test]
method TestMethodPocoPassAndGetValue (line 846) | [Test]
method HelpTestPocoPassAndGetValue (line 857) | private void HelpTestPocoPassAndGetValue(string tValue, string tParam)
method TestGetDynamic (line 867) | [Test]
method TestGetDynamicChained (line 882) | [Test]
method TestGetDynamicChainedWithIndexes (line 898) | [Test]
method TestSetDynamicChained (line 919) | [Test]
method TestSetDynamicChainedWithInexes (line 934) | [Test]
method TestSetDynamicAllDict (line 954) | [Test]
method TestSetDynamicAllAnonymous (line 973) | [Test]
method TestSetDynamicAllNamed (line 986) | [Test]
method TestSetDynamicChainedOne (line 999) | [Test]
method TestGetDynamicChainedOne (line 1012) | [Test]
method TestCacheableGetDynamic (line 1027) | [Test]
method TestStaticGet (line 1042) | [Test]
method TestCacheableStaticGet (line 1050) | [Test]
method TestStaticGet2 (line 1061) | [Test]
method TestStaticGet3 (line 1069) | [Test]
method TestStaticSet (line 1075) | [Test]
method TestCacheableStaticSet (line 1084) | [Test]
method TestStaticDateTimeMethod (line 1095) | [Test]
method TestCacheableStaticDateTimeMethod (line 1104) | [Test]
method TestIsEvent (line 1117) | [Test]
method TestCacheableIsEventAndIsNotEvent (line 1127) | [Test]
method TestIsNotEvent (line 1147) | [Test]
method TestPocoAddAssign (line 1178) | [Test]
method TestCacheablePocoAddAssign (line 1197) | [Test]
method TestPocoSubtractAssign (line 1218) | [Test]
method TestCacheablePocoSubtractAssign (line 1242) | [Test]
method TestDynamicAddAssign (line 1268) | [Test]
method TestCacheableDynamicAddAssign (line 1285) | [Test]
method TestDynamicSubtractAssign (line 1305) | [Test]
method TestCacheableDynamicSubtractAssign (line 1327) | [Test]
method TestDynamicMemberNamesExpando (line 1352) | [Test]
method TestDynamicMemberNamesImpromput (line 1360) | [Test]
method TestCachedInvocationEquality (line 1368) | [Test]
method CreateMock (line 1382) | private DynamicObject CreateMock(ExpressionType op)
class OperatorTestDynObject (line 1392) | public class OperatorTestDynObject:DynamicObject{
method OperatorTestDynObject (line 1394) | public OperatorTestDynObject(ExpressionType type){
method TryBinaryOperation (line 1398) | public override bool TryBinaryOperation(BinaryOperationBinder binder...
method TryUnaryOperation (line 1404) | public override bool TryUnaryOperation(UnaryOperationBinder binder, ...
method RunBinaryMockTests (line 1411) | private void RunBinaryMockTests(ExpressionType type){
method RunUnaryMockTests (line 1417) | private void RunUnaryMockTests(ExpressionType type){
method TestInvokeAdd (line 1424) | [Test]
method TestInvokeBasicUnaryOperatorsDynamic (line 1430) | [Test]
method TestInvokeBasicBinaryOperatorsDynamic (line 1442) | [Test]
method TestInvokeSubtract (line 1471) | [Test]
FILE: Tests/Linq.cs
class Linq (line 14) | [TestFixture]
method SimpleLinqDynamicLinq (line 19) | [Test]
method MoreGenericsDynamicLinq (line 28) | [Test]
method RunPythonHelper (line 40) | private dynamic RunPythonHelper(object linq, string code)
method PythonDynamicLinqGenericArgs (line 59) | [Test]
method PythonDynamicLinq (line 73) | [Test]
method PrintOutInterface (line 90) | [Test]
method HelperIsGenericExtension (line 138) | private bool HelperIsGenericExtension(MethodInfo it, Type genericType)
method HelperSignleGenericArgMatch (line 145) | bool HelperSignleGenericArgMatch(Type info)
method HelperFormatType (line 160) | string HelperFormatType(Type it)
method HelperGenericParams (line 177) | string HelperGenericParams(Type[] it)
method HelperReturnTypeSub (line 186) | string HelperReturnTypeSub(Type it)
method HelperGetParams (line 200) | string HelperGetParams(ParameterInfo[] it)
method HelperGetParamsDebug (line 207) | string HelperGetParamsDebug(ParameterInfo[] it)
method HelperMakeName (line 214) | string HelperMakeName(MethodInfo it)
method HelperMakeNameDebug (line 218) | string HelperMakeNameDebug(MethodInfo it)
FILE: Tests/MimicTest.cs
class MimicTest (line 9) | [TestFixture]
class SubMimic (line 12) | private class SubMimic : DynamicObjects.Mimic
method Add (line 14) | public int Add(int x, int y)
method Add (line 19) | public string Add(string x, string y)
method Get_Property (line 25) | [Test]
method Set_Property (line 33) | [Test]
method Call_Method (line 41) | [Test]
method Call_Method_With_Parameters (line 49) | [Test]
method Get_Index (line 57) | [Test]
method Set_Index (line 65) | [Test]
method Cast (line 73) | [Test]
method Unary (line 92) | [Test]
method Binary (line 126) | [Test]
method Inheritance_Int (line 151) | [Test]
method Inheritance_String (line 159) | [Test]
method Inheritance_No_Match (line 167) | [Test]
FILE: Tests/PrivateTest.cs
class PrivateTest (line 12) | [TestFixture]
method TestInvokePrivateMethod (line 16) | [Test]
method TestInvokePrivateMethodAcrossAssemblyBoundries (line 23) | [Test]
method TestInvokeInternalTypeMethodAcrossAssemblyBoundries (line 30) | [Test]
method TestInvokeDoNotExposePrivateMethod (line 37) | [Test]
method TestCacheableDoNotExposePrivateMethod (line 45) | [Test]
method TestCacheableExposePrivateMethodViaInstance (line 53) | [Test]
method TestCacheableExposePrivateMethodViaType (line 61) | [Test]
class TestWithPrivateMethod (line 70) | public class TestWithPrivateMethod
method Test (line 72) | private int Test()
FILE: Tests/SpeedTest.cs
class SpeedTest (line 12) | [TestFixture]
method WarmUpDlr (line 16) | [OneTimeSetUp]
method Setup (line 24) | [SetUp]
method PropPocoGetValueTimed (line 31) | [Test]
method CacheableGetValueTimed (line 60) | [Test]
method ConstructorTimed (line 87) | [Test]
method CacheableConstructorTimed (line 105) | [Test]
method ConstructorNoARgTimed (line 124) | [Test]
method CachableConstructorNoARgTimed (line 148) | [Test]
method ConstructorValueTypeTimed (line 174) | [Test]
method CachedConstructorValueTypeTimed (line 195) | [Test]
method MethodPocoGetValueTimed (line 216) | [Test]
method CacheableMethodPocoGetValueTimed (line 241) | [Test]
method GetStaticTimed (line 265) | [Test]
method CacheableGetStaticTimed (line 291) | [Test]
method MethodStaticMethodValueTimed (line 319) | [Test]
method CacheableMethodStaticMethodValueTimed (line 343) | [Test]
method MethodPocoGetValuePassNullTimed (line 368) | [Test]
method CacheableMethodPocoGetValuePassNullTimed (line 394) | [Test]
method MethodPocoGetValuePassNullDoubleCallTimed (line 423) | [Test]
method CacheableMethodPocoGetValuePassNullDoubleCallTimed (line 452) | [Test]
method MethodPocoGetValue4argsTimed (line 480) | [Test]
method CacheableMethodPocoGetValue4argsTimed (line 506) | [Test]
method MethodPocoVoidTimed (line 534) | [Test]
method CacheableMethodPocoVoidTimed (line 557) | [Test]
method SetTimed (line 581) | [Test]
method CacheableSetTimed (line 605) | [Test]
method CacheableSetNullTimed (line 629) | [Test]
method SetNullTimed (line 648) | [Test]
method FastDynamicInvoke (line 673) | [Test]
method FastDynamicInvokeAction (line 690) | [Test]
method IsTupleTimed (line 707) | [Test]
method TupleIndexTimed (line 727) | [Test]
method TupleToListTimed (line 747) | [Test]
method ListToTupleTimed (line 766) | [Test]
FILE: Tests/TimeIt.cs
class TimeIt (line 7) | public class TimeIt
method TimeIt (line 15) | public TimeIt(bool skipInitializationCosts = false)
method GoThree (line 22) | public Tuple<TimeSpan, TimeSpan, TimeSpan> GoThree(int iteration = Mil...
method Go (line 55) | public Tuple<TimeSpan, TimeSpan> Go(int iteration = Million)
method RelativeSpeed (line 65) | public static string RelativeSpeed(Tuple<TimeSpan, TimeSpan> elapsed)
FILE: Tests/TuplerTest.cs
class TuplerTest (line 11) | [TestFixture]
method DynamicCreateTypedTuple (line 15) | [Test]
method DynamicCreateTypedTuple8 (line 27) | [Test]
method DynamicCreateLongTypedTuple (line 40) | [Test]
method DynamicTupleSize (line 56) | [Test]
method DynamicTupleSize8 (line 63) | [Test]
method DynamicTupleSize20 (line 70) | [Test]
method DynamicTupleToList (line 78) | [Test]
method DynamicTupleToList8 (line 87) | [Test]
method DynamicTupleToList20 (line 95) | [Test]
method DynamicListToTuple (line 105) | [Test]
method DynamicListToTuplet8 (line 115) | [Test]
method DynamicListToTuple20 (line 124) | [Test]
method DynamicTupleIndex (line 136) | [Test]
method DynamicTupleIndex7 (line 143) | [Test]
method DynamicTupleIndex19 (line 150) | [Test]
Condensed preview — 73 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (758K chars).
[
{
"path": ".appveyor.yml",
"chars": 1112,
"preview": "image: Visual Studio 2017\n\nconfiguration: Debug\n\nbuild: off\n\ninstall:\n - ps: nuget install FSharp.Compiler.Tools -Exclu"
},
{
"path": ".github/workflows/dotnet.yml",
"chars": 637,
"preview": "name: Build .net core\n\non: [push]\n\njobs:\n build:\n name: Test ${{ matrix.os }} for dotnet ${{ matrix.dotnet }}\n ru"
},
{
"path": ".github/workflows/dotnet48.yml",
"chars": 992,
"preview": "name: Build CrossComple .net core/.net framework Windows\n\non: [push]\n\njobs:\n build:\n name: Test Windows .net Framewo"
},
{
"path": ".gitignore",
"chars": 2090,
"preview": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\nf\n# Use"
},
{
"path": ".vscode/tasks.json",
"chars": 450,
"preview": "{\n // See https://go.microsoft.com/fwlink/?LinkId=733558\n // for the documentation about the tasks.json format\n "
},
{
"path": "Directory.Build.props",
"chars": 177,
"preview": "<Project>\n <PropertyGroup>\n <WithoutCrossCompile Condition=\"'$(GITHUB_ACTION)' != '' OR '$(LGTM_SRC)' != ''\">T"
},
{
"path": "Dynamitey/Builder.cs",
"chars": 6543,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/CacheableInvocation.cs",
"chars": 14818,
"preview": "using System;\nusing System.Dynamic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing Dynamitey.Internal."
},
{
"path": "Dynamitey/Dynamic.cs",
"chars": 42309,
"preview": "// \n// Copyright 2010 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/DynamicObjects/BaseDictionary.cs",
"chars": 15416,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you"
},
{
"path": "Dynamitey/DynamicObjects/BaseForwarder.cs",
"chars": 15206,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/DynamicObjects/BaseObject.cs",
"chars": 3671,
"preview": "// \n// Copyright 2010 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/DynamicObjects/Builder.cs",
"chars": 15942,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/DynamicObjects/Dictionary.cs",
"chars": 5300,
"preview": " // \n// Copyright 2010 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// "
},
{
"path": "Dynamitey/DynamicObjects/Dummy.cs",
"chars": 6239,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing Dynamitey.Internal.Optimiza"
},
{
"path": "Dynamitey/DynamicObjects/ExtensionToInstanceProxy.cs",
"chars": 17170,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\nusin"
},
{
"path": "Dynamitey/DynamicObjects/Factory.cs",
"chars": 6640,
"preview": "// \n// Copyright 2010 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/DynamicObjects/FauxType.cs",
"chars": 7594,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing Dynamitey.Internal.Co"
},
{
"path": "Dynamitey/DynamicObjects/FluentStringLookup.cs",
"chars": 1766,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\n\nusing System.Text;\n\nusing Sys"
},
{
"path": "Dynamitey/DynamicObjects/Get.cs",
"chars": 7140,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/DynamicObjects/LateType.cs",
"chars": 4767,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\nusing System.Reflection;\n\nusin"
},
{
"path": "Dynamitey/DynamicObjects/Lazy.cs",
"chars": 2743,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\n\n\nnamespace Dynamitey.DynamicObjects\n{\n\n /// <su"
},
{
"path": "Dynamitey/DynamicObjects/LinqInstanceProxy.cs",
"chars": 12431,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n\nusing System.Text;\n\n\nname"
},
{
"path": "Dynamitey/DynamicObjects/List.cs",
"chars": 12920,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/DynamicObjects/Mimic.cs",
"chars": 4819,
"preview": "using System.Dynamic;\nusing System;\nusing System.Reflection;\n\n\n\nnamespace Dynamitey.DynamicObjects\n{\n /// <summary>\n"
},
{
"path": "Dynamitey/DynamicObjects/Recorder.cs",
"chars": 6446,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/DynamicObjects/RegexMatch.cs",
"chars": 3823,
"preview": "using System;\nusing System.Dynamic;\nusing System.Linq;\n\nusing System.Text.RegularExpressions;\nusing System.Collections."
},
{
"path": "Dynamitey/Dynamitey.csproj",
"chars": 2674,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFrameworks>netstandard2.0;net40</TargetFrameworks>\n "
},
{
"path": "Dynamitey/Expando.cs",
"chars": 1488,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/FluentRegex.cs",
"chars": 2588,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace Dynamitey\n{\n /"
},
{
"path": "Dynamitey/InlineLambdas.cs",
"chars": 61180,
"preview": "// Copyright 2010 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you m"
},
{
"path": "Dynamitey/InlineLambdas.tt",
"chars": 4170,
"preview": "<#@ template language=\"C#\" #>\n<#@ output extension=\"cs\" #>\n// Copyright 2010 Ekon Benefits\n// \n// Licensed under t"
},
{
"path": "Dynamitey/Internal/Compat/Net40.cs",
"chars": 801,
"preview": "\n\n\n\nnamespace Dynamitey.Internal.Compat\n{\n\n using System;\n using System.Collections.Generic;\n using System.Ref"
},
{
"path": "Dynamitey/Internal/Curry.cs",
"chars": 9035,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/Internal/InvokeSetters.cs",
"chars": 4458,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\nusin"
},
{
"path": "Dynamitey/Internal/Optimization/BareBonesList.cs",
"chars": 3016,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/Internal/Optimization/BinderHash.cs",
"chars": 6872,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/Internal/Optimization/InvokeHelper-Regular.cs",
"chars": 36821,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\nusing System.Reflection;\nusing"
},
{
"path": "Dynamitey/Internal/Optimization/InvokeHelper.cs",
"chars": 39675,
"preview": "\n// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/Internal/Optimization/InvokeHelper.tt",
"chars": 9759,
"preview": "<#@ template language=\"C#\" #>\n<#@ output extension=\"cs\" #>\n<#@ assembly name=\"System.Core\" #>\n<#@ import namespace=\"Sy"
},
{
"path": "Dynamitey/Internal/Optimization/Util.cs",
"chars": 6766,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/Invocation.cs",
"chars": 10217,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/InvokeArg.cs",
"chars": 3241,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey/InvokeContext.cs",
"chars": 4440,
"preview": "// \n// Copyright 2011 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// y"
},
{
"path": "Dynamitey/InvokeMemberName.cs",
"chars": 5591,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Dynamitey\n{\n \n\n //"
},
{
"path": "Dynamitey/PartialApply.cs",
"chars": 9133,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\nusin"
},
{
"path": "Dynamitey/ThisFunctions.cs",
"chars": 12878,
"preview": "\n// Copyright 2010 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you "
},
{
"path": "Dynamitey/ThisFunctions.tt",
"chars": 3199,
"preview": "<#@ template language=\"C#\" #>\n<#@ output extension=\"cs\" #>\n<#@ assembly name=\"System.Core\" #>\n<#@ import namespace=\"Sy"
},
{
"path": "Dynamitey/Tupler.cs",
"chars": 7302,
"preview": "// \n// Copyright 2013 Ekon Benefits\n// \n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// yo"
},
{
"path": "Dynamitey.sln",
"chars": 2541,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.7.3420"
},
{
"path": "Dynamitey.sln.DotSettings",
"chars": 1600,
"preview": "<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namesp"
},
{
"path": "License.txt",
"chars": 10300,
"preview": "Apache License, Version 2.0\nApache License\nVersion 2.0, January 2004\nhttp://www.apache.org/licenses/\n\nTERMS AND CONDITIO"
},
{
"path": "NuGet.config",
"chars": 281,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n <config>\n <add key=\"globalPackagesFolder\" value=\"packages\" /"
},
{
"path": "Readme.md",
"chars": 1726,
"preview": "# Dynamitey \n\n(pronounced dyna-mighty) flexes DLR muscle to do meta-mazing things in .net\n\nDynamitey is available Nuget"
},
{
"path": "SupportLibrary/SupportLibrary.csproj",
"chars": 372,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>netstandard2.0</TargetFramework>\n </Property"
},
{
"path": "SupportLibrary/SupportTypes.cs",
"chars": 9968,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.Compi"
},
{
"path": "TestResult.xml",
"chars": 92071,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<test-run id=\"2\" testcasecount=\"214\" result=\"Passed\" total=\"182\" "
},
{
"path": "Tests/Curry.cs",
"chars": 9279,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusi"
},
{
"path": "Tests/DynamicObjects.cs",
"chars": 21001,
"preview": "using System;\nusing System.CodeDom.Compiler;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.D"
},
{
"path": "Tests/ExpandoObjs.cs",
"chars": 1748,
"preview": "using System.Dynamic;\nusing NUnit.Framework;\n\nnamespace Dynamitey.Tests\n{\n [TestFixture]\n public class ExpandoObj"
},
{
"path": "Tests/Helper.cs",
"chars": 236,
"preview": "using NUnit.Framework;\n\nnamespace Dynamitey.Tests\n{\n#pragma warning disable CS0618 // Type or member is obsolete\n pub"
},
{
"path": "Tests/Impromptu.cs",
"chars": 4558,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusi"
},
{
"path": "Tests/Invoke.cs",
"chars": 42792,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Dynamic;\nusing System.Linq;\nusing Sy"
},
{
"path": "Tests/Linq.cs",
"chars": 7432,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nu"
},
{
"path": "Tests/MimicTest.cs",
"chars": 6356,
"preview": "using System;\nusing NUnit.Framework;\n\nnamespace Dynamitey.Tests\n{\n /// <summary>\n /// This is the craziest set of"
},
{
"path": "Tests/PrivateTest.cs",
"chars": 2510,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusi"
},
{
"path": "Tests/SpeedTest.cs",
"chars": 28683,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusi"
},
{
"path": "Tests/Tests.csproj",
"chars": 1064,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n <PropertyGroup>\n <TargetFrameworks>net8.0;net48</TargetFrameworks>\n\t <IsPackabl"
},
{
"path": "Tests/TimeIt.cs",
"chars": 2710,
"preview": "using System;\nusing System.Diagnostics;\nusing NUnit.Framework;\n\nnamespace Dynamitey.Tests\n{\n public class TimeIt\n "
},
{
"path": "Tests/TuplerTest.cs",
"chars": 4560,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusi"
},
{
"path": "Version.props",
"chars": 216,
"preview": "<Project>\n <PropertyGroup>\n <VersionPrefix>3.0.4</VersionPrefix>\n <VersionSuffix Condition=\" '$(GITHUB_"
},
{
"path": "build.fsx",
"chars": 6006,
"preview": "#!/bin/sh\n#if bin_sh\n # Doing this because arguments can't be used with /usr/bin/env on linux, just mac\n exec fsharpi "
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the ekonbenefits/dynamitey GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 73 files (705.5 KB), approximately 170.9k tokens, and a symbol index with 1009 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.