Exemplo n.º 1
0
		public NetConstructor(Db4objects.Db4o.Reflect.IReflector reflector, System.Reflection.ConstructorInfo
			 constructor)
		{
			this.reflector = reflector;
			this.constructor = constructor;
			Db4objects.Db4o.Internal.Platform4.SetAccessible(constructor);
		}
		/// <summary>
		/// Create an <see cref="IEnumerable"/> wrapper over an <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to enumerate over.</param>
		/// <param name="cmd">The <see cref="IDbCommand"/> used to create the <see cref="IDataReader"/>.</param>
		/// <param name="sess">The <see cref="ISession"/> to use to load objects.</param>
		/// <param name="types">The <see cref="IType"/>s contained in the <see cref="IDataReader"/>.</param>
		/// <param name="columnNames">The names of the columns in the <see cref="IDataReader"/>.</param>
		/// <param name="selection">The <see cref="RowSelection"/> that should be applied to the <see cref="IDataReader"/>.</param>
		/// <param name="holderType">Optional type of the result holder (used for "select new SomeClass(...)" queries).</param>
		/// <remarks>
		/// The <see cref="IDataReader"/> should already be positioned on the first record in <see cref="RowSelection"/>.
		/// </remarks>
		public EnumerableImpl( IDataReader reader, IDbCommand cmd, ISessionImplementor sess, IType[ ] types, string[ ][ ] columnNames, RowSelection selection,
			System.Type holderType )
		{
			_reader = reader;
			_cmd = cmd;
			_sess = sess;
			_types = types;
			_names = columnNames;
			_selection = selection;

			if( holderType != null )
			{
				_holderConstructor = NHibernate.Util.ReflectHelper.GetConstructor(
					holderType, types );
			}

			_single = _types.Length == 1;
		}
        public void DisplayConstructorProperties(System.Reflection.ConstructorInfo constructorInfo)
        {
            ThisConstructor = constructorInfo;//store the constructor information

            Label2.Text = ThisConstructor.Name;//display constructor name
            //calling convention output to textbox
            Label4.Text = "0x" + ThisConstructor.CallingConvention.ToString("x") + " = " + ThisConstructor.CallingConvention.ToString();
            //standard attributes to textbox
            Label6.Text = "0x" + ThisConstructor.Attributes.ToString("x") + " = " + ThisConstructor.Attributes.ToString();
            //constructor parameters
            foreach (System.Reflection.ParameterInfo parm in ThisConstructor.GetParameters())
            {
                ListBox1.Items.Add(parm);
            }
            //display custom attributes
            foreach (object attr in ThisConstructor.GetCustomAttributes(true))
            {
                ListBox2.Items.Add(attr);
            }
        }
Exemplo n.º 4
0
 public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute)
 {
     throw new PlatformNotSupportedException();
 }
Exemplo n.º 5
0
 public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues)
 {
 }
Exemplo n.º 6
0
 public virtual void Emit(System.Reflection.Emit.OpCode opcode, System.Reflection.ConstructorInfo con)
 {
 }
Exemplo n.º 7
0
 public NewExpression(System.Reflection.ConstructorInfo constructor, IEnumerable <Expression> arguments = null, IEnumerable <System.Reflection.MemberInfo> members = null)
     : this(new ConstructorInfo(constructor), arguments, ReferenceEquals(null, members) ? null : members.Select(x => MemberInfo.Create(x)))
 {
 }
Exemplo n.º 8
0
		/// <summary>
		/// 加载程序集信息
		/// </summary>
		/// <returns></returns>
		public bool EnsureLoadAssembly()
		{
			if (constInfo != null) return true;

			System.Type tp = null;
			State = ServiceState.NotInstalled;

			if (string.IsNullOrEmpty(Assembly))
			{
				try
				{
					tp = System.Type.GetType(TypeName);
				}
				catch (Exception) { return false; }
			}
			else
			{
				string file = LocateAssemblyPath(Assembly);
				if (file == null) return false;
				try
				{
					tp = System.Reflection.Assembly.LoadFile(file).GetType(TypeName);
				}
				catch (Exception) { return false; }
			}

			State = ServiceState.LoadingError;
			if (tp == null) return false;

			//获得插件的信息
			object[] infos = tp.GetCustomAttributes(typeof(ServiceAttribute), true);
			if (infos != null && infos.Length > 0)
			{
				this.ServiceDescription = (infos[0] as ServiceAttribute).Description;
			}
			else
			{
				this.ServiceDescription = new ServiceDescription("未知", "未知", tp.Name, "未知", tp.FullName);
			}

			if ((constInfo = tp.GetConstructor(System.Type.EmptyTypes)) == null) return false;

			State = ServiceState.TypeLoaded;
			return true;
		}
Exemplo n.º 9
0
 internal NewArrayExpression(Type type, ReadOnlyCollection<Expression> expressions)
     : base(AstNodeType.NewArrayExpression)
 {
     _type = type;
     _expressions = expressions;
     _constructor = _type.GetConstructor(new Type[] { typeof(int) });
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new object or a new instance of a value type, pushing an object reference (type O)
 /// onto the evaluation stack.
 /// </summary>
 /// <param name="il">The instance of <see cref="ILGenerator"/>.</param>
 /// <param name="constructorInfo">The constructor of the type.</param>
 /// <returns>The instance of <see cref="ILGenerator"/>.</returns>
 public static System.Reflection.Emit.ILGenerator Newobj(this System.Reflection.Emit.ILGenerator il, System.Reflection.ConstructorInfo constructorInfo)
 {
     il.Emit(System.Reflection.Emit.OpCodes.Newobj, constructorInfo);
     return(il);
 }
Exemplo n.º 11
0
        private dynamic ParseCollection(Type t, STEPParser.CollectionContext value)
        {
            // Ex: #25 = IFCDIRECTION((1., 0., 0.));
            // IfcDirection takes a List<double> as its input parameters, so we get the type argument - double - and
            // do the coercion for all the items.

            // Ex: #31 = IFCSITE('3BoQ8L5UXBEOT1kW0PLzej', #2, 'Default Site', 'Description of Default Site', $, #32, $, $, .ELEMENT., (24, 28, 0), (54, 25, 0), 10., $, $);
            // IfcSite takes two IfcCompoundPlaneMeasure objects. It seems that some IFC exporters will not specify a type's constructor, they'll just
            // specify the arguments as a collection.

            Type collectionType;

            System.Reflection.ConstructorInfo ctor = null;
            var ctorChain = new List <System.Reflection.ConstructorInfo>();

            if (t.IsGenericType)
            {
                collectionType = t.GetGenericArguments()[0];
            }
            else
            {
                ctor           = GetConstructorForType(t, ref ctorChain);
                collectionType = ctor.GetParameters()[0].ParameterType.GetGenericArguments()[0];
            }

            var result = new List <object>();

            foreach (var cv in value.collectionValue())
            {
                if (cv.Id() != null)
                {
                    result.Add(ParseId(cv.Id().GetText()));
                }
                else if (cv.AnyString() != null)
                {
                    result.Add(ParseString(collectionType, cv.AnyString().GetText()));
                }
                else if (cv.StringLiteral() != null)
                {
                    result.Add(ParseString(collectionType, cv.StringLiteral().GetText()));
                }
                else if (cv.IntegerLiteral() != null)
                {
                    result.Add(ParseInt(collectionType, cv.IntegerLiteral().GetText()));
                }
                else if (cv.RealLiteral() != null)
                {
                    result.Add(ParseReal(collectionType, cv.RealLiteral().GetText()));
                }
                else if (cv.constructor() != null)
                {
                    result.Add(ParseConstructor(currId, cv.constructor()));
                }
            }

            if (ctor != null)
            {
                return(new InstanceData(-1, t, new List <object>()
                {
                    result
                }, ctor, ctorChain));
            }

            return(result);
        }
Exemplo n.º 12
0
 public static System.Reflection.ConstructorInfo GetConstructor(System.Type type, System.Reflection.ConstructorInfo constructor)
 {
     return(default(System.Reflection.ConstructorInfo));
 }
 /// <summary>
 /// Calls a method on this variable
 /// </summary>
 /// <param name="Method">Method</param>
 /// <param name="Parameters">Parameters sent in</param>
 /// <returns>Variable returned by the function (if one exists, null otherwise)</returns>
 public virtual void Call(System.Reflection.ConstructorInfo Method, object[] Parameters = null)
 {
     Contract.Requires<ArgumentNullException>(Method!=null,"Method");
     MethodBase.CurrentMethod.Call(this, Method, Parameters);
 }
 public static Microsoft.Extensions.DiagnosticAdapter.Internal.ProxyTypeCacheResult FromType(System.Tuple <System.Type, System.Type> key, System.Type type, System.Reflection.ConstructorInfo constructor)
 {
     throw null;
 }
Exemplo n.º 15
0
 static public void Emit(this MethodBody body, OpCode instruction, ConstructorInfo constructor)
 {
     body.Add(Instruction.Create(instruction, body.Method.DeclaringType.Module.Import(constructor)));
 }
 public bool Is <T>() where T : class
 {
     System.Reflection.ConstructorInfo ctor = typeof(T).GetConstructors()[0];
     System.Type paramType = ctor.GetParameters()[0].ParameterType;
     return(paramType.IsInstanceOfType(this.WrappedObject));
 }
Exemplo n.º 17
0
 SqlMapper.IMemberMap SqlMapper.ITypeMap.GetConstructorParameter(System.Reflection.ConstructorInfo constructor, string columnName)
 {
     return(null);
 }
Exemplo n.º 18
0
            static SqlExceptionInstantiator()
            {
                constructor = typeof(System.Data.SqlClient.SqlException).GetConstructor
                (
                System.Reflection.BindingFlags.NonPublic |
                System.Reflection.BindingFlags.Instance,
                null,
                new System.Type[]
                {
                    typeof(string),
                    typeof(System.Data.SqlClient.SqlErrorCollection)
                },
                null
                );

                return;
            }
Exemplo n.º 19
0
        private void startService(string service, string entryPoint, string[] args)
        {
            lock (this)
            {
                //
                // Extract the assembly name and the class name.
                //
                string err    = "ServiceManager: unable to load service '" + entryPoint + "': ";
                int    sepPos = entryPoint.IndexOf(':');
                if (sepPos != -1)
                {
                    const string driveLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                    if (entryPoint.Length > 3 &&
                        sepPos == 1 &&
                        driveLetters.IndexOf(entryPoint[0]) != -1 &&
                        (entryPoint[2] == '\\' || entryPoint[2] == '/'))
                    {
                        sepPos = entryPoint.IndexOf(':', 3);
                    }
                }
                if (sepPos == -1)
                {
                    FailureException e = new FailureException();
                    e.reason = err + "invalid entry point format";
                    throw e;
                }

                System.Reflection.Assembly serviceAssembly = null;
                string assemblyName = entryPoint.Substring(0, sepPos);
                string className    = entryPoint.Substring(sepPos + 1);

                try
                {
                    //
                    // First try to load the assembly using Assembly.Load, which will succeed
                    // if a fully-qualified name is provided or if a partial name has been qualified
                    // in configuration. If that fails, try Assembly.LoadFrom(), which will succeed
                    // if a file name is configured or a partial name is configured and DEVPATH is used.
                    //
                    try
                    {
                        serviceAssembly = System.Reflection.Assembly.Load(assemblyName);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            serviceAssembly = System.Reflection.Assembly.LoadFrom(assemblyName);
                        }
                        catch (Exception)
                        {
                            throw ex;
                        }
                    }
                }
                catch (Exception ex)
                {
                    FailureException e = new FailureException(ex);
                    e.reason = err + "unable to load assembly: " + assemblyName;
                    throw e;
                }

                //
                // Instantiate the class.
                //
                Type c = null;
                try
                {
                    c = serviceAssembly.GetType(className, true);
                }
                catch (Exception ex)
                {
                    FailureException e = new FailureException(ex);
                    e.reason = err + "GetType failed for '" + className + "'";
                    throw e;
                }

                ServiceInfo info = new ServiceInfo();
                info.name   = service;
                info.status = ServiceStatus.Stopped;
                info.args   = args;

                //
                // If IceBox.UseSharedCommunicator.<name> is defined, create a
                // communicator for the service. The communicator inherits
                // from the shared communicator properties. If it's not
                // defined, add the service properties to the shared
                // commnunicator property set.
                //
                Ice.Communicator communicator;
                if (_communicator.getProperties().getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0)
                {
                    Debug.Assert(_sharedCommunicator != null);
                    communicator = _sharedCommunicator;
                }
                else
                {
                    //
                    // Create the service properties. We use the communicator properties as the default
                    // properties if IceBox.InheritProperties is set.
                    //
                    Ice.InitializationData initData = new Ice.InitializationData();
                    initData.properties = createServiceProperties(service);
                    if (info.args.Length > 0)
                    {
                        //
                        // Create the service properties with the given service arguments. This should
                        // read the service config file if it's specified with --Ice.Config.
                        //
                        initData.properties = Ice.Util.createProperties(ref info.args, initData.properties);

                        //
                        // Next, parse the service "<service>.*" command line options (the Ice command
                        // line options were parsed by the createProperties above)
                        //
                        info.args = initData.properties.parseCommandLineOptions(service, info.args);
                    }

                    //
                    // Clone the logger to assign a new prefix. If one of the built-in loggers is configured
                    // don't set any logger.
                    //
                    if (initData.properties.getProperty("Ice.LogFile").Length == 0)
                    {
                        initData.logger = _logger.cloneWithPrefix(initData.properties.getProperty("Ice.ProgramName"));
                    }

                    //
                    // If Admin is enabled on the IceBox communicator, for each service that does not set
                    // Ice.Admin.Enabled, we set Ice.Admin.Enabled=1 to have this service create facets; then
                    // we add these facets to the IceBox Admin object as IceBox.Service.<service>.<facet>.
                    //
                    string serviceFacetNamePrefix = "IceBox.Service." + service + ".";
                    bool   addFacets = configureAdmin(initData.properties, serviceFacetNamePrefix);

                    //
                    // Remaining command line options are passed to the communicator. This is
                    // necessary for Ice plug-in properties (e.g.: IceSSL).
                    //
                    info.communicator = Ice.Util.initialize(ref info.args, initData);
                    communicator      = info.communicator;

                    if (addFacets)
                    {
                        // Add all facets created on the service communicator to the IceBox communicator
                        // but renamed IceBox.Service.<service>.<facet-name>, except for the Process facet
                        // which is never added
                        foreach (KeyValuePair <string, Ice.Object> p in communicator.findAllAdminFacets())
                        {
                            if (!p.Key.Equals("Process"))
                            {
                                _communicator.addAdminFacet(p.Value, serviceFacetNamePrefix + p.Key);
                            }
                        }
                    }
                }

                try
                {
                    //
                    // Instantiate the service.
                    //
                    try
                    {
                        //
                        // If the service class provides a constructor that accepts an Ice.Communicator argument,
                        // use that in preference to the default constructor.
                        //
                        Type[] parameterTypes = new Type[1];
                        parameterTypes[0] = typeof(Ice.Communicator);
                        System.Reflection.ConstructorInfo ci = c.GetConstructor(parameterTypes);
                        if (ci != null)
                        {
                            try
                            {
                                object[] parameters = new object[1];
                                parameters[0] = _communicator;
                                info.service  = (Service)ci.Invoke(parameters);
                            }
                            catch (MethodAccessException ex)
                            {
                                FailureException e = new FailureException(ex);
                                e.reason = err + "unable to access service constructor " + className + "(Ice.Communicator)";
                                throw e;
                            }
                        }
                        else
                        {
                            //
                            // Fall back to the default constructor.
                            //
                            try
                            {
                                info.service = (Service)IceInternal.AssemblyUtil.createInstance(c);
                                if (info.service == null)
                                {
                                    FailureException e = new FailureException();
                                    e.reason = err + "no default constructor for '" + className + "'";
                                    throw e;
                                }
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                                FailureException e = new FailureException(ex);
                                e.reason = err + "unauthorized access to default service constructor for " + className;
                                throw e;
                            }
                        }
                    }
                    catch (FailureException)
                    {
                        throw;
                    }
                    catch (InvalidCastException ex)
                    {
                        FailureException e = new FailureException(ex);
                        e.reason = err + "service does not implement IceBox.Service";
                        throw e;
                    }
                    catch (System.Reflection.TargetInvocationException ex)
                    {
                        if (ex.InnerException is FailureException)
                        {
                            throw ex.InnerException;
                        }
                        else
                        {
                            FailureException e = new FailureException(ex.InnerException);
                            e.reason = err + "exception in service constructor for " + className;
                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        FailureException e = new FailureException(ex);
                        e.reason = err + "exception in service constructor " + className;
                        throw e;
                    }

                    try
                    {
                        info.service.start(service, communicator, info.args);
                    }
                    catch (FailureException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        FailureException e = new FailureException(ex);
                        e.reason = "exception while starting service " + service;
                        throw e;
                    }

                    info.status = ServiceStatus.Started;
                    _services.Add(info);
                }
                catch (Exception)
                {
                    if (info.communicator != null)
                    {
                        destroyServiceCommunicator(service, info.communicator);
                    }

                    throw;
                }
            }
        }
Exemplo n.º 20
0
 public System.Reflection.Emit.MethodToken GetConstructorToken(System.Reflection.ConstructorInfo constructor, System.Collections.Generic.IEnumerable <System.Type> optionalParameterTypes)
 {
     throw new PlatformNotSupportedException();
 }
        /*=========================*/
        #endregion

        #region Private Methods
        /*=========================*/

        /// <summary>
        /// Fills DB with data that retrieved by EasyForex BackOffice
        /// </summary>
        /// <param name="dataFromBO">Data from BackOffice to write to DB.</param>
        private void ProcessData(string xmlPath, DateTime _requiredDay)
        {
            SqlCommand insertCommand = InitalizeInsertCommand();

            using (ConnectionKey key = DataManager.Current.OpenConnection())
            {
                // Init insertCommand with the data manger connection
                DataManager.ApplyConnection(insertCommand);

                // Yaniv: add Exception
                /////////////////////
                Type t = Type.GetType(Instance.Configuration.Options["BackOfficeXmlReader"]);
                System.Reflection.ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(string) });
                //if (constructor == null)
                //	throw new blahl
                //BackOfficeXmlReader reader = (BackOfficeXmlReader) constructor.Invoke(new object[] { xmlPath });

                ////////////////////

                //EasyForexReader reader = new EasyForexReader(xmlPath);

                // Initalize const parmaters.
                insertCommand.Parameters["@Downloaded_Date"].Value = DateTime.Now;
                insertCommand.Parameters["@day_Code"].Value        = DayCode(_requiredDay);
                insertCommand.Parameters["@hour_Code"].Value       = DayCode(_requiredDay) == DayCode(DateTime.Today) ? DateTime.Now.Hour : 0;
                insertCommand.Parameters["@account_ID"].Value      = Instance.AccountID;
                //insertCommand.Parameters["@channel_ID"].Value = ChannelID;

                using (EasyForexReader reader = (EasyForexReader)constructor.Invoke(new object[] { xmlPath }))
                {
                    // Read all rows in the BackOffice XML and insert them to the DB.
                    while (reader.Read())
                    {
                        if (reader.CurrentRow.GatewayID == 0)
                        {
                            Log.Write("Error parsing BackOffice row, Can't insert row to DB.", LogMessageType.Error);
                            continue;
                        }

                        InitalizeParametersWithNull(insertCommand);

                        // Initalize command parmaters.
                        insertCommand.Parameters["@gateway_id"].Value                    = reader.CurrentRow.GatewayID;
                        insertCommand.Parameters["@total_Hits"].Value                    = reader.CurrentRow.TotalHits;
                        insertCommand.Parameters["@new_Leads"].Value                     = reader.CurrentRow.NewLeads;
                        insertCommand.Parameters["@new_Users"].Value                     = reader.CurrentRow.NewUsers;
                        insertCommand.Parameters["@new_Active_Users"].Value              = reader.CurrentRow.NewActiveUsers;
                        insertCommand.Parameters["@new_Net_Deposits_in_dollars"].Value   = reader.CurrentRow.NewNetDepostit;
                        insertCommand.Parameters["@active_Users"].Value                  = reader.CurrentRow.ActiveUsers;
                        insertCommand.Parameters["@total_Net_Deposits_in_dollars"].Value = reader.CurrentRow.TotalNetDeposit;
                        insertCommand.Parameters["@Gateway_GK"].Value                    = GkManager.GetGatewayGK(Instance.AccountID, reader.CurrentRow.GatewayID);

                        try
                        {
                            // Execute command.
                            insertCommand.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            Log.Write(string.Format("Error in Inserting data to BackOffice_Client_Gateway table in easynet_Oltp DB."), ex);
                        }
                    }
                }
            }
        }
        //     OBJECTS, METHODS, TYPES AND FIELDS
        //_________________________________________________________________________________________

        /// <summary>
        /// Pops the constructor arguments off the stack and creates a new instance of the object.
        /// </summary>
        /// <param name="constructor"> The constructor that is used to initialize the object. </param>
        public override void NewObject(System.Reflection.ConstructorInfo constructor)
        {
            this.m_generator.Emit(OpCodes.Newobj, constructor);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Returns a friendly strign representation of this instruction
        /// </summary>
        /// <returns></returns>
        public string GetCode()
        {
            string result = "";

            result += GetExpandedOffset(offset) + " : " + code;
            if (operand != null)
            {
                switch (code.OperandType)
                {
                case OperandType.InlineField:
                    System.Reflection.FieldInfo fOperand = ((System.Reflection.FieldInfo)operand);
                    result += " " + Globals.ProcessSpecialTypes(fOperand.FieldType.ToString()) + " " +
                              Globals.ProcessSpecialTypes(fOperand.ReflectedType.ToString()) +
                              "::" + fOperand.Name + "";
                    break;

                case OperandType.InlineMethod:
                    try
                    {
                        System.Reflection.MethodInfo mOperand = (System.Reflection.MethodInfo)operand;
                        result += " ";
                        if (!mOperand.IsStatic)
                        {
                            result += "instance ";
                        }
                        result += Globals.ProcessSpecialTypes(mOperand.ReturnType.ToString()) +
                                  " " + Globals.ProcessSpecialTypes(mOperand.ReflectedType.ToString()) +
                                  "::" + mOperand.Name + "()";
                    }
                    catch
                    {
                        try
                        {
                            System.Reflection.ConstructorInfo mOperand = (System.Reflection.ConstructorInfo)operand;
                            result += " ";
                            if (!mOperand.IsStatic)
                            {
                                result += "instance ";
                            }
                            result += "void " +
                                      Globals.ProcessSpecialTypes(mOperand.ReflectedType.ToString()) +
                                      "::" + mOperand.Name + "()";
                        }
                        catch
                        {
                        }
                    }
                    break;

                case OperandType.ShortInlineBrTarget:
                case OperandType.InlineBrTarget:
                    result += " " + GetExpandedOffset((int)operand);
                    break;

                case OperandType.InlineType:
                    result += " " + Globals.ProcessSpecialTypes(operand.ToString());
                    break;

                case OperandType.InlineString:
                    if (operand.ToString() == "\r\n")
                    {
                        result += " \"\\r\\n\"";
                    }
                    else
                    {
                        result += " \"" + operand.ToString() + "\"";
                    }
                    break;

                case OperandType.ShortInlineVar:
                    result += operand.ToString();
                    break;

                case OperandType.InlineI:
                case OperandType.InlineI8:
                case OperandType.InlineR:
                case OperandType.ShortInlineI:
                case OperandType.ShortInlineR:
                    result += operand.ToString();
                    break;

                case OperandType.InlineTok:
                    if (operand is Type)
                    {
                        result += ((Type)operand).FullName;
                    }
                    else
                    {
                        result += "not supported";
                    }
                    break;

                default: result += "not supported"; break;
                }
            }
            return(result);
        }
 /// <summary>Puts the specified instruction and metadata token for the specified constructor onto the Microsoft intermediate language (MSIL) stream of instructions.</summary>
 /// <param name="opcode">The MSIL instruction to be emitted onto the stream. </param>
 /// <param name="con">A ConstructorInfo representing a constructor. </param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="con" /> is null. This exception is new in the .NET Framework 4.</exception>
 /// <param name="generator">The <see cref="T:System.Reflection.Emit.XsILGenerator" /> to emit instructions from</param>
 public static XsILGenerator FluentEmit(this XsILGenerator generator, System.Reflection.Emit.OpCode opcode, System.Reflection.ConstructorInfo con)
 {
     generator.Emit(opcode, con);
     return(generator);
 }
 /// <summary>
 /// Outputs an instruction and a constructor to the log.
 /// </summary>
 /// <param name="instruction"> The instruction to output. </param>
 /// <param name="constructor"> The constructor to output. </param>
 private void Log(string instruction, System.Reflection.ConstructorInfo constructor)
 {
     LogInstruction(instruction, string.Format("{0}/{1}", constructor, constructor.DeclaringType));
 }
Exemplo n.º 26
0
 public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs)
 {
 }
        //     OBJECTS, METHODS, TYPES AND FIELDS
        //_________________________________________________________________________________________

        /// <summary>
        /// Pops the constructor arguments off the stack and creates a new instance of the object.
        /// </summary>
        /// <param name="constructor"> The constructor that is used to initialize the object. </param>
        public override void NewObject(System.Reflection.ConstructorInfo constructor)
        {
            Log("newobj", constructor);
            this.m_generator.NewObject(constructor);
        }
Exemplo n.º 28
0
 public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute)
 {
 }
 public void SetCustomAttribute(System.Reflection.ConstructorInfo !con, Byte[] !binaryAttribute)
 {
     CodeContract.Requires(con != null);
     CodeContract.Requires(binaryAttribute != null);
 }
Exemplo n.º 30
0
        public static WorldEditBlock Create(Block block, Vector3i originalPosition, Vector3i offsetPosition)
        {
            Vector3i relativePosition = originalPosition - offsetPosition;

            WorldEditBlock worldEditBlock = new WorldEditBlock();

            worldEditBlock.Position         = relativePosition;
            worldEditBlock.OffsetPosition   = offsetPosition;
            worldEditBlock.OriginalPosition = originalPosition;
            worldEditBlock.BlockType        = block.GetType();


            switch (block)
            {
            case PlantBlock plantBlock:
            case TreeBlock treeBlock:
                //Log.Debug($"{worldEditBlock.BlockType.ToString()} at {originalPosition} is a PlantBlock or TreeBlock");
                Plant plant = EcoSim.PlantSim.GetPlant(originalPosition);
                if (plant != null)
                {
                    worldEditBlock.Position  = plant.Position.XYZi - offsetPosition;
                    worldEditBlock.BlockData = WorldEditPlantBlockData.From(plant);
                }
                else
                {
                    worldEditBlock.BlockType = typeof(EmptyBlock);
                }
                break;

            case WorldObjectBlock objectBlock:
                //Log.Debug($"{worldEditBlock.BlockType.ToString()} at {originalPosition} is a WorldObjectBlock");
                WorldObject worldObject = objectBlock.WorldObjectHandle.Object;
                worldEditBlock.BlockData = WorldEditWorldObjectBlockData.From(worldObject);
                relativePosition         = worldObject.Position3i - offsetPosition;
                worldEditBlock.Position  = relativePosition;
                break;

            case EmptyBlock emptyBlock:
                //Log.Debug($"{worldEditBlock.BlockType.ToString()} at {originalPosition} is a EmptyBlock");
                break;

            default:
                //Log.Debug($"{worldEditBlock.BlockType.ToString()} at {originalPosition} is a Block");
                System.Reflection.ConstructorInfo constuctor = worldEditBlock.BlockType.GetConstructor(Type.EmptyTypes);
                if (constuctor == null)
                {
                    throw new ArgumentOutOfRangeException(message: "Block type is not supported", paramName: worldEditBlock.BlockType.FullName);
                }
                if (BlockContainerManager.Obj.IsBlockContained(originalPosition))
                {
                    worldEditBlock.BlockType = typeof(EmptyBlock);
                    WorldObject obj = ServiceHolder <IWorldObjectManager> .Obj.All.Where(x => x.Position3i.Equals(originalPosition)).FirstOrDefault();

                    if (obj != null)
                    {
                        worldEditBlock.BlockType = typeof(WorldObjectBlock);
                        worldEditBlock.BlockData = WorldEditWorldObjectBlockData.From(obj);
                        relativePosition         = obj.Position3i - offsetPosition;
                        worldEditBlock.Position  = relativePosition;
                    }
                }
                break;
            }

            return(worldEditBlock);
        }
 public void SetCustomAttribute(System.Reflection.ConstructorInfo con, System.Byte[] binaryAttribute) => throw null;
Exemplo n.º 32
0
 public ConstructorMetadata(System.Reflection.ConstructorInfo constructor)
 {
     // TODO: Complete member initialization
     this.constructor = constructor;
 }
Exemplo n.º 33
0
 public static ImageResource CreateResource(Type type)
 {
     System.Reflection.ConstructorInfo ci = type.GetConstructor(new Type[] { });
     return (ImageResource)ci.Invoke(new object[] { });
 }
Exemplo n.º 34
0
        public virtual System.Reflection.ConstructorInfo GetConstructorInfo()
        {
            if(this.constructorInfo == null)
            {
                if(this.DeclaringType == null)
                    return null;
                Type t = this.DeclaringType.GetRuntimeType();
                if(t == null)
                    return null;
                ParameterList pars = this.Parameters;
                int n = pars == null ? 0 : pars.Count;
                Type[] types = new Type[n];
                for(int i = 0; i < n; i++)
                {
                    Parameter p = pars[i];
                    if(p == null || p.Type == null)
                        return null;
                    Type pt = types[i] = p.Type.GetRuntimeType();
                    if(pt == null)
                        return null;
                }
                System.Reflection.MemberInfo[] members = t.GetMember(this.Name.ToString(), System.Reflection.MemberTypes.Constructor,
                  BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                foreach(System.Reflection.ConstructorInfo cons in members)
                {
                    if(cons == null)
                        continue;
                    System.Reflection.ParameterInfo[] parameters = cons.GetParameters();
                    int numPars = parameters == null ? 0 : parameters.Length;
                    if(numPars != n)
                        continue;
                    if(parameters != null)
                        for(int i = 0; i < n; i++)
                        {
                            System.Reflection.ParameterInfo par = parameters[i];
                            if(par == null || par.ParameterType != types[i])
                                goto tryNext;
                        }
                    return this.constructorInfo = cons;
tryNext:
                    ;
                }
            }
            return this.constructorInfo;
        }
Exemplo n.º 35
0
        private void AddFilter(IDeviceFilter filter, bool isReadonly)
        {
            this.RowCount++;
            this.RowStyles.Add(new RowStyle());

            Type typControl = this.m_Application.GetControlType(filter.GetType(), typeof(System.Windows.Forms.Control));

            if (typControl == null)
            {
                Label lab = new Label();
                lab.Text         = "未发现 " + filter.GetType().FullName + " 的筛选器控件";
                lab.AutoEllipsis = true;
                lab.Padding      = new System.Windows.Forms.Padding(3);
                lab.Dock         = DockStyle.Bottom;
                this.Controls.Add(lab);

                if (this.EnabledRemove)
                {
                    System.Windows.Forms.Button btnFilterRemove = new Button();
                    btnFilterRemove.Image     = Properties.Resources.DeleteBlack;
                    btnFilterRemove.Width     = 24;
                    btnFilterRemove.FlatStyle = FlatStyle.Flat;
                    btnFilterRemove.FlatAppearance.BorderSize = 0;
                    btnFilterRemove.Dock   = DockStyle.Right;
                    btnFilterRemove.Click += new EventHandler(btnFilterRemove_Click);
                    this.Controls.Add(btnFilterRemove);
                }
            }
            else
            {
                System.Reflection.ConstructorInfo ciFilter = typControl.GetConstructor(new System.Type[] { });
                object objFilterInstance = ciFilter.Invoke(new object[] { });

                IDeviceFilterControl _FilterControl = objFilterInstance as IDeviceFilterControl;
                _FilterControl.SetApplication(this.m_Application);

                if (objFilterInstance is IUseAccount)
                {
                    IUseAccount useAccount = objFilterInstance as IUseAccount;
                    useAccount.SetAccount(this.m_Account);
                }

                _FilterControl.SetFilter(filter);

                Control ctl = objFilterInstance as Control;
                ctl.Dock = DockStyle.Bottom;
                if (isReadonly)
                {
                    ctl.Enabled = false;
                }
                this.Controls.Add(ctl);

                if (this.EnabledRemove)
                {
                    if (isReadonly)
                    {
                        Control ctlButton = new Control();
                        this.Controls.Add(ctlButton);
                    }
                    else
                    {
                        System.Windows.Forms.Button btnFilterRemove = new Button();
                        btnFilterRemove.Image     = Properties.Resources.DeleteBlack;
                        btnFilterRemove.Width     = 24;
                        btnFilterRemove.FlatStyle = FlatStyle.Flat;
                        btnFilterRemove.FlatAppearance.BorderSize = 0;
                        btnFilterRemove.Dock   = DockStyle.Right;
                        btnFilterRemove.Click += new EventHandler(btnFilterRemove_Click);
                        this.Controls.Add(btnFilterRemove);
                    }
                }
            }
        }
Exemplo n.º 36
0
            static SqlErrorCollectionInstantiator()
            {
                constructor =
                typeof(System.Data.SqlClient.SqlErrorCollection).GetConstructor
                (
                    System.Reflection.BindingFlags.NonPublic |
                    System.Reflection.BindingFlags.Instance,
                    null,
                    new System.Type[] { },
                    null
                );

                add = typeof(System.Data.SqlClient.SqlErrorCollection).GetMethod
                (
                "Add",
                System.Reflection.BindingFlags.NonPublic |
                System.Reflection.BindingFlags.Instance
                );

                return;
            }
Exemplo n.º 37
0
        /// <summary> Instantiates an LdapControl.  We search through our list of
        /// registered controls.  If we find a matchiing OID we instantiate
        /// that control by calling its contructor.  Otherwise we default to
        /// returning a regular LdapControl object
        ///
        /// </summary>
        private LdapControl controlFactory(System.String oid, bool critical, sbyte[] value_Renamed)
        {
//			throw new NotImplementedException();
            RespControlVector regControls = LdapControl.RegisteredControls;

            try
            {
                /*
                 * search through the registered extension list to find the
                 * response control class
                 */
                System.Type respCtlClass = regControls.findResponseControl(oid);

                // Did not find a match so return default LDAPControl
                if (respCtlClass == null)
                {
                    return(new LdapControl(oid, critical, value_Renamed));
                }

                /* If found, get LDAPControl constructor */
                System.Type[]    argsClass = new System.Type[] { typeof(System.String), typeof(bool), typeof(sbyte[]) };
                System.Object[]  args      = new System.Object[] { oid, critical, value_Renamed };
                System.Exception ex        = null;
                try
                {
                    System.Reflection.ConstructorInfo ctlConstructor = respCtlClass.GetConstructor(argsClass);

                    try
                    {
                        /* Call the control constructor for a registered Class*/
                        System.Object ctl = null;
//						ctl = ctlConstructor.newInstance(args);
                        ctl = ctlConstructor.Invoke(args);
                        return((LdapControl)ctl);
                    }
                    catch (System.UnauthorizedAccessException e)
                    {
                        ex = e;
                    }
                    catch (System.Reflection.TargetInvocationException e)
                    {
                        ex = e;
                    }
                    catch (System.Exception e)
                    {
                        // Could not create the ResponseControl object
                        // All possible exceptions are ignored. We fall through
                        // and create a default LDAPControl object
                        ex = e;
                    }
                }
                catch (System.MethodAccessException e)
                {
                    // bad class was specified, fall through and return a
                    // default LDAPControl object
                    ex = e;
                }
            }
            catch (System.FieldAccessException e)
            {
                // No match with the OID
                // Do nothing. Fall through and construct a default LDAPControl object.
            }
            // If we get here we did not have a registered response control
            // for this oid.  Return a default LDAPControl object.
            return(new LdapControl(oid, critical, value_Renamed));
        }
Exemplo n.º 38
0
 internal ConstructorInfoImpl(System.Reflection.ConstructorInfo constructor)
 {
     Debug.Assert(constructor != null);
     this.Constructor = constructor;
 }
Exemplo n.º 39
0
 public EmbeddedType(Type type, System.Reflection.ConstructorInfo ctor, PropertyAttributes attrs)
 {
     Type       = type;
     Ctor       = ctor;
     Attributes = attrs;
 }
Exemplo n.º 40
0
        //TODO: Возможно объеденить с compiled_function_node
		private compiled_constructor_node(System.Reflection.ConstructorInfo con_info)
		{
			_con_info=con_info;
            compiled_constructors[con_info] = this;
            //type_node ret_val=null;
			System.Reflection.ParameterInfo[] pinf=_con_info.GetParameters();
			parameter_list pal=new parameter_list();
			foreach(System.Reflection.ParameterInfo pi in pinf)
			{
				Type t=null;
				type_node par_type=null;
				SemanticTree.parameter_type pt=SemanticTree.parameter_type.value;
				if (pi.ParameterType.IsByRef) 
				{
					t=pi.ParameterType.GetElementType();
					par_type=compiled_type_node.get_type_node(t);
					pt=SemanticTree.parameter_type.var;
				}
				else
				{
					par_type=compiled_type_node.get_type_node(pi.ParameterType);
				}
				string name=pi.Name;
				compiled_parameter crpar=new compiled_parameter(pi);
				crpar.SetParameterType(pt);
				pal.AddElement(crpar);
                if (pi.IsOptional && pi.DefaultValue != null)
                    _num_of_default_parameters++;
			}
			this.return_value_type=compiled_type_node.get_type_node(_con_info.DeclaringType);
			this.parameters.AddRange(pal);
		}
            private System.ComponentModel.Design.Serialization.InstanceDescriptor ConvertToInstanceDescriptor(OleDbParameter p)
            {
                int flags = 0;

                if (p.ShouldSerializeOleDbType())
                {
                    flags |= 1;
                }
                if (p.ShouldSerializeSize())
                {
                    flags |= 2;
                }
                if (!ADP.IsEmpty(p.SourceColumn))
                {
                    flags |= 4;
                }
                if (null != p.Value)
                {
                    flags |= 8;
                }
                if ((ParameterDirection.Input != p.Direction) || p.IsNullable ||
                    p.ShouldSerializePrecision() || p.ShouldSerializeScale() ||
                    (DataRowVersion.Current != p.SourceVersion))
                {
                    flags |= 16; // V1.0 everything
                }
                if (p.SourceColumnNullMapping)
                {
                    flags |= 32; // v2.0 everything
                }

                Type[]   ctorParams;
                object[] ctorValues;
                switch (flags)
                {
                case 0:     // ParameterName
                case 1:     // OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType };
                    break;

                case 2:     // Size
                case 3:     // Size, OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType), typeof(int) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType, p.Size };
                    break;

                case 4:     // SourceColumn
                case 5:     // SourceColumn, OleDbType
                case 6:     // SourceColumn, Size
                case 7:     // SourceColumn, Size, OleDbType
                    ctorParams = new Type[] { typeof(string), typeof(OleDbType), typeof(int), typeof(string) };
                    ctorValues = new object[] { p.ParameterName, p.OleDbType, p.Size, p.SourceColumn };
                    break;

                case 8:     // Value
                    ctorParams = new Type[] { typeof(string), typeof(object) };
                    ctorValues = new object[] { p.ParameterName, p.Value };
                    break;

                default:  // everything else
                    if (0 == (32 & flags))
                    {     // V1.0 everything
                        ctorParams = new Type[] {
                            typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection),
                            typeof(bool), typeof(byte), typeof(byte), typeof(string),
                            typeof(DataRowVersion), typeof(object)
                        };
                        ctorValues = new object[] {
                            p.ParameterName, p.OleDbType, p.Size, p.Direction,
                            p.IsNullable, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn,
                            p.SourceVersion, p.Value
                        };
                    }
                    else
                    {     // v2.0 everything - round trip all browsable properties + precision/scale
                        ctorParams = new Type[] {
                            typeof(string), typeof(OleDbType), typeof(int), typeof(ParameterDirection),
                            typeof(byte), typeof(byte),
                            typeof(string), typeof(DataRowVersion), typeof(bool),
                            typeof(object)
                        };
                        ctorValues = new object[] {
                            p.ParameterName, p.OleDbType, p.Size, p.Direction,
                            p.PrecisionInternal, p.ScaleInternal,
                            p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping,
                            p.Value
                        };
                    }
                    break;
                }
                System.Reflection.ConstructorInfo ctor = typeof(OleDbParameter).GetConstructor(ctorParams);
                return(new System.ComponentModel.Design.Serialization.InstanceDescriptor(ctor, ctorValues));
            }