Skip to content

Commit 20ab6bf

Browse files
committed
Initial commit
0 parents  commit 20ab6bf

File tree

2,720 files changed

+1462898
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,720 files changed

+1462898
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.vs/msg/v14/.suo

96 KB
Binary file not shown.

.vs/msg/v15/.suo

97 KB
Binary file not shown.

.vs/msg/v15/Server/sqlite3/db.lock

Whitespace-only changes.
632 KB
Binary file not shown.

XSLT.rar

621 KB
Binary file not shown.

XSLT/.vs/db/v14/.suo

7.5 KB
Binary file not shown.

XSLT/Linq/DeepCopy.Assign.cs

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.IO;
5+
using System.Runtime.Serialization.Formatters.Binary;
6+
7+
namespace System.Linq.Expressions
8+
{
9+
public static class GenericCopier<T>
10+
{
11+
public static T DeepCopy(object objectToCopy)
12+
{
13+
using (MemoryStream memoryStream = new MemoryStream())
14+
{
15+
BinaryFormatter binaryFormatter = new BinaryFormatter();
16+
binaryFormatter.Serialize(memoryStream, objectToCopy);
17+
memoryStream.Seek(0, SeekOrigin.Begin);
18+
return (T)binaryFormatter.Deserialize(memoryStream);
19+
}
20+
}
21+
}
22+
23+
public static class ExpressionEx1
24+
{
25+
public static BinaryExpression Assign(Expression left, Expression right)
26+
{
27+
var assign = typeof(Assigner<>).MakeGenericType(left.Type).GetMethod("Assign");
28+
29+
var assignExpr = Expression.Add(left, right, assign);
30+
31+
return assignExpr;
32+
}
33+
34+
private static class Assigner<T>
35+
{
36+
public static T Assign(ref T left, T right)
37+
{
38+
left = GenericCopier<T>.DeepCopy(right);
39+
//T clone = ProtoBuf.PropertyCopy<T>.CopyFrom(right);
40+
//return (left = right);
41+
return left;
42+
}
43+
}
44+
}
45+
}
46+
47+
//using System.Reflection;
48+
49+
//namespace System.Linq.Expressions
50+
//{
51+
// /// <summary>
52+
// /// Provides extensions for converting lambda functions into assignment actions
53+
// /// </summary>
54+
// public static class ExpressionEx1
55+
// {
56+
// /// <summary>
57+
// /// Converts a field/property retrieve expression into a field/property assign expression
58+
// /// </summary>
59+
// /// <typeparam name="TInstance">The type of the instance.</typeparam>
60+
// /// <typeparam name="TProp">The type of the prop.</typeparam>
61+
// /// <param name="fieldGetter">The field getter.</param>
62+
// /// <returns></returns>
63+
// public static Expression<Action<TInstance, TProp>> ToFieldAssignExpression<TInstance, TProp>
64+
// (
65+
// this Expression<Func<TInstance, TProp>> fieldGetter
66+
// )
67+
// {
68+
// if (fieldGetter == null)
69+
// throw new ArgumentNullException("fieldGetter");
70+
71+
// if (fieldGetter.Parameters.Count != 1 || !(fieldGetter.Body is MemberExpression))
72+
// throw new ArgumentException(
73+
// @"Input expression must be a single parameter field getter, e.g. g => g._fieldToSet or function(g) g._fieldToSet");
74+
75+
// var parms = new[]
76+
// {
77+
// fieldGetter.Parameters[0],
78+
// Expression.Parameter(typeof (TProp), "value")
79+
// };
80+
81+
// Expression body = Expression.Call(AssignmentHelper<TProp>.MethodInfoSetValue,
82+
// new[] { fieldGetter.Body, parms[1] });
83+
84+
// return Expression.Lambda<Action<TInstance, TProp>>(body, parms);
85+
// }
86+
87+
88+
// public static Action<TInstance, TProp> ToFieldAssignment<TInstance, TProp>
89+
// (
90+
// this Expression<Func<TInstance, TProp>> fieldGetter
91+
// )
92+
// {
93+
// return fieldGetter.ToFieldAssignExpression().Compile();
94+
// }
95+
96+
// #region Nested type: AssignmentHelper
97+
98+
// private class AssignmentHelper<T>
99+
// {
100+
// internal static readonly MethodInfo MethodInfoSetValue =
101+
// typeof(AssignmentHelper<T>).GetMethod("SetValue", BindingFlags.NonPublic | BindingFlags.Static);
102+
103+
// private static void SetValue(ref T target, T value)
104+
// {
105+
// target = value;
106+
// }
107+
// }
108+
109+
// #endregion
110+
// }
111+
112+
// public static class ExpressionEx2
113+
// {
114+
// public static Expression Create(Expression left, Expression right)
115+
// {
116+
// return
117+
// Expression.Call(
118+
// null,
119+
// typeof(ExpressionEx2)
120+
// .GetMethod("AssignTo", BindingFlags.NonPublic | BindingFlags.Static)
121+
// .MakeGenericMethod(left.Type),
122+
// left,
123+
// right);
124+
// }
125+
126+
// private static void AssignTo<T>(ref T left, T right) // note the 'ref', which is
127+
// { // important when assigning
128+
// left = right; // to value types!
129+
// }
130+
// }
131+
//}

0 commit comments

Comments
 (0)