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


C# IModule.GetType方法代码示例

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


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

示例1: RegisterModule

        public static void RegisterModule(IModule module)
        {
            var config = new ModuleConfiguration();
            module.Configure(config);
            ModuleConfigurations[module.GetType()] = config;

            RoutesConfig.AddRoute(config.ModuleHttpRoute, module.GetType());
        }
开发者ID:cbvoxel,项目名称:cncengine,代码行数:8,代码来源:ModulesConfig.cs

示例2: C2V

 internal static VModule C2V(IModule contract)
 {
     if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) &&
         (contract.GetType().Equals(typeof(ModuleV2C))))
     {
         return ((ModuleV2C)(contract)).GetSourceView();
     }
     else
     {
         return new ModuleC2V(contract);
     }
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:12,代码来源:AModule.cs

示例3: LoadModule

        public void LoadModule(IModule module)
        {
            if (module == null)
                throw new ArgumentNullException ("module");

            var info = new ModuleInformation (module);

            if (this.modules [info.Level].Contains (module, ModulesNameEqualityComparer.Instance))
                throw new ModuleAlreadyLoadedException (module.GetType ().FullName);

            // todo
        }
开发者ID:victorsamun,项目名称:NSimulator,代码行数:12,代码来源:ModuleDispatcher.cs

示例4: InstallNetworkingModules

 private bool InstallNetworkingModules(IModule module, IModelSystemStructure ps, ref string error)
 {
     var moduleType = module.GetType();
     var clientType = typeof(IClient);
     var hostType = typeof(IHost);
     foreach (var field in moduleType.GetFields())
     {
         if (field.IsPublic)
         {
             if (field.FieldType == clientType)
             {
                 IClient networkingClient = Configuration.RetriveCurrentNetworkingClient();
                 if (networkingClient != null)
                 {
                     field.SetValue(module, networkingClient);
                 }
             }
             else if (field.FieldType == hostType)
             {
                 IHost networkingHost;
                 if (!Configuration.StartupNetworkingHost(out networkingHost, ref error))
                 {
                     return false;
                 }
                 field.SetValue(module, networkingHost);
             }
         }
     }
     foreach (var field in moduleType.GetProperties())
     {
         if (field.CanRead && field.CanWrite)
         {
             if (field.PropertyType == clientType)
             {
                 IClient networkingClient;
                 if (!Configuration.StartupNetworkingClient(out networkingClient, ref error))
                 {
                     return false;
                 }
                 field.SetValue(module, networkingClient, null);
             }
             else if (field.PropertyType == hostType)
             {
                 IHost networkingHost;
                 if (!Configuration.StartupNetworkingHost(out networkingHost, ref error))
                 {
                     return false;
                 }
                 field.SetValue(module, networkingHost, null);
             }
         }
     }
     return true;
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:54,代码来源:Project.cs

示例5: RegisterAutofacModule

 public static void RegisterAutofacModule(this ContainerBuilder containerBuilder,IModule module)
 {
     log.Info("Registering autofac module: {0}",module.GetType().Name.Replace("Module",string.Empty));
     containerBuilder.RegisterModule(module);
 }
开发者ID:BernhardGlueck,项目名称:Phare,代码行数:5,代码来源:RegistrationExtensions.cs

示例6: IterateNodes

 private void IterateNodes(DependencyNode node, AttributeContext<DependsOnAttribute> context, IModule item, ref bool added)
 {
     if (node.Nodes.ContainsKey(context.AttributeInstance.DependencyType))
     {
         node.Nodes[context.AttributeInstance.DependencyType].Nodes.Add(item.GetType(), new DependencyNode(item));
         added = true;
     }
     else if (node.Nodes.Count == 0)
     {
         added = false;
     }
     else
     {
         foreach (var child in node.Nodes.Values)
         {
             IterateNodes(child, context, item, ref added);
         }
     }
 }
开发者ID:msusur,项目名称:Crowfx,代码行数:19,代码来源:BootStrapper.cs

示例7: WriteModule

        public static NBTag WriteModule( string tagName, IModule module )
        {
            NBTCompound root = new NBTCompound( tagName );
            IModuleFactory factory = GetFactoryByType( module.GetType() );
            root.Append( "ID", factory.ID );

            bool auto =
                !factory.ModuleType.GetCustomAttributes( typeof( DisableAutoSerializationAttribute ), true ).Any();
            if( auto ) {
                root.Append( WriteModuleProperties( module ) );
            }
            NBTag customSettings = new NBTCompound( "Settings" );
            module.WriteSettings( customSettings );
            root.Append( customSettings );
            return root;
        }
开发者ID:fragmer,项目名称:SuperImageEvolver,代码行数:16,代码来源:ModuleManager.cs

示例8: WriteModuleProperties

 public static NBTag WriteModuleProperties( IModule module )
 {
     IModuleFactory factory = GetFactoryByType( module.GetType() );
     NBTag root = new NBTCompound( "Properties" );
     foreach( PropertyInfo p in factory.ModuleType.GetProperties() ) {
         object val = p.GetValue( module, null );
         if( p.PropertyType == typeof( byte ) ) {
             root.Append( p.Name, (byte)val );
         } else if( p.PropertyType == typeof( short ) ) {
             root.Append( p.Name, (short)val );
         } else if( p.PropertyType == typeof( int ) ) {
             root.Append( p.Name, (int)val );
         } else if( p.PropertyType == typeof( long ) ) {
             root.Append( p.Name, (long)val );
         } else if( p.PropertyType == typeof( float ) ) {
             root.Append( p.Name, (float)val );
         } else if( p.PropertyType == typeof( double ) ) {
             root.Append( p.Name, (double)val );
         } else if( p.PropertyType == typeof( byte[] ) ) {
             root.Append( p.Name, (byte[])val );
         } else if( p.PropertyType == typeof( string ) ) {
             root.Append( p.Name, (string)val );
         } else if( p.PropertyType == typeof( bool ) ) {
             root.Append( p.Name, (bool)val );
         } else if( p.PropertyType == typeof( Color ) ) {
             root.Append( p.Name, (Color)val );
         } else if( p.PropertyType == typeof( Point ) ) {
             root.Append( p.Name, (Point)val );
         } else if( p.PropertyType == typeof( PointF ) ) {
             root.Append( p.Name, (PointF)val );
         } else {
             throw new NotSupportedException( "Unknown property type." );
         }
     }
     return root;
 }
开发者ID:fragmer,项目名称:SuperImageEvolver,代码行数:36,代码来源:ModuleManager.cs

示例9: AddModule

 /// <summary>
 /// Adds module to _module array while ensuring that only 1 instance of specific module exists at the time.
 /// </summary>
 /// <param name="newModule"></param>
 /// <returns>true if module has been added to list</returns>
 public bool AddModule(IModule newModule)
 {
     var ss = newModule.GetType();
     foreach (var module in _modules)
     {
         var ss2 = module.GetType();
         if (ss == ss2)
             return false;
     }
     _modules.Add(newModule);
     return true;
 }
开发者ID:ColdVolcano,项目名称:StreamCompanion,代码行数:17,代码来源:Initializer.cs

示例10: ReadModuleProperties

 public static void ReadModuleProperties( IModule module, NBTag tag )
 {
     IModuleFactory factory = GetFactoryByType( module.GetType() );
     foreach( PropertyInfo p in factory.ModuleType.GetProperties() ) {
         if( !tag.Contains( p.Name ) ) continue;
         if( p.PropertyType == typeof( byte ) ) {
             p.SetValue( module, tag.GetByte(), null );
         } else if( p.PropertyType == typeof( short ) ) {
             p.SetValue( module, tag.GetShort(), null );
         } else if( p.PropertyType == typeof( int ) ) {
             p.SetValue( module, tag.GetInt(), null );
         } else if( p.PropertyType == typeof( long ) ) {
             p.SetValue( module, tag.GetLong(), null );
         } else if( p.PropertyType == typeof( float ) ) {
             p.SetValue( module, tag.GetFloat(), null );
         } else if( p.PropertyType == typeof( double ) ) {
             p.SetValue( module, tag.GetDouble(), null );
         } else if( p.PropertyType == typeof( byte[] ) ) {
             p.SetValue( module, tag.GetBytes(), null );
         } else if( p.PropertyType == typeof( string ) ) {
             p.SetValue( module, tag.GetString(), null );
         } else if( p.PropertyType == typeof( bool ) ) {
             p.SetValue( module, tag.GetBool(), null );
         } else if( p.PropertyType == typeof( Color ) ) {
             p.SetValue( module, tag.GetColor(), null );
         } else if( p.PropertyType == typeof( Point ) ) {
             p.SetValue( module, tag.GetBool(), null );
         } else if( p.PropertyType == typeof( PointF ) ) {
             p.SetValue( module, tag.GetPointF(), null );
         } else {
             throw new NotSupportedException( "Unknown property type." );
         }
     }
 }
开发者ID:fragmer,项目名称:SuperImageEvolver,代码行数:34,代码来源:ModuleManager.cs

示例11: InitializeModule

 private static void InitializeModule(IModule module)
 {
     try
     {
         Log.Trace("Initializing module " + module.ModuleName);
         module.Init();
         Log.Trace("Module " + module.ModuleName + " is now running.");
         _runningModules.Add(module.ModuleName);
     }
     catch (Exception e)
     {
         EventController.TriggerEvent(new ErrorOccuredEvent(new ModuleInitializationFailure(e, module.GetType())));
         throw new ModuleInitializationFailure(e, module.GetType());
     }
 }
开发者ID:marquismark,项目名称:freeswitchconfig,代码行数:15,代码来源:ModuleController.cs

示例12: ToStringImpl

 internal static String ToStringImpl(IModule module)
 {
     return module.GetType().Name + "-" + module.Name;
 }
开发者ID:takeshik,项目名称:metatweet-old,代码行数:4,代码来源:Module.cs

示例13: AttachRootModelSystem

        private bool AttachRootModelSystem(IModelSystemStructure iModelSystem, IModule root, ref string error)
        {
            foreach (var field in root.GetType().GetFields())
            {
                if (field.IsPublic)
                {
                    var attributes = field.GetCustomAttributes(typeof(RootModule), true);
                    if (attributes == null || attributes.Length == 0) continue;
                    // make sure the root model system structure actually exists
                    if (iModelSystem == null)
                    {
                        error = string.Format("The type {0} used for the root in {1} has no module to use as an ancestor.  Please contact your model system provider!", field.FieldType.FullName, root.Name);
                        return false;
                    }
                    Type rootType = iModelSystem.Module.GetType();

                    if (!field.FieldType.IsAssignableFrom(rootType))
                    {
                        error = string.Format("The parent type of {0} is not assignable from the true root type of {1}!", field.FieldType.FullName, rootType.FullName);
                        return false;
                    }
                    field.SetValue(root, iModelSystem.Module);
                }
            }
            foreach (var field in root.GetType().GetProperties())
            {
                if (field.CanRead && field.CanWrite)
                {
                    var attributes = field.GetCustomAttributes(typeof(RootModule), true);
                    if (attributes == null || attributes.Length == 0) continue;
                    Type rootType = iModelSystem.Module.GetType();

                    if (!field.PropertyType.IsAssignableFrom(rootType))
                    {
                        error = string.Format("The parent type of {0} is not assignable from the true root type of {1}!", field.PropertyType.FullName, rootType.FullName);
                        return false;
                    }
                    field.SetValue(root, iModelSystem.Module, null);
                }
            }
            return true;
        }
开发者ID:dianatle,项目名称:XTMF,代码行数:42,代码来源:Project.cs

示例14: AttachParent

        private bool AttachParent(IModule parent, IModelSystemStructure child, ref string error)
        {
            foreach (var field in child.Type.GetFields())
            {
                if (field.IsPublic)
                {
                    var attributes = field.GetCustomAttributes(typeof(ParentModel), true);
                    if (attributes == null || attributes.Length == 0) continue;
                    Type parentType = parent.GetType();

                    if (!field.FieldType.IsAssignableFrom(parentType))
                    {
                        error = string.Format("The parent type of {0} is not assignable from the true parent type of {1}!", field.FieldType.FullName, parentType.FullName);
                        return false;
                    }
                    field.SetValue(child.Module, parent);
                }
            }
            foreach (var field in child.Type.GetProperties())
            {
                if (field.CanRead && field.CanWrite)
                {
                    var attributes = field.GetCustomAttributes(typeof(ParentModel), true);
                    if (attributes == null || attributes.Length == 0) continue;
                    Type parentType = parent.GetType();

                    if (!field.PropertyType.IsAssignableFrom(parentType))
                    {
                        error = string.Format("The parent type of {0} is not assignable from the true parent type of {1}!", field.PropertyType.FullName, parentType.FullName);
                        return false;
                    }
                    field.SetValue(child.Module, parent, null);
                }
            }
            return true;
        }
开发者ID:dianatle,项目名称:XTMF,代码行数:36,代码来源:Project.cs

示例15: AddCollection

        private bool AddCollection(IConfiguration config, IModule root, IModelSystemStructure rootMS, IModelSystemStructure child,
            FieldInfo infoField, PropertyInfo infoProperty, Type listOfInner, Type inner, ref string error)
        {
            object collectionValue = null;
            Type collectionType = null;

            if (infoField == null && infoProperty != null && !infoProperty.CanRead)
            {
                error = string.Format("Since the {0}.{1} property has no public getter we can not initialize its values. Please add one so that XTMF can load the model.",
                        root.GetType().FullName, infoProperty.Name);
                return false;
            }

            if (infoField != null)
            {
                collectionValue = infoField.GetValue(root);
                collectionType = infoField.FieldType;
            }
            else
            {
                collectionValue = infoProperty.GetValue(root, null);
                collectionType = infoProperty.PropertyType;
            }

            // check to make sure that it exists before trying to add new values to it.
            if (collectionValue == null)
            {
                if (infoField == null && infoProperty != null && !infoProperty.CanWrite)
                {
                    error = string.Format("Since the {0}.{1} property has no public setter we can not create a collection.  Please either add a public setter or initialize this property in your constructor.",
                        root.GetType().FullName, infoProperty.Name);
                    return false;
                }
                // Lets attempt to create it IF it doesn't already exist
                bool created = false;
                if (collectionType.IsClass && !collectionType.IsAbstract)
                {
                    if (collectionType.IsArray)
                    {
                        var collectionObject = Array.CreateInstance(collectionType.GetElementType(), child.Children == null ? 0 : child.Children.Count);
                        if (infoField != null)
                        {
                            infoField.SetValue(root, collectionObject);
                        }
                        else
                        {
                            infoProperty.SetValue(root, collectionObject, null);
                        }
                        created = true;
                    }
                    else
                    {
                        // if we know it is concrete, lets try to just make it with a default constructor
                        var defaultConstructor = collectionType.GetConstructor(new Type[] { });
                        if (defaultConstructor != null)
                        {
                            var collectionObject = defaultConstructor.Invoke(new object[] { });
                            if (infoField != null)
                            {
                                infoField.SetValue(root, collectionObject);
                            }
                            else
                            {
                                infoProperty.SetValue(root, collectionObject, null);
                            }
                            created = true;
                        }
                    }
                }
                else
                {
                    if (collectionType.IsAssignableFrom(listOfInner))
                    {
                        if (infoField != null)
                        {
                            infoField.SetValue(root, listOfInner.GetConstructor(new Type[] { }).Invoke(new object[] { }));
                        }
                        else
                        {
                            infoProperty.SetValue(root, listOfInner.GetConstructor(new Type[] { }).Invoke(new object[] { }), null);
                        }
                        created = true;
                    }
                }

                if (!created)
                {
                    if (infoField != null)
                    {
                        error = string.Format("We were unable to create any Collection object for {0}.{1}.  Please initialize this field in your constructor!", root.GetType().FullName,
                            infoField.Name);
                    }
                    else
                    {
                        error = string.Format("We were unable to create any Collection object for {0}.{1}.  Please initialize this field in your constructor!", root.GetType().FullName,
                        infoProperty.Name);
                    }
                    return false;
                }
            }
//.........这里部分代码省略.........
开发者ID:dianatle,项目名称:XTMF,代码行数:101,代码来源:Project.cs


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