PageRenderTime 63ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/facebook.Linq/Linq/FqlExecuteResult.cs

https://bitbucket.org/assaframan/facebooklinq
C# | 71 lines | 56 code | 10 blank | 5 comment | 3 complexity | 5af1c01191136b965968045cf20ed9ac MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.Linq;
  6. using System.Linq.Expressions;
  7. using System.Xml;
  8. namespace facebook.Linq
  9. {
  10. class FqlExecuteResult : IExecuteResult
  11. {
  12. public FqlExecuteResult(string responseXml, Type resultType, Type tableRowType, QueryOptions options)
  13. {
  14. ResponseXml = responseXml;
  15. TableRowType = tableRowType;
  16. ResultType = resultType;
  17. QueryOptions = options;
  18. if (options.Select != null)
  19. {
  20. //Select = options.Select;
  21. TableRowType = (options.Select as LambdaExpression).Parameters[0].Type;
  22. }
  23. //var funcType = typeof(Func<>).MakeGenericType(tableRowType, resultType);
  24. //Activator.CreateInstance(typeof(Expression).MakeGenericType(funcType));
  25. //Expression<Func<tableRowType, resultType>> e =new Expression<Func<object,object>>(
  26. }
  27. QueryOptions QueryOptions;
  28. string ResponseXml;
  29. Type TableRowType;
  30. Type ResultType;
  31. #region IExecuteResult Members
  32. public object GetParameterValue(int parameterIndex)
  33. {
  34. throw new NotImplementedException();
  35. }
  36. public object ReturnValue
  37. {
  38. get
  39. {
  40. if (QueryOptions.IsCount)
  41. {
  42. var Reader = new FacebookDataReader(ResponseXml);
  43. return Reader.Count;
  44. }
  45. return Activator.CreateInstance(typeof(FqlQueryResultEnumerable<,>).MakeGenericType(TableRowType, ResultType), ResponseXml, QueryOptions.Select);
  46. }
  47. }
  48. #endregion
  49. #region IDisposable Members
  50. public void Dispose()
  51. {
  52. }
  53. #endregion
  54. }
  55. class QueryOptions
  56. {
  57. public Expression Select;
  58. //public bool IsScalar;
  59. public bool IsCount;
  60. }
  61. }