Ejemplo n.º 1
0
        static void Main()
        {
            Type obj = Type.GetType(ConfigurationManager.AppSettings["UserRepository"]);

            System.Reflection.ConstructorInfo constructor = obj.GetConstructor(new Type[] { });
            IUserDAO userRepository = (IUserDAO)constructor.Invoke(null);

            UserService userService = new UserService(userRepository);

            obj         = Type.GetType(ConfigurationManager.AppSettings["ServiciuRepository"]);
            constructor = obj.GetConstructor(new Type[] { });
            IServiciuDAO serviciuRepository = (IServiciuDAO)constructor.Invoke(null);

            ServiciuService serviciuServer = new ServiciuService(serviciuRepository);

            obj         = Type.GetType(ConfigurationManager.AppSettings["ProgramareServiciuRepository"]);
            constructor = obj.GetConstructor(new Type[] { });
            IProgramareServiciuDAO programareServiciuRepository = (IProgramareServiciuDAO)constructor.Invoke(null);


            obj         = Type.GetType(ConfigurationManager.AppSettings["ProgramareRepository"]);
            constructor = obj.GetConstructor(new Type[] { });
            IProgramareDAO programareRepository = (IProgramareDAO)constructor.Invoke(null);

            ProgramareService programareService = new ProgramareService(programareRepository, serviciuRepository, programareServiciuRepository);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginForm(userService, serviciuServer, programareService));
        }
Ejemplo n.º 2
0
        private SchedulerClient GetSchedulerClient(string strProcess, ScheduleHistoryItem objScheduleHistoryItem)
        {
            try
            {
                // ''''''''''''''''''''''''''''''''''''''''''''''''''
                // This is a method to encapsulate returning
                // an object whose class inherits SchedulerClient.
                // ''''''''''''''''''''''''''''''''''''''''''''''''''

                // Return value
                SchedulerClient objRetClient = null;
                // The constructor we've found
                System.Reflection.ConstructorInfo objConstructor = null;

                // The type we need
                Type t = Type.GetType(strProcess, true);

                // ''''''''''''''''''''''''''''''''''''''''''''''''''
                // Get the default constructor for the class
                // ''''''''''''''''''''''''''''''''''''''''''''''''''
                objConstructor = t.GetConstructor(System.Type.EmptyTypes);
                if (null != objConstructor)
                {
                    // Found the default constructor
                    objRetClient = (SchedulerClient)objConstructor.Invoke(null);
                }
                else
                {
                    // ''''''''''''''''''''''''''''''''''''''''''''''''''
                    // Get the parameterised constructor for the class
                    // ''''''''''''''''''''''''''''''''''''''''''''''''''

                    // Parameters we pass to the constructor
                    ScheduleHistoryItem[] param = new ScheduleHistoryItem[1];
                    param[0] = objScheduleHistoryItem;
                    // Parameter types we pass to the constructor
                    Type[] types = new Type[1];
                    types[0] = typeof(ScheduleHistoryItem);
                    // Get the parameterised contructor
                    objConstructor = t.GetConstructor(types);
                    // Call the constructor
                    objRetClient = (SchedulerClient)objConstructor.Invoke(param);
                }

                // ''''''''''''''''''''''''''''''''''''''''''''''''''
                // Return an instance of the class as an object
                // ''''''''''''''''''''''''''''''''''''''''''''''''''
                return(objRetClient);
            }
            catch (Exception exc)
            {
                //Exceptions.ProcessSchedulerException(exc);
                throw exc;
            }
            return(null);
        }
Ejemplo n.º 3
0
 /// <summary> Create a channel with the given capacity and
 /// semaphore implementations instantiated from the supplied class
 /// </summary>
 public SemaphoreControlledChannel(int capacity, System.Type semaphoreClass)
 {
     if (capacity <= 0)
     {
         throw new System.ArgumentException();
     }
     capacity_ = capacity;
     System.Type[] longarg = new System.Type[] { System.Type.GetType("System.Int64") };
     System.Reflection.ConstructorInfo ctor = semaphoreClass.GetConstructor(System.Reflection.BindingFlags.DeclaredOnly, null, longarg, null);
     object [] cap = new object [] { (System.Int64)capacity };
     putGuard_ = (Semaphore)(ctor.Invoke(cap));
     object [] zero = new object [] { (System.Int64) 0 };
     takeGuard_ = (Semaphore)(ctor.Invoke(zero));
 }
Ejemplo n.º 4
0
        public List <IMigration> GetAllMigrations(string connectionString)
        {
            CollectibleAssemblyLoadContext context = new CollectibleAssemblyLoadContext(_pluginConfiguration.Name);
            string assemblyPath = Path.Combine(_tempFolderName, $"{_pluginConfiguration.Name}.dll");

            using (FileStream fs = new FileStream(assemblyPath, FileMode.Open, FileAccess.Read))
            {
                System.Reflection.Assembly assembly       = context.LoadFromStream(fs);
                IEnumerable <Type>         migrationTypes = assembly.ExportedTypes.Where(p => p.GetInterfaces().Contains(typeof(IMigration)));

                List <IMigration> migrations = new List <IMigration>();
                foreach (Type migrationType in migrationTypes)
                {
                    System.Reflection.ConstructorInfo constructor = migrationType.GetConstructors().First(p => p.GetParameters().Count() == 1 && p.GetParameters()[0].ParameterType == typeof(IDbHelper));

                    migrations.Add((IMigration)constructor.Invoke(new object[] { _dbHelper }));
                }

                context.Unload();

                GC.Collect();
                GC.WaitForPendingFinalizers();

                return(migrations.OrderBy(p => p.Version).ToList());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Создает произвольный диалог для класса из доменной модели приложения.
        /// </summary>
        /// <returns>Виджет с интерфейсом ITdiDialog</returns>
        /// <param name="objectClass">Класс объекта для которого нужно создать диалог.</param>
        /// <param name="parameters">Параметры конструктора диалога.</param>
        public static ITdiDialog CreateObjectDialog(System.Type objectClass, params object[] parameters)
        {
            System.Type dlgType = GetDialogType(objectClass);
            if (dlgType == null)
            {
                InvalidOperationException ex = new InvalidOperationException(
                    String.Format("Для класса {0} нет привязанного диалога.", objectClass));
                logger.Error(ex);
                throw ex;
            }
            Type[] paramTypes = new Type[parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                paramTypes[i] = parameters[i].GetType();
            }

            System.Reflection.ConstructorInfo ci = dlgType.GetConstructor(paramTypes);
            if (ci == null)
            {
                InvalidOperationException ex = new InvalidOperationException(
                    String.Format("Конструктор для диалога {0} с параметрами({1}) не найден.", dlgType.ToString(), NHibernate.Util.CollectionPrinter.ToString(paramTypes)));
                logger.Error(ex);
                throw ex;
            }
            logger.Debug("Вызываем конструктор диалога {0} c параметрами {1}.", dlgType.ToString(), NHibernate.Util.CollectionPrinter.ToString(paramTypes));
            return((ITdiDialog)ci.Invoke(parameters));
        }
Ejemplo n.º 6
0
        private object InstantiatePlugin(Hashtable plugins, String type)
        {
            Type pluginType = (Type)plugins[type];

            System.Reflection.ConstructorInfo info = pluginType.GetConstructor(new Type[] {});
            return(info.Invoke(new object[] {}));
        }
Ejemplo n.º 7
0
        public static tydisasm GetDisassembler(string arch)
        {
            System.Type[] types = typeof(tydisasm).Assembly.GetTypes();
            System.Type   t     = null;
            foreach (System.Type test in types)
            {
                if (test.Name == (arch + "_disasm"))
                {
                    t = test;
                    break;
                }
            }

            if (t == null)
            {
                return(null);
            }
            System.Reflection.ConstructorInfo ctor = t.GetConstructor(System.Type.EmptyTypes);
            if (ctor == null)
            {
                return(null);
            }
            tydisasm ret = ctor.Invoke(null) as tydisasm;

            return(ret);
        }
Ejemplo n.º 8
0
        public CciInterface(string pefilename)
        {
            object dh = ctor_DefaultHost.Invoke(new object[] { });

            pdb     = ctor_PdbReader_Stream_IMetadataHost.Invoke(new object[] { new FileStream(Path.ChangeExtension(pefilename, "pdb"), FileMode.Open), dh });
            tok_dev = meth_MetadataReaderHost_LoadUnitFrom_string.Invoke(dh, new object[] { pefilename });
        }
Ejemplo n.º 9
0
            /// <summary>
            /// 获取实现 IHtmlContext 接口的 GetContext 方法的内容。
            /// </summary>
            /// <param name="typeName">类型名称</param>
            /// <param name="parameter">参数</param>
            /// <param name="callback">HTML 页面中回调方法的名称</param>
            public void GetHtmlContext(string typeName, string parameter, string callback)
            {
                Type typ = Function.GetType(typeName);

                if (typ != null)
                {
                    try
                    {
                        System.Reflection.ConstructorInfo ciObject = typ.GetConstructor(new System.Type[] { });
                        object obj = ciObject.Invoke(new object[] { });

                        IHtmlContext _IHtmlContext = obj as IHtmlContext;
                        if (_IHtmlContext is IUseAccount)
                        {
                            IUseAccount _IUseAccount = _IHtmlContext as IUseAccount;
                            _IUseAccount.SetAccount(this.PluginView.Application.CurrentAccount);
                        }
                        this.PluginView.SetHtmlContext(callback, true, _IHtmlContext.GetContext(this.PluginView.Application, parameter));
                    }
                    catch (Exception ex)
                    {
                        this.PluginView.SetHtmlContext(callback, false, ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("无法加载名称为“" + typeName + "”的类型", "获取内容", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
Ejemplo n.º 10
0
 public object GetInstance(InstanceContext instanceContext)
 {
     System.Reflection.ConstructorInfo cinfo = syncServiceType.GetConstructor(new Type[] { typeof(String), typeof(System.Net.NetworkCredential) });
     if (cinfo == null)
     {
         throw new Exception(String.Format("Type {0} does not implement String parameter constructor", syncServiceType.ToString()));
     }
     else
     {
         try
         {
             return(cinfo.Invoke(new object[] { name, GetCredentials() }));
         }
         catch (Exception e)
         {
             if (e.InnerException is UnauthorizedAccessException)
             {
                 WebOperationContext.Current.OutgoingResponse.StatusCode        = HttpStatusCode.Unauthorized;
                 WebOperationContext.Current.OutgoingResponse.StatusDescription = e.InnerException.Message;
                 return(null);
                 //throw new System.Web.HttpException(401, e.Message);
             }
             throw e;
         }
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Call method of given class using provided arguments.
        /// </summary>
        /// <param name="class_name">Class name</param>
        /// <param name="args0">Constructor args</param>
        /// <param name="method_name">Method name</param>
        /// <param name="args">List of arguments</param>
        /// <returns>Result of method execution</returns>
        public static Object CallMethod(String class_name, TArrayList args0, String method_name, TArrayList args)
        {
            Type type = Type.GetType(class_name.Replace('/', '.'));

            Type[] types0 = GetTypes(args0);
            System.Reflection.ConstructorInfo constructorInfo = type.GetConstructor(types0);
            Object doObject = constructorInfo.Invoke(args0.ToArray());

            Type[] types = GetTypes(args);
            System.Reflection.MethodInfo methodInfo = type.GetMethod(method_name, types);
            if (methodInfo != null)
            {
                if (args != null && args.Size() > 0)
                {
                    return(methodInfo.Invoke(doObject, args.ToArray()));
                }
                else
                {
                    return(methodInfo.Invoke(doObject, null));
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a version-specific MSH object and returns it as a version-independent MSH interface.
        /// throws HL7Exception if there is a problem, e.g. invalid version, code not available for given
        /// version.
        /// </summary>
        ///
        /// <exception cref="HL7Exception"> Thrown when a HL 7 error condition occurs. </exception>
        ///
        /// <param name="version">  . </param>
        /// <param name="factory">  The factory. </param>
        ///
        /// <returns>   An ISegment. </returns>

        public static ISegment MakeControlMSH(System.String version, IModelClassFactory factory)
        {
            ISegment msh = null;

            try
            {
                IMessage dummy =
                    (IMessage)
                    GenericMessage.getGenericMessageClass(version)
                    .GetConstructor(new[] { typeof(IModelClassFactory) })
                    .Invoke(new System.Object[] { factory });

                System.Type[]   constructorParamTypes = { typeof(IGroup), typeof(IModelClassFactory) };
                System.Object[] constructorParamArgs  = { dummy, factory };
                System.Type     c = factory.GetSegmentClass("MSH", version);
                System.Reflection.ConstructorInfo constructor = c.GetConstructor(constructorParamTypes);
                msh = (ISegment)constructor.Invoke(constructorParamArgs);
            }
            catch (System.Exception e)
            {
                throw new HL7Exception(
                          "Couldn't create MSH for version " + version + " (does your classpath include this version?) ... ",
                          HL7Exception.APPLICATION_INTERNAL_ERROR,
                          e);
            }
            return(msh);
        }
Ejemplo n.º 13
0
        //该任务的图标和照片。
        private IIcon GetImages(Type taskType)
        {
            if (taskType.GetCustomAttributes(typeof(TaskTypeAttribute), false).Length > 0)
            {
                TaskTypeAttribute attr = (TaskTypeAttribute)taskType.GetCustomAttributes(typeof(TaskTypeAttribute), false)[0];
                if (attr.ImageType != null && attr.ImageType.GetInterface(typeof(IIcon).FullName) != null)
                {
                    System.Reflection.ConstructorInfo ci = attr.ImageType.GetConstructor(new System.Type[] { });
                    object objInstance = ci.Invoke(new object[] { });

                    return(objInstance as IIcon);
                }
                else
                {
                    if (taskType.BaseType != typeof(Task) && taskType.BaseType.IsAbstract == false)
                    {
                        return(GetImages(taskType.BaseType));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 14
0
        private object Create(Type type)
        {
            if (implementations.ContainsKey(type))
            {
                return(implementations[type]);
            }

            var availableTypes = types[type];

            System.Reflection.ConstructorInfo defConstructor = availableTypes.GetConstructors()[0];
            System.Reflection.ParameterInfo[] defParams      = defConstructor.GetParameters();

            var parameters = defParams.Select(param => {
                if (implementations.ContainsKey(param.GetType()))
                {
                    return(implementations[param.GetType()]);
                }
                else
                {
                    return(Create(param.ParameterType));
                }
            }).ToArray();

            return(defConstructor.Invoke(parameters));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 创建当前设备类型的驱动对象,如该设备无驱动则返回 null。
        /// </summary>
        /// <returns></returns>
        internal IDrive CreateDrive()
        {
            System.Reflection.ConstructorInfo ci = this.DriveType.GetConstructor(new System.Type[] { });
            object objInstance = ci.Invoke(new object[] { });

            return(objInstance as IDrive);
        }
Ejemplo n.º 16
0
        public void RestoreSaveData(TaskSaveData_v1 data)
        {
            // Restore base task data
            symbol               = data.symbol;
            targetSymbol         = data.targetSymbol;
            IsTriggered          = data.triggered;
            prevTriggered        = data.prevTriggered;
            type                 = data.type;
            dropped              = data.dropped;
            globalVarName        = data.globalVarName;
            globalVarLink        = data.globalVarLink;
            hasTriggerConditions = data.hasTriggerConditions;

            // Restore actions
            actions.Clear();
            foreach (ActionTemplate.ActionSaveData_v1 actionData in data.actions)
            {
                // Construct deserialized QuestAction based on type
                System.Reflection.ConstructorInfo ctor = actionData.type.GetConstructor(new Type[] { typeof(Quest) });
                ActionTemplate action = (ActionTemplate)ctor.Invoke(new object[] { ParentQuest });

                // Restore state
                action.RestoreActionSaveData(actionData);
                actions.Add(action);
            }
        }
Ejemplo n.º 17
0
        public static LayerResource Create(Type type)
        {
            System.Reflection.ConstructorInfo ci = type.GetConstructor(new Type[] { });
            LayerResource res = (LayerResource)ci.Invoke(new object[] { });

            return(res);
        }
Ejemplo n.º 18
0
        private Object instancePlayerForTimeline(String timelineType)
        {
            try
            {
                String typeName = ns + timelineType + "Player";
                Type   t        = Type.GetType(typeName);
                if (t == null)
                {
                    return(null);
                }

                System.Reflection.ConstructorInfo ctor = t.GetConstructor(argTypes);
                if (ctor == null)
                {
                    return(null);
                }

                Object[] argValues = new Object[] { this.globe };
                return(ctor.Invoke(argValues));
            }
            catch (Exception e)
            {
                throw new TimelineException("Error constructing script player for "
                                            + timelineType + ".", e);
            }
        }
Ejemplo n.º 19
0
        public static ImpresorElemento InstanciarImpresor(Lbl.IElementoDeDatos elemento, IDbTransaction transaction)
        {
            Type tipo = InferirImpresor(elemento.GetType());

            System.Reflection.ConstructorInfo TConstr = tipo.GetConstructor(new Type[] { typeof(Lbl.ElementoDeDatos), typeof(IDbTransaction) });
            return((ImpresorElemento)(TConstr.Invoke(new object[] { elemento, transaction })));
        }
Ejemplo n.º 20
0
        private IList <FilesComparator> GetComparators(string sampleRoot, string resultsRoot, string samplePath, bool debug)
        {
            IList <FilesComparator> comparators = new List <FilesComparator>();

            foreach (var names in Names)
            {
                Paths path = new Paths(sampleRoot, resultsRoot, samplePath, names);
                if (System.IO.File.Exists(path.Result))
                {
                    Type type = names.GetComparatorType();
                    var  isEI = names.IsEI();
                    System.Reflection.ConstructorInfo constructor = type.GetConstructor(new[] { typeof(Paths), typeof(bool), typeof(bool) });
                    comparators.Add((FilesComparator)constructor?.Invoke(new object[] { path, debug, isEI }));
                }
            }
#if EUROINFO_RULES
            if (comparators.Any(c => c.IsEI))
            {
                //If any -EI result file exists => Remove all comparators without isEI flag to true.
                //We only want to check EI results files.
                foreach (var comparatorToRemove in comparators.Where(c => !(c.IsEI)).ToList())
                {
                    comparators.Remove(comparatorToRemove);
                }
            }
#endif
            return(comparators);
        }
Ejemplo n.º 21
0
        static internal bool Create()
        {
            if (Program.arch_name == null)
            {
                throw new Exception("architecture not selected");
            }

            try
            {
                Type archt = Type.GetType("tydb." + Program.arch_name + "_dbgarch", false, true);
                System.Reflection.ConstructorInfo ctorm = archt.GetConstructor(new Type[] { });
                if (ctorm == null)
                {
                    throw new TypeLoadException();
                }
                Program.arch = ctorm.Invoke(new object[] { }) as dbgarch;
            }
            catch (Exception e)
            {
                if (e is TypeLoadException)
                {
                    Console.WriteLine(Program.arch_name + " is not a valid debug architecture");
                    Console.WriteLine();
                    return(false);
                }
                throw;
            }

            if (Program.arch.Init(Program.feature_list.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)))
            {
                //Program.arch.ass.search_dirs = Program.lib_dirs;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 22
0
        void _dhcpv4Client_IpConfigChanged(object sender, uint ipAddress, uint gatewayAddress, uint subnetMask)
        {
            _ipv4configIPAddress      = ipAddress;
            _ipv4configSubnetMask     = subnetMask;
            _ipv4configGatewayAddress = gatewayAddress;

            _arpResolver.SetIpv4Address(_ipv4configIPAddress);

            /*** TODO: we should re-send our gratuitious (or probe) ARP every time that our IP address changes (via DHCP or otherwise), and also every time our network link goes up ***/
            /*** TODO: if our IP address changes, should we update the source IP address on all of our sockets?  Should we close any active connection-based sockets?  ***/

            Type networkChangeListenerType = Type.GetType("Microsoft.SPOT.Net.NetworkInformation.NetworkChange+NetworkChangeListener, Microsoft.SPOT.Net");

            if (networkChangeListenerType != null)
            {
                // create instance of NetworkChangeListener
                System.Reflection.ConstructorInfo networkChangeListenerConstructor = networkChangeListenerType.GetConstructor(new Type[] { });
                object networkChangeListener = networkChangeListenerConstructor.Invoke(new object[] { });

                // now call the ProcessEvent function to create a NetworkEvent class.
                System.Reflection.MethodInfo processEventMethodType = networkChangeListenerType.GetMethod("ProcessEvent");
                object networkEvent = processEventMethodType.Invoke(networkChangeListener, new object[] { (UInt32)(((UInt32)2 /* AddressChanged*/)), (UInt32)0, DateTime.Now }); /* TODO: should this be DateTime.Now or DateTime.UtcNow? */

                // and finally call the static NetworkChange.OnNetworkChangeCallback function to raise the event.
                Type networkChangeType = Type.GetType("Microsoft.SPOT.Net.NetworkInformation.NetworkChange, Microsoft.SPOT.Net");
                if (networkChangeType != null)
                {
                    System.Reflection.MethodInfo onNetworkChangeCallbackMethod = networkChangeType.GetMethod("OnNetworkChangeCallback", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
                    onNetworkChangeCallbackMethod.Invoke(networkChangeType, new object[] { networkEvent });
                }
            }
        }
Ejemplo n.º 23
0
        private static object CoerceObject(object value, Type to)
        {
            if (value == null)
            {
                return(null);
            }

            var result = value;

            if (typeof(Select).IsAssignableFrom(to))
            {
                var ctorChain = new List <System.Reflection.ConstructorInfo>();
                System.Reflection.ConstructorInfo ctor = null;
                if (STEPListener.TypeHasConstructorForSelectChoice(to, value.GetType(), out ctor, ref ctorChain))
                {
                    result = ctor.Invoke(new object[] { value });
                    if (ctorChain.Any())
                    {
                        // Construct the necessary wrappers working
                        // backwards. For the first constructor, the parameter
                        // will be the constructed instance.
                        for (var y = ctorChain.Count - 1; y >= 0; y--)
                        {
                            result = ctorChain[y].Invoke(new object[] { result });
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 24
0
        BaseTest InitCurrentTest(TestInfo testInfo, Type[] types, object[] args)
        {
            // find constructor.
            Type t = testInfo.Method.DeclaringType;

            System.Reflection.ConstructorInfo ci =
                t.GetConstructor(
                    System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance,
                    null,
                    System.Reflection.CallingConventions.HasThis,
                    types,
                    null);

            // Create object
            object   itObject = ci.Invoke(args);
            BaseTest test     = (BaseTest)itObject;

            _currentTest = test;

            // subscribe to test events.
            SubscribeToTestEvents(test);

            if (testInfo.ProcessType == ProcessType.FeatureDefinition)
            {
                FeaturesDefinitionProcess fdp = (FeaturesDefinitionProcess)test;
                fdp.FeatureDefined            += new Action <Feature, bool>(fdp_FeatureDefined);
                fdp.FeatureDefinitionFailed   += new Action <Feature>(fdp_FeatureDefinitionFailed);
                fdp.ScopeDefined              += new Action <string>(fdp_ScopeDefined);
                fdp.DeviceInformationReceived += new Action <DeviceInformation>(fdp_DeviceInformationReceived);
            }

            _currentTest.EntryPoint = testInfo.Method;
            return(test);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known)
        /// </summary>
        /// <param name="cid">Chunk Id</param>
        /// <param name="info"></param>
        /// <returns></returns>
        internal static PngChunk FactoryFromId(String cid, ImageInfo info)
        {
            PngChunk chunk = null;

            if (factoryMap == null)
            {
                initFactory();
            }
            if (isKnown(cid))
            {
                Type t = factoryMap[cid];
                if (t == null)
                {
                    Console.Error.WriteLine("What?? " + cid);
                }
                System.Reflection.ConstructorInfo cons = t.GetConstructor(new Type[] { typeof(ImageInfo) });
                object o = cons.Invoke(new object[] { info });
                chunk = (PngChunk)o;
            }
            if (chunk == null)
            {
                chunk = new PngChunkUNKNOWN(cid, info);
            }

            return(chunk);
        }
Ejemplo n.º 26
0
        public MyFile OpenFile(string filePath, string fileExtension, TextRange doc)
        {
            MyFile file = new MyFile
            {
                Extension = fileExtension
            };
            Type TestType = Type.GetType("PaternExamNew." + fileExtension.ToUpper(), false, true);

            //если класс не найден
            if (TestType != null)
            {
                //получаем конструктор
                System.Reflection.ConstructorInfo ci = TestType.GetConstructor(new Type[] { });

                //вызываем конструтор
                object Obj = ci.Invoke(new object[] { });
                file.SetStrategy(Obj as IStrategy);
            }
            else
            {
                MessageBox.Show("Расширение не поддерживается");
            }
            file.Open(doc);
            Files.Add(file);
            CurrentFileId = Files.Count - 1;
            return(Files[CurrentFileId]);
        }
Ejemplo n.º 27
0
        public void RestoreSaveData(QuestSaveData_v1 data)
        {
            // Restore base state
            uid                  = data.uid;
            questComplete        = data.questComplete;
            questSuccess         = data.questSuccess;
            questName            = data.questName;
            displayName          = data.displayName;
            factionId            = data.factionId;
            questStartTime       = data.questStartTime;
            questTombstoned      = data.questTombstoned;
            questTombstoneTime   = data.questTombstoneTime;
            smallerDungeonsState = data.smallerDungeonsState;
            compiledByVersion    = data.compiledByVersion;

            // Restore active log messages
            activeLogMessages.Clear();
            foreach (LogEntry logEntry in data.activeLogMessages)
            {
                activeLogMessages.Add(logEntry.stepID, logEntry);
            }

            // Restore messages
            messages.Clear();
            foreach (Message.MessageSaveData_v1 messageData in data.messages)
            {
                Message message = new Message(this);
                message.RestoreSaveData(messageData);
                messages.Add(message.ID, message);
            }

            // Restore resources
            resources.Clear();
            foreach (QuestResource.ResourceSaveData_v1 resourceData in data.resources)
            {
                // Construct deserialized QuestResource based on type
                System.Reflection.ConstructorInfo ctor = resourceData.type.GetConstructor(new Type[] { typeof(Quest) });
                QuestResource resource = (QuestResource)ctor.Invoke(new object[] { this });

                // Restore state
                resource.RestoreResourceSaveData(resourceData);
                resources.Add(resource.Symbol.Name, resource);
            }

            // Restore questors
            questors.Clear();
            if (data.questors != null)
            {
                questors = data.questors;
            }

            // Restore tasks
            tasks.Clear();
            foreach (Task.TaskSaveData_v1 taskData in data.tasks)
            {
                Task task = new Task(this);
                task.RestoreSaveData(taskData);
                tasks.Add(task.Symbol.Name, task);
            }
        }
Ejemplo n.º 28
0
        public void addArc(string name, Type arcType, node fromNode, node toNode)
        {
            if (arcType == null)
            {
                addArc(name, fromNode, toNode);
            }
            else
            {
                Type[] types = new Type[3];
                types[0] = typeof(string);
                types[1] = typeof(node);
                types[2] = typeof(node);
                System.Reflection.ConstructorInfo arcConstructor = arcType.GetConstructor(types);

                object[] inputs = new object[3];
                inputs[0] = name;
                inputs[1] = fromNode;
                inputs[2] = toNode;
                arcs.Add((arc)arcConstructor.Invoke(inputs));

                if (fromNode != null)
                {
                    fromNode.arcs.Add(arcs[lastArc]);
                    fromNode.arcsFrom.Add(arcs[lastArc]);
                }
                if (toNode != null)
                {
                    toNode.arcs.Add(arcs[lastArc]);
                    toNode.arcsTo.Add(arcs[lastArc]);
                }
            }
        }
Ejemplo n.º 29
0
 /// <summary>User can override to do their own debugging
 /// </summary>
 protected internal virtual void  setupDebugging(TokenStream lexer, TokenBuffer tokenBuf)
 {
     setDebugMode(true);
     // default parser debug setup is ParseView
     try
     {
         try
         {
             System.Type.GetType("javax.swing.JButton");
         }
         catch (System.Exception)
         {
             System.Console.Error.WriteLine("Swing is required to use ParseView, but is not present in your CLASSPATH");
             System.Environment.Exit(1);
         }
         System.Type c = System.Type.GetType("antlr.parseview.ParseView");
         System.Reflection.ConstructorInfo constructor = c.GetConstructor(new System.Type[] { typeof(LLkDebuggingParser), typeof(TokenStream), typeof(TokenBuffer) });
         constructor.Invoke(new object[] { this, lexer, tokenBuf });
     }
     catch (System.Exception e)
     {
         System.Console.Error.WriteLine("Error initializing ParseView: " + e);
         System.Console.Error.WriteLine("Please report this to Scott Stanchfield, [email protected]");
         System.Environment.Exit(1);
     }
 }
Ejemplo n.º 30
0
        /// <summary> Note that the validation context of the resulting message is set to this parser's validation
        /// context.  The validation context is used within Primitive.setValue().
        ///
        /// </summary>
        /// <param name="name">name of the desired structure in the form XXX_YYY
        /// </param>
        /// <param name="version">HL7 version (e.g. "2.3")
        /// </param>
        /// <param name="isExplicit">true if the structure was specified explicitly in MSH-9-3, false if it
        /// was inferred from MSH-9-1 and MSH-9-2.  If false, a lookup may be performed to find
        /// an alternate structure corresponding to that message type and event.
        /// </param>
        /// <returns> a Message instance
        /// </returns>
        /// <throws>  HL7Exception if the version is not recognized or no appropriate class can be found or the Message  </throws>
        /// <summary>      class throws an exception on instantiation (e.g. if args are not as expected)
        /// </summary>
        protected internal virtual Message instantiateMessage(System.String theName, System.String theVersion, bool isExplicit)
        {
            Message result = null;

            try
            {
                System.Type messageClass = myFactory.getMessageClass(theName, theVersion, isExplicit);
                if (messageClass == null)
                {
                    //UPGRADE_NOTE: Exception 'java.lang.ClassNotFoundException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                    throw new System.Exception("Can't find message class in current package list: " + theName);
                }
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                log.info("Instantiating msg of class " + messageClass.FullName);
                System.Reflection.ConstructorInfo constructor = messageClass.GetConstructor(new System.Type[] { typeof(ModelClassFactory) });
                result = (Message)constructor.Invoke(new System.Object[] { myFactory });
            }
            catch (System.Exception e)
            {
                throw new HL7Exception("Couldn't create Message object of type " + theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
            }

            result.ValidationContext = myContext;

            return(result);
        }