示例#1
0
        public CodeMember(CodeElement2 element, CodeElement2 type, Language language)
        {
            this.element     = element;
            this.TypeElement = type;
            this.language    = language;

            this.Name = element.Name;
            this.RequiresSeparatorLine = element.Kind != vsCMElement.vsCMElementVariable;
            switch (element.Kind)
            {
            case vsCMElement.vsCMElementFunction:
                CodeFunction2 function = (CodeFunction2)element;
                MemberKind    kind;
                switch (function.FunctionKind)
                {
                case vsCMFunction.vsCMFunctionConstructor:
                    kind = MemberKind.Constructor;
                    break;

                case vsCMFunction.vsCMFunctionDestructor:
                    kind = MemberKind.Destructor;
                    break;

                case vsCMFunction.vsCMFunctionOperator:
                    kind = MemberKind.Operator;
                    break;

                default:
                    kind = MemberKind.Function;
                    break;
                }

                this.Initialize(
                    kind,
                    function.Access,
                    function.IsShared,
                    function.OverrideKind,
                    functionKind: function.FunctionKind,
                    parameters: function.Parameters);
                break;

            case vsCMElement.vsCMElementProperty:
                CodeProperty2 property = (CodeProperty2)element;
                this.Initialize(MemberKind.Property, property.Access, property.IsShared, property.OverrideKind, parameters: property.Parameters);
                break;

            case vsCMElement.vsCMElementVariable:
                CodeVariable2 variable = (CodeVariable2)element;
                this.Initialize(MemberKind.Variable, variable.Access, variable.IsShared, constKind: variable.ConstKind);
                break;

            case vsCMElement.vsCMElementEvent:
                CodeEvent evt = (CodeEvent)element;
                this.Initialize(MemberKind.Event, evt.Access, evt.IsShared, evt.OverrideKind);
                break;

            default:
                throw new NotSupportedException("Unsupported element kind: " + element.Kind);
            }
        }
        /// <summary>
        /// Determines if the specified code event is an explicit interface implementation.
        /// </summary>
        /// <param name="codeEvent">The code event.</param>
        /// <returns>True if an explicit interface implementation, otherwise false.</returns>
        public static bool IsExplicitInterfaceImplementation(CodeEvent codeEvent)
        {
            var declaration = CodeElementHelper.GetEventDeclaration(codeEvent);
            var matchString = @"\." + codeEvent.Name;

            return Regex.IsMatch(declaration, matchString);
        }
        public void Visit(ComponentBase.FilePoint.CodeFile result)
        {
            var e = new CodeEvent();

            var session = FindSession();

            e.Session             = session;
            e.SequenceId          = ++_sessions[session];
            e.Type                = e.GetType().Name;
            e.TriggeredAt         = result.LastEdit;
            e.TimeStamp           = (long)e.TriggeredAt.Value.Subtract(new DateTime(2010, 01, 01)).TotalMilliseconds;
            e.TriggeredBy         = "Save File";
            e.Duration            = 1000.ToString();
            e.ActiveDocumentName  = result.Name ?? "";
            e.ActiveDocumentType  = result.Extension;
            e.ActiveWindowCaption = "";
            e.ActiveWindowType    = "";

            e.Details  = "Code Change // " + result.FullPath;
            e.Content  = result.Changes.LastOrDefault()?.Content ?? "-";
            e.Exists   = result.Exists;
            e.FullPath = result.FullPath;

            session.Events.Add(e);

            _baseContext.Events.Add(e);

            SaveChanges();
        }
示例#4
0
 /// <summary>
 ///  Показує запит на введення логіна пароля користувача з розширеними правами.
 /// </summary>
 bool GetExAccess(CodeEvent parCodeEvent)
 {
     SetView(ModeInterface.GetExAccess);
     // Необхідно очікувати завершення вводу!!! Треба подумати над реалізацією.
     Wait();
     return(false);
 }
示例#5
0
 public EventNode(CodeEvent ce, CodeModelEditorForm context)
     : base(CodeModelEditor.BrowseKind.ClassEvent, context)
 {
     base.Tag              = ce;
     base.ImageKey         = "Event";
     base.SelectedImageKey = "Event";
     SetText(ce.Name);
 }
        public void CancelCodeEvent(long codeEventId)
        {
            var codeEventProxy = new CodeEvent()
            {
                Id = codeEventId
            };

            _dbContext.CodeEvents.Remove(codeEventProxy);
            _dbContext.SaveChanges();
        }
示例#7
0
        /// <summary>
        /// Gets the declaration of the specified code event as a string.
        /// </summary>
        /// <param name="codeEvent">The code event.</param>
        /// <returns>The string declaration.</returns>
        internal static string GetEventDeclaration(CodeEvent codeEvent)
        {
            // Get the start point at the end of the attributes if there are any (vsCMPartHeader is
            // not available for events).
            var startPoint = codeEvent.Attributes.Count > 0
                ? codeEvent.GetEndPoint(vsCMPart.vsCMPartAttributesWithDelimiter)
                : codeEvent.StartPoint;

            return(TextDocumentHelper.GetTextToFirstMatch(startPoint, @"[\{;]"));
        }
示例#8
0
 public TypeAccess  GetTypeAccess(CodeEvent parCodeEvent)
 {
     try
     {
         return(varPermissions[parCodeEvent]);
     }
     catch
     {
         return(TypeAccess.No);
     }
 }
        /// <summary>
        /// Obtains a reflection wrapper for an event.
        /// </summary>
        /// <param name="target">The event, or null if none.</param>
        /// <returns>The reflection wrapper, or null if none.</returns>
        public StaticEventWrapper Wrap(CodeEvent target)
        {
            if (target == null)
            {
                return(null);
            }

            StaticDeclaredTypeWrapper declaringType = MakeDeclaredType(GetContainingType((CodeElement)target));

            return(new StaticEventWrapper(this, target, declaringType, declaringType));
        }
        /// <summary>
        /// Determines if the specified code event is an explicit interface implementation.
        /// </summary>
        /// <param name="codeEvent">The code event.</param>
        /// <returns>True if an explicit interface implementation, otherwise false.</returns>
        public static bool IsExplicitInterfaceImplementation(CodeEvent codeEvent)
        {
            // In some VS editions, the name may be reported including the interface name.
            if (codeEvent.Name.Contains("."))
            {
                return true;
            }

            // Otherwise, look for the element name with a preceding dot.
            var declaration = CodeElementHelper.GetEventDeclaration(codeEvent);
            var matchString = @"\." + codeEvent.Name;

            return RegexNullSafe.IsMatch(declaration, matchString);
        }
        /// <summary>
        /// Determines if the specified code event is an explicit interface implementation.
        /// </summary>
        /// <param name="codeEvent">The code event.</param>
        /// <returns>True if an explicit interface implementation, otherwise false.</returns>
        public static bool IsExplicitInterfaceImplementation(CodeEvent codeEvent)
        {
            // In some VS editions, the name may be reported including the interface name.
            if (codeEvent.Name.Contains("."))
            {
                return(true);
            }

            // Otherwise, look for the element name with a preceding dot.
            var declaration = CodeElementHelper.GetEventDeclaration(codeEvent);
            var matchString = @"\." + codeEvent.Name;

            return(RegexNullSafe.IsMatch(declaration, matchString));
        }
 public static bool IsInherited(this CodeElement codeElement)
 {
     if (codeElement is CodeFunction)
     {
         CodeFunction codefuction = (CodeFunction)codeElement;
         if (HasParent(codeElement))
         {
             CodeClass codeClass = codefuction.Parent as CodeClass;
             if (codeClass != null)
             {
                 if (CheckIfCodeClassInheritsFunction(codeClass, codefuction))
                 {
                     return(true);
                 }
             }
         }
     }
     else if (codeElement is CodeProperty)
     {
         CodeProperty codeProperty = (CodeProperty)codeElement;
         if (HasParent(codeElement))
         {
             CodeClass codeClass = codeProperty.Parent;
             if (codeClass != null)
             {
                 if (CheckIfCodeClassInheritsProperty(codeClass, codeProperty))
                 {
                     return(true);
                 }
             }
         }
     }
     else if (codeElement is CodeEvent)
     {
         CodeEvent codeEvent = (CodeEvent)codeElement;
         if (HasParent(codeElement))
         {
             CodeClass codeClass = codeEvent.Parent as CodeClass;
             if (codeClass != null)
             {
                 if (CheckIfCodeClassInheritsEvent(codeClass, codeEvent))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
        private static bool CheckIfCodeClassInheritsEvent(CodeClass codeClass, CodeEvent codeEvent)
        {
            List <CodeInterface> implementedInterfaces = codeClass.GetImplementedInterfaces();

            if (
                SearchService.SearchInCodeElements <CodeEvent>(implementedInterfaces.OfType <CodeElement>())
                .Any(
                    p =>
                    p.Name == codeEvent.Name && p.Kind == codeEvent.Kind && p.Type.AsFullName == codeEvent.Type.AsFullName &&
                    p.Access == codeClass.Access))
            {
                return(true);
            }
            return(false);
        }
示例#14
0
        public PublicCodeEventDto GetExamples()
        {
            var mockCodeEvent = new CodeEvent {
                Id = RandomNumberGenerator.GetInt32(1, 1000)
            };

            return(new PublicCodeEventDto {
                Title = "LaunchCode: Introduction to Azure",
                Date = DateTime.Today,
                Links = new {
                    CodeEvent = CodeEventsController.ResourceLinks.GetCodeEvent(mockCodeEvent),
                    Join = MembersController.ResourceLinks.JoinCodeEvent(mockCodeEvent)
                }
            });
        }
示例#15
0
        public MemberCodeEventDto GetExamples()
        {
            var mockCodeEvent = new CodeEvent {
                Id = RandomNumberGenerator.GetInt32(1, 1000)
            };

            return(new MemberCodeEventDto {
                Title = "LaunchCode: Introduction to Azure",
                Date = DateTime.Today,
                Description = "A one week course on deploying a RESTful API to Azure",
                Links = new {
                    CodeEvent = CodeEventsController.ResourceLinks.GetCodeEvent(mockCodeEvent),
                    Leave = MembersController.ResourceLinks.LeaveCodeEvent(mockCodeEvent),
                    Cancel = CodeEventsController.ResourceLinks.CancelCodeEvent(mockCodeEvent)
                }
            });
        }
示例#16
0
        public override TypeAccess GetPermissions(int parCodeUser, CodeEvent parEvent)
        {
            ParametersCollection varParameters = new ParametersCollection();;

            varParameters.Add("parCodeUser", parCodeUser, DbType.Int32);
            varParameters.Add("parCodeAccess", (int)parEvent, DbType.Int32);

            DataTable varDT = this.db.Execute(this.varSqlGetAllPermissions, varParameters);

            if (varDT != null && varDT.Rows.Count > 0)
            {
                return((TypeAccess)varDT.Rows[0][0]);
            }
            else
            {
                return(TypeAccess.No);
            }
        }
示例#17
0
        public override TypeAccess GetPermissions(int parCodeUser, CodeEvent parEvent)
        {
            Parameter[] varParameters = new Parameter[] { new Parameter {
                                                              ColumnName = "parCodeUser", Value = parCodeUser
                                                          }, new Parameter {
                                                              ColumnName = "parCodeAccess", Value = (int)parEvent
                                                          }, };

            DataTable varDT = this.db.Execute(this.varSqlGetAllPermissions, varParameters);

            if (varDT != null && varDT.Rows.Count > 0)
            {
                return((TypeAccess)varDT.Rows[0][0]);
            }
            else
            {
                return(TypeAccess.No);
            }
        }
示例#18
0
文件: WDB.cs 项目: OlehR/UniCS.TM
 public virtual TypeAccess GetPermissions(int parCodeUser, CodeEvent parEvent)
 {
     return(TypeAccess.No);
 }
示例#19
0
        private void AddEvent(Project currentAssembly,
                              CodeTypeDeclaration proxyClass, CodeClass interopFormClass,
                              CodeEvent evt, CodeTypeDeclaration proxyClassEventSinkInterface)
        {
            CodeDelegate2 delegate1 = null;

            try
            {
                delegate1 = (CodeDelegate2)currentAssembly.CodeModel.CodeTypeFromFullName(evt.Type.AsFullName);
            }
            catch (Exception exception2)
            {
                foreach (CodeElement element1 in evt.ProjectItem.FileCodeModel.CodeElements)
                {
                    if (element1.IsCodeType)
                    {
                        CodeType type1 = (CodeType)element1;
                        foreach (CodeElement element2 in type1.Children)
                        {
                            if ((element2.Kind == vsCMElement.vsCMElementDelegate) &
                                (String.Compare(element2.FullName, evt.Type.AsFullName, false) == 0))
                            {
                                delegate1 = (CodeDelegate2)element2;
                            }
                        }
                        continue;
                    }
                }
            }

            if (delegate1 == null)
            {
                this.DisplayWarning(string.Format(Resource.EventErrMsg, evt.Name, evt.Type.AsFullName));
            }
            else
            {
                CodeMemberMethod method1 = null;
                foreach (CodeTypeMember member1 in proxyClass.Members)
                {
                    if (String.Compare(member1.Name, "HookCustomEvents", false) == 0)
                    {
                        method1 = (CodeMemberMethod)member1;
                    }
                }
                if (method1 == null)
                {
                    method1            = new CodeMemberMethod();
                    method1.Name       = "HookCustomEvents";
                    method1.Attributes = MemberAttributes.Family | MemberAttributes.Override;
                    method1.Statements.Add(this.GetStatementCastFormInstance(interopFormClass));
                    proxyClass.Members.Add(method1);
                }
                CodeMemberEvent event1 = new CodeMemberEvent();
                event1.Attributes = MemberAttributes.Public;
                event1.Type       = new CodeTypeReference(evt.Type.AsFullName);
                event1.Name       = evt.Name;
                CodeMemberMethod method3 = new CodeMemberMethod();
                method3.Name = evt.Name;
                CodeTypeDelegate delegate2 = new CodeTypeDelegate(evt.Name + "Handler");
                bool             flag1     = false;
                CodeMemberMethod method2   = new CodeMemberMethod();
                method2.Name = "castFormInstance_" + evt.Name;
                CodeDelegateInvokeExpression expression1 = new CodeDelegateInvokeExpression(new CodeEventReferenceExpression(new CodeThisReferenceExpression(), event1.Name));
                foreach (CodeParameter parameter1 in delegate1.Parameters)
                {
                    CodeParameterDeclarationExpression expression2;
                    CodeArgumentReferenceExpression    expression3;
                    CodeParameterDeclarationExpression expression4;
                    if ((parameter1.Type.CodeType != null) && this.IsEventArgs(parameter1.Type.CodeType))
                    {
                        if (!flag1)
                        {
                            proxyClass.Members.Add(delegate2);
                            event1.Type = new CodeTypeReference(delegate2.Name);
                        }
                        expression4 = new CodeParameterDeclarationExpression("System.EventArgs", parameter1.Name);
                        expression2 = new CodeParameterDeclarationExpression(parameter1.Type.AsFullName, parameter1.Name);
                        expression3 = new CodeArgumentReferenceExpression(expression4.Name);
                        event1.Comments.Add(new CodeCommentStatement(this.EVENT_ARGS_COMMENT));
                        method3.Comments.Add(new CodeCommentStatement(this.EVENT_ARGS_COMMENT));
                    }
                    else
                    {
                        if (!this.IsSupported(parameter1.Type))
                        {
                            this.DisplayWarning(String.Format(Resource.EventErrMsg2, parameter1.Type.AsFullName, evt.Name));
                            return;
                        }
                        expression4 = new CodeParameterDeclarationExpression(parameter1.Type.AsFullName, parameter1.Name);
                        expression2 = new CodeParameterDeclarationExpression(parameter1.Type.AsFullName, parameter1.Name);
                        expression3 = new CodeArgumentReferenceExpression(expression4.Name);
                    }
                    method3.Parameters.Add(expression4);
                    delegate2.Parameters.Add(expression4);
                    method2.Parameters.Add(expression2);
                    expression1.Parameters.Add(expression3);
                }
                method2.Statements.Add(expression1);
                method1.Statements.Add(new CodeAttachEventStatement(new CodeEventReferenceExpression(new CodeVariableReferenceExpression("castFormInstance"), event1.Name), new CodeDelegateCreateExpression(event1.Type, new CodeThisReferenceExpression(), method2.Name)));
                proxyClassEventSinkInterface.Members.Add(method3);
                proxyClass.Members.Add(method2);
                proxyClass.Members.Add(event1);
            }
        }
示例#20
0
        private void CreateInteropFormProxiesForDocument(List <CodeClass> interopFormClasses, Project currentAssembly, ProjectItem interopFormDoc)
        {
            if (checkFileExists(currentAssembly, interopFormDoc))
            {
                return;
            }

            if (interopFormClasses.Count <= 0)
            {
                return;
            }

            CodeCompileUnit     unit1   = new CodeCompileUnit();
            CodeNamespaceImport import1 = new CodeNamespaceImport(this._attrTypeForm.Namespace);

            System.CodeDom.CodeNamespace namespace1 = new System.CodeDom.CodeNamespace();
            namespace1.Name = "Interop";
            unit1.Namespaces.Add(namespace1);
            namespace1.Imports.Add(import1);
            namespace1.Imports.Add(new CodeNamespaceImport("System"));
            foreach (CodeClass class1 in interopFormClasses)
            {
                string text2 = class1.FullName;
                CodeTypeDeclaration declaration1 = new CodeTypeDeclaration(class1.Name);
                namespace1.Types.Add(declaration1);
                declaration1.IsClass   = true;
                declaration1.IsPartial = true;
                CodePrimitiveExpression expression2 = new CodePrimitiveExpression(true);
                CodeSnippetExpression   expression1 = new CodeSnippetExpression("System.Runtime.InteropServices.ClassInterfaceType.AutoDual");
                declaration1.CustomAttributes.Add(new CodeAttributeDeclaration("System.Runtime.InteropServices.ClassInterface", new System.CodeDom.CodeAttributeArgument[] { new System.CodeDom.CodeAttributeArgument(expression1) }));
                declaration1.CustomAttributes.Add(new CodeAttributeDeclaration("System.Runtime.InteropServices.ComVisible", new System.CodeDom.CodeAttributeArgument[] { new System.CodeDom.CodeAttributeArgument(expression2) }));
                declaration1.BaseTypes.Add(new CodeTypeReference(typeof(InteropFormProxyBase).Name));
                CodeTypeDeclaration declaration2 = new CodeTypeDeclaration("I" + declaration1.Name + "EventSink");
                declaration2.CustomAttributes.Add(new CodeAttributeDeclaration("System.Runtime.InteropServices.InterfaceTypeAttribute", new System.CodeDom.CodeAttributeArgument[] { new System.CodeDom.CodeAttributeArgument(new CodeSnippetExpression("System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch")) }));
                declaration2.CustomAttributes.Add(new CodeAttributeDeclaration("System.Runtime.InteropServices.ComVisible", new System.CodeDom.CodeAttributeArgument[] { new System.CodeDom.CodeAttributeArgument(expression2) }));
                declaration2.IsInterface = true;
                CodeConstructor      constructor1 = new CodeConstructor();
                CodeSnippetStatement statement1   = GetStatementInitializeForm(text2);
                CodeSnippetStatement statement2   = GetStatementRegisterForm();
                constructor1.Statements.Add(statement1);
                constructor1.Statements.Add(statement2);
                constructor1.Attributes = MemberAttributes.Public;
                declaration1.Members.Add(constructor1);
                if (class1.Members.Count > 0)
                {
                    foreach (CodeElement element1 in class1.Members)
                    {
                        switch (element1.Kind)
                        {
                        case vsCMElement.vsCMElementFunction:
                            CodeFunction2 function1 = (CodeFunction2)element1;
                            if (function1.Access == vsCMAccess.vsCMAccessPublic)
                            {
                                foreach (CodeElement element2 in function1.Attributes)
                                {
                                    if (this.AttributesMatch(element2, this._attrTypeInitializer))
                                    {
                                        this.AddInitializeMethodForConstructor(declaration1, class1, function1);
                                        break;
                                    }
                                    if (this.AttributesMatch(element2, this._attrTypeMethod))
                                    {
                                        this.AddMethod(declaration1, class1, function1);
                                        break;
                                    }
                                }
                            }
                            break;

                        case vsCMElement.vsCMElementProperty:
                            CodeProperty property1 = (CodeProperty)element1;
                            if (property1.Access == vsCMAccess.vsCMAccessPublic)
                            {
                                foreach (CodeElement element3 in property1.Attributes)
                                {
                                    if (this.AttributesMatch(element3, this._attrTypeProperty))
                                    {
                                        this.AddProperty(declaration1, class1, property1);
                                        break;
                                    }
                                }
                            }
                            break;

                        case vsCMElement.vsCMElementEvent:
                            CodeEvent event1 = (CodeEvent)element1;
                            if (event1.Access == vsCMAccess.vsCMAccessPublic)
                            {
                                foreach (CodeElement element3 in event1.Attributes)
                                {
                                    if (this.AttributesMatch(element3, this._attrTypeEvent))
                                    {
                                        this.AddEvent(currentAssembly, declaration1, class1, event1, declaration2);
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                if (declaration2.Members.Count > 0)
                {
                    namespace1.Types.Add(declaration2);
                    declaration1.CustomAttributes.Add(new CodeAttributeDeclaration("System.Runtime.InteropServices.ComSourceInterfaces", new System.CodeDom.CodeAttributeArgument[] { new System.CodeDom.CodeAttributeArgument(new CodeTypeOfExpression(declaration2.Name)) }));
                }
            }

            ProjectItem generatedFolderItem = GetGeneratedFolderItem(currentAssembly);

            FileInfo generatedItemInfo = getGeneratedItem(currentAssembly, generatedFolderItem, interopFormDoc);

            StreamWriter writer1 = new StreamWriter(generatedItemInfo.Create());

            writer1.AutoFlush = true;
            CodeDomProvider      provider = GetProvider();
            CodeGeneratorOptions options1 = new CodeGeneratorOptions();

            provider.GenerateCodeFromCompileUnit(unit1, writer1, options1);
            writer1.Close();
            writer1.Dispose();
            generatedFolderItem.ProjectItems.AddFromFile(generatedItemInfo.FullName);
        }
        /// <inheritdoc />
        protected override StaticTypeWrapper GetEventHandlerType(StaticEventWrapper @event)
        {
            CodeEvent eventHandle = (CodeEvent)@event.Handle;

            return(MakeType(eventHandle.Type));
        }
        /// <inheritdoc />
        protected override StaticMethodWrapper GetEventRemoveMethod(StaticEventWrapper @event)
        {
            CodeEvent eventHandle = (CodeEvent)@event.Handle;

            return(WrapAccessor(eventHandle.Remover, @event));
        }
示例#23
0
 private CodeDomEventMetadata(CodeEvent codeEvent, CodeDomFileMetadata file)
 {
     this.codeEvent = codeEvent;
     this.file      = file;
 }
 public static ITypeMetadata FromCodeElement(CodeEvent codeVariable, CodeDomFileMetadata file)
 {
     return(GetType(codeVariable, file));
 }
示例#25
0
        //解析接口或类
        void parse_body(EnvDTE.CodeClass codeClass)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            var children = codeClass.Members;

            foreach (CodeElement codeElement in children)
            {
                //解析方法定义,只解析公有方法
                if (codeElement.Kind == vsCMElement.vsCMElementFunction)
                {
                    CodeFunction codeFunction = codeElement as CodeFunction;
                    if (codeFunction.Access == vsCMAccess.vsCMAccessPublic)
                    {
                        CodeFunctionInfo func_info = new CodeFunctionInfo();
                        //解析返回值
                        var returnType = codeFunction.Type.AsFullName;
                        func_info.ReturnTypeName = returnType;
                        func_info.IsStatic       = codeFunction.IsShared;

                        //解析参数
                        //string parms = "";
                        string parms_for_invoke = "";

                        foreach (CodeParameter param in codeFunction.Parameters)
                        {
                            //TextPoint start = param.GetStartPoint();
                            //TextPoint finish = param.GetEndPoint();
                            //parms += start.CreateEditPoint().GetText(finish) + ",";
                            func_info.ParamList.Add(new CodeParamInfo()
                            {
                                Name = param.Name, TypeName = param.Type.AsFullName
                            });
                            parms_for_invoke += param.Name + ",";
                        }
                        //if (parms.Length > 0) parms = parms.Remove(parms.Length - 1, 1);
                        if (parms_for_invoke.Length > 0)
                        {
                            parms_for_invoke = parms_for_invoke.Remove(parms_for_invoke.Length - 1, 1);
                        }
                        //func_info.ParamString = parms;
                        func_info.InvokeParamString = parms_for_invoke;
                        func_info.ShortName         = codeFunction.Name;
                        var tmps = codeFunction.FullName.Split('.');
                        func_info.Name = tmps[tmps.Length - 1];
                        if (func_info.Name.IndexOf("<") != -1)
                        {
                            var s = func_info.Name.IndexOf("<") + 1;
                            var l = func_info.Name.Length - s - 1;
                            func_info.GenericTypeArguments = func_info.Name.Substring(s, l).Split(',').Select(it => it.Trim()).ToList();
                        }
                        if (func_info.ShortName == this.ShortClassName)
                        {
                            CodeConstructorList.Add(func_info);
                        }
                        else if (func_info.ShortName != codeClass.Name)
                        {
                            CodeFunctionList.Add(func_info);
                        }
                    }
                }
                ////解析属性定义,只解析公有属性
                else if (codeElement.Kind == vsCMElement.vsCMElementProperty)
                {
                    CodeProperty codeProperty = codeElement as CodeProperty;
                    if (codeProperty.Access == vsCMAccess.vsCMAccessPublic)
                    {
                        CodePropertyInfo property_info = new CodePropertyInfo();
                        property_info.Name     = codeProperty.Name;
                        property_info.TypeName = codeProperty.Type.AsFullName;
                        try
                        {
                            var getter = codeProperty.Getter;
                            property_info.HasGet   = getter != null && getter.Access == vsCMAccess.vsCMAccessPublic;
                            property_info.IsStatic = codeProperty.Getter.IsShared;
                        }
                        catch
                        {
                            property_info.HasGet = false;
                        }
                        try
                        {
                            var setter = codeProperty.Setter;
                            property_info.HasSet   = setter != null && setter.Access == vsCMAccess.vsCMAccessPublic;
                            property_info.IsStatic = codeProperty.Setter.IsShared;
                            foreach (CodeParameter param in setter.Parameters)
                            {
                                //TextPoint start = param.GetStartPoint();
                                //TextPoint finish = param.GetEndPoint();
                                //parms += start.CreateEditPoint().GetText(finish) + ",";
                                property_info.ParamList.Add(new CodeParamInfo()
                                {
                                    Name = param.Name, TypeName = param.Type.AsFullName
                                });
                            }
                        }
                        catch
                        {
                            property_info.HasSet = false;
                        }
                        CodePropertyList.Add(property_info);
                    }
                }
                else if (codeElement.Kind == vsCMElement.vsCMElementEvent)
                {
                    CodeEvent codeEvent = codeElement as CodeEvent;
                    if (codeEvent.Access == vsCMAccess.vsCMAccessPublic)
                    {
                        CodeEventInfo codeEventInfo = new CodeEventInfo();
                        codeEventInfo.Name     = codeEvent.Name;
                        codeEventInfo.TypeName = codeEvent.Type.AsFullName;
                        codeEventInfo.IsStatic = codeEvent.IsShared;
                        CodeEventList.Add(codeEventInfo);
                    }
                }
            }
            foreach (CodeClass baseClass in codeClass.Bases)
            {
                if (baseClass.Kind == vsCMElement.vsCMElementClass)
                {
                    parse_body(baseClass);
                    break;
                }
            }
        }
 private CodeDomEventMetadata(CodeEvent codeEvent, CodeDomFileMetadata file)
 {
     this.codeEvent = codeEvent;
     this.file = file;
 }
 /// <summary>
 /// Determines if the specified code event is an explicit interface implementation.
 /// </summary>
 /// <remarks>
 /// CodeEvent does not report the interface name as usual, but it can be identified by
 /// looking at the FullName and comparing it to the expected concatenation of parent name +
 /// event name.
 /// </remarks>
 /// <param name="codeEvent">The code event.</param>
 /// <returns>True if an explicit interface implementation, otherwise false.</returns>
 public static bool IsExplicitInterfaceImplementation(CodeEvent codeEvent)
 {
     return codeEvent != null &&
            codeEvent.Parent is CodeElement &&
            codeEvent.FullName != (((CodeElement)codeEvent.Parent).FullName + "." + codeEvent.Name);
 }
示例#28
0
 public static TypeAccess  GetTypeAccess(CodeEvent parCodeEvent)
 {
     // Треба розробити ефективніший механізм через бітові структури!!!
     return(varPermissions.GetTypeAccess(parCodeEvent));
 }
示例#29
0
        private void BeforeExpand(TreeNode parentNode, CodeEvent codeEvent)
        {
            EventNode ce = new EventNode(codeEvent, this);

            parentNode.Nodes.Add(ce);
        }
示例#30
0
 public CodeEventNodeFactory(CodeEvent @event) : base(@event as CodeElement)
 {
     _event = @event;
 }
示例#31
0
 internal ShellCodeEvent(CodeEvent @event) : base(@event as CodeElement2)
 {
     _event = @event;
 }
示例#32
0
 /// <summary>
 /// Determines if the specified code event is an explicit interface implementation.
 /// </summary>
 /// <remarks>
 /// CodeEvent does not report the interface name as usual, but it can be identified by
 /// looking at the FullName and comparing it to the expected concatenation of parent name +
 /// event name.
 /// </remarks>
 /// <param name="codeEvent">The code event.</param>
 /// <returns>True if an explicit interface implementation, otherwise false.</returns>
 public static bool IsExplicitInterfaceImplementation(CodeEvent codeEvent)
 {
     return(codeEvent != null &&
            codeEvent.Parent is CodeElement &&
            codeEvent.FullName != (((CodeElement)codeEvent.Parent).FullName + "." + codeEvent.Name));
 }
示例#33
0
 public static void Log(CodeEvent parCodeLog, int parCodeOperationLog = 0, int parCodeOperationExLog = 0, string parString = null)
 {
     WriteToFile(GlobalVar.varPathLog + @"\mid" + DateTime.Today.ToString("yyyyMMDD") + @".log", "\"" + parCodeLog.ToString().Trim() + "\"," + parCodeOperationLog.ToString().Trim() + "\"," + "\"," + parCodeOperationExLog.ToString().Trim() + "\",");
 }
示例#34
0
 void ErrorAccess(CodeEvent parCodeEvend, string varExMessage = null)
 {
     SetView(ModeInterface.ErrorAccess);
     // Необхідно очікувати завершення вводу!!! Треба подумати над реалізацією.
 }
		private static bool CheckIfCodeClassInheritsEvent(CodeClass codeClass, CodeEvent codeEvent)
		{
			List<CodeInterface> implementedInterfaces = codeClass.GetImplementedInterfaces();
			if (
				SearchService.SearchInCodeElements<CodeEvent>(implementedInterfaces.OfType<CodeElement>())
					.Any(
						p =>
						p.Name == codeEvent.Name && p.Kind == codeEvent.Kind && p.Type.AsFullName == codeEvent.Type.AsFullName
						&& p.Access == codeClass.Access))
			{
				return true;
			}
			return false;
		}
示例#36
0
 internal ShellCodeEvent(CodeEvent @event) : base(@event as CodeElement2)
 {
     _event = @event;
 }
示例#37
0
        /// <summary>
        /// Gets the declaration of the specified code event as a string.
        /// </summary>
        /// <param name="codeEvent">The code event.</param>
        /// <returns>The string declaration.</returns>
        internal static string GetEventDeclaration(CodeEvent codeEvent)
        {
            // Get the start point at the end of the attributes if there are any (vsCMPartHeader is
            // not available for events).
            var startPoint = codeEvent.Attributes.Count > 0
                ? codeEvent.GetEndPoint(vsCMPart.vsCMPartAttributesWithDelimiter)
                : codeEvent.StartPoint;

            return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"[\{;]");
        }
示例#38
0
 public CodeEventNodeFactory(CodeEvent @event) : base(@event as CodeElement)
 {
     _event = @event;
 }
示例#39
0
 public static ITypeMetadata FromCodeElement(CodeEvent codeVariable, CodeDomFileMetadata file)
 {
     return GetType(codeVariable, file);
 }
示例#40
0
 private Event ParseEvent(CodeEvent codeEvent, string currentFile)
 {
     var @event = new Event {Name = codeEvent.Name, Type = codeEvent.Type.AsString, Access = codeEvent.Access.Convert(), FileName = currentFile};
     WriteLine("ParseEvent" + " " + codeEvent.Name + " " + codeEvent.Type);
     return @event;
 }