public override void TranslateTypes <TItem, TDom>(ITypeParent parent, IDeclaredTypes <TItem, TDom> ambigTypes) { foreach (IDeclaredType <TDom> ambigDeclType in ambigTypes.Values) { //Emit the root, if it exists as a child of the type, //-or- if the type is segmentable, the parent is segmentable, and the instances //align. if ((ambigDeclType.ParentTarget == parent) || ((!(options.AllowPartials)) && (parent is ISegmentableDeclarationTarget) && (ambigDeclType.ParentTarget is ISegmentableDeclarationTarget) && (((ISegmentableDeclarationTarget)(parent)).GetRootDeclaration() == ((ISegmentableDeclarationTarget)(ambigDeclType.ParentTarget)).GetRootDeclaration()))) { TranslateType(ambigDeclType); } //Don't exclude the possibility that a partial of the same type //might have been inserted into the -same- parent instance. //Not likely, but possible and legal. But only legal if partials are. if (options.AllowPartials && (ambigDeclType is ISegmentableDeclaredType)) { foreach (IDeclaredType <TDom> ambigDeclTypePartial in ((ISegmentableDeclaredType)(ambigDeclType)).Partials) { if (ambigDeclTypePartial.ParentTarget == parent) { TranslateType(ambigDeclTypePartial); } } } } }
/// <summary> /// Creates a new instance of <see cref="DeclarationResources"/> with the <paramref name="name"/> /// and <paramref name="parentTarget"/> provided. /// </summary> /// <param name="parentTarget">The <see cref="ITypeParent"/> which contains the <see cref="DeclarationResources"/>.</param> public DeclarationResources(ITypeParent parentTarget) : base(GetName(parentTarget), parentTarget) { base.IsStatic = true; base.IsSealed = false; base.IsAbstract = false; this.AccessLevel = DeclarationAccessLevel.Internal; }
/// <summary> /// Creates a new <see cref="SegmentableParameteredType{TItem, TDom, TPartials}"/> with /// the <paramref name="basePartial"/> and <paramref name="parentTarget"/> provided. /// </summary> /// <param name="basePartial">The base partial which created the <see cref="SegmentableParameteredType{TItem, TDom, TPartials}"/>.</param> /// <param name="parentTarget">The <see cref="ITypeParent"/> which could potentially be a segment of the /// original parent.</param> internal SegmentableParameteredType(TItem basePartial, ITypeParent parentTarget) : base(parentTarget) { this.basePartial = basePartial; if (parentTarget is INameSpaceDeclaration) { CheckModule(); } }
public TItem AddNew(ITypeParent parentTarget) { if ((parentTarget is ISegmentableDeclarationTarget && this.RootDeclaration.ParentTarget is ISegmentableDeclarationTarget && ((ISegmentableDeclarationTarget)parentTarget).GetRootDeclaration().Equals(((ISegmentableDeclarationTarget)(this.RootDeclaration.ParentTarget)).GetRootDeclaration())) || parentTarget == this.RootDeclaration.ParentTarget) { TItem partial = this.GetNewPartial(parentTarget); base.baseList.Add(partial); return(partial); } throw new InvalidOperationException("Type-hierarchy must be identical to the root declaration"); }
/// <summary> /// Obtains a new partial of the <see cref="IClassType"/> relative to /// <see cref="SegmentableDeclaredTypePartials{TItem, TDom}.RootDeclaration"/>. /// </summary> /// <returns>A new instance of an <see cref="IClassType"/> partial implementation if successful.</returns> /// <exception cref="System.InvalidOperationException"><see cref="ClassPartials"/> is in an /// invalid state.</exception> protected override IClassType GetNewPartial(ITypeParent parent) { if (base.RootDeclaration is IDeclarationResources) { return(new DeclarationResources((IDeclarationResources)this.RootDeclaration, parent)); } else { return(new ClassType(this.RootDeclaration, parent)); } }
/// <summary> /// Creates a new instance of <see cref="ClassType"/> with the <paramref name="name"/> /// and <paramref name="parentTarget"/> provided. /// </summary> /// <param name="name">The name of the <see cref="ClassType"/>.</param> /// <param name="parentTarget">The <see cref="ITypeParent"/> which contains the <see cref="ClassType"/>.</param> protected internal ClassType(string name, ITypeParent parentTarget) : base(name, parentTarget) { if (parentTarget is IType) { this.AccessLevel = DeclarationAccessLevel.Private; } else { this.AccessLevel = DeclarationAccessLevel.Public; } }
private static string GetName(ITypeParent parentTarget) { string baseName = res.ResourcesAutoClassName; if (parentTarget is IDeclaredType) { Guid g = Guid.NewGuid(); return(string.Format("{0}_{1}", baseName, g.ToString("N").Substring(0, 6))); } else { return(baseName); } }
private static string BuildVariedName(this ITypeParent target, bool shortFormGeneric = false, bool numericTypeParams = false, TypeParameterDisplayMode typeParameterDisplayMode = TypeParameterDisplayMode.SystemStandard) { if (target is IMember) { return(((IMember)(target)).BuildMemberName(shortFormGeneric, numericTypeParams, typeParameterDisplayMode)); } else if (target is IType) { return(((IType)(target)).BuildTypeName(shortFormGeneric, numericTypeParams, typeParameterDisplayMode)); } else if (target is INamespaceDeclaration) { return(((INamespaceDeclaration)target).FullName); } throw new ArgumentException("Unrecognized entity in type nesting chain."); }
private ITypeParent OnGetParentImpl() { ITypeParent declParent = this.Original.Parent; if (declParent == null) { return(null); } else { if (this.Original.IsGenericConstruct) { if (declParent is IGenericType) { IGenericType genericParent = ((IGenericType)(declParent)); if (genericParent.IsGenericConstruct) { if (!genericParent.IsGenericDefinition) { genericParent = (IGenericType)genericParent.ElementType; } return((ITypeParent)genericParent.MakeGenericClosure(this.GenericParameters.Take(genericParent.GenericParameters.Count).ToCollection())); } else { return((ITypeParent)genericParent); } } else if (declParent is IMethodMember) { IMethodMember genericParent = ((IMethodMember)(declParent)); if (genericParent.IsGenericConstruct) { if (!genericParent.IsGenericDefinition) { genericParent = (IMethodMember)genericParent.GetGenericDefinition(); } return((ITypeParent)genericParent.MakeGenericClosure(this.GenericParameters.Take(genericParent.GenericParameters.Count).ToCollection())); } } } return(declParent); } }
private ITypeParent OnGetParentImpl() { ITypeParent declType = this.Original.Parent; if (declType == null) return null; else { if (this.Original.IsGenericConstruct && declType is IGenericType) { IGenericType genericParent = ((IGenericType)(declType)); if (genericParent.IsGenericConstruct) { if (!genericParent.IsGenericDefinition) genericParent = (IGenericType)genericParent.ElementType; return (ITypeParent)genericParent.MakeGenericClosure(this.GenericParameters.Take(genericParent.GenericParameters.Count).ToCollection()); } else return (ITypeParent)genericParent; } else return declType; } }
public EnumeratorTypes(ITypeParent targetDeclaration) : base(targetDeclaration) { }
public DeclaredType(ITypeParent parentTarget) : base(parentTarget) { }
/// <summary> /// Creates a new instance of <see cref="DeclaredType{TDom}"/> with the <paramref name="name"/> and /// <paramref name="parentTarget"/> provided. /// </summary> /// <param name="name">The name of the <see cref="DeclaredType{TDom}"/>.</param> /// <param name="parentTarget">The <see cref="ITypeParent"/> which contains the <see cref="DeclaredType{TDom}"/>.</param> public DeclaredType(string name, ITypeParent parentTarget) : base(name, parentTarget) { }
public IStructTypes GetPartialClone(ITypeParent partialTarget) { return(new StructTypes(partialTarget, this)); }
internal StructTypes(ITypeParent partialTarget, StructTypes sibling) : base(partialTarget, sibling) { }
public abstract void TranslateTypeParentTypes(ITypeParent parent);
public IEnumeratorTypes GetPartialClone(ITypeParent partialTarget) { return(new EnumeratorTypes(partialTarget, this)); }
ISegmentableDeclaredType ISegmentableDeclaredTypePartials.AddNew(ITypeParent parentTarget) { return(this.AddNew(parentTarget)); }
public virtual void TranslateTypes(ITypeParent parent, IStructTypes structTypes) { TranslateTypes <IStructType, CodeTypeDeclaration>(parent, structTypes); }
public virtual void TranslateTypes(ITypeParent parent, IInterfaceTypes interfaceTypes) { TranslateTypes <IInterfaceType, CodeTypeDeclaration>(parent, interfaceTypes); }
public virtual void TranslateTypes(ITypeParent parent, IEnumeratorTypes enumTypes) { TranslateTypes <IEnumeratorType, CodeTypeDeclaration>(parent, enumTypes); }
public virtual void TranslateTypes(ITypeParent parent, IDelegateTypes delegateTypes) { TranslateTypes <IDelegateType, CodeTypeDelegate>(parent, delegateTypes); }
public virtual void TranslateTypes(ITypeParent parent, IClassTypes classTypes) { TranslateTypes <IClassType, CodeTypeDeclaration>(parent, classTypes); }
public EnumeratorTypes(ITypeParent targetDeclaration, EnumeratorTypes sibling) : base(targetDeclaration, sibling) { }
protected override IDeclaredTypes <IEnumeratorType, CodeTypeDeclaration> OnGetPartialClone(ITypeParent partialTarget) { return(this.GetPartialClone(partialTarget)); }
/// <summary> /// Creates a new instance of <see cref="StructTypes"/> denoting the <see cref="ITypeParent"/> /// that members are children of initially. /// </summary> internal StructTypes(ITypeParent targetDeclaration) : base(targetDeclaration) { }
/// <summary> /// Obtains a new partial of the <typeparamref name="TItem"/> relative to /// <see cref="RootDeclaration"/>. /// </summary> /// <returns>A new instance of <typeparamref name="TItem"/> if successful.</returns> /// <exception cref="System.InvalidOperationException"><see cref="SegmentableDeclaredTypePartials{TItem, TDom}"/> is in an /// invalid state.</exception> protected abstract TItem GetNewPartial(ITypeParent parent);
public override void TranslateTypeParentTypes(ITypeParent parent) { /* * * lastBlockFlag ensures that the null line is only inserted if the last block * -with members- is present. This way if the delegates were null but the * classes had members, the enumerators check on the lastblockflag still checks * out with the 'classes' block. * */ ISegmentableDeclarationTarget seggedMember = null; if (!options.AllowPartials && parent is ISegmentableDeclarationTarget && ((ISegmentableDeclarationTarget)(parent)).IsPartial) { return; } else if (parent is ISegmentableDeclarationTarget) { seggedMember = (ISegmentableDeclarationTarget)parent; } bool lastBlockFlag = false; string regionText = ""; bool useRegion = false; if (!(parent.Classes == null && parent.Delegates == null && parent.Enumerators == null && parent.Interfaces == null && parent.Structures == null)) { useRegion = (!(parent is INameSpaceDeclaration)) && (!(parent is IDeclarationResources)) && options.AutoRegionsFor(AutoRegionAreas.NestedTypes) && (options.AllowPartials && seggedMember != null && (parent.Classes.GetCountForTarget(parent) > 0 || parent.Delegates.GetCountForTarget(parent) > 0 || parent.Enumerators.GetCountForTarget(parent) > 0 || parent.Interfaces.GetCountForTarget(parent) > 0 || parent.Structures.GetCountForTarget(parent) > 0) || ((seggedMember == null) && (parent.GetTypeCount() > 0))); } if (useRegion) { regionText = String.Format(_OIL._Core.MaintenanceResources.AutoRegions_BasePattern, parent.Name, _OIL._Core.MaintenanceResources.AutoRegions_NestedTypes); TranslateConceptRegionStart(regionText); } if ((!(parent is IIntermediateProject)) && !(parent is IDeclarationResources) && parent is IResourceable) { if (((IResourceable)parent).Resources != null && ((IResourceable)parent).Resources.GetMemberCount(false) > 0) { if ((options.AllowPartials) || (parent is ISegmentableDeclarationTarget && ((ISegmentableDeclarationTarget)(parent)).IsRoot)) { options.BuildTrail.Push(((IResourceable)parent).Resources); TranslateType(((IResourceable)parent).Resources); options.BuildTrail.Pop(); } } } if (parent.Classes != null) { TranslateTypes(parent, parent.Classes); if (!lastBlockFlag) { if (seggedMember == null) { lastBlockFlag = parent.Classes.Count > 0; } else { lastBlockFlag = parent.Classes.GetCountForTarget(parent) > 0; } } } if (parent.Delegates != null) { if ((seggedMember != null && parent.Delegates.GetCountForTarget(parent) > 0) || (seggedMember == null) && (parent.Delegates.Count > 0) && (lastBlockFlag)) { this.WriteLine(); lastBlockFlag = false; } TranslateTypes(parent, parent.Delegates); if (!lastBlockFlag) { if (seggedMember == null) { lastBlockFlag = parent.Delegates.Count > 0; } else { lastBlockFlag = parent.Delegates.GetCountForTarget(parent) > 0; } } } if (parent.Enumerators != null) { if ((seggedMember != null && parent.Enumerators.GetCountForTarget(parent) > 0) || (seggedMember == null) && (parent.Enumerators.Count > 0) && (lastBlockFlag)) { this.WriteLine(); lastBlockFlag = false; } TranslateTypes(parent, parent.Enumerators); if (!lastBlockFlag) { if (seggedMember == null) { lastBlockFlag = parent.Enumerators.Count > 0; } else { lastBlockFlag = parent.Enumerators.GetCountForTarget(parent) > 0; } } } if (parent.Interfaces != null) { if ((seggedMember != null && parent.Interfaces.GetCountForTarget(parent) > 0) || (seggedMember == null) && (parent.Interfaces.Count > 0) && (lastBlockFlag)) { this.WriteLine(); lastBlockFlag = false; } TranslateTypes(parent, parent.Interfaces); if (!lastBlockFlag) { if (seggedMember == null) { lastBlockFlag = parent.Interfaces.Count > 0; } else { lastBlockFlag = parent.Interfaces.GetCountForTarget(parent) > 0; } } } if (parent.Structures != null) { if ((seggedMember != null && parent.Structures.GetCountForTarget(parent) > 0) || (seggedMember == null) && (parent.Structures.Count > 0) && (lastBlockFlag)) { this.WriteLine(); lastBlockFlag = false; } TranslateTypes(parent, parent.Structures); } if (useRegion) { TranslateConceptRegionEnd(regionText); } }
public abstract void TranslateTypes <TItem, TDom>(ITypeParent parent, IDeclaredTypes <TItem, TDom> ambigTypes) where TItem : IDeclaredType <TDom> where TDom : CodeTypeDeclaration;
protected override IInterfaceType GetNewPartial(ITypeParent parent) { return(new InterfaceType(this.RootDeclaration, parent)); }