Ejemplo n.º 1
0
 private PqlOutput ProcessResult(PqlResult result)
 {
     if (result is PqlBoolean)
     {
         return(new PqlBooleanOutput(resultBoolean));
     }
     else
     {
         PqlTupleOutput output = new PqlTupleOutput();
         if (resultBoolean)
         {
             PqlTuple tuple = result as PqlTuple;
             foreach (PqlElem elem in tuple.Elems)
             {
                 string synonym;
                 if (elem is PqlAttrRef)
                 {
                     synonym = (elem as PqlAttrRef).SynonymName;
                 }
                 else
                 {
                     synonym = (elem as PqlSynonym).Name;
                 }
                 PqlDeclaration declaration = Declarations.GetDeclarationBySynonym(synonym);
                 output.Declarations.AddDeclaration(declaration);
             }
         }
         return(output);
     }
 }
Ejemplo n.º 2
0
        private void CreateMemebers()
        {
            var namedTypeSymbol = (INamedTypeSymbol)Type;

            var methodTableType = new NamedTypeImpl()
            {
                Name = TypeName, TypeKind = TypeKind.Unknown, ContainingType = (INamedTypeSymbol)Type
            };

            if (!Type.IsAbstract && (Type.TypeKind == TypeKind.Class || Type.TypeKind == TypeKind.Struct))
            {
                Declarations.Add(new CCodeNewDeclaration(namedTypeSymbol));
            }

            Declarations.Add(new CCodeGetTypeDeclaration(namedTypeSymbol));

            if (Type.IsValueType && Type.SpecialType != SpecialType.System_Void)
            {
                Declarations.Add(new CCodeBoxRefDeclaration(namedTypeSymbol));
                Declarations.Add(new CCodeUnboxToDeclaration(namedTypeSymbol));
            }

            // transition to external definitions
            foreach (var declaration in Declarations.OfType <CCodeMethodDeclaration>().Where(m => m.MethodBodyOpt != null))
            {
                declaration.ToDefinition(Definitions, methodTableType);
            }
        }
Ejemplo n.º 3
0
 private void AcquireTarget(QualifiedSelection selection)
 {
     TargetDeclaration = Declarations.FindTarget(selection, ValidDeclarationTypes);
     TargetDeclaration = PromptIfTargetImplementsInterface();
     TargetDeclaration = GetEvent();
     TargetDeclaration = GetGetter();
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> CreateDeclaration1([FromBody] CreateDeclarationViewModel declarationData)
        {
            if (_context.User_list.FirstOrDefault(x => x.UserName == declarationData.Declaration.Patient.Phone) != null)
            {
                return(StatusCode(200, Json("such user already exists")));
            }
            Employees employee = _context.Employees.Include(i => i.Msp).Single(x => x.EmployeeId == declarationData.Declaration.Employee.EmployeeId);
            User      newUser  = new User();

            newUser.UserName  = declarationData.Declaration.Patient.Phone;
            newUser.UserGroup = 1;
            PasswordHandler passwordhandler = new PasswordHandler(declarationData.Password);

            newUser.Password = passwordhandler.GetHashedPassword();
            PatientList newPatient = new PatientList();

            newPatient = declarationData.Declaration.Patient;
            Declarations newDeclaration = new Declarations();

            newDeclaration.CreateDate = declarationData.Declaration.CreateDate.Date;
            newDeclaration.Status     = "active";
            newDeclaration.Employee   = employee;
            newDeclaration.Msp        = employee.Msp;
            newPatient.Declarations   = newDeclaration;
            newUser.PatientList       = newPatient;
            _context.User_list.Add(newUser);
            _context.SaveChanges();
            return(StatusCode(200, Json("ok")));
        }
Ejemplo n.º 5
0
        public object Visit(Declarations obj)
        {
            string codeString = "";

            if (_preVisit)
            {
                if (obj.NodeType == Declarations.NodeTypes.DeclarationDeclarations)
                {
                    codeString += (string)obj.DeclarationNode.Accept(this);
                }
            }
            else
            {
                if (obj.NodeType == Declarations.NodeTypes.MethodDeclarationDeclarations)
                {
                    codeString += (string)obj.MethodDeclarationNode.Accept(this);
                }
            }
            //<Declarations> ::= <Declaration> ';' <Declarations>


            //<Declarations> ::= <MethodDeclaration> <Declarations>
            if (obj.DeclarationsNode != null)
            {
                codeString += (string)obj.DeclarationsNode.Accept(this);
            }

            return(codeString);
        }
Ejemplo n.º 6
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        protected override void Dispose(bool disposing)
        {
            // If you need thread safety, use a lock around these
            // operations, as well as in your methods that use the resource.
            if (Disposed)
            {
                return;
            }

            // If disposing equals true, dispose all managed
            // and unmanaged resources.
            if (disposing)
            {
                // Dispose managed resources.
                if (Declarations != null)
                {
                    Declarations.Dispose();
                }

                if (Definitions != null)
                {
                    Definitions.Dispose();
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
            }

            // Indicate that the instance has been disposed.
            Declarations = null;
            Definitions  = null;
            Disposed     = true;
        }
Ejemplo n.º 7
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            if (Declarations.Count() > 0)
            {
                sb.Append(Selector);
                sb.Append('{');
                foreach (Declaration rule in Declarations)
                {
                    sb.Append(rule.ToString());
                }
                sb.Append("}}");
            }
            else
            {
                sb.Append(Selector);
                sb.Append('{');
                foreach (IRule rule in NestedRules)
                {
                    sb.Append(rule.ToString());
                }
                sb.Append("}");
            }
            return(sb.ToString());
        }
Ejemplo n.º 8
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            if (Declarations != null)
            {
                Declarations.Clear();
            }

            if (Comments != null)
            {
                Comments.Clear();
            }

            if (Annotations != null)
            {
                Annotations.Clear();
            }

            if (ModuleAttributes != null)
            {
                ModuleAttributes.Clear();
            }

            _isDisposed = true;
        }
Ejemplo n.º 9
0
        public void PostWithSiterIDError()
        {
            // Arrange
            Declarations controller = new Declarations();
            string       xmlInput   = @"<InputDocument>
	                                <DeclarationList>
		                                <Declaration Command=""DEFAULT"" Version=""5.13"">
			                                <DeclarationHeader>
				                                <Jurisdiction>IE</Jurisdiction>
				                                <CWProcedure>IMPORT</CWProcedure>
				                                <DeclarationDestination>CUSTOMSWAREIE</DeclarationDestination>
				                                <DocumentRef>71Q0019681</DocumentRef>
				                                <SiteID>COR</SiteID>
				                                <AccountCode>G0779837</AccountCode>
			                                </DeclarationHeader>
		                                </Declaration>
	                                </DeclarationList>
                                </InputDocument>";

            xmlInput = HttpUtility.HtmlDecode(xmlInput);

            // Act
            var response = controller.ReceiveDeclarations(xmlInput);

            // Assert
            XDocument parsedResponse = XDocument.Parse(response);


            IList <string> expectedResponse = new List <string>()
            {
                "-2"
            };

            TestResponse(expectedResponse, parsedResponse);
        }
Ejemplo n.º 10
0
        public RazorCodeDocument Update(string filePath, string content)
        {
            var obj = FileSystem.GetItem(filePath, fileKind: FileKinds.Component);

            if (obj.Exists && obj is TestRazorProjectItem item)
            {
                Declarations.TryGetValue(filePath, out var existing);

                var declaration     = Engine.ProcessDeclarationOnly(item);
                var declarationText = declaration.GetCSharpDocument().GeneratedCode;

                // Updating a declaration, create a new compilation
                if (!string.Equals(existing, declarationText, StringComparison.Ordinal))
                {
                    Declarations[filePath] = declarationText;

                    // Yeet the old one.
                    References.RemoveAt(References.Count - 1);

                    var compilation = BaseCompilation.AddSyntaxTrees(Declarations.Select(kvp =>
                    {
                        return(CSharpSyntaxTree.ParseText(kvp.Value, path: kvp.Key));
                    }));
                    References.Add(compilation.ToMetadataReference());
                }

                item.Content = content ?? string.Empty;
                var generated = Engine.Process(item);
                return(generated);
            }

            throw new InvalidOperationException($"Cannot find item '{filePath}'.");
        }
Ejemplo n.º 11
0
 public static IEnumerable <DeclarationInfo> Cast(this Declarations src)
 {
     foreach (DeclarationInfo item in src)
     {
         yield return(item);
     }
 }
        public void OneTriggerNoText()
        {
            using (OleServiceProvider provider = new OleServiceProvider())
            {
                ResetScopeState();

                // Create a mock engine provider.
                BaseMock mockEngineProvider = MockFactories.EngineProviderFactory.GetInstance();
                // Create a mock engine.
                BaseMock mockEngine = MockFactories.EngineFactory.GetInstance();
                // Set this engine as the one returned from the GetSharedEngine of the engine provider.
                mockEngineProvider.AddMethodReturnValues(
                    string.Format("{0}.{1}", typeof(IPythonEngineProvider), "GetSharedEngine"),
                    new object[] { (IEngine)mockEngine });
                // Add the engine provider to the list of the services.
                provider.AddService(typeof(IPythonEngineProvider), mockEngineProvider, false);

                // Create the scanner for this test.
                BaseMock scannerMock = MockFactories.ScannerFactory.GetInstance();
                scannerMock["Iteration"] = 0;
                TokenInfo token = new TokenInfo();
                token.StartIndex      = 0;
                token.EndIndex        = 1;
                token.Trigger         = TokenTriggers.MemberSelect;
                scannerMock["Tokens"] = new TokenInfo[] { token };
                scannerMock.AddMethodCallback(
                    string.Format("{0}.{1}", typeof(IScanner).FullName, "ScanTokenAndProvideInfoAboutIt"),
                    new EventHandler <CallbackArgs>(StandardScannerCallback));

                Declarations declarations = ExecuteGetDeclarations(".", scannerMock as IScanner, provider);
                Assert.IsTrue(0 == mockEngine.TotalCallsAllFunctions());
            }
        }
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(Declarations declarations, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
            {
                return;
            }


            // Create a local variable for the new instance.
            Declaration newobj = null;

            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;


            // Iterate through the table rows
            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(declarations.ContainsType[0]) as Declaration;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                declarations.Add(newobj);
            }
        }
        /// <summary>
        /// Fill method for populating an entire collection of Declarations
        /// </summary>
        public virtual void Fill(Declarations declarations)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDeclarations");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(declarations, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
        /// <remarks>
        /// Interface implementation members are private, they're not called from an object
        /// variable reference of the type of the procedure's class, and whether they're called or not,
        /// they have to be implemented anyway, so removing them would break the code.
        /// Best just ignore them.
        /// </remarks>
        private bool IsInterfaceMember(Declarations declarations, IEnumerable <Declaration> classes, Declaration procedure)
        {
            // get the procedure's parent module
            var enumerable = classes as IList <Declaration> ?? classes.ToList();
            var parent     = enumerable.Where(item => item.Project == procedure.Project)
                             .SingleOrDefault(item => item.IdentifierName == procedure.ComponentName);

            if (parent == null)
            {
                return(false);
            }

            var interfaces = enumerable.Where(item => item.References.Any(reference =>
                                                                          reference.Context.Parent is VBAParser.ImplementsStmtContext));

            if (interfaces.Select(i => i.ComponentName).Contains(procedure.ComponentName))
            {
                return(true);
            }

            var result = GetImplementedInterfaceMembers(declarations, enumerable, procedure.ComponentName)
                         .Contains(procedure.IdentifierName);

            return(result);
        }
Ejemplo n.º 16
0
        protected override IEnumerable <IInspectionResult> DoGetInspectionResults()
        {
            var unresolved = State.DeclarationFinder.UnresolvedMemberDeclarations.Where(decl => !IsIgnoringInspectionResultFor(decl, AnnotationName)).ToList();

            var targets = Declarations.Where(decl => decl.AsTypeDeclaration != null &&
                                             !decl.AsTypeDeclaration.IsUserDefined &&
                                             decl.AsTypeDeclaration.DeclarationType.HasFlag(DeclarationType.ClassModule) &&
                                             ((ClassModuleDeclaration)decl.AsTypeDeclaration).IsExtensible)
                          .SelectMany(decl => decl.References).ToList();

            return(unresolved
                   .Select(access => new
            {
                access,
                callingContext = targets.FirstOrDefault(usage => usage.Context.Equals(access.CallingContext) ||
                                                        (access.CallingContext is VBAParser.NewExprContext &&
                                                         usage.Context.Parent.Parent.Equals(access.CallingContext))
                                                        )
            })
                   .Where(memberAccess => memberAccess.callingContext != null &&
                          memberAccess.callingContext.Declaration.DeclarationType != DeclarationType.Control)                 //TODO - remove this exception after resolving #2592)
                   .Select(memberAccess => new DeclarationInspectionResult(this,
                                                                           string.Format(InspectionResults.MemberNotOnInterfaceInspection, memberAccess.access.IdentifierName,
                                                                                         memberAccess.callingContext.Declaration.AsTypeDeclaration.IdentifierName), memberAccess.access)));
        }
Ejemplo n.º 17
0
 public void visit(Declarations that)
 {
     foreach (Declaration declaration in that.DeclarationsArray)
     {
         declaration.visit(this);
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Ajoute des déclarations à ce Container à partir d'un block Access.
        /// </summary>
        /// <param name="block"></param>
        void AddDeclarationsFromAccessBlock(Language.NamedBlockDeclaration block, Semantic.TypeTable table)
        {
            foreach (Language.Instruction instruction in block.Instructions)
            {
                if (instruction is Language.FunctionDeclaration)
                {
                    // Vérifie que le type de retour de la fonction est public.
                    Language.FunctionDeclaration decl = (Language.FunctionDeclaration)instruction;
                    decl.Func.Owner = table.Types[Language.SemanticConstants.StateClass];
                    if (!decl.Func.IsPublic)
                    {
                        ParsingLog.AddWarning("Les fonctions contenues dans le block access doivent être publiques.",
                                              instruction.Line, instruction.Character, instruction.Source);
                    }
                    if (decl.Func.ReturnType.IsPrivateOrHasPrivateGenericArgs())
                    {
                        ParsingLog.AddWarning("Les types de retour des déclaration de fonction du bloc access doivent être des types publics" +
                                              " et ne pas contenir de paramètre générique privé. (donné : "
                                              + decl.Func.ReturnType.GetFullName() + ")",
                                              instruction.Line, instruction.Character, instruction.Source);
                    }

                    // Vérification du return type.
                    List <string> outReasons;
                    if (!decl.Func.ReturnType.DoesSupportSerialization(out outReasons))
                    {
                        string error;
                        error = "Le type de retour de la fonction '" + decl.Func.GetFullName() + "' (" + decl.Func.ReturnType.GetFullName() +
                                ") ne prend pas en charge la sérialisation. Raisons : ";
                        error += Tools.StringUtils.Join(outReasons, ", ") + ".";
                        ParsingLog.AddWarning(error, decl.Line, decl.Character, decl.Source);
                    }

                    // Vérification des types des arguments.
                    foreach (Language.FunctionArgument arg in decl.Func.Arguments)
                    {
                        if (!arg.ArgType.DoesSupportSerialization(out outReasons))
                        {
                            string error;
                            error = "Le type de l'argument '" + arg.ArgName + "' (" + arg.ArgType + ") de la fonction " + decl.Func.GetFullName() +
                                    " ne prend pas en charge la sérialisation. Reasons : ";


                            error += Tools.StringUtils.Join(outReasons, ", ") + ".";
                            ParsingLog.AddWarning(error, decl.Line, decl.Character, decl.Source);
                        }
                    }
                    Declarations.Add((Language.FunctionDeclaration)instruction);
                }
                else
                {
                    ParsingLog.AddError("Instruction de type " + instruction.GetType().Name + " invalide dans un AccessBlock",
                                        instruction.Line,
                                        instruction.Character,
                                        instruction.Source
                                        );
                }
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// スニペット変数を追加する
 /// </summary>
 /// <param name="id">変数名</param>
 /// <param name="toolTip">説明</param>
 /// <param name="_default">デフォルト値</param>
 public void AddDeclaration(string id, string toolTip, string _default)
 {
     if (Declarations is null)
     {
         Declarations = new List <Literal>();
     }
     Declarations.Add(new Literal(id, toolTip, _default));
 }
Ejemplo n.º 20
0
        private Variable Parse(Parser.Exp.Decl declExp, Declarations declaration)
        {
            string        factorName = declExp.Item1;
            List <string> factors    = declExp.Item2.ToList();

            declaration[factorName] = factors;
            return(null);
        }
Ejemplo n.º 21
0
 public ImportUri(string uri)
 {
     _uri = uri;
     Declarations.Add(new Declaration {
         Property = "@import", Value = uri
     });
     Selector = _hash.GetHashCode(this, null);
 }
Ejemplo n.º 22
0
 public void TestInitialization()
 {
     _vbe          = new Mock <VBE>();
     _vbProject    = new Mock <VBProject>();
     _declarations = new Declarations();
     _module       = new QualifiedModuleName();
     _view         = new Mock <IRenameView>();
 }
Ejemplo n.º 23
0
 /// <inheritdoc />
 public override void Accept(Visitor visitor)
 {
     visitor.Visit(this);
     foreach (var declaration in Declarations.AsStructEnumerable())
     {
         declaration.Accept(visitor);
     }
 }
        /// <summary>
        /// Gets the objects for the DECLARATION relationship.
        /// </summary>
        public Declarations GetDeclarations()
        {
            Declarations declarations = new Declarations();


            DeclarationBase.ServiceObject.FillByPriorPropertyUsageType(declarations, _id);
            return(declarations);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// スニペット変数を追加する
 /// </summary>
 /// <param name="id">変数名</param>
 /// <param name="toolTip">説明</param>
 /// <param name="_default">デフォルト値</param>
 /// <param name="function">適用する関数</param>
 /// <param name="functionValue">関数に使用する引数</param>
 public void AddDeclaration(string id, string toolTip, string _default, Function?function, string functionValue)
 {
     if (Declarations is null)
     {
         Declarations = new List <Literal>();
     }
     Declarations.Add(new Literal(id, function, functionValue));
 }
        /// <summary>
        /// Gets the objects for the DECLARATION relationship.
        /// </summary>
        public Declarations GetDeclarations()
        {
            Declarations declarations = new Declarations();


            DeclarationBase.ServiceObject.FillByCitizenshipResidencyType(declarations, _id);
            return(declarations);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// スニペット変数を追加する
 /// </summary>
 /// <param name="literal">変数</param>
 public void AddDeclaration(Literal literal)
 {
     if (Declarations is null)
     {
         Declarations = new List <Literal>();
     }
     Declarations.Add(literal);
 }
Ejemplo n.º 28
0
        public void DeclarationsGetGlyph()
        {
            Declarations declarations = CreateDeclarations();

            // Check that it is possible to add and get back a single string.
            AddMethod(declarations, "Test1");
            Assert.IsTrue(0 == declarations.GetGlyph(0));
        }
Ejemplo n.º 29
0
 public void Apply()
 {
     Declarations.Add(AddDeclaration());
     ISupportInitializeBegin.Add(AddISupportInitializeBegin());
     PropsSetup.Add(AddPropsSetup());
     ISupportInitializeEnd.Add(AddISupportInitializeEnd());
     Instantiations.Add(AddInstantiation());
 }
Ejemplo n.º 30
0
        protected override IEnumerable <IInspectionResult> DoGetInspectionResults()
        {
            var interesting = MembersUnderTest.SelectMany(member => member.References).ToList();

            if (!interesting.Any())
            {
                return(Enumerable.Empty <IInspectionResult>());
            }

            var output = new List <IInspectionResult>();
            // prefilter to reduce search space
            var prefilteredReferences = interesting.Where(use => !use.IsIgnoringInspectionResultFor(AnnotationName));

            foreach (var reference in prefilteredReferences)
            {
                var access       = reference.Context.GetAncestor <VBAParser.MemberAccessExprContext>();
                var usageContext = access.Parent is VBAParser.IndexExprContext
                    ? access.Parent.Parent
                    : access.Parent;

                var setter = usageContext is VBAParser.LExprContext lexpr && lexpr.Parent is VBAParser.SetStmtContext
                    ? lexpr.Parent
                    : null;

                if (setter is null)
                {
                    if (usageContext is VBAParser.MemberAccessExprContext || !ContextIsNothingTest(usageContext))
                    {
                        output.Add(new IdentifierReferenceInspectionResult(this,
                                                                           string.Format(ResultTemplate,
                                                                                         $"{reference.Declaration.ParentDeclaration.IdentifierName}.{reference.IdentifierName}"),
                                                                           State, reference));
                    }
                    continue;
                }

                var assignedTo = Declarations.SelectMany(decl => decl.References).SingleOrDefault(assign =>
                                                                                                  assign.IsAssignment && (assign.Context.GetAncestor <VBAParser.SetStmtContext>()?.Equals(setter) ?? false));
                if (assignedTo is null)
                {
                    continue;
                }

                var tree     = new Walker().GenerateTree(assignedTo.Declaration.ParentScopeDeclaration.Context, assignedTo.Declaration);
                var firstUse = GetReferenceNodes(tree).FirstOrDefault();
                if (firstUse is null || ContextIsNothingTest(firstUse.Reference.Context.Parent))
                {
                    continue;
                }

                output.Add(new IdentifierReferenceInspectionResult(this,
                                                                   string.Format(ResultTemplate,
                                                                                 $"{reference.Declaration.ParentDeclaration.IdentifierName}.{reference.IdentifierName}"),
                                                                   State, reference));
            }

            return(output);
        }
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(Declarations declarations, System.Data.SqlClient.SqlDataReader data)
        {
            // Do nothing if we have nothing
            if (data == null) return;

            // Create a local variable for the new instance.
            Declaration newobj = null;
            // Iterate through the data reader
            while (data.Read())
            {
                // Create a new object instance
                newobj = System.Activator.CreateInstance(declarations.ContainsType[0]) as Declaration;
                // Let the instance set its own members
                newobj.SetMembers(ref data);
                // Add the new object to the collection instance
                declarations.Add(newobj);
            }
        }
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(Declarations declarations, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) return;

            // Create a local variable for the new instance.
            Declaration newobj = null;
            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;

            // Iterate through the table rows
            for (int i = 0; i<data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(declarations.ContainsType[0]) as Declaration;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                declarations.Add(newobj);
            }
        }
Ejemplo n.º 33
0
 //TODO: Position in Sekunden und Prozent übergeben für Zeitanzeige in der UI
 void Events_TimeChanged(object sender, Declarations.Events.MediaPlayerTimeChanged e)
 {
     //TODO: Use PositionChanged instead?!
     /*double pos = (double)e.NewTime / vlc.Length;
     if (PositionChanged != null)
         PositionChanged(pos);
     if (pos > 0.8 && PlaybackLoggingMode == TP_PLAYBACKLOG.After80Percent)
         LogCurrentSong();*/
 }
Ejemplo n.º 34
0
        private void DoReset()
        {
            m_declarations = new Declarations();
            m_indexTable = new Dictionary<int, Declaration>();

            removeAllItems();
        }
Ejemplo n.º 35
0
        private void DoUpdate(Declarations decs)
        {
            if (m_controller.Path != null && Paths.AreEqual(decs.Path, m_controller.Path))
            {
                bool changed = decs != m_declarations;

                // Note that we still need to save the new info because it has
                // updated offsets.
                m_declarations = decs;

                if (changed)
                {
                    DoBuildUsingOffsetsOrder();
                    textSelectionChanged();
                }
            }
        }
        /// <summary>
        /// Gets the objects for the DECLARATION relationship.
        /// </summary>
        public Declarations GetDeclarations()
        {
            Declarations declarations = new Declarations();

            DeclarationBase.ServiceObject.FillByPriorPropertyUsageType(declarations, _id);
            return declarations;
        }
Ejemplo n.º 37
0
 public virtual void Close() {
   if (this.displayed && this.textView != null) {
     textView.UpdateCompletionStatus(null, 0 );
   }
   this.displayed = false;
   this.textView = null;
   this.decls = null;
 }
Ejemplo n.º 38
0
 public virtual void Dismiss() {
   this.displayed = false;
   this.decls = null;
   this.textView = null;
 }
Ejemplo n.º 39
0
 public void addToDeclarations(Declarations d)
 {
     d.Variables.Add(this);
 }
Ejemplo n.º 40
0
 public void addToDeclarations(Declarations d)
 {
     d.Functions.Add(this);
 }
Ejemplo n.º 41
0
    void ProcessProtocol(string proto)
    {
        string[] d = proto.Split(new char[] { ' ', '<', '>' });
        string line;

        StringBuilder sbProtocol = new StringBuilder();
        types.Add(d[1]);

        Declarations decl = null;

        if (protocolCache.TryGetValue(d[1], out decl) == false)
        {
            sbProtocol = new StringBuilder();
            decl = new Declarations(sbProtocol) { ClassName = d[1], IsProtocol = true };
            protocolCache[d[1]] = decl;
            string typeString2 = "NSObject";

            if (extraAttribute != null)
                sbProtocol.AppendFormat("\n\t[{0}]", extraAttribute);
            if (d.Length >= 4)
            {
                typeString2 = d[3];
                int iii = typeString2.IndexOf("<");
                if (iii != -1)
                {
                    int rr = typeString2.IndexOf(">");
                    string uu = typeString2.Substring(iii, rr - iii + 1);
                    typeString2 = typeString2.Replace(uu, "");
                }
            }

            sbProtocol.AppendFormat("\t//{0}", proto);

            sbProtocol.AppendFormat("\n\t[BaseType (typeof ({0}))]", typeString2);
            sbProtocol.AppendLine();
            sbProtocol.AppendLine("\t[Model]");
            sbProtocol.AppendFormat("\tinterface {0} {{\n", d[1]);
            sbProtocol.AppendLine();

            decl.Definition = sbProtocol.ToString ();
        }
        //currentWork = sbProtocol;

        bool optional = false;

        //var decl = new Declarations(sbProtocol);
        while ((line = r.ReadLine()) != null && !line.StartsWith("@end"))
        {
            if (line.StartsWith("@optional"))
                optional = true;

            string full = "";
            while ((line = r.ReadLine()) != null && !line.StartsWith("@end"))
            {
                full += line;
                if (full.IndexOf(';') != -1)
                {
                    full = full.Replace('\n', ' ');
                    decl.Add(ProcessDeclaration(true, full, optional, decl.ClassName));
                    full = "";
                }
            }
            if (line.StartsWith("@end"))
                break;
        }
        //decl.Generate(extraAttribute);
    }
Ejemplo n.º 42
0
        private void DoProcessParse(Parse parse)
        {
            var decs = new List<Declaration>();

            CsGlobalNamespace globals = parse.Globals;
            if (globals != null)
            {
                DoGetDeclarations(globals, string.Empty, decs);
                DoGetDirectives(globals.Preprocess, decs);

                decs.Sort((lhs, rhs) => lhs.Extent.location.CompareTo(rhs.Extent.location));

                var data = new Declarations(parse.Key, parse.Edit, decs.ToArray());
                Broadcaster.Invoke("computed declarations", data);
            }
        }
        /// <summary>
        /// Fill method for populating an entire collection of Declarations
        /// </summary>
        public virtual void Fill(Declarations declarations)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString());

            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();

                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDeclarations");

                    // Send the collection and data to the object factory
                    CreateObjectsFromData(declarations, datareader);

                    // close the connection
                    cnn.Close();
                }

                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
        /// <summary>
        /// Fill method for populating a collection by PriorPropertyUsageType
        /// </summary>
        public void FillByPriorPropertyUsageType(Declarations declarations, System.Int16 id)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(Declaration.GetConnectionString());

            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Declaration.GetConnectionString(), "gsp_SelectDeclarationsByPriorPropertyUsageType");

                using (cnn)
                {
                    // open the connection
                    cnn.Open();

                    // set the parameters
                    sqlparams["@priorPropertyUsageType"].Value = id;

                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDeclarationsByPriorPropertyUsageType", sqlparams);

                    // Send the collection and data to the object factory.
                    CreateObjectsFromData(declarations, datareader);

                    // close the connection
                    cnn.Close();
                }

                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
        /// <summary>
        /// Gets all the available objects.
        /// </summary>
        public virtual Declarations GetAll()
        {
            // create a new instance of the return object
            Declarations objects = new Declarations();

            // fill the objects
            this.Fill(objects);

            // return the filled object from the service
            return objects;
        }
Ejemplo n.º 46
0
	void ProcessInterface (string iface)
	{
		bool need_close = iface.IndexOf ("{") != -1;
		var cols = iface.Split ();
		string line;

		//Console.WriteLine ("**** {0} ", iface);
		types.Add (cols [1]);
		if (extraAttribute != null)
			gencs.Write ("\n\t[{0}]", extraAttribute);
		if (cols.Length >= 4)
			gencs.WriteLine ("\n\t[BaseType (typeof ({0}))]", cols [3]);
		gencs.WriteLine ("\t{0}interface {1} {{", limit == null ? "" : "public partial ", cols [1]);

		//while ((line = r.ReadLine ()) != null && (need_close && !line.StartsWith ("}"))){
		//	if (line == "{")
		//		need_close = true;
		//}
		line = r.ReadLine ();
		if (line == "{")
			need_close = true;
		while (line != null && (need_close && line != "}"))
			line = r.ReadLine ();

		var decl = new Declarations (gencs);
		while ((line = r.ReadLine ()) != null && !line.StartsWith ("@end")){
			string full = "";
				
			while ((line = r.ReadLine ()) != null && !line.StartsWith ("@end")){
				full += line;
				if (full.IndexOf (';') != -1){
					full = full.Replace ('\n', ' ');
					decl.Add (ProcessDeclaration (false, full, false));
					full = "";
				}
			}
			break;
		}
		decl.Generate (extraAttribute);
		gencs.WriteLine ("\t}");
	}
Ejemplo n.º 47
0
	void ProcessProtocol (string proto)
	{
		string [] d = proto.Split (new char [] { ' ', '<', '>'});
		string line;

		types.Add (d [1]);
		if (extraAttribute != null)
			gencs.WriteLine ("\n\t[{0}]", extraAttribute);
		gencs.WriteLine ("\n\t[BaseType (typeof ({0}))]", d.Length > 2 ? d [2] : "NSObject");
		gencs.WriteLine ("\t[Model]");
		gencs.WriteLine ("\tinterface {0} {{", d [1]);
		bool optional = false;
		
		var decl = new Declarations (gencs);
		while ((line = r.ReadLine ()) != null && !line.StartsWith ("@end")){
			if (line.StartsWith ("@optional"))
				optional = true;

			string full = "";
			while ((line = r.ReadLine ()) != null && !line.StartsWith ("@end")){
				full += line;
				if (full.IndexOf (';') != -1){
					full = full.Replace ('\n', ' ');
					decl.Add (ProcessDeclaration (true, full, optional));
					full = "";
				}
			}
			if (line.StartsWith ("@end"))
				break;
		}
		decl.Generate (extraAttribute);
		gencs.WriteLine ("\t}");
	}
Ejemplo n.º 48
0
 public void addToDeclarations(Declarations d)
 {
     d.Classes.Add(this);
 }
Ejemplo n.º 49
0
    public virtual void Init( IVsTextView textView, Declarations decls, bool completeWord ){
      
      Close();

      this.textView = textView;
      this.decls = decls;
      this.completeWord = completeWord;

      //check if we have members
      long count = decls.GetCount();
      if (count <= 0) return ;

      //initialise and refresh      
      UpdateCompletionFlags flags = UpdateCompletionFlags.UCS_NAMESCHANGED;
      if (this.completeWord) flags |= UpdateCompletionFlags.UCS_COMPLETEWORD;

      textView.UpdateCompletionStatus(this, (uint)flags);
      this.displayed = true;
    }
Ejemplo n.º 50
0
    void ProcessInterface(string iface)
    {
        if (iface.Contains ("interface CCTransitionSlideInT"))
            debugStop = true;

        iface = iface.Replace (":", " : ");
        iface = Regex.Replace (iface, " {2,}", " ");

        bool need_close = iface.IndexOf ("{") != -1;
        var cols = iface.Split ();
        string line;

        //Console.WriteLine ("**** {0} ", iface);
        types.Add (cols [1]);

        Declarations decl = null;
        StringBuilder interfaceSB = null;
        string typeString = null;

        if (interfaceCache.TryGetValue (cols [1], out decl) == false) {
            decl = new Declarations (interfaceSB) { ClassName = cols[1] };

            interfaceSB = new StringBuilder ();
            interfaceCache [cols [1]] = decl;
            interfaceSB.AppendLine ();
            interfaceSB.AppendFormat ("\t//{0}", iface);

            if (extraAttribute != null)
                interfaceSB.AppendFormat ("\n\t[{0}]", extraAttribute);
            if (cols.Length >= 4) {
                string[] temp1 = cols [3].Split ('<');
                typeString = temp1 [0];
            }
            else {
                typeString = "NSObject";
                //interfaceSB.AppendFormat ("\n\t[BaseType (typeof ({0}))]", "NSObject");
            }

            //interfaceSB.AppendFormat ("\n\t[BaseType (typeof ({0}))]", typeString);
            decl.ParentClassName = typeString;

            if (iface.Contains("<")) {

         				int ii = iface.IndexOf ("<");
                if (ii != -1) {
                    int rr = iface.IndexOf (">");
                    string uu = iface.Substring (ii, rr - ii + 1).Replace ("<", "").Replace(">", "");
                    string[] oo = uu.Split (',');
                    List<string> usedProtocols = new List<string> ();
                    foreach (string ooo in oo)
                        usedProtocols.Add (ooo.Trim ());
                    decl.Protocols = usedProtocols;
                }
            }

            string newTypeString = null;
            if (changeClassBaseType.TryGetValue(decl.ClassName, out newTypeString) == true)
                typeString = newTypeString;
            interfaceSB.AppendFormat ("\n\t[BaseType (typeof ({0}))]", typeString);

            interfaceSB.AppendLine ();
            interfaceSB.AppendFormat ("\t{0}interface {1} {{", limit == null ? "" : "public partial ", cols [1]);
            interfaceSB.AppendLine ();

            decl.Definition = interfaceSB.ToString ();
        }
        //decl = new Declarations(interfaceSB) { ClassName = cols[1] };
        //currentWork = interfaceSB;

        bool haveEnd = false;
        if (iface.Contains ("@end")) {
            line = iface;
            haveEnd = true;
        }

        while (haveEnd == false && (line = r.ReadLine()) != null && (need_close && !line.StartsWith("}")))
        {
            if (line == "{")
                need_close = true;
        }

        while (haveEnd == true || !line.StartsWith("@end"))
        {
            if (line.StartsWith("#"))
                continue;
            string full = "";

            while (haveEnd == true || (line = r.ReadLine()) != null && !line.StartsWith("@end"))
            {
                if (line.StartsWith("#"))
                    continue;

                full += line;
                if (full.IndexOf(';') != -1)
                {
                    full = full.Replace('\n', ' ');
                    decl.Add(ProcessDeclaration(false, full, false, decl.ClassName));
                    full = "";
                }

                if (haveEnd)
                    break;
            }
            break;
        }
        //decl.Generate(extraAttribute);
    }
Ejemplo n.º 51
0
        private void DoProcessStyles(StyleRuns styles)
        {
            if (styles.Boss == m_boss)
            {
                string text = DoGetText(styles.Path);
                if (text != null)
                {
                    var decs = new List<Declaration>();
                    string indent = string.Empty;
                    foreach (StyleRun run in styles.Runs)
                    {
                        if (run.Type == "Type")
                        {
                            decs.Add(new Declaration(
                                text.Substring(run.Offset, run.Length),
                                new NSRange(run.Offset, run.Length),
                                true, false));
                            indent = "    ";
                        }
                        else if (run.Type == "Member")
                        {
                            decs.Add(new Declaration(
                                indent + text.Substring(run.Offset, run.Length),
                                new NSRange(run.Offset, run.Length),
                                false, false));
                        }
                    }

                    var data = new Declarations(styles.Path, styles.Edit, decs.ToArray());
                    Broadcaster.Invoke("computed declarations", data);
                }
            }
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Gets the objects for the DECLARATION relationship.
        /// </summary>
        public Declarations GetDeclarations()
        {
            Declarations declarations = new Declarations();

            DeclarationBase.ServiceObject.FillByBorrower(declarations, _id);
            return declarations;
        }