Permalink
Browse files

Introduced PCL

  • Loading branch information...
activa committed Nov 16, 2013
1 parent 105140d commit 07940564150f188b5b3c917605c78d010c25cb83
Showing with 307 additions and 73 deletions.
  1. +1 −1 Library/CompatibilityLayer.cs
  2. +3 −3 Library/CoreExtensions.cs
  3. +2 −2 Library/EasyConfig/FieldOrPropertyInfo.cs
  4. +1 −1 Library/Parser/ExpressionParser/Exceptions/BadArgumentException.cs
  5. +1 −1 Library/Parser/ExpressionParser/Exceptions/ExpressionEvaluationException.cs
  6. +1 −1 Library/Parser/ExpressionParser/Exceptions/IllegalAssignmentException.cs
  7. +1 −1 Library/Parser/ExpressionParser/Exceptions/IllegalOperandsException.cs
  8. +1 −1 Library/Parser/ExpressionParser/Exceptions/LexerException.cs
  9. +1 −1 Library/Parser/ExpressionParser/Exceptions/LiteralException.cs
  10. +1 −1 Library/Parser/ExpressionParser/Exceptions/ParserException.cs
  11. +1 −1 Library/Parser/ExpressionParser/Exceptions/UnknownPropertyException.cs
  12. +2 −2 Library/Parser/ExpressionParser/Expression/CallExpression.cs
  13. +1 −1 Library/Parser/ExpressionParser/Expression/IndexExpression.cs
  14. +1 −1 Library/Parser/TemplateParser/Exceptions/TemplateParserException.cs
  15. +1 −1 Library/Parser/TemplateParser/Exceptions/TemplateParsingException.cs
  16. +1 −1 Library/Parser/TemplateParser/Exceptions/TemplateRenderingException.cs
  17. +1 −1 Library/Parser/TemplateParser/TemplateConfigs/Xml/Xml.cs
  18. +2 −2 Library/Parser/TemplateParser/TemplateParser.cs
  19. +2 −2 Library/Parser/TemplateParser/TemplateParserConfig.cs
  20. +2 −0 Library/Properties/AssemblyInfo.cs
  21. +1 −1 Library/Reflection/LazyBinder.cs
  22. +15 −15 Library/TypeInspector.cs
  23. +236 −0 Library/Vici.Core.PCL.csproj
  24. +28 −0 Vici.Core.PCL.sln
  25. +0 −32 Vici.Core.WP8.sln
@@ -57,7 +57,7 @@ public static Type[] FindInterfaces(this Type type, TypeFilter typeFilter, objec
}
#endif
-#if !NETFX_CORE
+#if !NETFX_CORE && !PCL
public static class File
{
public static string ReadAllText(string filename)
@@ -33,7 +33,7 @@
namespace Vici.Core
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
public delegate TOutput Converter<TInput, TOutput>(TInput value);
#endif
public static class CoreExtensions
@@ -42,14 +42,14 @@ public static class CoreExtensions
{
if (array == null)
throw new ArgumentException();
-#if WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE
+#if WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE || PCL
return array.Select(item => converter(item)).ToArray();
#else
return Array.ConvertAll(array,converter);
#endif
}
-#if NETFX_CORE
+#if NETFX_CORE || PCL
public static void ForEach<T>(this IEnumerable<T> list, Action<T> action)
{
foreach (var item in list)
@@ -62,7 +62,7 @@ public void SetValue(object o, object value)
public Attribute[] GetCustomAttributes(Type type, bool inherit)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _memberInfo.GetCustomAttributes(type, inherit).ToArray();
#else
return (Attribute[]) _memberInfo.GetCustomAttributes(type, inherit);
@@ -71,7 +71,7 @@ public Attribute[] GetCustomAttributes(Type type, bool inherit)
public T[] GetCustomAttributes<T>(bool inherit) where T:Attribute
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _memberInfo.GetCustomAttributes<T>(inherit).ToArray();
#else
return (T[]) _memberInfo.GetCustomAttributes(typeof(T), inherit);
@@ -43,7 +43,7 @@ public BadArgumentException(string message, Expression expressionNode, Exception
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public BadArgumentException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -53,7 +53,7 @@ public ExpressionEvaluationException(string message, Expression expressionNode,
ExpressionNode = expressionNode;
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public ExpressionEvaluationException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -44,7 +44,7 @@ public IllegalAssignmentException(string message, Expression expressionNode, Exc
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public IllegalAssignmentException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -43,7 +43,7 @@ public IllegalOperandsException(string message, Expression expressionNode, Excep
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public IllegalOperandsException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -52,7 +52,7 @@ public LexerException(string message, TokenPosition position, string token, Exce
Token = token;
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public LexerException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -43,7 +43,7 @@ public LiteralException(string message, Expression expressionNode, Exception inn
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public LiteralException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -43,7 +43,7 @@ protected ParserException(string message, Exception innerException) : base(messa
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
protected ParserException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -43,7 +43,7 @@ public UnknownPropertyException(string message, Expression expressionNode, Excep
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public UnknownPropertyException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -85,7 +85,7 @@ public override ValueExpression Evaluate(IParserContext context)
if (methodObject is Delegate[])
{
Delegate[] delegates = (Delegate[]) methodObject;
-#if NETFX_CORE
+#if NETFX_CORE || PCL
MethodBase[] methods = delegates.ConvertAll<Delegate, MethodBase>(d => d.GetMethodInfo());
#else
MethodBase[] methods = delegates.ConvertAll<Delegate, MethodBase>(d => d.Method);
@@ -104,7 +104,7 @@ public override ValueExpression Evaluate(IParserContext context)
if (methodObject is Delegate)
{
Delegate method = (Delegate) methodObject;
-#if NETFX_CORE
+#if NETFX_CORE || PCL
MethodInfo methodInfo = method.GetMethodInfo();
#else
MethodInfo methodInfo = method.Method;
@@ -73,7 +73,7 @@ public ValueExpression Evaluate(IParserContext context, bool assign, object newV
throw new BadArgumentException(t.GetType().Name + " is not a valid type for array indexers", this);
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
if (useLong)
{
long[] indexes = new long[parameters.Length];
@@ -43,7 +43,7 @@ public TemplateParserException(string message, Exception innerException, TokenPo
_tokenPosition = tokenPosition;
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public TemplateParserException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -40,7 +40,7 @@ public TemplateParsingException(string message, Exception innerException, TokenP
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public TemplateParsingException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -39,7 +39,7 @@ public TemplateRenderingException(string message, Exception innerException, Toke
{
}
-#if !WINDOWS_PHONE && !NETFX_CORE
+#if !WINDOWS_PHONE && !NETFX_CORE && !PCL
public TemplateRenderingException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
@@ -44,7 +44,7 @@ internal static string ReplaceEscapes(string text)
XmlWriter xmlWriter = XmlWriter.Create(writer, settings);
xmlWriter.WriteString(text);
-#if NETFX_CORE
+#if NETFX_CORE || PCL
xmlWriter.Dispose();
#else
xmlWriter.Close();
@@ -70,7 +70,7 @@ public TemplateParserConfig Config
get { return _config; }
}
-#if !NETFX_CORE
+#if !NETFX_CORE && !PCL
public CompiledTemplate ParseFile(string fileName)
{
CompiledTemplate template = Parse(CompatibilityLayer.File.ReadAllText(fileName));
@@ -244,7 +244,7 @@ private static string CheckEmptyLine(TextTemplateNode lastTextNode, string text)
return text;
}
-#if !NETFX_CORE
+#if !NETFX_CORE && !PCL
public string RenderFile(string fileName, IParserContext context)
{
return Render(ParseFile(fileName), context);
@@ -161,7 +161,7 @@ protected virtual CompiledTemplate OnEvalParseFile(ExpressionParser parser, Temp
parameters[var.Key] = parser.Evaluate(var.Value, context);
}
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return null; // TODO: use isolated storage
#else
string includeFile = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(pExpr.MainExpression), fileName));
@@ -177,7 +177,7 @@ internal string EvalIncludeFile(ExpressionParser parser, string fileName, Templa
protected virtual string OnEvalIncludeFile(ExpressionParser parser, string fileName, TemplateToken token, IParserContext context)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return ""; // TODO: use isolated storage
#else
string includeFile = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(fileName), fileName));
@@ -15,4 +15,6 @@
[assembly:InternalsVisibleTo("Vici.Core.Test")]
[assembly: InternalsVisibleTo("Vici.Core.Metro.Test")]
+#if !PCL
[assembly: Guid("85cfa949-a3df-4f38-bb53-a2d992d0adc1")]
+#endif
@@ -32,7 +32,7 @@
namespace Vici.Core
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
public abstract class Binder { }
[Flags]
View
@@ -6,7 +6,7 @@
namespace Vici.Core
{
-#if !NETFX_CORE
+#if !NETFX_CORE && !PCL
public static class TypeInfoMocker
{
public static Type GetTypeInfo(this Type type) { return type; }
@@ -113,7 +113,7 @@ public object DefaultValue()
public MethodInfo GetMethod(string name, Type[] types)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return WalkAndFindSingle(t => t.GetTypeInfo().GetDeclaredMethods(name).FirstOrDefault(mi => types.SequenceEqual(mi.GetParameters().Select(p => p.ParameterType))));
#else
return _t.GetMethod(name, types);
@@ -127,7 +127,7 @@ public MethodInfo GetMethod(string name, Type[] types)
public T GetAttribute<T>(bool inherit) where T : Attribute
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _t.GetTypeInfo().GetCustomAttributes<T>(inherit).FirstOrDefault();
#else
return (T) _t.GetCustomAttributes(typeof(T),inherit).FirstOrDefault();
@@ -146,7 +146,7 @@ public bool IsAssignableFrom(Type type)
public ConstructorInfo[] GetConstructors()
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _t.GetTypeInfo().DeclaredConstructors.ToArray();
#else
return _t.GetConstructors();
@@ -155,7 +155,7 @@ public ConstructorInfo[] GetConstructors()
public MemberInfo[] GetMember(string propertyName)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return WalkAndFindMultiple(t => t.GetTypeInfo().DeclaredMembers.Where(m => m.Name == propertyName));
#else
return _t.GetMember(propertyName);
@@ -164,7 +164,7 @@ public MemberInfo[] GetMember(string propertyName)
public PropertyInfo GetIndexer(Type[] types)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return WalkAndFindSingle(t => t.GetTypeInfo().DeclaredProperties.FirstOrDefault(pi => pi.Name == "Item" && LazyBinder.MatchParameters(types, pi.GetIndexParameters())));
#else
return _t.GetProperty("Item", null, types);
@@ -173,7 +173,7 @@ public PropertyInfo GetIndexer(Type[] types)
public T[] GetCustomAttributes<T>(bool inherit) where T:Attribute
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _t.GetTypeInfo().GetCustomAttributes<T>(inherit).ToArray();
#else
return (T[]) _t.GetCustomAttributes(typeof(T), inherit);
@@ -187,7 +187,7 @@ public MethodInfo GetPropertyGetter(string propertyName, Type[] parameterTypes)
public PropertyInfo GetProperty(string propName)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return WalkAndFindSingle(t => t.GetTypeInfo().GetDeclaredProperty(propName));
#else
return _t.GetProperty(propName);
@@ -196,7 +196,7 @@ public PropertyInfo GetProperty(string propName)
public FieldInfo GetField(string fieldName)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return WalkAndFindSingle(t => t.GetTypeInfo().GetDeclaredField(fieldName));
#else
return _t.GetField(fieldName);
@@ -207,7 +207,7 @@ public bool ImplementsOrInherits(Type type)
{
if (type.GetTypeInfo().IsGenericTypeDefinition && type.GetTypeInfo().IsInterface)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _t.GetTypeInfo().ImplementedInterfaces.Any(t => (t.GetTypeInfo().IsGenericType && t.GetTypeInfo().GetGenericTypeDefinition() == type));
#else
return _t.FindInterfaces((t, criteria) => (t.GetTypeInfo().IsGenericType && t.GetTypeInfo().GetGenericTypeDefinition() == type), null).Any();
@@ -230,14 +230,14 @@ public MethodInfo GetMethod(string methodName, BindingFlags bindingFlags, Type[]
public Type[] GetGenericArguments()
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _t.GenericTypeArguments;
#else
return _t.GetGenericArguments();
#endif
}
-#if NETFX_CORE
+#if NETFX_CORE || PCL
private bool MatchBindingFlags(FieldInfo fieldInfo, BindingFlags flags)
{
if (flags == BindingFlags.Default)
@@ -283,7 +283,7 @@ private bool MatchBindingFlags(PropertyInfo propertyInfo, BindingFlags flags)
public FieldInfo[] GetFields(BindingFlags bindingFlags)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
if ((bindingFlags & BindingFlags.DeclaredOnly) != 0)
return _t.GetTypeInfo().DeclaredFields.Where(fi => MatchBindingFlags(fi, bindingFlags)).ToArray();
else
@@ -295,7 +295,7 @@ public FieldInfo[] GetFields(BindingFlags bindingFlags)
public PropertyInfo[] GetProperties(BindingFlags bindingFlags)
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
if ((bindingFlags & BindingFlags.DeclaredOnly) != 0)
return _t.GetTypeInfo().DeclaredProperties.Where(pi => MatchBindingFlags(pi, bindingFlags)).ToArray();
else
@@ -307,7 +307,7 @@ public PropertyInfo[] GetProperties(BindingFlags bindingFlags)
public Type[] GetInterfaces()
{
-#if NETFX_CORE
+#if NETFX_CORE || PCL
return _t.GetTypeInfo().ImplementedInterfaces.ToArray();
#else
return _t.GetInterfaces();
Oops, something went wrong.

0 comments on commit 0794056

Please sign in to comment.