public override Type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr)
 {
     // According to the spec, we should only expect these 4, so we guard against that here!
     Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!");
     return(new Type[] { });
 }
 protected override System.Reflection.MethodInfo GetMethodImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers)
 {
     Debug.Assert(false, "NYI");
     throw new NotImplementedException();
 }
 // This method is called when in the source file we have something like:
 // - N.T.StaticProp
 // (most likely also when we have an instance prop...)
 // name -> "StaticProp"
 protected override System.Reflection.PropertyInfo GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type returnType, Type[] types, System.Reflection.ParameterModifier[] modifiers)
 {
     // According to the spec, we should only expect these 4, so we guard against that here!
     Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!");
     Debug.Assert(binder == null && returnType == null && types == null && modifiers == null, "One of binder, returnType, types, or modifiers was not null");
     if (name == _Property1.Name)
     {
         return(_Property1);
     }
     else
     {
         return(null);
     }
 }
 // Events...
 public override System.Reflection.EventInfo[] GetEvents(System.Reflection.BindingFlags bindingAttr)
 {
     return(_Event1 != null ? new [] { _Event1 } : new System.Reflection.EventInfo[] { });
 }
Exemple #5
0
 protected override System.Reflection.ConstructorInfo GetConstructorImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
 public override System.Reflection.EventInfo[] GetEvents(System.Reflection.BindingFlags bindingAttr)
 {
     throw new NotImplementedException();
 }
 public static System.Reflection.MethodInfo[] GetMethods(System.Type type, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
Exemple #8
0
 public override System.Reflection.PropertyInfo[] GetProperties(System.Reflection.BindingFlags bindingAttr)
 {
     throw new NotImplementedException();
 }
 public static System.Reflection.FieldInfo GetField(System.Type type, string name, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
 public static System.Reflection.MemberInfo[] GetMember(System.Type type, string name, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
 public static System.Reflection.EventInfo[] GetEvents(System.Type type, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
 public static System.Reflection.EventInfo GetEvent(System.Type type, string name, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
 public static System.Reflection.ConstructorInfo[] GetConstructors(System.Type type, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
Exemple #14
0
 // TODO: replace binding flags by bool flags
 public MethodInfo(string name, Type declaringType, BindingFlags bindingFlags, Type[] genericArguments, Type[] parameterTypes)
     : base(name, declaringType, bindingFlags, genericArguments, parameterTypes, TypeInfo.CreateReferenceTracker<Type>())
 {
 }
 public static System.Type GetNestedType(System.Type type, string name, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
 System.Reflection.MethodInfo IReflect.GetMethod(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type[] types, System.Reflection.ParameterModifier[] modifiers)
 {
     return(typeIReflectImplementation.GetMethod(name, bindingAttr, binder, types, modifiers));
 }
 public static System.Type[] GetNestedTypes(System.Type type, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
Exemple #18
0
 protected override System.Reflection.PropertyInfo GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type returnType, Type[] types, System.Reflection.ParameterModifier[] modifiers)
 {
     throw new NotImplementedException();
 }
 public static System.Reflection.PropertyInfo[] GetProperties(System.Type type, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
Exemple #20
0
 public override System.Reflection.ConstructorInfo[] GetConstructors(System.Reflection.BindingFlags bindingAttr)
 {
     throw new NotImplementedException();
 }
 public static System.Reflection.PropertyInfo GetProperty(System.Type type, string name, System.Reflection.BindingFlags bindingAttr)
 {
     throw null;
 }
 /// <summary>
 /// 获取私有成员的值
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="instance"></param>
 /// <param name="fieldname"></param>
 /// <returns></returns>
 protected static T GetBaseTypePrivateField <T>(object instance, string fieldname)
 {
     System.Reflection.BindingFlags flag = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic; Type type = instance.GetType().BaseType; System.Reflection.FieldInfo field = type.GetField(fieldname, flag); return((T)field.GetValue(instance));
 }
Exemple #23
0
        private static Ref.MemberInfo ResolveMember(object obj, string memberName, bool callableOnly)
        {
            Type type = obj.GetType();
            const Ref.BindingFlags flags = Ref.BindingFlags.Instance | Ref.BindingFlags.Static | Ref.BindingFlags.Public | Ref.BindingFlags.NonPublic |
                                           Ref.BindingFlags.DeclaredOnly;

            // case-sensitive:
            Type currentType = type;

            while (currentType != null)
            {
                if (!callableOnly)
                {
                    var field = currentType.GetField(memberName, flags);
                    if (field != null)
                    {
                        return(field);
                    }

                    var property = currentType.GetProperty(memberName, flags, null, null, Type.EmptyTypes, null);
                    if (property != null)
                    {
                        var getter = property.GetGetMethod(nonPublic: true);
                        if (getter != null)
                        {
                            return(getter);
                        }
                    }
                }

                var method = currentType.GetMethod(memberName, flags, null, Type.EmptyTypes, null);
                if (method != null)
                {
                    return(method);
                }

                currentType = currentType.BaseType;
            }

            // case-insensitive:
            currentType = type;
            while (currentType != null)
            {
                IEnumerable <Ref.MemberInfo> members;
                if (callableOnly)
                {
                    members = type.GetMethods(flags);
                }
                else
                {
                    members = ((IEnumerable <Ref.MemberInfo>)type.GetFields(flags)).Concat(type.GetProperties(flags));
                }

                Ref.MemberInfo candidate = null;
                foreach (var member in members)
                {
                    if (StringComparer.OrdinalIgnoreCase.Equals(memberName, member.Name))
                    {
                        if (candidate == null)
                        {
                            switch (member.MemberType)
                            {
                            case Ref.MemberTypes.Field:
                                candidate = member;
                                break;

                            case Ref.MemberTypes.Method:
                                if (((Ref.MethodInfo)member).GetParameters().Length == 0)
                                {
                                    candidate = member;
                                }

                                break;

                            case Ref.MemberTypes.Property:
                                var getter = ((Ref.PropertyInfo)member).GetGetMethod(nonPublic: true);
                                if (getter != null && getter.GetParameters().Length == 0)
                                {
                                    candidate = member;
                                }
                                break;

                            default:
                                throw Contract.Unreachable;
                            }
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }

                if (candidate != null)
                {
                    return(candidate);
                }
                currentType = currentType.BaseType;
            }

            return(null);
        }
 // No fields...
 public override System.Reflection.FieldInfo GetField(string name, System.Reflection.BindingFlags bindingAttr)
 {
     // According to the spec, we should only expect these 4, so we guard against that here!
     Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!");
     return(null);
 }
        /// <summary>
        /// 获得模板字符串,从设置中的模板路径来读取模板文件.
        /// </summary>
        /// <param name="sitePath">站点目录</param>
        /// <param name="tempPath">模板目录</param>
        /// <param name="skinName">模板名</param>
        /// <param name="templateName">模板文件的文件名称</param>
        /// <param name="fromPage">源页面名称</param>
        /// <param name="inherit">该页面继承的类</param>
        /// <param name="buildPath">生成目录名</param>
        /// <param name="channelName">频道名称</param>
        /// <param name="nest">嵌套次数</param>
        /// <param name="name">插件目录</param>
        /// <returns>string值,如果失败则为"",成功则为模板内容的string</returns>
        private static string GetTemplate(string sitePath, string tempPath, string skinName, string templet, string fromPage, string inherit, string buildPath, string channelName, string pageSize, int nest, string name)
        {
            StringBuilder strReturn       = new StringBuilder(220000);                                                                //返回的字符
            string        templetFullPath = Utils.GetMapPath(string.Format("{0}{1}/{2}/{3}", sitePath, tempPath, skinName, templet)); //取得模板文件物理路径

            //超过5次嵌套退出
            if (nest < 1)
            {
                nest = 1;
            }
            else if (nest > 5)
            {
                return("");
            }

            //检查模板文件是否存在
            if (!File.Exists(templetFullPath))
            {
                return("");
            }

            //开始读写文件
            using (StreamReader objReader = new StreamReader(templetFullPath, Encoding.UTF8))
            {
                StringBuilder extNamespace = new StringBuilder(); //命名空间标签转换容器
                StringBuilder textOutput   = new StringBuilder(70000);
                textOutput.Append(objReader.ReadToEnd());
                objReader.Close();

                //开始查找替换标签
                string[] strlist = Utils.SplitString(textOutput.ToString(), "\r");
                for (int i = 0; i < strlist.Length; i++)
                {
                    if (strlist[i] == "")
                    {
                        continue;
                    }

                    strReturn.Append(strlist[i]);//不进行标签替换 直接发挥模板的内容
                }
                //如果是第一层则写入文件
                if (nest == 1)
                {
                    //定义页面常量
                    string channelStr       = string.Empty; //频道名称
                    string constStr         = string.Empty; //分页大小
                    string validate_channel = string.Empty; //验证频道列表数据
                    if (channelName != string.Empty)
                    {
                        channelStr = "\tconst string channel = \"" + channelName + "\";\r\n";
                    }
                    if (pageSize != string.Empty && Utils.StrToInt(pageSize, 0) > 0)
                    {
                        constStr = "\tconst int pagesize = " + pageSize + ";\r\n";
                    }
                    if (channelName != string.Empty)
                    {
                        //验证频道列表数据
                        validate_channel = "\tc.validate_channel_data(\"" + channelName + "\");\r\n";
                    }

                    //页面头部声明
                    string        template           = string.Empty;
                    StringBuilder sb                 = new StringBuilder();
                    string        inherit_controller = string.Empty;
                    string[]      strinherit         = inherit.Split('.');
                    if (strinherit.Length >= 4)
                    {
                        inherit_controller = inherit;
                        inherit            = string.Empty;
                        for (int i = 0; i < strinherit.Length; i++)
                        {
                            if (i <= 3)
                            {
                                inherit += strinherit[i] + ".";
                            }
                        }
                        inherit = inherit.TrimEnd('.');
                    }
                    else
                    {
                        inherit_controller = inherit + "." + name;
                    }
                    //..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props。
                    sb.Append(string.Format("<!--本页面代码由DTcms非官方Mvc版模板引擎生成于 {0} -->\r\n", DateTime.Now));
                    sb.Append(string.Format(
                                  "@using System.Collections.Generic;\r\n" +
                                  "@using System.Text;\r\n" +
                                  "@using System.Data;\r\n" +
                                  "@using DTcms.Common;\r\n" +
                                  "@using DTcms.Web.Mvc.UI.Controllers;{0}\r\n", extNamespace.ToString()));
                    sb.Append(string.Format(
                                  "@{{\r\n" +
                                  "\tDTcms.Model.channel_site site = ViewData[\"site\"] as DTcms.Model.channel_site;\r\n" +
                                  "\tDTcms.Model.siteconfig config = ViewData[\"config\"] as DTcms.Model.siteconfig;\r\n" +
                                  "\tDTcms.Model.userconfig uconfig = ViewData[\"uconfig\"] as DTcms.Model.userconfig;\r\n" +
                                  "\t{0}Controller c = ViewData[\"controller\"] as {0}Controller;\r\n", inherit_controller));
                    Assembly assembly = Assembly.Load(inherit);
                    Type     type     = assembly.GetType(inherit_controller + "Controller", true);
                    if (type != null)
                    {
                        System.Reflection.BindingFlags flag   = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
                        System.Reflection.FieldInfo[]  fields = type.GetFields(flag);
                        foreach (System.Reflection.FieldInfo fi in fields)
                        {
                            if (fi.Name != "channel")
                            {
                                string _str = string.Format("\t{0} {1} = c.{1};\r\n", fi.FieldType.ToString(), fi.Name);
                                _str = _str.Replace("`1[", "<").Replace("]", "]");
                                sb.Append(_str);
                            }
                        }
                    }
                    sb.Append(string.Format("\tViewBag.Title = site.seo_title;\r\n" + "}}\r\n{2}", channelStr, constStr, strReturn.ToString()));
                    template = sb.ToString();

                    string pageDir    = Utils.GetMapPath(string.Format("{0}Areas/Web/Views/{1}/", sitePath, buildPath)); //生成文件的目录路径
                    string outputPath = pageDir + fromPage;                                                              //生成文件的物理路径

                    if (!Directory.Exists(pageDir))                                                                      //如果物理路径不存在则创建
                    {
                        Directory.CreateDirectory(pageDir);
                    }
                    //保存写入文件
                    File.WriteAllText(outputPath, template, Encoding.UTF8);
                }
            }

            return(strReturn.ToString());
        }
 // No nested type
 // This method is invoked on the type 'T', e.g.:
 //    let _ = N.T.M
 // to figure out if M is a nested type.
 public override Type GetNestedType(string name, System.Reflection.BindingFlags bindingAttr)
 {
     return(null);
 }
 public static System.Object[] Internal_GetAllMethodsWithAttribute(System.Type attrType, System.Reflection.BindingFlags staticness)
 {
     if (__Internal_GetAllMethodsWithAttribute_0_2 == null)
     {
         __Internal_GetAllMethodsWithAttribute_0_2 = (Func <System.Type, System.Reflection.BindingFlags, System.Object[]>)Delegate.CreateDelegate(typeof(Func <System.Type, System.Reflection.BindingFlags, System.Object[]>), null, UnityTypes.UnityEditor_EditorAssemblies.GetMethod("Internal_GetAllMethodsWithAttribute", R.StaticMembers, null, new Type[] { typeof(System.Type), typeof(System.Reflection.BindingFlags) }, null));
     }
     return(__Internal_GetAllMethodsWithAttribute_0_2(attrType, staticness));
 }
 public override System.Reflection.MemberInfo[] GetMembers(System.Reflection.BindingFlags bindingAttr)
 {
     Debug.Assert(false, "NYI");
     throw new NotImplementedException();
 }
Exemple #29
0
 public override System.Reflection.FieldInfo GetField(string name, System.Reflection.BindingFlags bindingAttr)
 {
     throw new NotImplementedException();
 }
 public override object InvokeMember(string name, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object target, object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] namedParameters)
 {
     Debug.Assert(false, "NYI");
     throw new NotImplementedException();
 }
Exemple #31
0
 public override Type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr)
 {
     throw new NotImplementedException();
 }
Exemple #32
0
 public MethodInfo(string name, TypeInfo declaringType, BindingFlags bindingFlags, IEnumerable<TypeInfo> genericArguments, IEnumerable<TypeInfo> parameterTypes)
     : base(name, declaringType, bindingFlags, genericArguments, parameterTypes)
 {
 }
 /// <summary>
 /// Creates a new instance of the reflection table that will map members of a particular object.
 /// </summary>
 /// <param name="ReflectionObject">The object that is being reflected.</param>
 /// <param name="bindingFlags">The specific binding flag attributes of the reflection table.</param>
 public MemberTable(object ReflectionObject, System.Reflection.BindingFlags bindingFlags)
 {
     _type = ReflectionObject.GetType();
     _bindflags = bindingFlags;
 }