void FillMembersComboBox()
        {
            IClass c = GetCurrentSelectedClass();

            if (c != null && lastClassInMembersComboBox != c)
            {
                lastClassInMembersComboBox = c;
                ArrayList items       = new ArrayList();
                bool      partialMode = false;
                IClass    currentPart = c;
                if (c.IsPartial)
                {
                    CompoundClass cc = c.GetCompoundClass() as CompoundClass;
                    if (cc != null)
                    {
                        partialMode = true;
                        c           = cc;
                    }
                }

                lock (c) {
                    int       lastIndex = 0;
                    IComparer comparer  = new Comparer(System.Globalization.CultureInfo.InvariantCulture);

                    foreach (IMethod m in c.Methods)
                    {
                        items.Add(new ComboBoxItem(m, m.Name, ClassBrowserIconService.GetIcon(m), partialMode ? currentPart.Methods.Contains(m) : true));
                    }
                    items.Sort(lastIndex, c.Methods.Count, comparer);
                    lastIndex = items.Count;

                    foreach (IProperty p in c.Properties)
                    {
                        items.Add(new ComboBoxItem(p, p.Name, ClassBrowserIconService.GetIcon(p), partialMode ? currentPart.Properties.Contains(p) : true));
                    }
                    items.Sort(lastIndex, c.Properties.Count, comparer);
                    lastIndex = items.Count;

                    foreach (IField f in c.Fields)
                    {
                        items.Add(new ComboBoxItem(f, f.Name, ClassBrowserIconService.GetIcon(f), partialMode ? currentPart.Fields.Contains(f) : true));
                    }
                    items.Sort(lastIndex, c.Fields.Count, comparer);
                    lastIndex = items.Count;

                    foreach (IEvent evt in c.Events)
                    {
                        items.Add(new ComboBoxItem(evt, evt.Name, ClassBrowserIconService.GetIcon(evt), partialMode ? currentPart.Events.Contains(evt) : true));
                    }
                    items.Sort(lastIndex, c.Events.Count, comparer);
                    lastIndex = items.Count;
                }

                membersComboBox.BeginUpdate();
                membersComboBox.Items.Clear();
                membersComboBox.Items.AddRange(items.ToArray());
                membersComboBox.EndUpdate();
                UpdateMembersComboBox();
            }
        }
Exemple #2
0
        static List <string> GetFileNames(IClass c)
        {
            List <string> list = new List <string>();
            CompoundClass cc   = c as CompoundClass;

            if (cc != null)
            {
                foreach (IClass part in cc.Parts)
                {
                    string fileName = part.CompilationUnit.FileName;
                    if (fileName != null)
                    {
                        list.Add(fileName);
                    }
                }
            }
            else
            {
                string fileName = c.CompilationUnit.FileName;
                if (fileName != null)
                {
                    list.Add(fileName);
                }
            }
            return(list);
        }
Exemple #3
0
        public override void UpdateParseInformation(ICompilationUnit oldUnit, ICompilationUnit unit)
        {
            if (!isInitialized)
            {
                return;
            }

            Dictionary <string, IClass> classDictionary      = new Dictionary <string, IClass>();
            Dictionary <string, bool>   wasUpdatedDictionary = new Dictionary <string, bool>();

            if (oldUnit != null)
            {
                foreach (IClass c in oldUnit.Classes)
                {
                    classDictionary[c.DotNetName]      = c.GetCompoundClass();
                    wasUpdatedDictionary[c.DotNetName] = false;
                }
            }
            if (unit != null)
            {
                foreach (IClass c in unit.Classes)
                {
                    TreeNode  path = GetNodeByPath(c.Namespace, true);
                    ClassNode node = GetNodeByClass(path.Nodes, c);
                    if (node != null)
                    {
                        node.Class = c.GetCompoundClass();
                    }
                    else
                    {
                        new ClassNode(Project, c.GetCompoundClass()).InsertSorted(path);
                    }
                    wasUpdatedDictionary[c.DotNetName] = true;
                }
            }
            foreach (KeyValuePair <string, bool> entry in wasUpdatedDictionary)
            {
                if (!entry.Value)
                {
                    IClass c = classDictionary[entry.Key];

                    TreeNode  path = GetNodeByPath(c.Namespace, true);
                    ClassNode node = GetNodeByClass(path.Nodes, c);

                    if (node != null)
                    {
                        CompoundClass cc = c as CompoundClass;
                        if (cc != null)
                        {
                            node.Class = cc;                             // update members after part has been removed
                        }
                        else
                        {
                            path.Nodes.Remove(node);
                            RemoveEmptyNamespace(path);
                        }
                    }
                }
            }
        }
Exemple #4
0
 public void GlobalSetUp()
 {
     V2::Utf8Json.JsonSerializerOptionsExtensions.PrepareJsonFormatter(V2::Utf8Json.JsonSerializer.DefaultOptions);
     Value = new CompoundClass
     {
         S0 = new EightMemberStruct
         {
             Second       = 113413,
             EighthNumber = 121741,
             Third        = -32,
             FourthInt    = int.MinValue,
             FifthNum     = int.MaxValue,
             SixthInteger = 0,
             SeventhDigit = -9715725,
             FirstInt32   = 1,
         },
         S1 = new SixMemberClass
         {
             第2の文章 = "",
             //"春は、あけぼの。やうやう白くなりゆく山ぎは少し明りて紫だちたる雲の細くたなびきたる。\n夏は、夜。月の頃はさらなり。闇もなほ。螢の多く飛び違ひたる。また、ただ一つ二つなど、ほのかにうち光りて行くもをかし。雨など降るもをかし。\n秋は、夕暮。夕日のさして、山の端(は)いと近うなりたるに、烏の寝どころへ行くとて、三つ四つ、二つ三つなど、飛び急ぐさへあはれなり。まいて雁などの連ねたるがいと小さく見ゆるは、いとをかし。日入り果てて、風の音、虫の音など、はたいふべきにあらず。\n冬は、つとめて。雪の降りたるはいふべきにもあらず。霜のいと白きも、またさらでも、いと寒きに、火など急ぎ熾して、炭もて渡るも、いとつきづきし。昼になりて、ぬるくゆるびもていけば、火桶の火も、白き灰がちになりて、わろし。"
             第Vの文章 = "春は、あけぼの。",
             //"ルイズ!ルイズ!ルイズ!ルイズぅぅうううわぁああああああああああああああああああああああん!!!あぁああああ…ああ…あっあっー!あぁああああああ!!!ルイズルイズルイズぅううぁわぁああああ!!!あぁクンカクンカ!クンカクンカ!スーハースーハー!スーハースーハー!いい匂いだなぁ…くんくん んはぁっ!ルイズ・フランソワーズたんの桃色ブロンドの髪をクンカクンカしたいお!クンカクンカ!あぁあ!!間違えた!モフモフしたいお!モフモフ!モフモフ!髪髪モフモフ!カリカリモフモフ…きゅんきゅんきゅい!!小説12巻のルイズたんかわいかったよぅ!!あぁぁああ…あああ…あっあぁああああ!!ふぁぁあああんんっ!!アニメ2期放送されて良かったねルイズたん!あぁあああああ!かわいい!ルイズたん!かわいい!あっああぁああ!コミック2巻も発売されて嬉し…いやぁああああああ!!!にゃああああああああん!!ぎゃああああああああ!!ぐあああああああああああ!!!コミックなんて現実じゃない!!!!あ…小説もアニメもよく考えたら…ル イ ズ ち ゃ ん は 現実 じ ゃ な い?にゃあああああああああああああん!!うぁああああああああああ!!そんなぁああああああ!!いやぁぁぁあああああああああ!!はぁああああああん!!ハルケギニアぁああああ!!この!ちきしょー!やめてやる!!現実なんかやめ…て…え!?見…てる?表紙絵のルイズちゃんが僕を見てる?表紙絵のルイズちゃんが僕を見てるぞ!ルイズちゃんが僕を見てるぞ!挿絵のルイズちゃんが僕を見てるぞ!!アニメのルイズちゃんが僕に話しかけてるぞ!!!よかった…世の中まだまだ捨てたモンじゃないんだねっ!いやっほぉおおおおおおお!!!僕にはルイズちゃんがいる!!やったよケティ!!ひとりでできるもん!!!あ、コミックのルイズちゃああああああああああああああん!!いやぁあああああああああああああああ!!!!あっあんああっああんあアン様ぁあ!!シ、シエスター!!アンリエッタぁああああああ!!!タバサァぁあああ!!ううっうぅうう!!俺の想いよルイズへ届け!!ハルケギニアのルイズへ届け!"
             第Ⅵの文章  = "ルイズ!",
             第よんの文章 = "..fdko",
             第一の文章  = "日本語!",
             第3の文章  = null,
         },
     };
 }
Exemple #5
0
    private void Update()
    {
        kart1Trigger = script1.isTrigger;
        kart2Trigger = script2.isTrigger;
        kart3Trigger = script3.isTrigger;


        //Bir kart seçer ve bileşiği onun üzerinde canlandırır


        if (null != CompoundFinderMeth())
        {
            if (ansverCompound == null)
            {
                ansverCompound = CompoundFinderMeth();
                ResultMeth();
            }
            else if (ansverCompound != CompoundFinderMeth())
            {
                ansverCompound = CompoundFinderMeth();
                ResultMeth();
            }


            ShowCompundModel();
        }
    }
Exemple #6
0
        protected IClass GetDesignedClassCodeBehindPart(IClass c)
        {
            CompoundClass compound = c as CompoundClass;

            if (compound != null)
            {
                c = null;
                foreach (IClass part in compound.Parts)
                {
                    if (string.IsNullOrEmpty(part.CompilationUnit.FileName))
                    {
                        continue;
                    }
                    if (".xaml".Equals(Path.GetExtension(part.CompilationUnit.FileName), StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    if (c == null || c.CompilationUnit.FileName.Length > part.CompilationUnit.FileName.Length)
                    {
                        c = part;
                    }
                }
            }
            return(c);
        }
Exemple #7
0
 //Bir bileşik ve bir element gelirse
 public CompoundClass Founding(CompoundClass compound, ElementClass element)
 {
     if (compound.components.Length == 2 && element != null)
     {
         return(Founding(compound.components[0], compound.components[1], element));
     }
     else
     {
         return(null);
     }
 }
        static IList <IClass> GetClassParts(IClass c)
        {
            CompoundClass cc = c as CompoundClass;

            if (cc != null)
            {
                return(cc.Parts);
            }
            else
            {
                return(new IClass[] { c });
            }
        }
        public void ReplacePartOfPartialClass()
        {
            ICompilationUnit part1 = ParseCSharp(null, "partial class PartialClass { public int Part1; }");
            ICompilationUnit part2 = ParseCSharp(null, "partial class PartialClass { public int Part2; }");

            part1 = ParseCSharp(part1, "partial class PartialClass { public string Part1; }");
            Assert.AreEqual(1, pc.Classes.Count);
            Assert.AreEqual(1, pc.NamespaceNames.Count);
            CompoundClass c = (CompoundClass)pc.GetClass("PartialClass", 0);

            Assert.IsNotNull(c);
            AssertSequenceSame(new[] { c }, pc.Classes);
            AssertSequenceSame(new[] { c }, pc.GetNamespaceContents(""));
        }
        public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            resolver.Initialize(parseInformation, typeDeclaration.BodyStartLocation.Line, typeDeclaration.BodyStartLocation.Column);

            if (resolver.CallingClass != null)
            {
                // add Partial modifier to all parts of the class
                IClass callingClass = resolver.CallingClass.GetCompoundClass();
                if (callingClass.IsPartial)
                {
                    typeDeclaration.Modifier |= Modifiers.Partial;
                }
                // determine if the type contains handles clauses referring to the current type
                bool containsClassHandlesClauses = false;
                bool hasConstructors             = false;
                foreach (IMethod method in callingClass.Methods)
                {
                    // do not count compiler-generated constructors
                    if (method.IsSynthetic)
                    {
                        continue;
                    }

                    hasConstructors |= method.IsConstructor;
                    foreach (string handles in method.HandlesClauses)
                    {
                        containsClassHandlesClauses |= !handles.Contains(".");
                    }
                }
                // ensure the type has at least one constructor to which the AddHandlerStatements can be added
                CompoundClass compoundClass = callingClass as CompoundClass;
                if (!hasConstructors)
                {
                    // add constructor only to one part
                    if (compoundClass == null || compoundClass.Parts[0] == resolver.CallingClass)
                    {
                        if (containsClassHandlesClauses || RequiresConstructor(callingClass))
                        {
                            AddDefaultConstructor(callingClass, typeDeclaration);
                        }
                    }
                }
            }

            base.VisitTypeDeclaration(typeDeclaration, data);
            return(null);
        }
Exemple #11
0
    //gelen iki elementin oluşturduğu bileşiği bulur
    public CompoundClass Founding(ElementClass element1, ElementClass element2)
    {
        foundObjects = new List <CompoundClass>();

        for (int i = 0; i < Compounds.Length; i++)
        {
            for (int j = 0; j < Compounds[i].components.Length; j++)
            {
                if (element1.elektronCaunt == Compounds[i].components[j].elektronCaunt)
                {
                    foundObjects.Add(Compounds[i]);
                }
            }
        }


        foundObjects2 = new List <CompoundClass>();

        for (int i = 0; i < foundObjects.Count; i++)
        {
            for (int j = 0; j < foundObjects[i].components.Length; j++)
            {
                if (element2.elektronCaunt == foundObjects[i].components[j].elektronCaunt)
                {
                    foundObjects2.Add(foundObjects[i]);
                }
            }
        }

        foundCompound = null;

        for (int i = 0; i < foundObjects2.Count; i++)
        {
            if (foundObjects2[i].components.Length == 2)
            {
                if (element1 != element2)
                {
                    foundCompound = foundObjects2[i];
                }
            }
        }



        return(foundCompound);
    }
Exemple #12
0
    void Update()
    {    //Kartın Arka Resmini Çekiyor
        element  = FrontCard.GetComponent <CardBehavior>().element;
        compound = FrontCard.GetComponent <CardBehavior>().compound;

        if (element != null)
        {
            gameObject.transform.parent.Find("CardImage").gameObject.GetComponent <Image>().sprite = element.cardImageBack;
        }
        else if (compound != null)
        {
            gameObject.transform.parent.Find("CardImage").gameObject.GetComponent <Image>().sprite = compound.cardImageBack;
        }
        else
        {
            gameObject.transform.parent.Find("CardImage").gameObject.GetComponent <Image>().sprite = FrontCard.GetComponent <CardBehavior>().defaultImage;
        }
    }
Exemple #13
0
        /// <summary>
        /// Find first change in project structure. Determines which method is changed etc. .
        /// </summary>
        /// <param name="change">Additional info about change in source code text.</param>
        /// <param name="doc">Document, that was changed.</param>
        /// <returns>Instance of BodyChange, containing info about change in structure.</returns>
        private BodyChange findBodyChanges(TextChangeEventArgs change, IDocument doc)
        {
            IDocumentLine line = doc.GetLineForOffset(change.Offset);

            int row    = line.LineNumber;
            int column = change.Offset - line.Offset;

            bool       found  = false;
            BodyChange entity = null;

            foreach (IClass classEl in ParserService.CurrentProjectContent.Classes)
            {
                if (classEl is CompoundClass)
                {
                    CompoundClass compClass = classEl as CompoundClass;
                    foreach (IClass compPart in compClass.Parts)
                    {
                        if (compPart.BodyRegion.IsInside(row, column) && FileUtility.IsEqualFileName(classEl.CompilationUnit.FileName, changingFilename))
                        {
                            entity = findBodyChangesClass(compPart, row, column);
                            if (entity != null)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                    if (found)
                    {
                        break;
                    }
                }
                if (classEl.BodyRegion.IsInside(row, column) && FileUtility.IsEqualFileName(classEl.CompilationUnit.FileName, changingFilename))
                {
                    entity = findBodyChangesClass(classEl, row, column);
                    if (entity != null)
                    {
                        found = true;
                        break;
                    }
                }
            }
            return(entity);
        }
Exemple #14
0
        static void WriteClasses(IProjectContent content, TextWriter writer, string excludeFilename)
        {
            writer.WriteLine("#pragma warning disable");
            writer.WriteLine("using System;");

            foreach (IClass c in content.Classes)
            {
                CompoundClass cc = c as CompoundClass;
                if (cc != null)
                {
                    foreach (IClass part in cc.Parts)
                    {
                        WriteClass(part, cc, content.Project as IProject, writer, excludeFilename);
                    }
                }
                else
                {
                    WriteClass(c, null, content.Project as IProject, writer, excludeFilename);
                }
            }

            writer.Write("\n#pragma warning restore\n");
        }
        public IEnumerable <OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
        {
            // get new initialize components
            ParseInformation info = ParserService.ParseFile(this.viewContent.PrimaryFileName, this.viewContent.PrimaryFileContent);
            ICompilationUnit cu   = info.CompilationUnit;

            foreach (IClass c in cu.Classes)
            {
                if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c))
                {
                    this.currentClassPart     = c;
                    this.initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
                    if (this.initializeComponents != null)
                    {
                        string designerFileName = this.initializeComponents.DeclaringType.CompilationUnit.FileName;
                        if (designerFileName != null)
                        {
                            designerCodeFile = FileService.GetOrCreateOpenedFile(designerFileName);

                            CompoundClass compound = c.GetCompoundClass() as CompoundClass;
                            if (compound == null)
                            {
                                return(new [] { designerCodeFile });
                            }
                            else
                            {
                                return(compound.Parts
                                       .Select(cl => FileService.GetOrCreateOpenedFile(cl.CompilationUnit.FileName))
                                       .Distinct());
                            }
                        }
                    }
                }
            }

            throw new FormsDesignerLoadException("Could not find InitializeComponent method in any part of the open class.");
        }
        /// <summary>
        /// Gets a specific part of the compound class.
        /// </summary>
        static IClass GetPart(IClass possibleCompound, string fileName)
        {
            CompoundClass compound = possibleCompound as CompoundClass;

            if (compound == null)
            {
                return(possibleCompound);
            }

            IList <IClass> parts = compound.Parts;

            if (!string.IsNullOrEmpty(fileName))
            {
                // get the part with the requested file name
                foreach (IClass part in parts)
                {
                    if (FileUtility.IsEqualFileName(fileName, part.CompilationUnit.FileName))
                    {
                        return(part);
                    }
                }
            }

            // Fallback: get the part with the shortest file name.
            // This should prefer non-designer files over designer files.
            IClass preferredClass = parts[0];

            for (int i = 1; i < parts.Count; i++)
            {
                if (IsShorterFileName(parts[i].CompilationUnit.FileName, preferredClass.CompilationUnit.FileName))
                {
                    preferredClass = parts[i];
                }
            }
            return(preferredClass);
        }
        void FillMembersComboBox()
        {
            IClass c = GetCurrentSelectedClass();

            if (c != null && lastClassInMembersComboBox != c)
            {
                lastClassInMembersComboBox = c;
                ArrayList items       = new ArrayList();
                bool      partialMode = false;
                IClass    currentPart = c;
                if (c.IsPartial)
                {
                    CompoundClass cc = c.GetCompoundClass() as CompoundClass;
                    if (cc != null)
                    {
                        partialMode = true;
                        c           = cc;
                    }
                }

                IAmbience ambience = AmbienceService.GetCurrentAmbience();
                ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames;

                int       lastIndex = 0;
                IComparer comparer  = new Comparer(System.Globalization.CultureInfo.InvariantCulture);

                foreach (IMethod m in c.Methods)
                {
                    items.Add(new ComboBoxItem(m, ambience.Convert(m), ClassBrowserIconService.GetIcon(m), partialMode ? currentPart.Methods.Contains(m) : true));
                }
                // use "items.Count - lastIndex" instead of "c.Methods.Count"
                // because it is possible that the number of methods in the class
                // changes while the loop is running (if a compound class is changed
                // from another thread)
                items.Sort(lastIndex, items.Count - lastIndex, comparer);
                lastIndex = items.Count;

                foreach (IProperty p in c.Properties)
                {
                    items.Add(new ComboBoxItem(p, ambience.Convert(p), ClassBrowserIconService.GetIcon(p), partialMode ? currentPart.Properties.Contains(p) : true));
                }
                items.Sort(lastIndex, items.Count - lastIndex, comparer);
                lastIndex = items.Count;

                foreach (IField f in c.Fields)
                {
                    items.Add(new ComboBoxItem(f, ambience.Convert(f), ClassBrowserIconService.GetIcon(f), partialMode ? currentPart.Fields.Contains(f) : true));
                }
                items.Sort(lastIndex, items.Count - lastIndex, comparer);
                lastIndex = items.Count;

                foreach (IEvent evt in c.Events)
                {
                    items.Add(new ComboBoxItem(evt, ambience.Convert(evt), ClassBrowserIconService.GetIcon(evt), partialMode ? currentPart.Events.Contains(evt) : true));
                }
                items.Sort(lastIndex, items.Count - lastIndex, comparer);
                lastIndex = items.Count;

                membersComboBox.BeginUpdate();
                membersComboBox.Items.Clear();
                membersComboBox.Items.AddRange(items.ToArray());
                membersComboBox.EndUpdate();
                UpdateMembersComboBox();
            }
        }
Exemple #18
0
        static bool CreateEventHandlerCode(CompletionContext context, NewEventCompletionItem completionItem, out int discriminator)
        {
            ParseInformation p = ParserService.GetParseInformation(context.Editor.FileName);
            var    unit        = p.CompilationUnit;
            var    loc         = context.Editor.Document.OffsetToPosition(context.StartOffset);
            IClass c           = unit.GetInnermostClass(loc.Line, loc.Column);

            discriminator = 1;

            if (c == null)
            {
                return(false);
            }
            IMethod       initializeComponent = c.Methods[0];
            CompoundClass compound            = c.GetCompoundClass() as CompoundClass;

            IMethod invokeMethod = completionItem.EventType.ReturnType.GetMethods().FirstOrDefault(m => m.Name == "Invoke");

            string handlerName = completionItem.HandlerName;

            if (invokeMethod == null)
            {
                throw new ArgumentException("delegateType is not a valid delegate!");
            }

            if (compound != null)
            {
                foreach (IClass part in compound.Parts)
                {
                    IMember lastMember = part.Methods.LastOrDefault();

                    if (lastMember != null && lastMember.ToString() == initializeComponent.ToString())
                    {
                        continue;
                    }

                    if (completionItem.EventType.ReturnType == null)
                    {
                        return(false);
                    }

                    while (part.Methods.Any(m => m.Name == handlerName &&
                                            m.Parameters.Count == invokeMethod.Parameters.Count &&
                                            m.Parameters.SequenceEqual(invokeMethod.Parameters, new ParameterComparer())
                                            ))
                    {
                        handlerName = completionItem.HandlerName + discriminator;
                        discriminator++;
                    }

                    discriminator--;

                    ParametrizedNode node = (ParametrizedNode)CodeGenerator.ConvertMember(invokeMethod, new ClassFinder(part, context.Editor.Caret.Line, context.Editor.Caret.Column));

                    node.Name = handlerName;

                    node.Modifier = Modifiers.None;

                    IViewContent          viewContent = FileService.OpenFile(part.CompilationUnit.FileName, XamlBindingOptions.SwitchToCodeViewAfterInsertion);
                    IFileDocumentProvider document    = viewContent as IFileDocumentProvider;

                    if (viewContent != null && document != null)
                    {
                        DomRegion domRegion;

                        if (lastMember != null)
                        {
                            unit.ProjectContent.Language.CodeGenerator.InsertCodeAfter(lastMember, new RefactoringDocumentAdapter(document.GetDocumentForFile(viewContent.PrimaryFile)), node);
                            domRegion = lastMember.BodyRegion;
                        }
                        else
                        {
                            unit.ProjectContent.Language.CodeGenerator.InsertCodeAtEnd(part.Region, new RefactoringDocumentAdapter(document.GetDocumentForFile(viewContent.PrimaryFile)), node);
                            domRegion = part.Region;
                        }

                        // move caret to generated code
                        ITextEditorProvider provider = viewContent as ITextEditorProvider;
                        if (provider != null)
                        {
                            provider.TextEditor.JumpTo(domRegion.EndLine + 2, domRegion.EndColumn - 1);
                        }
                    }
                    return(true);
                }
            }

            return(false);
        }
Exemple #19
0
    //gelen üç elementin oluşturduğu bileşiği bulur
    public CompoundClass Founding(ElementClass element1, ElementClass element2, ElementClass element3)
    {
        foundObjects = new List <CompoundClass>();

        for (int i = 0; i < Compounds.Length; i++)
        {
            for (int j = 0; j < Compounds[i].components.Length; j++)
            {
                if (element1.elektronCaunt == Compounds[i].components[j].elektronCaunt)
                {
                    foundObjects.Add(Compounds[i]);
                }
            }
        }

        foundObjects2 = new List <CompoundClass>();

        for (int i = 0; i < foundObjects.Count; i++)
        {
            for (int j = 0; j < foundObjects[i].components.Length; j++)
            {
                if (element2.elektronCaunt == foundObjects[i].components[j].elektronCaunt)
                {
                    foundObjects2.Add(foundObjects[i]);
                }
            }
        }


        foundObjects = new List <CompoundClass>();

        for (int i = 0; i < foundObjects2.Count; i++)
        {
            for (int j = 0; j < foundObjects2[i].components.Length; j++)
            {
                if (element3.elektronCaunt == foundObjects2[i].components[j].elektronCaunt)
                {
                    foundObjects.Add(foundObjects2[i]);
                }
            }
        }



        foundObjects2 = new List <CompoundClass>();


        for (int i = 0; i < foundObjects.Count; i++)
        {
            if (foundObjects[i].components.Length == 3)
            {
                if (element1.elektronCaunt == element2.elektronCaunt || element1.elektronCaunt == element3.elektronCaunt || element2.elektronCaunt == element3.elektronCaunt)
                {
                    for (int j = 0; j < foundObjects[i].components.Length; j++)
                    {
                        if (foundObjects[i].components[j].elektronCaunt != element1.elektronCaunt && foundObjects[i].components[j].elektronCaunt != element2.elektronCaunt && foundObjects[i].components[j].elektronCaunt != element3.elektronCaunt)
                        {
                        }
                        else
                        {
                            foundObjects2.Add(foundObjects[i]);
                        }
                    }
                }
            }
        }

        foundCompound = null;

        foundCompound = foundObjects2[0];

        List <ElementClass> sepet = new List <ElementClass>();

        for (int i = 0; i < foundObjects2[0].components.Length; i++)
        {
            sepet.Add(foundObjects2[0].components[i]);
        }



        for (int i = 0; i < sepet.Count; i++)
        {
            if (element1 == sepet[i])
            {
                sepet.Remove(sepet[i]);
            }
        }
        for (int i = 0; i < sepet.Count; i++)
        {
            if (element2 == sepet[i])
            {
                sepet.Remove(sepet[i]);
            }
        }
        for (int i = 0; i < sepet.Count; i++)
        {
            if (element3 == sepet[i])
            {
                sepet.Remove(sepet[i]);
            }
        }

        if (sepet.Count > 0)
        {
            return(null);
        }
        else
        {
            return(foundCompound);
        }
    }
        // ********************************************************************************************************************************

        /// <summary>
        /// Determines the file which contains the resources referenced by the specified manifest resource name.
        /// </summary>
        /// <param name="sourceFileName">The name of the source code file which the reference occurs in.</param>
        /// <param name="resourceName">The manifest resource name to find the resource file for.</param>
        /// <returns>A <see cref="ResourceSetReference"/> with the specified resource set name and the name of the file that contains the resources with the specified manifest resource name, or <c>null</c> if the file name cannot be determined.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="resourceName"/> parameter is <c>null</c>.</exception>
        public static ResourceSetReference GetResourceSetReference(string sourceFileName, string resourceName)
        {
            if (resourceName == null)
            {
                throw new ArgumentNullException("resourceName");
            }

            IProject p = ProjectFileDictionaryService.GetProjectForFile(sourceFileName);

            if (p != null)
            {
                string fileName;

                if ((fileName = TryGetResourceFileNameFromProjectDirect(resourceName, p)) != null)
                {
                    return(new ResourceSetReference(resourceName, fileName));
                }

                // SharpDevelop silently strips the (hard-coded) folder names
                // "src" and "source" when generating the default namespace name
                // for new files.
                // When MSBuild generates the manifest resource names for the
                // forms designer resources, it uses the type name of the
                // first class in the file. So we should find all files
                // that contain a type with the name in resourceName
                // and then look for dependent resource files or resource files
                // with the same name in the same directory as the source files.

                // Find all source files that contain a type with the same
                // name as the resource we are looking for.
                List <string>   possibleSourceFiles = new List <string>();
                IProjectContent pc = ResourceResolverService.GetProjectContent(p);
                if (pc != null)
                {
                    IClass resourceClass = pc.GetClass(resourceName, 0);

                    if (resourceClass != null)
                    {
                        CompoundClass cc = resourceClass.GetCompoundClass() as CompoundClass;

                        foreach (IClass c in (cc == null ? (IList <IClass>) new IClass[] { resourceClass } : cc.Parts))
                        {
                            if (c.CompilationUnit != null && c.CompilationUnit.FileName != null)
                            {
                                                                #if DEBUG
                                LoggingService.Debug("ResourceToolkit: NRefactoryResourceResolver found file '" + c.CompilationUnit.FileName + "' to contain the type '" + resourceName + "'");
                                                                #endif

                                possibleSourceFiles.Add(c.CompilationUnit.FileName);
                            }
                        }
                    }
                }

                foreach (string possibleSourceFile in possibleSourceFiles)
                {
                    string possibleSourceFileName = Path.GetFileName(possibleSourceFile);

                    // Find resource files dependent on these source files.
                    foreach (ProjectItem pi in p.Items)
                    {
                        FileProjectItem fpi = pi as FileProjectItem;
                        if (fpi != null)
                        {
                            if (fpi.DependentUpon != null &&
                                (fpi.ItemType == ItemType.EmbeddedResource || fpi.ItemType == ItemType.Resource || fpi.ItemType == ItemType.None) &&
                                FileUtility.IsEqualFileName(fpi.DependentUpon, possibleSourceFileName))
                            {
                                                                #if DEBUG
                                LoggingService.Debug("ResourceToolkit: NRefactoryResourceResolver trying to use dependent file '" + fpi.FileName + "' as resource file");
                                                                #endif

                                if ((fileName = FindResourceFileName(fpi.FileName)) != null)
                                {
                                    // Prefer culture-invariant resource file
                                    // over localized resource file
                                    IResourceFileContent rfc = ResourceFileContentRegistry.GetResourceFileContent(fileName);
                                    if (rfc.Culture.Equals(CultureInfo.InvariantCulture))
                                    {
                                        return(new ResourceSetReference(resourceName, fileName));
                                    }
                                }
                            }
                        }
                    }

                    // Fall back to any found resource file
                    // if no culture-invariant resource file was found
                    if (fileName != null)
                    {
                        return(new ResourceSetReference(resourceName, fileName));
                    }

                    // Find resource files with the same name as the source file
                    // and in the same directory.
                    if ((fileName = FindResourceFileName(possibleSourceFile)) != null)
                    {
                        return(new ResourceSetReference(resourceName, fileName));
                    }
                }
            }
            else
            {
                                #if DEBUG
                LoggingService.Info("ResourceToolkit: NRefactoryResourceResolver.GetResourceSetReference could not determine the project for the source file '" + (sourceFileName ?? "<null>") + "'.");
                                #endif

                if (sourceFileName != null)
                {
                    // The project could not be determined.
                    // Try a simple file search.

                    string directory    = Path.GetDirectoryName(sourceFileName);
                    string resourcePart = resourceName;
                    string fileName;

                    while (true)
                    {
                                                #if DEBUG
                        LoggingService.Debug("ResourceToolkit: NRefactoryResourceResolver.GetResourceSetReference: looking for a resource file like '" + Path.Combine(directory, resourcePart) + "'");
                                                #endif

                        if ((fileName = FindResourceFileName(Path.Combine(directory, resourcePart.Replace('.', Path.DirectorySeparatorChar)))) != null)
                        {
                            return(new ResourceSetReference(resourceName, fileName));
                        }
                        if ((fileName = FindResourceFileName(Path.Combine(directory, resourcePart))) != null)
                        {
                            return(new ResourceSetReference(resourceName, fileName));
                        }

                        if (resourcePart.Contains("."))
                        {
                            resourcePart = resourcePart.Substring(resourcePart.IndexOf('.') + 1);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

                        #if DEBUG
            LoggingService.Info("ResourceToolkit: NRefactoryResourceResolver.GetResourceSetReference is unable to find a suitable resource file for '" + resourceName + "'");
                        #endif

            return(new ResourceSetReference(resourceName, null));
        }
Exemple #21
0
    //Trigırlanma olayına göre hangi founding methoduna gireceğini ayarlayan ve dışarıya bileşik döndüren method
    public CompoundClass CompoundFinderMeth()
    {
        Result = null;

        if (kart1Trigger == true && kart2Trigger == true && kart3Trigger == true)
        {
            if (script1.element != null && script2.element != null && script3.element != null)
            {
                Result = Founding(script1.element, script2.element, script3.element);
            }
        }
        else if (kart1Trigger == true && kart2Trigger == true && kart3Trigger == false)
        {
            if (script1.element != null && script2.element != null)
            {
                Result = Founding(script1.element, script2.element);
            }
            else if (script1.compound != null)
            {
                Result = Founding(script1.compound, script2.element);
            }
            else if (script2.compound != null)
            {
                Result = Founding(script2.compound, script1.element);
            }
        }
        else if (kart1Trigger == true && kart3Trigger == true && kart2Trigger == false)
        {
            if (script1.element != null && script3.element != null)
            {
                Result = Founding(script1.element, script3.element);
            }
            else if (script1.compound != null)
            {
                Result = Founding(script1.compound, script3.element);
            }
            else if (script3.compound != null)
            {
                Result = Founding(script3.compound, script1.element);
            }
        }
        else if (kart2Trigger == true && kart3Trigger == true && kart1Trigger == false)
        {
            if (script2.element != null && script3.element != null)
            {
                Result = Founding(script2.element, script3.element);
            }
            else if (script2.compound != null)
            {
                Result = Founding(script2.compound, script3.element);
            }
            else if (script3.compound != null)
            {
                Result = Founding(script3.compound, script2.element);
            }
        }
        else
        {
            Result = null;
        }



        return(Result);
    }
Exemple #22
0
    //kartın üstünü temizler, bileşiği atar, üstüne ekleynecek kartı seçer

    public void ResultMeth()
    {
        if (kart1Trigger && kart2Trigger && kart3Trigger)
        {
            if (script1.element != null && script2.element != null && script3.element != null)
            {
                if (script1.element.elektronCaunt >= script2.element.elektronCaunt && script1.element.elektronCaunt >= script3.element.elektronCaunt)
                {
                    script1.compound = ansverCompound;
                }
                else if (script2.element.elektronCaunt >= script1.element.elektronCaunt && script2.element.elektronCaunt >= script3.element.elektronCaunt)
                {
                    script2.compound = ansverCompound;
                }
                else
                {
                    script3.compound = ansverCompound;
                }
                script1.element = null;
                script2.element = null;
                script3.element = null;

                ElektronClose(Kart1);
                ElektronClose(Kart2);
                ElektronClose(Kart3);
                ansverCompound = null;
            }
        }
        if (kart1Trigger && kart2Trigger && !kart3Trigger)
        {
            if (script1.element != null && script2.element != null)
            {
                if (script1.element.elektronCaunt > script2.element.elektronCaunt)
                {
                    script1.compound = ansverCompound;
                }
            }
            else if (script1.compound != null)
            {
                script1.compound = ansverCompound;
            }
            else
            {
                script2.compound = ansverCompound;
            }
            script1.element = null;
            script2.element = null;

            ElektronClose(Kart1);
            ElektronClose(Kart2);
            ansverCompound = null;
        }
        if (kart2Trigger && kart3Trigger && !kart1Trigger)
        {
            if (script2.element != null && script3.element != null)
            {
                if (script2.element.elektronCaunt > script3.element.elektronCaunt)
                {
                    script2.compound = ansverCompound;
                }
            }
            else if (script2.compound != null)
            {
                script2.compound = ansverCompound;
            }
            else
            {
                script3.compound = ansverCompound;
            }

            script2.element = null;
            script3.element = null;


            ElektronClose(Kart2);
            ElektronClose(Kart3);



            ansverCompound = null;
        }
        if (kart1Trigger && kart3Trigger && !kart2Trigger)
        {
            if (script1.element != null && script3.element != null)
            {
                if (script1.element.elektronCaunt > script3.element.elektronCaunt)
                {
                    script1.compound = ansverCompound;
                }
            }
            else if (script1.compound != null)
            {
                script1.compound = ansverCompound;
            }
            else
            {
                script3.compound = ansverCompound;
            }

            script1.element = null;
            script3.element = null;

            ElektronClose(Kart1);
            ElektronClose(Kart3);

            ansverCompound = null;
        }
    }