public string InsertDecoration(string aquariumName, string decorationType) { //Ornament Plant if (decorationType != "Ornament" && decorationType != "Plant") { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } var aquarium = this.aquariums.FirstOrDefault(x => x.Name == aquariumName); IDecoration decoration = null; switch (decorationType) { case "Ornament": decoration = new Ornament(); break; case "Plant": decoration = new Plant(); break; } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); return($"Successfully added {decorationType} to {aquariumName}."); }
private void NormalSyntaxHighlight(Utoken utoken, UnparsableAst target, IDecoration decoration) { if (target.AstValue is D.Color && SpecialSyntaxHighlightForColorLiterals) { Color color; if (Enum.TryParse <Color>(target.AstValue.ToString(), out color)) { decoration .Add(DecorationKey.Background, color) ; if (color.EqualToAny(Color.Black, Color.Blue, Color.Green, Color.Red)) { decoration .Add(DecorationKey.Foreground, Color.White) ; } else { decoration .Add(DecorationKey.Foreground, Color.Black) ; } } } else if (utoken.Discriminator.EqualToAny(CommentContent, CommentStartSymbol, CommentEndSymbol)) { decoration .Add(DecorationKey.Foreground, ForeColorOfComment) ; } else if (target.BnfTerm is KeyTerm) { if (target.BnfTerm.IsOperator() || target.BnfTerm.IsBrace()) { decoration .Add(DecorationKey.Foreground, ForeColorOfOperator) ; } else { decoration .Add(DecorationKey.Foreground, ForeColorOfKeyword) ; } } else if (target.AstValue is D.Type) { decoration .Add(DecorationKey.Foreground, ForeColorOfType) ; } else if (target.BnfTerm.IsLiteral() || target.BnfTerm.IsConstant()) { decoration .Add(DecorationKey.Foreground, ForeColorOfLiteral) ; } }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException (string.Format(Utilities.Messages.ExceptionMessages .InexistentDecoration, decorationType)); } IAquarium aquarium = this.aquariums.FirstOrDefault(a => a.Name == aquariumName); if (aquarium == null) { throw new InvalidOperationException (Utilities.Messages.ExceptionMessages.InvalidAquariumType); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); return(string.Format(Utilities.Messages .OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
string GetModifier(IDecoration decoration) { StringBuilder builder = new StringBuilder(); if (IncludeHTMLMarkup) { builder.Append("<i>"); } if (decoration.IsStatic) { builder.Append("Shared "); } if (decoration.IsAbstract) { builder.Append("MustOverride "); } else if (decoration.IsSealed) { builder.Append("NotOverridable "); } else if (decoration.IsVirtual) { builder.Append("Overridable "); } else if (decoration.IsOverride) { builder.Append("Overrides "); } else if (decoration.IsNew) { builder.Append("Shadows "); } if (IncludeHTMLMarkup) { builder.Append("</i>"); } return builder.ToString(); }
string GetModifier(IDecoration decoration) { string ret = ""; if (IncludeHTMLMarkup) { ret += "<i>"; } if (decoration.IsStatic) { ret += "static "; } else if (decoration.IsSealed) { ret += "sealed "; } else if (decoration.IsVirtual) { ret += "virtual "; } else if (decoration.IsOverride) { ret += "override "; } else if (decoration.IsNew) { ret += "new "; } if (IncludeHTMLMarkup) { ret += "</i>"; } return ret; }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration currentDecor = null; // this.decorations.FirstOrDeafault(x => x.GetType().Name == decorationType) as IDecoration; foreach (var dec in this.decorations.Models) { if (dec.GetType().Name == decorationType) { currentDecor = dec; } } var currentAquarium = this.aquariums.FirstOrDefault(x => x.Name == aquariumName); if (currentDecor != null) { foreach (var aqua in this.aquariums) { if (aqua.Name == aquariumName) { aqua.AddDecoration(currentDecor); this.decorations.Remove(currentDecor); break; } } } else { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } return($"Successfully added {decorationType} to {aquariumName}."); }
public void dispose() { (_curDecoration as DecorationRemoveBase).isGrow = false; _params = null; _curDecoration = null; _attachChunk = null; }
/// <summary> /// Gets the files of files that could have a reference to the <paramref name="member"/> /// int the <paramref name="ownerClass"/>. /// </summary> static List <ProjectItem> GetPossibleFiles(IClass ownerClass, IDecoration member) { List <ProjectItem> resultList = new List <ProjectItem>(); if (ProjectService.OpenSolution == null) { foreach (IViewContent vc in WorkbenchSingleton.Workbench.ViewContentCollection) { string name = vc.FileName ?? vc.UntitledName; if (ParserService.GetParser(name) != null) { FileProjectItem tempItem = new FileProjectItem(null, ItemType.Compile); tempItem.Include = name; resultList.Add(tempItem); } } return(resultList); } if (member == null) { // get files possibly referencing ownerClass while (ownerClass.DeclaringType != null) { // for nested classes, treat class as member member = ownerClass; ownerClass = ownerClass.DeclaringType; } if (member == null) { GetPossibleFilesInternal(resultList, ownerClass.ProjectContent, ownerClass.IsInternal); return(resultList); } } if (member.IsPrivate) { List <string> fileNames = GetFileNames(ownerClass); foreach (string fileName in fileNames) { ProjectItem item = FindItem(fileName); if (item != null) { resultList.Add(item); } } return(resultList); } if (member.IsProtected) { // TODO: Optimize when member is protected } GetPossibleFilesInternal(resultList, ownerClass.ProjectContent, ownerClass.IsInternal || member.IsInternal && !member.IsProtected); return(resultList); }
public static IReturnType Create(IProjectContent pc, IDecoration member, Type type, bool createLazyReturnType) { if (type.IsByRef) { // TODO: Use ByRefRefReturnType return Create(pc, member, type.GetElementType(), createLazyReturnType); } else if (type.IsArray) { return new ArrayReturnType(pc, Create(pc, member, type.GetElementType(), createLazyReturnType), type.GetArrayRank()); } else if (type.IsGenericType && !type.IsGenericTypeDefinition) { Type[] args = type.GetGenericArguments(); List<IReturnType> para = new List<IReturnType>(args.Length); for (int i = 0; i < args.Length; ++i) { para.Add(Create(pc, member, args[i], createLazyReturnType)); } return new ConstructedReturnType(Create(pc, member, type.GetGenericTypeDefinition(), createLazyReturnType), para); } else if (type.IsGenericParameter) { IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null; if (c != null && type.GenericParameterPosition < c.TypeParameters.Count) { if (c.TypeParameters[type.GenericParameterPosition].Name == type.Name) { return new GenericReturnType(c.TypeParameters[type.GenericParameterPosition]); } } if (type.DeclaringMethod != null) { IMethod method = member as IMethod; if (method != null) { if (type.GenericParameterPosition < method.TypeParameters.Count) { return new GenericReturnType(method.TypeParameters[type.GenericParameterPosition]); } return new GenericReturnType(new DefaultTypeParameter(method, type)); } } return new GenericReturnType(new DefaultTypeParameter(c, type)); } else { string name = type.FullName; if (name == null) throw new ApplicationException("type.FullName returned null. Type: " + type.ToString()); int typeParameterCount = 0; if (name.Length > 2) { if (name[name.Length - 2] == '`') { typeParameterCount = int.Parse(name[name.Length - 1].ToString()); name = name.Substring(0, name.Length - 2); } } if (name.IndexOf('+') > 0) { name = name.Replace('+', '.'); } if (!createLazyReturnType) { IClass c = pc.GetClass(name, typeParameterCount); if (c != null) return c.DefaultReturnType; // example where name is not found: pointers like System.Char* // or when the class is in a assembly that is not referenced } return new GetClassReturnType(pc, name, typeParameterCount); } }
public GrowDecoration(GrowDecorationParam paras) { _params = paras; _params.growedTime = 0; _growMark = true; _curDecoration = DecorationFactory.GetDecorationInstance((DecorationType)_params.plantData.decorationType); (_curDecoration as DecorationRemoveBase).isGrow = true; _attachChunk = World.world.GetChunk((int)_params.pos.x, (int)_params.pos.y, (int)_params.pos.z); _curDecoration.Decorade(_attachChunk, (int)_params.loacalPos.x, (int)_params.loacalPos.y, (int)_params.loacalPos.z, _params.random); _growNeedTime = _params.plantData.growTime; }
static string GetMemberText(IAmbience ambience, IDecoration member, string expression, out bool debuggerCanShowValue) { bool tryDisplayValue = false; debuggerCanShowValue = false; StringBuilder text = new StringBuilder(); if (member is IField) { text.Append(ambience.Convert(member as IField)); tryDisplayValue = true; } else if (member is IProperty) { text.Append(ambience.Convert(member as IProperty)); tryDisplayValue = true; } else if (member is IEvent) { text.Append(ambience.Convert(member as IEvent)); } else if (member is IMethod) { text.Append(ambience.Convert(member as IMethod)); } else if (member is IClass) { text.Append(ambience.Convert(member as IClass)); } else { text.Append("unknown member "); text.Append(member.ToString()); } if (tryDisplayValue && currentDebugger != null) { LoggingService.Info("asking debugger for value of '" + expression + "'"); string currentValue = currentDebugger.GetValueAsString(expression); if (currentValue != null) { debuggerCanShowValue = true; text.Append(" = "); text.Append(currentValue); } } string documentation = member.Documentation; if (documentation != null && documentation.Length > 0) { text.Append('\n'); text.Append(ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionData.GetDocumentation(documentation)); } return(text.ToString()); }
private static IDecoration[] GetMap() { IDecoration[] arrMap = new IDecoration[256]; foreach (var item in Enum.GetValues(typeof(DecorationType))) { string className = "MTB.Decoration_" + ((DecorationType)item).ToString(); Type t = Type.GetType(className); arrMap[(byte)item] = Activator.CreateInstance(t) as IDecoration; } return(arrMap); }
bool MustBeShowen(IClass c, IDecoration member) { // Console.WriteLine("member:" + member.Modifiers); if ((!showStatic && ((member.Modifiers & ModifierEnum.Static) == ModifierEnum.Static)) || (showStatic && !((member.Modifiers & ModifierEnum.Static) == ModifierEnum.Static))) { //// enum type fields are not shown here - there is no info in member about enum field return(false); } // Console.WriteLine("Testing Accessibility"); return(IsAccessible(c, member)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = decorationRepository.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquariums.First(a => a.Name == aquariumName).AddDecoration(decoration); decorationRepository.Remove(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { aquarium = aquariums.FirstOrDefault(a => a.Name == aquariumName); decoration = decorations.Models.FirstOrDefault(a => a.GetType().Name == decorationType); if (decoration == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } aquarium.AddDecoration(decoration); decorations.Remove(decoration); return(string.Format(OutputMessages.DecorationAdded, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IAquarium wantedAquarium = aquariums.FirstOrDefault(a => a.Name == aquariumName); IDecoration wantedDecoration = decorations.Models.FirstOrDefault(d => d.GetType().Name == decorationType); if (wantedDecoration == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.InexistentDecoration, decorationType)); } wantedAquarium.AddDecoration(wantedDecoration); decorations.Remove(wantedDecoration); return(String.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string AddDecoration(string decorationType) { IDecoration decoration = decorationType switch { "Ornament" => new Ornament(), "Plant" => new Plant(), _ => throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType) }; this.decorationRepository.Add(decoration); return(string.Format(OutputMessages.SuccessfullyAdded, decorationType)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = this.decorations.Models.FirstOrDefault(m => m.GetType().Name == decorationType); if (decoration == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.InexistentDecoration, decorationType)); } this.aquariums[aquariumName].AddDecoration(decoration); this.decorations.Remove(decoration); return(String.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = decorations.FindByType(decorationType); IAquarium aquarium = aquariums.FirstOrDefault(x => x.Name == aquariumName); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquarium.AddDecoration(decoration); decorations.Remove(decoration); return string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName); }
public string InsertDecoration(string aquariumName, string decorationType) { if (!decorations.Models.Any(x => x.GetType().Name == decorationType)) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } IDecoration decoration = decorations.FindByType(decorationType); decorations.Remove(decoration); aquariums.FirstOrDefault(x => x.Name == aquariumName).AddDecoration(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
private IDecoration GetDecorationOfCurrentType(string decorationType) { IDecoration decoration = null; if (decorationType == "Ornament") { decoration = new Ornament(); } else if (decorationType == "Plant") { decoration = new Plant(); } return(decoration); }
private void NormalSyntaxHighlight(Utoken utoken, UnparsableAst target, IDecoration decoration) { if (target.BnfTerm is KeyTerm) { decoration .Add(DecorationKey.Foreground, ForeColorOfOperator) ; } else if (target.BnfTerm.IsLiteral() || target.BnfTerm.IsConstant()) { decoration .Add(DecorationKey.Foreground, ForeColorOfLiteral) ; } }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } IAquarium aquarium = this.aquariums.Where(x => x.Name == aquariumName).FirstOrDefault(); this.decorations.Remove(decoration); aquarium.AddDecoration(decoration); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { if (this.decorationRepository.FindByType(decorationType) == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } IAquarium aquarium = this.aquaria.First(x => x.Name == aquariumName); IDecoration decoration = this.decorationRepository.FindByType(decorationType); aquarium.AddDecoration(decoration); this.decorationRepository.Remove(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
/// <summary> /// Finds all decorations in this assembly, creates instances of each in memory, /// and adds them to the list. /// </summary> public static List <IDecoration> LoadDecorators(WorldData worldData) { List <IDecoration> decorations = new List <IDecoration>(); foreach (Type type in typeof(IDecoration).Assembly.GetTypes()) { if (typeof(IDecoration).IsAssignableFrom(type) && type.IsClass && !type.IsAbstract) { IDecoration decoration = Activator.CreateInstance(type, new object[] { worldData }) as IDecoration; decorations.Add(decoration); } } return(decorations); }
public void NullObjectDemo() { Form1.commandLogger.logMessage(AbstractLogger.TEST, "\t\nNull Object Test:\n\n"); DecorationFactory df = new DecorationFactory(); IDecoration deco1 = df.GetDecoration("Leaf"); IDecoration deco2 = df.GetDecoration("Tree"); IDecoration deco3 = df.GetDecoration("Water"); IDecoration deco4 = df.GetDecoration("House"); Form1.commandLogger.logMessage(AbstractLogger.TEST, "Get decoration: Leaf\n"); Form1.commandLogger.logMessage(AbstractLogger.TEST, "Get decoration: Tree\n"); Form1.commandLogger.logMessage(AbstractLogger.TEST, "Get decoration: Water\n"); Form1.commandLogger.logMessage(AbstractLogger.TEST, "Get decoration: House\n"); Form1.commandLogger.logMessage(AbstractLogger.TEST, deco1.IsNull() + " " + deco2.IsNull() + " " + deco3.IsNull() + " " + deco4.IsNull() + "\n\n"); }
private void changeToNextState() { _params.growedTime = 0; (_curDecoration as DecorationRemoveBase).removeDecoration(_attachChunk); if (_params.plantData.nextId == 0) { HasActionObjectManager.Instance.plantManager.endGrow(_params.aoId); dispose(); return; } _params.plantData = MTBPlantDataManager.Instance.getData(_params.plantData.nextId); _curDecoration = DecorationFactory.GetDecorationInstance((DecorationType)_params.plantData.decorationType); _curDecoration.Decorade(_attachChunk, (int)_params.loacalPos.x, (int)_params.loacalPos.y, (int)_params.loacalPos.z, _params.random); _growNeedTime = DayNightTime.Instance.normalTimeConfig.daySeconds * _params.plantData.growTime; World.world.CheckAndRecalculateMesh((int)_params.pos.x, (int)_params.pos.y, (int)_params.pos.z, World.world.GetBlock((int)_params.pos.x, (int)_params.pos.y, (int)_params.pos.z)); }
public string InsertDecoration(string aquariumName, string decorationType) { if (decorationType != "Ornament" && decorationType != "Plant") { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } if (decorations.FindByType(decorationType) == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } IDecoration searchedDec = decorations.FindByType(decorationType); aquariums.First(a => a.Name == aquariumName).Decorations.Add(searchedDec); decorations.Remove(searchedDec); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { IAquarium currentAq = aquariums.FirstOrDefault(x => x.Name == aquariumName); IDecoration currentDecoration = decorations.FindByType(decorationType); if (currentDecoration is null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } //if (currentAq is null) //{ // throw new InvalidOperationException(ExceptionMessages.aq); //} currentAq.AddDecoration(currentDecoration); decorations.Remove(currentDecoration); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = this.decorations.FindByType(decorationType); IAquarium aquarium = this.aquariums.First(a => a.Name == aquariumName); if (decoration == null) { string excMsg = string.Format(ExceptionMessages.InexistentDecoration, decorationType); throw new InvalidOperationException(excMsg); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); string outputMsg = string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName); return(outputMsg); }
public string InsertDecoration(string aquariumName, string decorationType) { //Posible exception IAquarium aquarium = this.aquariums.First(a => a.Name == aquariumName); IDecoration decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); return(string.Format(OutputMessages.DecorationAdded, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decor = decorations.FindByType(decorationType); if (decor == null) { throw new InvalidOperationException(string.Format(Utilities.Messages.ExceptionMessages.InexistentDecoration, decorationType)); } IAquarium aquarium = aquariums[aquariumName]; //If Error Check aquarium.AddDecoration(decor); decorations.Remove(decor); return(string.Format(Utilities.Messages.OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string AddDecoration(string decorationType) { if (decorationType != "Ornament" && decorationType != "Plant") { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } IDecoration decoration = null; if (decorationType == "Ornament") { decoration = new Ornament(); } else if (decorationType == "Plant") { decoration = new Plant(); } decorations.Add(decoration); return(String.Format(OutputMessages.SuccessfullyAdded, decorationType)); }
bool MustBeShowen(IClass c, IDecoration member) { // Console.WriteLine("member:" + member.Modifiers); if ((!showStatic && ((member.Modifiers & ModifierEnum.Static) == ModifierEnum.Static)) || ( showStatic && !((member.Modifiers & ModifierEnum.Static) == ModifierEnum.Static))) { //// enum type fields are not shown here - there is no info in member about enum field return false; } // Console.WriteLine("Testing Accessibility"); return IsAccessible(c, member); }
/// <summary> /// Is the given decoration shown on this list /// </summary> /// <param name="decoration">The overlay</param> public virtual bool HasDecoration(IDecoration decoration) { return this.Decorations.Contains(decoration); }
/// <summary> /// Create a SharpDevelop return type from a Cecil type reference. /// </summary> internal static IReturnType CreateType(IProjectContent pc, IDecoration member, TypeReference type) { while (type is ModType) { type = (type as ModType).ElementType; } if (type == null) { LoggingService.Warn("CecilReader: Null type for: " + member); return VoidReturnType.Instance; } if (type is ReferenceType) { // TODO: Use ByRefRefReturnType return CreateType(pc, member, (type as ReferenceType).ElementType); } else if (type is ArrayType) { return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType), (type as ArrayType).Rank); } else if (type is GenericInstanceType) { GenericInstanceType gType = (GenericInstanceType)type; IReturnType[] para = new IReturnType[gType.GenericArguments.Count]; for (int i = 0; i < para.Length; ++i) { para[i] = CreateType(pc, member, gType.GenericArguments[i]); } return new ConstructedReturnType(CreateType(pc, member, gType.ElementType), para); } else if (type is GenericParameter) { GenericParameter typeGP = type as GenericParameter; if (typeGP.Owner is MethodDefinition) { IMethod method = member as IMethod; if (method != null) { if (typeGP.Position < method.TypeParameters.Count) { return new GenericReturnType(method.TypeParameters[typeGP.Position]); } } return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position)); } else { IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null; if (c != null && typeGP.Position < c.TypeParameters.Count) { if (c.TypeParameters[typeGP.Position].Name == type.Name) { return new GenericReturnType(c.TypeParameters[typeGP.Position]); } } return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position)); } } else { string name = type.FullName; if (name == null) throw new ApplicationException("type.FullName returned null. Type: " + type.ToString()); if (name.IndexOf('/') > 0) { name = name.Replace('/', '.'); } int typeParameterCount = 0; if (name.Length > 2 && name[name.Length - 2] == '`') { typeParameterCount = name[name.Length - 1] - '0'; name = name.Substring(0, name.Length - 2); } IClass c = pc.GetClass(name, typeParameterCount); if (c != null) { return c.DefaultReturnType; } else { // example where name is not found: pointers like System.Char* // or when the class is in a assembly that is not referenced return new GetClassReturnType(pc, name, typeParameterCount); } } }
public virtual int CompareTo(IDecoration value) { int cmp; if(0 != (cmp = (int)(Modifiers - value.Modifiers))) return cmp; return DiffUtility.Compare(Attributes, value.Attributes); }
/// <summary> /// Gets the files of files that could have a reference to the <paramref name="member"/> /// int the <paramref name="ownerClass"/>. /// </summary> static List<ProjectItem> GetPossibleFiles(IClass ownerClass, IDecoration member) { List<ProjectItem> resultList = new List<ProjectItem>(); if (ProjectService.OpenSolution == null) { foreach (IViewContent vc in WorkbenchSingleton.Workbench.ViewContentCollection) { string name = vc.FileName ?? vc.UntitledName; if (ParserService.GetParser(name) != null) { FileProjectItem tempItem = new FileProjectItem(null, ItemType.Compile); tempItem.Include = name; resultList.Add(tempItem); } } return resultList; } if (member == null) { // get files possibly referencing ownerClass while (ownerClass.DeclaringType != null) { // for nested classes, treat class as member member = ownerClass; ownerClass = ownerClass.DeclaringType; } if (member == null) { GetPossibleFilesInternal(resultList, ownerClass.ProjectContent, ownerClass.IsInternal); return resultList; } } if (member.IsPrivate) { List<string> fileNames = GetFileNames(ownerClass); foreach (string fileName in fileNames) { ProjectItem item = FindItem(fileName); if (item != null) resultList.Add(item); } return resultList; } if (member.IsProtected) { // TODO: Optimize when member is protected } GetPossibleFilesInternal(resultList, ownerClass.ProjectContent, ownerClass.IsInternal || member.IsInternal && !member.IsProtected); return resultList; }
bool IsAccessible(IClass c, IDecoration member) { // Console.WriteLine("member.Modifiers = " + member.Modifiers); if ((member.Modifiers & ModifierEnum.Internal) == ModifierEnum.Internal) { return true; } if ((member.Modifiers & ModifierEnum.Public) == ModifierEnum.Public) { // Console.WriteLine("IsAccessible"); return true; } if ((member.Modifiers & ModifierEnum.Protected) == ModifierEnum.Protected && IsClassInInheritanceTree(c, callingClass)) { // Console.WriteLine("IsAccessible"); return true; } return c.FullyQualifiedName == callingClass.FullyQualifiedName; }
/// <summary> /// Add the given decoration to those on this list and make it appear /// </summary> /// <param name="decoration">The decoration</param> /// <remarks> /// A decoration scrolls with the listview. An overlay stays fixed in place. /// </remarks> public virtual void AddDecoration(IDecoration decoration) { if (decoration == null) return; this.Decorations.Add(decoration); this.Invalidate(); }
string GetModifier(IDecoration decoration) { string mod; if (decoration.IsStatic) mod = "static "; else if (decoration.IsFinal) mod = "final "; else if (decoration.IsVirtual) mod = "virtual "; else if (decoration.IsOverride) mod = "override "; else if (decoration.IsNew) mod = "new "; else return ""; if (IncludeHTMLMarkup | IncludePangoMarkup) return "<i>" + mod + "</i>"; else return mod; }
/// <summary> /// Remove the given decoration from this list /// </summary> /// <param name="decoration">The decoration to remove</param> public virtual void RemoveDecoration(IDecoration decoration) { if (decoration == null) return; this.Decorations.Remove(decoration); this.Invalidate(); }
public virtual int CompareTo(IDecoration value) { return this.Modifiers - value.Modifiers; }