• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Construct类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Construct的典型用法代码示例。如果您正苦于以下问题:C# Construct类的具体用法?C# Construct怎么用?C# Construct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Construct类属于命名空间,在下文中一共展示了Construct类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Person myp = new Person();
            myp.Age = 38;

            Console.Write(myp.Age);

            //This constructs the object.
            //Looks like anon class in Java.
            Construct cDo = new Construct()
            {
                Name = "Jason",
                JobCode = 8675309
            };

            Console.WriteLine("Enter one - three");
            //Convert a String read from the user input to an INT.
            int result = int.Parse(Console.ReadLine());

            switch (result)
            {
                case 1:
                    Console.WriteLine("You entered:{0} ", result);
                    break;
                case 3:
                    Console.WriteLine("You entered:{0} ", result);
                    break;
                case 2:
                    Console.WriteLine("You entered:{0} ", result);
                    break;
                default:
                    break;
            }
        }
开发者ID:Hummingdroid,项目名称:Personal-CSharp-Projects-And-Practices,代码行数:34,代码来源:Program.cs


示例2: Billing

        public static void Billing(Construct construct)
        {
            var deligate = new BeginInvoiceRequestDelegate(BeginInvoiceRequest);
            var callback = new AsyncCallback(EndInvoiceRequest);

            deligate.BeginInvoke(construct, callback, null);
        }
开发者ID:ucdavis,项目名称:PTF,代码行数:7,代码来源:EmailBLL.cs


示例3: VisitConstruct

        /// <summary>Visits a constructor invocation.</summary>
        /// <param name="cons">Construction.</param>
        /// <returns>Resulting expression to visit.</returns>
        public override void VisitConstruct(Construct cons)
        {
            CheckMethod(
                ConstructAsInstanceInitializer(cons),
                x =>
                    x.DeclaringType.FullName.StartsWith("Microsoft.OData.Service.DataServiceException") &&
                    !HasParameterType(x, "System.Int32"),
                methodUnderCheck.FullName);

            base.VisitConstruct(cons);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:14,代码来源:WebDataServiceExceptionCtorRule.cs


示例4: ConstructComplete

        public static void ConstructComplete(Construct construct)
        {
            MailMessage message = new MailMessage();
            message.From = new MailAddress(fromEmail);                              // add in all the to emails
            if (adminEmails.Count() > 0) foreach (var a in adminEmails) { message.To.Add(a); }     // add in all from from emails
            message.Body = EmailText.STR_OrderCompleted + "<br/>Construct Code:" + construct.ConstructCode;
            message.Subject = "PTF Order Completed.";
            message.IsBodyHtml = true;

            SmtpClient client = new SmtpClient();
            client.Send(message);
        }
开发者ID:ucdavis,项目名称:PTF,代码行数:12,代码来源:EmailBLL.cs


示例5: CreateMonthly

    internal void CreateMonthly(Construct wts_, Technicals.ProductBase[] products_)
    {
      List<DateTime> dates = new List<DateTime>();
      List<double> vals = new List<double>();

      int countOfZerosThisMonth = 0;
      int numberOfRebalsThisMomth = 0;

      int currentMonth = 0;
      int currentYear = 0;

      for (int i = 0; i < wts_.Dates.Count; ++i)
      {
        if (wts_.Dates[i].Year != currentYear || wts_.Dates[i].Month != currentMonth)
        {
          if (currentMonth != 0)
          {
            dates.Add(new DateTime(currentYear, currentMonth, 1));
            vals.Add(Convert.ToDouble(countOfZerosThisMonth) / Convert.ToDouble(numberOfRebalsThisMomth));
          }

          countOfZerosThisMonth = 0;
          numberOfRebalsThisMomth = 0;
        }

        double[] weightsThisRebal = wts_.GetValues(wts_.Dates[i]);

        for(int y=0;y<weightsThisRebal.Length;++y)
          if (weightsThisRebal[y] == 0.0 && products_[y].IsValid(wts_.Dates[i]))
            ++countOfZerosThisMonth;

        ++numberOfRebalsThisMomth;

        currentMonth = wts_.Dates[i].Month;
        currentYear = wts_.Dates[i].Year;
      }

      dates.Add(new DateTime(currentYear, currentMonth, 1));
      vals.Add(Convert.ToDouble(countOfZerosThisMonth) / Convert.ToDouble(numberOfRebalsThisMomth));

      foreach (DateTime date in dates)
        dt.Columns.Add(date.ToString("MMM yy"), typeof(double));

      DataRow row = dt.NewRow();

      for (int i = 0; i < vals.Count; ++i)
        row[i] = vals[i];

      dt.Rows.Add(row);

      Chart.DataSource = dt;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:52,代码来源:AverageZeroWeightsPerMonthChart.cs


示例6: VisitConstruct

        public override void VisitConstruct(Construct construct)
        {
            var memberBinding = construct.Constructor as MemberBinding;

            if (memberBinding != null
                && memberBinding.BoundMember.Name.Name == ".ctor"
                && memberBinding.BoundMember.DeclaringType.IsTask())
            {
                Problems.Add(new Problem(GetResolution(), construct.UniqueKey.ToString()));
            }

            base.VisitConstruct(construct);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:13,代码来源:DoNotConstructTaskInstancesRule.cs


示例7: VisitConstruct

 public override Expression VisitConstruct(Construct cons) {
   MemberBinding mb = cons.Constructor as MemberBinding;
   if (mb != null) {
     mb.TargetObject = this.VisitExpression(mb.TargetObject);
   }
   cons.Operands = this.VisitExpressionList(cons.Operands);
   this.composers.Clear();
   if (mb != null) {
     this.composers.Add(this.GetComposer(mb.TargetObject));
   }
   this.GetComposers(this.composers, cons.Operands);
   return (Expression) this.Compose(cons, this.composers);
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:13,代码来源:Partitioner.cs


示例8: Load

        public void Load()
        {
            string gamePicturePath = Path.Combine(_scenarioPath, "Picture");
            string gameDataPath = Path.Combine(_scenarioPath, "Data");

            // 地形タイプ情報の読み込み
            var landformInfos = LoadInfo();

            // 各チップ画像の取得
            var landImages = WarGlobal.BmpManager.GetSurfaces(
                Path.Combine(gamePicturePath, "BMAPCHAR.BMP"), WarGlobal.ChipSize);

            var objectImages = WarGlobal.BmpManager.GetSurfaces(
                Path.Combine(gamePicturePath, "BMAPOBJ.BMP"), WarGlobal.ChipSize,
                path => BitmapUtil.Load(path, Color.Black));

            // 地形チップの生成
            var landforms = new Landform[landImages.Count];
            // 地形タイプの読み込み
            using (var reader = new StreamReader(Path.Combine(gameDataPath, "TikeiType"), WarGlobal.Encoding))
            {
                var sc = new Scanner(reader);
                for (int i = 0; i < landforms.Length; i++)
                {
                    int id = sc.NextInt32(NumberStyles.HexNumber);
                    landforms[i] = new Landform(landImages[i], landformInfos[id + 1]);
                }
            }
            WarGlobal.Landforms = landforms;

            // オブジェクトチップの生成
            var constructs = new Construct[objectImages.Count + 2];
            // 0番目は移動不可, 1番目はnull
            for (int i = 2; i < objectImages.Count; i++)
            {
                int id;
                if (i > EndWall)
                    id = 18;
                else if (i > EndCity)
                    id = 17;
                else
                    id = 16;
                constructs[i] = new Construct(objectImages[i - 1], landformInfos[id + 1]);
            }
            // 移動不可オブジェクトの生成
            constructs[0] = new Construct(null, landformInfos[0]);

            WarGlobal.Constructs = constructs;
        }
开发者ID:ProjectTane,项目名称:FarenDotNet,代码行数:49,代码来源:LandformLoader.cs


示例9: CreateWeekly

    internal void CreateWeekly(Construct wts_, Technicals.ProductBase[] products_)
    {
      int lastDay = (int)DayOfWeek.Sunday;
      int countThisWeek = 0;
      List<DateTime> dates = new List<DateTime>();
      List<int> values = new List<int>();
      DateTime firsInWeek = wts_.Dates[0];

      for (int i = 0; i < wts_.Dates.Count; ++i)
      {
        DateTime rebalDate = wts_.Dates[i];

        int dayIndex = (int)rebalDate.DayOfWeek;

        if (dayIndex > lastDay)
        {
          ++countThisWeek;
          lastDay = dayIndex;
        }
        else
        {
          dates.Add(firsInWeek);
          values.Add(countThisWeek);
          countThisWeek = 1;
          firsInWeek = rebalDate;
          lastDay = dayIndex;
        }
      }

      // last one won't have been added to the list
      dates.Add(firsInWeek);
      values.Add(countThisWeek);

      foreach (DateTime date in dates)
        dt.Columns.Add(date.ToString("MMM yy"), typeof(double));

      DataRow row = dt.NewRow();

      for (int i = 0; i < values.Count; ++i)
        row[i] = values[i];

      dt.Rows.Add(row);

      Chart.DataSource = dt;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:45,代码来源:AverageZeroWeightsPerMonthChart.cs


示例10: VisitConstruct

        /// <summary>Visits a constructor invocation.</summary>
        /// <param name="cons">Construction.</param>
        /// <returns>Resulting expression to visit.</returns>
        public override void VisitConstruct(Construct cons)
        {
            InstanceInitializer init = ConstructAsInstanceInitializer(cons);

            if (init != null)
            {
                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeTypeReference" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReferenceOptions"),
                    methodUnderCheck.FullName);

                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeTypeReferenceExpression" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReference"),
                        methodUnderCheck.FullName);

                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeParameterDeclaration" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReference"),
                        methodUnderCheck.FullName);

                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeMemberField" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReference"),
                        methodUnderCheck.FullName);

                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeArrayCreateExpression" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReference"),
                        methodUnderCheck.FullName);
                
                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeCastExpression" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReference"),
                        methodUnderCheck.FullName);

                CheckMethod(init,
                    x => x.DeclaringType.FullName == "System.CodeDom.CodeObjectCreateExpression" &&
                        !HasParameterType(x, "System.CodeDom.CodeTypeReference"),
                        methodUnderCheck.FullName);
            }

            base.VisitConstruct(cons);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:47,代码来源:CodeTypeReferenceRule.cs


示例11: VisitConstruct

        /// <summary>Visits a constructor invocation.</summary>
        /// <param name="cons">Construction.</param>
        /// <returns>Resulting expression to visit.</returns>
        public override void VisitConstruct(Construct cons)
        {
            CheckMethod(
                ConstructAsInstanceInitializer(cons),
                x =>
                    x.Template != null &&
                    x.Template.FullName == "System.Collections.Generic.HashSet`1.#ctor" &&
                    !HasParameterType(x, "System.Collections.Generic.IEqualityComparer`1"),
                methodUnderCheck.FullName);

            CheckMethod(
                ConstructAsInstanceInitializer(cons),
                x =>
                    x.Template != null &&
                    x.Template.FullName == "System.Collections.Generic.Dictionary`2.#ctor" &&
                    !HasParameterType(x, "System.Collections.Generic.IEqualityComparer`1"),
                methodUnderCheck.FullName);

            base.VisitConstruct(cons);
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:23,代码来源:HashSetCtorRule.cs


示例12: Main

    public static void Main(String[] Args)
    {
        Construct root = new Construct();

        root.setType( "rootConstruct" );

        root.setName( "rootName" );

        root.addAnnotation( "rootAnnotation1" );
        root.addAnnotation( "rootAnnotation2" );

        root.addSuper( "rootSuper1" );
        root.addSuper( "rootSuper2" );

        root.addModifier( new Modifier( "rootSwitchModifier" ) );
        root.addModifier( new Modifier( "rootStringModifier", "abc" ) );
        root.addModifier( new Modifier( "rootIntegerModifier", 123 ) );
        root.addModifier( new Modifier( "rootBooleanModifier", false ) );

        Construct child = new Construct();

        child.setType( "childConstruct" );

        child.setName( "childName" );

        child.addAnnotation( "childAnnotation1" );
        child.addAnnotation( "childAnnotation2" );

        child.addSuper( "childSuper1" );
        child.addSuper( "childSuper2" );

        child.addModifier( new Modifier( "childSwitchModifier" ) );
        child.addModifier( new Modifier( "childStringModifier", "abc" ) );
        child.addModifier( new Modifier( "childIntegerModifier", 123 ) );
        child.addModifier( new Modifier( "childBooleanModifier", false ) );

        root.addChild(child);

        Console.WriteLine( root );
    }
开发者ID:christophevg,项目名称:ADL,代码行数:40,代码来源:test.cs


示例13: BeginInvoiceRequest

        public static void BeginInvoiceRequest(Construct construct)
        {
            var reportName = "/PTF/Invoice";

            var parameters = new Dictionary<string, string>();
            parameters.Add("ConstructCode", construct.ConstructCode);

            var invoice = Get(reportName, parameters);
            var memoryStream = new MemoryStream(invoice);

            //var message = new MailMessage(fromEmail, billingEmail);
            var message = new MailMessage();
            message.From = new MailAddress(fromEmail);
            if (billingEmails.Count() > 0) foreach (var a in billingEmails) { message.To.Add(a); }
            if (adminEmails.Count() > 0) foreach( var a in adminEmails) {message.To.Add(a);}
            message.Attachments.Add(new Attachment(memoryStream, string.Format("{0}_{1}.pdf", construct.Order.ID, construct.ConstructCode)));
            message.Body = EmailText.STR_Billing;
            message.Subject = "PTF Order Ready for Billing";
            message.IsBodyHtml = true;

            SmtpClient client = new SmtpClient();
            client.Send(message);
        }
开发者ID:ucdavis,项目名称:PTF,代码行数:23,代码来源:EmailBLL.cs


示例14: VisitConstruct

 public override Expression VisitConstruct(Construct cons){
   cons = (Construct)base.VisitConstruct(cons);
   if (cons == null) return null;
   MemberBinding mb = cons.Constructor as MemberBinding;
   if (mb == null) return cons;
   Method meth = mb.BoundMember as Method;
   if (meth == null) return cons;
   ParameterList parameters = meth.Parameters;
   if (parameters == null) return cons;
   ExpressionList operands = cons.Operands;
   int n = operands == null ? 0 : operands.Count;
   if (n > parameters.Count) n = parameters.Count;
   for (int i = 0; i < n; i++){
     //^ assert operands != null;
     Expression e = operands[i];
     if (e == null) continue;
     Parameter p = parameters[i];
     if (p == null) continue;
     if (e.Type == null || p.Type == null) continue;
     if (e.Type.IsValueType && !p.Type.IsValueType)
       operands[i] = new BinaryExpression(e, new MemberBinding(null, e.Type), NodeType.Box, p.Type);
   }
   return cons;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:24,代码来源:Specializer.cs


示例15: VisitConstruct

		public virtual Expression VisitConstruct (Construct node)
		{
			if (node == null)
				return null;

			node.Constructor = VisitExpression (node.Constructor);
			node.Arguments = VisitExpressionList (node.Arguments);

			return node;
		}
开发者ID:carrie901,项目名称:mono,代码行数:10,代码来源:DefaultNodeVisitor.cs


示例16: VisitConstruct

        /// <summary>Visits a constructor invocation.</summary>
        /// <param name="cons">Construction.</param>
        /// <returns>Resulting expression to visit.</returns>
        public override void VisitConstruct(Construct cons)
        {
            if (cons != null)
            {
                MemberBinding constructorBinding = cons.Constructor as MemberBinding;
                if (constructorBinding != null)
                {
                    Method method = constructorBinding.BoundMember as Method; // More likely: InstanceInitializer;
                    this.CheckMethodUsage(method);
                }
            }

            base.VisitConstruct(cons);
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:17,代码来源:MethodCallNotAllowed.cs


示例17: VisitConstruct

		public virtual void VisitConstruct (Construct node)
		{
			if (node == null)
				return;

			VisitExpression (node.Constructor);
			VisitExpressionList (node.Arguments);
		}
开发者ID:carrie901,项目名称:mono,代码行数:8,代码来源:NodeInspector.cs


示例18: VisitConstruct

 public override Expression VisitConstruct(Construct cons) {
   if (cons == null) return cons;
   MemberBinding mb = cons.Constructor as MemberBinding;
   if (mb == null) {
     Literal lit = cons.Constructor as Literal;
     DelegateNode del = lit == null ? null : lit.Value as DelegateNode;
     if (del != null && cons.Operands != null && cons.Operands.Count == 1) {
       MemberList members = null;
       TypeNode offendingType = this.currentType;
       string offendingName = null;
       Expression e = cons.Operands[0];
       NameBinding nb = e as NameBinding;
       if (nb != null) {
         members = nb.BoundMembers;
         offendingName = nb.Identifier.ToString();
       } else {
         QualifiedIdentifier qualId = e as QualifiedIdentifier;
         if (qualId != null) {
           offendingName = qualId.Identifier.ToString();
           e = qualId.Identifier;
           Expression ob = qualId.Qualifier;
           if (ob is TemplateInstance) {
             this.VisitTemplateInstance((TemplateInstance)ob);
             return null;
           }
           if (ob is Literal && ob.Type == SystemTypes.Type)
             members = this.GetTypeView(offendingType = (ob as Literal).Value as TypeNode).GetMembersNamed(qualId.Identifier);
           else if (ob != null && ob.Type != null)
             members = this.GetTypeView(offendingType = TypeNode.StripModifiers(ob.Type)).GetMembersNamed(qualId.Identifier);
         }
       }
       int n = members == null ? 0 : members.Count;
       Member offendingMember = n > 0 ? members[0] : null;
       for (int i = 0; i < n; i++) {
         Method m = members[i] as Method;
         if (m != null) { offendingMember = m; break; }
       }
       if (offendingMember == null) {
         if (offendingName == null)
           this.HandleError(e, Error.MethodNameExpected);
         else
           this.HandleError(e, Error.NoSuchMember, this.GetTypeName(offendingType), offendingName);
       } else if (offendingMember is Method) {
         this.HandleError(e, Error.NoMethodMatchesDelegate, this.GetDelegateSignature(del), this.GetUnqualifiedMemberName((Method)offendingMember));
         this.HandleRelatedError(del);
         this.HandleRelatedError(offendingMember);
       } else
         this.HandleNonMethodWhereMethodExpectedError(e, offendingMember);
       return null;
     }
     return null;
   }
   InstanceInitializer c = mb.BoundMember as InstanceInitializer;
   if (c == null) {
     TypeNode consType = TypeNode.StripModifiers(cons.Type);
     if (consType != null && consType.IsValueType && (cons.Operands == null || cons.Operands.Count == 0))
       return new Local(StandardIds.NewObj, consType, cons.SourceContext);
     TypeNode t = mb.BoundMember as TypeNode;
     if (t == null)
       this.HandleError(cons, Error.NoSuchConstructor, "");
     else if (t.Name == Looker.NotFound || t.Name == null)
       this.VisitTypeReference(t); //Report appropriate error about type
     else {
       MemberList members = this.GetTypeView(t).GetConstructors();
       int n = members == null ? 0 : members.Count;
       if (n == 0) {
         if ((cons.Operands == null || cons.Operands.Count == 0) && t is ITypeParameter && 
           (((ITypeParameter)t).TypeParameterFlags & (TypeParameterFlags.DefaultConstructorConstraint|TypeParameterFlags.ValueTypeConstraint)) != 0) {
           if (this.useGenerics) {
             Method createInstance = Runtime.GenericCreateInstance.GetTemplateInstance(this.currentType, t);
             return new MethodCall(new MemberBinding(null, createInstance), null, NodeType.Call, t, cons.SourceContext);
           } else {
             if ((((ITypeParameter)t).TypeParameterFlags & TypeParameterFlags.DefaultConstructorConstraint) != 0) {
               ExpressionList arguments = new ExpressionList(Normalizer.TypeOf(t));
               MethodCall call = new MethodCall(new MemberBinding(null, Runtime.CreateInstance), arguments, NodeType.Call, SystemTypes.Object, cons.SourceContext);
               return new BinaryExpression(call, new Literal(t, SystemTypes.Type), NodeType.Castclass, t, cons.SourceContext);
             } else {
               return new Local(StandardIds.NewObj, consType, cons.SourceContext);
             }
           }
         }
         if (t.IsAbstract)
           if (t.IsSealed)
             this.HandleError(cons, Error.ConstructsAbstractSealedClass, this.GetTypeName(t));
           else
             this.HandleError(cons, Error.ConstructsAbstractClass, this.GetTypeName(t));
         else
           this.HandleError(cons, Error.NoSuchConstructor, this.GetTypeName(t));
       } else {
         this.HandleError(cons, Error.NoOverloadWithMatchingArgumentCount, t.Name.ToString(), (cons.Operands == null ? 0 : cons.Operands.Count).ToString());
       }
       for (int i = 0; i < n; i++) {
         Member m = members[i];
         if (m == null) continue;
         if (m.SourceContext.Document == null) continue;
         this.HandleRelatedError(m);
       }
     }
     return null;
   }
//.........这里部分代码省略.........
开发者ID:hesam,项目名称:SketchSharp,代码行数:101,代码来源:Checker.cs


示例19: CoerceFromTypeUnion

 protected virtual Expression CoerceFromTypeUnion(Expression source, TypeUnion sourceType, TypeNode targetType, bool explicitCoercion, TypeNode originalTargetType, TypeViewer typeViewer){
   if (source == null || sourceType == null || targetType == null) return null;
   if (targetType == SystemTypes.Object) return this.CoerceTypeUnionToObject(source, typeViewer);
   int cErrors = (this.Errors != null) ? this.Errors.Count : 0;
   if (explicitCoercion){
     Method coercion = this.UserDefinedExplicitCoercionMethod(source, sourceType, targetType, false, originalTargetType, typeViewer);
     if (coercion != null && coercion.ReturnType == targetType && coercion.Parameters != null && coercion.Parameters[0] != null &&
       this.ImplicitCoercionFromTo(sourceType, coercion.Parameters[0].Type, typeViewer))
       return this.ImplicitCoercion(new MethodCall(new MemberBinding(null, coercion), new ExpressionList(source), NodeType.Call, coercion.ReturnType),
         targetType, typeViewer);
   }
   Method getTag = TypeViewer.GetTypeView(typeViewer, sourceType).GetMethod(StandardIds.GetTag);
   if (getTag == null) return null;
   Method getValue = TypeViewer.GetTypeView(typeViewer, sourceType).GetMethod(StandardIds.GetValue);
   if (getValue == null) return null;
   Local src = new Local(sourceType);
   Local srcOb = new Local(SystemTypes.Object, source.SourceContext);
   Local tgt = new Local(targetType);
   Expression callGetTag = new MethodCall(new MemberBinding(new UnaryExpression(src, NodeType.AddressOf), getTag), null);
   Expression callGetValue = new MethodCall(new MemberBinding(new UnaryExpression(src, NodeType.AddressOf), getValue), null);
   TypeNodeList types = sourceType.Types;
   int n = types == null ? 0 : types.Count;
   Block endOfSwitch = new Block();
   StatementList statements = new StatementList(5+n);
   statements.Add(new AssignmentStatement(src, source));
   statements.Add(new AssignmentStatement(srcOb, callGetValue));
   BlockList cases = new BlockList(n);
   statements.Add(new SwitchInstruction(callGetTag, cases));
   bool hadCoercion = false;
   Block eb = new Block(new StatementList(1));
   Construct c = new Construct(new MemberBinding(null, SystemTypes.InvalidCastException.GetConstructor()), null, SystemTypes.InvalidCastException);
   eb.Statements.Add(new Throw(c));
   for (int i = 0; i < n; i++){
     TypeNode t = types[i];
     if (t == null) continue;
     if (!explicitCoercion && !this.ImplicitCoercionFromTo(t, targetType, typeViewer)) return null;
     Expression expr = this.ExplicitCoercion(srcOb, t, typeViewer);
     if (expr == null) return null;
     expr = this.ExplicitCoercion(expr, targetType, typeViewer);
     if (expr == null) {
       cases.Add(eb);
       statements.Add(eb);
     }
     else {
       Block b = new Block(new StatementList(2));
       hadCoercion = true;
       expr.SourceContext = srcOb.SourceContext;
       b.Statements.Add(new AssignmentStatement(tgt, expr));
       b.Statements.Add(new Branch(null, endOfSwitch));
       cases.Add(b);
       statements.Add(b);
     }
   }
   if (this.Errors != null) {
     for (int ie = cErrors, ne = this.Errors.Count; ie < ne; ie++) {
       this.Errors[ie] = null;
     }
   }
   if (!hadCoercion) return null;
   statements.Add(endOfSwitch);
   statements.Add(new ExpressionStatement(tgt));
   return new BlockExpression(new Block(statements));
   //TODO: wrap this in a CoerceTypeUnion node so that source code can be reconstructed easily
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:64,代码来源:TypeSystem.cs


示例20: ParseConstruct

 private Construct/*!*/ ParseConstruct() {
   TypeNodeList varArgTypes;
   Method meth = (Method)this.GetMemberFromToken(out varArgTypes);
   int n = meth.Parameters.Count;
   Expression[] args = new Expression[n];
   ExpressionList arguments = new ExpressionList(n);
   for (int i = n-1; i >= 0; i--) args[i] = PopOperand();
   for (int i = 0; i < n; i++) arguments.Add(args[i]);
   Construct result = new Construct(new MemberBinding(null, meth), arguments);
   result.Type = meth.DeclaringType;
   return result;
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:12,代码来源:Reader.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ConstructGen类代码示例发布时间:2022-05-24
下一篇:
C# ConstraintTypes类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap