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

C# CodeDom.CodePropertySetValueReferenceExpression类代码示例

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

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



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

示例1: TypescriptPropertySetValueReferenceExpression

 public TypescriptPropertySetValueReferenceExpression(
     CodePropertySetValueReferenceExpression codeExpression, 
     CodeGeneratorOptions options)
 {
     _codeExpression = codeExpression;
     _options = options;
     System.Diagnostics.Debug.WriteLine("TypescriptPropertySetValueReferenceExpression Created");
 }
开发者ID:s2quake,项目名称:TypescriptCodeDom,代码行数:8,代码来源:TypescriptPropertySetValueReferenceExpression.cs


示例2: CreateProperty

        CodeMemberProperty CreateProperty(CodeTypeReference type, string propertyName, string fieldName, bool isValueType, bool raisePropertyChanged)
        {
            CodeMemberProperty property = new CodeMemberProperty();
            property.Type = type;
            property.Name = propertyName;
            property.Attributes = MemberAttributes.Final;
            if (GenerateInternalTypes)
                property.Attributes |= MemberAttributes.Assembly;
            else
                property.Attributes |= MemberAttributes.Public;

            CodeMethodReturnStatement propertyGet = new CodeMethodReturnStatement();
            propertyGet.Expression = new CodeFieldReferenceExpression(ThisReference, fieldName);
            property.GetStatements.Add(propertyGet);

            CodeAssignStatement propertySet = new CodeAssignStatement();
            propertySet.Left = new CodeFieldReferenceExpression(ThisReference, fieldName);
            propertySet.Right = new CodePropertySetValueReferenceExpression();
            if (raisePropertyChanged)
            {
                CodeConditionStatement ifStatement = new CodeConditionStatement();
                CodeExpression left = new CodeFieldReferenceExpression(ThisReference, fieldName);
                CodeExpression right = new CodePropertySetValueReferenceExpression();
                if (!isValueType)
                {
                    left = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(Globals.TypeOfObject),
                        "ReferenceEquals", new CodeExpression[] { left, right });
                }
                else
                {
                    left = new CodeMethodInvokeExpression(left, "Equals", new CodeExpression[] { right });
                }
                right = new CodePrimitiveExpression(true);
                ifStatement.Condition = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.IdentityInequality, right);
                ifStatement.TrueStatements.Add(propertySet);
                ifStatement.TrueStatements.Add(new CodeMethodInvokeExpression(ThisReference, RaisePropertyChangedEventMethod.Name, new CodePrimitiveExpression(propertyName)));
                property.SetStatements.Add(ifStatement);
            }
            else
                property.SetStatements.Add(propertySet);
            return property;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:42,代码来源:CodeExporter.cs


示例3: GeneratePropertySetValueReferenceExpression

		protected override void GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression e)
		{
			Output.Write("[CodePropertySetValueReferenceExpression: {0}]", e.ToString());
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:4,代码来源:CodeDOMVerboseOutputGenerator.cs


示例4: GenerateProperties


//.........这里部分代码省略.........
                    }

                    if (fi.References != null)
                    {
                        prop.GetStatements.Add(
                            new CodeMethodReturnStatement(
                            new CodeMethodInvokeExpression(
                                LoaderClass(fi.ReferencedClass),
                                "GetRef",
                                GetTransaction(),
                                new CodeCastExpression(
                                    GetReturnType(actualNotNullRepresentation, fi),
                                    getPrimaryKeyValue
                            ))));
                    }
                    else
                    {
                        prop.GetStatements.Add(
                            new CodeMethodReturnStatement(
                            new CodeCastExpression(
                            prop.Type,
                            getPrimaryKeyValue
                            )));
                    }

                    if (!classInfo.ReadOnly && !fi.ReadOnly)
                    {
                        if (classInfo.GetPrimaryKeyFields().Length == 1)
                        {
                            prop.SetStatements.Add(
                                new CodeExpressionStatement(
                                new CodeMethodInvokeExpression(
                                new CodeThisReferenceExpression(), "SetPrimaryKeyValue",
                                new CodePropertySetValueReferenceExpression())));
                        }
                        else
                        {
                            CodeExpression plainValue = new CodePropertySetValueReferenceExpression();
                            if (fi.References != null)
                                plainValue = new CodeMethodInvokeExpression(plainValue, "GetPrimaryKeyValue");
                            prop.SetStatements.Add(
                                new CodeExpressionStatement(
                                new CodeMethodInvokeExpression(
                                new CodeThisReferenceExpression(), "SetPrimaryKeySubValue",
                                plainValue,
                                new CodePrimitiveExpression(primaryKeyComponentNumber),
                                new CodePrimitiveExpression(classInfo.GetPrimaryKeyFields().Length))));
                        }
                    }
                    primaryKeyComponentNumber++;
                    continue;
                }

                if (options.NullPropagation && (fi.References != null || fi.IsNullable) && actualNullableRepresentation != PrimitiveRepresentation.Raw)
                {
                    CodeExpression retVal = new CodePrimitiveExpression(null);

                    if (fi.References == null && actualNullableRepresentation == PrimitiveRepresentation.SqlType)
                    {
                        retVal = new CodePropertyReferenceExpression(
                            new CodeTypeReferenceExpression(fi.GetNullableFieldHandler().GetSqlType()), "Null");
                    }

                    prop.GetStatements.Add(
                        new CodeConditionStatement(
                        new CodeBinaryOperatorExpression(
开发者ID:valery-shinkevich,项目名称:sooda,代码行数:67,代码来源:CodeDomClassStubGenerator.cs


示例5: GeneratePropertySetValueReferenceExpression

 protected override void GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression e)
 {
     base.Output.Write("value");
 }
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:4,代码来源:VBCodeGenerator.cs


示例6: EmitNavigationProperty

        /// <summary>
        /// Generate a navigation property
        /// </summary>
        /// <param name="target">the other end</param>
        /// <param name="referenceProperty">True to emit Reference navigation property</param>
        /// <returns>the generated property</returns>
        private CodeMemberProperty EmitNavigationProperty(RelationshipEndMember target)
        {
            CodeTypeReference typeRef = GetReturnType(target);

            // raise the PropertyGenerated event
            PropertyGeneratedEventArgs eventArgs = new PropertyGeneratedEventArgs(Item,
                                                                                  null, // no backing field
                                                                                  typeRef);
            this.Generator.RaisePropertyGeneratedEvent(eventArgs);

            // [System.ComponentModel.Browsable(false)]
            // public TargetType TargetName
            // public EntityReference<TargetType> TargetName
            // or
            // public EntityCollection<targetType> TargetNames
            CodeMemberProperty property = new CodeMemberProperty();

            // Only reference navigation properties are currently currently supported with XML serialization
            // and thus we should use the XmlIgnore and SoapIgnore attributes on other property types.
            AttributeEmitter.AddIgnoreAttributes(property);

            AttributeEmitter.AddBrowsableAttribute(property);

            AttributeEmitter.AddGeneratedCodeAttribute(property);

            CommentEmitter.EmitSummaryComments(Item, property.Comments);

            property.Name = Item.Name;

            if (eventArgs.ReturnType != null && !eventArgs.ReturnType.Equals(typeRef))
            {
                property.Type = eventArgs.ReturnType;
            }
            else
            {
                property.Type = typeRef;
            }

            property.Attributes = MemberAttributes.Final;

            CodeExpression getMethod = EmitGetMethod(target);
            CodeExpression getReturnExpression;

            if (target.RelationshipMultiplicity != RelationshipMultiplicity.Many)
            {
                property.Attributes |= AccessibilityFromGettersAndSetters(Item);

                // insert user-supplied Set code here, before the assignment
                //
                List<CodeStatement> additionalSetStatements = eventArgs.AdditionalSetStatements;
                if (additionalSetStatements != null && additionalSetStatements.Count > 0)
                {
                    try
                    {
                        property.SetStatements.AddRange(additionalSetStatements.ToArray());
                    }
                    catch (ArgumentNullException e)
                    {
                        Generator.AddError(Strings.InvalidSetStatementSuppliedForProperty(Item.Name),
                                           ModelBuilderErrorCode.InvalidSetStatementSuppliedForProperty,
                                           EdmSchemaErrorSeverity.Error,
                                           e);
                    }
                }

                CodeExpression valueRef = new CodePropertySetValueReferenceExpression();
                if (typeRef != eventArgs.ReturnType)
                {
                    // we need to cast to the actual type
                    valueRef = new CodeCastExpression(typeRef, valueRef);
                }


                CodeExpression valueProperty = getMethod;

                // get                
                //     return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<TTargetEntity>("CSpaceQualifiedRelationshipName", "TargetRoleName").Value;
                getReturnExpression = valueProperty;

                // set
                //     ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<TTargetEntity>("CSpaceQualifiedRelationshipName", "TargetRoleName").Value = value;
                property.SetStatements.Add(
                    new CodeAssignStatement(valueProperty, valueRef));

                // setup the accessibility of the navigation property setter and getter
                MemberAttributes propertyAccessibility = property.Attributes & MemberAttributes.AccessMask;
                PropertyEmitter.AddGetterSetterFixUp(Generator.FixUps, GetFullyQualifiedPropertyName(property.Name),
                    PropertyEmitter.GetGetterAccessibility(Item), propertyAccessibility, true);
                PropertyEmitter.AddGetterSetterFixUp(Generator.FixUps, GetFullyQualifiedPropertyName(property.Name),
                    PropertyEmitter.GetSetterAccessibility(Item), propertyAccessibility, false);

                List<CodeStatement> additionalAfterSetStatements = eventArgs.AdditionalAfterSetStatements;
                if (additionalAfterSetStatements != null && additionalAfterSetStatements.Count > 0)
                {
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:NavigationPropertyEmitter.cs


示例7: Visit

			public void Visit (CodePropertySetValueReferenceExpression o)
			{
				g.GeneratePropertySetValueReferenceExpression (o);
			}
开发者ID:carrie901,项目名称:mono,代码行数:4,代码来源:CodeGenerator.cs


示例8: GeneratePropertySetValueReferenceExpression

 private  void GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression e) {
     Output.Write("value");
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:3,代码来源:csharpcodeprovider.cs


示例9: GenerateSetInstanceVariableStatement

 /// <summary>
 /// Generates the "SetInstanceVariable" statement.
 /// </summary>
 /// <returns>The "SetInstanceVariable" statement.</returns>
 /// <param name="thisRef">This reference.</param>
 /// <param name="typeRef">Type reference.</param>
 /// <param name="nameRef">Name reference.</param>
 /// <param name="valueRef">Value reference</param>
 protected override CodeExpression GenerateSetInstanceVariableStatement(CodeThisReferenceExpression thisRef, CodeTypeReference typeRef, CodePrimitiveExpression nameRef, CodePropertySetValueReferenceExpression valueRef)
 {
     throw new NotImplementedException();
 }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:12,代码来源:FSharpCodeBehindGenerator.cs


示例10: CreateConstantSetters

		private void CreateConstantSetters(IShaderDom shader, Action<CodeTypeMember, string> add, string name, CodeExpression assignmentField, CodeExpression assignmentArrayField)
		{
			/*
			 * Something like:

			public void SetInvTargetSize(ref Microsoft.Xna.Framework.Vector2 value)
			{
				this.vreg.SetVector2(130, ref value);
			}

			public Microsoft.Xna.Framework.Vector2 InvTargetSize
			{
				set
				{
					this.SetInvTargetSize(ref value);
				}
			}*/

			Register reg;
			Type dataType;
			bool hasSetMethod;
			int stride;

			if (!ExtractRegType(name, out reg, out dataType, out hasSetMethod, out stride))
				return;

			Type arrayOrSingleType = dataType;

			//right...

			//create the method of the given type.


			//public void SetInvTargetSize(ref Microsoft.Xna.Framework.Vector2 value)
			CodeStatementCollection methodStatements = new CodeStatementCollection();

			CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(dataType, "value");
			List<CodeParameterDeclarationExpression> additionalParams = new List<CodeParameterDeclarationExpression>();

			if (reg.ArraySize == -1)
				param.Direction = FieldDirection.Ref;
			else
			{
				arrayOrSingleType = dataType.MakeArrayType();
				param.Type = new CodeTypeReference(arrayOrSingleType);

				//add array params, readIndex, writeIndex, count
				additionalParams.Add(new CodeParameterDeclarationExpression(typeof(uint), "readIndex"));
				additionalParams.Add(new CodeParameterDeclarationExpression(typeof(uint), "writeIndex"));
				additionalParams.Add(new CodeParameterDeclarationExpression(typeof(uint), "count"));
			}

			CodeExpression valueRef = new CodeArgumentReferenceExpression(param.Name);

			//when there isn't a set method, there is just a set property
			if (!hasSetMethod)
				valueRef = new CodePropertySetValueReferenceExpression();

			//create the guts
			//depends on what constants use it...

			//eg:
			//this.vreg.SetVector2(130, ref value);

			Register sreg;

			if (dataType == typeof(bool))
			{
				//special case for booleans, assign the array directly.
				//looks like:
				// 
				// if (preg_bool[index] != value)
				// {
				//  preg_bool[index] = value;
				//  preg_bool_changed = true;
				// }

				foreach (KeyValuePair<AsmListing, CodeExpression> listing in listingRegisters)
				{
					RegisterSet registers = listing.Key.RegisterSet;
					CodeExpression registersRef = listing.Value;

					if (registers.TryGetRegister(name, out sreg))
					{
						if (listing.Key == asm.PixelShader)
						{
							CodeExpression arrayIndex = new CodeArrayIndexerExpression(shader.PixelShaderBooleanRegistersRef, new CodePrimitiveExpression(sreg.Index));

							CodeStatement assign = new CodeAssignStatement(arrayIndex, new CodePropertySetValueReferenceExpression());
							CodeStatement change = new CodeAssignStatement(shader.PixelShaderBooleanRegistersChangedRef, new CodePrimitiveExpression(true));

							CodeStatement condition = new CodeConditionStatement(
								new CodeBinaryOperatorExpression(arrayIndex, CodeBinaryOperatorType.IdentityInequality, new CodePropertySetValueReferenceExpression()),
								new CodeStatement[]{assign, change});

							methodStatements.Add(condition);
						}
						if (listing.Key == asm.VertexShader)
						{
							CodeExpression arrayIndex = new CodeArrayIndexerExpression(shader.VertexShaderBooleanRegistersRef, new CodePrimitiveExpression(sreg.Index));
//.........这里部分代码省略.........
开发者ID:shadarath,项目名称:Wirtualna-rzeczywistosc,代码行数:101,代码来源:Constants.cs


示例11: EmitBasicClassMembers


//.........这里部分代码省略.........
                "ReferenceEquals");
            CodeFieldReferenceExpression internalSyncObjectFieldReference = new CodeFieldReferenceExpression(null, InternalSyncObjectFieldName);
            CodeMethodInvokeExpression referenceEqualInvokeExpression = new CodeMethodInvokeExpression(referenceEqualsMethodReference,
                new CodeExpression[] { internalSyncObjectFieldReference, new CodePrimitiveExpression(null) });
            CodeObjectCreateExpression objectCreateExpression = new CodeObjectCreateExpression(objectTypeReference, new CodeExpression[] {});
            CodeMethodReferenceExpression compareExchangeMethodReference = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(interlockedCodeTypeReference),
                "CompareExchange");
            CodeMethodInvokeExpression compareExchangeMethodInvokeExpression = new CodeMethodInvokeExpression(compareExchangeMethodReference,
                new CodeDirectionExpression(FieldDirection.Ref, internalSyncObjectFieldReference), objectCreateExpression,
                new CodePrimitiveExpression(null));
            internalSyncObjectProperty.GetStatements.Add(new CodeConditionStatement(referenceEqualInvokeExpression,
                new CodeExpressionStatement(compareExchangeMethodInvokeExpression)));
            internalSyncObjectProperty.GetStatements.Add(new CodeMethodReturnStatement(internalSyncObjectFieldReference));

            AddComments(internalSyncObjectProperty, InternalSyncObjectPropertyComment);

            // Generation of the ResourceManager property
            CodeMemberProperty resourceManagerProperty = new CodeMemberProperty();
            resourceClass.Members.Add(resourceManagerProperty);
            resourceManagerProperty.Name = ResMgrPropertyName;
            resourceManagerProperty.HasGet = true;
            resourceManagerProperty.HasSet = false;
            resourceManagerProperty.Type = resourceManagerTypeReference;
            /*if (internalClass)
                resourceManagerProperty.Attributes = MemberAttributes.Assembly;
            else*///Ð
                resourceManagerProperty.Attributes = MemberAttributes.Public;

            if (useStatic)
                resourceManagerProperty.Attributes |= MemberAttributes.Static;

            CodeTypeReference eitorBrowsableTypeReference = new CodeTypeReference(typeof(EditorBrowsableState));
            eitorBrowsableTypeReference.Options = CodeTypeReferenceOptions.GlobalReference;
            CodeAttributeArgument codeAttributeArgument = new CodeAttributeArgument(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(eitorBrowsableTypeReference), "Advanced"));
            CodeAttributeDeclaration codeAttributeDeclaration = new CodeAttributeDeclaration("System.ComponentModel.EditorBrowsableAttribute", new CodeAttributeArgument[] { codeAttributeArgument });
            codeAttributeDeclaration.AttributeType.Options = CodeTypeReferenceOptions.GlobalReference;
            resourceManagerProperty.CustomAttributes.Add(codeAttributeDeclaration);

            CodeFieldReferenceExpression resourceManagerFieldReference = new CodeFieldReferenceExpression(null, ResMgrFieldName);
            CodeMethodInvokeExpression referenceEqualsMethodInvokeExpression = new CodeMethodInvokeExpression(referenceEqualsMethodReference,
                resourceManagerFieldReference, new CodePrimitiveExpression(null));

            CodeTypeReference monitorCodeTypeReference = new CodeTypeReference(typeof(Monitor), CodeTypeReferenceOptions.GlobalReference);

            CodeMethodReferenceExpression monitorEnterMethodReference = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(monitorCodeTypeReference),
                "Enter");
            CodePropertyReferenceExpression internalSyncObjectPropertyReference = new CodePropertyReferenceExpression(null, InternalSyncObjectPropertyName);
            CodeMethodInvokeExpression monitorEnterMethodInvokeExpression = new CodeMethodInvokeExpression(monitorEnterMethodReference,
                internalSyncObjectPropertyReference);

            CodePropertyReferenceExpression assemblyPropertyReference = new CodePropertyReferenceExpression(new CodeTypeOfExpression(new CodeTypeReference(resourceClass.Name)),
                "Assembly");
            CodeObjectCreateExpression resourceManagerCreateExpression = new CodeObjectCreateExpression(resourceManagerTypeReference,
                new CodePrimitiveExpression(logicalName), assemblyPropertyReference); //logicalName changed by Ðonny

            CodeMethodReferenceExpression interlockedExchangeMethodReference = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(interlockedCodeTypeReference),
                "Exchange");
            CodeMethodInvokeExpression interlockedExchangeMethodInvokeExpression = new CodeMethodInvokeExpression(interlockedExchangeMethodReference,
                new CodeDirectionExpression(FieldDirection.Ref, resourceManagerFieldReference), resourceManagerCreateExpression);

            CodeMethodReferenceExpression monitorExitMethodReference = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(monitorCodeTypeReference),
                "Exit");
            CodeMethodInvokeExpression monitorExitMethodInvokeExpression = new CodeMethodInvokeExpression(monitorExitMethodReference,
                internalSyncObjectPropertyReference);

            CodeTryCatchFinallyStatement tryFinallyStatement = new CodeTryCatchFinallyStatement();
            tryFinallyStatement.TryStatements.Add(new CodeConditionStatement(referenceEqualsMethodInvokeExpression,
                new CodeExpressionStatement(interlockedExchangeMethodInvokeExpression)));
            tryFinallyStatement.FinallyStatements.Add(monitorExitMethodInvokeExpression);

            resourceManagerProperty.GetStatements.Add(new CodeConditionStatement(referenceEqualsMethodInvokeExpression,
                new CodeExpressionStatement(monitorEnterMethodInvokeExpression), tryFinallyStatement));
            resourceManagerProperty.GetStatements.Add(new CodeMethodReturnStatement(resourceManagerFieldReference));

            AddComments(resourceManagerProperty, ResMgrPropertyComment);

            // Generation of the Culture property
            CodeMemberProperty cultureProperty = new CodeMemberProperty();
            resourceClass.Members.Add(cultureProperty);
            cultureProperty.Name = CultureInfoPropertyName;
            cultureProperty.HasGet = true;
            cultureProperty.HasSet = true;
            cultureProperty.Type = cultureInfoTypeReference;
            /*if (internalClass)
                cultureProperty.Attributes = MemberAttributes.Assembly;
            else*///Ð
                cultureProperty.Attributes = MemberAttributes.Public;

            if (useStatic)
                cultureProperty.Attributes |= MemberAttributes.Static;
            cultureProperty.CustomAttributes.Add(codeAttributeDeclaration);

            CodeFieldReferenceExpression resourceCultureFieldReference = new CodeFieldReferenceExpression(null, CultureInfoFieldName);
            cultureProperty.GetStatements.Add(new CodeMethodReturnStatement(resourceCultureFieldReference));

            CodePropertySetValueReferenceExpression codePropertySetValueReferenceExpression = new CodePropertySetValueReferenceExpression();
            cultureProperty.SetStatements.Add(new CodeAssignStatement(resourceCultureFieldReference, codePropertySetValueReferenceExpression));

            AddComments(cultureProperty, CulturePropertyComment1, CulturePropertyComment2);
        }
开发者ID:wskplho,项目名称:Tools,代码行数:101,代码来源:StronglyTypedResourceBuilderEx.cs


示例12: Generate

 public void Generate(CodePropertySetValueReferenceExpression expression)
 {
     Write("value");
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:4,代码来源:RubyCodeGenerator.cs


示例13: Write

 private void Write(CodePropertySetValueReferenceExpression e){
   this.writer.Write("value");
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:3,代码来源:Compiler.cs


示例14: CreateDocTypes

        private void CreateDocTypes(IEnumerable<DocType> docTypes, CodeNamespace ns)
        {
            foreach (var docType in docTypes)
            {
                string genName = docType.TypeName;

                CodeCompileUnit currUnit = new CodeCompileUnit();

                currUnit.Namespaces.Add(ns);

                //create class
                CodeTypeDeclaration currClass = new CodeTypeDeclaration(genName);
                //create the custom attribute
                CodeAttributeDeclarationCollection classAttributes = new CodeAttributeDeclarationCollection(
                    new CodeAttributeDeclaration[] {
                        new CodeAttributeDeclaration("UmbracoInfo",
                            new CodeAttributeArgument(new CodePrimitiveExpression(docType.Alias))
                            ),
                        new CodeAttributeDeclaration("DocType")
                    });

                if (!Args.IsInterface)
                {
                    classAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DataContractAttribute))));
                }

                //add the address to the class
                currClass.CustomAttributes.AddRange(classAttributes);

                currClass.IsClass = true;
                //add the summary decoration
                currClass.Comments.AddRange(GenerateSummary(docType.Description));
                //set up the type
                currClass.TypeAttributes = TypeAttributes.Public;
                if (docType.ParentId > 0)
                {
                    string typeName = docTypes.Single(d => d.Id == docType.ParentId).TypeName;

                    if (!Args.IsInterface)
                    {
                        currClass.BaseTypes.Add(new CodeTypeReference(typeName)); //docType inheritance
                    }
                    else
                    {
                        currClass.BaseTypes.Add(new CodeTypeReference("I" + typeName)); //docType inheritance of interface type
                    }
                }
                else
                {
                    if (!Args.IsInterface)
                    {
                        currClass.BaseTypes.Add(new CodeTypeReference("DocTypeBase")); //base class
                    }
                    else
                    {
                        currClass.BaseTypes.Add(new CodeTypeReference("IDocTypeBase")); //base interface
                    }
                }
                if (!Args.IsInterface)
                {
                    currClass.IsPartial = true;
                }
                else
                {
                    currClass.IsInterface = true;
                    currClass.Name = "I" + currClass.Name;
                }

                currClass.Members.AddRange(GenerateConstructors());

                #region Doc Type Properties
                foreach (var docTypeProperty in docType.Properties)
                {
                    CodeMemberField valueField = new CodeMemberField();
                    valueField.Attributes = MemberAttributes.Private;
                    valueField.Name = "_" + docTypeProperty.TypeName;
                    valueField.Type = new CodeTypeReference(docTypeProperty.DatabaseType);
                    currClass.Members.Add(valueField);

                    //store the umbraco data in an attribute.
                    CodeMemberProperty p = new CodeMemberProperty();
                    p.CustomAttributes.AddRange(GenerateDocTypePropertyAttributes(docTypeProperty));

                    p.Name = docTypeProperty.TypeName;
                    p.Type = new CodeTypeReference(docTypeProperty.DatabaseType);
                    p.Attributes = MemberAttributes.Public;
                    p.HasGet = true;
                    p.HasSet = false;
                    p.GetStatements.Add(new CodeMethodReturnStatement(
                        new CodeFieldReferenceExpression(
                            new CodeThisReferenceExpression(), valueField.Name))
                        );

                    #region Set statement
                    //have a conditional statment so we can use the INotifyChanging and INotifyChanged events
                    CodeExpression left = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), valueField.Name);
                    CodeExpression right = new CodePropertySetValueReferenceExpression();

                    CodeExpression cond = GenerateInequalityConditionalStatement(left, right);

//.........这里部分代码省略.........
开发者ID:jracabado,项目名称:justEdit-,代码行数:101,代码来源:ClassGenerator.cs


示例15: CreateProperty

 private CodeMemberProperty CreateProperty(CodeTypeReference type, string propertyName, string fieldName, bool isValueType)
 {
     CodeMemberProperty property = new CodeMemberProperty {
         Type = type,
         Name = propertyName,
         Attributes = MemberAttributes.Final
     };
     if (this.GenerateInternalTypes)
     {
         property.Attributes |= MemberAttributes.Assembly;
     }
     else
     {
         property.Attributes |= MemberAttributes.Public;
     }
     CodeMethodReturnStatement statement = new CodeMethodReturnStatement {
         Expression = new CodeFieldReferenceExpression(this.ThisReference, fieldName)
     };
     property.GetStatements.Add(statement);
     CodeAssignStatement statement2 = new CodeAssignStatement {
         Left = new CodeFieldReferenceExpression(this.ThisReference, fieldName),
         Right = new CodePropertySetValueReferenceExpression()
     };
     if (this.EnableDataBinding && this.SupportsDeclareEvents)
     {
         CodeConditionStatement statement3 = new CodeConditionStatement();
         CodeExpression targetObject = new CodeFieldReferenceExpression(this.ThisReference, fieldName);
         CodeExpression right = new CodePropertySetValueReferenceExpression();
         if (!isValueType)
         {
             targetObject = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(Globals.TypeOfObject), "ReferenceEquals", new CodeExpression[] { targetObject, right });
         }
         else
         {
             targetObject = new CodeMethodInvokeExpression(targetObject, "Equals", new CodeExpression[] { right });
         }
         right = new CodePrimitiveExpression(true);
         statement3.Condition = new CodeBinaryOperatorExpression(targetObject, CodeBinaryOperatorType.IdentityInequality, right);
         statement3.TrueStatements.Add(statement2);
         statement3.TrueStatements.Add(new CodeMethodInvokeExpression(this.ThisReference, this.RaisePropertyChangedEventMethod.Name, new CodeExpression[] { new CodePrimitiveExpression(propertyName) }));
         property.SetStatements.Add(statement3);
         return property;
     }
     property.SetStatements.Add(statement2);
     return property;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:CodeExporter.cs


示例16: AddOutletProperty

		static void AddOutletProperty (CodeTypeReference outletAtt, CodeTypeDeclaration type, string name,
			CodeTypeReference typeRef)
		{
			var fieldName = "__impl_" + name;
			var field = new CodeMemberField (typeRef, fieldName);
			
			var prop = new CodeMemberProperty () {
				Name = name,
				Type = typeRef
			};
			AddAttribute (prop.CustomAttributes, outletAtt, name);
			
			var setValue = new CodePropertySetValueReferenceExpression ();
			var thisRef = new CodeThisReferenceExpression ();
			var fieldRef = new CodeFieldReferenceExpression (thisRef, fieldName);
			
			prop.SetStatements.Add (new CodeAssignStatement (fieldRef, setValue));
			prop.GetStatements.Add (new CodeMethodReturnStatement (fieldRef));
			
			prop.Attributes = field.Attributes = (prop.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Private;
			
			type.Members.Add (prop);
			type.Members.Add (field);
		}
开发者ID:JoeRobich,项目名称:monodevelop,代码行数:24,代码来源:NSObjectTypeInfo.cs


示例17: ReplaceSetValue

        private void ReplaceSetValue(ref CodeObject target, CodeObject parent, int indent)
        {
            CodeVariableReferenceExpression variableRefExpr = target as CodeVariableReferenceExpression;

            if (variableRefExpr != null && StringUtils.CaseInsensitiveEquals(variableRefExpr.VariableName, _name))
            {
                target = new CodePropertySetValueReferenceExpression();
            }
        }
开发者ID:Saleslogix,项目名称:SLXMigration,代码行数:9,代码来源:ReturnValueCorrector.cs


示例18: GeneratePropertySetValueReferenceExpression

 /// <summary>
 /// Generates code for the specified property set value reference expression.
 /// </summary>
 /// <remarks>Not supported.</remarks>
 protected override void GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression e)
 {
     throw new Exception("The method or operation is not implemented.");
 }
开发者ID:jdluzen,项目名称:Phalanger,代码行数:8,代码来源:PhpGenerator.CLR.cs


示例19: ProcessType

		static void ProcessType(Type type, CodeTypeDeclaration ctd)
		{
			foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
				ctd.AddField(ConvertType(field.FieldType), field.Name).Attributes = 0;
			}
			foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
				EasyProperty p = ctd.AddProperty(ConvertType(field.FieldType), GetPropertyName(field.Name));
				p.Getter.Return(Easy.Var(field.Name));
				CodeExpression ex;
				if (field.FieldType.IsValueType)
					ex = new CodePropertySetValueReferenceExpression();
				else
					ex = GetDefaultValue("value", field);
				p.Setter.Assign(Easy.Var(field.Name), ex);
				if (typeof(INode).IsAssignableFrom(field.FieldType)) {
					if (typeof(INullable).IsAssignableFrom(field.FieldType)) {
						p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\tif (!" +field.Name+".IsNull) "+field.Name+".Parent = this;"));
					} else {
						p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\t"+field.Name+".Parent = this;"));
					}
				}
			}
			foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
				CodeConstructor c = new CodeConstructor();
				if (type.IsAbstract)
					c.Attributes = MemberAttributes.Family;
				else
					c.Attributes = MemberAttributes.Public;
				ctd.Members.Add(c);
				ConstructorInfo baseCtor = GetBaseCtor(type);
				foreach(ParameterInfo param in ctor.GetParameters()) {
					c.Parameters.Add(new CodeParameterDeclarationExpression(ConvertType(param.ParameterType),
					                                                        param.Name));
					if (baseCtor != null && Array.Exists(baseCtor.GetParameters(), delegate(ParameterInfo p) { return param.Name == p.Name; }))
						continue;
					c.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(GetPropertyName(param.Name)),
					                                         new CodeVariableReferenceExpression(param.Name)));
				}
				if (baseCtor != null) {
					foreach(ParameterInfo param in baseCtor.GetParameters()) {
						c.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(param.Name));
					}
				}
				// initialize fields that were not initialized by parameter
				foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
					if (field.FieldType.IsValueType && field.FieldType != typeof(Location))
						continue;
					if (Array.Exists(ctor.GetParameters(), delegate(ParameterInfo p) { return field.Name == p.Name; }))
						continue;
					c.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(field.Name),
					                                         GetDefaultValue(null, field)));
				}
			}
		}
开发者ID:ThomasZitzler,项目名称:ILSpy,代码行数:54,代码来源:Main.cs


示例20: CreatePropertyDeclaration

 internal CodeMemberProperty CreatePropertyDeclaration(CodeMemberField field, string name, string typeName)
 {
     CodeMemberProperty property;
     property = new CodeMemberProperty {
         Type = new CodeTypeReference(typeName),
         Name = name,
         Attributes = (property.Attributes & ~MemberAttributes.AccessM 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CodeDom.CodeSnippetExpression类代码示例发布时间:2022-05-26
下一篇:
C# CodeDom.CodePropertyReferenceExpression类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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