当前位置: 首页>>代码示例>>C#>>正文


C# ModelType.GetType方法代码示例

本文整理汇总了C#中ModelType.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ModelType.GetType方法的具体用法?C# ModelType.GetType怎么用?C# ModelType.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelType的用法示例。


在下文中一共展示了ModelType.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAvailableAnalyzeOptions

        /// <summary>
        /// Retrieves available analyze options for specified research type and model type.
        /// </summary>
        /// <param name="rt">Research type.</param>
        /// <param name="mt">Model type.</param>
        /// <returns>Available analyze options.</returns>
        /// <note>Analyze option is available for research, if it is available 
        /// both for research type and model type.</note>
        public static AnalyzeOption GetAvailableAnalyzeOptions(ResearchType rt, ModelType mt)
        {
            ResearchTypeInfo[] rInfo = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false);
            Type researchType = Type.GetType(rInfo[0].Implementation, true);

            AvailableAnalyzeOption rAvailableOptions = ((AvailableAnalyzeOption[])researchType.GetCustomAttributes(typeof(AvailableAnalyzeOption), true))[0];

            ModelTypeInfo[] mInfo = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false);
            Type modelType = Type.GetType(mInfo[0].Implementation, true);

            AvailableAnalyzeOption mAvailableOptions = ((AvailableAnalyzeOption[])modelType.GetCustomAttributes(typeof(AvailableAnalyzeOption), true))[0];

            return rAvailableOptions.Options & mAvailableOptions.Options;
        }
开发者ID:kocharyan-ani,项目名称:random_networks_explorer,代码行数:22,代码来源:StatSessionManager.cs

示例2: GetRequiredGenerationParameters

        /// <summary>
        /// Returns list of generation parameters which are required for specified research.
        /// </summary>
        /// <param name="id">ID of research.</param>
        /// <returns>List of generation parameters.</returns>
        public static List<GenerationParameter> GetRequiredGenerationParameters(ResearchType rt,
            ModelType mt, GenerationType gt)
        {
            List<GenerationParameter> gp = new List<GenerationParameter>();

            if (rt == ResearchType.Collection ||
                rt == ResearchType.Structural)
                return gp;

            if (gt == GenerationType.Static)
            {
                gp.Add(GenerationParameter.AdjacencyMatrix);
                return gp;
            }

            ModelTypeInfo[] info = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false);
            Type t = Type.GetType(info[0].Implementation, true);

            RequiredGenerationParameter[] rRequiredGenerationParameters = (RequiredGenerationParameter[])t.GetCustomAttributes(typeof(RequiredGenerationParameter), true);
            for (int i = 0; i < rRequiredGenerationParameters.Length; ++i)
            {
                GenerationParameter g = rRequiredGenerationParameters[i].Parameter;
                if (g != GenerationParameter.AdjacencyMatrix)
                    gp.Add(g);
            }

            return gp;
        }
开发者ID:kocharyan-ani,项目名称:random_networks_explorer,代码行数:33,代码来源:SessionManager.cs

示例3: CreateNetworkByType

 public static AbstractNetwork CreateNetworkByType(ModelType mt, String rName,
     GenerationType gType,
     Dictionary<ResearchParameter, object> rParams,
     Dictionary<GenerationParameter, object> genParams,
     AnalyzeOption AnalyzeOptions)
 {
     ModelTypeInfo[] info = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false);
     Type t = Type.GetType(info[0].Implementation);
     Type[] constructTypes = new Type[] {
             typeof(String),
             typeof(GenerationType),
             typeof(Dictionary<ResearchParameter, object>),
             typeof(Dictionary<GenerationParameter, object>),
             typeof(AnalyzeOption) };
     object[] invokeParams = new object[] {
             rName,
             gType,
             rParams,
             genParams,
             AnalyzeOptions };
     return (AbstractNetwork)t.GetConstructor(constructTypes).Invoke(invokeParams);
 }
开发者ID:kocharyan-ani,项目名称:random_networks_explorer,代码行数:22,代码来源:AbstractNetwork.cs


注:本文中的ModelType.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。