public bool PerformTask(TargetLevelCodeGeneratorPipelineState manager) { var targetCodeBehind = new TypeDeclaration { ClassType = ClassType.Class, Modifiers = manager.TargetSourceTypeDeclaration.Modifiers, // this should include partial Name = manager.TargetSourceTypeDeclaration.Name }; var codeGenerator = new CodeGeneratorProxy( targetCodeBehind, addCodeGeneratedAttribute: true); //implement TargetCodeBehindPlan.MixinInterfaces manager.CodeGenerationPlan.TargetCodeBehindPlan.MixinInterfaces .Map(i => codeGenerator.ImplementInterface(i.GetOriginalFullNameWithGlobal())); //Save targetCodeBehind to state manager.TargetCodeBehindTypeDeclaration = targetCodeBehind; //Add targetCodeGehind to Syntax Tree manager.CodeBehindSyntaxTree.AddChildTypeDeclaration (targetCodeBehind, manager.TargetSourceTypeDeclaration.GetParent <NamespaceDeclaration>()); return(true); }
private void ImplementIContainsMixin( CodeGeneratorProxy codeBehind, MixinGenerationPlan mgp) { var containMixinInterfaceName = string.Format( "global::{0}.{1}<{2}>", typeof(IContainMixin <>).Namespace, "IContainMixin", mgp.MixinAttribute.Mixin.GetOriginalFullNameWithGlobal()); codeBehind.ImplementInterface( containMixinInterfaceName); codeBehind.CreateProperty( modifier: //implement explicitly string.Empty, returnTypeFullName: mgp.MixinAttribute.Mixin.GetOriginalFullNameWithGlobal(), propertyName: containMixinInterfaceName + ".MixinInstance", getterMethodBody: string.Format( "get{{ return {0}.{1}; }}", mgp.MasterWrapperPlan.MasterWrapperInstanceNameAvailableFromTargetCodeBehind, MasterWrapperPlan.MixinInstanceDataMemberName), setterMethodBody: //no setter string.Empty ); }
public bool PerformTask(TargetLevelCodeGeneratorPipelineState manager) { var codeGeneratorProxy = new CodeGeneratorProxy(manager.TargetCodeBehindTypeDeclaration); foreach (var mixinPlan in manager.CodeGenerationPlan.MixinGenerationPlans.Values) { codeGeneratorProxy.ImplementInterface( mixinPlan.ExternalMixinSpecificAutoGeneratedNamespaceName.EnsureEndsWith(".") + mixinPlan.RequirementsInterfacePlan.RequirementsInterfaceName); } return(true); }
public bool PerformTask(TargetLevelCodeGeneratorPipelineState manager) { var codeGeneratorProxy = new CodeGeneratorProxy(manager.TargetCodeBehindTypeDeclaration); manager.CodeGenerationPlan.MixinGenerationPlans.Values .Where(mgp => mgp.AddIMixinConstructorRequirementInterface) .Map(mgp => codeGeneratorProxy.ImplementInterface( string.Format("{0}.{1}<{2}>", typeof(IMixinConstructorRequirement <>).Namespace, "IMixinConstructorRequirement", mgp.MasterWrapperPlan.MixinInstanceTypeFullName ) ) ); return(true); }