当前位置: 首页>>代码示例>>C#>>正文


C# EventDescription类代码示例

本文整理汇总了C#中EventDescription的典型用法代码示例。如果您正苦于以下问题:C# EventDescription类的具体用法?C# EventDescription怎么用?C# EventDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventDescription类属于命名空间,在下文中一共展示了EventDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMethod

        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements)
        {
            // build the new method handler
            var view = _pythonFileNode.GetTextView();
            var textBuffer = _pythonFileNode.GetTextBuffer();
            var classDef = GetClassForEvents();
            if (classDef != null) {
                int end = classDef.Body.EndIndex;

                using (var edit = textBuffer.CreateEdit()) {
                    var text = BuildMethod(
                        eventDescription,
                        methodName,
                        new string(' ', classDef.Body.Start.Column - 1),
                        view.Options.IsConvertTabsToSpacesEnabled() ?
                            view.Options.GetIndentSize() :
                            -1);

                    edit.Insert(end, text);
                    edit.Apply();
                    return true;
                }
            }

            return false;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:26,代码来源:WpfEventBindingProvider.cs

示例2: MapIt

        public Event MapIt(Event a, EventDescription p)
        {
            // Terminating call.  Since we can return null from this function
            // we need to be ready for PetaPoco to callback later with null
            // parameters
            if (a == null)
                return current;

            // Is this the same author as the current one we're processing
            if (current != null && current.Id == a.Id)
            {
                // Yes, just add this post to the current author's collection of posts
                current.descriptions.Add(p);

                // Return null to indicate we're not done with this author yet
                return null;
            }

            // This is a different author to the current one, or this is the 
            // first time through and we don't have an author yet

            // Save the current author
            var prev = current;

            // Setup the new current author
            current = a;
            current.descriptions = new List<EventDescription>();
            current.descriptions.Add(p);

            // Return the now populated previous author (or null if first time through)
            return prev;
        }
开发者ID:nhaberl,项目名称:EventCalendarBelle,代码行数:32,代码来源:EventDescriptionMapper.cs

示例3: CreateUniqueMethodName

        public override string CreateUniqueMethodName(string objectName, EventDescription eventDescription)
        {
            string originalMethodName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name);
            string methodName = originalMethodName;

            List<CodeTypeMember> methods = GetHandlersFromActiveFile(string.Format(CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name));

            while (methods.Count > 0)
            {
                //Try to append a _# at the end until we find an unused method name
                Match match = Regex.Match(methodName, @"_\d+$");

                if (!match.Success)
                {
                    methodName = originalMethodName + "_1";
                }
                else
                {
                    int nextValue = Int32.Parse(match.Value.Substring(1)) + 1;
                    methodName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", originalMethodName, nextValue);
                }

                methods = GetHandlersFromActiveFile(methodName);
            }
            return methodName;
        }
开发者ID:X-Sharp,项目名称:XSharpPublic,代码行数:26,代码来源:XSharpEventBindingProvider.cs

示例4: BuildMethod

        private static string BuildMethod(EventDescription eventDescription, string methodName, string indentation, int tabSize) {
            StringBuilder text = new StringBuilder();
            text.AppendLine(indentation);
            text.Append(indentation);
            text.Append("def ");
            text.Append(methodName);
            text.Append('(');
            text.Append("self");
            foreach (var param in eventDescription.Parameters) {
                text.Append(", ");
                text.Append(param.Name);
            }
            text.AppendLine("):");
            if (tabSize < 0) {
                text.Append(indentation);
                text.Append("\tpass");
            } else {
                text.Append(indentation);
                text.Append(' ', tabSize);
                text.Append("pass");
            }
            text.AppendLine();

            return text.ToString();
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:25,代码来源:WpfEventBindingProvider.cs

示例5: AddEventHandler

        public override bool AddEventHandler(EventDescription eventDescription, string objectName, string methodName)
        {
            //FixMe: VladD2: Какая-то питоновская чушь! Надо разобраться и переписать.
            const string Init = "__init__";

            //This is not the most optimal solution for WPF since we will call FindLogicalNode for each event handler,
            //but it simplifies the code generation for now.

            CodeDomDocDataAdapter adapter = GetDocDataAdapterForNemerleFile();
            CodeMemberMethod      method  = null;

            //Find the __init__ method
            foreach (CodeTypeMember ctMember in adapter.TypeDeclaration.Members)
            {
                if (ctMember is CodeConstructor)
                {
                    if (ctMember.Name == Init)
                    {
                        method = ctMember as CodeMemberMethod;
                        break;
                    }
                }
            }

            if (method == null)
            {
                method = new CodeConstructor();
                method.Name = Init;
            }

            //Create a code statement which looks like: LogicalTreeHelper.FindLogicalNode(self.Root, "button1").Click += self.button1_Click
            var logicalTreeHelper        = new CodeTypeReferenceExpression  ("LogicalTreeHelper");
            var findLogicalNodeMethod    = new CodeMethodReferenceExpression(logicalTreeHelper, "FindLogicalNode");
            var selfWindow               = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Root");
            var findLogicalNodeInvoke    = new CodeMethodInvokeExpression   (findLogicalNodeMethod, selfWindow, new CodeSnippetExpression("\'" + objectName + "\'"));
            var createDelegateExpression = new CodeDelegateCreateExpression (new CodeTypeReference("System.EventHandler"), new CodeThisReferenceExpression(), methodName);
            var attachEvent              = new CodeAttachEventStatement     (findLogicalNodeInvoke, eventDescription.Name, createDelegateExpression);

            method.Statements.Add(attachEvent);
            adapter.Generate();

            return true;
        }
开发者ID:vestild,项目名称:nemerle,代码行数:43,代码来源:NemerleEventBindingProvider.cs

示例6: CreateMethod

        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements)
        {
            CodeMemberMethod method = new CodeMemberMethod();

            method.Name = methodName;

            foreach (EventParameter param in eventDescription.Parameters)
            {
                method.Parameters.Add(new CodeParameterDeclarationExpression(param.TypeName, param.Name));
            }

            //Finally, add the new method to the class

            CodeDomDocDataAdapter adapter = GetDocDataAdapterForXSharpFile();

            adapter.TypeDeclaration.Members.Add(method);
            adapter.Generate();

            return true;
        }
开发者ID:X-Sharp,项目名称:XSharpPublic,代码行数:20,代码来源:XSharpEventBindingProvider.cs

示例7: CreateMethod

        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements) {
            // build the new method handler
            var view = _pythonFileNode.GetTextView();
            var textBuffer = _pythonFileNode.GetTextBuffer();
            PythonAst ast;
            var classDef = GetClassForEvents(out ast);
            if (classDef != null) {
                int end = classDef.Body.EndIndex;
                
                // insert after the newline at the end of the last statement of the class def
                if (textBuffer.CurrentSnapshot[end] == '\r') {
                    if (end + 1 < textBuffer.CurrentSnapshot.Length &&
                        textBuffer.CurrentSnapshot[end + 1] == '\n') {
                        end += 2;
                    } else {
                        end++;
                    }
                } else if (textBuffer.CurrentSnapshot[end] == '\n') {
                    end++;
                }

                using (var edit = textBuffer.CreateEdit()) {
                    var text = BuildMethod(
                        eventDescription,
                        methodName,
                        new string(' ', classDef.Body.GetStart(ast).Column - 1),
                        view.Options.IsConvertTabsToSpacesEnabled() ?
                            view.Options.GetIndentSize() :
                            -1);

                    edit.Insert(end, text);
                    edit.Apply();
                    return true;
                }
            }


            return false;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:39,代码来源:WpfEventBindingProvider.cs

示例8: CreateMethod

        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements) {
            // build the new method handler
            var insertPoint = _callback.GetInsertionPoint(null);

            if (insertPoint != null) {
                var view = _callback.TextView;
                var textBuffer = _callback.Buffer;
                using (var edit = textBuffer.CreateEdit()) {
                    var text = BuildMethod(
                        eventDescription,
                        methodName,
                        new string(' ', insertPoint.Indentation),
                        view.Options.IsConvertTabsToSpacesEnabled() ?
                            view.Options.GetIndentSize() :
                            -1);

                    edit.Insert(insertPoint.Location, text);
                    edit.Apply();
                    return true;
                }
            }

            return false;
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:24,代码来源:WpfEventBindingProvider.cs

示例9: GetCompatibleMethods

 public override IEnumerable<string> GetCompatibleMethods(EventDescription eventDescription)
 {
     throw new NotImplementedException();
 }
开发者ID:smartmobili,项目名称:parsing,代码行数:4,代码来源:PythonEventBindingProvider.cs

示例10: getEvent

            public RESULT getEvent(GUID guid, LOADING_MODE mode, out EventDescription _event)
            {
                RESULT result   = RESULT.OK;
                IntPtr eventraw = new IntPtr();
                _event = null;

                try
                {
                result = FMOD_Studio_System_GetEvent(rawPtr, ref guid, mode, out eventraw);
                }
                catch
                {
                result = RESULT.ERR_INVALID_PARAM;
                }
                if (result != RESULT.OK)
                {
                return result;
                }

                _event = new EventDescription();
                _event.setRaw(eventraw);

                return result;
            }
开发者ID:simonchauvin,项目名称:Mapping-The-Iceberg,代码行数:24,代码来源:fmod_studio.cs

示例11: AppendStatements

 public override void AppendStatements(EventDescription eventDescription, string methodName, string statements, int relativePosition)
 {
     throw new NotImplementedException();
 }
开发者ID:smartmobili,项目名称:parsing,代码行数:4,代码来源:PythonEventBindingProvider.cs

示例12: GetCompatibleMethods

        public override IEnumerable<string> GetCompatibleMethods(EventDescription eventDescription) {
            var classDef = GetClassForEvents();
            SuiteStatement suite = classDef.Body as SuiteStatement;

            if (suite != null) {
                int requiredParamCount = eventDescription.Parameters.Count() + 1;
                foreach (var methodCandidate in suite.Statements) {
                    FunctionDefinition funcDef = methodCandidate as FunctionDefinition;
                    if (funcDef != null) {
                        // Given that event handlers can be given any arbitrary 
                        // name, it is important to not rely on the default naming 
                        // to detect compatible methods.  Instead we look at the 
                        // event parameters. We don't have param types in Python, 
                        // so really the only thing that can be done is look at 
                        // the method parameter count, which should be one more than
                        // the event parameter count (to account for the self param).
                        if (funcDef.Parameters.Count == requiredParamCount) {
                            yield return funcDef.Name;
                        }
                    }
                }
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:23,代码来源:WpfEventBindingProvider.cs

示例13: RemoveEventHandler

 public override bool RemoveEventHandler(EventDescription eventDescription, string objectName, string methodName)
 {
     throw new NotImplementedException();
 }
开发者ID:smartmobili,项目名称:parsing,代码行数:4,代码来源:PythonEventBindingProvider.cs

示例14: ShowMethod

        public override bool ShowMethod(EventDescription eventDescription, string methodName)
        {
            CodeDomDocDataAdapter adapter = GetDocDataAdapterForPyFile();
            List<CodeTypeMember> methodsToShow = GetHandlersFromActivePyFile(methodName);
            if (methodsToShow == null || methodsToShow.Count < 1)
                return false;

            Point point = new Point();
            if (methodsToShow[0] != null)
            {
                //We can't navigate to every method, so just take the first one in the list.
                object pt = methodsToShow[0].UserData[typeof(Point)];
                if (pt != null)
                {
                    point = (Point)pt;
                }
            }
            //Get IVsTextManager to navigate to the code
            IVsTextManager mgr = Package.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager;
            Guid logViewCode = VSConstants.LOGVIEWID_Code;
            return ErrorHandler.Succeeded(mgr.NavigateToLineAndColumn(adapter.DocData.Buffer, ref logViewCode, point.Y - 1, point.X, point.Y - 1, point.X));
        }
开发者ID:smartmobili,项目名称:parsing,代码行数:22,代码来源:PythonEventBindingProvider.cs

示例15: getEvent

            public RESULT getEvent(string path, out EventDescription _event)
            {
                _event = null;

                IntPtr eventraw = new IntPtr();
                RESULT result = FMOD_Studio_System_GetEvent(rawPtr, Encoding.UTF8.GetBytes(path + Char.MinValue), out eventraw);
                if (result != RESULT.OK)
                {
                return result;
                }

                _event = new EventDescription(eventraw);
                return result;
            }
开发者ID:andi2,项目名称:FireStarter,代码行数:14,代码来源:fmod_studio.cs


注:本文中的EventDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。